hoi4-agent-tools 4.20.3 → 4.22.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 +40 -0
- package/README.md +2 -0
- package/dist/bin/setup.js +1 -0
- package/dist/bin/stdio.js +1 -0
- package/dist/hoi4_agent_tools/characters/write-operations.js +2 -2
- package/dist/hoi4_agent_tools/characters/write-plan.js +21 -205
- package/dist/hoi4_agent_tools/common-write/documented-lists.js +62 -0
- package/dist/hoi4_agent_tools/common-write/limits.js +35 -0
- package/dist/hoi4_agent_tools/common-write/paths.js +17 -0
- package/dist/hoi4_agent_tools/common-write/write-job-operations.js +42 -0
- package/dist/hoi4_agent_tools/common-write/write-operations.js +360 -0
- package/dist/hoi4_agent_tools/common-write/write-plan.js +34 -0
- package/dist/hoi4_agent_tools/core/artifacts-engine.js +272 -0
- package/dist/hoi4_agent_tools/core/configuration.js +6 -0
- package/dist/hoi4_agent_tools/core/domain-tools.js +8 -0
- package/dist/hoi4_agent_tools/core/engine.js +67 -21
- package/dist/hoi4_agent_tools/core/idle-cache-lifetime.js +7 -0
- package/dist/hoi4_agent_tools/core/job-controls.js +12 -2
- package/dist/hoi4_agent_tools/core/job-executor.js +8 -7
- package/dist/hoi4_agent_tools/core/job-operation-registration.js +4 -0
- package/dist/hoi4_agent_tools/core/job-store.js +97 -5
- package/dist/hoi4_agent_tools/core/job-worker-host.js +2 -2
- package/dist/hoi4_agent_tools/core/operation-result.js +118 -33
- package/dist/hoi4_agent_tools/core/operation-tasks.js +4 -2
- package/dist/hoi4_agent_tools/core/transactions.js +6 -0
- package/dist/hoi4_agent_tools/core/workspace.js +25 -2
- package/dist/hoi4_agent_tools/country/job-operations.js +42 -0
- package/dist/hoi4_agent_tools/country/write-operations.js +646 -0
- package/dist/hoi4_agent_tools/country/write-plan.js +28 -0
- package/dist/hoi4_agent_tools/decision/write-operations.js +7 -8
- package/dist/hoi4_agent_tools/decision/write-plan.js +25 -245
- package/dist/hoi4_agent_tools/doctrine/write-operations.js +2 -2
- package/dist/hoi4_agent_tools/doctrine/write-plan.js +21 -180
- package/dist/hoi4_agent_tools/event/graph.js +3 -3
- package/dist/hoi4_agent_tools/event/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/event/write-job-operations.js +2 -2
- package/dist/hoi4_agent_tools/event/write-operations.js +9 -10
- package/dist/hoi4_agent_tools/event/write-plan.js +28 -278
- package/dist/hoi4_agent_tools/focus/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/gui/assets.js +3 -13
- package/dist/hoi4_agent_tools/gui/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/gui/layout.js +2 -4
- package/dist/hoi4_agent_tools/gui/renderer.js +2 -1
- package/dist/hoi4_agent_tools/gui/source-graph.js +16 -0
- package/dist/hoi4_agent_tools/gui/studio.js +31 -0
- package/dist/hoi4_agent_tools/ideas/write-operations.js +7 -8
- package/dist/hoi4_agent_tools/ideas/write-plan.js +24 -304
- package/dist/hoi4_agent_tools/map/engine-validation.js +230 -0
- package/dist/hoi4_agent_tools/map/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/map/landmass-source.js +42 -0
- package/dist/hoi4_agent_tools/map/landmass.js +190 -0
- package/dist/hoi4_agent_tools/map/model.js +17 -3
- package/dist/hoi4_agent_tools/map/operations.js +20 -6
- package/dist/hoi4_agent_tools/map/references.js +6 -3
- package/dist/hoi4_agent_tools/map/service.js +88 -8
- package/dist/hoi4_agent_tools/map/validation.js +12 -18
- package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +2 -0
- package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +1 -1
- package/dist/hoi4_agent_tools/mcp/server/create.js +4 -0
- package/dist/hoi4_agent_tools/mcp/server/task-tool-catalog.js +4 -0
- package/dist/hoi4_agent_tools/mcp/tools/common-write.js +21 -0
- package/dist/hoi4_agent_tools/mcp/tools/country-write.js +21 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.js +1 -1
- package/dist/hoi4_agent_tools/mcp/transports/http.js +2 -0
- package/dist/hoi4_agent_tools/mcp/transports/negotiated-stdio.js +24 -16
- package/dist/hoi4_agent_tools/probability/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/runtime.js +83 -3
- package/dist/hoi4_agent_tools/schemas/character-write.js +5 -1
- package/dist/hoi4_agent_tools/schemas/common-write.js +74 -0
- package/dist/hoi4_agent_tools/schemas/country-write.js +206 -0
- package/dist/hoi4_agent_tools/schemas/decision-write.js +5 -1
- package/dist/hoi4_agent_tools/schemas/doctrine-write.js +5 -1
- package/dist/hoi4_agent_tools/schemas/event-write.js +5 -1
- package/dist/hoi4_agent_tools/schemas/idea-write.js +5 -1
- package/dist/hoi4_agent_tools/schemas/landmass.js +129 -0
- package/dist/hoi4_agent_tools/schemas/localisation-write.js +10 -1
- package/dist/hoi4_agent_tools/schemas/map-requests.js +1 -1
- package/dist/hoi4_agent_tools/schemas/map.js +2 -0
- package/dist/hoi4_agent_tools/schemas/tech-write.js +5 -1
- package/dist/hoi4_agent_tools/script-write/engine-plan.js +45 -0
- package/dist/hoi4_agent_tools/technology/engine-graph.js +156 -0
- package/dist/hoi4_agent_tools/technology/job-operations.js +2 -2
- package/dist/hoi4_agent_tools/technology/operations.js +1 -2
- package/dist/hoi4_agent_tools/technology/service.js +30 -59
- package/dist/hoi4_agent_tools/technology/write-job-operations.js +2 -2
- package/dist/hoi4_agent_tools/technology/write-operations.js +2 -2
- package/dist/hoi4_agent_tools/technology/write-plan.js +21 -207
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/configuration.md +11 -10
- package/docs/jobs.md +2 -2
- package/docs/setup.md +1 -0
- package/docs/tools.md +16 -2
- package/docs/troubleshooting.md +11 -11
- package/engine/bin/darwin-arm64/hoi4-engine +0 -0
- package/engine/bin/linux-arm64/hoi4-engine +0 -0
- package/engine/bin/linux-x64/hoi4-engine +0 -0
- package/engine/bin/manifest.json +8 -8
- package/engine/bin/win32-x64/hoi4-engine.exe +0 -0
- package/npm-shrinkwrap.json +43 -19
- package/package.json +2 -2
- package/schemas/configuration.schema.json +143 -134
- 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/error-log-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/geography-model.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 +354 -1
- package/schemas/mechanic-test-input.schema.json +1 -1
- package/schemas/mod-index-input.schema.json +1 -1
- package/schemas/operation-result.schema.json +1 -1
- package/schemas/package-check-input.schema.json +1 -1
- package/schemas/package-manifest.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/schemas/reference-context-input.schema.json +1 -1
- package/schemas/reference-read-input.schema.json +1 -1
- package/schemas/reference-search-input.schema.json +1 -1
- package/schemas/reference-sheets.schema.json +1 -1
- package/schemas/scenario-suite.schema.json +1 -1
- package/schemas/scenario-test-input.schema.json +1 -1
- package/schemas/script-validate-input.schema.json +1 -1
- package/schemas/shared-scenario.schema.json +1 -1
- package/schemas/source-lookup-input.schema.json +1 -1
- package/server.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { realpathSync } from 'node:fs';
|
|
1
2
|
import { lstat, mkdir, opendir, readFile, readdir, realpath } from 'node:fs/promises';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { WORKSPACE_MAX_REGISTRATIONS, workspaceRegistrationSchema, } from './configuration.js';
|
|
@@ -389,6 +390,7 @@ export class WorkspaceResolver {
|
|
|
389
390
|
#state = 'prepared';
|
|
390
391
|
#population;
|
|
391
392
|
#startupError;
|
|
393
|
+
#useHook;
|
|
392
394
|
constructor(configuration) {
|
|
393
395
|
this.configuration = configuration;
|
|
394
396
|
}
|
|
@@ -503,6 +505,14 @@ export class WorkspaceResolver {
|
|
|
503
505
|
: new ServiceError('INTERNAL_ERROR', error instanceof Error ? error.message : String(error));
|
|
504
506
|
return this.#startupError;
|
|
505
507
|
}
|
|
508
|
+
/**
|
|
509
|
+
* Run `hook` with the workspace's ID before each file access through this resolver
|
|
510
|
+
* (`refreshDescriptors`, `resolvePath`, `resolvePathInRoot`). The engine uses it to
|
|
511
|
+
* recover a workspace on its first use.
|
|
512
|
+
*/
|
|
513
|
+
onWorkspaceUse(hook) {
|
|
514
|
+
this.#useHook = hook;
|
|
515
|
+
}
|
|
506
516
|
/** The reason the server could not start, when it could not. */
|
|
507
517
|
startupError() {
|
|
508
518
|
return this.#startupError;
|
|
@@ -551,7 +561,16 @@ export class WorkspaceResolver {
|
|
|
551
561
|
throw new ServiceError('WORKSPACE_CONTEXT_NOT_FOUND', 'No writable mod workspace is configured for the MCP server', workspaceCandidates(workspaces));
|
|
552
562
|
}
|
|
553
563
|
const currentDirectory = path.normalize(process.cwd());
|
|
554
|
-
|
|
564
|
+
// Workspace roots are canonical, so a symlink, junction or 8.3 name must be resolved too.
|
|
565
|
+
let canonicalDirectory = currentDirectory;
|
|
566
|
+
try {
|
|
567
|
+
canonicalDirectory = path.normalize(realpathSync.native(currentDirectory));
|
|
568
|
+
}
|
|
569
|
+
catch {
|
|
570
|
+
// A vanished working folder keeps its lexical form.
|
|
571
|
+
}
|
|
572
|
+
const containing = workspaces.filter((workspace) => isWithin(workspace.modRoot, currentDirectory) ||
|
|
573
|
+
isWithin(workspace.modRoot, canonicalDirectory));
|
|
555
574
|
if (containing.length === 1)
|
|
556
575
|
return containing[0].id;
|
|
557
576
|
if (containing.length > 1) {
|
|
@@ -723,6 +742,7 @@ export class WorkspaceResolver {
|
|
|
723
742
|
*/
|
|
724
743
|
async refreshDescriptors(workspaceId, principal) {
|
|
725
744
|
const workspace = this.get(workspaceId, principal);
|
|
745
|
+
await this.#useHook?.(workspace.id);
|
|
726
746
|
if (workspace.registration.kind === 'game')
|
|
727
747
|
return;
|
|
728
748
|
const dependencies = workspace.registration.dependencies;
|
|
@@ -809,13 +829,16 @@ export class WorkspaceResolver {
|
|
|
809
829
|
* workspace lookup when it was TypeScript.
|
|
810
830
|
*/
|
|
811
831
|
async getAfterPathCheck(workspaceId, relativePath, principal) {
|
|
832
|
+
let workspace;
|
|
812
833
|
try {
|
|
813
|
-
|
|
834
|
+
workspace = this.get(workspaceId, principal);
|
|
814
835
|
}
|
|
815
836
|
catch (error) {
|
|
816
837
|
await refuseUnsafeRelativePath(relativePath);
|
|
817
838
|
throw error;
|
|
818
839
|
}
|
|
840
|
+
await this.#useHook?.(workspace.id);
|
|
841
|
+
return workspace;
|
|
819
842
|
}
|
|
820
843
|
allowedWorkspaceIds(principal) {
|
|
821
844
|
const token = this.configuration.http.tokens.find((entry) => entry.principal === principal);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { toolResult } from '../core/operation-result.js';
|
|
3
|
+
import { ServiceError } from '../core/result.js';
|
|
4
|
+
import { countryWriteRequestSchema } from '../schemas/country-write.js';
|
|
5
|
+
import { completeCountryWrite, prepareCountryWrite, previewCountryWrite, } from './write-operations.js';
|
|
6
|
+
const wireResult = z.record(z.string(), z.json());
|
|
7
|
+
function wire(result) {
|
|
8
|
+
return wireResult.parse(JSON.parse(JSON.stringify(toolResult(result))));
|
|
9
|
+
}
|
|
10
|
+
/** Registers `hoi4.country_write`: a read-only preview, or one journaled transaction. */
|
|
11
|
+
export function registerCountryWriteJobs(operations, engine) {
|
|
12
|
+
operations.registerWrite('hoi4.country_write', countryWriteRequestSchema, async (input, context) => {
|
|
13
|
+
if (input.workspaceId !== 'current' && input.workspaceId !== context.workspaceId)
|
|
14
|
+
throw new ServiceError('JOB_ARGUMENT_SCOPE_MISMATCH', 'The request workspace does not match the authorized job workspace');
|
|
15
|
+
const operationContext = {
|
|
16
|
+
workspaceId: context.workspaceId,
|
|
17
|
+
...(context.principal === undefined ? {} : { principal: context.principal }),
|
|
18
|
+
signal: context.signal,
|
|
19
|
+
progress: (completed, total, message) => context.progress({ completed, total, message }),
|
|
20
|
+
};
|
|
21
|
+
if (!input.apply)
|
|
22
|
+
return {
|
|
23
|
+
readOnlyPreview: wire(await previewCountryWrite(engine, input, operationContext)),
|
|
24
|
+
};
|
|
25
|
+
const prepared = await prepareCountryWrite(engine, input, operationContext);
|
|
26
|
+
if ('readOnlyPreview' in prepared)
|
|
27
|
+
return { readOnlyPreview: wire(prepared.readOnlyPreview) };
|
|
28
|
+
return { transaction: prepared.transaction, recipe: { ...prepared.recipe } };
|
|
29
|
+
}, async (_input, execution, _reconciled, recipe, context) => {
|
|
30
|
+
const result = completeCountryWrite(context.workspaceId, execution, recipe);
|
|
31
|
+
await context.progress({
|
|
32
|
+
completed: 3,
|
|
33
|
+
total: 3,
|
|
34
|
+
message: execution.outcome === 'applied'
|
|
35
|
+
? 'Country change complete'
|
|
36
|
+
: execution.outcome === 'unchanged'
|
|
37
|
+
? 'The country already matched the request'
|
|
38
|
+
: 'Country change blocked',
|
|
39
|
+
});
|
|
40
|
+
return wire(result);
|
|
41
|
+
});
|
|
42
|
+
}
|