hoi4-agent-tools 4.3.0 → 4.4.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 (110) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/dist/hoi4_agent_tools/core/bounded-source.js +31 -9
  3. package/dist/hoi4_agent_tools/core/configuration.js +11 -0
  4. package/dist/hoi4_agent_tools/core/operation-context.js +17 -1
  5. package/dist/hoi4_agent_tools/core/temporary-directories.js +7 -2
  6. package/dist/hoi4_agent_tools/core/transaction-limits.js +18 -4
  7. package/dist/hoi4_agent_tools/core/transactions.js +23 -4
  8. package/dist/hoi4_agent_tools/core/workspace-json.js +54 -0
  9. package/dist/hoi4_agent_tools/core/workspace.js +42 -6
  10. package/dist/hoi4_agent_tools/map/appearance-validation.js +1110 -0
  11. package/dist/hoi4_agent_tools/map/bmp.js +9 -1
  12. package/dist/hoi4_agent_tools/map/border-quality-input.js +209 -0
  13. package/dist/hoi4_agent_tools/map/border-quality.js +1180 -0
  14. package/dist/hoi4_agent_tools/map/colormap.js +128 -0
  15. package/dist/hoi4_agent_tools/map/geography/geometry.js +284 -0
  16. package/dist/hoi4_agent_tools/map/geography/index.js +6 -0
  17. package/dist/hoi4_agent_tools/map/geography/model.js +196 -0
  18. package/dist/hoi4_agent_tools/map/geography/preparation.js +120 -0
  19. package/dist/hoi4_agent_tools/map/geography/preview.js +647 -0
  20. package/dist/hoi4_agent_tools/map/geography/raster.js +253 -0
  21. package/dist/hoi4_agent_tools/map/geography/resolve.js +1467 -0
  22. package/dist/hoi4_agent_tools/map/model.js +15 -2
  23. package/dist/hoi4_agent_tools/map/operations.js +111 -8
  24. package/dist/hoi4_agent_tools/map/partition-fields.js +398 -0
  25. package/dist/hoi4_agent_tools/map/partition-geography.js +113 -0
  26. package/dist/hoi4_agent_tools/map/partition-graph.js +165 -0
  27. package/dist/hoi4_agent_tools/map/partition-groups.js +164 -0
  28. package/dist/hoi4_agent_tools/map/partition-provinces.js +727 -0
  29. package/dist/hoi4_agent_tools/map/partition-tuning.js +101 -0
  30. package/dist/hoi4_agent_tools/map/partition-watershed.js +252 -0
  31. package/dist/hoi4_agent_tools/map/partition.js +163 -0
  32. package/dist/hoi4_agent_tools/map/reference-import.js +333 -0
  33. package/dist/hoi4_agent_tools/map/reference-preparation.js +138 -5
  34. package/dist/hoi4_agent_tools/map/reference-sheets.js +231 -0
  35. package/dist/hoi4_agent_tools/map/reference-world.js +104 -13
  36. package/dist/hoi4_agent_tools/map/relief/checks.js +281 -0
  37. package/dist/hoi4_agent_tools/map/relief/fields.js +15 -0
  38. package/dist/hoi4_agent_tools/map/relief/full-resolution.js +133 -0
  39. package/dist/hoi4_agent_tools/map/relief/grid.js +190 -0
  40. package/dist/hoi4_agent_tools/map/relief/hydrology.js +1315 -0
  41. package/dist/hoi4_agent_tools/map/relief/index.js +27 -0
  42. package/dist/hoi4_agent_tools/map/relief/land.js +110 -0
  43. package/dist/hoi4_agent_tools/map/relief/macro-relief.js +535 -0
  44. package/dist/hoi4_agent_tools/map/relief/math.js +93 -0
  45. package/dist/hoi4_agent_tools/map/relief/river-raster.js +680 -0
  46. package/dist/hoi4_agent_tools/map/relief/terrain-synthesis.js +304 -0
  47. package/dist/hoi4_agent_tools/map/render.js +36 -0
  48. package/dist/hoi4_agent_tools/map/service.js +191 -16
  49. package/dist/hoi4_agent_tools/map/tool-operations.js +208 -2
  50. package/dist/hoi4_agent_tools/map/validation.js +9 -0
  51. package/dist/hoi4_agent_tools/map/water.js +227 -0
  52. package/dist/hoi4_agent_tools/map/world-context.js +24 -1
  53. package/dist/hoi4_agent_tools/map/world-edge.js +335 -0
  54. package/dist/hoi4_agent_tools/map/world-noise.js +34 -0
  55. package/dist/hoi4_agent_tools/map/world-partition.js +119 -0
  56. package/dist/hoi4_agent_tools/map/world-provinces.js +131 -56
  57. package/dist/hoi4_agent_tools/map/world.js +462 -124
  58. package/dist/hoi4_agent_tools/mcp/tools/map.js +69 -1
  59. package/dist/hoi4_agent_tools/reference/operations.js +3 -2
  60. package/dist/hoi4_agent_tools/schemas/geography.js +325 -0
  61. package/dist/hoi4_agent_tools/schemas/map-requests.js +20 -2
  62. package/dist/hoi4_agent_tools/schemas/map.js +209 -2
  63. package/dist/hoi4_agent_tools/schemas/reference-sheets.js +92 -0
  64. package/dist/hoi4_agent_tools/version.js +1 -1
  65. package/docs/configuration.md +17 -14
  66. package/docs/map.md +258 -15
  67. package/docs/tools.md +4 -4
  68. package/docs/troubleshooting.md +11 -11
  69. package/npm-shrinkwrap.json +109 -91
  70. package/package.json +3 -3
  71. package/schemas/configuration.schema.json +65 -58
  72. package/schemas/continuous-focus-palette.schema.json +1 -1
  73. package/schemas/custom-weighted-pool.schema.json +1 -1
  74. package/schemas/decision-inspect-input.schema.json +1 -1
  75. package/schemas/error-log-input.schema.json +1 -1
  76. package/schemas/event-feature-manifest.schema.json +1 -1
  77. package/schemas/focus-plan.schema.json +1 -1
  78. package/schemas/focus-planning-sidecar.schema.json +1 -1
  79. package/schemas/geography-model.schema.json +1148 -0
  80. package/schemas/gui-animation-source.schema.json +1 -1
  81. package/schemas/gui-helper.schema.json +5 -11
  82. package/schemas/gui-scenario.schema.json +1 -1
  83. package/schemas/helper-expansion-request.schema.json +1 -1
  84. package/schemas/helper-expansion-summary.schema.json +1 -1
  85. package/schemas/impact-inspect-input.schema.json +1 -1
  86. package/schemas/map-operation.schema.json +2156 -259
  87. package/schemas/mechanic-test-input.schema.json +1 -1
  88. package/schemas/mod-index-input.schema.json +1 -1
  89. package/schemas/operation-result.schema.json +1 -1
  90. package/schemas/package-check-input.schema.json +1 -1
  91. package/schemas/package-manifest.schema.json +1 -1
  92. package/schemas/probability-analysis-result.schema.json +25 -7
  93. package/schemas/probability-compare-input.schema.json +1 -1
  94. package/schemas/probability-evaluate-input.schema.json +1 -1
  95. package/schemas/probability-inspect-input.schema.json +1 -1
  96. package/schemas/probability-render-input.schema.json +1 -1
  97. package/schemas/probability-scenario-set.schema.json +1 -1
  98. package/schemas/probability-sequence-input.schema.json +1 -1
  99. package/schemas/probability-simulate-input.schema.json +1 -1
  100. package/schemas/probability-sweep-input.schema.json +1 -1
  101. package/schemas/reference-context-input.schema.json +1 -1
  102. package/schemas/reference-read-input.schema.json +1 -1
  103. package/schemas/reference-search-input.schema.json +1 -1
  104. package/schemas/reference-sheets.schema.json +267 -0
  105. package/schemas/scenario-suite.schema.json +1 -1
  106. package/schemas/scenario-test-input.schema.json +1 -1
  107. package/schemas/script-validate-input.schema.json +1 -1
  108. package/schemas/shared-scenario.schema.json +1 -1
  109. package/schemas/source-lookup-input.schema.json +1 -1
  110. package/server.json +2 -2
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Platform-stable numeric helpers for relief and hydrology synthesis (ADR 0056). Only `+ - * /`,
3
+ * `sqrt`, `floor` and integer arithmetic are used: `Math.exp`, `Math.pow` and `Math.sin` may differ
4
+ * between Node builds, which would change the world a seed produces.
5
+ */
6
+ import { fractal, lattice, valueNoise } from '../world-noise.js';
7
+ export const SQRT2 = 1.4142135623730951;
8
+ export function clamp(value, low, high) {
9
+ return value < low ? low : value > high ? high : value;
10
+ }
11
+ export function clamp01(value) {
12
+ return value < 0 ? 0 : value > 1 ? 1 : value;
13
+ }
14
+ export function lerp(a, b, t) {
15
+ return a + (b - a) * t;
16
+ }
17
+ /** Cubic smoothstep of `t` clamped to 0..1. */
18
+ export function smoothstep(t) {
19
+ const clamped = t < 0 ? 0 : t > 1 ? 1 : t;
20
+ return clamped * clamped * (3 - 2 * clamped);
21
+ }
22
+ /** `u ** 1.5` for `u >= 0`. */
23
+ export function pow15(u) {
24
+ return u * Math.sqrt(u);
25
+ }
26
+ /** `u ** 1.25` for `u >= 0`. */
27
+ export function pow125(u) {
28
+ return u * Math.sqrt(Math.sqrt(u));
29
+ }
30
+ /** Piecewise-linear base two logarithm for `x >= 1`: exact at powers of two. */
31
+ export function log2Approx(x) {
32
+ if (x <= 1)
33
+ return 0;
34
+ let mantissa = x;
35
+ let exponent = 0;
36
+ while (mantissa >= 2) {
37
+ mantissa /= 2;
38
+ exponent += 1;
39
+ }
40
+ return exponent + (mantissa - 1);
41
+ }
42
+ /** Integer hash to 0..1 for pairs of integers. */
43
+ export function hash01(seed, a, b = 0) {
44
+ return lattice(seed, a, b);
45
+ }
46
+ /** Smooth value noise in 0..1. */
47
+ export function noise2(seed, x, y) {
48
+ return valueNoise(seed, x, y);
49
+ }
50
+ /** Fractal value noise in about 0.2..0.8; `scale` is the wavelength of the first octave. */
51
+ export function fractal2(seed, x, y, scale, octaves = 4) {
52
+ return fractal(seed, x, y, scale, octaves);
53
+ }
54
+ /**
55
+ * Ridged multifractal noise in 0..1: sharp crests where the underlying noise crosses its middle,
56
+ * squared per octave so the crests stand out from broad flanks.
57
+ */
58
+ export function ridged2(seed, x, y, scale, octaves = 3) {
59
+ let total = 0;
60
+ let amplitude = 1;
61
+ let weight = 0;
62
+ let frequency = 1 / scale;
63
+ for (let octave = 0; octave < octaves; octave += 1) {
64
+ const n = valueNoise(seed + octave * 131, x * frequency, y * frequency) * 2 - 1;
65
+ const ridge = 1 - (n < 0 ? -n : n);
66
+ total += ridge * ridge * amplitude;
67
+ weight += amplitude;
68
+ amplitude *= 0.5;
69
+ frequency *= 2.03;
70
+ }
71
+ return total / weight;
72
+ }
73
+ /** A deterministic generator for sequences (mulberry32). */
74
+ export class Rng {
75
+ #state;
76
+ constructor(seed) {
77
+ this.#state = (seed ^ 0x9e3779b9) >>> 0;
78
+ }
79
+ next() {
80
+ this.#state = (this.#state + 0x6d2b79f5) >>> 0;
81
+ let value = this.#state;
82
+ value = Math.imul(value ^ (value >>> 15), value | 1);
83
+ value ^= value + Math.imul(value ^ (value >>> 7), value | 61);
84
+ return ((value ^ (value >>> 14)) >>> 0) / 4294967296;
85
+ }
86
+ }
87
+ /** Mix a string into a seed so every feature gets its own stable stream. */
88
+ export function seedFromString(base, text) {
89
+ let hash = Math.imul(base ^ 0x811c9dc5, 0x01000193);
90
+ for (let index = 0; index < text.length; index += 1)
91
+ hash = Math.imul(hash ^ text.charCodeAt(index), 0x01000193);
92
+ return (hash ^ (hash >>> 15)) >>> 0;
93
+ }