hoi4-agent-tools 3.0.6 → 3.0.7

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  No unreleased changes.
6
6
 
7
+ ## 3.0.7 - 2026-09-01
8
+
9
+ - Reclaim detached parser, graph, and render memory after the idle cache window so parallel coding-agent tasks do not retain large V8 heaps and trigger `Transport closed` through host memory exhaustion. Idle cleanup is coordinated across every MCP domain and never compacts during an active tool call.
10
+ - Give packed-package build, pack, and isolated-install qualification enough time on loaded Windows runners while retaining bounded subprocess timeouts.
11
+
7
12
  ## 3.0.6 - 2026-09-01
8
13
 
9
14
  - Prevent long-lived coding-agent tasks from exhausting the host and closing MCP transports. Stdio disconnects now abort in-flight requests, vanilla scan caches are byte-bounded, event and technology histories are reduced, probability results are bounded, and heavy domain caches are released after a concurrent-safe idle window.
@@ -1,13 +1,26 @@
1
+ import { compactManagedHeap } from './managed-heap.js';
1
2
  export const DEFAULT_IDLE_CACHE_RELEASE_MS = 30_000;
3
+ let activeCacheOperations = 0;
4
+ const deferredReleases = new Set();
5
+ function flushDeferredReleases() {
6
+ if (activeCacheOperations !== 0)
7
+ return;
8
+ const ready = [...deferredReleases];
9
+ deferredReleases.clear();
10
+ for (const lifetime of ready)
11
+ lifetime.releaseDeferred();
12
+ }
2
13
  /** Keeps reusable analysis caches alive across an immediate tool sequence, then releases them. */
3
14
  export class IdleCacheLifetime {
4
15
  releaseCaches;
5
16
  idleMs;
17
+ compactHeap;
6
18
  #active = 0;
7
19
  #timer;
8
- constructor(releaseCaches, idleMs = DEFAULT_IDLE_CACHE_RELEASE_MS) {
20
+ constructor(releaseCaches, idleMs = DEFAULT_IDLE_CACHE_RELEASE_MS, compactHeap = compactManagedHeap) {
9
21
  this.releaseCaches = releaseCaches;
10
22
  this.idleMs = idleMs;
23
+ this.compactHeap = compactHeap;
11
24
  }
12
25
  release() {
13
26
  try {
@@ -20,27 +33,48 @@ export class IdleCacheLifetime {
20
33
  message: error instanceof Error ? error.message : String(error),
21
34
  })}\n`);
22
35
  }
36
+ try {
37
+ this.compactHeap();
38
+ }
39
+ catch {
40
+ // Heap compaction is best-effort maintenance. Cache release already succeeded.
41
+ }
42
+ }
43
+ releaseDeferred() {
44
+ if (this.#active !== 0 || activeCacheOperations !== 0) {
45
+ deferredReleases.add(this);
46
+ return;
47
+ }
48
+ this.release();
23
49
  }
24
50
  begin() {
25
51
  if (this.#timer !== undefined) {
26
52
  clearTimeout(this.#timer);
27
53
  this.#timer = undefined;
28
54
  }
55
+ deferredReleases.delete(this);
29
56
  this.#active += 1;
57
+ activeCacheOperations += 1;
30
58
  let ended = false;
31
59
  return () => {
32
60
  if (ended)
33
61
  return;
34
62
  ended = true;
35
63
  this.#active = Math.max(0, this.#active - 1);
36
- if (this.#active !== 0)
37
- return;
38
- this.#timer = setTimeout(() => {
39
- this.#timer = undefined;
40
- if (this.#active === 0)
41
- this.release();
42
- }, this.idleMs);
43
- this.#timer.unref();
64
+ activeCacheOperations = Math.max(0, activeCacheOperations - 1);
65
+ if (this.#active === 0) {
66
+ this.#timer = setTimeout(() => {
67
+ this.#timer = undefined;
68
+ if (this.#active !== 0)
69
+ return;
70
+ if (activeCacheOperations === 0)
71
+ this.release();
72
+ else
73
+ deferredReleases.add(this);
74
+ }, this.idleMs);
75
+ this.#timer.unref();
76
+ }
77
+ flushDeferredReleases();
44
78
  };
45
79
  }
46
80
  async run(operation) {
@@ -56,7 +90,9 @@ export class IdleCacheLifetime {
56
90
  if (this.#timer !== undefined)
57
91
  clearTimeout(this.#timer);
58
92
  this.#timer = undefined;
59
- if (this.#active === 0)
93
+ if (this.#active !== 0 || activeCacheOperations !== 0)
94
+ deferredReleases.add(this);
95
+ else
60
96
  this.release();
61
97
  }
62
98
  }
@@ -0,0 +1,29 @@
1
+ import { runInNewContext } from 'node:vm';
2
+ import { setFlagsFromString } from 'node:v8';
3
+ /**
4
+ * Ask V8 to reclaim detached analysis graphs after an idle cache release.
5
+ *
6
+ * npm bin shims cannot portably add `--expose-gc`, so the collector is exposed
7
+ * only for the duration of this best-effort idle maintenance call.
8
+ */
9
+ export function compactManagedHeap() {
10
+ const direct = globalThis.gc;
11
+ if (direct !== undefined) {
12
+ direct();
13
+ return true;
14
+ }
15
+ try {
16
+ setFlagsFromString('--expose-gc');
17
+ const candidate = runInNewContext('gc');
18
+ if (typeof candidate !== 'function')
19
+ return false;
20
+ candidate();
21
+ return true;
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ finally {
27
+ setFlagsFromString('--no-expose-gc');
28
+ }
29
+ }
@@ -1,6 +1,6 @@
1
1
  import { LATEST_PROTOCOL_VERSION } from '@modelcontextprotocol/sdk/types.js';
2
2
  export const PACKAGE_NAME = 'hoi4-agent-tools';
3
- export const PACKAGE_VERSION = '3.0.6';
3
+ export const PACKAGE_VERSION = '3.0.7';
4
4
  export const MCP_PROTOCOL_VERSION = LATEST_PROTOCOL_VERSION;
5
5
  export const CONFIG_VERSION = 1;
6
6
  export const TRANSACTION_VERSION = 1;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hoi4-agent-tools",
3
3
  "mcpName": "io.github.klimPaskov/hoi4-agent-tools",
4
- "version": "3.0.6",
4
+ "version": "3.0.7",
5
5
  "description": "Analyze HOI4 events, tech trees, AI weights, and MTTH; build focus trees, GUIs, and maps.",
6
6
  "type": "module",
7
7
  "license": "Apache-2.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/configuration.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/configuration.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/continuous-focus-palette.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/continuous-focus-palette.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/custom-weighted-pool.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/custom-weighted-pool.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/event-feature-manifest.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/event-feature-manifest.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/focus-plan.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/focus-plan.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/focus-planning-sidecar.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/focus-planning-sidecar.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/gui-animation-source.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/gui-animation-source.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/gui-helper.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/gui-helper.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/gui-scenario.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/gui-scenario.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/map-operation.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/map-operation.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "oneOf": [
5
5
  {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/operation-result.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/operation-result.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/probability-analysis-result.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/probability-analysis-result.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/probability-compare-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/probability-compare-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/probability-evaluate-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/probability-evaluate-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/probability-inspect-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/probability-inspect-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/probability-render-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/probability-render-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/probability-scenario-set.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/probability-scenario-set.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/probability-sequence-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/probability-sequence-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/probability-simulate-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/probability-simulate-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.6/schemas/probability-sweep-input.schema.json",
2
+ "$id": "https://github.com/klimPaskov/hoi4-agent-tools/blob/v3.0.7/schemas/probability-sweep-input.schema.json",
3
3
  "$schema": "https://json-schema.org/draft/2020-12/schema",
4
4
  "type": "object",
5
5
  "properties": {
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "io.github.klimPaskov/hoi4-agent-tools",
4
4
  "title": "HOI4 Agent Tools",
5
5
  "description": "Analyze HOI4 events, tech trees, AI weights, and MTTH; build focus trees, GUIs, and maps.",
6
- "version": "3.0.6",
6
+ "version": "3.0.7",
7
7
  "repository": {
8
8
  "url": "https://github.com/klimPaskov/hoi4-agent-tools",
9
9
  "source": "github"
@@ -13,7 +13,7 @@
13
13
  {
14
14
  "registryType": "npm",
15
15
  "identifier": "hoi4-agent-tools",
16
- "version": "3.0.6",
16
+ "version": "3.0.7",
17
17
  "transport": {
18
18
  "type": "stdio"
19
19
  }