hoi4-agent-tools 3.0.9 → 3.2.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 +32 -1
- package/README.md +10 -2
- package/dist/bin/stdio.js +23 -12
- package/dist/hoi4_agent_tools/core/analysis-checkpoints.js +82 -0
- package/dist/hoi4_agent_tools/core/analysis-evidence.js +9 -0
- package/dist/hoi4_agent_tools/core/analysis-job-operations.js +38 -0
- package/dist/hoi4_agent_tools/core/artifact-resource.js +173 -0
- package/dist/hoi4_agent_tools/core/artifacts.js +84 -2
- package/dist/hoi4_agent_tools/core/condition-evaluator.js +16 -0
- package/dist/hoi4_agent_tools/core/dependency-pages.js +216 -0
- package/dist/hoi4_agent_tools/core/dependency-walk.js +266 -0
- package/dist/hoi4_agent_tools/core/domain-validation.js +188 -0
- package/dist/hoi4_agent_tools/core/engine.js +48 -5
- package/dist/hoi4_agent_tools/core/helper-expansion.js +186 -0
- package/dist/hoi4_agent_tools/core/impact-comparison.js +49 -0
- package/dist/hoi4_agent_tools/core/impact-graph.js +301 -0
- package/dist/hoi4_agent_tools/core/impact-semantic.js +256 -0
- package/dist/hoi4_agent_tools/core/index-segments.js +137 -0
- package/dist/hoi4_agent_tools/core/index.js +47 -4
- package/dist/hoi4_agent_tools/core/job-controls.js +109 -0
- package/dist/hoi4_agent_tools/core/job-executor.js +190 -0
- package/dist/hoi4_agent_tools/core/job-service.js +112 -0
- package/dist/hoi4_agent_tools/core/job-store.js +641 -0
- package/dist/hoi4_agent_tools/core/job-transactions.js +126 -0
- package/dist/hoi4_agent_tools/core/job-worker-host.js +202 -0
- package/dist/hoi4_agent_tools/core/job-worker.js +64 -0
- package/dist/hoi4_agent_tools/core/operation-context.js +31 -0
- package/dist/hoi4_agent_tools/core/operation-result.js +412 -0
- package/dist/hoi4_agent_tools/core/operation-tasks.js +387 -0
- package/dist/hoi4_agent_tools/core/persistent-analysis-cache.js +383 -0
- package/dist/hoi4_agent_tools/core/result.js +1 -0
- package/dist/hoi4_agent_tools/core/scanner.js +15 -75
- package/dist/hoi4_agent_tools/core/semantic-dependencies.js +233 -0
- package/dist/hoi4_agent_tools/core/shared-request-capacity.js +43 -11
- package/dist/hoi4_agent_tools/core/source/cache.js +107 -0
- package/dist/hoi4_agent_tools/core/source/parser.js +11 -1
- package/dist/hoi4_agent_tools/core/source-overlay.js +125 -0
- package/dist/hoi4_agent_tools/core/transaction-execution.js +134 -0
- package/dist/hoi4_agent_tools/core/transactions.js +80 -27
- package/dist/hoi4_agent_tools/decision/ai.js +104 -0
- package/dist/hoi4_agent_tools/decision/comparison.js +106 -0
- package/dist/hoi4_agent_tools/decision/cost.js +177 -0
- package/dist/hoi4_agent_tools/decision/evaluation.js +256 -0
- package/dist/hoi4_agent_tools/decision/lifecycle.js +114 -0
- package/dist/hoi4_agent_tools/decision/service.js +172 -0
- package/dist/hoi4_agent_tools/decision/source-inventory.js +182 -0
- package/dist/hoi4_agent_tools/event/graph.js +214 -290
- package/dist/hoi4_agent_tools/event/helper-expansion.js +33 -0
- package/dist/hoi4_agent_tools/event/job-operations.js +51 -0
- package/dist/hoi4_agent_tools/event/operations.js +179 -0
- package/dist/hoi4_agent_tools/event/service.js +67 -15
- package/dist/hoi4_agent_tools/event/source-analysis.js +5 -4
- package/dist/hoi4_agent_tools/focus/job-operations.js +77 -0
- package/dist/hoi4_agent_tools/focus/tool-operations.js +669 -0
- package/dist/hoi4_agent_tools/focus/tool-support.js +123 -0
- package/dist/hoi4_agent_tools/gui/job-operations.js +81 -0
- package/dist/hoi4_agent_tools/gui/tool-operations.js +270 -0
- package/dist/hoi4_agent_tools/impact/scenario-suites.js +74 -0
- package/dist/hoi4_agent_tools/impact/service.js +127 -0
- package/dist/hoi4_agent_tools/map/job-operations.js +76 -0
- package/dist/hoi4_agent_tools/map/tool-operations.js +493 -0
- package/dist/hoi4_agent_tools/mcp/prompts/probability.js +25 -0
- package/dist/hoi4_agent_tools/mcp/prompts/register-modern.js +29 -0
- package/dist/hoi4_agent_tools/mcp/resources/register-modern.js +34 -0
- package/dist/hoi4_agent_tools/mcp/resources/register.js +4 -150
- package/dist/hoi4_agent_tools/mcp/server/base-tools.js +3 -219
- package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +188 -0
- package/dist/hoi4_agent_tools/mcp/server/create.js +18 -6
- package/dist/hoi4_agent_tools/mcp/server/instructions.js +2 -0
- package/dist/hoi4_agent_tools/mcp/server/job-task-store.js +67 -0
- package/dist/hoi4_agent_tools/mcp/server/legacy-task-tools.js +20 -0
- package/dist/hoi4_agent_tools/mcp/server/modern-tasks.js +168 -0
- package/dist/hoi4_agent_tools/mcp/server/progress.js +17 -15
- package/dist/hoi4_agent_tools/mcp/server/request-lifecycle.js +45 -0
- package/dist/hoi4_agent_tools/mcp/server/result.js +2 -412
- package/dist/hoi4_agent_tools/mcp/server/task-request-context.js +9 -0
- package/dist/hoi4_agent_tools/mcp/server/task-tool-catalog.js +16 -0
- package/dist/hoi4_agent_tools/mcp/server/task-tool-definition.js +1 -0
- package/dist/hoi4_agent_tools/mcp/server/transaction-execution.js +1 -123
- package/dist/hoi4_agent_tools/mcp/tools/analysis.js +65 -0
- package/dist/hoi4_agent_tools/mcp/tools/chaosx.js +38 -21
- package/dist/hoi4_agent_tools/mcp/tools/event.js +24 -315
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +34 -1039
- package/dist/hoi4_agent_tools/mcp/tools/gui.js +19 -504
- package/dist/hoi4_agent_tools/mcp/tools/job.js +46 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.js +21 -600
- package/dist/hoi4_agent_tools/mcp/tools/probability.js +39 -463
- package/dist/hoi4_agent_tools/mcp/tools/technology.js +40 -304
- package/dist/hoi4_agent_tools/mcp/transports/http.js +58 -1
- package/dist/hoi4_agent_tools/mcp/transports/modern-task-routing.js +109 -0
- package/dist/hoi4_agent_tools/mcp/transports/negotiated-stdio.js +121 -0
- package/dist/hoi4_agent_tools/probability/job-operations.js +58 -0
- package/dist/hoi4_agent_tools/probability/operations.js +183 -0
- package/dist/hoi4_agent_tools/probability/service.js +24 -3
- package/dist/hoi4_agent_tools/schemas/analysis.js +228 -0
- package/dist/hoi4_agent_tools/schemas/common.js +2 -0
- package/dist/hoi4_agent_tools/schemas/event.js +72 -1
- package/dist/hoi4_agent_tools/schemas/focus-requests.js +189 -0
- package/dist/hoi4_agent_tools/schemas/gui-requests.js +193 -0
- package/dist/hoi4_agent_tools/schemas/helper-expansion.js +58 -0
- package/dist/hoi4_agent_tools/schemas/map-requests.js +85 -0
- package/dist/hoi4_agent_tools/schemas/probability-requests.js +168 -0
- package/dist/hoi4_agent_tools/schemas/technology.js +90 -1
- package/dist/hoi4_agent_tools/schemas/transaction.js +1 -0
- package/dist/hoi4_agent_tools/technology/graph.js +83 -78
- package/dist/hoi4_agent_tools/technology/helper-expansion.js +33 -0
- package/dist/hoi4_agent_tools/technology/job-operations.js +60 -0
- package/dist/hoi4_agent_tools/technology/operations.js +125 -0
- package/dist/hoi4_agent_tools/technology/service.js +89 -15
- package/dist/hoi4_agent_tools/technology/source-analysis.js +2 -1
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/README.md +3 -0
- package/docs/analysis.md +100 -0
- package/docs/development.md +2 -0
- package/docs/events.md +7 -2
- package/docs/helper-expansion.md +78 -0
- package/docs/http.md +2 -0
- package/docs/jobs.md +86 -0
- package/docs/technology.md +6 -2
- package/package.json +15 -6
- 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 +290 -0
- 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 +44 -0
- package/schemas/helper-expansion-summary.schema.json +70 -0
- package/schemas/impact-inspect-input.schema.json +203 -0
- package/schemas/map-operation.schema.json +1 -1
- package/schemas/operation-result.schema.json +1 -1
- 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/server.json +3 -3
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { compareCodeUnits } from '../core/canonical.js';
|
|
2
|
+
import { assignments, parseClausewitz, } from '../core/source/index.js';
|
|
3
|
+
export const decisionFieldNames = [
|
|
4
|
+
'allowed',
|
|
5
|
+
'visible',
|
|
6
|
+
'available',
|
|
7
|
+
'targets',
|
|
8
|
+
'target_array',
|
|
9
|
+
'state_trigger',
|
|
10
|
+
'target_root_trigger',
|
|
11
|
+
'target_trigger',
|
|
12
|
+
'cost',
|
|
13
|
+
'custom_cost_trigger',
|
|
14
|
+
'custom_cost_text',
|
|
15
|
+
'complete_effect',
|
|
16
|
+
'fire_only_once',
|
|
17
|
+
'days_re_enable',
|
|
18
|
+
'days_remove',
|
|
19
|
+
'remove_trigger',
|
|
20
|
+
'remove_effect',
|
|
21
|
+
'cancel_trigger',
|
|
22
|
+
'cancel_if_not_visible',
|
|
23
|
+
'cancel_effect',
|
|
24
|
+
'days_mission_timeout',
|
|
25
|
+
'timeout_effect',
|
|
26
|
+
'activation',
|
|
27
|
+
'selectable_mission',
|
|
28
|
+
'ai_will_do',
|
|
29
|
+
];
|
|
30
|
+
/** Static targeting declarations; scenario evaluation determines whether a target qualifies. */
|
|
31
|
+
export function decisionTargetCatalog(source) {
|
|
32
|
+
const explicitTargets = source.fields.targets.flatMap((assignment) => {
|
|
33
|
+
if (assignment.value.type !== 'block')
|
|
34
|
+
return [];
|
|
35
|
+
return [
|
|
36
|
+
...assignment.value.entries
|
|
37
|
+
.filter((entry) => entry.type === 'scalar')
|
|
38
|
+
.map((entry) => entry.value),
|
|
39
|
+
...assignments(assignment.value, 'state')
|
|
40
|
+
.filter((entry) => entry.value.type === 'scalar')
|
|
41
|
+
.map((entry) => entry.value.value),
|
|
42
|
+
];
|
|
43
|
+
});
|
|
44
|
+
const targetArrays = source.fields.target_array.flatMap((assignment) => assignment.value.type === 'scalar' ? [assignment.value.value] : []);
|
|
45
|
+
const stateFilters = source.fields.state_trigger.flatMap((assignment) => assignment.value.type === 'scalar' ? [assignment.value.value] : []);
|
|
46
|
+
const hasTargetRootTrigger = source.fields.target_root_trigger.length > 0;
|
|
47
|
+
const hasTargetTrigger = source.fields.target_trigger.length > 0;
|
|
48
|
+
return {
|
|
49
|
+
targeted: explicitTargets.length > 0 ||
|
|
50
|
+
targetArrays.length > 0 ||
|
|
51
|
+
stateFilters.some((filter) => filter !== 'no') ||
|
|
52
|
+
hasTargetRootTrigger ||
|
|
53
|
+
hasTargetTrigger,
|
|
54
|
+
explicitTargets,
|
|
55
|
+
targetArrays,
|
|
56
|
+
stateFilters,
|
|
57
|
+
hasTargetRootTrigger,
|
|
58
|
+
hasTargetTrigger,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function fields(block) {
|
|
62
|
+
return Object.fromEntries(decisionFieldNames.map((name) => [name, assignments(block, name)]));
|
|
63
|
+
}
|
|
64
|
+
function sourceDocument(file, documents) {
|
|
65
|
+
if (file === undefined)
|
|
66
|
+
return undefined;
|
|
67
|
+
const existing = documents.get(file.displayPath);
|
|
68
|
+
if (existing !== undefined)
|
|
69
|
+
return existing;
|
|
70
|
+
const parsed = parseClausewitz(file.bytes, file.displayPath);
|
|
71
|
+
documents.set(file.displayPath, parsed);
|
|
72
|
+
return parsed;
|
|
73
|
+
}
|
|
74
|
+
function categoryBlock(document, id) {
|
|
75
|
+
return assignments(document.root, id).find((assignment) => assignment.value.type === 'block')
|
|
76
|
+
?.value;
|
|
77
|
+
}
|
|
78
|
+
function sourceOrder(left, right) {
|
|
79
|
+
return (compareCodeUnits(left.id, right.id) ||
|
|
80
|
+
right.loadOrder - left.loadOrder ||
|
|
81
|
+
compareCodeUnits(left.path, right.path));
|
|
82
|
+
}
|
|
83
|
+
/** Reuses the shared index's active/overridden selection and source inventory. */
|
|
84
|
+
export function decisionSourceInventory(snapshot) {
|
|
85
|
+
const files = new Map(snapshot.files.map((file) => [file.displayPath, file]));
|
|
86
|
+
const documents = new Map();
|
|
87
|
+
const unresolvedDefinitions = [];
|
|
88
|
+
const categories = [];
|
|
89
|
+
const decisions = [];
|
|
90
|
+
const overrides = [
|
|
91
|
+
...snapshot.index.findAll('decision_category'),
|
|
92
|
+
...snapshot.index.findAll('decision'),
|
|
93
|
+
]
|
|
94
|
+
.filter(({ overridden }) => overridden)
|
|
95
|
+
.sort(sourceOrder)
|
|
96
|
+
.map(({ kind, id, path, rootKind, loadOrder, location, sourceShadowed }) => ({
|
|
97
|
+
kind,
|
|
98
|
+
id,
|
|
99
|
+
path,
|
|
100
|
+
rootKind,
|
|
101
|
+
loadOrder,
|
|
102
|
+
...(location === undefined ? {} : { location }),
|
|
103
|
+
sourceShadowed,
|
|
104
|
+
}));
|
|
105
|
+
for (const symbol of snapshot.index
|
|
106
|
+
.findAll('decision_category')
|
|
107
|
+
.filter(({ overridden }) => !overridden)
|
|
108
|
+
.sort(sourceOrder)) {
|
|
109
|
+
const file = files.get(symbol.path);
|
|
110
|
+
const document = sourceDocument(file, documents);
|
|
111
|
+
const block = document === undefined ? undefined : categoryBlock(document, symbol.id);
|
|
112
|
+
if (file === undefined || document === undefined || block === undefined) {
|
|
113
|
+
unresolvedDefinitions.push({
|
|
114
|
+
kind: 'decision_category',
|
|
115
|
+
id: symbol.id,
|
|
116
|
+
path: symbol.path,
|
|
117
|
+
reason: 'Active category index entry could not be matched to a source block',
|
|
118
|
+
});
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
categories.push({
|
|
122
|
+
id: symbol.id,
|
|
123
|
+
path: symbol.path,
|
|
124
|
+
rootKind: file.rootKind,
|
|
125
|
+
loadOrder: file.loadOrder,
|
|
126
|
+
sourceHash: file.sha256,
|
|
127
|
+
...(symbol.location === undefined ? {} : { location: symbol.location }),
|
|
128
|
+
document,
|
|
129
|
+
block,
|
|
130
|
+
fields: fields(block),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
for (const symbol of snapshot.index
|
|
134
|
+
.findAll('decision')
|
|
135
|
+
.filter(({ overridden }) => !overridden)
|
|
136
|
+
.sort(sourceOrder)) {
|
|
137
|
+
const category = typeof symbol.metadata.category === 'string' ? symbol.metadata.category : undefined;
|
|
138
|
+
const file = files.get(symbol.path);
|
|
139
|
+
const document = sourceDocument(file, documents);
|
|
140
|
+
const categoryNode = document === undefined || category === undefined
|
|
141
|
+
? undefined
|
|
142
|
+
: categoryBlock(document, category);
|
|
143
|
+
const decisionNode = categoryNode === undefined
|
|
144
|
+
? undefined
|
|
145
|
+
: assignments(categoryNode, symbol.id).find((assignment) => assignment.value.type === 'block')?.value;
|
|
146
|
+
if (file === undefined ||
|
|
147
|
+
document === undefined ||
|
|
148
|
+
category === undefined ||
|
|
149
|
+
decisionNode?.type !== 'block') {
|
|
150
|
+
unresolvedDefinitions.push({
|
|
151
|
+
kind: 'decision',
|
|
152
|
+
id: symbol.id,
|
|
153
|
+
path: symbol.path,
|
|
154
|
+
reason: 'Active decision index entry could not be matched to a source block',
|
|
155
|
+
});
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const decisionFields = fields(decisionNode);
|
|
159
|
+
decisions.push({
|
|
160
|
+
id: symbol.id,
|
|
161
|
+
category,
|
|
162
|
+
kind: decisionFields.days_mission_timeout.length > 0 ? 'mission' : 'decision',
|
|
163
|
+
path: symbol.path,
|
|
164
|
+
rootKind: file.rootKind,
|
|
165
|
+
loadOrder: file.loadOrder,
|
|
166
|
+
sourceHash: file.sha256,
|
|
167
|
+
...(symbol.location === undefined ? {} : { location: symbol.location }),
|
|
168
|
+
document,
|
|
169
|
+
block: decisionNode,
|
|
170
|
+
fields: decisionFields,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
sourceRevision: snapshot.revision,
|
|
175
|
+
complete: snapshot.complete && unresolvedDefinitions.length === 0,
|
|
176
|
+
skippedSourceCount: snapshot.skippedSourceCount,
|
|
177
|
+
decisions,
|
|
178
|
+
categories,
|
|
179
|
+
overrides,
|
|
180
|
+
unresolvedDefinitions,
|
|
181
|
+
};
|
|
182
|
+
}
|