hoi4-agent-tools 0.0.0-bootstrap.1 → 0.1.2
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 +42 -0
- package/LICENSE +201 -0
- package/README.md +140 -2
- package/SECURITY.md +17 -0
- package/dist/bin/http.d.ts +3 -0
- package/dist/bin/http.d.ts.map +1 -0
- package/dist/bin/http.js +27 -0
- package/dist/bin/http.js.map +1 -0
- package/dist/bin/setup.d.ts +3 -0
- package/dist/bin/setup.d.ts.map +1 -0
- package/dist/bin/setup.js +188 -0
- package/dist/bin/setup.js.map +1 -0
- package/dist/bin/stdio.d.ts +3 -0
- package/dist/bin/stdio.d.ts.map +1 -0
- package/dist/bin/stdio.js +36 -0
- package/dist/bin/stdio.js.map +1 -0
- package/dist/hoi4_agent_tools/core/artifacts.d.ts +117 -0
- package/dist/hoi4_agent_tools/core/artifacts.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/artifacts.js +1047 -0
- package/dist/hoi4_agent_tools/core/artifacts.js.map +1 -0
- package/dist/hoi4_agent_tools/core/canonical.d.ts +13 -0
- package/dist/hoi4_agent_tools/core/canonical.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/canonical.js +41 -0
- package/dist/hoi4_agent_tools/core/canonical.js.map +1 -0
- package/dist/hoi4_agent_tools/core/configuration.d.ts +137 -0
- package/dist/hoi4_agent_tools/core/configuration.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/configuration.js +383 -0
- package/dist/hoi4_agent_tools/core/configuration.js.map +1 -0
- package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts +18 -0
- package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/diagnostic-collector.js +45 -0
- package/dist/hoi4_agent_tools/core/diagnostic-collector.js.map +1 -0
- package/dist/hoi4_agent_tools/core/diagnostics.d.ts +26 -0
- package/dist/hoi4_agent_tools/core/diagnostics.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/diagnostics.js +25 -0
- package/dist/hoi4_agent_tools/core/diagnostics.js.map +1 -0
- package/dist/hoi4_agent_tools/core/diff.d.ts +22 -0
- package/dist/hoi4_agent_tools/core/diff.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/diff.js +93 -0
- package/dist/hoi4_agent_tools/core/diff.js.map +1 -0
- package/dist/hoi4_agent_tools/core/engine.d.ts +56 -0
- package/dist/hoi4_agent_tools/core/engine.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/engine.js +319 -0
- package/dist/hoi4_agent_tools/core/engine.js.map +1 -0
- package/dist/hoi4_agent_tools/core/image-diff.d.ts +14 -0
- package/dist/hoi4_agent_tools/core/image-diff.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/image-diff.js +121 -0
- package/dist/hoi4_agent_tools/core/image-diff.js.map +1 -0
- package/dist/hoi4_agent_tools/core/index.d.ts +64 -0
- package/dist/hoi4_agent_tools/core/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/index.js +963 -0
- package/dist/hoi4_agent_tools/core/index.js.map +1 -0
- package/dist/hoi4_agent_tools/core/index.public.d.ts +16 -0
- package/dist/hoi4_agent_tools/core/index.public.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/index.public.js +16 -0
- package/dist/hoi4_agent_tools/core/index.public.js.map +1 -0
- package/dist/hoi4_agent_tools/core/render-budget.d.ts +51 -0
- package/dist/hoi4_agent_tools/core/render-budget.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/render-budget.js +109 -0
- package/dist/hoi4_agent_tools/core/render-budget.js.map +1 -0
- package/dist/hoi4_agent_tools/core/result.d.ts +45 -0
- package/dist/hoi4_agent_tools/core/result.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/result.js +26 -0
- package/dist/hoi4_agent_tools/core/result.js.map +1 -0
- package/dist/hoi4_agent_tools/core/scanner.d.ts +28 -0
- package/dist/hoi4_agent_tools/core/scanner.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/scanner.js +136 -0
- package/dist/hoi4_agent_tools/core/scanner.js.map +1 -0
- package/dist/hoi4_agent_tools/core/server-state.d.ts +31 -0
- package/dist/hoi4_agent_tools/core/server-state.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/server-state.js +413 -0
- package/dist/hoi4_agent_tools/core/server-state.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/encoding.d.ts +10 -0
- package/dist/hoi4_agent_tools/core/source/encoding.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/encoding.js +54 -0
- package/dist/hoi4_agent_tools/core/source/encoding.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/index.d.ts +7 -0
- package/dist/hoi4_agent_tools/core/source/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/index.js +7 -0
- package/dist/hoi4_agent_tools/core/source/index.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/lexer.d.ts +30 -0
- package/dist/hoi4_agent_tools/core/source/lexer.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/lexer.js +266 -0
- package/dist/hoi4_agent_tools/core/source/lexer.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/limits.d.ts +21 -0
- package/dist/hoi4_agent_tools/core/source/limits.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/limits.js +49 -0
- package/dist/hoi4_agent_tools/core/source/limits.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/localisation.d.ts +20 -0
- package/dist/hoi4_agent_tools/core/source/localisation.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/localisation.js +163 -0
- package/dist/hoi4_agent_tools/core/source/localisation.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/parser.d.ts +44 -0
- package/dist/hoi4_agent_tools/core/source/parser.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/parser.js +334 -0
- package/dist/hoi4_agent_tools/core/source/parser.js.map +1 -0
- package/dist/hoi4_agent_tools/core/source/rewrite.d.ts +10 -0
- package/dist/hoi4_agent_tools/core/source/rewrite.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/source/rewrite.js +28 -0
- package/dist/hoi4_agent_tools/core/source/rewrite.js.map +1 -0
- package/dist/hoi4_agent_tools/core/svg-text.d.ts +34 -0
- package/dist/hoi4_agent_tools/core/svg-text.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/svg-text.js +127 -0
- package/dist/hoi4_agent_tools/core/svg-text.js.map +1 -0
- package/dist/hoi4_agent_tools/core/transaction-limits.d.ts +9 -0
- package/dist/hoi4_agent_tools/core/transaction-limits.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/transaction-limits.js +9 -0
- package/dist/hoi4_agent_tools/core/transaction-limits.js.map +1 -0
- package/dist/hoi4_agent_tools/core/transactions.d.ts +162 -0
- package/dist/hoi4_agent_tools/core/transactions.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/transactions.js +1181 -0
- package/dist/hoi4_agent_tools/core/transactions.js.map +1 -0
- package/dist/hoi4_agent_tools/core/workspace.d.ts +68 -0
- package/dist/hoi4_agent_tools/core/workspace.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/core/workspace.js +794 -0
- package/dist/hoi4_agent_tools/core/workspace.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/compiler.d.ts +9 -0
- package/dist/hoi4_agent_tools/focus/compiler.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/compiler.js +273 -0
- package/dist/hoi4_agent_tools/focus/compiler.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/continuous-render.d.ts +32 -0
- package/dist/hoi4_agent_tools/focus/continuous-render.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/continuous-render.js +179 -0
- package/dist/hoi4_agent_tools/focus/continuous-render.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/drift.d.ts +22 -0
- package/dist/hoi4_agent_tools/focus/drift.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/drift.js +124 -0
- package/dist/hoi4_agent_tools/focus/drift.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/geometry.d.ts +17 -0
- package/dist/hoi4_agent_tools/focus/geometry.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/geometry.js +35 -0
- package/dist/hoi4_agent_tools/focus/geometry.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/importer.d.ts +9 -0
- package/dist/hoi4_agent_tools/focus/importer.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/importer.js +732 -0
- package/dist/hoi4_agent_tools/focus/importer.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/index.d.ts +14 -0
- package/dist/hoi4_agent_tools/focus/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/index.js +14 -0
- package/dist/hoi4_agent_tools/focus/index.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/layout.d.ts +5 -0
- package/dist/hoi4_agent_tools/focus/layout.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/layout.js +653 -0
- package/dist/hoi4_agent_tools/focus/layout.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/limits.d.ts +9 -0
- package/dist/hoi4_agent_tools/focus/limits.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/limits.js +9 -0
- package/dist/hoi4_agent_tools/focus/limits.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/lint.d.ts +14 -0
- package/dist/hoi4_agent_tools/focus/lint.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/lint.js +839 -0
- package/dist/hoi4_agent_tools/focus/lint.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/model.d.ts +303 -0
- package/dist/hoi4_agent_tools/focus/model.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/model.js +20 -0
- package/dist/hoi4_agent_tools/focus/model.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/native-effects.d.ts +9 -0
- package/dist/hoi4_agent_tools/focus/native-effects.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/native-effects.js +563 -0
- package/dist/hoi4_agent_tools/focus/native-effects.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/planning.d.ts +15 -0
- package/dist/hoi4_agent_tools/focus/planning.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/planning.js +241 -0
- package/dist/hoi4_agent_tools/focus/planning.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/presentation.d.ts +24 -0
- package/dist/hoi4_agent_tools/focus/presentation.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/presentation.js +204 -0
- package/dist/hoi4_agent_tools/focus/presentation.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/render.d.ts +35 -0
- package/dist/hoi4_agent_tools/focus/render.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/render.js +491 -0
- package/dist/hoi4_agent_tools/focus/render.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/service.d.ts +82 -0
- package/dist/hoi4_agent_tools/focus/service.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/service.js +492 -0
- package/dist/hoi4_agent_tools/focus/service.js.map +1 -0
- package/dist/hoi4_agent_tools/focus/source-update.d.ts +6 -0
- package/dist/hoi4_agent_tools/focus/source-update.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/focus/source-update.js +328 -0
- package/dist/hoi4_agent_tools/focus/source-update.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts +37 -0
- package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/animation-manifest.js +66 -0
- package/dist/hoi4_agent_tools/gui/animation-manifest.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/assets.d.ts +71 -0
- package/dist/hoi4_agent_tools/gui/assets.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/assets.js +629 -0
- package/dist/hoi4_agent_tools/gui/assets.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/dds.d.ts +17 -0
- package/dist/hoi4_agent_tools/gui/dds.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/dds.js +245 -0
- package/dist/hoi4_agent_tools/gui/dds.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/helpers.d.ts +101 -0
- package/dist/hoi4_agent_tools/gui/helpers.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/helpers.js +1072 -0
- package/dist/hoi4_agent_tools/gui/helpers.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/index.d.ts +15 -0
- package/dist/hoi4_agent_tools/gui/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/index.js +15 -0
- package/dist/hoi4_agent_tools/gui/index.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/layout.d.ts +6 -0
- package/dist/hoi4_agent_tools/gui/layout.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/layout.js +753 -0
- package/dist/hoi4_agent_tools/gui/layout.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/limits.d.ts +25 -0
- package/dist/hoi4_agent_tools/gui/limits.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/limits.js +27 -0
- package/dist/hoi4_agent_tools/gui/limits.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/renderer.d.ts +18 -0
- package/dist/hoi4_agent_tools/gui/renderer.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/renderer.js +388 -0
- package/dist/hoi4_agent_tools/gui/renderer.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/scenario.d.ts +66 -0
- package/dist/hoi4_agent_tools/gui/scenario.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/scenario.js +191 -0
- package/dist/hoi4_agent_tools/gui/scenario.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/source-graph.d.ts +7 -0
- package/dist/hoi4_agent_tools/gui/source-graph.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/source-graph.js +1074 -0
- package/dist/hoi4_agent_tools/gui/source-graph.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/source-patch.d.ts +13 -0
- package/dist/hoi4_agent_tools/gui/source-patch.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/source-patch.js +90 -0
- package/dist/hoi4_agent_tools/gui/source-patch.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/studio.d.ts +86 -0
- package/dist/hoi4_agent_tools/gui/studio.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/studio.js +830 -0
- package/dist/hoi4_agent_tools/gui/studio.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/tga.d.ts +16 -0
- package/dist/hoi4_agent_tools/gui/tga.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/tga.js +157 -0
- package/dist/hoi4_agent_tools/gui/tga.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/types.d.ts +322 -0
- package/dist/hoi4_agent_tools/gui/types.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/types.js +19 -0
- package/dist/hoi4_agent_tools/gui/types.js.map +1 -0
- package/dist/hoi4_agent_tools/gui/validators.d.ts +8 -0
- package/dist/hoi4_agent_tools/gui/validators.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/gui/validators.js +951 -0
- package/dist/hoi4_agent_tools/gui/validators.js.map +1 -0
- package/dist/hoi4_agent_tools/map/bmp.d.ts +62 -0
- package/dist/hoi4_agent_tools/map/bmp.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/bmp.js +363 -0
- package/dist/hoi4_agent_tools/map/bmp.js.map +1 -0
- package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts +5 -0
- package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/diagnostic-limit.js +21 -0
- package/dist/hoi4_agent_tools/map/diagnostic-limit.js.map +1 -0
- package/dist/hoi4_agent_tools/map/index.d.ts +8 -0
- package/dist/hoi4_agent_tools/map/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/index.js +8 -0
- package/dist/hoi4_agent_tools/map/index.js.map +1 -0
- package/dist/hoi4_agent_tools/map/limits.d.ts +13 -0
- package/dist/hoi4_agent_tools/map/limits.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/limits.js +13 -0
- package/dist/hoi4_agent_tools/map/limits.js.map +1 -0
- package/dist/hoi4_agent_tools/map/model.d.ts +269 -0
- package/dist/hoi4_agent_tools/map/model.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/model.js +1114 -0
- package/dist/hoi4_agent_tools/map/model.js.map +1 -0
- package/dist/hoi4_agent_tools/map/operations.d.ts +401 -0
- package/dist/hoi4_agent_tools/map/operations.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/operations.js +2717 -0
- package/dist/hoi4_agent_tools/map/operations.js.map +1 -0
- package/dist/hoi4_agent_tools/map/render.d.ts +90 -0
- package/dist/hoi4_agent_tools/map/render.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/render.js +759 -0
- package/dist/hoi4_agent_tools/map/render.js.map +1 -0
- package/dist/hoi4_agent_tools/map/service.d.ts +81 -0
- package/dist/hoi4_agent_tools/map/service.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/service.js +695 -0
- package/dist/hoi4_agent_tools/map/service.js.map +1 -0
- package/dist/hoi4_agent_tools/map/validation.d.ts +23 -0
- package/dist/hoi4_agent_tools/map/validation.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/map/validation.js +1177 -0
- package/dist/hoi4_agent_tools/map/validation.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts +3 -0
- package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/prompts/register.js +50 -0
- package/dist/hoi4_agent_tools/mcp/prompts/register.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts +9 -0
- package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/registry/metadata.js +10 -0
- package/dist/hoi4_agent_tools/mcp/registry/metadata.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/resources/register.d.ts +5 -0
- package/dist/hoi4_agent_tools/mcp/resources/register.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/resources/register.js +278 -0
- package/dist/hoi4_agent_tools/mcp/resources/register.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/security/auth.d.ts +24 -0
- package/dist/hoi4_agent_tools/mcp/security/auth.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/security/auth.js +234 -0
- package/dist/hoi4_agent_tools/mcp/security/auth.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts +35 -0
- package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/base-tools.js +835 -0
- package/dist/hoi4_agent_tools/mcp/server/base-tools.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/create.d.ts +5 -0
- package/dist/hoi4_agent_tools/mcp/server/create.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/create.js +26 -0
- package/dist/hoi4_agent_tools/mcp/server/create.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts +133 -0
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.js +127 -0
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/progress.d.ts +8 -0
- package/dist/hoi4_agent_tools/mcp/server/progress.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/progress.js +21 -0
- package/dist/hoi4_agent_tools/mcp/server/progress.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/result.d.ts +232 -0
- package/dist/hoi4_agent_tools/mcp/server/result.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/server/result.js +353 -0
- package/dist/hoi4_agent_tools/mcp/server/result.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts +5 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +1059 -0
- package/dist/hoi4_agent_tools/mcp/tools/focus.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts +111 -0
- package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/gui.js +598 -0
- package/dist/hoi4_agent_tools/mcp/tools/gui.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.d.ts +5 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.js +685 -0
- package/dist/hoi4_agent_tools/mcp/tools/map.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts +58 -0
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js +181 -0
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts +26 -0
- package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/event-store.js +86 -0
- package/dist/hoi4_agent_tools/mcp/transports/event-store.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.d.ts +28 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.js +744 -0
- package/dist/hoi4_agent_tools/mcp/transports/http.js.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts +15 -0
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js +51 -0
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js.map +1 -0
- package/dist/hoi4_agent_tools/runtime.d.ts +4 -0
- package/dist/hoi4_agent_tools/runtime.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/runtime.js +27 -0
- package/dist/hoi4_agent_tools/runtime.js.map +1 -0
- package/dist/hoi4_agent_tools/schemas/common.d.ts +74 -0
- package/dist/hoi4_agent_tools/schemas/common.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/schemas/common.js +51 -0
- package/dist/hoi4_agent_tools/schemas/common.js.map +1 -0
- package/dist/hoi4_agent_tools/schemas/focus.d.ts +784 -0
- package/dist/hoi4_agent_tools/schemas/focus.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/schemas/focus.js +330 -0
- package/dist/hoi4_agent_tools/schemas/focus.js.map +1 -0
- package/dist/hoi4_agent_tools/schemas/index.d.ts +5 -0
- package/dist/hoi4_agent_tools/schemas/index.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/schemas/index.js +5 -0
- package/dist/hoi4_agent_tools/schemas/index.js.map +1 -0
- package/dist/hoi4_agent_tools/schemas/map.d.ts +654 -0
- package/dist/hoi4_agent_tools/schemas/map.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/schemas/map.js +570 -0
- package/dist/hoi4_agent_tools/schemas/map.js.map +1 -0
- package/dist/hoi4_agent_tools/schemas/transaction.d.ts +259 -0
- package/dist/hoi4_agent_tools/schemas/transaction.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/schemas/transaction.js +104 -0
- package/dist/hoi4_agent_tools/schemas/transaction.js.map +1 -0
- package/dist/hoi4_agent_tools/version.d.ts +6 -0
- package/dist/hoi4_agent_tools/version.d.ts.map +1 -0
- package/dist/hoi4_agent_tools/version.js +7 -0
- package/dist/hoi4_agent_tools/version.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/docs/README.md +22 -0
- package/docs/adr/0001-runtime-and-language.md +16 -0
- package/docs/adr/0002-lossless-source-model.md +18 -0
- package/docs/adr/0003-image-and-font-codecs.md +18 -0
- package/docs/adr/0004-focus-layout.md +16 -0
- package/docs/adr/0005-offline-rendering.md +18 -0
- package/docs/adr/0006-mcp-sdk-and-protocol.md +16 -0
- package/docs/adr/0007-storage-and-transactions.md +24 -0
- package/docs/adr/0008-test-strategy.md +18 -0
- package/docs/adr/0009-packaging-and-registry.md +16 -0
- package/docs/adr/0010-unsupported-and-refusal-policy.md +18 -0
- package/docs/adr/0011-http-security.md +16 -0
- package/docs/adr/README.md +13 -0
- package/docs/architecture.md +60 -0
- package/docs/artifacts.md +133 -0
- package/docs/compatibility.md +33 -0
- package/docs/completion-report.md +60 -0
- package/docs/configuration.md +285 -0
- package/docs/focus-workflow.md +68 -0
- package/docs/gui-workflow.md +121 -0
- package/docs/limitations.md +30 -0
- package/docs/map-workflow.md +89 -0
- package/docs/performance.md +117 -0
- package/docs/release.md +181 -0
- package/docs/research/mcp-2026-07-10.md +46 -0
- package/docs/research/source-ledger.md +68 -0
- package/docs/security.md +139 -0
- package/docs/self-hosting.md +168 -0
- package/docs/testing.md +43 -0
- package/docs/third-party-notices.md +11 -0
- package/docs/transactions.md +162 -0
- package/docs/troubleshooting.md +46 -0
- package/package.json +98 -5
- package/schemas/configuration.schema.json +794 -0
- package/schemas/continuous-focus-palette.schema.json +325 -0
- package/schemas/focus-plan.schema.json +902 -0
- package/schemas/focus-planning-sidecar.schema.json +364 -0
- package/schemas/gui-animation-source.schema.json +176 -0
- package/schemas/gui-helper.schema.json +301 -0
- package/schemas/gui-scenario.schema.json +298 -0
- package/schemas/map-operation.schema.json +2284 -0
- package/schemas/operation-result.schema.json +344 -0
- package/schemas/transaction-manifest.schema.json +685 -0
- package/server.json +32 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { chmod, link, lstat, mkdir, open, readFile, readdir, realpath, rm, unlink, } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { z } from 'zod/v4';
|
|
5
|
+
import { compareCodeUnits, canonicalJson, secureId } from './canonical.js';
|
|
6
|
+
import { ServiceError } from './result.js';
|
|
7
|
+
const journalKeyFile = 'journal-hmac.key';
|
|
8
|
+
const journalKeyBytes = 32;
|
|
9
|
+
const sha256Schema = z.string().regex(/^[a-f0-9]{64}$/u);
|
|
10
|
+
const transactionIdSchema = z.string().regex(/^txn_[0-9a-f-]{36}$/u);
|
|
11
|
+
const journalHeadSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
version: z.literal(1),
|
|
14
|
+
workspaceIdentity: sha256Schema,
|
|
15
|
+
transactionId: transactionIdSchema,
|
|
16
|
+
revision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
17
|
+
manifestHash: sha256Schema,
|
|
18
|
+
authenticationTag: sha256Schema,
|
|
19
|
+
headTag: sha256Schema,
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
22
|
+
function stateError(code, message) {
|
|
23
|
+
return new ServiceError(code, message);
|
|
24
|
+
}
|
|
25
|
+
function isNotFound(error) {
|
|
26
|
+
return error.code === 'ENOENT';
|
|
27
|
+
}
|
|
28
|
+
function sameFileIdentity(left, right) {
|
|
29
|
+
return left.dev === right.dev && left.ino === right.ino;
|
|
30
|
+
}
|
|
31
|
+
async function assertNoLinkComponents(absolutePath) {
|
|
32
|
+
const parsed = path.parse(absolutePath);
|
|
33
|
+
let cursor = parsed.root;
|
|
34
|
+
for (const segment of absolutePath.slice(parsed.root.length).split(path.sep).filter(Boolean)) {
|
|
35
|
+
cursor = path.join(cursor, segment);
|
|
36
|
+
try {
|
|
37
|
+
const metadata = await lstat(cursor);
|
|
38
|
+
if (metadata.isSymbolicLink()) {
|
|
39
|
+
throw stateError('SERVER_STATE_UNSAFE', 'Server state root contains a symbolic link or junction');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (isNotFound(error))
|
|
44
|
+
return;
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function assertPrivateFile(filePath, expectedBytes) {
|
|
50
|
+
let metadata;
|
|
51
|
+
try {
|
|
52
|
+
metadata = await lstat(filePath);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
throw stateError('SERVER_STATE_KEY_INVALID', 'Server journal authentication key is unavailable');
|
|
56
|
+
}
|
|
57
|
+
if (metadata.isSymbolicLink() || !metadata.isFile() || metadata.size !== expectedBytes) {
|
|
58
|
+
throw stateError('SERVER_STATE_KEY_INVALID', 'Server journal authentication key is invalid');
|
|
59
|
+
}
|
|
60
|
+
if (process.platform !== 'win32' && (metadata.mode & 0o777) !== 0o600) {
|
|
61
|
+
throw stateError('SERVER_STATE_KEY_PERMISSIONS', 'Server journal authentication key permissions must be 0600');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function atomicCreate(filePath, bytes, mode) {
|
|
65
|
+
const temporaryPath = path.join(path.dirname(filePath), `.${secureId('state')}.tmp`);
|
|
66
|
+
let handle;
|
|
67
|
+
try {
|
|
68
|
+
handle = await open(temporaryPath, 'wx', mode);
|
|
69
|
+
await handle.writeFile(bytes);
|
|
70
|
+
await handle.sync();
|
|
71
|
+
await handle.close();
|
|
72
|
+
handle = undefined;
|
|
73
|
+
if (process.platform !== 'win32')
|
|
74
|
+
await chmod(temporaryPath, mode);
|
|
75
|
+
try {
|
|
76
|
+
await link(temporaryPath, filePath);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (error.code === 'EEXIST')
|
|
81
|
+
return false;
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
await handle?.close().catch(() => undefined);
|
|
87
|
+
await unlink(temporaryPath).catch(() => undefined);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function headPayload(head) {
|
|
91
|
+
return head;
|
|
92
|
+
}
|
|
93
|
+
/** Operator-owned state and authentication material outside every workspace/capability root. */
|
|
94
|
+
export class ServerState {
|
|
95
|
+
root;
|
|
96
|
+
journalKey;
|
|
97
|
+
constructor(root, journalKey) {
|
|
98
|
+
this.root = root;
|
|
99
|
+
this.journalKey = journalKey;
|
|
100
|
+
}
|
|
101
|
+
static async create(requestedRoot) {
|
|
102
|
+
const absoluteRoot = path.normalize(requestedRoot);
|
|
103
|
+
if (!path.isAbsolute(absoluteRoot)) {
|
|
104
|
+
throw stateError('SERVER_STATE_ROOT_INVALID', 'Server state root must be absolute');
|
|
105
|
+
}
|
|
106
|
+
await assertNoLinkComponents(absoluteRoot);
|
|
107
|
+
await mkdir(absoluteRoot, { recursive: true, mode: 0o700 });
|
|
108
|
+
await assertNoLinkComponents(absoluteRoot);
|
|
109
|
+
const metadata = await lstat(absoluteRoot, { bigint: true });
|
|
110
|
+
if (metadata.isSymbolicLink() || !metadata.isDirectory()) {
|
|
111
|
+
throw stateError('SERVER_STATE_ROOT_INVALID', 'Server state root must be a real directory');
|
|
112
|
+
}
|
|
113
|
+
if (process.platform !== 'win32' && (metadata.mode & 63n) !== 0n) {
|
|
114
|
+
throw stateError('SERVER_STATE_ROOT_PERMISSIONS', 'Server state root permissions must exclude group and other access');
|
|
115
|
+
}
|
|
116
|
+
const canonicalRoot = path.normalize(await realpath(absoluteRoot));
|
|
117
|
+
await assertNoLinkComponents(absoluteRoot);
|
|
118
|
+
await assertNoLinkComponents(canonicalRoot);
|
|
119
|
+
const [currentMetadata, canonicalMetadata] = await Promise.all([
|
|
120
|
+
lstat(absoluteRoot, { bigint: true }),
|
|
121
|
+
lstat(canonicalRoot, { bigint: true }),
|
|
122
|
+
]);
|
|
123
|
+
if (currentMetadata.isSymbolicLink() ||
|
|
124
|
+
!currentMetadata.isDirectory() ||
|
|
125
|
+
canonicalMetadata.isSymbolicLink() ||
|
|
126
|
+
!canonicalMetadata.isDirectory() ||
|
|
127
|
+
!sameFileIdentity(metadata, currentMetadata) ||
|
|
128
|
+
!sameFileIdentity(metadata, canonicalMetadata)) {
|
|
129
|
+
throw stateError('SERVER_STATE_ROOT_NOT_CANONICAL', 'Server state root changed while its canonical identity was being established');
|
|
130
|
+
}
|
|
131
|
+
// Windows realpath expands harmless 8.3 names (for example RUNNER~1 on hosted runners).
|
|
132
|
+
// Component checks and the identity comparison above accept only that native spelling
|
|
133
|
+
// normalization while symbolic links, junctions, and replacement races fail closed.
|
|
134
|
+
const keyPath = path.join(canonicalRoot, journalKeyFile);
|
|
135
|
+
let key;
|
|
136
|
+
try {
|
|
137
|
+
await assertPrivateFile(keyPath, journalKeyBytes);
|
|
138
|
+
key = await readFile(keyPath);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
if (!(error instanceof ServiceError) || error.code !== 'SERVER_STATE_KEY_INVALID')
|
|
142
|
+
throw error;
|
|
143
|
+
const createdKey = randomBytes(journalKeyBytes);
|
|
144
|
+
let created;
|
|
145
|
+
try {
|
|
146
|
+
created = await atomicCreate(keyPath, createdKey, 0o600);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
throw stateError('SERVER_STATE_KEY_CREATE_FAILED', 'Server journal authentication key could not be created atomically');
|
|
150
|
+
}
|
|
151
|
+
await assertPrivateFile(keyPath, journalKeyBytes);
|
|
152
|
+
key = created ? createdKey : await readFile(keyPath);
|
|
153
|
+
}
|
|
154
|
+
if (key.length !== journalKeyBytes) {
|
|
155
|
+
throw stateError('SERVER_STATE_KEY_INVALID', 'Server journal authentication key is invalid');
|
|
156
|
+
}
|
|
157
|
+
return new ServerState(canonicalRoot, Buffer.from(key));
|
|
158
|
+
}
|
|
159
|
+
authenticateJournal(payload) {
|
|
160
|
+
return createHmac('sha256', this.journalKey).update(canonicalJson(payload)).digest('hex');
|
|
161
|
+
}
|
|
162
|
+
verifyJournal(payload, authenticationTag) {
|
|
163
|
+
if (!/^[a-f0-9]{64}$/u.test(authenticationTag))
|
|
164
|
+
return false;
|
|
165
|
+
const expected = Buffer.from(this.authenticateJournal(payload), 'hex');
|
|
166
|
+
const actual = Buffer.from(authenticationTag, 'hex');
|
|
167
|
+
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
168
|
+
}
|
|
169
|
+
async recordInitialJournalHead(input) {
|
|
170
|
+
this.assertHeadInput(input);
|
|
171
|
+
if (input.revision !== 1) {
|
|
172
|
+
throw stateError('TRANSACTION_HEAD_INVALID', 'Initial transaction revision must be one');
|
|
173
|
+
}
|
|
174
|
+
const directory = this.journalHeadDirectory(input.workspaceIdentity, input.transactionId);
|
|
175
|
+
await assertNoLinkComponents(directory);
|
|
176
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
177
|
+
await assertNoLinkComponents(directory);
|
|
178
|
+
const latest = await this.latestJournalHead(directory, input.workspaceIdentity, input.transactionId);
|
|
179
|
+
if (latest !== undefined) {
|
|
180
|
+
if (this.headMatches(latest.head, input)) {
|
|
181
|
+
await this.removeOlderHeads(latest.olderPaths);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
throw stateError('TRANSACTION_MANIFEST_REPLAY', 'Initial transaction journal conflicts with protected server state');
|
|
185
|
+
}
|
|
186
|
+
await this.createJournalHead(directory, input);
|
|
187
|
+
}
|
|
188
|
+
async recordJournalSuccessor(input) {
|
|
189
|
+
this.assertHeadInput(input);
|
|
190
|
+
const directory = this.journalHeadDirectory(input.workspaceIdentity, input.transactionId);
|
|
191
|
+
const latest = await this.latestJournalHead(directory, input.workspaceIdentity, input.transactionId);
|
|
192
|
+
if (latest === undefined) {
|
|
193
|
+
throw stateError('TRANSACTION_HEAD_MISSING', 'Transaction journal has no protected server-state head');
|
|
194
|
+
}
|
|
195
|
+
if (input.revision === latest.head.revision && this.headMatches(latest.head, input)) {
|
|
196
|
+
await this.removeOlderHeads(latest.olderPaths);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (input.revision !== latest.head.revision + 1) {
|
|
200
|
+
throw stateError('TRANSACTION_MANIFEST_REPLAY', 'Transaction journal revision is not the protected successor');
|
|
201
|
+
}
|
|
202
|
+
const target = await this.createJournalHead(directory, input);
|
|
203
|
+
await this.removeOlderHeads([latest.path, ...latest.olderPaths].filter((value) => value !== target));
|
|
204
|
+
}
|
|
205
|
+
async verifyJournalHead(input, signal) {
|
|
206
|
+
signal?.throwIfAborted();
|
|
207
|
+
this.assertHeadInput(input);
|
|
208
|
+
const directory = this.journalHeadDirectory(input.workspaceIdentity, input.transactionId);
|
|
209
|
+
const latest = await this.latestJournalHead(directory, input.workspaceIdentity, input.transactionId, signal);
|
|
210
|
+
signal?.throwIfAborted();
|
|
211
|
+
if (latest === undefined) {
|
|
212
|
+
throw stateError('TRANSACTION_HEAD_MISSING', 'Transaction journal has no protected server-state head');
|
|
213
|
+
}
|
|
214
|
+
if (this.headMatches(latest.head, input))
|
|
215
|
+
return;
|
|
216
|
+
if (input.revision === latest.head.revision + 1) {
|
|
217
|
+
throw stateError('TRANSACTION_HEAD_RECONCILIATION_REQUIRED', 'Transaction journal has an authenticated successor pending write-path recovery');
|
|
218
|
+
}
|
|
219
|
+
throw stateError('TRANSACTION_MANIFEST_REPLAY', 'Transaction journal conflicts with protected server state');
|
|
220
|
+
}
|
|
221
|
+
async verifyOrReconcileJournalHead(input, signal) {
|
|
222
|
+
signal?.throwIfAborted();
|
|
223
|
+
this.assertHeadInput(input);
|
|
224
|
+
const directory = this.journalHeadDirectory(input.workspaceIdentity, input.transactionId);
|
|
225
|
+
const latest = await this.latestJournalHead(directory, input.workspaceIdentity, input.transactionId, signal);
|
|
226
|
+
signal?.throwIfAborted();
|
|
227
|
+
if (latest === undefined) {
|
|
228
|
+
throw stateError('TRANSACTION_HEAD_MISSING', 'Transaction journal has no protected server-state head');
|
|
229
|
+
}
|
|
230
|
+
if (this.headMatches(latest.head, input))
|
|
231
|
+
return;
|
|
232
|
+
if (input.revision === latest.head.revision + 1) {
|
|
233
|
+
// Once successor publication starts it completes atomically even if the
|
|
234
|
+
// originating request is cancelled.
|
|
235
|
+
const target = await this.createJournalHead(directory, input);
|
|
236
|
+
await this.removeOlderHeads([latest.path, ...latest.olderPaths].filter((value) => value !== target));
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
throw stateError('TRANSACTION_MANIFEST_REPLAY', 'Transaction journal conflicts with protected server state');
|
|
240
|
+
}
|
|
241
|
+
async removeJournalHead(workspaceIdentity, transactionId) {
|
|
242
|
+
const directory = this.journalHeadDirectory(workspaceIdentity, transactionId);
|
|
243
|
+
await assertNoLinkComponents(directory);
|
|
244
|
+
await rm(directory, { recursive: true, force: true });
|
|
245
|
+
}
|
|
246
|
+
async listJournalHeadTransactionIds(workspaceIdentity, signal) {
|
|
247
|
+
signal?.throwIfAborted();
|
|
248
|
+
if (!sha256Schema.safeParse(workspaceIdentity).success) {
|
|
249
|
+
throw stateError('TRANSACTION_HEAD_INVALID', 'Workspace head identity is invalid');
|
|
250
|
+
}
|
|
251
|
+
const workspaceDirectory = path.join(this.root, 'transaction-heads', workspaceIdentity.slice(0, 2), workspaceIdentity);
|
|
252
|
+
await assertNoLinkComponents(workspaceDirectory);
|
|
253
|
+
let entries;
|
|
254
|
+
try {
|
|
255
|
+
entries = await readdir(workspaceDirectory, { withFileTypes: true });
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
if (isNotFound(error))
|
|
259
|
+
return [];
|
|
260
|
+
throw error;
|
|
261
|
+
}
|
|
262
|
+
signal?.throwIfAborted();
|
|
263
|
+
const ids = [];
|
|
264
|
+
for (const entry of entries) {
|
|
265
|
+
signal?.throwIfAborted();
|
|
266
|
+
if (entry.isSymbolicLink() ||
|
|
267
|
+
!entry.isDirectory() ||
|
|
268
|
+
!transactionIdSchema.safeParse(entry.name).success) {
|
|
269
|
+
throw stateError('TRANSACTION_HEAD_INVALID', 'Protected transaction state is invalid');
|
|
270
|
+
}
|
|
271
|
+
ids.push(entry.name);
|
|
272
|
+
}
|
|
273
|
+
return ids.sort((left, right) => compareCodeUnits(left, right));
|
|
274
|
+
}
|
|
275
|
+
async createJournalHead(directory, input) {
|
|
276
|
+
const withoutTag = {
|
|
277
|
+
version: 1,
|
|
278
|
+
workspaceIdentity: input.workspaceIdentity,
|
|
279
|
+
transactionId: input.transactionId,
|
|
280
|
+
revision: input.revision,
|
|
281
|
+
manifestHash: input.manifestHash,
|
|
282
|
+
authenticationTag: input.authenticationTag,
|
|
283
|
+
};
|
|
284
|
+
const head = {
|
|
285
|
+
...withoutTag,
|
|
286
|
+
headTag: this.authenticateJournal(headPayload(withoutTag)),
|
|
287
|
+
};
|
|
288
|
+
const target = path.join(directory, `${String(input.revision).padStart(16, '0')}.json`);
|
|
289
|
+
const bytes = Buffer.from(`${canonicalJson(head)}\n`, 'utf8');
|
|
290
|
+
let created;
|
|
291
|
+
try {
|
|
292
|
+
created = await atomicCreate(target, bytes, 0o600);
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
throw stateError('TRANSACTION_HEAD_WRITE_FAILED', 'Protected transaction journal state could not be recorded');
|
|
296
|
+
}
|
|
297
|
+
if (!created) {
|
|
298
|
+
const raced = await this.readJournalHead(target, input.workspaceIdentity, input.transactionId);
|
|
299
|
+
if (canonicalJson(raced) !== canonicalJson(head)) {
|
|
300
|
+
throw stateError('TRANSACTION_MANIFEST_REPLAY', 'Transaction journal conflicts with a concurrent protected revision');
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return target;
|
|
304
|
+
}
|
|
305
|
+
assertHeadInput(input) {
|
|
306
|
+
if (!sha256Schema.safeParse(input.workspaceIdentity).success ||
|
|
307
|
+
!transactionIdSchema.safeParse(input.transactionId).success ||
|
|
308
|
+
!Number.isSafeInteger(input.revision) ||
|
|
309
|
+
input.revision < 1 ||
|
|
310
|
+
!sha256Schema.safeParse(input.authenticationTag).success ||
|
|
311
|
+
!sha256Schema.safeParse(input.manifestHash).success) {
|
|
312
|
+
throw stateError('TRANSACTION_HEAD_INVALID', 'Transaction journal head identity is invalid');
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
headMatches(head, input) {
|
|
316
|
+
return (head.revision === input.revision &&
|
|
317
|
+
head.authenticationTag === input.authenticationTag &&
|
|
318
|
+
head.manifestHash === input.manifestHash);
|
|
319
|
+
}
|
|
320
|
+
async removeOlderHeads(paths) {
|
|
321
|
+
for (const filePath of paths)
|
|
322
|
+
await unlink(filePath).catch(() => undefined);
|
|
323
|
+
}
|
|
324
|
+
journalHeadDirectory(workspaceIdentity, transactionId) {
|
|
325
|
+
const directory = path.join(this.root, 'transaction-heads', workspaceIdentity.slice(0, 2), workspaceIdentity, transactionId);
|
|
326
|
+
const relative = path.relative(this.root, directory);
|
|
327
|
+
if (relative.startsWith(`..${path.sep}`) || relative === '..' || path.isAbsolute(relative)) {
|
|
328
|
+
throw stateError('SERVER_STATE_ESCAPE', 'Protected transaction state escapes its root');
|
|
329
|
+
}
|
|
330
|
+
return directory;
|
|
331
|
+
}
|
|
332
|
+
async latestJournalHead(directory, workspaceIdentity, transactionId, signal) {
|
|
333
|
+
signal?.throwIfAborted();
|
|
334
|
+
await assertNoLinkComponents(directory);
|
|
335
|
+
let entries;
|
|
336
|
+
try {
|
|
337
|
+
entries = await readdir(directory, { withFileTypes: true });
|
|
338
|
+
}
|
|
339
|
+
catch (error) {
|
|
340
|
+
if (isNotFound(error))
|
|
341
|
+
return undefined;
|
|
342
|
+
throw error;
|
|
343
|
+
}
|
|
344
|
+
signal?.throwIfAborted();
|
|
345
|
+
let latest;
|
|
346
|
+
for (const entry of entries) {
|
|
347
|
+
signal?.throwIfAborted();
|
|
348
|
+
if (/^\.state_[0-9a-f-]{36}\.tmp$/u.test(entry.name) && entry.isFile())
|
|
349
|
+
continue;
|
|
350
|
+
if (entry.isSymbolicLink() || !entry.isFile() || !/^\d{16}\.json$/u.test(entry.name)) {
|
|
351
|
+
throw stateError('TRANSACTION_HEAD_INVALID', 'Protected transaction state contains an invalid entry');
|
|
352
|
+
}
|
|
353
|
+
const revision = Number.parseInt(entry.name.slice(0, 16), 10);
|
|
354
|
+
if (!Number.isSafeInteger(revision) || revision < 1) {
|
|
355
|
+
throw stateError('TRANSACTION_HEAD_INVALID', 'Protected transaction revision is invalid');
|
|
356
|
+
}
|
|
357
|
+
if (latest === undefined || revision > latest.revision) {
|
|
358
|
+
latest = { revision, path: path.join(directory, entry.name) };
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (latest === undefined)
|
|
362
|
+
return undefined;
|
|
363
|
+
const latestPath = latest.path;
|
|
364
|
+
return {
|
|
365
|
+
head: await this.readJournalHead(latestPath, workspaceIdentity, transactionId, signal),
|
|
366
|
+
path: latestPath,
|
|
367
|
+
olderPaths: entries
|
|
368
|
+
.filter((entry) => /^\d{16}\.json$/u.test(entry.name))
|
|
369
|
+
.map((entry) => path.join(directory, entry.name))
|
|
370
|
+
.filter((filePath) => filePath !== latestPath),
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
async readJournalHead(filePath, workspaceIdentity, transactionId, signal) {
|
|
374
|
+
signal?.throwIfAborted();
|
|
375
|
+
let parsed;
|
|
376
|
+
try {
|
|
377
|
+
const metadata = await lstat(filePath);
|
|
378
|
+
if (metadata.isSymbolicLink() || !metadata.isFile() || metadata.size > 4_096)
|
|
379
|
+
throw new Error();
|
|
380
|
+
signal?.throwIfAborted();
|
|
381
|
+
const text = signal === undefined
|
|
382
|
+
? await readFile(filePath, 'utf8')
|
|
383
|
+
: await readFile(filePath, { encoding: 'utf8', signal });
|
|
384
|
+
signal?.throwIfAborted();
|
|
385
|
+
parsed = JSON.parse(text);
|
|
386
|
+
}
|
|
387
|
+
catch (error) {
|
|
388
|
+
if (error.name === 'AbortError')
|
|
389
|
+
throw error;
|
|
390
|
+
throw stateError('TRANSACTION_HEAD_INVALID', 'Protected transaction state is invalid');
|
|
391
|
+
}
|
|
392
|
+
signal?.throwIfAborted();
|
|
393
|
+
const validated = journalHeadSchema.safeParse(parsed);
|
|
394
|
+
if (!validated.success) {
|
|
395
|
+
throw stateError('TRANSACTION_HEAD_INVALID', 'Protected transaction state is invalid');
|
|
396
|
+
}
|
|
397
|
+
const head = validated.data;
|
|
398
|
+
if (head.workspaceIdentity !== workspaceIdentity ||
|
|
399
|
+
head.transactionId !== transactionId ||
|
|
400
|
+
!this.verifyJournal(headPayload({
|
|
401
|
+
version: head.version,
|
|
402
|
+
workspaceIdentity: head.workspaceIdentity,
|
|
403
|
+
transactionId: head.transactionId,
|
|
404
|
+
revision: head.revision,
|
|
405
|
+
manifestHash: head.manifestHash,
|
|
406
|
+
authenticationTag: head.authenticationTag,
|
|
407
|
+
}), head.headTag)) {
|
|
408
|
+
throw stateError('TRANSACTION_HEAD_INVALID', 'Protected transaction state is invalid');
|
|
409
|
+
}
|
|
410
|
+
return head;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
//# sourceMappingURL=server-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-state.js","sourceRoot":"","sources":["../../../src/hoi4_agent_tools/core/server-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,KAAK,EACL,IAAI,EACJ,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,EAAE,EACF,MAAM,GACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAA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,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;YACvB,MAAM,UAAU,CAAC,0BAA0B,EAAE,wCAAwC,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;QAC5B,IACE,IAAI,CAAC,iBAAiB,KAAK,iBAAiB;YAC5C,IAAI,CAAC,aAAa,KAAK,aAAa;YACpC,CAAC,IAAI,CAAC,aAAa,CACjB,WAAW,CAAC;gBACV,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;gBACzC,aAAa,EAAE,IAAI,CAAC,aAAa;gBACjC,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;aAC1C,CAAC,EACF,IAAI,CAAC,OAAO,CACb,EACD,CAAC;YACD,MAAM,UAAU,CAAC,0BAA0B,EAAE,wCAAwC,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type SourceEncoding = 'utf8' | 'utf8-bom' | 'windows-1252';
|
|
2
|
+
export interface DecodedSource {
|
|
3
|
+
encoding: SourceEncoding;
|
|
4
|
+
text: string;
|
|
5
|
+
bytes: Buffer;
|
|
6
|
+
newline: '\n' | '\r\n' | '\r';
|
|
7
|
+
}
|
|
8
|
+
export declare function decodeSource(input: Uint8Array): DecodedSource;
|
|
9
|
+
export declare function encodeSource(text: string, encoding: SourceEncoding): Buffer;
|
|
10
|
+
//# sourceMappingURL=encoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../../../../src/hoi4_agent_tools/core/source/encoding.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,cAAc,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,cAAc,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;CAC/B;AAuBD,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,CAe7D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM,CAY3E"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import iconv from 'iconv-lite';
|
|
2
|
+
import { ServiceError } from '../result.js';
|
|
3
|
+
const utf8Bom = Buffer.from([0xef, 0xbb, 0xbf]);
|
|
4
|
+
function detectNewline(text) {
|
|
5
|
+
const crlf = text.indexOf('\r\n');
|
|
6
|
+
const lf = text.indexOf('\n');
|
|
7
|
+
const cr = text.indexOf('\r');
|
|
8
|
+
if (crlf >= 0 && (lf < 0 || crlf <= lf))
|
|
9
|
+
return '\r\n';
|
|
10
|
+
if (lf >= 0)
|
|
11
|
+
return '\n';
|
|
12
|
+
if (cr >= 0)
|
|
13
|
+
return '\r';
|
|
14
|
+
return '\n';
|
|
15
|
+
}
|
|
16
|
+
function isUtf8(bytes) {
|
|
17
|
+
try {
|
|
18
|
+
new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function decodeSource(input) {
|
|
26
|
+
const bytes = Buffer.from(input);
|
|
27
|
+
let encoding;
|
|
28
|
+
let text;
|
|
29
|
+
if (bytes.subarray(0, 3).equals(utf8Bom)) {
|
|
30
|
+
encoding = 'utf8-bom';
|
|
31
|
+
text = bytes.subarray(3).toString('utf8');
|
|
32
|
+
}
|
|
33
|
+
else if (isUtf8(bytes)) {
|
|
34
|
+
encoding = 'utf8';
|
|
35
|
+
text = bytes.toString('utf8');
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
encoding = 'windows-1252';
|
|
39
|
+
text = iconv.decode(bytes, 'windows-1252');
|
|
40
|
+
}
|
|
41
|
+
return { encoding, text, bytes, newline: detectNewline(text) };
|
|
42
|
+
}
|
|
43
|
+
export function encodeSource(text, encoding) {
|
|
44
|
+
if (encoding === 'utf8')
|
|
45
|
+
return Buffer.from(text, 'utf8');
|
|
46
|
+
if (encoding === 'utf8-bom')
|
|
47
|
+
return Buffer.concat([utf8Bom, Buffer.from(text, 'utf8')]);
|
|
48
|
+
const encoded = iconv.encode(text, 'windows-1252');
|
|
49
|
+
if (iconv.decode(encoded, 'windows-1252') !== text) {
|
|
50
|
+
throw new ServiceError('SOURCE_ENCODING_UNREPRESENTABLE', 'The edit introduces characters that cannot be represented in the source encoding', { encoding });
|
|
51
|
+
}
|
|
52
|
+
return encoded;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=encoding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../../../../src/hoi4_agent_tools/core/source/encoding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAW5C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEhD,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IA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,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,QAAwB;IACjE,IAAI,QAAQ,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1D,IAAI,QAAQ,KAAK,UAAU;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IACxF,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACnD,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC;QACnD,MAAM,IAAI,YAAY,CACpB,iCAAiC,EACjC,kFAAkF,EAClF,EAAE,QAAQ,EAAE,CACb,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hoi4_agent_tools/core/source/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hoi4_agent_tools/core/source/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Diagnostic, SourceLocation, SourcePosition } from '../diagnostics.js';
|
|
2
|
+
import { SourceDiagnosticCollector } from './limits.js';
|
|
3
|
+
export type TokenKind = 'whitespace' | 'comment' | 'string' | 'atom' | 'operator' | 'left_brace' | 'right_brace' | 'invalid';
|
|
4
|
+
export interface SourceToken {
|
|
5
|
+
kind: TokenKind;
|
|
6
|
+
text: string;
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
line: number;
|
|
10
|
+
column: number;
|
|
11
|
+
}
|
|
12
|
+
export interface LexResult {
|
|
13
|
+
tokens: SourceToken[];
|
|
14
|
+
diagnostics: Diagnostic[];
|
|
15
|
+
}
|
|
16
|
+
export interface SourceLineIndex {
|
|
17
|
+
readonly text: string;
|
|
18
|
+
readonly lineStarts: readonly number[];
|
|
19
|
+
readonly lineLimitExceededAt?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface LexOptions {
|
|
22
|
+
lineIndex?: SourceLineIndex;
|
|
23
|
+
diagnostics?: SourceDiagnosticCollector;
|
|
24
|
+
}
|
|
25
|
+
export declare function isTrivia(token: SourceToken): boolean;
|
|
26
|
+
export declare function createSourceLineIndex(text: string): SourceLineIndex;
|
|
27
|
+
export declare function positionAt(source: string | SourceLineIndex, offset: number): SourcePosition;
|
|
28
|
+
export declare function locationFor(path: string, source: string | SourceLineIndex, start: number, end: number): SourceLocation;
|
|
29
|
+
export declare function lexClausewitz(text: string, sourcePath: string, options?: LexOptions): LexResult;
|
|
30
|
+
//# sourceMappingURL=lexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexer.d.ts","sourceRoot":"","sources":["../../../../src/hoi4_agent_tools/core/source/lexer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAyC,yBAAyB,EAAE,MAAM,aAAa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