hoi4-agent-tools 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -118
- package/README.md +35 -127
- package/SECURITY.md +5 -7
- package/dist/bin/http.js +0 -1
- package/dist/bin/setup.js +141 -92
- package/dist/bin/stdio.js +0 -1
- package/dist/hoi4_agent_tools/core/artifacts.js +0 -1
- package/dist/hoi4_agent_tools/core/canonical.js +0 -1
- package/dist/hoi4_agent_tools/core/configuration.js +28 -28
- package/dist/hoi4_agent_tools/core/diagnostic-collector.js +0 -1
- package/dist/hoi4_agent_tools/core/diagnostics.js +0 -1
- package/dist/hoi4_agent_tools/core/diff.js +0 -1
- package/dist/hoi4_agent_tools/core/engine.js +6 -21
- package/dist/hoi4_agent_tools/core/image-diff.js +0 -1
- package/dist/hoi4_agent_tools/core/index.js +0 -1
- package/dist/hoi4_agent_tools/core/render-budget.js +0 -1
- package/dist/hoi4_agent_tools/core/result.js +0 -1
- package/dist/hoi4_agent_tools/core/scanner.js +0 -1
- package/dist/hoi4_agent_tools/core/server-state.js +0 -1
- package/dist/hoi4_agent_tools/core/source/encoding.js +0 -1
- package/dist/hoi4_agent_tools/core/source/index.js +0 -1
- package/dist/hoi4_agent_tools/core/source/lexer.js +0 -1
- package/dist/hoi4_agent_tools/core/source/limits.js +0 -1
- package/dist/hoi4_agent_tools/core/source/localisation.js +0 -1
- package/dist/hoi4_agent_tools/core/source/parser.js +0 -1
- package/dist/hoi4_agent_tools/core/source/rewrite.js +0 -1
- package/dist/hoi4_agent_tools/core/svg-text.js +0 -1
- package/dist/hoi4_agent_tools/core/transaction-limits.js +0 -1
- package/dist/hoi4_agent_tools/core/transactions.js +2 -30
- package/dist/hoi4_agent_tools/core/workspace.js +112 -396
- package/dist/hoi4_agent_tools/focus/compiler.js +0 -1
- package/dist/hoi4_agent_tools/focus/continuous-render.js +0 -1
- package/dist/hoi4_agent_tools/focus/drift.js +0 -1
- package/dist/hoi4_agent_tools/focus/geometry.js +0 -1
- package/dist/hoi4_agent_tools/focus/importer.js +0 -1
- package/dist/hoi4_agent_tools/focus/index.js +0 -1
- package/dist/hoi4_agent_tools/focus/layout.js +0 -1
- package/dist/hoi4_agent_tools/focus/limits.js +0 -1
- package/dist/hoi4_agent_tools/focus/lint.js +0 -1
- package/dist/hoi4_agent_tools/focus/model.js +0 -1
- package/dist/hoi4_agent_tools/focus/native-effects.js +0 -1
- package/dist/hoi4_agent_tools/focus/planning.js +0 -1
- package/dist/hoi4_agent_tools/focus/presentation.js +0 -1
- package/dist/hoi4_agent_tools/focus/render.js +0 -1
- package/dist/hoi4_agent_tools/focus/service.js +7 -8
- package/dist/hoi4_agent_tools/focus/source-update.js +1 -2
- package/dist/hoi4_agent_tools/gui/animation-manifest.js +0 -1
- package/dist/hoi4_agent_tools/gui/assets.js +0 -1
- package/dist/hoi4_agent_tools/gui/dds.js +0 -1
- package/dist/hoi4_agent_tools/gui/helpers.js +1 -2
- package/dist/hoi4_agent_tools/gui/index.js +0 -1
- package/dist/hoi4_agent_tools/gui/layout.js +0 -1
- package/dist/hoi4_agent_tools/gui/limits.js +0 -1
- package/dist/hoi4_agent_tools/gui/renderer.js +0 -1
- package/dist/hoi4_agent_tools/gui/scenario.js +0 -1
- package/dist/hoi4_agent_tools/gui/source-graph.js +0 -1
- package/dist/hoi4_agent_tools/gui/source-patch.js +1 -2
- package/dist/hoi4_agent_tools/gui/studio.js +247 -104
- package/dist/hoi4_agent_tools/gui/tga.js +0 -1
- package/dist/hoi4_agent_tools/gui/types.js +0 -1
- package/dist/hoi4_agent_tools/gui/validators.js +0 -1
- package/dist/hoi4_agent_tools/map/bmp.js +0 -1
- package/dist/hoi4_agent_tools/map/diagnostic-limit.js +0 -1
- package/dist/hoi4_agent_tools/map/index.js +0 -1
- package/dist/hoi4_agent_tools/map/limits.js +2 -1
- package/dist/hoi4_agent_tools/map/model.js +0 -1
- package/dist/hoi4_agent_tools/map/operations.js +0 -1
- package/dist/hoi4_agent_tools/map/render.js +0 -1
- package/dist/hoi4_agent_tools/map/service.js +171 -33
- package/dist/hoi4_agent_tools/map/validation.js +0 -1
- package/dist/hoi4_agent_tools/mcp/resources/register.js +61 -187
- package/dist/hoi4_agent_tools/mcp/security/auth.js +1 -2
- package/dist/hoi4_agent_tools/mcp/server/base-tools.js +24 -750
- package/dist/hoi4_agent_tools/mcp/server/create.js +3 -12
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.js +0 -71
- package/dist/hoi4_agent_tools/mcp/server/progress.js +0 -1
- package/dist/hoi4_agent_tools/mcp/server/result.js +24 -30
- package/dist/hoi4_agent_tools/mcp/server/transaction-execution.js +10 -14
- package/dist/hoi4_agent_tools/mcp/tools/focus.js +219 -275
- package/dist/hoi4_agent_tools/mcp/tools/gui.js +149 -250
- package/dist/hoi4_agent_tools/mcp/tools/map.js +256 -337
- package/dist/hoi4_agent_tools/mcp/tools/mods.js +54 -0
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/event-store.js +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/http.js +1 -12
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js +0 -1
- package/dist/hoi4_agent_tools/runtime.js +5 -2
- package/dist/hoi4_agent_tools/schemas/common.js +1 -2
- package/dist/hoi4_agent_tools/schemas/focus.js +0 -1
- package/dist/hoi4_agent_tools/schemas/map.js +0 -1
- package/dist/hoi4_agent_tools/schemas/transaction.js +0 -1
- package/dist/hoi4_agent_tools/version.js +1 -2
- package/docs/README.md +8 -21
- package/docs/development.md +22 -0
- package/docs/focus.md +40 -0
- package/docs/gui.md +37 -0
- package/docs/http.md +53 -0
- package/docs/map.md +39 -0
- package/docs/setup.md +39 -0
- package/package.json +10 -11
- package/server.json +3 -12
- package/dist/bin/http.d.ts +0 -3
- package/dist/bin/http.d.ts.map +0 -1
- package/dist/bin/http.js.map +0 -1
- package/dist/bin/setup.d.ts +0 -3
- package/dist/bin/setup.d.ts.map +0 -1
- package/dist/bin/setup.js.map +0 -1
- package/dist/bin/stdio.d.ts +0 -3
- package/dist/bin/stdio.d.ts.map +0 -1
- package/dist/bin/stdio.js.map +0 -1
- package/dist/hoi4_agent_tools/core/artifacts.d.ts +0 -117
- package/dist/hoi4_agent_tools/core/artifacts.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/artifacts.js.map +0 -1
- package/dist/hoi4_agent_tools/core/canonical.d.ts +0 -13
- package/dist/hoi4_agent_tools/core/canonical.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/canonical.js.map +0 -1
- package/dist/hoi4_agent_tools/core/configuration.d.ts +0 -138
- package/dist/hoi4_agent_tools/core/configuration.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/configuration.js.map +0 -1
- package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts +0 -18
- package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/diagnostic-collector.js.map +0 -1
- package/dist/hoi4_agent_tools/core/diagnostics.d.ts +0 -26
- package/dist/hoi4_agent_tools/core/diagnostics.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/diagnostics.js.map +0 -1
- package/dist/hoi4_agent_tools/core/diff.d.ts +0 -22
- package/dist/hoi4_agent_tools/core/diff.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/diff.js.map +0 -1
- package/dist/hoi4_agent_tools/core/engine.d.ts +0 -57
- package/dist/hoi4_agent_tools/core/engine.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/engine.js.map +0 -1
- package/dist/hoi4_agent_tools/core/image-diff.d.ts +0 -14
- package/dist/hoi4_agent_tools/core/image-diff.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/image-diff.js.map +0 -1
- package/dist/hoi4_agent_tools/core/index.d.ts +0 -64
- package/dist/hoi4_agent_tools/core/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/index.js.map +0 -1
- package/dist/hoi4_agent_tools/core/index.public.d.ts +0 -16
- package/dist/hoi4_agent_tools/core/index.public.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/index.public.js +0 -16
- package/dist/hoi4_agent_tools/core/index.public.js.map +0 -1
- package/dist/hoi4_agent_tools/core/render-budget.d.ts +0 -51
- package/dist/hoi4_agent_tools/core/render-budget.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/render-budget.js.map +0 -1
- package/dist/hoi4_agent_tools/core/result.d.ts +0 -45
- package/dist/hoi4_agent_tools/core/result.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/result.js.map +0 -1
- package/dist/hoi4_agent_tools/core/scanner.d.ts +0 -28
- package/dist/hoi4_agent_tools/core/scanner.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/scanner.js.map +0 -1
- package/dist/hoi4_agent_tools/core/server-state.d.ts +0 -31
- package/dist/hoi4_agent_tools/core/server-state.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/server-state.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/encoding.d.ts +0 -10
- package/dist/hoi4_agent_tools/core/source/encoding.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/encoding.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/index.d.ts +0 -7
- package/dist/hoi4_agent_tools/core/source/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/index.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/lexer.d.ts +0 -30
- package/dist/hoi4_agent_tools/core/source/lexer.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/lexer.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/limits.d.ts +0 -21
- package/dist/hoi4_agent_tools/core/source/limits.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/limits.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/localisation.d.ts +0 -20
- package/dist/hoi4_agent_tools/core/source/localisation.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/localisation.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/parser.d.ts +0 -44
- package/dist/hoi4_agent_tools/core/source/parser.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/parser.js.map +0 -1
- package/dist/hoi4_agent_tools/core/source/rewrite.d.ts +0 -10
- package/dist/hoi4_agent_tools/core/source/rewrite.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/source/rewrite.js.map +0 -1
- package/dist/hoi4_agent_tools/core/svg-text.d.ts +0 -34
- package/dist/hoi4_agent_tools/core/svg-text.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/svg-text.js.map +0 -1
- package/dist/hoi4_agent_tools/core/transaction-limits.d.ts +0 -9
- package/dist/hoi4_agent_tools/core/transaction-limits.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/transaction-limits.js.map +0 -1
- package/dist/hoi4_agent_tools/core/transactions.d.ts +0 -164
- package/dist/hoi4_agent_tools/core/transactions.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/transactions.js.map +0 -1
- package/dist/hoi4_agent_tools/core/workspace.d.ts +0 -68
- package/dist/hoi4_agent_tools/core/workspace.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/core/workspace.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/compiler.d.ts +0 -10
- package/dist/hoi4_agent_tools/focus/compiler.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/compiler.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/continuous-render.d.ts +0 -32
- package/dist/hoi4_agent_tools/focus/continuous-render.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/continuous-render.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/drift.d.ts +0 -22
- package/dist/hoi4_agent_tools/focus/drift.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/drift.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/geometry.d.ts +0 -17
- package/dist/hoi4_agent_tools/focus/geometry.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/geometry.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/importer.d.ts +0 -9
- package/dist/hoi4_agent_tools/focus/importer.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/importer.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/index.d.ts +0 -14
- package/dist/hoi4_agent_tools/focus/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/index.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/layout.d.ts +0 -5
- package/dist/hoi4_agent_tools/focus/layout.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/layout.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/limits.d.ts +0 -9
- package/dist/hoi4_agent_tools/focus/limits.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/limits.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/lint.d.ts +0 -14
- package/dist/hoi4_agent_tools/focus/lint.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/lint.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/model.d.ts +0 -307
- package/dist/hoi4_agent_tools/focus/model.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/model.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/native-effects.d.ts +0 -9
- package/dist/hoi4_agent_tools/focus/native-effects.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/native-effects.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/planning.d.ts +0 -15
- package/dist/hoi4_agent_tools/focus/planning.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/planning.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/presentation.d.ts +0 -24
- package/dist/hoi4_agent_tools/focus/presentation.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/presentation.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/render.d.ts +0 -39
- package/dist/hoi4_agent_tools/focus/render.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/render.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/service.d.ts +0 -82
- package/dist/hoi4_agent_tools/focus/service.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/service.js.map +0 -1
- package/dist/hoi4_agent_tools/focus/source-update.d.ts +0 -6
- package/dist/hoi4_agent_tools/focus/source-update.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/focus/source-update.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts +0 -37
- package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/animation-manifest.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/assets.d.ts +0 -71
- package/dist/hoi4_agent_tools/gui/assets.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/assets.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/dds.d.ts +0 -17
- package/dist/hoi4_agent_tools/gui/dds.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/dds.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/helpers.d.ts +0 -101
- package/dist/hoi4_agent_tools/gui/helpers.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/helpers.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/index.d.ts +0 -15
- package/dist/hoi4_agent_tools/gui/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/index.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/layout.d.ts +0 -6
- package/dist/hoi4_agent_tools/gui/layout.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/layout.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/limits.d.ts +0 -25
- package/dist/hoi4_agent_tools/gui/limits.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/limits.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/renderer.d.ts +0 -18
- package/dist/hoi4_agent_tools/gui/renderer.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/renderer.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/scenario.d.ts +0 -66
- package/dist/hoi4_agent_tools/gui/scenario.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/scenario.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/source-graph.d.ts +0 -7
- package/dist/hoi4_agent_tools/gui/source-graph.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/source-graph.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/source-patch.d.ts +0 -13
- package/dist/hoi4_agent_tools/gui/source-patch.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/source-patch.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/studio.d.ts +0 -86
- package/dist/hoi4_agent_tools/gui/studio.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/studio.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/tga.d.ts +0 -16
- package/dist/hoi4_agent_tools/gui/tga.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/tga.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/types.d.ts +0 -322
- package/dist/hoi4_agent_tools/gui/types.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/types.js.map +0 -1
- package/dist/hoi4_agent_tools/gui/validators.d.ts +0 -8
- package/dist/hoi4_agent_tools/gui/validators.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/gui/validators.js.map +0 -1
- package/dist/hoi4_agent_tools/map/bmp.d.ts +0 -62
- package/dist/hoi4_agent_tools/map/bmp.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/bmp.js.map +0 -1
- package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts +0 -5
- package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/diagnostic-limit.js.map +0 -1
- package/dist/hoi4_agent_tools/map/index.d.ts +0 -8
- package/dist/hoi4_agent_tools/map/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/index.js.map +0 -1
- package/dist/hoi4_agent_tools/map/limits.d.ts +0 -13
- package/dist/hoi4_agent_tools/map/limits.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/limits.js.map +0 -1
- package/dist/hoi4_agent_tools/map/model.d.ts +0 -269
- package/dist/hoi4_agent_tools/map/model.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/model.js.map +0 -1
- package/dist/hoi4_agent_tools/map/operations.d.ts +0 -401
- package/dist/hoi4_agent_tools/map/operations.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/operations.js.map +0 -1
- package/dist/hoi4_agent_tools/map/render.d.ts +0 -90
- package/dist/hoi4_agent_tools/map/render.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/render.js.map +0 -1
- package/dist/hoi4_agent_tools/map/service.d.ts +0 -81
- package/dist/hoi4_agent_tools/map/service.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/service.js.map +0 -1
- package/dist/hoi4_agent_tools/map/validation.d.ts +0 -23
- package/dist/hoi4_agent_tools/map/validation.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/map/validation.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts +0 -4
- package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/prompts/register.js +0 -72
- package/dist/hoi4_agent_tools/mcp/prompts/register.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts +0 -9
- package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/registry/metadata.js +0 -10
- package/dist/hoi4_agent_tools/mcp/registry/metadata.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/resources/register.d.ts +0 -5
- package/dist/hoi4_agent_tools/mcp/resources/register.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/resources/register.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/security/auth.d.ts +0 -24
- package/dist/hoi4_agent_tools/mcp/security/auth.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/security/auth.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts +0 -47
- package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/base-tools.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/create.d.ts +0 -5
- package/dist/hoi4_agent_tools/mcp/server/create.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/create.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts +0 -138
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/output-schemas.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/progress.d.ts +0 -8
- package/dist/hoi4_agent_tools/mcp/server/progress.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/progress.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/result.d.ts +0 -232
- package/dist/hoi4_agent_tools/mcp/server/result.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/result.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/transaction-execution.d.ts +0 -31
- package/dist/hoi4_agent_tools/mcp/server/transaction-execution.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/server/transaction-execution.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts +0 -5
- package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/focus.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts +0 -117
- package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/gui.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/map.d.ts +0 -5
- package/dist/hoi4_agent_tools/mcp/tools/map.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/tools/map.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts +0 -58
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts +0 -26
- package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/event-store.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/http.d.ts +0 -28
- package/dist/hoi4_agent_tools/mcp/transports/http.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/http.js.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts +0 -15
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js.map +0 -1
- package/dist/hoi4_agent_tools/runtime.d.ts +0 -4
- package/dist/hoi4_agent_tools/runtime.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/runtime.js.map +0 -1
- package/dist/hoi4_agent_tools/schemas/common.d.ts +0 -74
- package/dist/hoi4_agent_tools/schemas/common.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/schemas/common.js.map +0 -1
- package/dist/hoi4_agent_tools/schemas/focus.d.ts +0 -784
- package/dist/hoi4_agent_tools/schemas/focus.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/schemas/focus.js.map +0 -1
- package/dist/hoi4_agent_tools/schemas/index.d.ts +0 -5
- package/dist/hoi4_agent_tools/schemas/index.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/schemas/index.js +0 -5
- package/dist/hoi4_agent_tools/schemas/index.js.map +0 -1
- package/dist/hoi4_agent_tools/schemas/map.d.ts +0 -654
- package/dist/hoi4_agent_tools/schemas/map.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/schemas/map.js.map +0 -1
- package/dist/hoi4_agent_tools/schemas/transaction.d.ts +0 -259
- package/dist/hoi4_agent_tools/schemas/transaction.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/schemas/transaction.js.map +0 -1
- package/dist/hoi4_agent_tools/version.d.ts +0 -6
- package/dist/hoi4_agent_tools/version.d.ts.map +0 -1
- package/dist/hoi4_agent_tools/version.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/docs/adr/0001-runtime-and-language.md +0 -16
- package/docs/adr/0002-lossless-source-model.md +0 -18
- package/docs/adr/0003-image-and-font-codecs.md +0 -18
- package/docs/adr/0004-focus-layout.md +0 -16
- package/docs/adr/0005-offline-rendering.md +0 -18
- package/docs/adr/0006-mcp-sdk-and-protocol.md +0 -16
- package/docs/adr/0007-storage-and-transactions.md +0 -24
- package/docs/adr/0008-test-strategy.md +0 -18
- package/docs/adr/0009-packaging-and-registry.md +0 -16
- package/docs/adr/0010-unsupported-and-refusal-policy.md +0 -18
- package/docs/adr/0011-http-security.md +0 -16
- package/docs/adr/0012-autonomous-rewrites.md +0 -55
- package/docs/adr/README.md +0 -14
- package/docs/agent-integration.md +0 -146
- package/docs/architecture.md +0 -76
- package/docs/artifacts.md +0 -136
- package/docs/compatibility.md +0 -33
- package/docs/completion-report.md +0 -122
- package/docs/configuration.md +0 -305
- package/docs/focus-workflow.md +0 -197
- package/docs/gui-workflow.md +0 -125
- package/docs/limitations.md +0 -32
- package/docs/map-workflow.md +0 -95
- package/docs/performance.md +0 -117
- package/docs/release.md +0 -222
- package/docs/research/mcp-2026-07-10.md +0 -52
- package/docs/research/source-ledger.md +0 -68
- package/docs/security.md +0 -145
- package/docs/self-hosting.md +0 -170
- package/docs/testing.md +0 -43
- package/docs/third-party-notices.md +0 -11
- package/docs/transactions.md +0 -180
- package/docs/troubleshooting.md +0 -54
- package/schemas/configuration.schema.json +0 -795
- package/schemas/continuous-focus-palette.schema.json +0 -325
- package/schemas/focus-plan.schema.json +0 -927
- package/schemas/focus-planning-sidecar.schema.json +0 -379
- package/schemas/gui-animation-source.schema.json +0 -176
- package/schemas/gui-helper.schema.json +0 -301
- package/schemas/gui-scenario.schema.json +0 -298
- package/schemas/map-operation.schema.json +0 -2284
- package/schemas/operation-result.schema.json +0 -344
- package/schemas/transaction-manifest.schema.json +0 -685
|
@@ -1,115 +1,12 @@
|
|
|
1
|
-
import { z } from 'zod/v4';
|
|
2
|
-
import { compareCodeUnits, canonicalJson, sha256Bytes } from '../../core/canonical.js';
|
|
3
1
|
import { boundedSourceHashEvidence, publicArtifactLink } from '../../core/artifacts.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { canonicalJson } from '../../core/canonical.js';
|
|
3
|
+
import { ServiceError } from '../../core/result.js';
|
|
6
4
|
import { parseClausewitz } from '../../core/source/index.js';
|
|
7
5
|
import { TRANSACTION_MAX_DIAGNOSTICS } from '../../core/transaction-limits.js';
|
|
8
6
|
import { importContinuousFocusPalettes, importFocusTrees, layoutFocusTreeAsync, lintContinuousFocusPalette, lintFocusTree, } from '../../focus/index.js';
|
|
9
7
|
import { ScriptedGuiStudio } from '../../gui/index.js';
|
|
10
8
|
import { AgentNudger, attributeMapValidationDiagnostics } from '../../map/index.js';
|
|
11
9
|
import { PACKAGE_VERSION } from '../../version.js';
|
|
12
|
-
import { artifactDescriptionSchema, indexSkippedSourceSchema, nonNegativeIntegerSchema, sha256Schema, transactionIdSchema, transactionStateDataSchema, transactionStateSchema, WORKSPACE_INLINE_OWNER_PATHS, WORKSPACE_INLINE_REPLACE_PATHS, workspaceStatusSchema, } from './output-schemas.js';
|
|
13
|
-
import { errorResult, setInlineFilesScanned, strictOperationResultSchema, toolResult, } from './result.js';
|
|
14
|
-
import { progressReporter } from './progress.js';
|
|
15
|
-
import { artifactLinkSchema } from '../../schemas/transaction.js';
|
|
16
|
-
const projectRegisterOutputSchema = strictOperationResultSchema(z.object({ workspace: workspaceStatusSchema }).strict());
|
|
17
|
-
const projectStatusOutputSchema = strictOperationResultSchema(z
|
|
18
|
-
.object({
|
|
19
|
-
count: nonNegativeIntegerSchema,
|
|
20
|
-
returned: nonNegativeIntegerSchema,
|
|
21
|
-
workspaces: z.array(workspaceStatusSchema).max(1),
|
|
22
|
-
nextCursor: z.string().max(4096).optional(),
|
|
23
|
-
})
|
|
24
|
-
.strict());
|
|
25
|
-
const projectScanOutputSchema = strictOperationResultSchema(z
|
|
26
|
-
.object({
|
|
27
|
-
revision: sha256Schema,
|
|
28
|
-
complete: z.boolean(),
|
|
29
|
-
skippedSourceCount: nonNegativeIntegerSchema,
|
|
30
|
-
skippedSources: z.array(indexSkippedSourceSchema).max(100),
|
|
31
|
-
symbols: nonNegativeIntegerSchema,
|
|
32
|
-
references: nonNegativeIntegerSchema,
|
|
33
|
-
unresolvedReferences: nonNegativeIntegerSchema,
|
|
34
|
-
symbolCounts: z.record(z.string().max(256), nonNegativeIntegerSchema),
|
|
35
|
-
})
|
|
36
|
-
.strict());
|
|
37
|
-
const transactionStatusOutputSchema = strictOperationResultSchema(z
|
|
38
|
-
.object({
|
|
39
|
-
manifest: z
|
|
40
|
-
.object({
|
|
41
|
-
version: z.number().int().positive(),
|
|
42
|
-
transactionId: transactionIdSchema,
|
|
43
|
-
createdAt: z.iso.datetime(),
|
|
44
|
-
expiresAt: z.iso.datetime(),
|
|
45
|
-
state: transactionStateSchema,
|
|
46
|
-
operationKind: z.string().min(1).max(256),
|
|
47
|
-
operationCount: nonNegativeIntegerSchema,
|
|
48
|
-
readDependencyCount: nonNegativeIntegerSchema,
|
|
49
|
-
fileCount: nonNegativeIntegerSchema,
|
|
50
|
-
diagnosticCount: nonNegativeIntegerSchema,
|
|
51
|
-
artifactCount: nonNegativeIntegerSchema,
|
|
52
|
-
appliedFileCount: nonNegativeIntegerSchema,
|
|
53
|
-
rollbackStatus: z.enum(['available', 'applied', 'failed']),
|
|
54
|
-
failure: z
|
|
55
|
-
.object({ code: z.string().max(256), message: z.string().max(4096) })
|
|
56
|
-
.strict()
|
|
57
|
-
.nullable(),
|
|
58
|
-
})
|
|
59
|
-
.strict(),
|
|
60
|
-
})
|
|
61
|
-
.strict());
|
|
62
|
-
const transactionDiffOutputSchema = strictOperationResultSchema(z
|
|
63
|
-
.object({
|
|
64
|
-
files: z
|
|
65
|
-
.array(z
|
|
66
|
-
.object({
|
|
67
|
-
relativePath: z.string().min(1).max(1024),
|
|
68
|
-
operationIdCount: nonNegativeIntegerSchema,
|
|
69
|
-
operationIds: z.array(z.string().min(1).max(256)).max(20),
|
|
70
|
-
beforeSha256: sha256Schema.nullable(),
|
|
71
|
-
afterSha256: sha256Schema.nullable(),
|
|
72
|
-
beforeSize: nonNegativeIntegerSchema.nullable(),
|
|
73
|
-
afterSize: nonNegativeIntegerSchema.nullable(),
|
|
74
|
-
mediaType: z.string().min(1).max(255),
|
|
75
|
-
diffArtifact: artifactLinkSchema.optional(),
|
|
76
|
-
})
|
|
77
|
-
.strict())
|
|
78
|
-
.max(20),
|
|
79
|
-
operations: z
|
|
80
|
-
.array(z
|
|
81
|
-
.object({
|
|
82
|
-
id: z.string().min(1).max(256),
|
|
83
|
-
kind: z.string().min(1).max(256),
|
|
84
|
-
summary: z.string().max(4096),
|
|
85
|
-
})
|
|
86
|
-
.strict())
|
|
87
|
-
.max(20),
|
|
88
|
-
fileCount: nonNegativeIntegerSchema,
|
|
89
|
-
operationCount: nonNegativeIntegerSchema,
|
|
90
|
-
artifactCount: nonNegativeIntegerSchema,
|
|
91
|
-
returnedFiles: nonNegativeIntegerSchema,
|
|
92
|
-
returnedOperations: nonNegativeIntegerSchema,
|
|
93
|
-
returnedArtifacts: nonNegativeIntegerSchema,
|
|
94
|
-
nextCursor: z.string().max(4096).optional(),
|
|
95
|
-
expiresAt: z.iso.datetime(),
|
|
96
|
-
})
|
|
97
|
-
.strict());
|
|
98
|
-
const transactionMutationOutputSchema = strictOperationResultSchema(transactionStateDataSchema
|
|
99
|
-
.extend({
|
|
100
|
-
fileCount: nonNegativeIntegerSchema.optional(),
|
|
101
|
-
appliedFileCount: nonNegativeIntegerSchema.optional(),
|
|
102
|
-
artifactCount: nonNegativeIntegerSchema.optional(),
|
|
103
|
-
})
|
|
104
|
-
.strict());
|
|
105
|
-
const artifactListOutputSchema = strictOperationResultSchema(z
|
|
106
|
-
.object({
|
|
107
|
-
count: nonNegativeIntegerSchema,
|
|
108
|
-
returned: nonNegativeIntegerSchema,
|
|
109
|
-
nextCursor: z.string().max(4096).optional(),
|
|
110
|
-
})
|
|
111
|
-
.strict());
|
|
112
|
-
const artifactDescribeOutputSchema = strictOperationResultSchema(z.object({ artifact: artifactDescriptionSchema }).strict());
|
|
113
10
|
export function requireServerScope(context, scope) {
|
|
114
11
|
if (context.scopes !== undefined && !context.scopes.includes(scope)) {
|
|
115
12
|
throw new ServiceError('AUTH_SCOPE_REQUIRED', `This operation requires the ${scope} scope`, {
|
|
@@ -117,135 +14,10 @@ export function requireServerScope(context, scope) {
|
|
|
117
14
|
});
|
|
118
15
|
}
|
|
119
16
|
}
|
|
120
|
-
const workspaceInput = z.object({ workspaceId: z.string().min(1).max(64) }).strict();
|
|
121
|
-
const transactionInput = workspaceInput
|
|
122
|
-
.extend({ transactionId: transactionIdSchema, expectedPlanHash: sha256Schema })
|
|
123
|
-
.strict();
|
|
124
17
|
function sourcePathComparisonKey(value) {
|
|
125
18
|
const normalized = value.replaceAll('\\', '/');
|
|
126
19
|
return process.platform === 'win32' ? normalized.toLocaleLowerCase('en-US') : normalized;
|
|
127
20
|
}
|
|
128
|
-
const readOnly = {
|
|
129
|
-
readOnlyHint: true,
|
|
130
|
-
destructiveHint: false,
|
|
131
|
-
idempotentHint: true,
|
|
132
|
-
openWorldHint: false,
|
|
133
|
-
};
|
|
134
|
-
const artifactProducing = {
|
|
135
|
-
readOnlyHint: false,
|
|
136
|
-
destructiveHint: false,
|
|
137
|
-
idempotentHint: true,
|
|
138
|
-
openWorldHint: false,
|
|
139
|
-
};
|
|
140
|
-
const artifactCursorSchema = z
|
|
141
|
-
.object({ version: z.literal(1), revision: sha256Schema, after: z.string().min(1).max(2048) })
|
|
142
|
-
.strict();
|
|
143
|
-
const workspaceCursorSchema = z
|
|
144
|
-
.object({ version: z.literal(1), revision: sha256Schema, after: z.string().min(1).max(64) })
|
|
145
|
-
.strict();
|
|
146
|
-
const transactionDiffCursorSchema = z
|
|
147
|
-
.object({
|
|
148
|
-
version: z.literal(1),
|
|
149
|
-
planHash: sha256Schema,
|
|
150
|
-
fileOffset: nonNegativeIntegerSchema,
|
|
151
|
-
operationOffset: nonNegativeIntegerSchema,
|
|
152
|
-
artifactOffset: nonNegativeIntegerSchema,
|
|
153
|
-
})
|
|
154
|
-
.strict();
|
|
155
|
-
function encodeArtifactCursor(revision, after) {
|
|
156
|
-
return Buffer.from(canonicalJson({ version: 1, revision, after }), 'utf8').toString('base64url');
|
|
157
|
-
}
|
|
158
|
-
function decodeArtifactCursor(cursor) {
|
|
159
|
-
try {
|
|
160
|
-
if (!/^[A-Za-z0-9_-]+$/u.test(cursor))
|
|
161
|
-
throw new Error('invalid base64url');
|
|
162
|
-
const decoded = Buffer.from(cursor, 'base64url');
|
|
163
|
-
if (decoded.toString('base64url') !== cursor)
|
|
164
|
-
throw new Error('non-canonical base64url');
|
|
165
|
-
return artifactCursorSchema.parse(JSON.parse(decoded.toString('utf8')));
|
|
166
|
-
}
|
|
167
|
-
catch {
|
|
168
|
-
throw new ServiceError('ARTIFACT_CURSOR_INVALID', 'Artifact list cursor is invalid');
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function encodeWorkspaceCursor(revision, after) {
|
|
172
|
-
return Buffer.from(canonicalJson({ version: 1, revision, after }), 'utf8').toString('base64url');
|
|
173
|
-
}
|
|
174
|
-
function decodeWorkspaceCursor(cursor) {
|
|
175
|
-
try {
|
|
176
|
-
if (!/^[A-Za-z0-9_-]+$/u.test(cursor))
|
|
177
|
-
throw new Error('invalid base64url');
|
|
178
|
-
const decoded = Buffer.from(cursor, 'base64url');
|
|
179
|
-
if (decoded.toString('base64url') !== cursor)
|
|
180
|
-
throw new Error('non-canonical base64url');
|
|
181
|
-
return workspaceCursorSchema.parse(JSON.parse(decoded.toString('utf8')));
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
throw new ServiceError('WORKSPACE_CURSOR_INVALID', 'Workspace status cursor is invalid');
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
function encodeTransactionDiffCursor(planHash, fileOffset, operationOffset, artifactOffset) {
|
|
188
|
-
return Buffer.from(canonicalJson({
|
|
189
|
-
version: 1,
|
|
190
|
-
planHash,
|
|
191
|
-
fileOffset,
|
|
192
|
-
operationOffset,
|
|
193
|
-
artifactOffset,
|
|
194
|
-
}), 'utf8').toString('base64url');
|
|
195
|
-
}
|
|
196
|
-
function decodeTransactionDiffCursor(cursor) {
|
|
197
|
-
try {
|
|
198
|
-
if (!/^[A-Za-z0-9_-]+$/u.test(cursor))
|
|
199
|
-
throw new Error('invalid base64url');
|
|
200
|
-
const decoded = Buffer.from(cursor, 'base64url');
|
|
201
|
-
if (decoded.toString('base64url') !== cursor)
|
|
202
|
-
throw new Error('non-canonical base64url');
|
|
203
|
-
return transactionDiffCursorSchema.parse(JSON.parse(decoded.toString('utf8')));
|
|
204
|
-
}
|
|
205
|
-
catch {
|
|
206
|
-
throw new ServiceError('TRANSACTION_CURSOR_INVALID', 'Transaction diff cursor is invalid');
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
export function transactionResourceLink(manifest) {
|
|
210
|
-
return {
|
|
211
|
-
uri: `hoi4-agent://workspace/${encodeURIComponent(manifest.workspaceId)}/transaction/${encodeURIComponent(manifest.transactionId)}`,
|
|
212
|
-
name: `${manifest.transactionId}.manifest.json`,
|
|
213
|
-
mimeType: 'application/json',
|
|
214
|
-
description: 'Complete authenticated transaction manifest and rollback status',
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
export function compactWorkspaceStatus(status) {
|
|
218
|
-
return {
|
|
219
|
-
...status,
|
|
220
|
-
replacePathCount: status.replacePaths.length,
|
|
221
|
-
replacePaths: status.replacePaths.slice(0, WORKSPACE_INLINE_REPLACE_PATHS),
|
|
222
|
-
replacePathsTruncated: status.replacePaths.length > WORKSPACE_INLINE_REPLACE_PATHS,
|
|
223
|
-
replacementOwners: status.replacementOwners.map((owner) => ({
|
|
224
|
-
...owner,
|
|
225
|
-
pathCount: owner.paths.length,
|
|
226
|
-
paths: owner.paths.slice(0, WORKSPACE_INLINE_OWNER_PATHS),
|
|
227
|
-
pathsTruncated: owner.paths.length > WORKSPACE_INLINE_OWNER_PATHS,
|
|
228
|
-
})),
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
function transactionSummary(manifest) {
|
|
232
|
-
return {
|
|
233
|
-
version: manifest.version,
|
|
234
|
-
transactionId: manifest.transactionId,
|
|
235
|
-
createdAt: manifest.createdAt,
|
|
236
|
-
expiresAt: manifest.expiresAt,
|
|
237
|
-
state: manifest.state,
|
|
238
|
-
operationKind: manifest.operationKind,
|
|
239
|
-
operationCount: manifest.operations.length,
|
|
240
|
-
readDependencyCount: manifest.readDependencies.length,
|
|
241
|
-
fileCount: manifest.files.length,
|
|
242
|
-
diagnosticCount: manifest.diagnostics.length,
|
|
243
|
-
artifactCount: manifest.artifacts.length,
|
|
244
|
-
appliedFileCount: manifest.appliedFiles.length,
|
|
245
|
-
rollbackStatus: manifest.rollbackStatus,
|
|
246
|
-
failure: manifest.failure ?? null,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
21
|
function focusReferences(engineSnapshot) {
|
|
250
22
|
const active = (kind) => engineSnapshot.index
|
|
251
23
|
.findAll(kind)
|
|
@@ -261,7 +33,7 @@ function focusReferences(engineSnapshot) {
|
|
|
261
33
|
helper: active('scripted_effect'),
|
|
262
34
|
};
|
|
263
35
|
}
|
|
264
|
-
export async function postValidateTransaction(engine, transaction, principal, signal
|
|
36
|
+
export async function postValidateTransaction(engine, transaction, principal, signal) {
|
|
265
37
|
engine.invalidate(transaction.workspaceId);
|
|
266
38
|
const snapshot = await engine.scan(transaction.workspaceId, {}, principal, signal);
|
|
267
39
|
const changed = new Set(transaction.files.map(({ relativePath }) => sourcePathComparisonKey(relativePath)));
|
|
@@ -294,27 +66,27 @@ export async function postValidateTransaction(engine, transaction, principal, si
|
|
|
294
66
|
id: 'post-write-focus',
|
|
295
67
|
passed,
|
|
296
68
|
message: passed
|
|
297
|
-
? '
|
|
298
|
-
: '
|
|
69
|
+
? 'The focus result re-imported, laid out, and linted successfully'
|
|
70
|
+
: 'The focus result failed post-write import or lint',
|
|
299
71
|
});
|
|
300
72
|
}
|
|
301
73
|
else if (transaction.operationKind === 'continuous-focus-plan-changes') {
|
|
302
74
|
for (const file of snapshot.files.filter(({ shadowedBy, relativePath }) => shadowedBy === undefined &&
|
|
303
75
|
relativePath.toLowerCase().endsWith('.txt') &&
|
|
304
76
|
changed.has(sourcePathComparisonKey(relativePath)))) {
|
|
305
|
-
const
|
|
306
|
-
const imported = importContinuousFocusPalettes(document);
|
|
77
|
+
const imported = importContinuousFocusPalettes(parseClausewitz(file.bytes, file.displayPath));
|
|
307
78
|
diagnostics.push(...imported.diagnostics);
|
|
308
|
-
for (const plan of imported.continuousFocusPalettes)
|
|
79
|
+
for (const plan of imported.continuousFocusPalettes) {
|
|
309
80
|
diagnostics.push(...lintContinuousFocusPalette(plan));
|
|
81
|
+
}
|
|
310
82
|
}
|
|
311
83
|
const passed = !diagnostics.some(({ severity }) => severity === 'error' || severity === 'blocker');
|
|
312
84
|
checks.push({
|
|
313
85
|
id: 'post-write-continuous-focus',
|
|
314
86
|
passed,
|
|
315
87
|
message: passed
|
|
316
|
-
? '
|
|
317
|
-
: '
|
|
88
|
+
? 'The continuous focus result re-imported and linted successfully'
|
|
89
|
+
: 'The continuous focus result failed post-write import or lint',
|
|
318
90
|
});
|
|
319
91
|
}
|
|
320
92
|
else if (transaction.operationKind === 'gui-source-change' ||
|
|
@@ -327,8 +99,8 @@ export async function postValidateTransaction(engine, transaction, principal, si
|
|
|
327
99
|
id: 'post-write-gui-graph',
|
|
328
100
|
passed,
|
|
329
101
|
message: passed
|
|
330
|
-
? '
|
|
331
|
-
: '
|
|
102
|
+
? 'The GUI graph rebuilt successfully'
|
|
103
|
+
: 'The GUI graph has blocking diagnostics',
|
|
332
104
|
});
|
|
333
105
|
}
|
|
334
106
|
else if (transaction.operationKind === 'agent-nudger-map-changes') {
|
|
@@ -346,8 +118,8 @@ export async function postValidateTransaction(engine, transaction, principal, si
|
|
|
346
118
|
id: 'post-write-map',
|
|
347
119
|
passed: validated.validation.passed,
|
|
348
120
|
message: validated.validation.passed
|
|
349
|
-
? '
|
|
350
|
-
: '
|
|
121
|
+
? 'The map result rescanned and validated successfully'
|
|
122
|
+
: 'The map result failed post-write validation',
|
|
351
123
|
});
|
|
352
124
|
}
|
|
353
125
|
const passed = !diagnostics.some(({ severity }) => severity === 'error' || severity === 'blocker');
|
|
@@ -355,36 +127,26 @@ export async function postValidateTransaction(engine, transaction, principal, si
|
|
|
355
127
|
id: 'post-write-shared-index',
|
|
356
128
|
passed,
|
|
357
129
|
message: passed
|
|
358
|
-
? 'Changed
|
|
359
|
-
: 'Changed
|
|
130
|
+
? 'Changed files reparsed and reindexed successfully'
|
|
131
|
+
: 'Changed files have blocking post-write diagnostics',
|
|
360
132
|
});
|
|
361
133
|
const availableDiagnostics = Math.max(0, TRANSACTION_MAX_DIAGNOSTICS - transaction.diagnostics.length);
|
|
362
134
|
if (diagnostics.length > availableDiagnostics) {
|
|
363
135
|
const workspace = engine.resolver.get(transaction.workspaceId, principal);
|
|
364
136
|
const sourceEvidence = boundedSourceHashEvidence(Object.fromEntries(transaction.files.flatMap(({ relativePath, afterSha256 }) => afterSha256 === null ? [] : [[relativePath, afterSha256]])));
|
|
365
|
-
const artifact = await engine.artifacts.putChunked(workspace,
|
|
366
|
-
? `${transaction.operationKind}.post-validation.json`
|
|
367
|
-
: `${transaction.transactionId}.post-validation.json`, 'application/json', `${canonicalJson({
|
|
137
|
+
const artifact = await engine.artifacts.putChunked(workspace, `${transaction.operationKind}.post-validation.json`, 'application/json', `${canonicalJson({
|
|
368
138
|
schemaVersion: 1,
|
|
369
|
-
...(autonomous
|
|
370
|
-
? { execution: 'autonomous-rewrite' }
|
|
371
|
-
: {
|
|
372
|
-
transactionId: transaction.transactionId,
|
|
373
|
-
planHash: transaction.planHash,
|
|
374
|
-
}),
|
|
375
139
|
operationKind: transaction.operationKind,
|
|
376
140
|
diagnosticCount: diagnostics.length,
|
|
377
141
|
checks,
|
|
378
142
|
diagnostics,
|
|
379
143
|
})}\n`, {
|
|
380
|
-
kind:
|
|
144
|
+
kind: 'rewrite-post-validation',
|
|
381
145
|
toolVersion: PACKAGE_VERSION,
|
|
382
|
-
schemaVersion:
|
|
383
|
-
? 'autonomous-rewrite-post-validation.v1'
|
|
384
|
-
: 'transaction-post-validation.v1',
|
|
146
|
+
schemaVersion: 'rewrite-post-validation.v1',
|
|
385
147
|
sourceHashes: sourceEvidence.sourceHashes,
|
|
386
148
|
metadata: { sourceHashInventory: sourceEvidence.inventory },
|
|
387
|
-
}, 'Complete
|
|
149
|
+
}, 'Complete diagnostics from post-write validation', signal);
|
|
388
150
|
const retainedLimit = Math.max(0, availableDiagnostics - 1);
|
|
389
151
|
const hard = diagnostics.filter(({ severity }) => severity === 'error' || severity === 'blocker');
|
|
390
152
|
const retainedHard = hard.slice(0, retainedLimit);
|
|
@@ -394,7 +156,7 @@ export async function postValidateTransaction(engine, transaction, principal, si
|
|
|
394
156
|
const omittedHard = hard.length - retainedHard.length;
|
|
395
157
|
const artifactLink = publicArtifactLink(artifact);
|
|
396
158
|
checks.push({
|
|
397
|
-
id: 'post-write-diagnostics-
|
|
159
|
+
id: 'post-write-diagnostics-artifact',
|
|
398
160
|
passed: omittedHard === 0,
|
|
399
161
|
message: `Complete post-write diagnostics are stored at ${artifactLink.uri}`,
|
|
400
162
|
});
|
|
@@ -405,10 +167,10 @@ export async function postValidateTransaction(engine, transaction, principal, si
|
|
|
405
167
|
...retainedHard,
|
|
406
168
|
...retainedSoft,
|
|
407
169
|
{
|
|
408
|
-
code: '
|
|
170
|
+
code: 'POST_VALIDATION_DIAGNOSTICS_IN_ARTIFACT',
|
|
409
171
|
severity: omittedHard > 0 ? 'blocker' : 'warning',
|
|
410
|
-
category: '
|
|
411
|
-
message: `Complete post-write validation contains ${diagnostics.length} diagnostics and is stored as an
|
|
172
|
+
category: 'validation',
|
|
173
|
+
message: `Complete post-write validation contains ${diagnostics.length} diagnostics and is stored as an artifact`,
|
|
412
174
|
details: {
|
|
413
175
|
total: diagnostics.length,
|
|
414
176
|
returned: availableDiagnostics,
|
|
@@ -424,491 +186,3 @@ export async function postValidateTransaction(engine, transaction, principal, si
|
|
|
424
186
|
}
|
|
425
187
|
return { diagnostics, checks, artifacts: [] };
|
|
426
188
|
}
|
|
427
|
-
export function registerBaseTools(server, engine, context) {
|
|
428
|
-
server.registerTool('hoi4.project_register', {
|
|
429
|
-
title: 'Register HOI4 workspace',
|
|
430
|
-
description: 'Register one server-side workspace under a configured registration root; does not edit MCP clients.',
|
|
431
|
-
inputSchema: workspaceRegistrationSchema,
|
|
432
|
-
outputSchema: projectRegisterOutputSchema,
|
|
433
|
-
annotations: {
|
|
434
|
-
readOnlyHint: false,
|
|
435
|
-
destructiveHint: false,
|
|
436
|
-
idempotentHint: false,
|
|
437
|
-
openWorldHint: false,
|
|
438
|
-
},
|
|
439
|
-
}, async (registration, extra) => {
|
|
440
|
-
try {
|
|
441
|
-
requireServerScope(context, 'hoi4:write');
|
|
442
|
-
const progress = progressReporter(extra);
|
|
443
|
-
progress.signal.throwIfAborted();
|
|
444
|
-
const status = await engine.register(registration, context.principal, progress.signal);
|
|
445
|
-
const result = emptyServiceResult(status.id, { workspace: compactWorkspaceStatus(status) });
|
|
446
|
-
result.code = 'WORKSPACE_REGISTERED';
|
|
447
|
-
return toolResult(result);
|
|
448
|
-
}
|
|
449
|
-
catch (error) {
|
|
450
|
-
return errorResult(error, registration.id);
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
server.registerTool('hoi4.project_status', {
|
|
454
|
-
title: 'Inspect HOI4 workspace status',
|
|
455
|
-
description: 'Return registered workspace capabilities without exposing canonical server paths.',
|
|
456
|
-
inputSchema: z
|
|
457
|
-
.object({
|
|
458
|
-
workspaceId: z.string().min(1).max(64).optional(),
|
|
459
|
-
cursor: z.string().min(1).max(4096).optional(),
|
|
460
|
-
})
|
|
461
|
-
.strict()
|
|
462
|
-
.superRefine((value, issue) => {
|
|
463
|
-
if (value.workspaceId !== undefined && value.cursor !== undefined) {
|
|
464
|
-
issue.addIssue({
|
|
465
|
-
code: 'custom',
|
|
466
|
-
message: 'cursor is only valid when listing all authorized workspaces',
|
|
467
|
-
path: ['cursor'],
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
}),
|
|
471
|
-
outputSchema: projectStatusOutputSchema,
|
|
472
|
-
annotations: readOnly,
|
|
473
|
-
}, ({ workspaceId, cursor }) => {
|
|
474
|
-
try {
|
|
475
|
-
const statuses = workspaceId === undefined
|
|
476
|
-
? engine
|
|
477
|
-
.list(context.principal)
|
|
478
|
-
.sort((left, right) => compareCodeUnits(left.id, right.id))
|
|
479
|
-
: [engine.status(workspaceId, context.principal)];
|
|
480
|
-
const revision = sha256Bytes(Buffer.from(canonicalJson(statuses.map(({ id }) => id)), 'utf8'));
|
|
481
|
-
let offset = 0;
|
|
482
|
-
if (cursor !== undefined) {
|
|
483
|
-
const decoded = decodeWorkspaceCursor(cursor);
|
|
484
|
-
const afterIndex = statuses.findIndex(({ id }) => id === decoded.after);
|
|
485
|
-
if (decoded.revision !== revision || afterIndex < 0) {
|
|
486
|
-
throw new ServiceError('WORKSPACE_CURSOR_STALE', 'Workspace inventory changed; restart pagination without a cursor');
|
|
487
|
-
}
|
|
488
|
-
offset = afterIndex + 1;
|
|
489
|
-
}
|
|
490
|
-
const page = statuses.slice(offset, offset + 1);
|
|
491
|
-
const last = page.at(-1);
|
|
492
|
-
const nextCursor = offset + page.length < statuses.length && last !== undefined
|
|
493
|
-
? encodeWorkspaceCursor(revision, last.id)
|
|
494
|
-
: undefined;
|
|
495
|
-
const result = emptyServiceResult(workspaceId ?? '', {
|
|
496
|
-
count: statuses.length,
|
|
497
|
-
returned: page.length,
|
|
498
|
-
workspaces: page.map(compactWorkspaceStatus),
|
|
499
|
-
...(nextCursor === undefined ? {} : { nextCursor }),
|
|
500
|
-
});
|
|
501
|
-
result.code = 'WORKSPACE_STATUS';
|
|
502
|
-
return toolResult(result);
|
|
503
|
-
}
|
|
504
|
-
catch (error) {
|
|
505
|
-
return errorResult(error, workspaceId ?? '');
|
|
506
|
-
}
|
|
507
|
-
});
|
|
508
|
-
server.registerTool('hoi4.project_scan', {
|
|
509
|
-
title: 'Scan HOI4 workspace',
|
|
510
|
-
description: 'Build the shared source/index snapshot across game, dependencies, and mod load order.',
|
|
511
|
-
inputSchema: workspaceInput
|
|
512
|
-
.extend({
|
|
513
|
-
maxFiles: z.number().int().min(1).max(1_000_000).optional(),
|
|
514
|
-
maxBytes: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
|
|
515
|
-
})
|
|
516
|
-
.strict(),
|
|
517
|
-
outputSchema: projectScanOutputSchema,
|
|
518
|
-
annotations: artifactProducing,
|
|
519
|
-
}, async ({ workspaceId, maxFiles, maxBytes }, extra) => {
|
|
520
|
-
try {
|
|
521
|
-
const progress = progressReporter(extra);
|
|
522
|
-
await progress.report(0, 3, 'Resolving workspace');
|
|
523
|
-
const snapshot = await engine.scan(workspaceId, {
|
|
524
|
-
...(maxFiles === undefined ? {} : { maxFiles }),
|
|
525
|
-
...(maxBytes === undefined ? {} : { maxBytes }),
|
|
526
|
-
}, context.principal, progress.signal);
|
|
527
|
-
await progress.report(2, 3, 'Writing diagnostics artifact');
|
|
528
|
-
const workspace = engine.resolver.get(workspaceId, context.principal);
|
|
529
|
-
const sourceEvidence = boundedSourceHashEvidence(Object.fromEntries(snapshot.files.map(({ displayPath, sha256 }) => [displayPath, sha256])));
|
|
530
|
-
const diagnosticsArtifact = await engine.artifacts.putChunked(workspace, 'diagnostics.json', 'application/json', `${canonicalJson({
|
|
531
|
-
revision: snapshot.revision,
|
|
532
|
-
complete: snapshot.complete,
|
|
533
|
-
skippedSourceCount: snapshot.skippedSourceCount,
|
|
534
|
-
skippedSources: snapshot.skippedSources,
|
|
535
|
-
files: snapshot.files.map(({ displayPath, sha256 }) => ({ displayPath, sha256 })),
|
|
536
|
-
diagnostics: snapshot.diagnostics,
|
|
537
|
-
})}\n`, {
|
|
538
|
-
kind: 'diagnostics',
|
|
539
|
-
toolVersion: PACKAGE_VERSION,
|
|
540
|
-
schemaVersion: 'diagnostics.v1',
|
|
541
|
-
sourceHashes: sourceEvidence.sourceHashes,
|
|
542
|
-
metadata: { sourceHashInventory: sourceEvidence.inventory },
|
|
543
|
-
}, 'Source-linked diagnostics and bounded shared-index completeness report', progress.signal);
|
|
544
|
-
const result = emptyServiceResult(workspaceId, {
|
|
545
|
-
revision: snapshot.revision,
|
|
546
|
-
complete: snapshot.complete,
|
|
547
|
-
skippedSourceCount: snapshot.skippedSourceCount,
|
|
548
|
-
skippedSources: snapshot.skippedSources,
|
|
549
|
-
symbols: snapshot.index.symbols.length,
|
|
550
|
-
references: snapshot.index.references.length,
|
|
551
|
-
unresolvedReferences: snapshot.index.unresolvedReferences().length,
|
|
552
|
-
symbolCounts: Object.fromEntries([...new Set(snapshot.index.symbols.map(({ kind }) => kind))]
|
|
553
|
-
.sort((a, b) => compareCodeUnits(a, b))
|
|
554
|
-
.map((kind) => [
|
|
555
|
-
kind,
|
|
556
|
-
snapshot.index.symbols.filter((symbol) => symbol.kind === kind).length,
|
|
557
|
-
])),
|
|
558
|
-
});
|
|
559
|
-
result.code = snapshot.complete ? 'WORKSPACE_SCANNED' : 'WORKSPACE_SCANNED_PARTIAL';
|
|
560
|
-
setInlineFilesScanned(result, snapshot.files.map(({ displayPath }) => displayPath));
|
|
561
|
-
result.diagnostics = snapshot.diagnostics.slice(0, 100);
|
|
562
|
-
result.artifacts = [publicArtifactLink(diagnosticsArtifact)];
|
|
563
|
-
result.validation = {
|
|
564
|
-
passed: !snapshot.diagnostics.some(({ severity }) => severity === 'error' || severity === 'blocker'),
|
|
565
|
-
checks: [
|
|
566
|
-
{
|
|
567
|
-
id: 'shared-index',
|
|
568
|
-
passed: true,
|
|
569
|
-
message: snapshot.complete
|
|
570
|
-
? `${snapshot.index.symbols.length} symbols indexed from a complete inventory`
|
|
571
|
-
: `${snapshot.index.symbols.length} symbols indexed from an incomplete inventory; ${snapshot.skippedSourceCount} over-limit source(s) were recorded and aggregate index ceilings may also apply`,
|
|
572
|
-
},
|
|
573
|
-
],
|
|
574
|
-
};
|
|
575
|
-
await progress.report(3, 3, 'Scan complete');
|
|
576
|
-
return toolResult(result);
|
|
577
|
-
}
|
|
578
|
-
catch (error) {
|
|
579
|
-
return errorResult(error, workspaceId);
|
|
580
|
-
}
|
|
581
|
-
});
|
|
582
|
-
if (engine.resolver.config().writePolicy !== 'autonomous') {
|
|
583
|
-
server.registerTool('hoi4.transaction_status', {
|
|
584
|
-
title: 'Inspect transaction',
|
|
585
|
-
description: 'Return compact dry-run/apply/rollback counts and current state with a complete manifest resource.',
|
|
586
|
-
inputSchema: workspaceInput.extend({ transactionId: transactionIdSchema }).strict(),
|
|
587
|
-
outputSchema: transactionStatusOutputSchema,
|
|
588
|
-
annotations: readOnly,
|
|
589
|
-
}, async ({ workspaceId, transactionId }, extra) => {
|
|
590
|
-
try {
|
|
591
|
-
const progress = progressReporter(extra);
|
|
592
|
-
progress.signal.throwIfAborted();
|
|
593
|
-
const manifest = await engine.transactions.status(workspaceId, transactionId, context.principal, progress.signal);
|
|
594
|
-
progress.signal.throwIfAborted();
|
|
595
|
-
const result = emptyServiceResult(workspaceId, {
|
|
596
|
-
manifest: transactionSummary(manifest),
|
|
597
|
-
});
|
|
598
|
-
result.code = 'TRANSACTION_STATUS';
|
|
599
|
-
result.transactionId = manifest.transactionId;
|
|
600
|
-
result.planHash = manifest.planHash;
|
|
601
|
-
result.proposedFiles = manifest.files
|
|
602
|
-
.slice(0, 100)
|
|
603
|
-
.map(({ relativePath }) => relativePath);
|
|
604
|
-
result.changedFiles = manifest.appliedFiles.slice(0, 100);
|
|
605
|
-
result.artifacts = [transactionResourceLink(manifest)];
|
|
606
|
-
result.validation = manifest.validation;
|
|
607
|
-
result.rollbackStatus = manifest.rollbackStatus;
|
|
608
|
-
return toolResult(result);
|
|
609
|
-
}
|
|
610
|
-
catch (error) {
|
|
611
|
-
return errorResult(error, workspaceId);
|
|
612
|
-
}
|
|
613
|
-
});
|
|
614
|
-
server.registerTool('hoi4.transaction_diff', {
|
|
615
|
-
title: 'Review transaction diff',
|
|
616
|
-
description: 'Page through the complete affected-file set, operation summaries, and source/binary artifact links before apply.',
|
|
617
|
-
inputSchema: workspaceInput
|
|
618
|
-
.extend({
|
|
619
|
-
transactionId: transactionIdSchema,
|
|
620
|
-
limit: z.number().int().min(1).max(20).default(20),
|
|
621
|
-
cursor: z.string().min(1).max(4096).optional(),
|
|
622
|
-
})
|
|
623
|
-
.strict(),
|
|
624
|
-
outputSchema: transactionDiffOutputSchema,
|
|
625
|
-
annotations: readOnly,
|
|
626
|
-
}, async ({ workspaceId, transactionId, limit, cursor }, extra) => {
|
|
627
|
-
try {
|
|
628
|
-
const progress = progressReporter(extra);
|
|
629
|
-
progress.signal.throwIfAborted();
|
|
630
|
-
const manifest = await engine.transactions.status(workspaceId, transactionId, context.principal, progress.signal);
|
|
631
|
-
progress.signal.throwIfAborted();
|
|
632
|
-
let fileOffset = 0;
|
|
633
|
-
let operationOffset = 0;
|
|
634
|
-
let artifactOffset = 0;
|
|
635
|
-
if (cursor !== undefined) {
|
|
636
|
-
const decoded = decodeTransactionDiffCursor(cursor);
|
|
637
|
-
if (decoded.planHash !== manifest.planHash ||
|
|
638
|
-
decoded.fileOffset > manifest.files.length ||
|
|
639
|
-
decoded.operationOffset > manifest.operations.length ||
|
|
640
|
-
decoded.artifactOffset > manifest.artifacts.length) {
|
|
641
|
-
throw new ServiceError('TRANSACTION_CURSOR_STALE', 'Transaction plan changed or the diff cursor is stale');
|
|
642
|
-
}
|
|
643
|
-
fileOffset = decoded.fileOffset;
|
|
644
|
-
operationOffset = decoded.operationOffset;
|
|
645
|
-
artifactOffset = decoded.artifactOffset;
|
|
646
|
-
}
|
|
647
|
-
const manifestFiles = manifest.files.slice(fileOffset, fileOffset + limit);
|
|
648
|
-
const files = manifestFiles.map(({ relativePath, operationIds, beforeSha256, afterSha256, beforeSize, afterSize, mediaType, diffArtifact, }) => ({
|
|
649
|
-
relativePath,
|
|
650
|
-
operationIdCount: operationIds.length,
|
|
651
|
-
operationIds: operationIds.slice(0, 20),
|
|
652
|
-
beforeSha256,
|
|
653
|
-
afterSha256,
|
|
654
|
-
beforeSize,
|
|
655
|
-
afterSize,
|
|
656
|
-
mediaType,
|
|
657
|
-
...(diffArtifact === undefined ? {} : { diffArtifact }),
|
|
658
|
-
}));
|
|
659
|
-
const operations = manifest.operations.slice(operationOffset, operationOffset + limit);
|
|
660
|
-
const artifacts = manifest.artifacts.slice(artifactOffset, artifactOffset + limit);
|
|
661
|
-
const nextFileOffset = fileOffset + manifestFiles.length;
|
|
662
|
-
const nextOperationOffset = operationOffset + operations.length;
|
|
663
|
-
const nextArtifactOffset = artifactOffset + artifacts.length;
|
|
664
|
-
const nextCursor = nextFileOffset < manifest.files.length ||
|
|
665
|
-
nextOperationOffset < manifest.operations.length ||
|
|
666
|
-
nextArtifactOffset < manifest.artifacts.length
|
|
667
|
-
? encodeTransactionDiffCursor(manifest.planHash, nextFileOffset, nextOperationOffset, nextArtifactOffset)
|
|
668
|
-
: undefined;
|
|
669
|
-
const result = emptyServiceResult(workspaceId, {
|
|
670
|
-
files,
|
|
671
|
-
operations: operations.map(({ id, kind, summary }) => ({ id, kind, summary })),
|
|
672
|
-
fileCount: manifest.files.length,
|
|
673
|
-
operationCount: manifest.operations.length,
|
|
674
|
-
artifactCount: manifest.artifacts.length,
|
|
675
|
-
returnedFiles: files.length,
|
|
676
|
-
returnedOperations: operations.length,
|
|
677
|
-
returnedArtifacts: artifacts.length,
|
|
678
|
-
...(nextCursor === undefined ? {} : { nextCursor }),
|
|
679
|
-
expiresAt: manifest.expiresAt,
|
|
680
|
-
});
|
|
681
|
-
result.code = 'TRANSACTION_DIFF';
|
|
682
|
-
result.transactionId = manifest.transactionId;
|
|
683
|
-
result.planHash = manifest.planHash;
|
|
684
|
-
result.proposedFiles = files.map(({ relativePath }) => relativePath);
|
|
685
|
-
result.artifacts = [transactionResourceLink(manifest), ...artifacts];
|
|
686
|
-
result.validation = manifest.validation;
|
|
687
|
-
result.rollbackStatus = manifest.rollbackStatus;
|
|
688
|
-
return toolResult(result);
|
|
689
|
-
}
|
|
690
|
-
catch (error) {
|
|
691
|
-
return errorResult(error, workspaceId);
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
server.registerTool('hoi4.transaction_apply', {
|
|
695
|
-
title: 'Apply reviewed transaction',
|
|
696
|
-
description: 'Apply a completed dry run only when transaction ID, workspace, principal, source hashes, and expected plan hash still match.',
|
|
697
|
-
inputSchema: transactionInput,
|
|
698
|
-
outputSchema: transactionMutationOutputSchema,
|
|
699
|
-
annotations: {
|
|
700
|
-
readOnlyHint: false,
|
|
701
|
-
destructiveHint: true,
|
|
702
|
-
idempotentHint: false,
|
|
703
|
-
openWorldHint: false,
|
|
704
|
-
},
|
|
705
|
-
}, async ({ workspaceId, transactionId, expectedPlanHash }, extra) => {
|
|
706
|
-
try {
|
|
707
|
-
requireServerScope(context, 'hoi4:write');
|
|
708
|
-
const progress = progressReporter(extra);
|
|
709
|
-
await progress.report(0, 3, 'Checking transaction preconditions');
|
|
710
|
-
const manifest = await engine.transactions.apply(workspaceId, transactionId, expectedPlanHash, {
|
|
711
|
-
...(context.principal === undefined ? {} : { principal: context.principal }),
|
|
712
|
-
signal: progress.signal,
|
|
713
|
-
postValidate: (transaction, signal) => postValidateTransaction(engine, transaction, context.principal, signal),
|
|
714
|
-
});
|
|
715
|
-
engine.invalidate(workspaceId);
|
|
716
|
-
await engine.scan(workspaceId, {}, context.principal, progress.signal);
|
|
717
|
-
await progress.report(3, 3, 'Apply and index rebuild complete');
|
|
718
|
-
const result = emptyServiceResult(workspaceId, {
|
|
719
|
-
state: manifest.state,
|
|
720
|
-
fileCount: manifest.files.length,
|
|
721
|
-
appliedFileCount: manifest.appliedFiles.length,
|
|
722
|
-
artifactCount: manifest.artifacts.length,
|
|
723
|
-
});
|
|
724
|
-
result.code = 'TRANSACTION_APPLIED';
|
|
725
|
-
result.transactionId = manifest.transactionId;
|
|
726
|
-
result.planHash = manifest.planHash;
|
|
727
|
-
result.proposedFiles = manifest.files
|
|
728
|
-
.slice(0, 100)
|
|
729
|
-
.map(({ relativePath }) => relativePath);
|
|
730
|
-
result.changedFiles = manifest.appliedFiles.slice(0, 100);
|
|
731
|
-
result.artifacts = [transactionResourceLink(manifest)];
|
|
732
|
-
result.validation = manifest.validation;
|
|
733
|
-
result.rollbackStatus = manifest.rollbackStatus;
|
|
734
|
-
return toolResult(result);
|
|
735
|
-
}
|
|
736
|
-
catch (error) {
|
|
737
|
-
engine.invalidate(workspaceId);
|
|
738
|
-
try {
|
|
739
|
-
const failed = await engine.transactions.status(workspaceId, transactionId, context.principal);
|
|
740
|
-
return errorResult(error, workspaceId, {
|
|
741
|
-
transactionId: failed.transactionId,
|
|
742
|
-
planHash: failed.planHash,
|
|
743
|
-
proposedFiles: failed.files.slice(0, 100).map(({ relativePath }) => relativePath),
|
|
744
|
-
changedFiles: failed.state === 'applied' ? failed.appliedFiles.slice(0, 100) : [],
|
|
745
|
-
artifacts: [transactionResourceLink(failed)],
|
|
746
|
-
validation: failed.validation,
|
|
747
|
-
rollbackStatus: failed.rollbackStatus,
|
|
748
|
-
data: { state: failed.state, failure: failed.failure ?? null },
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
catch {
|
|
752
|
-
// A forged or cross-workspace transaction ID intentionally reveals no manifest details.
|
|
753
|
-
}
|
|
754
|
-
return errorResult(error, workspaceId);
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
server.registerTool('hoi4.transaction_rollback', {
|
|
758
|
-
title: 'Roll back applied transaction',
|
|
759
|
-
description: 'Restore exact original bytes when the applied result still matches rollback preconditions.',
|
|
760
|
-
inputSchema: transactionInput,
|
|
761
|
-
outputSchema: transactionMutationOutputSchema,
|
|
762
|
-
annotations: {
|
|
763
|
-
readOnlyHint: false,
|
|
764
|
-
destructiveHint: true,
|
|
765
|
-
idempotentHint: false,
|
|
766
|
-
openWorldHint: false,
|
|
767
|
-
},
|
|
768
|
-
}, async ({ workspaceId, transactionId, expectedPlanHash }, extra) => {
|
|
769
|
-
try {
|
|
770
|
-
requireServerScope(context, 'hoi4:write');
|
|
771
|
-
const progress = progressReporter(extra);
|
|
772
|
-
await progress.report(0, 2, 'Checking rollback preconditions');
|
|
773
|
-
progress.signal.throwIfAborted();
|
|
774
|
-
const manifest = await engine.transactions.rollback(workspaceId, transactionId, expectedPlanHash, context.principal, progress.signal);
|
|
775
|
-
engine.invalidate(workspaceId);
|
|
776
|
-
const result = emptyServiceResult(workspaceId, {
|
|
777
|
-
state: manifest.state,
|
|
778
|
-
fileCount: manifest.files.length,
|
|
779
|
-
appliedFileCount: manifest.appliedFiles.length,
|
|
780
|
-
artifactCount: manifest.artifacts.length,
|
|
781
|
-
});
|
|
782
|
-
result.code = 'TRANSACTION_ROLLED_BACK';
|
|
783
|
-
result.transactionId = manifest.transactionId;
|
|
784
|
-
result.planHash = manifest.planHash;
|
|
785
|
-
result.changedFiles = manifest.files
|
|
786
|
-
.slice(0, 100)
|
|
787
|
-
.map(({ relativePath }) => relativePath);
|
|
788
|
-
result.artifacts = [transactionResourceLink(manifest)];
|
|
789
|
-
result.validation = manifest.validation;
|
|
790
|
-
result.rollbackStatus = manifest.rollbackStatus;
|
|
791
|
-
await progress.report(2, 2, 'Atomic rollback complete');
|
|
792
|
-
return toolResult(result);
|
|
793
|
-
}
|
|
794
|
-
catch (error) {
|
|
795
|
-
try {
|
|
796
|
-
const failed = await engine.transactions.status(workspaceId, transactionId, context.principal);
|
|
797
|
-
return errorResult(error, workspaceId, {
|
|
798
|
-
transactionId: failed.transactionId,
|
|
799
|
-
planHash: failed.planHash,
|
|
800
|
-
proposedFiles: failed.files.slice(0, 100).map(({ relativePath }) => relativePath),
|
|
801
|
-
changedFiles: failed.state === 'applied' ? failed.appliedFiles.slice(0, 100) : [],
|
|
802
|
-
artifacts: [transactionResourceLink(failed)],
|
|
803
|
-
validation: failed.validation,
|
|
804
|
-
rollbackStatus: failed.rollbackStatus,
|
|
805
|
-
data: { state: failed.state, failure: failed.failure ?? null },
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
catch {
|
|
809
|
-
// Invalid or inaccessible transaction IDs intentionally reveal no manifest details.
|
|
810
|
-
}
|
|
811
|
-
return errorResult(error, workspaceId);
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
server.registerTool('hoi4.artifact_list', {
|
|
816
|
-
title: 'List workspace artifacts',
|
|
817
|
-
description: 'List content-addressed artifacts without exposing filesystem paths.',
|
|
818
|
-
inputSchema: workspaceInput
|
|
819
|
-
.extend({
|
|
820
|
-
limit: z.number().int().min(1).max(100).default(100),
|
|
821
|
-
cursor: z.string().min(1).max(4096).optional(),
|
|
822
|
-
})
|
|
823
|
-
.strict(),
|
|
824
|
-
outputSchema: artifactListOutputSchema,
|
|
825
|
-
annotations: readOnly,
|
|
826
|
-
}, async ({ workspaceId, limit, cursor }, extra) => {
|
|
827
|
-
try {
|
|
828
|
-
const progress = progressReporter(extra);
|
|
829
|
-
progress.signal.throwIfAborted();
|
|
830
|
-
const workspace = engine.resolver.get(workspaceId, context.principal);
|
|
831
|
-
const decoded = cursor === undefined ? undefined : decodeArtifactCursor(cursor);
|
|
832
|
-
const listing = await engine.artifacts.listPage(workspace, {
|
|
833
|
-
limit,
|
|
834
|
-
...(decoded === undefined ? {} : { afterUri: decoded.after }),
|
|
835
|
-
}, progress.signal);
|
|
836
|
-
progress.signal.throwIfAborted();
|
|
837
|
-
if (decoded !== undefined &&
|
|
838
|
-
(decoded.revision !== listing.revision || !listing.afterFound)) {
|
|
839
|
-
throw new ServiceError('ARTIFACT_CURSOR_STALE', 'Artifact inventory changed; restart pagination without a cursor');
|
|
840
|
-
}
|
|
841
|
-
const last = listing.artifacts.at(-1);
|
|
842
|
-
const nextCursor = listing.hasMore && last !== undefined
|
|
843
|
-
? encodeArtifactCursor(listing.revision, last.uri)
|
|
844
|
-
: undefined;
|
|
845
|
-
const result = emptyServiceResult(workspaceId, {
|
|
846
|
-
count: listing.total,
|
|
847
|
-
returned: listing.artifacts.length,
|
|
848
|
-
...(nextCursor === undefined ? {} : { nextCursor }),
|
|
849
|
-
});
|
|
850
|
-
result.code = 'ARTIFACT_LIST';
|
|
851
|
-
result.artifacts = listing.artifacts;
|
|
852
|
-
return toolResult(result);
|
|
853
|
-
}
|
|
854
|
-
catch (error) {
|
|
855
|
-
return errorResult(error, workspaceId);
|
|
856
|
-
}
|
|
857
|
-
});
|
|
858
|
-
server.registerTool('hoi4.artifact_describe', {
|
|
859
|
-
title: 'Describe workspace artifact',
|
|
860
|
-
description: 'Return artifact integrity and provenance metadata for an authorized workspace.',
|
|
861
|
-
inputSchema: workspaceInput.extend({ uri: z.url().max(4096) }).strict(),
|
|
862
|
-
outputSchema: artifactDescribeOutputSchema,
|
|
863
|
-
annotations: readOnly,
|
|
864
|
-
}, async ({ workspaceId, uri }, extra) => {
|
|
865
|
-
try {
|
|
866
|
-
const progress = progressReporter(extra);
|
|
867
|
-
progress.signal.throwIfAborted();
|
|
868
|
-
const workspace = engine.resolver.get(workspaceId, context.principal);
|
|
869
|
-
const artifact = await engine.artifacts.describe(workspace, uri, progress.signal);
|
|
870
|
-
progress.signal.throwIfAborted();
|
|
871
|
-
const sourceHashes = Object.entries(artifact.provenance.sourceHashes).sort(([left], [right]) => compareCodeUnits(left, right));
|
|
872
|
-
const description = {
|
|
873
|
-
uri: artifact.uri,
|
|
874
|
-
name: artifact.name,
|
|
875
|
-
mimeType: artifact.mimeType,
|
|
876
|
-
size: artifact.size,
|
|
877
|
-
sha256: artifact.sha256,
|
|
878
|
-
provenanceHash: artifact.provenanceHash,
|
|
879
|
-
...(artifact.description === undefined
|
|
880
|
-
? {}
|
|
881
|
-
: { description: artifact.description.slice(0, 1_024) }),
|
|
882
|
-
descriptionTruncated: (artifact.description?.length ?? 0) > 1_024,
|
|
883
|
-
provenance: {
|
|
884
|
-
kind: artifact.provenance.kind,
|
|
885
|
-
toolVersion: artifact.provenance.toolVersion,
|
|
886
|
-
schemaVersion: artifact.provenance.schemaVersion,
|
|
887
|
-
sourceHashCount: sourceHashes.length,
|
|
888
|
-
sourceHashes: sourceHashes.slice(0, 100).map(([path, sha256]) => ({ path, sha256 })),
|
|
889
|
-
sourceHashesTruncated: sourceHashes.length > 100,
|
|
890
|
-
hasRenderProfile: artifact.provenance.renderProfile !== undefined,
|
|
891
|
-
hasMetadata: artifact.provenance.metadata !== undefined,
|
|
892
|
-
},
|
|
893
|
-
};
|
|
894
|
-
const manifestUri = new URL(artifact.uri);
|
|
895
|
-
manifestUri.searchParams.set('metadata', 'manifest');
|
|
896
|
-
const result = emptyServiceResult(workspaceId, { artifact: description });
|
|
897
|
-
result.code = 'ARTIFACT_DESCRIBE';
|
|
898
|
-
result.artifacts = [
|
|
899
|
-
publicArtifactLink(artifact),
|
|
900
|
-
{
|
|
901
|
-
uri: manifestUri.href,
|
|
902
|
-
name: `${artifact.name}.manifest.json`,
|
|
903
|
-
mimeType: 'application/json',
|
|
904
|
-
description: 'Complete public provenance manifest for this artifact',
|
|
905
|
-
},
|
|
906
|
-
];
|
|
907
|
-
return toolResult(result);
|
|
908
|
-
}
|
|
909
|
-
catch (error) {
|
|
910
|
-
return errorResult(error, workspaceId);
|
|
911
|
-
}
|
|
912
|
-
});
|
|
913
|
-
}
|
|
914
|
-
//# sourceMappingURL=base-tools.js.map
|