hoi4-agent-tools 4.11.1 → 4.13.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 (116) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +3 -3
  3. package/dist/bin/setup.js +38 -0
  4. package/dist/bin/stdio.js +12 -10
  5. package/dist/hoi4_agent_tools/core/configuration.js +29 -0
  6. package/dist/hoi4_agent_tools/core/domain-tools.js +4 -0
  7. package/dist/hoi4_agent_tools/core/engine-check.js +87 -0
  8. package/dist/hoi4_agent_tools/core/engine-client.js +1 -1
  9. package/dist/hoi4_agent_tools/core/engine.js +18 -2
  10. package/dist/hoi4_agent_tools/core/job-operation-registration.js +2 -0
  11. package/dist/hoi4_agent_tools/core/job-store.js +1 -1
  12. package/dist/hoi4_agent_tools/focus/native-effects.js +1 -1
  13. package/dist/hoi4_agent_tools/localisation/job-operations.js +42 -0
  14. package/dist/hoi4_agent_tools/localisation/write-diff.js +96 -0
  15. package/dist/hoi4_agent_tools/localisation/write-format.js +329 -0
  16. package/dist/hoi4_agent_tools/localisation/write-operations.js +213 -0
  17. package/dist/hoi4_agent_tools/localisation/write-plan.js +557 -0
  18. package/dist/hoi4_agent_tools/map/gameplay/crossing-validation.js +17 -0
  19. package/dist/hoi4_agent_tools/map/model.js +31 -1
  20. package/dist/hoi4_agent_tools/map/operations.js +37 -8
  21. package/dist/hoi4_agent_tools/map/references.js +87 -0
  22. package/dist/hoi4_agent_tools/map/relief/hydrology.js +7 -2
  23. package/dist/hoi4_agent_tools/map/relief/terrain-synthesis.js +1 -0
  24. package/dist/hoi4_agent_tools/map/service.js +13 -4
  25. package/dist/hoi4_agent_tools/map/tool-operations.js +6 -0
  26. package/dist/hoi4_agent_tools/map/world-edge.js +0 -25
  27. package/dist/hoi4_agent_tools/map/world.js +181 -64
  28. package/dist/hoi4_agent_tools/mcp/plugins.js +74 -0
  29. package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +5 -0
  30. package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +15 -21
  31. package/dist/hoi4_agent_tools/mcp/server/create.js +5 -1
  32. package/dist/hoi4_agent_tools/mcp/server/request-lifecycle.js +10 -2
  33. package/dist/hoi4_agent_tools/mcp/server/task-tool-catalog.js +2 -0
  34. package/dist/hoi4_agent_tools/mcp/server/tool-profiles.js +83 -0
  35. package/dist/hoi4_agent_tools/mcp/tools/localisation-write.js +21 -0
  36. package/dist/hoi4_agent_tools/mcp/tools/reference.js +34 -0
  37. package/dist/hoi4_agent_tools/mcp/transports/http.js +6 -1
  38. package/dist/hoi4_agent_tools/mcp/transports/negotiated-stdio.js +64 -6
  39. package/dist/hoi4_agent_tools/probability/model.js +4 -4
  40. package/dist/hoi4_agent_tools/reference/compat-patch.js +555 -0
  41. package/dist/hoi4_agent_tools/reference/compat.js +255 -0
  42. package/dist/hoi4_agent_tools/reference/docs-pack.js +164 -0
  43. package/dist/hoi4_agent_tools/reference/docs-pack.json +339 -0
  44. package/dist/hoi4_agent_tools/reference/documented-commands.js +26 -0
  45. package/dist/hoi4_agent_tools/reference/error-explain.js +235 -0
  46. package/dist/hoi4_agent_tools/reference/error-explanations.json +262 -0
  47. package/dist/hoi4_agent_tools/reference/error-log.js +30 -10
  48. package/dist/hoi4_agent_tools/reference/mod-health.js +255 -0
  49. package/dist/hoi4_agent_tools/reference/mod-index.js +63 -65
  50. package/dist/hoi4_agent_tools/reference/operations.js +435 -21
  51. package/dist/hoi4_agent_tools/reference/script-guard.js +109 -0
  52. package/dist/hoi4_agent_tools/reference/service.js +58 -20
  53. package/dist/hoi4_agent_tools/runtime.js +17 -2
  54. package/dist/hoi4_agent_tools/schemas/compat.js +153 -0
  55. package/dist/hoi4_agent_tools/schemas/localisation-write.js +154 -0
  56. package/dist/hoi4_agent_tools/schemas/map.js +5 -1
  57. package/dist/hoi4_agent_tools/schemas/mod-tools.js +50 -0
  58. package/dist/hoi4_agent_tools/schemas/modder-tools.js +191 -0
  59. package/dist/hoi4_agent_tools/version.js +1 -1
  60. package/docs/configuration.md +14 -11
  61. package/docs/development.md +2 -0
  62. package/docs/jobs.md +3 -1
  63. package/docs/map.md +8 -4
  64. package/docs/reference.md +47 -5
  65. package/docs/research/probability-adapter-evidence.md +11 -1
  66. package/docs/setup.md +23 -3
  67. package/docs/tools.md +18 -4
  68. package/docs/troubleshooting.md +1 -1
  69. package/engine/bin/darwin-arm64/hoi4-engine +0 -0
  70. package/engine/bin/linux-arm64/hoi4-engine +0 -0
  71. package/engine/bin/linux-x64/hoi4-engine +0 -0
  72. package/engine/bin/manifest.json +8 -8
  73. package/engine/bin/win32-x64/hoi4-engine.exe +0 -0
  74. package/npm-shrinkwrap.json +2 -2
  75. package/package.json +1 -1
  76. package/schemas/configuration.schema.json +181 -138
  77. package/schemas/continuous-focus-palette.schema.json +1 -1
  78. package/schemas/custom-weighted-pool.schema.json +1 -1
  79. package/schemas/decision-inspect-input.schema.json +1 -1
  80. package/schemas/error-log-input.schema.json +1 -1
  81. package/schemas/event-feature-manifest.schema.json +1 -1
  82. package/schemas/focus-plan.schema.json +1 -1
  83. package/schemas/focus-planning-sidecar.schema.json +1 -1
  84. package/schemas/geography-model.schema.json +1 -1
  85. package/schemas/gui-animation-source.schema.json +1 -1
  86. package/schemas/gui-helper.schema.json +1 -1
  87. package/schemas/gui-scenario.schema.json +1 -1
  88. package/schemas/helper-expansion-request.schema.json +1 -1
  89. package/schemas/helper-expansion-summary.schema.json +1 -1
  90. package/schemas/impact-inspect-input.schema.json +1 -1
  91. package/schemas/map-operation.schema.json +153 -139
  92. package/schemas/mechanic-test-input.schema.json +1 -1
  93. package/schemas/mod-index-input.schema.json +1 -1
  94. package/schemas/operation-result.schema.json +1 -1
  95. package/schemas/package-check-input.schema.json +1 -1
  96. package/schemas/package-manifest.schema.json +1 -1
  97. package/schemas/probability-analysis-result.schema.json +1 -1
  98. package/schemas/probability-compare-input.schema.json +1 -1
  99. package/schemas/probability-evaluate-input.schema.json +1 -1
  100. package/schemas/probability-inspect-input.schema.json +1 -1
  101. package/schemas/probability-render-input.schema.json +1 -1
  102. package/schemas/probability-scenario-set.schema.json +1 -1
  103. package/schemas/probability-sequence-input.schema.json +1 -1
  104. package/schemas/probability-simulate-input.schema.json +1 -1
  105. package/schemas/probability-sweep-input.schema.json +1 -1
  106. package/schemas/reference-context-input.schema.json +1 -1
  107. package/schemas/reference-read-input.schema.json +1 -1
  108. package/schemas/reference-search-input.schema.json +1 -1
  109. package/schemas/reference-sheets.schema.json +1 -1
  110. package/schemas/scenario-suite.schema.json +1 -1
  111. package/schemas/scenario-test-input.schema.json +1 -1
  112. package/schemas/script-validate-input.schema.json +1 -1
  113. package/schemas/shared-scenario.schema.json +1 -1
  114. package/schemas/source-lookup-input.schema.json +1 -1
  115. package/server.json +2 -2
  116. package/dist/hoi4_agent_tools/mcp/tools/chaosx.js +0 -509
@@ -6,7 +6,7 @@ import { applyReplacements, assignments, encodeSource, parseLocalisation, parseC
6
6
  import { rgbKey } from './bmp.js';
7
7
  import { MAP_MASK_CELL_LIMIT, MAP_POLYGON_WORK_LIMIT, MAP_SELECTED_OFFSET_BYTES, MAP_SELECTED_PIXEL_LIMIT, } from './limits.js';
8
8
  import { derivedStateCapital, encodeTextDocument, LEVEL_STATE_BUILDINGS, MapWorkspaceIndex, parseMapDate, parseTextDocument, } from './model.js';
9
- import { planReferenceRemap, ReferenceRemapError } from './references.js';
9
+ import { collectContinentReferences, droppedContinentDiagnostics, planReferenceRemap, ReferenceRemapError, } from './references.js';
10
10
  import { generateWorld } from './world.js';
11
11
  import { resolveEdge } from './world-edge.js';
12
12
  import { DEFAULT_AUTO_STRAIT_GAP_PX } from './gameplay/crossings.js';
@@ -3421,6 +3421,7 @@ function applyCreateWorld(base, changes, operation, context, signal) {
3421
3421
  ...(operation.continentNames === undefined
3422
3422
  ? {}
3423
3423
  : { continentNames: operation.continentNames }),
3424
+ ...(operation.inheritedContinents === 'drop' ? { inheritedContinents: 'drop' } : {}),
3424
3425
  startDate: operation.startDate ?? '1936.1.1',
3425
3426
  rivers: typeof operation.rivers === 'number' ? operation.rivers : reference === undefined ? 8 : 80,
3426
3427
  ...(geography === undefined
@@ -3482,13 +3483,17 @@ function applyCreateWorld(base, changes, operation, context, signal) {
3482
3483
  message: note.message,
3483
3484
  ...(note.details === undefined ? {} : { details: note.details }),
3484
3485
  })),
3485
- {
3486
- code: 'MAP_SYNTHESIS_CHECK_READY',
3487
- severity: 'info',
3488
- category: 'map',
3489
- operationId: operation.id,
3490
- message: `Every river of the model reaches its mouth over the synthesised relief of a ${world.summary.width}x${world.summary.height} map; nothing was written`,
3491
- },
3486
+ ...(world.notes.some(({ severity }) => severity === 'error')
3487
+ ? []
3488
+ : [
3489
+ {
3490
+ code: 'MAP_SYNTHESIS_CHECK_READY',
3491
+ severity: 'info',
3492
+ category: 'map',
3493
+ operationId: operation.id,
3494
+ message: `Every river of the model reaches its mouth over the synthesised relief of a ${world.summary.width}x${world.summary.height} map; nothing was written`,
3495
+ },
3496
+ ]),
3492
3497
  ];
3493
3498
  const roots = operation.replaceBaseGame === false
3494
3499
  ? []
@@ -3512,6 +3517,9 @@ function applyCreateWorld(base, changes, operation, context, signal) {
3512
3517
  if (roots.length > 0)
3513
3518
  addChange(changes, 'descriptor.mod', descriptorWithReplacePaths(base, roots), operation.id, 'text/plain');
3514
3519
  const generated = currentIndex(base, changes);
3520
+ // Scripts that stay active after the write and still name a continent the world dropped.
3521
+ const droppedContinents = world.droppedContinents ?? [];
3522
+ const continentReferences = collectContinentReferences(generated.activeFiles.all, new Set(droppedContinents));
3515
3523
  for (const file of planMapPositions(generated, { mode: 'replace' }))
3516
3524
  addChange(changes, file.relativePath, file.content, operation.id, 'text/plain');
3517
3525
  const positioned = currentIndex(base, changes);
@@ -3576,6 +3584,27 @@ function applyCreateWorld(base, changes, operation, context, signal) {
3576
3584
  },
3577
3585
  ]),
3578
3586
  ...worldTagDiagnostics(operation.id, tagCatalog, world, workspaceCountries !== undefined),
3587
+ ...(operation.inheritedContinents === 'drop'
3588
+ ? [
3589
+ {
3590
+ code: 'MAP_CONTINENTS_DROPPED',
3591
+ severity: 'info',
3592
+ category: 'map',
3593
+ operationId: operation.id,
3594
+ message: droppedContinents.length === 0
3595
+ ? 'continent.txt lists only the generated continents; the active sources declared no other'
3596
+ : `continent.txt lists only the generated continents and leaves out ${droppedContinents.length} inherited one(s); ${continentReferences.length} active script reference(s) still name them`,
3597
+ details: {
3598
+ dropped: droppedContinents,
3599
+ references: continentReferences.length,
3600
+ },
3601
+ },
3602
+ ...droppedContinentDiagnostics(continentReferences).map((diagnostic) => ({
3603
+ ...diagnostic,
3604
+ operationId: operation.id,
3605
+ })),
3606
+ ]
3607
+ : []),
3579
3608
  ...worldRealmDiagnostics(operation.id, world),
3580
3609
  ...(outputs.released.length === 0
3581
3610
  ? []
@@ -506,3 +506,90 @@ export function mapScriptConsistency(index) {
506
506
  }
507
507
  return { diagnostics, references: references.length, missing };
508
508
  }
509
+ /**
510
+ * Folders whose scripts may name a continent: triggers and effects anywhere in `common`, events
511
+ * and country history, the AI areas, and the portrait pools.
512
+ */
513
+ export const CONTINENT_REFERENCE_SCRIPT_PATTERNS = [
514
+ 'common/**/*.txt',
515
+ 'events/**/*.txt',
516
+ 'history/countries/**/*.txt',
517
+ 'portraits/**/*.txt',
518
+ ];
519
+ const CONTINENT_SCRIPT_FILE = /^(?:common|events|history\/countries|portraits)\/.+\.txt$/iu;
520
+ /** Every place an active script names one of `keys` as a continent, in load order. */
521
+ export function collectContinentReferences(files, keys) {
522
+ const references = [];
523
+ if (keys.size === 0)
524
+ return references;
525
+ const active = files
526
+ .filter((file) => file.shadowedBy === undefined &&
527
+ CONTINENT_SCRIPT_FILE.test(file.relativePath.replaceAll('\\', '/')))
528
+ .sort((left, right) => left.loadOrder - right.loadOrder || compareCodeUnits(left.displayPath, right.displayPath));
529
+ for (const file of active) {
530
+ // A cheap byte check skips the many files that name no continent key at all.
531
+ const text = file.bytes.toString('latin1');
532
+ if (![...keys].some((key) => text.includes(key)))
533
+ continue;
534
+ const document = parseClausewitz(file.bytes, file.displayPath);
535
+ const folder = file.relativePath.replaceAll('\\', '/').toLowerCase();
536
+ const aiAreas = folder.startsWith('common/ai_areas/');
537
+ const portraits = folder.startsWith('portraits/');
538
+ const add = (node, kind) => {
539
+ if (keys.has(node.value))
540
+ references.push({ continent: node.value, kind, file, document, node });
541
+ };
542
+ const visit = (entry) => {
543
+ if (entry.type === 'block') {
544
+ for (const child of entry.entries)
545
+ visit(child);
546
+ return;
547
+ }
548
+ if (entry.type !== 'assignment')
549
+ return;
550
+ const key = entry.key.value;
551
+ if (entry.value.type === 'scalar') {
552
+ if (key === 'is_on_continent')
553
+ add(entry.value, 'is_on_continent');
554
+ else if (key === 'continent')
555
+ add(entry.value, 'continent');
556
+ return;
557
+ }
558
+ if (aiAreas && key === 'continents')
559
+ for (const item of entry.value.entries)
560
+ if (item.type === 'scalar')
561
+ add(item, 'ai_area');
562
+ if (portraits && key === 'continent')
563
+ for (const child of entry.value.entries)
564
+ if (child.type === 'assignment' &&
565
+ child.key.value === 'name' &&
566
+ child.value.type === 'scalar')
567
+ add(child.value, 'portrait');
568
+ for (const child of entry.value.entries)
569
+ visit(child);
570
+ };
571
+ visit(document.root);
572
+ }
573
+ return references;
574
+ }
575
+ const CONTINENT_REFERENCE_FORMS = {
576
+ is_on_continent: 'is_on_continent',
577
+ continent: 'continent',
578
+ ai_area: "an AI area's continents",
579
+ portrait: "a portrait pool's continent",
580
+ };
581
+ /** One warning for each script reference to a continent the new `continent.txt` leaves out. */
582
+ export function droppedContinentDiagnostics(references) {
583
+ return references.map((reference) => ({
584
+ code: 'MAP_CONTINENT_DROPPED_REFERENCED',
585
+ severity: 'warning',
586
+ category: 'map',
587
+ message: `${reference.file.relativePath} names the dropped continent ${reference.continent} (${CONTINENT_REFERENCE_FORMS[reference.kind]}); the new continent.txt no longer declares it`,
588
+ location: nodeLocation(reference.document, reference.node),
589
+ details: {
590
+ continent: reference.continent,
591
+ kind: reference.kind,
592
+ layer: reference.file.rootKind,
593
+ },
594
+ }));
595
+ }
@@ -750,10 +750,14 @@ function routeNamedRivers(context) {
750
750
  }
751
751
  }
752
752
  }
753
- void notes;
754
753
  if (failures.length > 0) {
755
754
  const first = failures[0];
756
- fail('MAP_RIVER_UNREACHABLE_MOUTH', failures.length === 1
755
+ const report = context.collectUnreachable
756
+ ? (code, message, details) => {
757
+ notes.push({ code, severity: 'error', message, details });
758
+ }
759
+ : fail;
760
+ report('MAP_RIVER_UNREACHABLE_MOUTH', failures.length === 1
757
761
  ? `River ${first.riverId} cannot reach its mouth: ${first.reason}`
758
762
  : `${failures.length} rivers cannot reach their mouths: ${failures
759
763
  .slice(0, 12)
@@ -1326,6 +1330,7 @@ export function synthesizeHydrology(input) {
1326
1330
  notes,
1327
1331
  seed,
1328
1332
  signal: input.signal,
1333
+ collectUnreachable: input.collectUnreachable,
1329
1334
  });
1330
1335
  // Burn the channels into the heights and flood again with the channels as outlets, so every
1331
1336
  // other cell drains either to the coast or into a channel.
@@ -128,6 +128,7 @@ export function checkTerrainRivers(input) {
128
128
  rainfall: input.rainfall,
129
129
  landPixels,
130
130
  signal: input.signal,
131
+ collectUnreachable: true,
131
132
  });
132
133
  const notes = [...hydrology.notes];
133
134
  // The pass test of the write, on the macro grid: a declared pass must be a saddle lower than
@@ -1,4 +1,4 @@
1
- import { MAP_REFERENCE_SCRIPT_PATTERNS, mapScriptConsistency } from './references.js';
1
+ import { CONTINENT_REFERENCE_SCRIPT_PATTERNS, MAP_REFERENCE_SCRIPT_PATTERNS, mapScriptConsistency, } from './references.js';
2
2
  import path from 'node:path';
3
3
  import { escapeFileGlob } from '../core/file-glob.js';
4
4
  import { ArtifactStore, boundedSourceHashEvidence, publicArtifactLink, } from '../core/artifacts.js';
@@ -627,7 +627,7 @@ export class AgentNudger {
627
627
  this.scanner = this.engine.scanner;
628
628
  this.transactions = this.engine.transactions;
629
629
  }
630
- async scan(workspaceId, principal, signal, includeExternalScriptReferences = false, includeWorldContext = false, includeAppearance = false, includeBorderInputs = false) {
630
+ async scan(workspaceId, principal, signal, includeExternalScriptReferences = false, includeWorldContext = false, includeAppearance = false, includeBorderInputs = false, includeContinentReferences = false) {
631
631
  signal?.throwIfAborted();
632
632
  const workspace = this.resolver.get(workspaceId, principal);
633
633
  const sourceRoots = {
@@ -688,14 +688,23 @@ export class AgentNudger {
688
688
  ],
689
689
  }, principal, signal)
690
690
  : undefined;
691
+ // Scripts that may name a continent, read when a new world drops the inherited continents.
692
+ const continentSnapshot = includeContinentReferences
693
+ ? await this.engine.scan(workspaceId, { patterns: [...CONTINENT_REFERENCE_SCRIPT_PATTERNS] }, principal, signal)
694
+ : undefined;
691
695
  signal?.throwIfAborted();
692
- const files = [
696
+ const collected = [
693
697
  ...contentSnapshot.files,
694
698
  ...locatorSnapshot.files,
695
699
  ...(externalScriptSnapshot?.files ?? []),
696
700
  ...(worldContextSnapshot?.files ?? []).filter((file) => !contentSnapshot.files.some((existing) => existing.displayPath === file.displayPath)),
697
701
  ...(appearanceSnapshot?.files ?? []).filter((file) => ![...contentSnapshot.files, ...(worldContextSnapshot?.files ?? [])].some((existing) => existing.displayPath === file.displayPath)),
698
702
  ...(generatedOutputsSnapshot?.files ?? []).filter((file) => ![...contentSnapshot.files, ...(worldContextSnapshot?.files ?? [])].some((existing) => existing.displayPath === file.displayPath)),
703
+ ];
704
+ const collectedPaths = new Set(collected.map(({ displayPath }) => displayPath));
705
+ const files = [
706
+ ...collected,
707
+ ...(continentSnapshot?.files ?? []).filter((file) => !collectedPaths.has(file.displayPath)),
699
708
  ].sort((left, right) => left.loadOrder - right.loadOrder || compareCodeUnits(left.displayPath, right.displayPath));
700
709
  const revision = hashCanonical(files.map(({ displayPath, loadOrder, sha256 }) => ({ displayPath, loadOrder, sha256 })));
701
710
  return {
@@ -735,7 +744,7 @@ export class AgentNudger {
735
744
  signal?.throwIfAborted();
736
745
  const snapshot = await this.scan(workspaceId, principal, signal, operations.some((operation) => operation.kind === 'renumber_map_entity' ||
737
746
  operation.kind === 'remap_map_references' ||
738
- 'remapReferences' in operation), operations.some((operation) => operation.kind === 'create_world'), false, operations.some((operation) => operation.kind === 'assign_territory' || operation.kind === 'repartition_states'));
747
+ 'remapReferences' in operation), operations.some((operation) => operation.kind === 'create_world'), false, operations.some((operation) => operation.kind === 'assign_territory' || operation.kind === 'repartition_states'), operations.some((operation) => operation.kind === 'create_world' && operation.inheritedContinents === 'drop'));
739
748
  const referenceWorlds = new Map();
740
749
  const referenceImages = [];
741
750
  const referenceLoads = new Map();
@@ -616,12 +616,18 @@ async function previewSynthesisCheck(nudger, input, context) {
616
616
  },
617
617
  ],
618
618
  };
619
+ // Every blocking problem the check found is listed, not only the first (one fix round, not six).
619
620
  result.blockers = [
620
621
  ...checked.plan.blockers.map(({ code, message, details }) => ({
621
622
  code,
622
623
  message,
623
624
  ...(details === undefined ? {} : { details }),
624
625
  })),
626
+ ...blocked.map(({ code, message, details }) => ({
627
+ code,
628
+ message,
629
+ ...(details === undefined ? {} : { details }),
630
+ })),
625
631
  ].slice(0, 100);
626
632
  await context.progress(2, 2, 'River check complete; nothing was written');
627
633
  return result;
@@ -358,31 +358,6 @@ export function edgeWaterDarkness(edge, width, height, x, y) {
358
358
  const pole = edge.polarPx > 0 ? smooth(1 - poleDistance / (edge.polarPx * 1.2)) * 0.8 : 0;
359
359
  return Math.max(side, pole);
360
360
  }
361
- /**
362
- * Impassable rows for every pair of distinct land provinces that meet across the seam (`rim` and
363
- * `wall`), in
364
- * `adjacencies.csv` order (rows are sorted by the lower then the higher province ID).
365
- */
366
- export function rimAdjacencyRows(input) {
367
- const { provincePixels, provinceKinds, width, height } = input;
368
- const pairs = new Set();
369
- for (let y = 0; y < height; y += 1) {
370
- const left = provincePixels[y * width];
371
- const right = provincePixels[y * width + width - 1];
372
- if (left === right || provinceKinds[left] !== LAND || provinceKinds[right] !== LAND)
373
- continue;
374
- const low = Math.min(left, right) + 1;
375
- const high = Math.max(left, right) + 1;
376
- pairs.add(`${low};${high}`);
377
- }
378
- return [...pairs]
379
- .sort((a, b) => {
380
- const [al, ah] = a.split(';').map(Number);
381
- const [bl, bh] = b.split(';').map(Number);
382
- return al - bl || ah - bh;
383
- })
384
- .map((pair) => `${pair};impassable;-1;-1;-1;-1;-1;;World rim`);
385
- }
386
361
  /** Heights and positions of the base map's frame meshes, scaled to the world size. */
387
362
  export function frameBorderPositions(width, height) {
388
363
  return {