hoi4-agent-tools 0.2.0 → 1.1.0

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 (430) hide show
  1. package/CHANGELOG.md +21 -118
  2. package/README.md +38 -124
  3. package/SECURITY.md +5 -7
  4. package/dist/bin/http.js +0 -1
  5. package/dist/bin/setup.js +141 -92
  6. package/dist/bin/stdio.js +0 -1
  7. package/dist/hoi4_agent_tools/core/artifacts.js +0 -1
  8. package/dist/hoi4_agent_tools/core/canonical.js +0 -1
  9. package/dist/hoi4_agent_tools/core/configuration.js +28 -28
  10. package/dist/hoi4_agent_tools/core/diagnostic-collector.js +0 -1
  11. package/dist/hoi4_agent_tools/core/diagnostics.js +0 -1
  12. package/dist/hoi4_agent_tools/core/diff.js +0 -1
  13. package/dist/hoi4_agent_tools/core/engine.js +6 -21
  14. package/dist/hoi4_agent_tools/core/image-diff.js +0 -1
  15. package/dist/hoi4_agent_tools/core/index.js +0 -1
  16. package/dist/hoi4_agent_tools/core/render-budget.js +0 -1
  17. package/dist/hoi4_agent_tools/core/result.js +0 -1
  18. package/dist/hoi4_agent_tools/core/scanner.js +0 -1
  19. package/dist/hoi4_agent_tools/core/server-state.js +0 -1
  20. package/dist/hoi4_agent_tools/core/source/encoding.js +0 -1
  21. package/dist/hoi4_agent_tools/core/source/index.js +0 -1
  22. package/dist/hoi4_agent_tools/core/source/lexer.js +0 -1
  23. package/dist/hoi4_agent_tools/core/source/limits.js +0 -1
  24. package/dist/hoi4_agent_tools/core/source/localisation.js +0 -1
  25. package/dist/hoi4_agent_tools/core/source/parser.js +0 -1
  26. package/dist/hoi4_agent_tools/core/source/rewrite.js +0 -1
  27. package/dist/hoi4_agent_tools/core/svg-text.js +0 -1
  28. package/dist/hoi4_agent_tools/core/transaction-limits.js +0 -1
  29. package/dist/hoi4_agent_tools/core/transactions.js +2 -30
  30. package/dist/hoi4_agent_tools/core/workspace.js +112 -396
  31. package/dist/hoi4_agent_tools/focus/compact.js +432 -0
  32. package/dist/hoi4_agent_tools/focus/compiler.js +1 -8
  33. package/dist/hoi4_agent_tools/focus/continuous-render.js +0 -1
  34. package/dist/hoi4_agent_tools/focus/drift.js +0 -1
  35. package/dist/hoi4_agent_tools/focus/geometry.js +203 -17
  36. package/dist/hoi4_agent_tools/focus/importer.js +0 -1
  37. package/dist/hoi4_agent_tools/focus/index.js +1 -1
  38. package/dist/hoi4_agent_tools/focus/layout.js +1256 -93
  39. package/dist/hoi4_agent_tools/focus/limits.js +1 -2
  40. package/dist/hoi4_agent_tools/focus/lint.js +11 -4
  41. package/dist/hoi4_agent_tools/focus/model.js +0 -1
  42. package/dist/hoi4_agent_tools/focus/native-effects.js +0 -1
  43. package/dist/hoi4_agent_tools/focus/planning.js +6 -2
  44. package/dist/hoi4_agent_tools/focus/presentation.js +0 -1
  45. package/dist/hoi4_agent_tools/focus/render.js +14 -10
  46. package/dist/hoi4_agent_tools/focus/service.js +7 -8
  47. package/dist/hoi4_agent_tools/focus/source-update.js +1 -2
  48. package/dist/hoi4_agent_tools/gui/animation-manifest.js +0 -1
  49. package/dist/hoi4_agent_tools/gui/assets.js +0 -1
  50. package/dist/hoi4_agent_tools/gui/dds.js +0 -1
  51. package/dist/hoi4_agent_tools/gui/helpers.js +1 -2
  52. package/dist/hoi4_agent_tools/gui/index.js +0 -1
  53. package/dist/hoi4_agent_tools/gui/layout.js +0 -1
  54. package/dist/hoi4_agent_tools/gui/limits.js +0 -1
  55. package/dist/hoi4_agent_tools/gui/renderer.js +0 -1
  56. package/dist/hoi4_agent_tools/gui/scenario.js +0 -1
  57. package/dist/hoi4_agent_tools/gui/source-graph.js +0 -1
  58. package/dist/hoi4_agent_tools/gui/source-patch.js +1 -2
  59. package/dist/hoi4_agent_tools/gui/studio.js +247 -104
  60. package/dist/hoi4_agent_tools/gui/tga.js +0 -1
  61. package/dist/hoi4_agent_tools/gui/types.js +0 -1
  62. package/dist/hoi4_agent_tools/gui/validators.js +0 -1
  63. package/dist/hoi4_agent_tools/map/bmp.js +0 -1
  64. package/dist/hoi4_agent_tools/map/diagnostic-limit.js +0 -1
  65. package/dist/hoi4_agent_tools/map/index.js +0 -1
  66. package/dist/hoi4_agent_tools/map/limits.js +2 -1
  67. package/dist/hoi4_agent_tools/map/model.js +0 -1
  68. package/dist/hoi4_agent_tools/map/operations.js +0 -1
  69. package/dist/hoi4_agent_tools/map/render.js +0 -1
  70. package/dist/hoi4_agent_tools/map/service.js +171 -33
  71. package/dist/hoi4_agent_tools/map/validation.js +0 -1
  72. package/dist/hoi4_agent_tools/mcp/resources/register.js +61 -187
  73. package/dist/hoi4_agent_tools/mcp/security/auth.js +1 -2
  74. package/dist/hoi4_agent_tools/mcp/server/base-tools.js +24 -750
  75. package/dist/hoi4_agent_tools/mcp/server/context-schemas.js +8 -0
  76. package/dist/hoi4_agent_tools/mcp/server/create.js +2 -12
  77. package/dist/hoi4_agent_tools/mcp/server/output-schemas.js +0 -71
  78. package/dist/hoi4_agent_tools/mcp/server/progress.js +0 -1
  79. package/dist/hoi4_agent_tools/mcp/server/result.js +146 -81
  80. package/dist/hoi4_agent_tools/mcp/server/transaction-execution.js +10 -14
  81. package/dist/hoi4_agent_tools/mcp/tools/focus.js +309 -279
  82. package/dist/hoi4_agent_tools/mcp/tools/gui.js +156 -254
  83. package/dist/hoi4_agent_tools/mcp/tools/map.js +259 -338
  84. package/dist/hoi4_agent_tools/mcp/tools/mods.js +54 -0
  85. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js +0 -1
  86. package/dist/hoi4_agent_tools/mcp/transports/event-store.js +0 -1
  87. package/dist/hoi4_agent_tools/mcp/transports/http.js +1 -12
  88. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js +0 -1
  89. package/dist/hoi4_agent_tools/runtime.js +5 -2
  90. package/dist/hoi4_agent_tools/schemas/common.js +1 -2
  91. package/dist/hoi4_agent_tools/schemas/focus.js +64 -9
  92. package/dist/hoi4_agent_tools/schemas/map.js +0 -1
  93. package/dist/hoi4_agent_tools/schemas/transaction.js +0 -1
  94. package/dist/hoi4_agent_tools/version.js +1 -2
  95. package/docs/README.md +8 -21
  96. package/docs/development.md +22 -0
  97. package/docs/focus.md +50 -0
  98. package/docs/gui.md +37 -0
  99. package/docs/http.md +53 -0
  100. package/docs/map.md +39 -0
  101. package/docs/setup.md +39 -0
  102. package/package.json +12 -13
  103. package/server.json +3 -12
  104. package/dist/bin/http.d.ts +0 -3
  105. package/dist/bin/http.d.ts.map +0 -1
  106. package/dist/bin/http.js.map +0 -1
  107. package/dist/bin/setup.d.ts +0 -3
  108. package/dist/bin/setup.d.ts.map +0 -1
  109. package/dist/bin/setup.js.map +0 -1
  110. package/dist/bin/stdio.d.ts +0 -3
  111. package/dist/bin/stdio.d.ts.map +0 -1
  112. package/dist/bin/stdio.js.map +0 -1
  113. package/dist/hoi4_agent_tools/core/artifacts.d.ts +0 -117
  114. package/dist/hoi4_agent_tools/core/artifacts.d.ts.map +0 -1
  115. package/dist/hoi4_agent_tools/core/artifacts.js.map +0 -1
  116. package/dist/hoi4_agent_tools/core/canonical.d.ts +0 -13
  117. package/dist/hoi4_agent_tools/core/canonical.d.ts.map +0 -1
  118. package/dist/hoi4_agent_tools/core/canonical.js.map +0 -1
  119. package/dist/hoi4_agent_tools/core/configuration.d.ts +0 -138
  120. package/dist/hoi4_agent_tools/core/configuration.d.ts.map +0 -1
  121. package/dist/hoi4_agent_tools/core/configuration.js.map +0 -1
  122. package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts +0 -18
  123. package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts.map +0 -1
  124. package/dist/hoi4_agent_tools/core/diagnostic-collector.js.map +0 -1
  125. package/dist/hoi4_agent_tools/core/diagnostics.d.ts +0 -26
  126. package/dist/hoi4_agent_tools/core/diagnostics.d.ts.map +0 -1
  127. package/dist/hoi4_agent_tools/core/diagnostics.js.map +0 -1
  128. package/dist/hoi4_agent_tools/core/diff.d.ts +0 -22
  129. package/dist/hoi4_agent_tools/core/diff.d.ts.map +0 -1
  130. package/dist/hoi4_agent_tools/core/diff.js.map +0 -1
  131. package/dist/hoi4_agent_tools/core/engine.d.ts +0 -57
  132. package/dist/hoi4_agent_tools/core/engine.d.ts.map +0 -1
  133. package/dist/hoi4_agent_tools/core/engine.js.map +0 -1
  134. package/dist/hoi4_agent_tools/core/image-diff.d.ts +0 -14
  135. package/dist/hoi4_agent_tools/core/image-diff.d.ts.map +0 -1
  136. package/dist/hoi4_agent_tools/core/image-diff.js.map +0 -1
  137. package/dist/hoi4_agent_tools/core/index.d.ts +0 -64
  138. package/dist/hoi4_agent_tools/core/index.d.ts.map +0 -1
  139. package/dist/hoi4_agent_tools/core/index.js.map +0 -1
  140. package/dist/hoi4_agent_tools/core/index.public.d.ts +0 -16
  141. package/dist/hoi4_agent_tools/core/index.public.d.ts.map +0 -1
  142. package/dist/hoi4_agent_tools/core/index.public.js +0 -16
  143. package/dist/hoi4_agent_tools/core/index.public.js.map +0 -1
  144. package/dist/hoi4_agent_tools/core/render-budget.d.ts +0 -51
  145. package/dist/hoi4_agent_tools/core/render-budget.d.ts.map +0 -1
  146. package/dist/hoi4_agent_tools/core/render-budget.js.map +0 -1
  147. package/dist/hoi4_agent_tools/core/result.d.ts +0 -45
  148. package/dist/hoi4_agent_tools/core/result.d.ts.map +0 -1
  149. package/dist/hoi4_agent_tools/core/result.js.map +0 -1
  150. package/dist/hoi4_agent_tools/core/scanner.d.ts +0 -28
  151. package/dist/hoi4_agent_tools/core/scanner.d.ts.map +0 -1
  152. package/dist/hoi4_agent_tools/core/scanner.js.map +0 -1
  153. package/dist/hoi4_agent_tools/core/server-state.d.ts +0 -31
  154. package/dist/hoi4_agent_tools/core/server-state.d.ts.map +0 -1
  155. package/dist/hoi4_agent_tools/core/server-state.js.map +0 -1
  156. package/dist/hoi4_agent_tools/core/source/encoding.d.ts +0 -10
  157. package/dist/hoi4_agent_tools/core/source/encoding.d.ts.map +0 -1
  158. package/dist/hoi4_agent_tools/core/source/encoding.js.map +0 -1
  159. package/dist/hoi4_agent_tools/core/source/index.d.ts +0 -7
  160. package/dist/hoi4_agent_tools/core/source/index.d.ts.map +0 -1
  161. package/dist/hoi4_agent_tools/core/source/index.js.map +0 -1
  162. package/dist/hoi4_agent_tools/core/source/lexer.d.ts +0 -30
  163. package/dist/hoi4_agent_tools/core/source/lexer.d.ts.map +0 -1
  164. package/dist/hoi4_agent_tools/core/source/lexer.js.map +0 -1
  165. package/dist/hoi4_agent_tools/core/source/limits.d.ts +0 -21
  166. package/dist/hoi4_agent_tools/core/source/limits.d.ts.map +0 -1
  167. package/dist/hoi4_agent_tools/core/source/limits.js.map +0 -1
  168. package/dist/hoi4_agent_tools/core/source/localisation.d.ts +0 -20
  169. package/dist/hoi4_agent_tools/core/source/localisation.d.ts.map +0 -1
  170. package/dist/hoi4_agent_tools/core/source/localisation.js.map +0 -1
  171. package/dist/hoi4_agent_tools/core/source/parser.d.ts +0 -44
  172. package/dist/hoi4_agent_tools/core/source/parser.d.ts.map +0 -1
  173. package/dist/hoi4_agent_tools/core/source/parser.js.map +0 -1
  174. package/dist/hoi4_agent_tools/core/source/rewrite.d.ts +0 -10
  175. package/dist/hoi4_agent_tools/core/source/rewrite.d.ts.map +0 -1
  176. package/dist/hoi4_agent_tools/core/source/rewrite.js.map +0 -1
  177. package/dist/hoi4_agent_tools/core/svg-text.d.ts +0 -34
  178. package/dist/hoi4_agent_tools/core/svg-text.d.ts.map +0 -1
  179. package/dist/hoi4_agent_tools/core/svg-text.js.map +0 -1
  180. package/dist/hoi4_agent_tools/core/transaction-limits.d.ts +0 -9
  181. package/dist/hoi4_agent_tools/core/transaction-limits.d.ts.map +0 -1
  182. package/dist/hoi4_agent_tools/core/transaction-limits.js.map +0 -1
  183. package/dist/hoi4_agent_tools/core/transactions.d.ts +0 -164
  184. package/dist/hoi4_agent_tools/core/transactions.d.ts.map +0 -1
  185. package/dist/hoi4_agent_tools/core/transactions.js.map +0 -1
  186. package/dist/hoi4_agent_tools/core/workspace.d.ts +0 -68
  187. package/dist/hoi4_agent_tools/core/workspace.d.ts.map +0 -1
  188. package/dist/hoi4_agent_tools/core/workspace.js.map +0 -1
  189. package/dist/hoi4_agent_tools/focus/compiler.d.ts +0 -10
  190. package/dist/hoi4_agent_tools/focus/compiler.d.ts.map +0 -1
  191. package/dist/hoi4_agent_tools/focus/compiler.js.map +0 -1
  192. package/dist/hoi4_agent_tools/focus/continuous-render.d.ts +0 -32
  193. package/dist/hoi4_agent_tools/focus/continuous-render.d.ts.map +0 -1
  194. package/dist/hoi4_agent_tools/focus/continuous-render.js.map +0 -1
  195. package/dist/hoi4_agent_tools/focus/drift.d.ts +0 -22
  196. package/dist/hoi4_agent_tools/focus/drift.d.ts.map +0 -1
  197. package/dist/hoi4_agent_tools/focus/drift.js.map +0 -1
  198. package/dist/hoi4_agent_tools/focus/geometry.d.ts +0 -17
  199. package/dist/hoi4_agent_tools/focus/geometry.d.ts.map +0 -1
  200. package/dist/hoi4_agent_tools/focus/geometry.js.map +0 -1
  201. package/dist/hoi4_agent_tools/focus/importer.d.ts +0 -9
  202. package/dist/hoi4_agent_tools/focus/importer.d.ts.map +0 -1
  203. package/dist/hoi4_agent_tools/focus/importer.js.map +0 -1
  204. package/dist/hoi4_agent_tools/focus/index.d.ts +0 -14
  205. package/dist/hoi4_agent_tools/focus/index.d.ts.map +0 -1
  206. package/dist/hoi4_agent_tools/focus/index.js.map +0 -1
  207. package/dist/hoi4_agent_tools/focus/layout.d.ts +0 -5
  208. package/dist/hoi4_agent_tools/focus/layout.d.ts.map +0 -1
  209. package/dist/hoi4_agent_tools/focus/layout.js.map +0 -1
  210. package/dist/hoi4_agent_tools/focus/limits.d.ts +0 -9
  211. package/dist/hoi4_agent_tools/focus/limits.d.ts.map +0 -1
  212. package/dist/hoi4_agent_tools/focus/limits.js.map +0 -1
  213. package/dist/hoi4_agent_tools/focus/lint.d.ts +0 -14
  214. package/dist/hoi4_agent_tools/focus/lint.d.ts.map +0 -1
  215. package/dist/hoi4_agent_tools/focus/lint.js.map +0 -1
  216. package/dist/hoi4_agent_tools/focus/model.d.ts +0 -307
  217. package/dist/hoi4_agent_tools/focus/model.d.ts.map +0 -1
  218. package/dist/hoi4_agent_tools/focus/model.js.map +0 -1
  219. package/dist/hoi4_agent_tools/focus/native-effects.d.ts +0 -9
  220. package/dist/hoi4_agent_tools/focus/native-effects.d.ts.map +0 -1
  221. package/dist/hoi4_agent_tools/focus/native-effects.js.map +0 -1
  222. package/dist/hoi4_agent_tools/focus/planning.d.ts +0 -15
  223. package/dist/hoi4_agent_tools/focus/planning.d.ts.map +0 -1
  224. package/dist/hoi4_agent_tools/focus/planning.js.map +0 -1
  225. package/dist/hoi4_agent_tools/focus/presentation.d.ts +0 -24
  226. package/dist/hoi4_agent_tools/focus/presentation.d.ts.map +0 -1
  227. package/dist/hoi4_agent_tools/focus/presentation.js.map +0 -1
  228. package/dist/hoi4_agent_tools/focus/render.d.ts +0 -39
  229. package/dist/hoi4_agent_tools/focus/render.d.ts.map +0 -1
  230. package/dist/hoi4_agent_tools/focus/render.js.map +0 -1
  231. package/dist/hoi4_agent_tools/focus/service.d.ts +0 -82
  232. package/dist/hoi4_agent_tools/focus/service.d.ts.map +0 -1
  233. package/dist/hoi4_agent_tools/focus/service.js.map +0 -1
  234. package/dist/hoi4_agent_tools/focus/source-update.d.ts +0 -6
  235. package/dist/hoi4_agent_tools/focus/source-update.d.ts.map +0 -1
  236. package/dist/hoi4_agent_tools/focus/source-update.js.map +0 -1
  237. package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts +0 -37
  238. package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts.map +0 -1
  239. package/dist/hoi4_agent_tools/gui/animation-manifest.js.map +0 -1
  240. package/dist/hoi4_agent_tools/gui/assets.d.ts +0 -71
  241. package/dist/hoi4_agent_tools/gui/assets.d.ts.map +0 -1
  242. package/dist/hoi4_agent_tools/gui/assets.js.map +0 -1
  243. package/dist/hoi4_agent_tools/gui/dds.d.ts +0 -17
  244. package/dist/hoi4_agent_tools/gui/dds.d.ts.map +0 -1
  245. package/dist/hoi4_agent_tools/gui/dds.js.map +0 -1
  246. package/dist/hoi4_agent_tools/gui/helpers.d.ts +0 -101
  247. package/dist/hoi4_agent_tools/gui/helpers.d.ts.map +0 -1
  248. package/dist/hoi4_agent_tools/gui/helpers.js.map +0 -1
  249. package/dist/hoi4_agent_tools/gui/index.d.ts +0 -15
  250. package/dist/hoi4_agent_tools/gui/index.d.ts.map +0 -1
  251. package/dist/hoi4_agent_tools/gui/index.js.map +0 -1
  252. package/dist/hoi4_agent_tools/gui/layout.d.ts +0 -6
  253. package/dist/hoi4_agent_tools/gui/layout.d.ts.map +0 -1
  254. package/dist/hoi4_agent_tools/gui/layout.js.map +0 -1
  255. package/dist/hoi4_agent_tools/gui/limits.d.ts +0 -25
  256. package/dist/hoi4_agent_tools/gui/limits.d.ts.map +0 -1
  257. package/dist/hoi4_agent_tools/gui/limits.js.map +0 -1
  258. package/dist/hoi4_agent_tools/gui/renderer.d.ts +0 -18
  259. package/dist/hoi4_agent_tools/gui/renderer.d.ts.map +0 -1
  260. package/dist/hoi4_agent_tools/gui/renderer.js.map +0 -1
  261. package/dist/hoi4_agent_tools/gui/scenario.d.ts +0 -66
  262. package/dist/hoi4_agent_tools/gui/scenario.d.ts.map +0 -1
  263. package/dist/hoi4_agent_tools/gui/scenario.js.map +0 -1
  264. package/dist/hoi4_agent_tools/gui/source-graph.d.ts +0 -7
  265. package/dist/hoi4_agent_tools/gui/source-graph.d.ts.map +0 -1
  266. package/dist/hoi4_agent_tools/gui/source-graph.js.map +0 -1
  267. package/dist/hoi4_agent_tools/gui/source-patch.d.ts +0 -13
  268. package/dist/hoi4_agent_tools/gui/source-patch.d.ts.map +0 -1
  269. package/dist/hoi4_agent_tools/gui/source-patch.js.map +0 -1
  270. package/dist/hoi4_agent_tools/gui/studio.d.ts +0 -86
  271. package/dist/hoi4_agent_tools/gui/studio.d.ts.map +0 -1
  272. package/dist/hoi4_agent_tools/gui/studio.js.map +0 -1
  273. package/dist/hoi4_agent_tools/gui/tga.d.ts +0 -16
  274. package/dist/hoi4_agent_tools/gui/tga.d.ts.map +0 -1
  275. package/dist/hoi4_agent_tools/gui/tga.js.map +0 -1
  276. package/dist/hoi4_agent_tools/gui/types.d.ts +0 -322
  277. package/dist/hoi4_agent_tools/gui/types.d.ts.map +0 -1
  278. package/dist/hoi4_agent_tools/gui/types.js.map +0 -1
  279. package/dist/hoi4_agent_tools/gui/validators.d.ts +0 -8
  280. package/dist/hoi4_agent_tools/gui/validators.d.ts.map +0 -1
  281. package/dist/hoi4_agent_tools/gui/validators.js.map +0 -1
  282. package/dist/hoi4_agent_tools/map/bmp.d.ts +0 -62
  283. package/dist/hoi4_agent_tools/map/bmp.d.ts.map +0 -1
  284. package/dist/hoi4_agent_tools/map/bmp.js.map +0 -1
  285. package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts +0 -5
  286. package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts.map +0 -1
  287. package/dist/hoi4_agent_tools/map/diagnostic-limit.js.map +0 -1
  288. package/dist/hoi4_agent_tools/map/index.d.ts +0 -8
  289. package/dist/hoi4_agent_tools/map/index.d.ts.map +0 -1
  290. package/dist/hoi4_agent_tools/map/index.js.map +0 -1
  291. package/dist/hoi4_agent_tools/map/limits.d.ts +0 -13
  292. package/dist/hoi4_agent_tools/map/limits.d.ts.map +0 -1
  293. package/dist/hoi4_agent_tools/map/limits.js.map +0 -1
  294. package/dist/hoi4_agent_tools/map/model.d.ts +0 -269
  295. package/dist/hoi4_agent_tools/map/model.d.ts.map +0 -1
  296. package/dist/hoi4_agent_tools/map/model.js.map +0 -1
  297. package/dist/hoi4_agent_tools/map/operations.d.ts +0 -401
  298. package/dist/hoi4_agent_tools/map/operations.d.ts.map +0 -1
  299. package/dist/hoi4_agent_tools/map/operations.js.map +0 -1
  300. package/dist/hoi4_agent_tools/map/render.d.ts +0 -90
  301. package/dist/hoi4_agent_tools/map/render.d.ts.map +0 -1
  302. package/dist/hoi4_agent_tools/map/render.js.map +0 -1
  303. package/dist/hoi4_agent_tools/map/service.d.ts +0 -81
  304. package/dist/hoi4_agent_tools/map/service.d.ts.map +0 -1
  305. package/dist/hoi4_agent_tools/map/service.js.map +0 -1
  306. package/dist/hoi4_agent_tools/map/validation.d.ts +0 -23
  307. package/dist/hoi4_agent_tools/map/validation.d.ts.map +0 -1
  308. package/dist/hoi4_agent_tools/map/validation.js.map +0 -1
  309. package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts +0 -4
  310. package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts.map +0 -1
  311. package/dist/hoi4_agent_tools/mcp/prompts/register.js +0 -72
  312. package/dist/hoi4_agent_tools/mcp/prompts/register.js.map +0 -1
  313. package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts +0 -9
  314. package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts.map +0 -1
  315. package/dist/hoi4_agent_tools/mcp/registry/metadata.js +0 -10
  316. package/dist/hoi4_agent_tools/mcp/registry/metadata.js.map +0 -1
  317. package/dist/hoi4_agent_tools/mcp/resources/register.d.ts +0 -5
  318. package/dist/hoi4_agent_tools/mcp/resources/register.d.ts.map +0 -1
  319. package/dist/hoi4_agent_tools/mcp/resources/register.js.map +0 -1
  320. package/dist/hoi4_agent_tools/mcp/security/auth.d.ts +0 -24
  321. package/dist/hoi4_agent_tools/mcp/security/auth.d.ts.map +0 -1
  322. package/dist/hoi4_agent_tools/mcp/security/auth.js.map +0 -1
  323. package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts +0 -47
  324. package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts.map +0 -1
  325. package/dist/hoi4_agent_tools/mcp/server/base-tools.js.map +0 -1
  326. package/dist/hoi4_agent_tools/mcp/server/create.d.ts +0 -5
  327. package/dist/hoi4_agent_tools/mcp/server/create.d.ts.map +0 -1
  328. package/dist/hoi4_agent_tools/mcp/server/create.js.map +0 -1
  329. package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts +0 -138
  330. package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts.map +0 -1
  331. package/dist/hoi4_agent_tools/mcp/server/output-schemas.js.map +0 -1
  332. package/dist/hoi4_agent_tools/mcp/server/progress.d.ts +0 -8
  333. package/dist/hoi4_agent_tools/mcp/server/progress.d.ts.map +0 -1
  334. package/dist/hoi4_agent_tools/mcp/server/progress.js.map +0 -1
  335. package/dist/hoi4_agent_tools/mcp/server/result.d.ts +0 -232
  336. package/dist/hoi4_agent_tools/mcp/server/result.d.ts.map +0 -1
  337. package/dist/hoi4_agent_tools/mcp/server/result.js.map +0 -1
  338. package/dist/hoi4_agent_tools/mcp/server/transaction-execution.d.ts +0 -31
  339. package/dist/hoi4_agent_tools/mcp/server/transaction-execution.d.ts.map +0 -1
  340. package/dist/hoi4_agent_tools/mcp/server/transaction-execution.js.map +0 -1
  341. package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts +0 -5
  342. package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts.map +0 -1
  343. package/dist/hoi4_agent_tools/mcp/tools/focus.js.map +0 -1
  344. package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts +0 -117
  345. package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts.map +0 -1
  346. package/dist/hoi4_agent_tools/mcp/tools/gui.js.map +0 -1
  347. package/dist/hoi4_agent_tools/mcp/tools/map.d.ts +0 -5
  348. package/dist/hoi4_agent_tools/mcp/tools/map.d.ts.map +0 -1
  349. package/dist/hoi4_agent_tools/mcp/tools/map.js.map +0 -1
  350. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts +0 -58
  351. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts.map +0 -1
  352. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js.map +0 -1
  353. package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts +0 -26
  354. package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts.map +0 -1
  355. package/dist/hoi4_agent_tools/mcp/transports/event-store.js.map +0 -1
  356. package/dist/hoi4_agent_tools/mcp/transports/http.d.ts +0 -28
  357. package/dist/hoi4_agent_tools/mcp/transports/http.d.ts.map +0 -1
  358. package/dist/hoi4_agent_tools/mcp/transports/http.js.map +0 -1
  359. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts +0 -15
  360. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts.map +0 -1
  361. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js.map +0 -1
  362. package/dist/hoi4_agent_tools/runtime.d.ts +0 -4
  363. package/dist/hoi4_agent_tools/runtime.d.ts.map +0 -1
  364. package/dist/hoi4_agent_tools/runtime.js.map +0 -1
  365. package/dist/hoi4_agent_tools/schemas/common.d.ts +0 -74
  366. package/dist/hoi4_agent_tools/schemas/common.d.ts.map +0 -1
  367. package/dist/hoi4_agent_tools/schemas/common.js.map +0 -1
  368. package/dist/hoi4_agent_tools/schemas/focus.d.ts +0 -784
  369. package/dist/hoi4_agent_tools/schemas/focus.d.ts.map +0 -1
  370. package/dist/hoi4_agent_tools/schemas/focus.js.map +0 -1
  371. package/dist/hoi4_agent_tools/schemas/index.d.ts +0 -5
  372. package/dist/hoi4_agent_tools/schemas/index.d.ts.map +0 -1
  373. package/dist/hoi4_agent_tools/schemas/index.js +0 -5
  374. package/dist/hoi4_agent_tools/schemas/index.js.map +0 -1
  375. package/dist/hoi4_agent_tools/schemas/map.d.ts +0 -654
  376. package/dist/hoi4_agent_tools/schemas/map.d.ts.map +0 -1
  377. package/dist/hoi4_agent_tools/schemas/map.js.map +0 -1
  378. package/dist/hoi4_agent_tools/schemas/transaction.d.ts +0 -259
  379. package/dist/hoi4_agent_tools/schemas/transaction.d.ts.map +0 -1
  380. package/dist/hoi4_agent_tools/schemas/transaction.js.map +0 -1
  381. package/dist/hoi4_agent_tools/version.d.ts +0 -6
  382. package/dist/hoi4_agent_tools/version.d.ts.map +0 -1
  383. package/dist/hoi4_agent_tools/version.js.map +0 -1
  384. package/dist/index.d.ts +0 -3
  385. package/dist/index.d.ts.map +0 -1
  386. package/dist/index.js +0 -3
  387. package/dist/index.js.map +0 -1
  388. package/docs/adr/0001-runtime-and-language.md +0 -16
  389. package/docs/adr/0002-lossless-source-model.md +0 -18
  390. package/docs/adr/0003-image-and-font-codecs.md +0 -18
  391. package/docs/adr/0004-focus-layout.md +0 -16
  392. package/docs/adr/0005-offline-rendering.md +0 -18
  393. package/docs/adr/0006-mcp-sdk-and-protocol.md +0 -16
  394. package/docs/adr/0007-storage-and-transactions.md +0 -24
  395. package/docs/adr/0008-test-strategy.md +0 -18
  396. package/docs/adr/0009-packaging-and-registry.md +0 -16
  397. package/docs/adr/0010-unsupported-and-refusal-policy.md +0 -18
  398. package/docs/adr/0011-http-security.md +0 -16
  399. package/docs/adr/0012-autonomous-rewrites.md +0 -55
  400. package/docs/adr/README.md +0 -14
  401. package/docs/agent-integration.md +0 -146
  402. package/docs/architecture.md +0 -76
  403. package/docs/artifacts.md +0 -136
  404. package/docs/compatibility.md +0 -33
  405. package/docs/completion-report.md +0 -122
  406. package/docs/configuration.md +0 -305
  407. package/docs/focus-workflow.md +0 -197
  408. package/docs/gui-workflow.md +0 -125
  409. package/docs/limitations.md +0 -32
  410. package/docs/map-workflow.md +0 -95
  411. package/docs/performance.md +0 -117
  412. package/docs/release.md +0 -222
  413. package/docs/research/mcp-2026-07-10.md +0 -52
  414. package/docs/research/source-ledger.md +0 -68
  415. package/docs/security.md +0 -145
  416. package/docs/self-hosting.md +0 -170
  417. package/docs/testing.md +0 -43
  418. package/docs/third-party-notices.md +0 -11
  419. package/docs/transactions.md +0 -180
  420. package/docs/troubleshooting.md +0 -54
  421. package/schemas/configuration.schema.json +0 -795
  422. package/schemas/continuous-focus-palette.schema.json +0 -325
  423. package/schemas/focus-plan.schema.json +0 -927
  424. package/schemas/focus-planning-sidecar.schema.json +0 -379
  425. package/schemas/gui-animation-source.schema.json +0 -176
  426. package/schemas/gui-helper.schema.json +0 -301
  427. package/schemas/gui-scenario.schema.json +0 -298
  428. package/schemas/map-operation.schema.json +0 -2284
  429. package/schemas/operation-result.schema.json +0 -344
  430. package/schemas/transaction-manifest.schema.json +0 -685
@@ -0,0 +1,432 @@
1
+ import { compareCodeUnits } from '../core/canonical.js';
2
+ import { ServiceError } from '../core/result.js';
3
+ import { focusPlanHash, } from './model.js';
4
+ import { FOCUS_LAYOUT_WORK_MAX } from './limits.js';
5
+ import { FocusLayoutWorkBudget, layoutFocusTree, layoutFocusTreeAsync } from './layout.js';
6
+ const COMPACT_SAME_ROW_SPACING = 2;
7
+ const COMPACT_LANE_SPACING = 8;
8
+ const SMALL_COMPACT_SCALES = [0.2, 0.3, 0.4, 0.55, 0.7, 0.9];
9
+ const LARGE_COMPACT_SCALES = [0.55, 0.6, 0.7, 0.8];
10
+ const COMPACT_LAYOUT_WORK_MAX = FOCUS_LAYOUT_WORK_MAX * 10;
11
+ const COMPACT_HARD_DIAGNOSTICS = new Set([
12
+ 'FOCUS_LAYOUT_CONNECTOR_CROSSING_UNSATISFIED',
13
+ 'FOCUS_LAYOUT_COORDINATE_CONFLICT',
14
+ 'FOCUS_LAYOUT_LANE_BOUNDS_UNSATISFIED',
15
+ 'FOCUS_LAYOUT_MUTUAL_EXCLUSION_SPACING_UNSATISFIED',
16
+ 'FOCUS_LAYOUT_PARENT_ORDER_UNSATISFIED',
17
+ 'FOCUS_LAYOUT_SAME_ROW_SPACING_UNSATISFIED',
18
+ 'FOCUS_LAYOUT_VISIBLE_OVERLAP',
19
+ ]);
20
+ function compactLimits(focusCount, connectorCount) {
21
+ const graphScale = Math.sqrt(Math.max(1, focusCount));
22
+ const maximumHorizontalSpan = Math.max(14, Math.ceil(graphScale * 3));
23
+ const maximumVerticalSpan = Math.max(4, Math.ceil(Math.log2(Math.max(2, focusCount))));
24
+ return {
25
+ maximumColumns: Math.max(16, Math.ceil(graphScale * 5)),
26
+ maximumHorizontalSpan,
27
+ maximumVerticalSpan,
28
+ maximumManhattanSpan: maximumHorizontalSpan + maximumVerticalSpan,
29
+ maximumLongConnectors: Math.ceil(connectorCount * 0.05),
30
+ maximumNodeIntersections: Math.ceil(connectorCount * 0.12),
31
+ maximumSiblingDeviation: Math.max(2, Math.ceil(graphScale * 2)),
32
+ maximumTotalSiblingDeviation: Math.max(4, Math.ceil(focusCount * 0.5)),
33
+ };
34
+ }
35
+ function requiredMetrics(layout) {
36
+ if (layout.metrics !== undefined)
37
+ return layout.metrics;
38
+ throw new ServiceError('FOCUS_COMPACT_METRICS_REQUIRED', 'Compact focus reflow requires current layout quality metrics', { treeId: layout.treeId });
39
+ }
40
+ function absoluteCompactRegressions(layout) {
41
+ const metrics = requiredMetrics(layout);
42
+ const limits = compactLimits(layout.nodes.length, metrics.connectors.count);
43
+ return [
44
+ ...(layout.diagnostics.some(({ code }) => COMPACT_HARD_DIAGNOSTICS.has(code))
45
+ ? ['hardLayoutDiagnostics']
46
+ : []),
47
+ ...(metrics.connectors.crossingCount > 0 ? ['connectorCrossingCount'] : []),
48
+ ...(metrics.connectors.nodeIntersectionCount > limits.maximumNodeIntersections
49
+ ? ['connectorNodeIntersectionBudget']
50
+ : []),
51
+ ...(metrics.spacing.tooCloseSameRowPairCount > 0 ? ['sameRowSpacing'] : []),
52
+ ...(metrics.symmetry.maximumSiblingDeviation > 1 ? ['siblingMirrorDeviation'] : []),
53
+ ...(metrics.symmetry.totalSiblingDeviation > metrics.symmetry.siblingCohortCount
54
+ ? ['totalSiblingMirrorDeviation']
55
+ : []),
56
+ ...(metrics.symmetry.maximumSiblingAnchorDeviation > limits.maximumSiblingDeviation
57
+ ? ['maximumSiblingDeviationBudget']
58
+ : []),
59
+ ...(metrics.symmetry.totalSiblingAnchorDeviation > limits.maximumTotalSiblingDeviation
60
+ ? ['totalSiblingDeviationBudget']
61
+ : []),
62
+ ...(metrics.symmetry.boundingCenterOffsetTwice > 1 ? ['boundingCenter'] : []),
63
+ ...(metrics.bounds.columnCount > limits.maximumColumns ? ['columnBudget'] : []),
64
+ ...(metrics.connectors.maximumHorizontalSpan > limits.maximumHorizontalSpan
65
+ ? ['maximumHorizontalConnectorBudget']
66
+ : []),
67
+ ...(metrics.connectors.maximumVerticalSpan > limits.maximumVerticalSpan
68
+ ? ['maximumVerticalConnectorBudget']
69
+ : []),
70
+ ...(metrics.connectors.maximumManhattanSpan > limits.maximumManhattanSpan
71
+ ? ['maximumManhattanConnectorBudget']
72
+ : []),
73
+ ...(metrics.connectors.longConnectorCount > limits.maximumLongConnectors
74
+ ? ['longConnectorBudget']
75
+ : []),
76
+ ];
77
+ }
78
+ function relativeCompactRegressions(current, proposed) {
79
+ const before = requiredMetrics(current);
80
+ const after = requiredMetrics(proposed);
81
+ return [
82
+ ...(after.connectors.crossingCount > before.connectors.crossingCount
83
+ ? ['connectorCrossingCount']
84
+ : []),
85
+ ...(after.connectors.nodeIntersectionCount > before.connectors.nodeIntersectionCount
86
+ ? ['connectorNodeIntersectionCount']
87
+ : []),
88
+ ...(after.connectors.maximumHorizontalSpan > before.connectors.maximumHorizontalSpan
89
+ ? ['maximumHorizontalConnectorSpan']
90
+ : []),
91
+ ...(after.connectors.maximumVerticalSpan > before.connectors.maximumVerticalSpan
92
+ ? ['maximumVerticalConnectorSpan']
93
+ : []),
94
+ ...(after.connectors.maximumManhattanSpan > before.connectors.maximumManhattanSpan
95
+ ? ['maximumManhattanConnectorSpan']
96
+ : []),
97
+ ...(after.connectors.longConnectorCount > before.connectors.longConnectorCount
98
+ ? ['longConnectorCount']
99
+ : []),
100
+ ...(after.connectors.totalHorizontalSpan > before.connectors.totalHorizontalSpan
101
+ ? ['totalHorizontalConnectorSpan']
102
+ : []),
103
+ ...(after.connectors.totalManhattanSpan > before.connectors.totalManhattanSpan
104
+ ? ['totalManhattanConnectorSpan']
105
+ : []),
106
+ ...(after.bounds.columnCount > before.bounds.columnCount ? ['columnCount'] : []),
107
+ ...(after.bounds.rowCount > before.bounds.rowCount ? ['rowCount'] : []),
108
+ ];
109
+ }
110
+ function compactShape(plan, layout) {
111
+ return (plan.focuses.every(({ position }) => position.mode === 'auto') &&
112
+ plan.laneGroups.every(({ minimumX, maximumX }) => minimumX === undefined && maximumX === undefined) &&
113
+ absoluteCompactRegressions(layout).length === 0);
114
+ }
115
+ function prerequisiteIds(plan, focusId) {
116
+ const focus = plan.focuses.find(({ id }) => id === focusId);
117
+ return (focus?.prerequisites.groups
118
+ .flatMap(({ focusIds }) => focusIds)
119
+ .sort((left, right) => compareCodeUnits(left, right)) ?? []);
120
+ }
121
+ function focusLaneId(plan, focus) {
122
+ if (focus.laneId !== undefined)
123
+ return focus.laneId;
124
+ if (focus.branchId !== undefined) {
125
+ const branch = plan.branchGroups.find(({ id }) => id === focus.branchId);
126
+ return branch?.laneId ?? focus.branchId;
127
+ }
128
+ return 'default';
129
+ }
130
+ function compactLaneBases(plan) {
131
+ const configured = [...plan.laneGroups].sort((left, right) => left.order - right.order || compareCodeUnits(left.id, right.id));
132
+ const configuredIds = new Set(configured.map(({ id }) => id));
133
+ const discovered = [...new Set(plan.focuses.map((focus) => focusLaneId(plan, focus)))]
134
+ .filter((id) => !configuredIds.has(id))
135
+ .sort((left, right) => compareCodeUnits(left, right));
136
+ const laneIds = [...configured.map(({ id }) => id), ...discovered];
137
+ return new Map(laneIds.map((id, index) => [
138
+ id,
139
+ Math.round((index - (laneIds.length - 1) / 2) * COMPACT_LANE_SPACING),
140
+ ]));
141
+ }
142
+ function compactStructuralAnchorX(plan, focus, parents, preferredX, laneBases) {
143
+ const parentCoordinates = parents
144
+ .flatMap((focusId) => {
145
+ const coordinate = preferredX.get(focusId);
146
+ return coordinate === undefined ? [] : [coordinate];
147
+ })
148
+ .sort((left, right) => left - right);
149
+ if (parentCoordinates.length > 1 && focus.convergence) {
150
+ return Math.floor(parentCoordinates.reduce((total, coordinate) => total + coordinate, 0) /
151
+ parentCoordinates.length);
152
+ }
153
+ if (parentCoordinates.length > 0) {
154
+ const middle = Math.floor(parentCoordinates.length / 2);
155
+ if (parentCoordinates.length % 2 === 1)
156
+ return parentCoordinates[middle] ?? 0;
157
+ return Math.floor(((parentCoordinates[middle - 1] ?? 0) + (parentCoordinates[middle] ?? 0)) / 2);
158
+ }
159
+ return laneBases.get(focusLaneId(plan, focus)) ?? 0;
160
+ }
161
+ function mirrorSiblingCohorts(plan, preferredX, preferredY) {
162
+ const cohorts = new Map();
163
+ const laneBases = compactLaneBases(plan);
164
+ const childCounts = new Map();
165
+ for (const focus of plan.focuses) {
166
+ const parents = prerequisiteIds(plan, focus.id);
167
+ for (const parentId of parents)
168
+ childCounts.set(parentId, (childCounts.get(parentId) ?? 0) + 1);
169
+ const key = JSON.stringify([
170
+ parents.length === 0 ? focusLaneId(plan, focus) : null,
171
+ parents,
172
+ preferredY.get(focus.id) ?? 0,
173
+ ]);
174
+ const cohort = cohorts.get(key) ?? [];
175
+ cohort.push(focus.id);
176
+ cohorts.set(key, cohort);
177
+ }
178
+ for (const cohort of cohorts.values()) {
179
+ if (cohort.length < 2)
180
+ continue;
181
+ cohort.sort((left, right) => (preferredX.get(left) ?? 0) - (preferredX.get(right) ?? 0) || compareCodeUnits(left, right));
182
+ const coordinates = cohort.map((id) => preferredX.get(id) ?? 0);
183
+ const pairCount = Math.floor(coordinates.length / 2);
184
+ const focus = plan.focuses.find(({ id }) => id === cohort[0]);
185
+ if (focus === undefined)
186
+ continue;
187
+ // A leaf fan can be mirrored directly around its structural parent. For
188
+ // rooted subtrees, moving only the entry focuses would push the long
189
+ // connectors into their descendants; keep the subtree envelope's center
190
+ // until the bounded gateway refinement can move the common parent.
191
+ const leafFan = cohort.every((focusId) => (childCounts.get(focusId) ?? 0) === 0);
192
+ const mirroredAt = (centerTwice) => {
193
+ const mirrored = [...coordinates];
194
+ for (let index = 0; index < pairCount; index += 1) {
195
+ const opposite = coordinates.length - 1 - index;
196
+ const left = Math.round(((coordinates[index] ?? 0) + centerTwice - (coordinates[opposite] ?? 0)) / 2);
197
+ mirrored[index] = left;
198
+ mirrored[opposite] = centerTwice - left;
199
+ }
200
+ if (coordinates.length % 2 === 1)
201
+ mirrored[pairCount] = Math.round(centerTwice / 2);
202
+ let maximumLeft = centerTwice / 2 - (coordinates.length % 2 === 1 ? 2 : 1);
203
+ for (let index = pairCount - 1; index >= 0; index -= 1) {
204
+ const opposite = coordinates.length - 1 - index;
205
+ const left = Math.min(mirrored[index] ?? maximumLeft, maximumLeft);
206
+ mirrored[index] = left;
207
+ mirrored[opposite] = centerTwice - left;
208
+ maximumLeft = left - COMPACT_SAME_ROW_SPACING;
209
+ }
210
+ return mirrored;
211
+ };
212
+ const selfCenterTwice = (coordinates[0] ?? 0) + (coordinates.at(-1) ?? 0);
213
+ const anchorCenterTwice = 2 *
214
+ compactStructuralAnchorX(plan, focus, prerequisiteIds(plan, focus.id), preferredX, laneBases);
215
+ let mirrored = mirroredAt(leafFan ? anchorCenterTwice : selfCenterTwice);
216
+ if (leafFan) {
217
+ const cohortIds = new Set(cohort);
218
+ const y = preferredY.get(cohort[0] ?? '');
219
+ const otherCoordinates = plan.focuses.flatMap((candidate) => !cohortIds.has(candidate.id) && preferredY.get(candidate.id) === y
220
+ ? [preferredX.get(candidate.id) ?? 0]
221
+ : []);
222
+ if (mirrored.some((coordinate) => otherCoordinates.some((otherCoordinate) => Math.abs(coordinate - otherCoordinate) < COMPACT_SAME_ROW_SPACING))) {
223
+ mirrored = mirroredAt(selfCenterTwice);
224
+ }
225
+ }
226
+ for (const [index, focusId] of cohort.entries())
227
+ preferredX.set(focusId, mirrored[index] ?? 0);
228
+ }
229
+ }
230
+ function compactCandidate(plan, layout, scale, compressRows) {
231
+ const minimumX = Math.min(...layout.nodes.map(({ x }) => x));
232
+ const maximumX = Math.max(...layout.nodes.map(({ x }) => x));
233
+ const minimumY = Math.min(...layout.nodes.map(({ y }) => y));
234
+ const centerX = (minimumX + maximumX) / 2;
235
+ const preferredX = new Map(layout.nodes.map((node) => [node.id, Math.round((node.x - centerX) * scale)]));
236
+ const sourceRows = [...new Set(layout.nodes.map(({ y }) => y))].sort((left, right) => left - right);
237
+ const compactRows = new Map(sourceRows.map((row, index) => [row, index]));
238
+ const preferredY = new Map(layout.nodes.map((node) => [
239
+ node.id,
240
+ compressRows ? (compactRows.get(node.y) ?? node.y - minimumY) : node.y - minimumY,
241
+ ]));
242
+ const rows = new Map();
243
+ for (const node of layout.nodes) {
244
+ const row = rows.get(node.y) ?? [];
245
+ row.push(node);
246
+ rows.set(node.y, row);
247
+ }
248
+ for (const row of rows.values()) {
249
+ row.sort((left, right) => left.x - right.x || compareCodeUnits(left.id, right.id));
250
+ const placed = [];
251
+ for (const [index, node] of row.entries()) {
252
+ const requested = preferredX.get(node.id) ?? 0;
253
+ placed.push(index === 0
254
+ ? requested
255
+ : Math.max(requested, (placed[index - 1] ?? 0) + COMPACT_SAME_ROW_SPACING));
256
+ }
257
+ const drift = Math.round(row.reduce((total, node, index) => total + (preferredX.get(node.id) ?? 0) - (placed[index] ?? 0), 0) / row.length);
258
+ for (const [index, node] of row.entries())
259
+ preferredX.set(node.id, (placed[index] ?? 0) + drift);
260
+ }
261
+ mirrorSiblingCohorts(plan, preferredX, preferredY);
262
+ const compacted = structuredClone(plan);
263
+ compacted.laneGroups = compacted.laneGroups.map(({ id, label, order }) => ({
264
+ id,
265
+ label,
266
+ order,
267
+ }));
268
+ for (const focus of compacted.focuses) {
269
+ focus.position = {
270
+ mode: 'auto',
271
+ pinned: false,
272
+ preferredX: preferredX.get(focus.id) ?? 0,
273
+ preferredY: preferredY.get(focus.id) ?? 0,
274
+ };
275
+ }
276
+ compacted.provenance.importedPlanHash = focusPlanHash(compacted);
277
+ return compacted;
278
+ }
279
+ function compactScore(layout) {
280
+ const metrics = requiredMetrics(layout);
281
+ return [
282
+ metrics.connectors.longConnectorCount,
283
+ metrics.connectors.maximumHorizontalSpan,
284
+ metrics.bounds.columnCount,
285
+ metrics.connectors.nodeIntersectionCount,
286
+ metrics.connectors.totalHorizontalSpan,
287
+ metrics.connectors.maximumManhattanSpan,
288
+ metrics.bounds.rowCount,
289
+ metrics.connectors.totalVerticalSpan,
290
+ layout.layoutHash,
291
+ ];
292
+ }
293
+ function betterScore(candidate, current) {
294
+ for (let index = 0; index < candidate.length; index += 1) {
295
+ const left = candidate[index];
296
+ const right = current[index];
297
+ if (left === right)
298
+ continue;
299
+ if (typeof left === 'number' && typeof right === 'number')
300
+ return left < right;
301
+ return String(left) < String(right);
302
+ }
303
+ return false;
304
+ }
305
+ function compactScales(focusCount) {
306
+ return focusCount <= 50
307
+ ? SMALL_COMPACT_SCALES
308
+ : focusCount <= 500
309
+ ? LARGE_COMPACT_SCALES
310
+ : focusCount <= 2_000
311
+ ? [0.55, 0.65, 0.75]
312
+ : [0.65];
313
+ }
314
+ /**
315
+ * Produces a gameplay-neutral compact-reflow plan. Several deterministic
316
+ * compression candidates are measured with the same layout engine; only a
317
+ * centered, crossing-free, evenly spaced, branch-balanced candidate that
318
+ * stays within absolute and source-relative connector budgets can win.
319
+ */
320
+ export function compactFocusTreePlan(plan) {
321
+ const currentLayout = layoutFocusTree(plan);
322
+ if (compactShape(plan, currentLayout)) {
323
+ const stable = structuredClone(plan);
324
+ stable.provenance.importedPlanHash = focusPlanHash(stable);
325
+ return stable;
326
+ }
327
+ const scales = compactScales(plan.focuses.length);
328
+ let selected;
329
+ let fallback;
330
+ for (const scale of scales) {
331
+ for (const compressRows of plan.focuses.length <= 500 ? [false, true] : [false]) {
332
+ const candidate = compactCandidate(plan, currentLayout, scale, compressRows);
333
+ let layout;
334
+ try {
335
+ layout = layoutFocusTree(candidate);
336
+ }
337
+ catch (error) {
338
+ if (error instanceof ServiceError && error.code === 'FOCUS_LAYOUT_WORK_BUDGET_BLOCKED')
339
+ continue;
340
+ throw error;
341
+ }
342
+ if (fallback === undefined ||
343
+ betterScore(compactScore(layout), compactScore(fallback.layout)))
344
+ fallback = { plan: candidate, layout };
345
+ if (absoluteCompactRegressions(layout).length > 0 ||
346
+ relativeCompactRegressions(currentLayout, layout).length > 0)
347
+ continue;
348
+ if (selected === undefined ||
349
+ betterScore(compactScore(layout), compactScore(selected.layout)))
350
+ selected = { plan: candidate, layout };
351
+ }
352
+ }
353
+ if (selected !== undefined)
354
+ return selected.plan;
355
+ if (fallback !== undefined) {
356
+ assertCompactLayoutQuality(currentLayout, fallback.layout);
357
+ return fallback.plan;
358
+ }
359
+ throw new ServiceError('FOCUS_COMPACT_LAYOUT_REQUIRED', 'Compact focus planning did not produce a measurable layout candidate', { treeId: plan.id });
360
+ }
361
+ /**
362
+ * Cooperative compact planning for protocol handlers. Candidate layouts share
363
+ * one work budget, and the selected layout is returned for validation/rendering.
364
+ */
365
+ export async function compactFocusTreePlanAsync(plan, options = {}) {
366
+ const workBudget = new FocusLayoutWorkBudget(options.maximumWork ?? COMPACT_LAYOUT_WORK_MAX);
367
+ const layoutOptions = {
368
+ workBudget,
369
+ ...(options.signal === undefined ? {} : { signal: options.signal }),
370
+ };
371
+ const currentLayout = await layoutFocusTreeAsync(plan, layoutOptions);
372
+ if (compactShape(plan, currentLayout)) {
373
+ const stable = structuredClone(plan);
374
+ stable.provenance.importedPlanHash = focusPlanHash(stable);
375
+ return { plan: stable, currentLayout, proposedLayout: currentLayout };
376
+ }
377
+ let selected;
378
+ let fallback;
379
+ let exhausted;
380
+ candidateSearch: for (const scale of compactScales(plan.focuses.length)) {
381
+ for (const compressRows of plan.focuses.length <= 500 ? [false, true] : [false]) {
382
+ options.signal?.throwIfAborted();
383
+ const candidate = compactCandidate(plan, currentLayout, scale, compressRows);
384
+ let layout;
385
+ try {
386
+ layout = await layoutFocusTreeAsync(candidate, layoutOptions);
387
+ }
388
+ catch (error) {
389
+ if (error instanceof ServiceError && error.code === 'FOCUS_LAYOUT_WORK_BUDGET_BLOCKED') {
390
+ exhausted = error;
391
+ break candidateSearch;
392
+ }
393
+ throw error;
394
+ }
395
+ if (fallback === undefined ||
396
+ betterScore(compactScore(layout), compactScore(fallback.layout)))
397
+ fallback = { plan: candidate, layout };
398
+ if (absoluteCompactRegressions(layout).length > 0 ||
399
+ relativeCompactRegressions(currentLayout, layout).length > 0)
400
+ continue;
401
+ if (selected === undefined ||
402
+ betterScore(compactScore(layout), compactScore(selected.layout)))
403
+ selected = { plan: candidate, layout };
404
+ }
405
+ }
406
+ if (selected !== undefined) {
407
+ return { plan: selected.plan, currentLayout, proposedLayout: selected.layout };
408
+ }
409
+ if (exhausted !== undefined)
410
+ throw exhausted;
411
+ if (fallback !== undefined) {
412
+ assertCompactLayoutQuality(currentLayout, fallback.layout);
413
+ return { plan: fallback.plan, currentLayout, proposedLayout: fallback.layout };
414
+ }
415
+ throw new ServiceError('FOCUS_COMPACT_LAYOUT_REQUIRED', 'Compact focus planning did not produce a measurable layout candidate', { treeId: plan.id });
416
+ }
417
+ /** Refuses compact rewrites that are not clean or trade readability for a smaller canvas. */
418
+ export function assertCompactLayoutQuality(current, proposed) {
419
+ const regressions = [
420
+ ...absoluteCompactRegressions(proposed),
421
+ ...(current === undefined ? [] : relativeCompactRegressions(current, proposed)),
422
+ ].filter((value, index, all) => all.indexOf(value) === index);
423
+ if (regressions.length === 0)
424
+ return;
425
+ throw new ServiceError('FOCUS_COMPACT_QUALITY_BLOCKED', 'Compact focus reflow failed the absolute or relative layout-quality gate', {
426
+ treeId: proposed.treeId,
427
+ regressions,
428
+ limits: compactLimits(proposed.nodes.length, requiredMetrics(proposed).connectors.count),
429
+ ...(current === undefined ? {} : { before: requiredMetrics(current) }),
430
+ proposed: requiredMetrics(proposed),
431
+ });
432
+ }
@@ -90,13 +90,7 @@ function positionLines(focus, layout) {
90
90
  if (focus.position.mode === 'fixed') {
91
91
  return [`x = ${focus.position.x}`, `y = ${focus.position.y}`];
92
92
  }
93
- const placed = layoutNodeMap(layout ?? {
94
- treeId: '',
95
- nodes: [],
96
- decisions: [],
97
- diagnostics: [],
98
- layoutHash: '',
99
- }).get(focus.id);
93
+ const placed = layout === undefined ? undefined : layoutNodeMap(layout).get(focus.id);
100
94
  if (placed === undefined) {
101
95
  throw new ServiceError('FOCUS_LAYOUT_REQUIRED', `Automatic focus ${focus.id} has no layout position`, {
102
96
  focusId: focus.id,
@@ -280,4 +274,3 @@ export function compileContinuousFocusPaletteWithSourceMap(plan, generatedPath =
280
274
  },
281
275
  };
282
276
  }
283
- //# sourceMappingURL=compiler.js.map
@@ -176,4 +176,3 @@ export async function storeContinuousFocusRenderArtifacts(workspace, store, plan
176
176
  }));
177
177
  return store.withAtomicChunkedWrites(workspace, writes, (stored) => Promise.resolve([...stored]), options.signal);
178
178
  }
179
- //# sourceMappingURL=continuous-render.js.map
@@ -121,4 +121,3 @@ export function detectContinuousFocusDrift(savedPlan, currentDocument) {
121
121
  currentSourcePlan,
122
122
  };
123
123
  }
124
- //# sourceMappingURL=drift.js.map