hoi4-agent-tools 0.2.0 → 1.0.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 (428) hide show
  1. package/CHANGELOG.md +12 -118
  2. package/README.md +35 -127
  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/compiler.js +0 -1
  32. package/dist/hoi4_agent_tools/focus/continuous-render.js +0 -1
  33. package/dist/hoi4_agent_tools/focus/drift.js +0 -1
  34. package/dist/hoi4_agent_tools/focus/geometry.js +0 -1
  35. package/dist/hoi4_agent_tools/focus/importer.js +0 -1
  36. package/dist/hoi4_agent_tools/focus/index.js +0 -1
  37. package/dist/hoi4_agent_tools/focus/layout.js +0 -1
  38. package/dist/hoi4_agent_tools/focus/limits.js +0 -1
  39. package/dist/hoi4_agent_tools/focus/lint.js +0 -1
  40. package/dist/hoi4_agent_tools/focus/model.js +0 -1
  41. package/dist/hoi4_agent_tools/focus/native-effects.js +0 -1
  42. package/dist/hoi4_agent_tools/focus/planning.js +0 -1
  43. package/dist/hoi4_agent_tools/focus/presentation.js +0 -1
  44. package/dist/hoi4_agent_tools/focus/render.js +0 -1
  45. package/dist/hoi4_agent_tools/focus/service.js +7 -8
  46. package/dist/hoi4_agent_tools/focus/source-update.js +1 -2
  47. package/dist/hoi4_agent_tools/gui/animation-manifest.js +0 -1
  48. package/dist/hoi4_agent_tools/gui/assets.js +0 -1
  49. package/dist/hoi4_agent_tools/gui/dds.js +0 -1
  50. package/dist/hoi4_agent_tools/gui/helpers.js +1 -2
  51. package/dist/hoi4_agent_tools/gui/index.js +0 -1
  52. package/dist/hoi4_agent_tools/gui/layout.js +0 -1
  53. package/dist/hoi4_agent_tools/gui/limits.js +0 -1
  54. package/dist/hoi4_agent_tools/gui/renderer.js +0 -1
  55. package/dist/hoi4_agent_tools/gui/scenario.js +0 -1
  56. package/dist/hoi4_agent_tools/gui/source-graph.js +0 -1
  57. package/dist/hoi4_agent_tools/gui/source-patch.js +1 -2
  58. package/dist/hoi4_agent_tools/gui/studio.js +247 -104
  59. package/dist/hoi4_agent_tools/gui/tga.js +0 -1
  60. package/dist/hoi4_agent_tools/gui/types.js +0 -1
  61. package/dist/hoi4_agent_tools/gui/validators.js +0 -1
  62. package/dist/hoi4_agent_tools/map/bmp.js +0 -1
  63. package/dist/hoi4_agent_tools/map/diagnostic-limit.js +0 -1
  64. package/dist/hoi4_agent_tools/map/index.js +0 -1
  65. package/dist/hoi4_agent_tools/map/limits.js +2 -1
  66. package/dist/hoi4_agent_tools/map/model.js +0 -1
  67. package/dist/hoi4_agent_tools/map/operations.js +0 -1
  68. package/dist/hoi4_agent_tools/map/render.js +0 -1
  69. package/dist/hoi4_agent_tools/map/service.js +171 -33
  70. package/dist/hoi4_agent_tools/map/validation.js +0 -1
  71. package/dist/hoi4_agent_tools/mcp/resources/register.js +61 -187
  72. package/dist/hoi4_agent_tools/mcp/security/auth.js +1 -2
  73. package/dist/hoi4_agent_tools/mcp/server/base-tools.js +24 -750
  74. package/dist/hoi4_agent_tools/mcp/server/create.js +3 -12
  75. package/dist/hoi4_agent_tools/mcp/server/output-schemas.js +0 -71
  76. package/dist/hoi4_agent_tools/mcp/server/progress.js +0 -1
  77. package/dist/hoi4_agent_tools/mcp/server/result.js +24 -30
  78. package/dist/hoi4_agent_tools/mcp/server/transaction-execution.js +10 -14
  79. package/dist/hoi4_agent_tools/mcp/tools/focus.js +219 -275
  80. package/dist/hoi4_agent_tools/mcp/tools/gui.js +149 -250
  81. package/dist/hoi4_agent_tools/mcp/tools/map.js +256 -337
  82. package/dist/hoi4_agent_tools/mcp/tools/mods.js +54 -0
  83. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js +0 -1
  84. package/dist/hoi4_agent_tools/mcp/transports/event-store.js +0 -1
  85. package/dist/hoi4_agent_tools/mcp/transports/http.js +1 -12
  86. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js +0 -1
  87. package/dist/hoi4_agent_tools/runtime.js +5 -2
  88. package/dist/hoi4_agent_tools/schemas/common.js +1 -2
  89. package/dist/hoi4_agent_tools/schemas/focus.js +0 -1
  90. package/dist/hoi4_agent_tools/schemas/map.js +0 -1
  91. package/dist/hoi4_agent_tools/schemas/transaction.js +0 -1
  92. package/dist/hoi4_agent_tools/version.js +1 -2
  93. package/docs/README.md +8 -21
  94. package/docs/development.md +22 -0
  95. package/docs/focus.md +40 -0
  96. package/docs/gui.md +37 -0
  97. package/docs/http.md +53 -0
  98. package/docs/map.md +39 -0
  99. package/docs/setup.md +39 -0
  100. package/package.json +10 -11
  101. package/server.json +3 -12
  102. package/dist/bin/http.d.ts +0 -3
  103. package/dist/bin/http.d.ts.map +0 -1
  104. package/dist/bin/http.js.map +0 -1
  105. package/dist/bin/setup.d.ts +0 -3
  106. package/dist/bin/setup.d.ts.map +0 -1
  107. package/dist/bin/setup.js.map +0 -1
  108. package/dist/bin/stdio.d.ts +0 -3
  109. package/dist/bin/stdio.d.ts.map +0 -1
  110. package/dist/bin/stdio.js.map +0 -1
  111. package/dist/hoi4_agent_tools/core/artifacts.d.ts +0 -117
  112. package/dist/hoi4_agent_tools/core/artifacts.d.ts.map +0 -1
  113. package/dist/hoi4_agent_tools/core/artifacts.js.map +0 -1
  114. package/dist/hoi4_agent_tools/core/canonical.d.ts +0 -13
  115. package/dist/hoi4_agent_tools/core/canonical.d.ts.map +0 -1
  116. package/dist/hoi4_agent_tools/core/canonical.js.map +0 -1
  117. package/dist/hoi4_agent_tools/core/configuration.d.ts +0 -138
  118. package/dist/hoi4_agent_tools/core/configuration.d.ts.map +0 -1
  119. package/dist/hoi4_agent_tools/core/configuration.js.map +0 -1
  120. package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts +0 -18
  121. package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts.map +0 -1
  122. package/dist/hoi4_agent_tools/core/diagnostic-collector.js.map +0 -1
  123. package/dist/hoi4_agent_tools/core/diagnostics.d.ts +0 -26
  124. package/dist/hoi4_agent_tools/core/diagnostics.d.ts.map +0 -1
  125. package/dist/hoi4_agent_tools/core/diagnostics.js.map +0 -1
  126. package/dist/hoi4_agent_tools/core/diff.d.ts +0 -22
  127. package/dist/hoi4_agent_tools/core/diff.d.ts.map +0 -1
  128. package/dist/hoi4_agent_tools/core/diff.js.map +0 -1
  129. package/dist/hoi4_agent_tools/core/engine.d.ts +0 -57
  130. package/dist/hoi4_agent_tools/core/engine.d.ts.map +0 -1
  131. package/dist/hoi4_agent_tools/core/engine.js.map +0 -1
  132. package/dist/hoi4_agent_tools/core/image-diff.d.ts +0 -14
  133. package/dist/hoi4_agent_tools/core/image-diff.d.ts.map +0 -1
  134. package/dist/hoi4_agent_tools/core/image-diff.js.map +0 -1
  135. package/dist/hoi4_agent_tools/core/index.d.ts +0 -64
  136. package/dist/hoi4_agent_tools/core/index.d.ts.map +0 -1
  137. package/dist/hoi4_agent_tools/core/index.js.map +0 -1
  138. package/dist/hoi4_agent_tools/core/index.public.d.ts +0 -16
  139. package/dist/hoi4_agent_tools/core/index.public.d.ts.map +0 -1
  140. package/dist/hoi4_agent_tools/core/index.public.js +0 -16
  141. package/dist/hoi4_agent_tools/core/index.public.js.map +0 -1
  142. package/dist/hoi4_agent_tools/core/render-budget.d.ts +0 -51
  143. package/dist/hoi4_agent_tools/core/render-budget.d.ts.map +0 -1
  144. package/dist/hoi4_agent_tools/core/render-budget.js.map +0 -1
  145. package/dist/hoi4_agent_tools/core/result.d.ts +0 -45
  146. package/dist/hoi4_agent_tools/core/result.d.ts.map +0 -1
  147. package/dist/hoi4_agent_tools/core/result.js.map +0 -1
  148. package/dist/hoi4_agent_tools/core/scanner.d.ts +0 -28
  149. package/dist/hoi4_agent_tools/core/scanner.d.ts.map +0 -1
  150. package/dist/hoi4_agent_tools/core/scanner.js.map +0 -1
  151. package/dist/hoi4_agent_tools/core/server-state.d.ts +0 -31
  152. package/dist/hoi4_agent_tools/core/server-state.d.ts.map +0 -1
  153. package/dist/hoi4_agent_tools/core/server-state.js.map +0 -1
  154. package/dist/hoi4_agent_tools/core/source/encoding.d.ts +0 -10
  155. package/dist/hoi4_agent_tools/core/source/encoding.d.ts.map +0 -1
  156. package/dist/hoi4_agent_tools/core/source/encoding.js.map +0 -1
  157. package/dist/hoi4_agent_tools/core/source/index.d.ts +0 -7
  158. package/dist/hoi4_agent_tools/core/source/index.d.ts.map +0 -1
  159. package/dist/hoi4_agent_tools/core/source/index.js.map +0 -1
  160. package/dist/hoi4_agent_tools/core/source/lexer.d.ts +0 -30
  161. package/dist/hoi4_agent_tools/core/source/lexer.d.ts.map +0 -1
  162. package/dist/hoi4_agent_tools/core/source/lexer.js.map +0 -1
  163. package/dist/hoi4_agent_tools/core/source/limits.d.ts +0 -21
  164. package/dist/hoi4_agent_tools/core/source/limits.d.ts.map +0 -1
  165. package/dist/hoi4_agent_tools/core/source/limits.js.map +0 -1
  166. package/dist/hoi4_agent_tools/core/source/localisation.d.ts +0 -20
  167. package/dist/hoi4_agent_tools/core/source/localisation.d.ts.map +0 -1
  168. package/dist/hoi4_agent_tools/core/source/localisation.js.map +0 -1
  169. package/dist/hoi4_agent_tools/core/source/parser.d.ts +0 -44
  170. package/dist/hoi4_agent_tools/core/source/parser.d.ts.map +0 -1
  171. package/dist/hoi4_agent_tools/core/source/parser.js.map +0 -1
  172. package/dist/hoi4_agent_tools/core/source/rewrite.d.ts +0 -10
  173. package/dist/hoi4_agent_tools/core/source/rewrite.d.ts.map +0 -1
  174. package/dist/hoi4_agent_tools/core/source/rewrite.js.map +0 -1
  175. package/dist/hoi4_agent_tools/core/svg-text.d.ts +0 -34
  176. package/dist/hoi4_agent_tools/core/svg-text.d.ts.map +0 -1
  177. package/dist/hoi4_agent_tools/core/svg-text.js.map +0 -1
  178. package/dist/hoi4_agent_tools/core/transaction-limits.d.ts +0 -9
  179. package/dist/hoi4_agent_tools/core/transaction-limits.d.ts.map +0 -1
  180. package/dist/hoi4_agent_tools/core/transaction-limits.js.map +0 -1
  181. package/dist/hoi4_agent_tools/core/transactions.d.ts +0 -164
  182. package/dist/hoi4_agent_tools/core/transactions.d.ts.map +0 -1
  183. package/dist/hoi4_agent_tools/core/transactions.js.map +0 -1
  184. package/dist/hoi4_agent_tools/core/workspace.d.ts +0 -68
  185. package/dist/hoi4_agent_tools/core/workspace.d.ts.map +0 -1
  186. package/dist/hoi4_agent_tools/core/workspace.js.map +0 -1
  187. package/dist/hoi4_agent_tools/focus/compiler.d.ts +0 -10
  188. package/dist/hoi4_agent_tools/focus/compiler.d.ts.map +0 -1
  189. package/dist/hoi4_agent_tools/focus/compiler.js.map +0 -1
  190. package/dist/hoi4_agent_tools/focus/continuous-render.d.ts +0 -32
  191. package/dist/hoi4_agent_tools/focus/continuous-render.d.ts.map +0 -1
  192. package/dist/hoi4_agent_tools/focus/continuous-render.js.map +0 -1
  193. package/dist/hoi4_agent_tools/focus/drift.d.ts +0 -22
  194. package/dist/hoi4_agent_tools/focus/drift.d.ts.map +0 -1
  195. package/dist/hoi4_agent_tools/focus/drift.js.map +0 -1
  196. package/dist/hoi4_agent_tools/focus/geometry.d.ts +0 -17
  197. package/dist/hoi4_agent_tools/focus/geometry.d.ts.map +0 -1
  198. package/dist/hoi4_agent_tools/focus/geometry.js.map +0 -1
  199. package/dist/hoi4_agent_tools/focus/importer.d.ts +0 -9
  200. package/dist/hoi4_agent_tools/focus/importer.d.ts.map +0 -1
  201. package/dist/hoi4_agent_tools/focus/importer.js.map +0 -1
  202. package/dist/hoi4_agent_tools/focus/index.d.ts +0 -14
  203. package/dist/hoi4_agent_tools/focus/index.d.ts.map +0 -1
  204. package/dist/hoi4_agent_tools/focus/index.js.map +0 -1
  205. package/dist/hoi4_agent_tools/focus/layout.d.ts +0 -5
  206. package/dist/hoi4_agent_tools/focus/layout.d.ts.map +0 -1
  207. package/dist/hoi4_agent_tools/focus/layout.js.map +0 -1
  208. package/dist/hoi4_agent_tools/focus/limits.d.ts +0 -9
  209. package/dist/hoi4_agent_tools/focus/limits.d.ts.map +0 -1
  210. package/dist/hoi4_agent_tools/focus/limits.js.map +0 -1
  211. package/dist/hoi4_agent_tools/focus/lint.d.ts +0 -14
  212. package/dist/hoi4_agent_tools/focus/lint.d.ts.map +0 -1
  213. package/dist/hoi4_agent_tools/focus/lint.js.map +0 -1
  214. package/dist/hoi4_agent_tools/focus/model.d.ts +0 -307
  215. package/dist/hoi4_agent_tools/focus/model.d.ts.map +0 -1
  216. package/dist/hoi4_agent_tools/focus/model.js.map +0 -1
  217. package/dist/hoi4_agent_tools/focus/native-effects.d.ts +0 -9
  218. package/dist/hoi4_agent_tools/focus/native-effects.d.ts.map +0 -1
  219. package/dist/hoi4_agent_tools/focus/native-effects.js.map +0 -1
  220. package/dist/hoi4_agent_tools/focus/planning.d.ts +0 -15
  221. package/dist/hoi4_agent_tools/focus/planning.d.ts.map +0 -1
  222. package/dist/hoi4_agent_tools/focus/planning.js.map +0 -1
  223. package/dist/hoi4_agent_tools/focus/presentation.d.ts +0 -24
  224. package/dist/hoi4_agent_tools/focus/presentation.d.ts.map +0 -1
  225. package/dist/hoi4_agent_tools/focus/presentation.js.map +0 -1
  226. package/dist/hoi4_agent_tools/focus/render.d.ts +0 -39
  227. package/dist/hoi4_agent_tools/focus/render.d.ts.map +0 -1
  228. package/dist/hoi4_agent_tools/focus/render.js.map +0 -1
  229. package/dist/hoi4_agent_tools/focus/service.d.ts +0 -82
  230. package/dist/hoi4_agent_tools/focus/service.d.ts.map +0 -1
  231. package/dist/hoi4_agent_tools/focus/service.js.map +0 -1
  232. package/dist/hoi4_agent_tools/focus/source-update.d.ts +0 -6
  233. package/dist/hoi4_agent_tools/focus/source-update.d.ts.map +0 -1
  234. package/dist/hoi4_agent_tools/focus/source-update.js.map +0 -1
  235. package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts +0 -37
  236. package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts.map +0 -1
  237. package/dist/hoi4_agent_tools/gui/animation-manifest.js.map +0 -1
  238. package/dist/hoi4_agent_tools/gui/assets.d.ts +0 -71
  239. package/dist/hoi4_agent_tools/gui/assets.d.ts.map +0 -1
  240. package/dist/hoi4_agent_tools/gui/assets.js.map +0 -1
  241. package/dist/hoi4_agent_tools/gui/dds.d.ts +0 -17
  242. package/dist/hoi4_agent_tools/gui/dds.d.ts.map +0 -1
  243. package/dist/hoi4_agent_tools/gui/dds.js.map +0 -1
  244. package/dist/hoi4_agent_tools/gui/helpers.d.ts +0 -101
  245. package/dist/hoi4_agent_tools/gui/helpers.d.ts.map +0 -1
  246. package/dist/hoi4_agent_tools/gui/helpers.js.map +0 -1
  247. package/dist/hoi4_agent_tools/gui/index.d.ts +0 -15
  248. package/dist/hoi4_agent_tools/gui/index.d.ts.map +0 -1
  249. package/dist/hoi4_agent_tools/gui/index.js.map +0 -1
  250. package/dist/hoi4_agent_tools/gui/layout.d.ts +0 -6
  251. package/dist/hoi4_agent_tools/gui/layout.d.ts.map +0 -1
  252. package/dist/hoi4_agent_tools/gui/layout.js.map +0 -1
  253. package/dist/hoi4_agent_tools/gui/limits.d.ts +0 -25
  254. package/dist/hoi4_agent_tools/gui/limits.d.ts.map +0 -1
  255. package/dist/hoi4_agent_tools/gui/limits.js.map +0 -1
  256. package/dist/hoi4_agent_tools/gui/renderer.d.ts +0 -18
  257. package/dist/hoi4_agent_tools/gui/renderer.d.ts.map +0 -1
  258. package/dist/hoi4_agent_tools/gui/renderer.js.map +0 -1
  259. package/dist/hoi4_agent_tools/gui/scenario.d.ts +0 -66
  260. package/dist/hoi4_agent_tools/gui/scenario.d.ts.map +0 -1
  261. package/dist/hoi4_agent_tools/gui/scenario.js.map +0 -1
  262. package/dist/hoi4_agent_tools/gui/source-graph.d.ts +0 -7
  263. package/dist/hoi4_agent_tools/gui/source-graph.d.ts.map +0 -1
  264. package/dist/hoi4_agent_tools/gui/source-graph.js.map +0 -1
  265. package/dist/hoi4_agent_tools/gui/source-patch.d.ts +0 -13
  266. package/dist/hoi4_agent_tools/gui/source-patch.d.ts.map +0 -1
  267. package/dist/hoi4_agent_tools/gui/source-patch.js.map +0 -1
  268. package/dist/hoi4_agent_tools/gui/studio.d.ts +0 -86
  269. package/dist/hoi4_agent_tools/gui/studio.d.ts.map +0 -1
  270. package/dist/hoi4_agent_tools/gui/studio.js.map +0 -1
  271. package/dist/hoi4_agent_tools/gui/tga.d.ts +0 -16
  272. package/dist/hoi4_agent_tools/gui/tga.d.ts.map +0 -1
  273. package/dist/hoi4_agent_tools/gui/tga.js.map +0 -1
  274. package/dist/hoi4_agent_tools/gui/types.d.ts +0 -322
  275. package/dist/hoi4_agent_tools/gui/types.d.ts.map +0 -1
  276. package/dist/hoi4_agent_tools/gui/types.js.map +0 -1
  277. package/dist/hoi4_agent_tools/gui/validators.d.ts +0 -8
  278. package/dist/hoi4_agent_tools/gui/validators.d.ts.map +0 -1
  279. package/dist/hoi4_agent_tools/gui/validators.js.map +0 -1
  280. package/dist/hoi4_agent_tools/map/bmp.d.ts +0 -62
  281. package/dist/hoi4_agent_tools/map/bmp.d.ts.map +0 -1
  282. package/dist/hoi4_agent_tools/map/bmp.js.map +0 -1
  283. package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts +0 -5
  284. package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts.map +0 -1
  285. package/dist/hoi4_agent_tools/map/diagnostic-limit.js.map +0 -1
  286. package/dist/hoi4_agent_tools/map/index.d.ts +0 -8
  287. package/dist/hoi4_agent_tools/map/index.d.ts.map +0 -1
  288. package/dist/hoi4_agent_tools/map/index.js.map +0 -1
  289. package/dist/hoi4_agent_tools/map/limits.d.ts +0 -13
  290. package/dist/hoi4_agent_tools/map/limits.d.ts.map +0 -1
  291. package/dist/hoi4_agent_tools/map/limits.js.map +0 -1
  292. package/dist/hoi4_agent_tools/map/model.d.ts +0 -269
  293. package/dist/hoi4_agent_tools/map/model.d.ts.map +0 -1
  294. package/dist/hoi4_agent_tools/map/model.js.map +0 -1
  295. package/dist/hoi4_agent_tools/map/operations.d.ts +0 -401
  296. package/dist/hoi4_agent_tools/map/operations.d.ts.map +0 -1
  297. package/dist/hoi4_agent_tools/map/operations.js.map +0 -1
  298. package/dist/hoi4_agent_tools/map/render.d.ts +0 -90
  299. package/dist/hoi4_agent_tools/map/render.d.ts.map +0 -1
  300. package/dist/hoi4_agent_tools/map/render.js.map +0 -1
  301. package/dist/hoi4_agent_tools/map/service.d.ts +0 -81
  302. package/dist/hoi4_agent_tools/map/service.d.ts.map +0 -1
  303. package/dist/hoi4_agent_tools/map/service.js.map +0 -1
  304. package/dist/hoi4_agent_tools/map/validation.d.ts +0 -23
  305. package/dist/hoi4_agent_tools/map/validation.d.ts.map +0 -1
  306. package/dist/hoi4_agent_tools/map/validation.js.map +0 -1
  307. package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts +0 -4
  308. package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts.map +0 -1
  309. package/dist/hoi4_agent_tools/mcp/prompts/register.js +0 -72
  310. package/dist/hoi4_agent_tools/mcp/prompts/register.js.map +0 -1
  311. package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts +0 -9
  312. package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts.map +0 -1
  313. package/dist/hoi4_agent_tools/mcp/registry/metadata.js +0 -10
  314. package/dist/hoi4_agent_tools/mcp/registry/metadata.js.map +0 -1
  315. package/dist/hoi4_agent_tools/mcp/resources/register.d.ts +0 -5
  316. package/dist/hoi4_agent_tools/mcp/resources/register.d.ts.map +0 -1
  317. package/dist/hoi4_agent_tools/mcp/resources/register.js.map +0 -1
  318. package/dist/hoi4_agent_tools/mcp/security/auth.d.ts +0 -24
  319. package/dist/hoi4_agent_tools/mcp/security/auth.d.ts.map +0 -1
  320. package/dist/hoi4_agent_tools/mcp/security/auth.js.map +0 -1
  321. package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts +0 -47
  322. package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts.map +0 -1
  323. package/dist/hoi4_agent_tools/mcp/server/base-tools.js.map +0 -1
  324. package/dist/hoi4_agent_tools/mcp/server/create.d.ts +0 -5
  325. package/dist/hoi4_agent_tools/mcp/server/create.d.ts.map +0 -1
  326. package/dist/hoi4_agent_tools/mcp/server/create.js.map +0 -1
  327. package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts +0 -138
  328. package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts.map +0 -1
  329. package/dist/hoi4_agent_tools/mcp/server/output-schemas.js.map +0 -1
  330. package/dist/hoi4_agent_tools/mcp/server/progress.d.ts +0 -8
  331. package/dist/hoi4_agent_tools/mcp/server/progress.d.ts.map +0 -1
  332. package/dist/hoi4_agent_tools/mcp/server/progress.js.map +0 -1
  333. package/dist/hoi4_agent_tools/mcp/server/result.d.ts +0 -232
  334. package/dist/hoi4_agent_tools/mcp/server/result.d.ts.map +0 -1
  335. package/dist/hoi4_agent_tools/mcp/server/result.js.map +0 -1
  336. package/dist/hoi4_agent_tools/mcp/server/transaction-execution.d.ts +0 -31
  337. package/dist/hoi4_agent_tools/mcp/server/transaction-execution.d.ts.map +0 -1
  338. package/dist/hoi4_agent_tools/mcp/server/transaction-execution.js.map +0 -1
  339. package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts +0 -5
  340. package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts.map +0 -1
  341. package/dist/hoi4_agent_tools/mcp/tools/focus.js.map +0 -1
  342. package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts +0 -117
  343. package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts.map +0 -1
  344. package/dist/hoi4_agent_tools/mcp/tools/gui.js.map +0 -1
  345. package/dist/hoi4_agent_tools/mcp/tools/map.d.ts +0 -5
  346. package/dist/hoi4_agent_tools/mcp/tools/map.d.ts.map +0 -1
  347. package/dist/hoi4_agent_tools/mcp/tools/map.js.map +0 -1
  348. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts +0 -58
  349. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts.map +0 -1
  350. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js.map +0 -1
  351. package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts +0 -26
  352. package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts.map +0 -1
  353. package/dist/hoi4_agent_tools/mcp/transports/event-store.js.map +0 -1
  354. package/dist/hoi4_agent_tools/mcp/transports/http.d.ts +0 -28
  355. package/dist/hoi4_agent_tools/mcp/transports/http.d.ts.map +0 -1
  356. package/dist/hoi4_agent_tools/mcp/transports/http.js.map +0 -1
  357. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts +0 -15
  358. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts.map +0 -1
  359. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js.map +0 -1
  360. package/dist/hoi4_agent_tools/runtime.d.ts +0 -4
  361. package/dist/hoi4_agent_tools/runtime.d.ts.map +0 -1
  362. package/dist/hoi4_agent_tools/runtime.js.map +0 -1
  363. package/dist/hoi4_agent_tools/schemas/common.d.ts +0 -74
  364. package/dist/hoi4_agent_tools/schemas/common.d.ts.map +0 -1
  365. package/dist/hoi4_agent_tools/schemas/common.js.map +0 -1
  366. package/dist/hoi4_agent_tools/schemas/focus.d.ts +0 -784
  367. package/dist/hoi4_agent_tools/schemas/focus.d.ts.map +0 -1
  368. package/dist/hoi4_agent_tools/schemas/focus.js.map +0 -1
  369. package/dist/hoi4_agent_tools/schemas/index.d.ts +0 -5
  370. package/dist/hoi4_agent_tools/schemas/index.d.ts.map +0 -1
  371. package/dist/hoi4_agent_tools/schemas/index.js +0 -5
  372. package/dist/hoi4_agent_tools/schemas/index.js.map +0 -1
  373. package/dist/hoi4_agent_tools/schemas/map.d.ts +0 -654
  374. package/dist/hoi4_agent_tools/schemas/map.d.ts.map +0 -1
  375. package/dist/hoi4_agent_tools/schemas/map.js.map +0 -1
  376. package/dist/hoi4_agent_tools/schemas/transaction.d.ts +0 -259
  377. package/dist/hoi4_agent_tools/schemas/transaction.d.ts.map +0 -1
  378. package/dist/hoi4_agent_tools/schemas/transaction.js.map +0 -1
  379. package/dist/hoi4_agent_tools/version.d.ts +0 -6
  380. package/dist/hoi4_agent_tools/version.d.ts.map +0 -1
  381. package/dist/hoi4_agent_tools/version.js.map +0 -1
  382. package/dist/index.d.ts +0 -3
  383. package/dist/index.d.ts.map +0 -1
  384. package/dist/index.js +0 -3
  385. package/dist/index.js.map +0 -1
  386. package/docs/adr/0001-runtime-and-language.md +0 -16
  387. package/docs/adr/0002-lossless-source-model.md +0 -18
  388. package/docs/adr/0003-image-and-font-codecs.md +0 -18
  389. package/docs/adr/0004-focus-layout.md +0 -16
  390. package/docs/adr/0005-offline-rendering.md +0 -18
  391. package/docs/adr/0006-mcp-sdk-and-protocol.md +0 -16
  392. package/docs/adr/0007-storage-and-transactions.md +0 -24
  393. package/docs/adr/0008-test-strategy.md +0 -18
  394. package/docs/adr/0009-packaging-and-registry.md +0 -16
  395. package/docs/adr/0010-unsupported-and-refusal-policy.md +0 -18
  396. package/docs/adr/0011-http-security.md +0 -16
  397. package/docs/adr/0012-autonomous-rewrites.md +0 -55
  398. package/docs/adr/README.md +0 -14
  399. package/docs/agent-integration.md +0 -146
  400. package/docs/architecture.md +0 -76
  401. package/docs/artifacts.md +0 -136
  402. package/docs/compatibility.md +0 -33
  403. package/docs/completion-report.md +0 -122
  404. package/docs/configuration.md +0 -305
  405. package/docs/focus-workflow.md +0 -197
  406. package/docs/gui-workflow.md +0 -125
  407. package/docs/limitations.md +0 -32
  408. package/docs/map-workflow.md +0 -95
  409. package/docs/performance.md +0 -117
  410. package/docs/release.md +0 -222
  411. package/docs/research/mcp-2026-07-10.md +0 -52
  412. package/docs/research/source-ledger.md +0 -68
  413. package/docs/security.md +0 -145
  414. package/docs/self-hosting.md +0 -170
  415. package/docs/testing.md +0 -43
  416. package/docs/third-party-notices.md +0 -11
  417. package/docs/transactions.md +0 -180
  418. package/docs/troubleshooting.md +0 -54
  419. package/schemas/configuration.schema.json +0 -795
  420. package/schemas/continuous-focus-palette.schema.json +0 -325
  421. package/schemas/focus-plan.schema.json +0 -927
  422. package/schemas/focus-planning-sidecar.schema.json +0 -379
  423. package/schemas/gui-animation-source.schema.json +0 -176
  424. package/schemas/gui-helper.schema.json +0 -301
  425. package/schemas/gui-scenario.schema.json +0 -298
  426. package/schemas/map-operation.schema.json +0 -2284
  427. package/schemas/operation-result.schema.json +0 -344
  428. package/schemas/transaction-manifest.schema.json +0 -685
@@ -1,115 +1,12 @@
1
- import { z } from 'zod/v4';
2
- import { compareCodeUnits, canonicalJson, sha256Bytes } from '../../core/canonical.js';
3
1
  import { boundedSourceHashEvidence, publicArtifactLink } from '../../core/artifacts.js';
4
- import { workspaceRegistrationSchema } from '../../core/configuration.js';
5
- import { emptyServiceResult, ServiceError } from '../../core/result.js';
2
+ import { canonicalJson } from '../../core/canonical.js';
3
+ import { ServiceError } from '../../core/result.js';
6
4
  import { parseClausewitz } from '../../core/source/index.js';
7
5
  import { TRANSACTION_MAX_DIAGNOSTICS } from '../../core/transaction-limits.js';
8
6
  import { importContinuousFocusPalettes, importFocusTrees, layoutFocusTreeAsync, lintContinuousFocusPalette, lintFocusTree, } from '../../focus/index.js';
9
7
  import { ScriptedGuiStudio } from '../../gui/index.js';
10
8
  import { AgentNudger, attributeMapValidationDiagnostics } from '../../map/index.js';
11
9
  import { PACKAGE_VERSION } from '../../version.js';
12
- import { artifactDescriptionSchema, indexSkippedSourceSchema, nonNegativeIntegerSchema, sha256Schema, transactionIdSchema, transactionStateDataSchema, transactionStateSchema, WORKSPACE_INLINE_OWNER_PATHS, WORKSPACE_INLINE_REPLACE_PATHS, workspaceStatusSchema, } from './output-schemas.js';
13
- import { errorResult, setInlineFilesScanned, strictOperationResultSchema, toolResult, } from './result.js';
14
- import { progressReporter } from './progress.js';
15
- import { artifactLinkSchema } from '../../schemas/transaction.js';
16
- const projectRegisterOutputSchema = strictOperationResultSchema(z.object({ workspace: workspaceStatusSchema }).strict());
17
- const projectStatusOutputSchema = strictOperationResultSchema(z
18
- .object({
19
- count: nonNegativeIntegerSchema,
20
- returned: nonNegativeIntegerSchema,
21
- workspaces: z.array(workspaceStatusSchema).max(1),
22
- nextCursor: z.string().max(4096).optional(),
23
- })
24
- .strict());
25
- const projectScanOutputSchema = strictOperationResultSchema(z
26
- .object({
27
- revision: sha256Schema,
28
- complete: z.boolean(),
29
- skippedSourceCount: nonNegativeIntegerSchema,
30
- skippedSources: z.array(indexSkippedSourceSchema).max(100),
31
- symbols: nonNegativeIntegerSchema,
32
- references: nonNegativeIntegerSchema,
33
- unresolvedReferences: nonNegativeIntegerSchema,
34
- symbolCounts: z.record(z.string().max(256), nonNegativeIntegerSchema),
35
- })
36
- .strict());
37
- const transactionStatusOutputSchema = strictOperationResultSchema(z
38
- .object({
39
- manifest: z
40
- .object({
41
- version: z.number().int().positive(),
42
- transactionId: transactionIdSchema,
43
- createdAt: z.iso.datetime(),
44
- expiresAt: z.iso.datetime(),
45
- state: transactionStateSchema,
46
- operationKind: z.string().min(1).max(256),
47
- operationCount: nonNegativeIntegerSchema,
48
- readDependencyCount: nonNegativeIntegerSchema,
49
- fileCount: nonNegativeIntegerSchema,
50
- diagnosticCount: nonNegativeIntegerSchema,
51
- artifactCount: nonNegativeIntegerSchema,
52
- appliedFileCount: nonNegativeIntegerSchema,
53
- rollbackStatus: z.enum(['available', 'applied', 'failed']),
54
- failure: z
55
- .object({ code: z.string().max(256), message: z.string().max(4096) })
56
- .strict()
57
- .nullable(),
58
- })
59
- .strict(),
60
- })
61
- .strict());
62
- const transactionDiffOutputSchema = strictOperationResultSchema(z
63
- .object({
64
- files: z
65
- .array(z
66
- .object({
67
- relativePath: z.string().min(1).max(1024),
68
- operationIdCount: nonNegativeIntegerSchema,
69
- operationIds: z.array(z.string().min(1).max(256)).max(20),
70
- beforeSha256: sha256Schema.nullable(),
71
- afterSha256: sha256Schema.nullable(),
72
- beforeSize: nonNegativeIntegerSchema.nullable(),
73
- afterSize: nonNegativeIntegerSchema.nullable(),
74
- mediaType: z.string().min(1).max(255),
75
- diffArtifact: artifactLinkSchema.optional(),
76
- })
77
- .strict())
78
- .max(20),
79
- operations: z
80
- .array(z
81
- .object({
82
- id: z.string().min(1).max(256),
83
- kind: z.string().min(1).max(256),
84
- summary: z.string().max(4096),
85
- })
86
- .strict())
87
- .max(20),
88
- fileCount: nonNegativeIntegerSchema,
89
- operationCount: nonNegativeIntegerSchema,
90
- artifactCount: nonNegativeIntegerSchema,
91
- returnedFiles: nonNegativeIntegerSchema,
92
- returnedOperations: nonNegativeIntegerSchema,
93
- returnedArtifacts: nonNegativeIntegerSchema,
94
- nextCursor: z.string().max(4096).optional(),
95
- expiresAt: z.iso.datetime(),
96
- })
97
- .strict());
98
- const transactionMutationOutputSchema = strictOperationResultSchema(transactionStateDataSchema
99
- .extend({
100
- fileCount: nonNegativeIntegerSchema.optional(),
101
- appliedFileCount: nonNegativeIntegerSchema.optional(),
102
- artifactCount: nonNegativeIntegerSchema.optional(),
103
- })
104
- .strict());
105
- const artifactListOutputSchema = strictOperationResultSchema(z
106
- .object({
107
- count: nonNegativeIntegerSchema,
108
- returned: nonNegativeIntegerSchema,
109
- nextCursor: z.string().max(4096).optional(),
110
- })
111
- .strict());
112
- const artifactDescribeOutputSchema = strictOperationResultSchema(z.object({ artifact: artifactDescriptionSchema }).strict());
113
10
  export function requireServerScope(context, scope) {
114
11
  if (context.scopes !== undefined && !context.scopes.includes(scope)) {
115
12
  throw new ServiceError('AUTH_SCOPE_REQUIRED', `This operation requires the ${scope} scope`, {
@@ -117,135 +14,10 @@ export function requireServerScope(context, scope) {
117
14
  });
118
15
  }
119
16
  }
120
- const workspaceInput = z.object({ workspaceId: z.string().min(1).max(64) }).strict();
121
- const transactionInput = workspaceInput
122
- .extend({ transactionId: transactionIdSchema, expectedPlanHash: sha256Schema })
123
- .strict();
124
17
  function sourcePathComparisonKey(value) {
125
18
  const normalized = value.replaceAll('\\', '/');
126
19
  return process.platform === 'win32' ? normalized.toLocaleLowerCase('en-US') : normalized;
127
20
  }
128
- const readOnly = {
129
- readOnlyHint: true,
130
- destructiveHint: false,
131
- idempotentHint: true,
132
- openWorldHint: false,
133
- };
134
- const artifactProducing = {
135
- readOnlyHint: false,
136
- destructiveHint: false,
137
- idempotentHint: true,
138
- openWorldHint: false,
139
- };
140
- const artifactCursorSchema = z
141
- .object({ version: z.literal(1), revision: sha256Schema, after: z.string().min(1).max(2048) })
142
- .strict();
143
- const workspaceCursorSchema = z
144
- .object({ version: z.literal(1), revision: sha256Schema, after: z.string().min(1).max(64) })
145
- .strict();
146
- const transactionDiffCursorSchema = z
147
- .object({
148
- version: z.literal(1),
149
- planHash: sha256Schema,
150
- fileOffset: nonNegativeIntegerSchema,
151
- operationOffset: nonNegativeIntegerSchema,
152
- artifactOffset: nonNegativeIntegerSchema,
153
- })
154
- .strict();
155
- function encodeArtifactCursor(revision, after) {
156
- return Buffer.from(canonicalJson({ version: 1, revision, after }), 'utf8').toString('base64url');
157
- }
158
- function decodeArtifactCursor(cursor) {
159
- try {
160
- if (!/^[A-Za-z0-9_-]+$/u.test(cursor))
161
- throw new Error('invalid base64url');
162
- const decoded = Buffer.from(cursor, 'base64url');
163
- if (decoded.toString('base64url') !== cursor)
164
- throw new Error('non-canonical base64url');
165
- return artifactCursorSchema.parse(JSON.parse(decoded.toString('utf8')));
166
- }
167
- catch {
168
- throw new ServiceError('ARTIFACT_CURSOR_INVALID', 'Artifact list cursor is invalid');
169
- }
170
- }
171
- function encodeWorkspaceCursor(revision, after) {
172
- return Buffer.from(canonicalJson({ version: 1, revision, after }), 'utf8').toString('base64url');
173
- }
174
- function decodeWorkspaceCursor(cursor) {
175
- try {
176
- if (!/^[A-Za-z0-9_-]+$/u.test(cursor))
177
- throw new Error('invalid base64url');
178
- const decoded = Buffer.from(cursor, 'base64url');
179
- if (decoded.toString('base64url') !== cursor)
180
- throw new Error('non-canonical base64url');
181
- return workspaceCursorSchema.parse(JSON.parse(decoded.toString('utf8')));
182
- }
183
- catch {
184
- throw new ServiceError('WORKSPACE_CURSOR_INVALID', 'Workspace status cursor is invalid');
185
- }
186
- }
187
- function encodeTransactionDiffCursor(planHash, fileOffset, operationOffset, artifactOffset) {
188
- return Buffer.from(canonicalJson({
189
- version: 1,
190
- planHash,
191
- fileOffset,
192
- operationOffset,
193
- artifactOffset,
194
- }), 'utf8').toString('base64url');
195
- }
196
- function decodeTransactionDiffCursor(cursor) {
197
- try {
198
- if (!/^[A-Za-z0-9_-]+$/u.test(cursor))
199
- throw new Error('invalid base64url');
200
- const decoded = Buffer.from(cursor, 'base64url');
201
- if (decoded.toString('base64url') !== cursor)
202
- throw new Error('non-canonical base64url');
203
- return transactionDiffCursorSchema.parse(JSON.parse(decoded.toString('utf8')));
204
- }
205
- catch {
206
- throw new ServiceError('TRANSACTION_CURSOR_INVALID', 'Transaction diff cursor is invalid');
207
- }
208
- }
209
- export function transactionResourceLink(manifest) {
210
- return {
211
- uri: `hoi4-agent://workspace/${encodeURIComponent(manifest.workspaceId)}/transaction/${encodeURIComponent(manifest.transactionId)}`,
212
- name: `${manifest.transactionId}.manifest.json`,
213
- mimeType: 'application/json',
214
- description: 'Complete authenticated transaction manifest and rollback status',
215
- };
216
- }
217
- export function compactWorkspaceStatus(status) {
218
- return {
219
- ...status,
220
- replacePathCount: status.replacePaths.length,
221
- replacePaths: status.replacePaths.slice(0, WORKSPACE_INLINE_REPLACE_PATHS),
222
- replacePathsTruncated: status.replacePaths.length > WORKSPACE_INLINE_REPLACE_PATHS,
223
- replacementOwners: status.replacementOwners.map((owner) => ({
224
- ...owner,
225
- pathCount: owner.paths.length,
226
- paths: owner.paths.slice(0, WORKSPACE_INLINE_OWNER_PATHS),
227
- pathsTruncated: owner.paths.length > WORKSPACE_INLINE_OWNER_PATHS,
228
- })),
229
- };
230
- }
231
- function transactionSummary(manifest) {
232
- return {
233
- version: manifest.version,
234
- transactionId: manifest.transactionId,
235
- createdAt: manifest.createdAt,
236
- expiresAt: manifest.expiresAt,
237
- state: manifest.state,
238
- operationKind: manifest.operationKind,
239
- operationCount: manifest.operations.length,
240
- readDependencyCount: manifest.readDependencies.length,
241
- fileCount: manifest.files.length,
242
- diagnosticCount: manifest.diagnostics.length,
243
- artifactCount: manifest.artifacts.length,
244
- appliedFileCount: manifest.appliedFiles.length,
245
- rollbackStatus: manifest.rollbackStatus,
246
- failure: manifest.failure ?? null,
247
- };
248
- }
249
21
  function focusReferences(engineSnapshot) {
250
22
  const active = (kind) => engineSnapshot.index
251
23
  .findAll(kind)
@@ -261,7 +33,7 @@ function focusReferences(engineSnapshot) {
261
33
  helper: active('scripted_effect'),
262
34
  };
263
35
  }
264
- export async function postValidateTransaction(engine, transaction, principal, signal, autonomous = false) {
36
+ export async function postValidateTransaction(engine, transaction, principal, signal) {
265
37
  engine.invalidate(transaction.workspaceId);
266
38
  const snapshot = await engine.scan(transaction.workspaceId, {}, principal, signal);
267
39
  const changed = new Set(transaction.files.map(({ relativePath }) => sourcePathComparisonKey(relativePath)));
@@ -294,27 +66,27 @@ export async function postValidateTransaction(engine, transaction, principal, si
294
66
  id: 'post-write-focus',
295
67
  passed,
296
68
  message: passed
297
- ? 'Applied focus source re-imported, laid out, and linted successfully'
298
- : 'Applied focus source failed post-write import or lint',
69
+ ? 'The focus result re-imported, laid out, and linted successfully'
70
+ : 'The focus result failed post-write import or lint',
299
71
  });
300
72
  }
301
73
  else if (transaction.operationKind === 'continuous-focus-plan-changes') {
302
74
  for (const file of snapshot.files.filter(({ shadowedBy, relativePath }) => shadowedBy === undefined &&
303
75
  relativePath.toLowerCase().endsWith('.txt') &&
304
76
  changed.has(sourcePathComparisonKey(relativePath)))) {
305
- const document = parseClausewitz(file.bytes, file.displayPath);
306
- const imported = importContinuousFocusPalettes(document);
77
+ const imported = importContinuousFocusPalettes(parseClausewitz(file.bytes, file.displayPath));
307
78
  diagnostics.push(...imported.diagnostics);
308
- for (const plan of imported.continuousFocusPalettes)
79
+ for (const plan of imported.continuousFocusPalettes) {
309
80
  diagnostics.push(...lintContinuousFocusPalette(plan));
81
+ }
310
82
  }
311
83
  const passed = !diagnostics.some(({ severity }) => severity === 'error' || severity === 'blocker');
312
84
  checks.push({
313
85
  id: 'post-write-continuous-focus',
314
86
  passed,
315
87
  message: passed
316
- ? 'Applied continuous focus source re-imported and linted successfully'
317
- : 'Applied continuous focus source failed post-write import or lint',
88
+ ? 'The continuous focus result re-imported and linted successfully'
89
+ : 'The continuous focus result failed post-write import or lint',
318
90
  });
319
91
  }
320
92
  else if (transaction.operationKind === 'gui-source-change' ||
@@ -327,8 +99,8 @@ export async function postValidateTransaction(engine, transaction, principal, si
327
99
  id: 'post-write-gui-graph',
328
100
  passed,
329
101
  message: passed
330
- ? 'Applied GUI source graph rebuilt successfully'
331
- : 'Applied GUI source graph has blocking diagnostics',
102
+ ? 'The GUI graph rebuilt successfully'
103
+ : 'The GUI graph has blocking diagnostics',
332
104
  });
333
105
  }
334
106
  else if (transaction.operationKind === 'agent-nudger-map-changes') {
@@ -346,8 +118,8 @@ export async function postValidateTransaction(engine, transaction, principal, si
346
118
  id: 'post-write-map',
347
119
  passed: validated.validation.passed,
348
120
  message: validated.validation.passed
349
- ? 'Applied map sources rescanned and validated successfully'
350
- : 'Applied map sources failed post-write validation',
121
+ ? 'The map result rescanned and validated successfully'
122
+ : 'The map result failed post-write validation',
351
123
  });
352
124
  }
353
125
  const passed = !diagnostics.some(({ severity }) => severity === 'error' || severity === 'blocker');
@@ -355,36 +127,26 @@ export async function postValidateTransaction(engine, transaction, principal, si
355
127
  id: 'post-write-shared-index',
356
128
  passed,
357
129
  message: passed
358
- ? 'Changed source reparsed and reindexed successfully'
359
- : 'Changed source has blocking post-write diagnostics',
130
+ ? 'Changed files reparsed and reindexed successfully'
131
+ : 'Changed files have blocking post-write diagnostics',
360
132
  });
361
133
  const availableDiagnostics = Math.max(0, TRANSACTION_MAX_DIAGNOSTICS - transaction.diagnostics.length);
362
134
  if (diagnostics.length > availableDiagnostics) {
363
135
  const workspace = engine.resolver.get(transaction.workspaceId, principal);
364
136
  const sourceEvidence = boundedSourceHashEvidence(Object.fromEntries(transaction.files.flatMap(({ relativePath, afterSha256 }) => afterSha256 === null ? [] : [[relativePath, afterSha256]])));
365
- const artifact = await engine.artifacts.putChunked(workspace, autonomous
366
- ? `${transaction.operationKind}.post-validation.json`
367
- : `${transaction.transactionId}.post-validation.json`, 'application/json', `${canonicalJson({
137
+ const artifact = await engine.artifacts.putChunked(workspace, `${transaction.operationKind}.post-validation.json`, 'application/json', `${canonicalJson({
368
138
  schemaVersion: 1,
369
- ...(autonomous
370
- ? { execution: 'autonomous-rewrite' }
371
- : {
372
- transactionId: transaction.transactionId,
373
- planHash: transaction.planHash,
374
- }),
375
139
  operationKind: transaction.operationKind,
376
140
  diagnosticCount: diagnostics.length,
377
141
  checks,
378
142
  diagnostics,
379
143
  })}\n`, {
380
- kind: autonomous ? 'autonomous-rewrite-post-validation' : 'transaction-post-validation',
144
+ kind: 'rewrite-post-validation',
381
145
  toolVersion: PACKAGE_VERSION,
382
- schemaVersion: autonomous
383
- ? 'autonomous-rewrite-post-validation.v1'
384
- : 'transaction-post-validation.v1',
146
+ schemaVersion: 'rewrite-post-validation.v1',
385
147
  sourceHashes: sourceEvidence.sourceHashes,
386
148
  metadata: { sourceHashInventory: sourceEvidence.inventory },
387
- }, 'Complete source-linked diagnostics from post-write transaction validation', signal);
149
+ }, 'Complete diagnostics from post-write validation', signal);
388
150
  const retainedLimit = Math.max(0, availableDiagnostics - 1);
389
151
  const hard = diagnostics.filter(({ severity }) => severity === 'error' || severity === 'blocker');
390
152
  const retainedHard = hard.slice(0, retainedLimit);
@@ -394,7 +156,7 @@ export async function postValidateTransaction(engine, transaction, principal, si
394
156
  const omittedHard = hard.length - retainedHard.length;
395
157
  const artifactLink = publicArtifactLink(artifact);
396
158
  checks.push({
397
- id: 'post-write-diagnostics-resource',
159
+ id: 'post-write-diagnostics-artifact',
398
160
  passed: omittedHard === 0,
399
161
  message: `Complete post-write diagnostics are stored at ${artifactLink.uri}`,
400
162
  });
@@ -405,10 +167,10 @@ export async function postValidateTransaction(engine, transaction, principal, si
405
167
  ...retainedHard,
406
168
  ...retainedSoft,
407
169
  {
408
- code: 'POST_VALIDATION_DIAGNOSTICS_IN_RESOURCE',
170
+ code: 'POST_VALIDATION_DIAGNOSTICS_IN_ARTIFACT',
409
171
  severity: omittedHard > 0 ? 'blocker' : 'warning',
410
- category: 'transaction',
411
- message: `Complete post-write validation contains ${diagnostics.length} diagnostics and is stored as an MCP resource`,
172
+ category: 'validation',
173
+ message: `Complete post-write validation contains ${diagnostics.length} diagnostics and is stored as an artifact`,
412
174
  details: {
413
175
  total: diagnostics.length,
414
176
  returned: availableDiagnostics,
@@ -424,491 +186,3 @@ export async function postValidateTransaction(engine, transaction, principal, si
424
186
  }
425
187
  return { diagnostics, checks, artifacts: [] };
426
188
  }
427
- export function registerBaseTools(server, engine, context) {
428
- server.registerTool('hoi4.project_register', {
429
- title: 'Register HOI4 workspace',
430
- description: 'Register one server-side workspace under a configured registration root; does not edit MCP clients.',
431
- inputSchema: workspaceRegistrationSchema,
432
- outputSchema: projectRegisterOutputSchema,
433
- annotations: {
434
- readOnlyHint: false,
435
- destructiveHint: false,
436
- idempotentHint: false,
437
- openWorldHint: false,
438
- },
439
- }, async (registration, extra) => {
440
- try {
441
- requireServerScope(context, 'hoi4:write');
442
- const progress = progressReporter(extra);
443
- progress.signal.throwIfAborted();
444
- const status = await engine.register(registration, context.principal, progress.signal);
445
- const result = emptyServiceResult(status.id, { workspace: compactWorkspaceStatus(status) });
446
- result.code = 'WORKSPACE_REGISTERED';
447
- return toolResult(result);
448
- }
449
- catch (error) {
450
- return errorResult(error, registration.id);
451
- }
452
- });
453
- server.registerTool('hoi4.project_status', {
454
- title: 'Inspect HOI4 workspace status',
455
- description: 'Return registered workspace capabilities without exposing canonical server paths.',
456
- inputSchema: z
457
- .object({
458
- workspaceId: z.string().min(1).max(64).optional(),
459
- cursor: z.string().min(1).max(4096).optional(),
460
- })
461
- .strict()
462
- .superRefine((value, issue) => {
463
- if (value.workspaceId !== undefined && value.cursor !== undefined) {
464
- issue.addIssue({
465
- code: 'custom',
466
- message: 'cursor is only valid when listing all authorized workspaces',
467
- path: ['cursor'],
468
- });
469
- }
470
- }),
471
- outputSchema: projectStatusOutputSchema,
472
- annotations: readOnly,
473
- }, ({ workspaceId, cursor }) => {
474
- try {
475
- const statuses = workspaceId === undefined
476
- ? engine
477
- .list(context.principal)
478
- .sort((left, right) => compareCodeUnits(left.id, right.id))
479
- : [engine.status(workspaceId, context.principal)];
480
- const revision = sha256Bytes(Buffer.from(canonicalJson(statuses.map(({ id }) => id)), 'utf8'));
481
- let offset = 0;
482
- if (cursor !== undefined) {
483
- const decoded = decodeWorkspaceCursor(cursor);
484
- const afterIndex = statuses.findIndex(({ id }) => id === decoded.after);
485
- if (decoded.revision !== revision || afterIndex < 0) {
486
- throw new ServiceError('WORKSPACE_CURSOR_STALE', 'Workspace inventory changed; restart pagination without a cursor');
487
- }
488
- offset = afterIndex + 1;
489
- }
490
- const page = statuses.slice(offset, offset + 1);
491
- const last = page.at(-1);
492
- const nextCursor = offset + page.length < statuses.length && last !== undefined
493
- ? encodeWorkspaceCursor(revision, last.id)
494
- : undefined;
495
- const result = emptyServiceResult(workspaceId ?? '', {
496
- count: statuses.length,
497
- returned: page.length,
498
- workspaces: page.map(compactWorkspaceStatus),
499
- ...(nextCursor === undefined ? {} : { nextCursor }),
500
- });
501
- result.code = 'WORKSPACE_STATUS';
502
- return toolResult(result);
503
- }
504
- catch (error) {
505
- return errorResult(error, workspaceId ?? '');
506
- }
507
- });
508
- server.registerTool('hoi4.project_scan', {
509
- title: 'Scan HOI4 workspace',
510
- description: 'Build the shared source/index snapshot across game, dependencies, and mod load order.',
511
- inputSchema: workspaceInput
512
- .extend({
513
- maxFiles: z.number().int().min(1).max(1_000_000).optional(),
514
- maxBytes: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
515
- })
516
- .strict(),
517
- outputSchema: projectScanOutputSchema,
518
- annotations: artifactProducing,
519
- }, async ({ workspaceId, maxFiles, maxBytes }, extra) => {
520
- try {
521
- const progress = progressReporter(extra);
522
- await progress.report(0, 3, 'Resolving workspace');
523
- const snapshot = await engine.scan(workspaceId, {
524
- ...(maxFiles === undefined ? {} : { maxFiles }),
525
- ...(maxBytes === undefined ? {} : { maxBytes }),
526
- }, context.principal, progress.signal);
527
- await progress.report(2, 3, 'Writing diagnostics artifact');
528
- const workspace = engine.resolver.get(workspaceId, context.principal);
529
- const sourceEvidence = boundedSourceHashEvidence(Object.fromEntries(snapshot.files.map(({ displayPath, sha256 }) => [displayPath, sha256])));
530
- const diagnosticsArtifact = await engine.artifacts.putChunked(workspace, 'diagnostics.json', 'application/json', `${canonicalJson({
531
- revision: snapshot.revision,
532
- complete: snapshot.complete,
533
- skippedSourceCount: snapshot.skippedSourceCount,
534
- skippedSources: snapshot.skippedSources,
535
- files: snapshot.files.map(({ displayPath, sha256 }) => ({ displayPath, sha256 })),
536
- diagnostics: snapshot.diagnostics,
537
- })}\n`, {
538
- kind: 'diagnostics',
539
- toolVersion: PACKAGE_VERSION,
540
- schemaVersion: 'diagnostics.v1',
541
- sourceHashes: sourceEvidence.sourceHashes,
542
- metadata: { sourceHashInventory: sourceEvidence.inventory },
543
- }, 'Source-linked diagnostics and bounded shared-index completeness report', progress.signal);
544
- const result = emptyServiceResult(workspaceId, {
545
- revision: snapshot.revision,
546
- complete: snapshot.complete,
547
- skippedSourceCount: snapshot.skippedSourceCount,
548
- skippedSources: snapshot.skippedSources,
549
- symbols: snapshot.index.symbols.length,
550
- references: snapshot.index.references.length,
551
- unresolvedReferences: snapshot.index.unresolvedReferences().length,
552
- symbolCounts: Object.fromEntries([...new Set(snapshot.index.symbols.map(({ kind }) => kind))]
553
- .sort((a, b) => compareCodeUnits(a, b))
554
- .map((kind) => [
555
- kind,
556
- snapshot.index.symbols.filter((symbol) => symbol.kind === kind).length,
557
- ])),
558
- });
559
- result.code = snapshot.complete ? 'WORKSPACE_SCANNED' : 'WORKSPACE_SCANNED_PARTIAL';
560
- setInlineFilesScanned(result, snapshot.files.map(({ displayPath }) => displayPath));
561
- result.diagnostics = snapshot.diagnostics.slice(0, 100);
562
- result.artifacts = [publicArtifactLink(diagnosticsArtifact)];
563
- result.validation = {
564
- passed: !snapshot.diagnostics.some(({ severity }) => severity === 'error' || severity === 'blocker'),
565
- checks: [
566
- {
567
- id: 'shared-index',
568
- passed: true,
569
- message: snapshot.complete
570
- ? `${snapshot.index.symbols.length} symbols indexed from a complete inventory`
571
- : `${snapshot.index.symbols.length} symbols indexed from an incomplete inventory; ${snapshot.skippedSourceCount} over-limit source(s) were recorded and aggregate index ceilings may also apply`,
572
- },
573
- ],
574
- };
575
- await progress.report(3, 3, 'Scan complete');
576
- return toolResult(result);
577
- }
578
- catch (error) {
579
- return errorResult(error, workspaceId);
580
- }
581
- });
582
- if (engine.resolver.config().writePolicy !== 'autonomous') {
583
- server.registerTool('hoi4.transaction_status', {
584
- title: 'Inspect transaction',
585
- description: 'Return compact dry-run/apply/rollback counts and current state with a complete manifest resource.',
586
- inputSchema: workspaceInput.extend({ transactionId: transactionIdSchema }).strict(),
587
- outputSchema: transactionStatusOutputSchema,
588
- annotations: readOnly,
589
- }, async ({ workspaceId, transactionId }, extra) => {
590
- try {
591
- const progress = progressReporter(extra);
592
- progress.signal.throwIfAborted();
593
- const manifest = await engine.transactions.status(workspaceId, transactionId, context.principal, progress.signal);
594
- progress.signal.throwIfAborted();
595
- const result = emptyServiceResult(workspaceId, {
596
- manifest: transactionSummary(manifest),
597
- });
598
- result.code = 'TRANSACTION_STATUS';
599
- result.transactionId = manifest.transactionId;
600
- result.planHash = manifest.planHash;
601
- result.proposedFiles = manifest.files
602
- .slice(0, 100)
603
- .map(({ relativePath }) => relativePath);
604
- result.changedFiles = manifest.appliedFiles.slice(0, 100);
605
- result.artifacts = [transactionResourceLink(manifest)];
606
- result.validation = manifest.validation;
607
- result.rollbackStatus = manifest.rollbackStatus;
608
- return toolResult(result);
609
- }
610
- catch (error) {
611
- return errorResult(error, workspaceId);
612
- }
613
- });
614
- server.registerTool('hoi4.transaction_diff', {
615
- title: 'Review transaction diff',
616
- description: 'Page through the complete affected-file set, operation summaries, and source/binary artifact links before apply.',
617
- inputSchema: workspaceInput
618
- .extend({
619
- transactionId: transactionIdSchema,
620
- limit: z.number().int().min(1).max(20).default(20),
621
- cursor: z.string().min(1).max(4096).optional(),
622
- })
623
- .strict(),
624
- outputSchema: transactionDiffOutputSchema,
625
- annotations: readOnly,
626
- }, async ({ workspaceId, transactionId, limit, cursor }, extra) => {
627
- try {
628
- const progress = progressReporter(extra);
629
- progress.signal.throwIfAborted();
630
- const manifest = await engine.transactions.status(workspaceId, transactionId, context.principal, progress.signal);
631
- progress.signal.throwIfAborted();
632
- let fileOffset = 0;
633
- let operationOffset = 0;
634
- let artifactOffset = 0;
635
- if (cursor !== undefined) {
636
- const decoded = decodeTransactionDiffCursor(cursor);
637
- if (decoded.planHash !== manifest.planHash ||
638
- decoded.fileOffset > manifest.files.length ||
639
- decoded.operationOffset > manifest.operations.length ||
640
- decoded.artifactOffset > manifest.artifacts.length) {
641
- throw new ServiceError('TRANSACTION_CURSOR_STALE', 'Transaction plan changed or the diff cursor is stale');
642
- }
643
- fileOffset = decoded.fileOffset;
644
- operationOffset = decoded.operationOffset;
645
- artifactOffset = decoded.artifactOffset;
646
- }
647
- const manifestFiles = manifest.files.slice(fileOffset, fileOffset + limit);
648
- const files = manifestFiles.map(({ relativePath, operationIds, beforeSha256, afterSha256, beforeSize, afterSize, mediaType, diffArtifact, }) => ({
649
- relativePath,
650
- operationIdCount: operationIds.length,
651
- operationIds: operationIds.slice(0, 20),
652
- beforeSha256,
653
- afterSha256,
654
- beforeSize,
655
- afterSize,
656
- mediaType,
657
- ...(diffArtifact === undefined ? {} : { diffArtifact }),
658
- }));
659
- const operations = manifest.operations.slice(operationOffset, operationOffset + limit);
660
- const artifacts = manifest.artifacts.slice(artifactOffset, artifactOffset + limit);
661
- const nextFileOffset = fileOffset + manifestFiles.length;
662
- const nextOperationOffset = operationOffset + operations.length;
663
- const nextArtifactOffset = artifactOffset + artifacts.length;
664
- const nextCursor = nextFileOffset < manifest.files.length ||
665
- nextOperationOffset < manifest.operations.length ||
666
- nextArtifactOffset < manifest.artifacts.length
667
- ? encodeTransactionDiffCursor(manifest.planHash, nextFileOffset, nextOperationOffset, nextArtifactOffset)
668
- : undefined;
669
- const result = emptyServiceResult(workspaceId, {
670
- files,
671
- operations: operations.map(({ id, kind, summary }) => ({ id, kind, summary })),
672
- fileCount: manifest.files.length,
673
- operationCount: manifest.operations.length,
674
- artifactCount: manifest.artifacts.length,
675
- returnedFiles: files.length,
676
- returnedOperations: operations.length,
677
- returnedArtifacts: artifacts.length,
678
- ...(nextCursor === undefined ? {} : { nextCursor }),
679
- expiresAt: manifest.expiresAt,
680
- });
681
- result.code = 'TRANSACTION_DIFF';
682
- result.transactionId = manifest.transactionId;
683
- result.planHash = manifest.planHash;
684
- result.proposedFiles = files.map(({ relativePath }) => relativePath);
685
- result.artifacts = [transactionResourceLink(manifest), ...artifacts];
686
- result.validation = manifest.validation;
687
- result.rollbackStatus = manifest.rollbackStatus;
688
- return toolResult(result);
689
- }
690
- catch (error) {
691
- return errorResult(error, workspaceId);
692
- }
693
- });
694
- server.registerTool('hoi4.transaction_apply', {
695
- title: 'Apply reviewed transaction',
696
- description: 'Apply a completed dry run only when transaction ID, workspace, principal, source hashes, and expected plan hash still match.',
697
- inputSchema: transactionInput,
698
- outputSchema: transactionMutationOutputSchema,
699
- annotations: {
700
- readOnlyHint: false,
701
- destructiveHint: true,
702
- idempotentHint: false,
703
- openWorldHint: false,
704
- },
705
- }, async ({ workspaceId, transactionId, expectedPlanHash }, extra) => {
706
- try {
707
- requireServerScope(context, 'hoi4:write');
708
- const progress = progressReporter(extra);
709
- await progress.report(0, 3, 'Checking transaction preconditions');
710
- const manifest = await engine.transactions.apply(workspaceId, transactionId, expectedPlanHash, {
711
- ...(context.principal === undefined ? {} : { principal: context.principal }),
712
- signal: progress.signal,
713
- postValidate: (transaction, signal) => postValidateTransaction(engine, transaction, context.principal, signal),
714
- });
715
- engine.invalidate(workspaceId);
716
- await engine.scan(workspaceId, {}, context.principal, progress.signal);
717
- await progress.report(3, 3, 'Apply and index rebuild complete');
718
- const result = emptyServiceResult(workspaceId, {
719
- state: manifest.state,
720
- fileCount: manifest.files.length,
721
- appliedFileCount: manifest.appliedFiles.length,
722
- artifactCount: manifest.artifacts.length,
723
- });
724
- result.code = 'TRANSACTION_APPLIED';
725
- result.transactionId = manifest.transactionId;
726
- result.planHash = manifest.planHash;
727
- result.proposedFiles = manifest.files
728
- .slice(0, 100)
729
- .map(({ relativePath }) => relativePath);
730
- result.changedFiles = manifest.appliedFiles.slice(0, 100);
731
- result.artifacts = [transactionResourceLink(manifest)];
732
- result.validation = manifest.validation;
733
- result.rollbackStatus = manifest.rollbackStatus;
734
- return toolResult(result);
735
- }
736
- catch (error) {
737
- engine.invalidate(workspaceId);
738
- try {
739
- const failed = await engine.transactions.status(workspaceId, transactionId, context.principal);
740
- return errorResult(error, workspaceId, {
741
- transactionId: failed.transactionId,
742
- planHash: failed.planHash,
743
- proposedFiles: failed.files.slice(0, 100).map(({ relativePath }) => relativePath),
744
- changedFiles: failed.state === 'applied' ? failed.appliedFiles.slice(0, 100) : [],
745
- artifacts: [transactionResourceLink(failed)],
746
- validation: failed.validation,
747
- rollbackStatus: failed.rollbackStatus,
748
- data: { state: failed.state, failure: failed.failure ?? null },
749
- });
750
- }
751
- catch {
752
- // A forged or cross-workspace transaction ID intentionally reveals no manifest details.
753
- }
754
- return errorResult(error, workspaceId);
755
- }
756
- });
757
- server.registerTool('hoi4.transaction_rollback', {
758
- title: 'Roll back applied transaction',
759
- description: 'Restore exact original bytes when the applied result still matches rollback preconditions.',
760
- inputSchema: transactionInput,
761
- outputSchema: transactionMutationOutputSchema,
762
- annotations: {
763
- readOnlyHint: false,
764
- destructiveHint: true,
765
- idempotentHint: false,
766
- openWorldHint: false,
767
- },
768
- }, async ({ workspaceId, transactionId, expectedPlanHash }, extra) => {
769
- try {
770
- requireServerScope(context, 'hoi4:write');
771
- const progress = progressReporter(extra);
772
- await progress.report(0, 2, 'Checking rollback preconditions');
773
- progress.signal.throwIfAborted();
774
- const manifest = await engine.transactions.rollback(workspaceId, transactionId, expectedPlanHash, context.principal, progress.signal);
775
- engine.invalidate(workspaceId);
776
- const result = emptyServiceResult(workspaceId, {
777
- state: manifest.state,
778
- fileCount: manifest.files.length,
779
- appliedFileCount: manifest.appliedFiles.length,
780
- artifactCount: manifest.artifacts.length,
781
- });
782
- result.code = 'TRANSACTION_ROLLED_BACK';
783
- result.transactionId = manifest.transactionId;
784
- result.planHash = manifest.planHash;
785
- result.changedFiles = manifest.files
786
- .slice(0, 100)
787
- .map(({ relativePath }) => relativePath);
788
- result.artifacts = [transactionResourceLink(manifest)];
789
- result.validation = manifest.validation;
790
- result.rollbackStatus = manifest.rollbackStatus;
791
- await progress.report(2, 2, 'Atomic rollback complete');
792
- return toolResult(result);
793
- }
794
- catch (error) {
795
- try {
796
- const failed = await engine.transactions.status(workspaceId, transactionId, context.principal);
797
- return errorResult(error, workspaceId, {
798
- transactionId: failed.transactionId,
799
- planHash: failed.planHash,
800
- proposedFiles: failed.files.slice(0, 100).map(({ relativePath }) => relativePath),
801
- changedFiles: failed.state === 'applied' ? failed.appliedFiles.slice(0, 100) : [],
802
- artifacts: [transactionResourceLink(failed)],
803
- validation: failed.validation,
804
- rollbackStatus: failed.rollbackStatus,
805
- data: { state: failed.state, failure: failed.failure ?? null },
806
- });
807
- }
808
- catch {
809
- // Invalid or inaccessible transaction IDs intentionally reveal no manifest details.
810
- }
811
- return errorResult(error, workspaceId);
812
- }
813
- });
814
- }
815
- server.registerTool('hoi4.artifact_list', {
816
- title: 'List workspace artifacts',
817
- description: 'List content-addressed artifacts without exposing filesystem paths.',
818
- inputSchema: workspaceInput
819
- .extend({
820
- limit: z.number().int().min(1).max(100).default(100),
821
- cursor: z.string().min(1).max(4096).optional(),
822
- })
823
- .strict(),
824
- outputSchema: artifactListOutputSchema,
825
- annotations: readOnly,
826
- }, async ({ workspaceId, limit, cursor }, extra) => {
827
- try {
828
- const progress = progressReporter(extra);
829
- progress.signal.throwIfAborted();
830
- const workspace = engine.resolver.get(workspaceId, context.principal);
831
- const decoded = cursor === undefined ? undefined : decodeArtifactCursor(cursor);
832
- const listing = await engine.artifacts.listPage(workspace, {
833
- limit,
834
- ...(decoded === undefined ? {} : { afterUri: decoded.after }),
835
- }, progress.signal);
836
- progress.signal.throwIfAborted();
837
- if (decoded !== undefined &&
838
- (decoded.revision !== listing.revision || !listing.afterFound)) {
839
- throw new ServiceError('ARTIFACT_CURSOR_STALE', 'Artifact inventory changed; restart pagination without a cursor');
840
- }
841
- const last = listing.artifacts.at(-1);
842
- const nextCursor = listing.hasMore && last !== undefined
843
- ? encodeArtifactCursor(listing.revision, last.uri)
844
- : undefined;
845
- const result = emptyServiceResult(workspaceId, {
846
- count: listing.total,
847
- returned: listing.artifacts.length,
848
- ...(nextCursor === undefined ? {} : { nextCursor }),
849
- });
850
- result.code = 'ARTIFACT_LIST';
851
- result.artifacts = listing.artifacts;
852
- return toolResult(result);
853
- }
854
- catch (error) {
855
- return errorResult(error, workspaceId);
856
- }
857
- });
858
- server.registerTool('hoi4.artifact_describe', {
859
- title: 'Describe workspace artifact',
860
- description: 'Return artifact integrity and provenance metadata for an authorized workspace.',
861
- inputSchema: workspaceInput.extend({ uri: z.url().max(4096) }).strict(),
862
- outputSchema: artifactDescribeOutputSchema,
863
- annotations: readOnly,
864
- }, async ({ workspaceId, uri }, extra) => {
865
- try {
866
- const progress = progressReporter(extra);
867
- progress.signal.throwIfAborted();
868
- const workspace = engine.resolver.get(workspaceId, context.principal);
869
- const artifact = await engine.artifacts.describe(workspace, uri, progress.signal);
870
- progress.signal.throwIfAborted();
871
- const sourceHashes = Object.entries(artifact.provenance.sourceHashes).sort(([left], [right]) => compareCodeUnits(left, right));
872
- const description = {
873
- uri: artifact.uri,
874
- name: artifact.name,
875
- mimeType: artifact.mimeType,
876
- size: artifact.size,
877
- sha256: artifact.sha256,
878
- provenanceHash: artifact.provenanceHash,
879
- ...(artifact.description === undefined
880
- ? {}
881
- : { description: artifact.description.slice(0, 1_024) }),
882
- descriptionTruncated: (artifact.description?.length ?? 0) > 1_024,
883
- provenance: {
884
- kind: artifact.provenance.kind,
885
- toolVersion: artifact.provenance.toolVersion,
886
- schemaVersion: artifact.provenance.schemaVersion,
887
- sourceHashCount: sourceHashes.length,
888
- sourceHashes: sourceHashes.slice(0, 100).map(([path, sha256]) => ({ path, sha256 })),
889
- sourceHashesTruncated: sourceHashes.length > 100,
890
- hasRenderProfile: artifact.provenance.renderProfile !== undefined,
891
- hasMetadata: artifact.provenance.metadata !== undefined,
892
- },
893
- };
894
- const manifestUri = new URL(artifact.uri);
895
- manifestUri.searchParams.set('metadata', 'manifest');
896
- const result = emptyServiceResult(workspaceId, { artifact: description });
897
- result.code = 'ARTIFACT_DESCRIBE';
898
- result.artifacts = [
899
- publicArtifactLink(artifact),
900
- {
901
- uri: manifestUri.href,
902
- name: `${artifact.name}.manifest.json`,
903
- mimeType: 'application/json',
904
- description: 'Complete public provenance manifest for this artifact',
905
- },
906
- ];
907
- return toolResult(result);
908
- }
909
- catch (error) {
910
- return errorResult(error, workspaceId);
911
- }
912
- });
913
- }
914
- //# sourceMappingURL=base-tools.js.map