hoi4-agent-tools 0.0.0-bootstrap.1 → 0.1.3
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 +50 -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 +69 -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 +200 -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,93 @@
|
|
|
1
|
+
const defaultMaxMatrixCells = 16_000_000;
|
|
2
|
+
function splitLines(text) {
|
|
3
|
+
if (text.length === 0)
|
|
4
|
+
return [];
|
|
5
|
+
return text.match(/[^\r\n]*(?:\r\n|\r|\n)|[^\r\n]+$/gu) ?? [];
|
|
6
|
+
}
|
|
7
|
+
function lineContent(line) {
|
|
8
|
+
return line.replace(/(?:\r\n|\r|\n)$/u, '');
|
|
9
|
+
}
|
|
10
|
+
export function unifiedTextDiff(oldText, newText, oldName, newName, options = {}) {
|
|
11
|
+
options.signal?.throwIfAborted();
|
|
12
|
+
if (oldText === newText)
|
|
13
|
+
return '';
|
|
14
|
+
const oldLines = splitLines(oldText);
|
|
15
|
+
const newLines = splitLines(newText);
|
|
16
|
+
const rows = lcsDiff(oldLines, newLines, options);
|
|
17
|
+
return [
|
|
18
|
+
`--- ${oldName}`,
|
|
19
|
+
`+++ ${newName}`,
|
|
20
|
+
`@@ -1,${oldLines.length} +1,${newLines.length} @@`,
|
|
21
|
+
...rows,
|
|
22
|
+
].join('\n');
|
|
23
|
+
}
|
|
24
|
+
function lcsDiff(oldLines, newLines, options) {
|
|
25
|
+
const columns = newLines.length + 1;
|
|
26
|
+
const cells = (oldLines.length + 1) * columns;
|
|
27
|
+
const maxMatrixCells = options.maxMatrixCells ?? defaultMaxMatrixCells;
|
|
28
|
+
if (!Number.isSafeInteger(cells) || cells > maxMatrixCells) {
|
|
29
|
+
throw new ServiceError('DIFF_COMPLEXITY_LIMIT', 'Exact source diff exceeds the configured deterministic memory bound', { oldLines: oldLines.length, newLines: newLines.length, cells, maxMatrixCells });
|
|
30
|
+
}
|
|
31
|
+
const table = new Uint32Array(cells);
|
|
32
|
+
for (let oldIndex = oldLines.length - 1; oldIndex >= 0; oldIndex -= 1) {
|
|
33
|
+
if ((oldIndex & 0x3f) === 0)
|
|
34
|
+
options.signal?.throwIfAborted();
|
|
35
|
+
for (let newIndex = newLines.length - 1; newIndex >= 0; newIndex -= 1) {
|
|
36
|
+
if ((newIndex & 0xfff) === 0)
|
|
37
|
+
options.signal?.throwIfAborted();
|
|
38
|
+
const current = oldIndex * columns + newIndex;
|
|
39
|
+
table[current] =
|
|
40
|
+
oldLines[oldIndex] === newLines[newIndex]
|
|
41
|
+
? table[(oldIndex + 1) * columns + newIndex + 1] + 1
|
|
42
|
+
: Math.max(table[(oldIndex + 1) * columns + newIndex], table[oldIndex * columns + newIndex + 1]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const result = [];
|
|
46
|
+
let oldIndex = 0;
|
|
47
|
+
let newIndex = 0;
|
|
48
|
+
while (oldIndex < oldLines.length || newIndex < newLines.length) {
|
|
49
|
+
if (((oldIndex + newIndex) & 0xff) === 0)
|
|
50
|
+
options.signal?.throwIfAborted();
|
|
51
|
+
if (oldIndex < oldLines.length &&
|
|
52
|
+
newIndex < newLines.length &&
|
|
53
|
+
oldLines[oldIndex] === newLines[newIndex]) {
|
|
54
|
+
result.push(` ${lineContent(oldLines[oldIndex])}`);
|
|
55
|
+
oldIndex += 1;
|
|
56
|
+
newIndex += 1;
|
|
57
|
+
}
|
|
58
|
+
else if (newIndex < newLines.length &&
|
|
59
|
+
(oldIndex === oldLines.length ||
|
|
60
|
+
table[oldIndex * columns + newIndex + 1] >= table[(oldIndex + 1) * columns + newIndex])) {
|
|
61
|
+
result.push(`+${lineContent(newLines[newIndex])}`);
|
|
62
|
+
newIndex += 1;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
result.push(`-${lineContent(oldLines[oldIndex])}`);
|
|
66
|
+
oldIndex += 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
export function binaryDiff(oldBytes, newBytes) {
|
|
72
|
+
const length = Math.max(oldBytes.length, newBytes.length);
|
|
73
|
+
let changedBytes = 0;
|
|
74
|
+
let firstChangedOffset;
|
|
75
|
+
let lastChangedOffset;
|
|
76
|
+
for (let index = 0; index < length; index += 1) {
|
|
77
|
+
if (oldBytes[index] !== newBytes[index]) {
|
|
78
|
+
changedBytes += 1;
|
|
79
|
+
firstChangedOffset ??= index;
|
|
80
|
+
lastChangedOffset = index;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
oldSize: oldBytes.length,
|
|
85
|
+
newSize: newBytes.length,
|
|
86
|
+
changedBytes,
|
|
87
|
+
...(firstChangedOffset === undefined
|
|
88
|
+
? {}
|
|
89
|
+
: { firstChangedOffset, lastChangedOffset: lastChangedOffset }),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
import { ServiceError } from './result.js';
|
|
93
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/hoi4_agent_tools/core/diff.ts"],"names":[],"mappings":"AAsBA,MAAM,qBAAqB,GAAG,UAAU,CAAC;AAEzC,SAAS,UAAU,CAAC,IAAY;IAC9B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,oCAAoC,CAAC,IAAI,EAAE,CAAC;AAChE,CAAC;AAED,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,OAAe,EACf,OAAe,EACf,OAAe,EACf,OAAe,EACf,UAA2B,EAAE;IAE7B,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,IAAI,OAAO,KAAK,OAAO;QAAE,OAAO,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAClD,OAAO;QACL,OAAO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,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAkB,EAAE,CAAC;KACnE,CAAC;AACJ,CAAC;AACD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { WorkspaceRegistration } from './configuration.js';
|
|
2
|
+
import type { Diagnostic } from './diagnostics.js';
|
|
3
|
+
import { SymbolIndex, type IndexSkippedSource } from './index.js';
|
|
4
|
+
import { WorkspaceScanner, type ScanOptions, type ScannedFile } from './scanner.js';
|
|
5
|
+
import { ArtifactStore } from './artifacts.js';
|
|
6
|
+
import { TransactionManager } from './transactions.js';
|
|
7
|
+
import type { WorkspaceResolver } from './workspace.js';
|
|
8
|
+
export interface ScanSnapshot {
|
|
9
|
+
workspaceId: string;
|
|
10
|
+
revision: string;
|
|
11
|
+
files: ScannedFile[];
|
|
12
|
+
index: SymbolIndex;
|
|
13
|
+
complete: boolean;
|
|
14
|
+
skippedSourceCount: number;
|
|
15
|
+
skippedSources: readonly IndexSkippedSource[];
|
|
16
|
+
diagnostics: Diagnostic[];
|
|
17
|
+
}
|
|
18
|
+
export interface WorkspaceStatus {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
kind: string;
|
|
22
|
+
writeEnabled: boolean;
|
|
23
|
+
rootKinds: string[];
|
|
24
|
+
dependencyCount: number;
|
|
25
|
+
replacePaths: string[];
|
|
26
|
+
replacementOwners: Array<{
|
|
27
|
+
rootKind: string;
|
|
28
|
+
loadOrder: number;
|
|
29
|
+
paths: string[];
|
|
30
|
+
}>;
|
|
31
|
+
generatedDirectory: '.hoi4-agent';
|
|
32
|
+
}
|
|
33
|
+
export interface CoreEngineServices {
|
|
34
|
+
scanner?: WorkspaceScanner;
|
|
35
|
+
artifacts?: ArtifactStore;
|
|
36
|
+
transactions?: TransactionManager;
|
|
37
|
+
}
|
|
38
|
+
export declare class CoreEngine {
|
|
39
|
+
#private;
|
|
40
|
+
readonly resolver: WorkspaceResolver;
|
|
41
|
+
readonly scanner: WorkspaceScanner;
|
|
42
|
+
readonly artifacts: ArtifactStore;
|
|
43
|
+
readonly transactions: TransactionManager;
|
|
44
|
+
constructor(resolver: WorkspaceResolver, services?: CoreEngineServices);
|
|
45
|
+
initialize(): Promise<void>;
|
|
46
|
+
register(registration: WorkspaceRegistration, principal?: string, signal?: AbortSignal): Promise<WorkspaceStatus>;
|
|
47
|
+
status(workspaceId: string, principal?: string): WorkspaceStatus;
|
|
48
|
+
list(principal?: string): WorkspaceStatus[];
|
|
49
|
+
scan(workspaceId: string, options?: Partial<ScanOptions>, principal?: string, signal?: AbortSignal): Promise<ScanSnapshot>;
|
|
50
|
+
invalidate(workspaceId: string): void;
|
|
51
|
+
private awaitScanFlight;
|
|
52
|
+
private withScanAdmission;
|
|
53
|
+
private drainScanAdmissionQueue;
|
|
54
|
+
indexFiles(files: readonly ScannedFile[]): SymbolIndex;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/hoi4_agent_tools/core/engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,WAAW,YAAY;I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AC,EAAE,WAAW,GACnB,OAAO,CAAC,eAAe,CAAC;IAe3B,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe;IA2BhE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE;IAIrC,IAAI,CACR,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,EAClC,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,YAAY,CAAC;IAwExB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAYrC,OAAO,CAAC,eAAe;IAyDvB,OAAO,CAAC,iBAAiB;IAqCzB,OAAO,CAAC,uBAAuB;IA6B/B,UAAU,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW;CAGvD"}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { compareCodeUnits, hashCanonical } from './canonical.js';
|
|
2
|
+
import { SymbolIndex } from './index.js';
|
|
3
|
+
import { WorkspaceScanner } from './scanner.js';
|
|
4
|
+
import { ArtifactStore } from './artifacts.js';
|
|
5
|
+
import { TransactionManager } from './transactions.js';
|
|
6
|
+
function abortReason(signal) {
|
|
7
|
+
return signal.reason instanceof Error
|
|
8
|
+
? signal.reason
|
|
9
|
+
: new DOMException('The operation was aborted', 'AbortError');
|
|
10
|
+
}
|
|
11
|
+
function scanFailureReason(reason) {
|
|
12
|
+
return reason instanceof Error ? reason : new Error('Workspace scan failed', { cause: reason });
|
|
13
|
+
}
|
|
14
|
+
function under(roots, glob) {
|
|
15
|
+
return roots.map((root) => `${root.replaceAll('\\', '/').replace(/\/$/u, '')}/${glob}`);
|
|
16
|
+
}
|
|
17
|
+
function englishLocalisationPatterns(roots) {
|
|
18
|
+
return [...under(roots, 'english/**/*.{yml,yaml}'), ...under(roots, '*.{yml,yaml}')];
|
|
19
|
+
}
|
|
20
|
+
function defaultPatterns(workspace) {
|
|
21
|
+
const roots = workspace.registration.roots;
|
|
22
|
+
return [
|
|
23
|
+
...new Set([
|
|
24
|
+
...under(roots.focus, '**/*.txt'),
|
|
25
|
+
...under(roots.focus, '**/*.focus-plan.json'),
|
|
26
|
+
'common/continuous_focus/**/*.txt',
|
|
27
|
+
...under(roots.scriptedGui, '**/*.txt'),
|
|
28
|
+
'common/decisions/**/*.txt',
|
|
29
|
+
'common/ideas/**/*.txt',
|
|
30
|
+
'common/characters/**/*.txt',
|
|
31
|
+
'common/scripted_effects/**/*.txt',
|
|
32
|
+
'common/scripted_triggers/**/*.txt',
|
|
33
|
+
'events/**/*.txt',
|
|
34
|
+
...under(roots.states, '**/*.txt'),
|
|
35
|
+
// Binary rasters and positional data tables are domain-selected by Agent
|
|
36
|
+
// Nudger. The shared symbol scan retains only map sources it can index.
|
|
37
|
+
...under(roots.map, '**/*.map'),
|
|
38
|
+
...under(roots.map, '**/*.csv'),
|
|
39
|
+
...under(roots.map, '**/strategicregions/**/*.txt'),
|
|
40
|
+
...under(roots.map, '**/supply_nodes.txt'),
|
|
41
|
+
...under(roots.map, '**/railways.txt'),
|
|
42
|
+
...under(roots.interface, '**/*.{gui,gfx}'),
|
|
43
|
+
...under(roots.gfx, '**/*.gfx'),
|
|
44
|
+
// Shared scans index the default player language. GUI scenario scans add
|
|
45
|
+
// the explicitly requested language without retaining every translation.
|
|
46
|
+
...englishLocalisationPatterns(roots.localisation),
|
|
47
|
+
]),
|
|
48
|
+
].sort((left, right) => compareCodeUnits(left, right));
|
|
49
|
+
}
|
|
50
|
+
export class CoreEngine {
|
|
51
|
+
resolver;
|
|
52
|
+
scanner;
|
|
53
|
+
artifacts;
|
|
54
|
+
transactions;
|
|
55
|
+
#scanCache = new Map();
|
|
56
|
+
#scanFlights = new Map();
|
|
57
|
+
#scanGenerations = new Map();
|
|
58
|
+
#scanAdmissionQueue = [];
|
|
59
|
+
#activeScanAdmissions = new Set();
|
|
60
|
+
constructor(resolver, services = {}) {
|
|
61
|
+
this.resolver = resolver;
|
|
62
|
+
this.scanner =
|
|
63
|
+
services.scanner ??
|
|
64
|
+
new WorkspaceScanner(resolver.config().scanMaxFiles, resolver.config().scanMaxBytes, resolver.config().scanMaxFileBytes);
|
|
65
|
+
this.artifacts =
|
|
66
|
+
services.artifacts ??
|
|
67
|
+
new ArtifactStore(resolver.config().artifactMaxBytes, resolver.config().artifactMaxEntries, resolver.config().artifactMaxSingleBytes);
|
|
68
|
+
this.transactions =
|
|
69
|
+
services.transactions ??
|
|
70
|
+
new TransactionManager(resolver, this.artifacts, resolver.config().transactionTtlSeconds, resolver.config().transactionMaxJournalBytes, resolver.config().transactionMaxJournals, resolver.serverState());
|
|
71
|
+
}
|
|
72
|
+
async initialize() {
|
|
73
|
+
for (const workspace of this.resolver.list()) {
|
|
74
|
+
// Recovery is a safety repair, not a newly authorized write. An interrupted
|
|
75
|
+
// transaction must be restored even if the operator restarts read-only.
|
|
76
|
+
await this.transactions.recover(workspace.id);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async register(registration, principal, signal) {
|
|
80
|
+
signal?.throwIfAborted();
|
|
81
|
+
const workspace = await this.resolver.register(registration, principal, signal);
|
|
82
|
+
// Runtime registrations are intentionally not persisted, so startup could not
|
|
83
|
+
// discover an interrupted journal for this root. Recover it before exposing the
|
|
84
|
+
// workspace or allowing another write transaction.
|
|
85
|
+
try {
|
|
86
|
+
await this.transactions.recover(workspace.id, principal, signal);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
this.resolver.unregisterRuntime(workspace.id, principal);
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
return this.status(workspace.id, principal);
|
|
93
|
+
}
|
|
94
|
+
status(workspaceId, principal) {
|
|
95
|
+
const workspace = this.resolver.get(workspaceId, principal);
|
|
96
|
+
return {
|
|
97
|
+
id: workspace.id,
|
|
98
|
+
name: workspace.name,
|
|
99
|
+
kind: workspace.registration.kind,
|
|
100
|
+
writeEnabled: workspace.writeEnabled,
|
|
101
|
+
rootKinds: [...new Set(workspace.roots.map(({ kind }) => kind))].sort((a, b) => compareCodeUnits(a, b)),
|
|
102
|
+
dependencyCount: workspace.dependencyRoots.length,
|
|
103
|
+
replacePaths: [...workspace.registration.replacePaths].sort((a, b) => compareCodeUnits(a, b)),
|
|
104
|
+
replacementOwners: workspace.roots
|
|
105
|
+
.filter(({ replacePaths }) => replacePaths.length > 0)
|
|
106
|
+
.map(({ kind, loadOrder, replacePaths }) => ({
|
|
107
|
+
rootKind: kind,
|
|
108
|
+
loadOrder,
|
|
109
|
+
paths: [...replacePaths].sort((a, b) => compareCodeUnits(a, b)),
|
|
110
|
+
}))
|
|
111
|
+
.sort((left, right) => left.loadOrder - right.loadOrder || compareCodeUnits(left.rootKind, right.rootKind)),
|
|
112
|
+
generatedDirectory: '.hoi4-agent',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
list(principal) {
|
|
116
|
+
return this.resolver.list(principal).map(({ id }) => this.status(id, principal));
|
|
117
|
+
}
|
|
118
|
+
async scan(workspaceId, options = {}, principal, signal) {
|
|
119
|
+
signal?.throwIfAborted();
|
|
120
|
+
const workspace = this.resolver.get(workspaceId, principal);
|
|
121
|
+
const patterns = options.patterns ?? defaultPatterns(workspace);
|
|
122
|
+
const ignore = options.ignore;
|
|
123
|
+
const generation = this.#scanGenerations.get(workspaceId) ?? 0;
|
|
124
|
+
const requestKey = `${workspaceId}:${generation}:${hashCanonical({
|
|
125
|
+
patterns: [...patterns].sort(),
|
|
126
|
+
ignore: [...(ignore ?? [])].sort(),
|
|
127
|
+
maxFiles: options.maxFiles ?? this.resolver.config().scanMaxFiles,
|
|
128
|
+
maxBytes: options.maxBytes ?? this.resolver.config().scanMaxBytes,
|
|
129
|
+
})}`;
|
|
130
|
+
let flight = this.#scanFlights.get(requestKey);
|
|
131
|
+
if (flight === undefined) {
|
|
132
|
+
const controller = new AbortController();
|
|
133
|
+
const promise = (async () => {
|
|
134
|
+
return this.withScanAdmission(controller.signal, async () => {
|
|
135
|
+
const files = await this.scanner.scan(workspace, {
|
|
136
|
+
patterns,
|
|
137
|
+
...(ignore === undefined ? {} : { ignore }),
|
|
138
|
+
...(options.maxFiles === undefined ? {} : { maxFiles: options.maxFiles }),
|
|
139
|
+
...(options.maxBytes === undefined ? {} : { maxBytes: options.maxBytes }),
|
|
140
|
+
signal: controller.signal,
|
|
141
|
+
});
|
|
142
|
+
controller.signal.throwIfAborted();
|
|
143
|
+
const revision = hashCanonical(files.map(({ displayPath, loadOrder, sha256 }) => ({ displayPath, loadOrder, sha256 })));
|
|
144
|
+
const cacheKey = `${requestKey}:${revision}`;
|
|
145
|
+
const cached = this.#scanCache.get(cacheKey);
|
|
146
|
+
if (cached !== undefined)
|
|
147
|
+
return cached;
|
|
148
|
+
const index = SymbolIndex.build(files);
|
|
149
|
+
const snapshot = {
|
|
150
|
+
workspaceId,
|
|
151
|
+
revision,
|
|
152
|
+
files,
|
|
153
|
+
index,
|
|
154
|
+
complete: index.complete,
|
|
155
|
+
skippedSourceCount: index.skippedSourceCount,
|
|
156
|
+
skippedSources: index.skippedSources,
|
|
157
|
+
diagnostics: index.diagnostics,
|
|
158
|
+
};
|
|
159
|
+
if ((this.#scanGenerations.get(workspaceId) ?? 0) === generation) {
|
|
160
|
+
for (const key of this.#scanCache.keys()) {
|
|
161
|
+
if (key.startsWith(`${workspaceId}:`))
|
|
162
|
+
this.#scanCache.delete(key);
|
|
163
|
+
}
|
|
164
|
+
this.#scanCache.set(cacheKey, snapshot);
|
|
165
|
+
}
|
|
166
|
+
return snapshot;
|
|
167
|
+
});
|
|
168
|
+
})();
|
|
169
|
+
flight = { promise, controller, waiters: 0, settled: false };
|
|
170
|
+
this.#scanFlights.set(requestKey, flight);
|
|
171
|
+
const createdFlight = flight;
|
|
172
|
+
void promise.then(() => {
|
|
173
|
+
createdFlight.settled = true;
|
|
174
|
+
if (this.#scanFlights.get(requestKey) === createdFlight) {
|
|
175
|
+
this.#scanFlights.delete(requestKey);
|
|
176
|
+
}
|
|
177
|
+
}, () => {
|
|
178
|
+
createdFlight.settled = true;
|
|
179
|
+
if (this.#scanFlights.get(requestKey) === createdFlight) {
|
|
180
|
+
this.#scanFlights.delete(requestKey);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return this.awaitScanFlight(requestKey, flight, signal);
|
|
185
|
+
}
|
|
186
|
+
invalidate(workspaceId) {
|
|
187
|
+
this.#scanGenerations.set(workspaceId, (this.#scanGenerations.get(workspaceId) ?? 0) + 1);
|
|
188
|
+
for (const key of this.#scanCache.keys()) {
|
|
189
|
+
if (key.startsWith(`${workspaceId}:`))
|
|
190
|
+
this.#scanCache.delete(key);
|
|
191
|
+
}
|
|
192
|
+
for (const [key, flight] of this.#scanFlights) {
|
|
193
|
+
if (!key.startsWith(`${workspaceId}:`))
|
|
194
|
+
continue;
|
|
195
|
+
this.#scanFlights.delete(key);
|
|
196
|
+
flight.controller.abort();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
awaitScanFlight(requestKey, flight, signal) {
|
|
200
|
+
signal?.throwIfAborted();
|
|
201
|
+
flight.waiters += 1;
|
|
202
|
+
return new Promise((resolve, reject) => {
|
|
203
|
+
let complete = false;
|
|
204
|
+
const finish = () => {
|
|
205
|
+
if (complete)
|
|
206
|
+
return;
|
|
207
|
+
complete = true;
|
|
208
|
+
signal?.removeEventListener('abort', abort);
|
|
209
|
+
flight.controller.signal.removeEventListener('abort', abortFlight);
|
|
210
|
+
flight.waiters = Math.max(0, flight.waiters - 1);
|
|
211
|
+
if (flight.waiters === 0 && !flight.settled) {
|
|
212
|
+
if (this.#scanFlights.get(requestKey) === flight)
|
|
213
|
+
this.#scanFlights.delete(requestKey);
|
|
214
|
+
flight.controller.abort();
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const abort = () => {
|
|
218
|
+
reject(signal === undefined
|
|
219
|
+
? new DOMException('The operation was aborted', 'AbortError')
|
|
220
|
+
: abortReason(signal));
|
|
221
|
+
finish();
|
|
222
|
+
};
|
|
223
|
+
const abortFlight = () => {
|
|
224
|
+
reject(abortReason(flight.controller.signal));
|
|
225
|
+
finish();
|
|
226
|
+
};
|
|
227
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
228
|
+
flight.controller.signal.addEventListener('abort', abortFlight, { once: true });
|
|
229
|
+
if (signal?.aborted === true) {
|
|
230
|
+
abort();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (flight.controller.signal.aborted) {
|
|
234
|
+
abortFlight();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
void flight.promise.then((snapshot) => {
|
|
238
|
+
if (complete)
|
|
239
|
+
return;
|
|
240
|
+
finish();
|
|
241
|
+
resolve(snapshot);
|
|
242
|
+
}, (error) => {
|
|
243
|
+
if (complete)
|
|
244
|
+
return;
|
|
245
|
+
reject(scanFailureReason(error));
|
|
246
|
+
finish();
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
withScanAdmission(signal, action) {
|
|
251
|
+
return new Promise((resolve, reject) => {
|
|
252
|
+
const request = {
|
|
253
|
+
signal,
|
|
254
|
+
started: false,
|
|
255
|
+
settled: false,
|
|
256
|
+
reject,
|
|
257
|
+
run: () => {
|
|
258
|
+
request.started = true;
|
|
259
|
+
this.#activeScanAdmissions.add(request);
|
|
260
|
+
void Promise.resolve()
|
|
261
|
+
.then(() => {
|
|
262
|
+
signal.throwIfAborted();
|
|
263
|
+
return action();
|
|
264
|
+
})
|
|
265
|
+
.then(resolve, reject)
|
|
266
|
+
.finally(() => {
|
|
267
|
+
request.settled = true;
|
|
268
|
+
signal.removeEventListener('abort', onAbort);
|
|
269
|
+
this.#activeScanAdmissions.delete(request);
|
|
270
|
+
this.drainScanAdmissionQueue();
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
const onAbort = () => {
|
|
275
|
+
if (!request.started && !request.settled) {
|
|
276
|
+
request.settled = true;
|
|
277
|
+
request.reject(abortReason(signal));
|
|
278
|
+
}
|
|
279
|
+
this.drainScanAdmissionQueue();
|
|
280
|
+
};
|
|
281
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
282
|
+
this.#scanAdmissionQueue.push(request);
|
|
283
|
+
this.drainScanAdmissionQueue();
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
drainScanAdmissionQueue() {
|
|
287
|
+
while (this.#scanAdmissionQueue.length > 0) {
|
|
288
|
+
const request = this.#scanAdmissionQueue[0];
|
|
289
|
+
if (request === undefined)
|
|
290
|
+
return;
|
|
291
|
+
if (request.settled || request.signal.aborted) {
|
|
292
|
+
this.#scanAdmissionQueue.shift();
|
|
293
|
+
if (!request.settled) {
|
|
294
|
+
request.settled = true;
|
|
295
|
+
request.reject(abortReason(request.signal));
|
|
296
|
+
}
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (this.#activeScanAdmissions.size > 0) {
|
|
300
|
+
// Normal scans remain globally serialized. A single replacement may
|
|
301
|
+
// bypass an admitted scan only after that physical scan has been
|
|
302
|
+
// aborted. Keeping the physical-call ceiling at two prevents repeated
|
|
303
|
+
// invalidations from accumulating an unbounded number of scanners that
|
|
304
|
+
// ignore AbortSignal.
|
|
305
|
+
if (this.#activeScanAdmissions.size >= 2)
|
|
306
|
+
return;
|
|
307
|
+
const active = this.#activeScanAdmissions.values().next().value;
|
|
308
|
+
if (active?.signal.aborted !== true)
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
this.#scanAdmissionQueue.shift();
|
|
312
|
+
request.run();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
indexFiles(files) {
|
|
316
|
+
return SymbolIndex.build(files);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot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CAAC;YAED,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAED,UAAU,CAAC,KAA6B;QACtC,OAAO,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RenderBudget } from './render-budget.js';
|
|
2
|
+
export interface PngComparisonResult {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
changedPixels: number;
|
|
6
|
+
changedRatio: number;
|
|
7
|
+
png: Buffer;
|
|
8
|
+
json: string;
|
|
9
|
+
}
|
|
10
|
+
/** Deterministic transparent review baseline for a newly created renderable target. */
|
|
11
|
+
export declare function createTransparentPng(width: number, height: number, label: string, budget?: RenderBudget): Promise<Buffer>;
|
|
12
|
+
/** Deterministic exact-channel PNG comparison shared by every workbench. */
|
|
13
|
+
export declare function comparePngImages(leftPng: Buffer, rightPng: Buffer, threshold?: number, signal?: AbortSignal, budget?: RenderBudget): Promise<PngComparisonResult>;
|
|
14
|
+
//# sourceMappingURL=image-diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-diff.d.ts","sourceRoot":"","sources":["../../../src/hoi4_agent_tools/core/image-diff.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,YAAY,EAAqB,MAAM,oBAAoB,CAAC;AAG7F,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AA8CD,uFAAuF;AACvF,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,eAAqB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAcjB;AAED,4EAA4E;AAC5E,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,SAAI,EACb,MAAM,CAAC,EAAE,WAAW,EACpB,MAAM,eAAqB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CAyE9B"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import sharp from 'sharp';
|
|
2
|
+
import { canonicalJson } from './canonical.js';
|
|
3
|
+
import { assertRenderDimensions, RenderBudget, RENDER_MAX_PIXELS } from './render-budget.js';
|
|
4
|
+
import { ServiceError } from './result.js';
|
|
5
|
+
const IMAGE_DIFF_YIELD_PIXELS = 65_536;
|
|
6
|
+
async function yieldImageDiff(signal) {
|
|
7
|
+
signal?.throwIfAborted();
|
|
8
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
9
|
+
signal?.throwIfAborted();
|
|
10
|
+
}
|
|
11
|
+
async function imageMetadata(png, label) {
|
|
12
|
+
try {
|
|
13
|
+
return await sharp(png, { limitInputPixels: RENDER_MAX_PIXELS }).metadata();
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
if (error instanceof Error && /pixel limit/iu.test(error.message)) {
|
|
17
|
+
throw new ServiceError('RENDER_PIXELS_BLOCKED', `${label} exceeds the fixed per-artifact pixel ceiling`, { label, maximumPixels: RENDER_MAX_PIXELS });
|
|
18
|
+
}
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function normalizeImage(png, sourceWidth, sourceHeight, width, height, label) {
|
|
23
|
+
assertRenderDimensions(sourceWidth, sourceHeight, `${label} input`);
|
|
24
|
+
assertRenderDimensions(width, height, `${label} normalized plane`);
|
|
25
|
+
return sharp(png, { limitInputPixels: RENDER_MAX_PIXELS })
|
|
26
|
+
.ensureAlpha()
|
|
27
|
+
.extend({
|
|
28
|
+
right: Math.max(0, width - sourceWidth),
|
|
29
|
+
bottom: Math.max(0, height - sourceHeight),
|
|
30
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
|
31
|
+
})
|
|
32
|
+
.raw()
|
|
33
|
+
.toBuffer();
|
|
34
|
+
}
|
|
35
|
+
/** Deterministic transparent review baseline for a newly created renderable target. */
|
|
36
|
+
export async function createTransparentPng(width, height, label, budget = new RenderBudget()) {
|
|
37
|
+
assertRenderDimensions(width, height, label);
|
|
38
|
+
budget.reserve(width, height, label);
|
|
39
|
+
return sharp({
|
|
40
|
+
create: {
|
|
41
|
+
width,
|
|
42
|
+
height,
|
|
43
|
+
channels: 4,
|
|
44
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
|
45
|
+
},
|
|
46
|
+
limitInputPixels: RENDER_MAX_PIXELS,
|
|
47
|
+
})
|
|
48
|
+
.png({ compressionLevel: 9, adaptiveFiltering: false, palette: false })
|
|
49
|
+
.toBuffer();
|
|
50
|
+
}
|
|
51
|
+
/** Deterministic exact-channel PNG comparison shared by every workbench. */
|
|
52
|
+
export async function comparePngImages(leftPng, rightPng, threshold = 8, signal, budget = new RenderBudget()) {
|
|
53
|
+
signal?.throwIfAborted();
|
|
54
|
+
const [leftMetadata, rightMetadata] = await Promise.all([
|
|
55
|
+
imageMetadata(leftPng, 'left comparison PNG'),
|
|
56
|
+
imageMetadata(rightPng, 'right comparison PNG'),
|
|
57
|
+
]);
|
|
58
|
+
const leftWidth = leftMetadata.width;
|
|
59
|
+
const leftHeight = leftMetadata.height;
|
|
60
|
+
const rightWidth = rightMetadata.width;
|
|
61
|
+
const rightHeight = rightMetadata.height;
|
|
62
|
+
assertRenderDimensions(leftWidth, leftHeight, 'left comparison PNG');
|
|
63
|
+
assertRenderDimensions(rightWidth, rightHeight, 'right comparison PNG');
|
|
64
|
+
const width = Math.max(leftWidth, rightWidth);
|
|
65
|
+
const height = Math.max(leftHeight, rightHeight);
|
|
66
|
+
budget.reserve(width, height, 'left comparison normalized plane');
|
|
67
|
+
budget.reserve(width, height, 'right comparison normalized plane');
|
|
68
|
+
budget.reserve(width, height, 'comparison diff plane');
|
|
69
|
+
const [left, right] = await Promise.all([
|
|
70
|
+
normalizeImage(leftPng, leftWidth, leftHeight, width, height, 'left comparison PNG'),
|
|
71
|
+
normalizeImage(rightPng, rightWidth, rightHeight, width, height, 'right comparison PNG'),
|
|
72
|
+
]);
|
|
73
|
+
signal?.throwIfAborted();
|
|
74
|
+
const output = Buffer.alloc(width * height * 4);
|
|
75
|
+
let changedPixels = 0;
|
|
76
|
+
for (let pixel = 0; pixel < width * height; pixel += 1) {
|
|
77
|
+
if (pixel > 0 && pixel % IMAGE_DIFF_YIELD_PIXELS === 0)
|
|
78
|
+
await yieldImageDiff(signal);
|
|
79
|
+
const offset = pixel * 4;
|
|
80
|
+
const delta = Math.max(Math.abs(left.readUInt8(offset) - right.readUInt8(offset)), Math.abs(left.readUInt8(offset + 1) - right.readUInt8(offset + 1)), Math.abs(left.readUInt8(offset + 2) - right.readUInt8(offset + 2)), Math.abs(left.readUInt8(offset + 3) - right.readUInt8(offset + 3)));
|
|
81
|
+
if (delta > threshold) {
|
|
82
|
+
changedPixels += 1;
|
|
83
|
+
output[offset] = 255;
|
|
84
|
+
output[offset + 1] = 58;
|
|
85
|
+
output[offset + 2] = 94;
|
|
86
|
+
output[offset + 3] = 255;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const luminance = Math.round((left.readUInt8(offset) + left.readUInt8(offset + 1) + left.readUInt8(offset + 2)) / 3);
|
|
90
|
+
output[offset] = luminance;
|
|
91
|
+
output[offset + 1] = luminance;
|
|
92
|
+
output[offset + 2] = luminance;
|
|
93
|
+
output[offset + 3] = 96;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
assertRenderDimensions(width, height, 'comparison diff Sharp raster');
|
|
97
|
+
const png = await sharp(output, {
|
|
98
|
+
raw: { width, height, channels: 4 },
|
|
99
|
+
limitInputPixels: RENDER_MAX_PIXELS,
|
|
100
|
+
})
|
|
101
|
+
.png({ compressionLevel: 9, adaptiveFiltering: false, palette: false })
|
|
102
|
+
.toBuffer();
|
|
103
|
+
signal?.throwIfAborted();
|
|
104
|
+
const changedRatio = changedPixels / (width * height);
|
|
105
|
+
return {
|
|
106
|
+
width,
|
|
107
|
+
height,
|
|
108
|
+
changedPixels,
|
|
109
|
+
changedRatio,
|
|
110
|
+
png,
|
|
111
|
+
json: `${canonicalJson({
|
|
112
|
+
offline: true,
|
|
113
|
+
width,
|
|
114
|
+
height,
|
|
115
|
+
changedPixels,
|
|
116
|
+
changedRatio,
|
|
117
|
+
threshold,
|
|
118
|
+
})}\n`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=image-diff.js.map
|