hoi4-agent-tools 3.2.0 → 3.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.
- package/CHANGELOG.md +19 -0
- package/README.md +4 -0
- package/dist/hoi4_agent_tools/core/analysis-job-operations.js +11 -1
- package/dist/hoi4_agent_tools/core/condition-evaluator.js +18 -9
- package/dist/hoi4_agent_tools/core/helper-expansion.js +3 -0
- package/dist/hoi4_agent_tools/core/job-worker-host.js +3 -0
- package/dist/hoi4_agent_tools/core/operation-tasks.js +7 -0
- package/dist/hoi4_agent_tools/core/scenario-model.js +85 -0
- package/dist/hoi4_agent_tools/event/comparison-selection.js +78 -0
- package/dist/hoi4_agent_tools/event/helper-expansion.js +48 -0
- package/dist/hoi4_agent_tools/event/operations.js +16 -0
- package/dist/hoi4_agent_tools/event/service.js +21 -2
- package/dist/hoi4_agent_tools/focus/compact.js +241 -27
- package/dist/hoi4_agent_tools/focus/layout.js +119 -8
- package/dist/hoi4_agent_tools/focus/render.js +62 -0
- package/dist/hoi4_agent_tools/focus/scenario.js +99 -0
- package/dist/hoi4_agent_tools/focus/tool-operations.js +30 -4
- package/dist/hoi4_agent_tools/gui/assets.js +54 -4
- package/dist/hoi4_agent_tools/gui/layout.js +935 -104
- package/dist/hoi4_agent_tools/gui/renderer.js +47 -17
- package/dist/hoi4_agent_tools/gui/scenario-conditions.js +2 -23
- package/dist/hoi4_agent_tools/gui/shader.js +515 -0
- package/dist/hoi4_agent_tools/gui/source-graph.js +166 -6
- package/dist/hoi4_agent_tools/gui/studio.js +245 -19
- package/dist/hoi4_agent_tools/gui/tool-operations.js +9 -0
- package/dist/hoi4_agent_tools/gui/validators.js +38 -12
- package/dist/hoi4_agent_tools/map/operations.js +70 -1
- package/dist/hoi4_agent_tools/map/render.js +70 -1
- package/dist/hoi4_agent_tools/map/service.js +30 -6
- package/dist/hoi4_agent_tools/map/tool-operations.js +67 -1
- package/dist/hoi4_agent_tools/mcp/server/instructions.js +1 -1
- package/dist/hoi4_agent_tools/mcp/server/request-lifecycle.js +3 -0
- package/dist/hoi4_agent_tools/mcp/tools/analysis.js +90 -0
- package/dist/hoi4_agent_tools/mcp/tools/event.js +10 -1
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +14 -4
- package/dist/hoi4_agent_tools/mcp/tools/gui.js +5 -1
- package/dist/hoi4_agent_tools/mcp/tools/map.js +12 -2
- package/dist/hoi4_agent_tools/mcp/tools/probability.js +5 -0
- package/dist/hoi4_agent_tools/mechanic/assertions.js +112 -0
- package/dist/hoi4_agent_tools/mechanic/interpreter.js +619 -0
- package/dist/hoi4_agent_tools/mechanic/service.js +145 -0
- package/dist/hoi4_agent_tools/mechanic/source.js +89 -0
- package/dist/hoi4_agent_tools/package-check/service.js +231 -0
- package/dist/hoi4_agent_tools/probability/evaluation.js +6 -1
- package/dist/hoi4_agent_tools/probability/operations.js +8 -0
- package/dist/hoi4_agent_tools/probability/service.js +33 -12
- package/dist/hoi4_agent_tools/probability/source-analysis.js +1 -0
- package/dist/hoi4_agent_tools/scenario-suite/service.js +341 -0
- package/dist/hoi4_agent_tools/schemas/event.js +8 -0
- package/dist/hoi4_agent_tools/schemas/focus-requests.js +40 -1
- package/dist/hoi4_agent_tools/schemas/gui-requests.js +8 -0
- package/dist/hoi4_agent_tools/schemas/map-requests.js +22 -1
- package/dist/hoi4_agent_tools/schemas/scenarios.js +264 -0
- package/dist/hoi4_agent_tools/schemas/technology.js +7 -0
- package/dist/hoi4_agent_tools/technology/graph.js +25 -10
- package/dist/hoi4_agent_tools/technology/render.js +286 -31
- package/dist/hoi4_agent_tools/technology/service.js +55 -8
- package/dist/hoi4_agent_tools/technology/source-analysis.js +166 -3
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/README.md +1 -0
- package/docs/events.md +3 -1
- package/docs/focus.md +10 -0
- package/docs/gui.md +49 -3
- package/docs/map.md +8 -0
- package/docs/mechanics.md +70 -0
- package/docs/probability.md +3 -1
- package/docs/technology.md +7 -2
- package/package.json +2 -1
- package/schemas/configuration.schema.json +1 -1
- package/schemas/continuous-focus-palette.schema.json +1 -1
- package/schemas/custom-weighted-pool.schema.json +1 -1
- package/schemas/decision-inspect-input.schema.json +1 -1
- package/schemas/event-feature-manifest.schema.json +1 -1
- package/schemas/focus-plan.schema.json +1 -1
- package/schemas/focus-planning-sidecar.schema.json +1 -1
- package/schemas/gui-animation-source.schema.json +1 -1
- package/schemas/gui-helper.schema.json +1 -1
- package/schemas/gui-scenario.schema.json +1 -1
- package/schemas/helper-expansion-request.schema.json +1 -1
- package/schemas/helper-expansion-summary.schema.json +1 -1
- package/schemas/impact-inspect-input.schema.json +1 -1
- package/schemas/map-operation.schema.json +1 -1
- package/schemas/mechanic-test-input.schema.json +650 -0
- package/schemas/operation-result.schema.json +1 -1
- package/schemas/package-check-input.schema.json +164 -0
- package/schemas/package-manifest.schema.json +142 -0
- package/schemas/probability-analysis-result.schema.json +1 -1
- package/schemas/probability-compare-input.schema.json +1 -1
- package/schemas/probability-evaluate-input.schema.json +1 -1
- package/schemas/probability-inspect-input.schema.json +1 -1
- package/schemas/probability-render-input.schema.json +1 -1
- package/schemas/probability-scenario-set.schema.json +1 -1
- package/schemas/probability-sequence-input.schema.json +1 -1
- package/schemas/probability-simulate-input.schema.json +1 -1
- package/schemas/probability-sweep-input.schema.json +1 -1
- package/schemas/scenario-suite.schema.json +1004 -0
- package/schemas/scenario-test-input.schema.json +1057 -0
- package/schemas/shared-scenario.schema.json +237 -0
- package/server.json +2 -2
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { canonicalJson } from '../core/canonical.js';
|
|
2
|
+
import { scenarioValue } from '../core/scenario-model.js';
|
|
3
|
+
function value(state, path) {
|
|
4
|
+
return scenarioValue(state, path.key, path.scope);
|
|
5
|
+
}
|
|
6
|
+
function number(state, path) {
|
|
7
|
+
const found = value(state, path);
|
|
8
|
+
return typeof found === 'number' && Number.isFinite(found) ? found : undefined;
|
|
9
|
+
}
|
|
10
|
+
function result(assertion, status, observed, reason) {
|
|
11
|
+
return {
|
|
12
|
+
id: assertion.id,
|
|
13
|
+
kind: assertion.kind,
|
|
14
|
+
status,
|
|
15
|
+
...(observed === undefined ? {} : { observed }),
|
|
16
|
+
...(reason === undefined ? {} : { reason }),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function evaluateMechanicAssertions(assertions, before, after, checkpoints, trace) {
|
|
20
|
+
return assertions.map((assertion) => {
|
|
21
|
+
if (before.unknown.has('*') || after.unknown.has('*'))
|
|
22
|
+
return result(assertion, 'unresolved', undefined, 'An unsupported effect may write this state');
|
|
23
|
+
if (assertion.kind === 'equals' || assertion.kind === 'end_state') {
|
|
24
|
+
const found = value(after, assertion.path);
|
|
25
|
+
if (found === undefined)
|
|
26
|
+
return result(assertion, 'unresolved', undefined, 'End-state value is unknown');
|
|
27
|
+
return result(assertion, found === assertion.expected ? 'passed' : 'failed', found);
|
|
28
|
+
}
|
|
29
|
+
if (assertion.kind === 'conservation') {
|
|
30
|
+
const starting = assertion.paths.map((path) => number(before, path));
|
|
31
|
+
const ending = assertion.paths.map((path) => number(after, path));
|
|
32
|
+
if ([...starting, ...ending].some((item) => item === undefined))
|
|
33
|
+
return result(assertion, 'unresolved', undefined, 'Conserved values must be declared numbers');
|
|
34
|
+
const initial = starting.reduce((sum, item) => sum + item, 0);
|
|
35
|
+
const final = ending.reduce((sum, item) => sum + item, 0);
|
|
36
|
+
return result(assertion, Math.abs(initial - final) <= assertion.tolerance ? 'passed' : 'failed', { initial, final, difference: final - initial });
|
|
37
|
+
}
|
|
38
|
+
if (assertion.kind === 'array_alignment') {
|
|
39
|
+
const arrays = assertion.paths.map((path) => value(after, path));
|
|
40
|
+
if (arrays.some((item) => !Array.isArray(item)))
|
|
41
|
+
return result(assertion, 'unresolved', undefined, 'All aligned values must be declared arrays');
|
|
42
|
+
const lengths = arrays.map((array) => array.length);
|
|
43
|
+
return result(assertion, lengths.every((length) => length === lengths[0]) ? 'passed' : 'failed', lengths);
|
|
44
|
+
}
|
|
45
|
+
if (assertion.kind === 'affordability') {
|
|
46
|
+
const available = number(before, assertion.balance);
|
|
47
|
+
return available === undefined
|
|
48
|
+
? result(assertion, 'unresolved', undefined, 'Starting balance is unknown')
|
|
49
|
+
: result(assertion, available >= assertion.cost ? 'passed' : 'failed', {
|
|
50
|
+
available,
|
|
51
|
+
cost: assertion.cost,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (assertion.kind === 'single_payment') {
|
|
55
|
+
const starting = number(before, assertion.balance);
|
|
56
|
+
const ending = number(after, assertion.balance);
|
|
57
|
+
const reductions = trace.flatMap((step) => step.status === 'applied' &&
|
|
58
|
+
step.scope === assertion.balance.scope &&
|
|
59
|
+
step.target === assertion.balance.key &&
|
|
60
|
+
typeof step.before === 'number' &&
|
|
61
|
+
typeof step.after === 'number' &&
|
|
62
|
+
step.before > step.after
|
|
63
|
+
? [step.before - step.after]
|
|
64
|
+
: []);
|
|
65
|
+
return starting === undefined || ending === undefined
|
|
66
|
+
? result(assertion, 'unresolved', undefined, 'Payment balance is unknown')
|
|
67
|
+
: result(assertion, reductions.length === 1 &&
|
|
68
|
+
reductions[0] === assertion.cost &&
|
|
69
|
+
starting - ending === assertion.cost
|
|
70
|
+
? 'passed'
|
|
71
|
+
: 'failed', {
|
|
72
|
+
paid: starting - ending,
|
|
73
|
+
expected: assertion.cost,
|
|
74
|
+
deductions: reductions,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (assertion.kind === 'repeated_setup') {
|
|
78
|
+
const first = checkpoints[assertion.firstStep];
|
|
79
|
+
const second = checkpoints[assertion.secondStep];
|
|
80
|
+
if (first === undefined ||
|
|
81
|
+
second === undefined ||
|
|
82
|
+
first.unknown.size > 0 ||
|
|
83
|
+
second.unknown.size > 0)
|
|
84
|
+
return result(assertion, 'unresolved', undefined, 'Repeated setup checkpoints are unavailable');
|
|
85
|
+
return result(assertion, canonicalJson(first.scenario) === canonicalJson(second.scenario) ? 'passed' : 'failed', { firstStep: assertion.firstStep, secondStep: assertion.secondStep });
|
|
86
|
+
}
|
|
87
|
+
if (assertion.kind === 'exclusive_flags') {
|
|
88
|
+
const flags = assertion.scope === 'GLOBAL'
|
|
89
|
+
? after.scenario.globalFlags
|
|
90
|
+
: assertion.scope === 'ROOT'
|
|
91
|
+
? after.scenario.flags
|
|
92
|
+
: after.scenario.scopes?.[assertion.scope]?.flags;
|
|
93
|
+
if (flags === undefined)
|
|
94
|
+
return result(assertion, 'unresolved', undefined, 'Flag scope is undeclared');
|
|
95
|
+
const active = assertion.flags.filter((flag) => flags.includes(flag));
|
|
96
|
+
return result(assertion, active.length <= 1 ? 'passed' : 'failed', active);
|
|
97
|
+
}
|
|
98
|
+
const flags = assertion.scope === 'GLOBAL'
|
|
99
|
+
? after.scenario.globalFlags
|
|
100
|
+
: assertion.scope === 'ROOT'
|
|
101
|
+
? after.scenario.flags
|
|
102
|
+
: after.scenario.scopes?.[assertion.scope]?.flags;
|
|
103
|
+
const targets = assertion.scope === 'ROOT'
|
|
104
|
+
? after.scenario.eventTargets
|
|
105
|
+
: after.scenario.scopes?.[assertion.scope]?.eventTargets;
|
|
106
|
+
if (flags === undefined && assertion.flags.length > 0)
|
|
107
|
+
return result(assertion, 'unresolved', undefined, 'Cleanup flag scope is undeclared');
|
|
108
|
+
const lingeringFlags = assertion.flags.filter((flag) => flags?.includes(flag));
|
|
109
|
+
const lingeringTargets = assertion.targets.filter((target) => targets?.[target] !== undefined);
|
|
110
|
+
return result(assertion, lingeringFlags.length === 0 && lingeringTargets.length === 0 ? 'passed' : 'failed', { lingeringFlags, lingeringTargets });
|
|
111
|
+
});
|
|
112
|
+
}
|