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.
- package/CHANGELOG.md +21 -0
- package/README.md +3 -3
- package/dist/bin/setup.js +38 -0
- package/dist/bin/stdio.js +12 -10
- package/dist/hoi4_agent_tools/core/configuration.js +29 -0
- package/dist/hoi4_agent_tools/core/domain-tools.js +4 -0
- package/dist/hoi4_agent_tools/core/engine-check.js +87 -0
- package/dist/hoi4_agent_tools/core/engine-client.js +1 -1
- package/dist/hoi4_agent_tools/core/engine.js +18 -2
- package/dist/hoi4_agent_tools/core/job-operation-registration.js +2 -0
- package/dist/hoi4_agent_tools/core/job-store.js +1 -1
- package/dist/hoi4_agent_tools/focus/native-effects.js +1 -1
- package/dist/hoi4_agent_tools/localisation/job-operations.js +42 -0
- package/dist/hoi4_agent_tools/localisation/write-diff.js +96 -0
- package/dist/hoi4_agent_tools/localisation/write-format.js +329 -0
- package/dist/hoi4_agent_tools/localisation/write-operations.js +213 -0
- package/dist/hoi4_agent_tools/localisation/write-plan.js +557 -0
- package/dist/hoi4_agent_tools/map/gameplay/crossing-validation.js +17 -0
- package/dist/hoi4_agent_tools/map/model.js +31 -1
- package/dist/hoi4_agent_tools/map/operations.js +37 -8
- package/dist/hoi4_agent_tools/map/references.js +87 -0
- package/dist/hoi4_agent_tools/map/relief/hydrology.js +7 -2
- package/dist/hoi4_agent_tools/map/relief/terrain-synthesis.js +1 -0
- package/dist/hoi4_agent_tools/map/service.js +13 -4
- package/dist/hoi4_agent_tools/map/tool-operations.js +6 -0
- package/dist/hoi4_agent_tools/map/world-edge.js +0 -25
- package/dist/hoi4_agent_tools/map/world.js +181 -64
- package/dist/hoi4_agent_tools/mcp/plugins.js +74 -0
- package/dist/hoi4_agent_tools/mcp/server/argument-errors.js +5 -0
- package/dist/hoi4_agent_tools/mcp/server/create-modern-operations.js +15 -21
- package/dist/hoi4_agent_tools/mcp/server/create.js +5 -1
- package/dist/hoi4_agent_tools/mcp/server/request-lifecycle.js +10 -2
- package/dist/hoi4_agent_tools/mcp/server/task-tool-catalog.js +2 -0
- package/dist/hoi4_agent_tools/mcp/server/tool-profiles.js +83 -0
- package/dist/hoi4_agent_tools/mcp/tools/localisation-write.js +21 -0
- package/dist/hoi4_agent_tools/mcp/tools/reference.js +34 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.js +6 -1
- package/dist/hoi4_agent_tools/mcp/transports/negotiated-stdio.js +64 -6
- package/dist/hoi4_agent_tools/probability/model.js +4 -4
- package/dist/hoi4_agent_tools/reference/compat-patch.js +555 -0
- package/dist/hoi4_agent_tools/reference/compat.js +255 -0
- package/dist/hoi4_agent_tools/reference/docs-pack.js +164 -0
- package/dist/hoi4_agent_tools/reference/docs-pack.json +339 -0
- package/dist/hoi4_agent_tools/reference/documented-commands.js +26 -0
- package/dist/hoi4_agent_tools/reference/error-explain.js +235 -0
- package/dist/hoi4_agent_tools/reference/error-explanations.json +262 -0
- package/dist/hoi4_agent_tools/reference/error-log.js +30 -10
- package/dist/hoi4_agent_tools/reference/mod-health.js +255 -0
- package/dist/hoi4_agent_tools/reference/mod-index.js +63 -65
- package/dist/hoi4_agent_tools/reference/operations.js +435 -21
- package/dist/hoi4_agent_tools/reference/script-guard.js +109 -0
- package/dist/hoi4_agent_tools/reference/service.js +58 -20
- package/dist/hoi4_agent_tools/runtime.js +17 -2
- package/dist/hoi4_agent_tools/schemas/compat.js +153 -0
- package/dist/hoi4_agent_tools/schemas/localisation-write.js +154 -0
- package/dist/hoi4_agent_tools/schemas/map.js +5 -1
- package/dist/hoi4_agent_tools/schemas/mod-tools.js +50 -0
- package/dist/hoi4_agent_tools/schemas/modder-tools.js +191 -0
- package/dist/hoi4_agent_tools/version.js +1 -1
- package/docs/configuration.md +14 -11
- package/docs/development.md +2 -0
- package/docs/jobs.md +3 -1
- package/docs/map.md +8 -4
- package/docs/reference.md +47 -5
- package/docs/research/probability-adapter-evidence.md +11 -1
- package/docs/setup.md +23 -3
- package/docs/tools.md +18 -4
- package/docs/troubleshooting.md +1 -1
- 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 +2 -2
- package/package.json +1 -1
- package/schemas/configuration.schema.json +181 -138
- 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 +153 -139
- 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
- package/dist/hoi4_agent_tools/mcp/tools/chaosx.js +0 -509
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool profiles (maintainer decision R-4): every session pays for the tools it lists, so a
|
|
3
|
+
* session lists the core profile unless it asks for more. `core` holds the tools most modding
|
|
4
|
+
* sessions use; `map` the world builder; `advanced` the editors, renders and analyses of focus
|
|
5
|
+
* trees, GUI, events, technology and probability, and the rest. A tool outside the listed
|
|
6
|
+
* profiles is not listed, and still answers a call that names it.
|
|
7
|
+
*/
|
|
8
|
+
export const TOOL_PROFILES = ['core', 'map', 'advanced'];
|
|
9
|
+
/** `all` stands for every profile. */
|
|
10
|
+
export const PROFILE_SELECTION_VALUES = [...TOOL_PROFILES, 'all'];
|
|
11
|
+
/** The profile a session lists when nothing chooses one. */
|
|
12
|
+
export const DEFAULT_PROFILES = ['core'];
|
|
13
|
+
/** The environment variable that chooses profiles for one client registration. */
|
|
14
|
+
export const PROFILES_ENV = 'HOI4_AGENT_TOOLS_PROFILES';
|
|
15
|
+
const coreTools = new Set([
|
|
16
|
+
'hoi4.skill',
|
|
17
|
+
'hoi4.reference_search',
|
|
18
|
+
'hoi4.reference_read',
|
|
19
|
+
'hoi4.reference_context',
|
|
20
|
+
'hoi4.source_lookup',
|
|
21
|
+
'hoi4.script_validate',
|
|
22
|
+
'hoi4.script_guard',
|
|
23
|
+
'hoi4.error_log',
|
|
24
|
+
'hoi4.explain_error',
|
|
25
|
+
'hoi4.mod_health',
|
|
26
|
+
'hoi4.mod_index',
|
|
27
|
+
'hoi4.localisation_inspect',
|
|
28
|
+
'hoi4.localisation_write',
|
|
29
|
+
]);
|
|
30
|
+
const mapTools = new Set(['hoi4.map_inspect', 'hoi4.map_rewrite']);
|
|
31
|
+
/** Job controls follow the long-running tools of map and advanced. */
|
|
32
|
+
const jobTools = new Set(['hoi4.job_inspect', 'hoi4.job_cancel']);
|
|
33
|
+
/** The profiles a tool belongs to. */
|
|
34
|
+
export function profilesOf(name) {
|
|
35
|
+
// A plugin tool (ADR 0081) is listed by every session: the configuration that loads the plugin
|
|
36
|
+
// is the choice, so a profile never hides it.
|
|
37
|
+
if (!name.startsWith('hoi4.'))
|
|
38
|
+
return TOOL_PROFILES;
|
|
39
|
+
if (coreTools.has(name))
|
|
40
|
+
return ['core'];
|
|
41
|
+
if (mapTools.has(name))
|
|
42
|
+
return ['map'];
|
|
43
|
+
if (jobTools.has(name))
|
|
44
|
+
return ['map', 'advanced'];
|
|
45
|
+
return ['advanced'];
|
|
46
|
+
}
|
|
47
|
+
/** Every profile when the selection names `all` or nothing; else the named ones. */
|
|
48
|
+
export function resolveProfiles(selection) {
|
|
49
|
+
if (selection === undefined || selection.includes('all'))
|
|
50
|
+
return new Set(TOOL_PROFILES);
|
|
51
|
+
return new Set(selection.filter((value) => value !== 'all'));
|
|
52
|
+
}
|
|
53
|
+
/** Whether a session with these profiles lists the tool. */
|
|
54
|
+
export function isListed(name, profiles) {
|
|
55
|
+
return profilesOf(name).some((profile) => profiles.has(profile));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Parse `HOI4_AGENT_TOOLS_PROFILES` (`core,map`, `all`). Unknown names fail, so a typo never
|
|
59
|
+
* silently hides every tool.
|
|
60
|
+
*/
|
|
61
|
+
export function parseProfilesEnv(value) {
|
|
62
|
+
if (value === undefined || value.trim() === '')
|
|
63
|
+
return undefined;
|
|
64
|
+
const names = value
|
|
65
|
+
.split(/[\s,]+/u)
|
|
66
|
+
.map((name) => name.trim().toLowerCase())
|
|
67
|
+
.filter(Boolean);
|
|
68
|
+
const unknown = names.filter((name) => !PROFILE_SELECTION_VALUES.includes(name));
|
|
69
|
+
if (unknown.length > 0)
|
|
70
|
+
throw new Error(`${PROFILES_ENV} names unknown profiles: ${unknown.join(', ')}; use ${PROFILE_SELECTION_VALUES.join(', ')}`);
|
|
71
|
+
return names;
|
|
72
|
+
}
|
|
73
|
+
/** One sentence for the server instructions when some tools are not listed. */
|
|
74
|
+
export function profileInstructions(profiles) {
|
|
75
|
+
const missing = TOOL_PROFILES.filter((profile) => !profiles.has(profile));
|
|
76
|
+
if (missing.length === 0)
|
|
77
|
+
return undefined;
|
|
78
|
+
return ` This session lists the ${[...profiles].join(' and ')} tools; the ${missing.join(' and ')} tools (${missing
|
|
79
|
+
.map((profile) => profile === 'map'
|
|
80
|
+
? 'world maps'
|
|
81
|
+
: 'focus, GUI, event, technology, probability and other editors')
|
|
82
|
+
.join('; ')}) need ${PROFILES_ENV}=${[...TOOL_PROFILES].join(',')} in the client's server entry.`;
|
|
83
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { strictOperationResultSchema } from '../server/result.js';
|
|
2
|
+
import { localisationWriteDataSchema, localisationWriteRequestSchema, } from '../../schemas/localisation-write.js';
|
|
3
|
+
import { registerLegacyTaskTools } from '../server/legacy-task-tools.js';
|
|
4
|
+
export const localisationTaskTools = [
|
|
5
|
+
{
|
|
6
|
+
name: 'hoi4.localisation_write',
|
|
7
|
+
title: 'Add or fix localisation',
|
|
8
|
+
description: 'Add localisation keys (mode add: key and text; language, file, replace) or repair localisation files (mode fix: BOM, broken quotes, keys missing from supported languages). Game keys are overridden from a replace folder. apply false returns the diff and writes nothing; apply true writes it. Returns up to 10 files with diffs. Example: {"mode":"add","entries":[{"key":"my_focus","text":"My focus"}]}',
|
|
9
|
+
inputSchema: localisationWriteRequestSchema,
|
|
10
|
+
outputSchema: strictOperationResultSchema(localisationWriteDataSchema),
|
|
11
|
+
annotations: {
|
|
12
|
+
readOnlyHint: false,
|
|
13
|
+
destructiveHint: true,
|
|
14
|
+
idempotentHint: false,
|
|
15
|
+
openWorldHint: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
export function registerLocalisationWriteTools(server, _engine, _context) {
|
|
20
|
+
registerLegacyTaskTools(server, localisationTaskTools);
|
|
21
|
+
}
|
|
@@ -3,10 +3,12 @@ import { ReferenceToolService } from '../../reference/operations.js';
|
|
|
3
3
|
import { referenceContextRequestSchema, referenceReadRequestSchema, referenceSearchRequestSchema, sourceLookupRequestSchema, referenceContextToolDataSchema, referenceReadDataSchema, referenceSearchToolDataSchema, sourceLookupDataSchema, } from '../../schemas/reference.js';
|
|
4
4
|
import { localisationInspectDataSchema, localisationInspectRequestSchema, } from '../../schemas/localisation.js';
|
|
5
5
|
import { systemInspectDataSchema, systemInspectRequestSchema, unitInspectDataSchema, unitInspectRequestSchema, assetInspectDataSchema, assetInspectRequestSchema, } from '../../schemas/system.js';
|
|
6
|
+
import { compatCheckDataSchema, compatCheckRequestSchema } from '../../schemas/compat.js';
|
|
6
7
|
import { ideaInspectDataSchema, ideaInspectRequestSchema } from '../../schemas/ideas.js';
|
|
7
8
|
import { errorLogDataSchema, errorLogRequestSchema, modIndexDataSchema, modIndexRequestSchema, } from '../../schemas/mod-tools.js';
|
|
8
9
|
import { scriptValidateDataSchema, scriptValidateRequestSchema, } from '../../schemas/script-validation.js';
|
|
9
10
|
import { skillDataSchema, skillRequestSchema } from '../../schemas/skill.js';
|
|
11
|
+
import { explainErrorDataSchema, explainErrorRequestSchema, modHealthDataSchema, modHealthRequestSchema, scriptGuardDataSchema, scriptGuardRequestSchema, } from '../../schemas/modder-tools.js';
|
|
10
12
|
const readOnly = {
|
|
11
13
|
readOnlyHint: true,
|
|
12
14
|
destructiveHint: false,
|
|
@@ -62,6 +64,30 @@ export const referenceTools = [
|
|
|
62
64
|
outputSchema: strictOperationResultSchema(errorLogDataSchema),
|
|
63
65
|
annotations: readOnly,
|
|
64
66
|
},
|
|
67
|
+
{
|
|
68
|
+
name: 'hoi4.explain_error',
|
|
69
|
+
title: 'Explain error.log lines',
|
|
70
|
+
description: 'Explain error.log lines: the rule each one breaks, its file and line with the lines around it, and the fix, from a reviewed catalogue of the game\'s messages. Says whether the game documents the command a line names, and the closest documented names. Example: {"line":"Invalid trigger \'stability\' in events/my_events.txt line : 12"}. Returns up to 20 explanations (10 lines).',
|
|
71
|
+
inputSchema: explainErrorRequestSchema,
|
|
72
|
+
outputSchema: strictOperationResultSchema(explainErrorDataSchema),
|
|
73
|
+
annotations: readOnly,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'hoi4.mod_health',
|
|
77
|
+
title: 'Check a whole mod',
|
|
78
|
+
description: 'Check a whole mod in one call: the last error.log, the engine check (unknown effects, triggers and modifiers, duplicate ids, broken overrides), script validation, and the localisation and asset audits. Returns the 10 problems that matter most, each counted with 2 examples, its fix and the tool to use next, and which audits ran. Example: {"limit":5} or {"checks":["error_log","engine_check"]}. Takes up to a minute on a large mod.',
|
|
79
|
+
inputSchema: modHealthRequestSchema,
|
|
80
|
+
outputSchema: strictOperationResultSchema(modHealthDataSchema),
|
|
81
|
+
annotations: readOnly,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'hoi4.script_guard',
|
|
85
|
+
title: 'Find invented commands in new script',
|
|
86
|
+
description: 'Check the files you wrote for invented commands: every effect, trigger and modifier that the installed game documentation does not list and no loaded file defines, with its file, line and the closest real name. Checks the named paths, or the mod script files changed in the last 120 minutes. Needs hoi4-engine. Example: {"paths":["events/my_events.txt"]}. Returns up to 40 names.',
|
|
87
|
+
inputSchema: scriptGuardRequestSchema,
|
|
88
|
+
outputSchema: strictOperationResultSchema(scriptGuardDataSchema),
|
|
89
|
+
annotations: readOnly,
|
|
90
|
+
},
|
|
65
91
|
{
|
|
66
92
|
name: 'hoi4.mod_index',
|
|
67
93
|
title: 'Explore mod content and find free IDs',
|
|
@@ -118,6 +144,14 @@ export const referenceTools = [
|
|
|
118
144
|
outputSchema: strictOperationResultSchema(skillDataSchema),
|
|
119
145
|
annotations: readOnly,
|
|
120
146
|
},
|
|
147
|
+
{
|
|
148
|
+
name: 'hoi4.compat_check',
|
|
149
|
+
title: 'Check a mod against another mod or a game patch',
|
|
150
|
+
description: 'mod: compare this mod with another in both load orders: files at the same path and who wins, duplicate ids, definitions and hooks dropped, replace_path losses, and which order loses less. patch: store the vanilla files the mod overrides and list those a game update changed. Example: {"mode":"mod","other":"my_other_mod"} or {"mode":"patch"}',
|
|
151
|
+
inputSchema: compatCheckRequestSchema,
|
|
152
|
+
outputSchema: strictOperationResultSchema(compatCheckDataSchema),
|
|
153
|
+
annotations: readOnly,
|
|
154
|
+
},
|
|
121
155
|
];
|
|
122
156
|
export function registerReferenceTools(server, engine, context) {
|
|
123
157
|
const service = new ReferenceToolService(engine);
|
|
@@ -13,7 +13,12 @@ import { authenticate, bearerChallenge, HttpAuthError, protectedResourceMetadata
|
|
|
13
13
|
import { BoundedEventStore, SharedEventStoreBudget } from './event-store.js';
|
|
14
14
|
import { createModernOperationServer } from '../server/create-modern-operations.js';
|
|
15
15
|
import { FinalProtocolTransport } from './protocol-gate.js';
|
|
16
|
-
const WRITE_SCOPED_TOOLS = new Set([
|
|
16
|
+
const WRITE_SCOPED_TOOLS = new Set([
|
|
17
|
+
'hoi4.focus_rewrite',
|
|
18
|
+
'hoi4.gui_rewrite',
|
|
19
|
+
'hoi4.map_rewrite',
|
|
20
|
+
'hoi4.localisation_write',
|
|
21
|
+
]);
|
|
17
22
|
const MCP_ALLOWED_METHODS = 'GET, POST, DELETE';
|
|
18
23
|
const SINGLETON_SECURITY_HEADERS = new Set([
|
|
19
24
|
'authorization',
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { serveStdio } from '@modelcontextprotocol/server/stdio';
|
|
2
|
+
import { progressReporter } from '../server/progress.js';
|
|
2
3
|
import { createMcpServer } from '../server/create.js';
|
|
3
4
|
import { createModernOperationServer } from '../server/create-modern-operations.js';
|
|
4
5
|
import { BoundedStdioServerTransport, STDIO_MAX_FRAME_BYTES } from './bounded-stdio.js';
|
|
5
6
|
import { FinalProtocolTransport } from './protocol-gate.js';
|
|
6
7
|
const MAX_QUEUED_MESSAGES = 128;
|
|
8
|
+
/**
|
|
9
|
+
* Requests that only describe the server. They are answered while startup recovery still runs;
|
|
10
|
+
* every other message waits for it, in arrival order, so no request reads or writes a workspace
|
|
11
|
+
* whose interrupted rewrite is not yet recovered.
|
|
12
|
+
*/
|
|
13
|
+
const ANSWERED_BEFORE_RECOVERY = new Set([
|
|
14
|
+
'initialize',
|
|
15
|
+
'notifications/initialized',
|
|
16
|
+
'ping',
|
|
17
|
+
'server/discover',
|
|
18
|
+
'tools/list',
|
|
19
|
+
'prompts/list',
|
|
20
|
+
'logging/setLevel',
|
|
21
|
+
]);
|
|
7
22
|
function isRecord(value) {
|
|
8
23
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
24
|
}
|
|
@@ -93,15 +108,12 @@ export async function serveNegotiatedStdio(engine, options) {
|
|
|
93
108
|
reportError(error);
|
|
94
109
|
pinned?.onerror(error);
|
|
95
110
|
};
|
|
96
|
-
|
|
97
|
-
observer?.received(message);
|
|
111
|
+
const deliver = (message) => {
|
|
98
112
|
if (pinned === undefined) {
|
|
99
113
|
pinned = new PinnedStdioTransport(physical, reportError);
|
|
100
114
|
try {
|
|
101
115
|
if (isModernStdioOpening(message)) {
|
|
102
|
-
serveStdio(() => createModernOperationServer(engine, {}, undefined, options.
|
|
103
|
-
? {}
|
|
104
|
-
: { createPrivateTools: options.createModernPrivateTools }), {
|
|
116
|
+
serveStdio(() => createModernOperationServer(engine, {}, undefined, options.plugins === undefined ? {} : { createPrivateTools: options.plugins }), {
|
|
105
117
|
transport: pinned,
|
|
106
118
|
legacy: 'reject',
|
|
107
119
|
onerror: reportError,
|
|
@@ -109,7 +121,11 @@ export async function serveNegotiatedStdio(engine, options) {
|
|
|
109
121
|
}
|
|
110
122
|
else {
|
|
111
123
|
const server = createMcpServer(engine, {});
|
|
112
|
-
options.
|
|
124
|
+
if (options.plugins !== undefined)
|
|
125
|
+
for (const tool of options.plugins(engine, {})) {
|
|
126
|
+
const { name, ...definition } = tool.definition;
|
|
127
|
+
server.registerTool(name, definition, (input, extra) => tool.call(input, progressReporter(extra)));
|
|
128
|
+
}
|
|
113
129
|
server.server.onerror = reportError;
|
|
114
130
|
void server.connect(new FinalProtocolTransport(pinned)).catch((error) => {
|
|
115
131
|
options.onFailure(error);
|
|
@@ -125,6 +141,48 @@ export async function serveNegotiatedStdio(engine, options) {
|
|
|
125
141
|
}
|
|
126
142
|
pinned.receive(message);
|
|
127
143
|
};
|
|
144
|
+
// Startup recovery: `held` until it ends, then `open`; `closed` drops every later message.
|
|
145
|
+
let recovery = 'held';
|
|
146
|
+
let heldBytes = 0;
|
|
147
|
+
const held = [];
|
|
148
|
+
const closeHeld = () => {
|
|
149
|
+
recovery = 'closed';
|
|
150
|
+
held.length = 0;
|
|
151
|
+
heldBytes = 0;
|
|
152
|
+
void physical.close();
|
|
153
|
+
};
|
|
154
|
+
engine.recovered().then(() => {
|
|
155
|
+
if (recovery === 'closed')
|
|
156
|
+
return;
|
|
157
|
+
recovery = 'open';
|
|
158
|
+
heldBytes = 0;
|
|
159
|
+
for (const message of held.splice(0))
|
|
160
|
+
deliver(message);
|
|
161
|
+
}, (error) => {
|
|
162
|
+
if (recovery === 'closed')
|
|
163
|
+
return;
|
|
164
|
+
options.onFailure(error);
|
|
165
|
+
closeHeld();
|
|
166
|
+
});
|
|
167
|
+
physical.onmessage = (message) => {
|
|
168
|
+
observer?.received(message);
|
|
169
|
+
if (recovery === 'closed')
|
|
170
|
+
return;
|
|
171
|
+
if (recovery === 'open' ||
|
|
172
|
+
(held.length === 0 &&
|
|
173
|
+
(!('method' in message) || ANSWERED_BEFORE_RECOVERY.has(message.method)))) {
|
|
174
|
+
deliver(message);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const bytes = Buffer.byteLength(JSON.stringify(message)) + 1;
|
|
178
|
+
if (held.length >= MAX_QUEUED_MESSAGES || bytes > STDIO_MAX_FRAME_BYTES - heldBytes) {
|
|
179
|
+
reportError(new Error('Requests held during startup recovery exceeded their bounded limit'));
|
|
180
|
+
closeHeld();
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
held.push(message);
|
|
184
|
+
heldBytes += bytes;
|
|
185
|
+
};
|
|
128
186
|
await physical.start();
|
|
129
187
|
return physical;
|
|
130
188
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const PROBABILITY_SCHEMA_VERSION = 1;
|
|
2
|
-
export const PROBABILITY_ADAPTER_VERSION = 'hoi4-1.19.4.
|
|
3
|
-
export const VERIFIED_GAME_VERSION = 'Operation Postern 1.19.4.
|
|
4
|
-
export const VERIFIED_GAME_RAW_VERSION = '1.19.4.
|
|
5
|
-
export const VERIFIED_GAME_CHECKSUM = '
|
|
2
|
+
export const PROBABILITY_ADAPTER_VERSION = 'hoi4-1.19.4.2.v1';
|
|
3
|
+
export const VERIFIED_GAME_VERSION = 'Operation Postern 1.19.4.2 (0bdb)';
|
|
4
|
+
export const VERIFIED_GAME_RAW_VERSION = '1.19.4.2';
|
|
5
|
+
export const VERIFIED_GAME_CHECKSUM = '0bdb';
|