@seriousgaming/sdk-tools 0.0.0-stage → 1.0.0-alpha.1
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/LICENSE +93 -0
- package/README.md +36 -2
- package/dist/bundling/logic-exports.d.ts +34 -0
- package/dist/bundling/node-builtins.d.ts +21 -0
- package/dist/bundling/transpiler.d.ts +7 -0
- package/dist/cli.js +27368 -0
- package/dist/client/dev-server.d.ts +59 -0
- package/dist/client/index.d.ts +28 -0
- package/dist/client/stub-services.d.ts +32 -0
- package/dist/client/test-session.d.ts +195 -0
- package/dist/client.js +16884 -0
- package/dist/core/asset-reference-translator.d.ts +46 -0
- package/dist/core/clock.d.ts +57 -0
- package/dist/core/faults.d.ts +65 -0
- package/dist/core/game-settings.d.ts +65 -0
- package/dist/core/history.d.ts +89 -0
- package/dist/core/listen-with-fallback.d.ts +30 -0
- package/dist/core/mutation-queue.d.ts +61 -0
- package/dist/core/package-scenario.d.ts +89 -0
- package/dist/core/participant-registry.d.ts +109 -0
- package/dist/core/pending-changes.d.ts +14 -0
- package/dist/core/protocol.d.ts +83 -0
- package/dist/core/scenario-drafts.d.ts +32 -0
- package/dist/core/session-endpoints.d.ts +108 -0
- package/dist/core/session-gates.d.ts +75 -0
- package/dist/core/session-host.d.ts +94 -0
- package/dist/core/session-refusals.d.ts +56 -0
- package/dist/core/session-rewind.d.ts +32 -0
- package/dist/core/session-roster.d.ts +128 -0
- package/dist/core/session-surfaces.d.ts +32 -0
- package/dist/core/session-ticks.d.ts +18 -0
- package/dist/core/session-timers.d.ts +84 -0
- package/dist/core/session-writes.d.ts +40 -0
- package/dist/core/session.d.ts +385 -0
- package/dist/core/settings-locks.d.ts +22 -0
- package/dist/core/team-names.d.ts +52 -0
- package/dist/core/team-state-store.d.ts +209 -0
- package/dist/core/tick-timer.d.ts +75 -0
- package/dist/dev/blob-links.d.ts +10 -0
- package/dist/dev/console/assets/index-DgFglsnA.js +204 -0
- package/dist/dev/console/index.html +12 -0
- package/dist/dev/console-path.d.ts +19 -0
- package/dist/dev/lockfile.d.ts +124 -0
- package/dist/dev/package-watcher.d.ts +21 -0
- package/dist/dev/routes.d.ts +67 -0
- package/dist/dev/shell.d.ts +260 -0
- package/dist/dev/surfaces.d.ts +41 -0
- package/dist/dev/tools-identity.d.ts +23 -0
- package/dist/dev/view/batch.d.ts +172 -0
- package/dist/dev/view/commands.d.ts +75 -0
- package/dist/dev/view/route.d.ts +58 -0
- package/dist/dev/view/view.d.ts +78 -0
- package/dist/dev/view/viewer.d.ts +32 -0
- package/dist/discovery/config.d.ts +9 -0
- package/dist/discovery/manifest-paths.d.ts +21 -0
- package/dist/discovery/removed-fields.d.ts +90 -0
- package/dist/docs/api/deck.md +386 -0
- package/dist/docs/api/index.md +67 -0
- package/dist/docs/api/sdk-commands.md +286 -0
- package/dist/docs/api/sdk-e2e.md +433 -0
- package/dist/docs/api/sdk-projection.md +207 -0
- package/dist/docs/api/sdk-testing.md +214 -0
- package/dist/docs/api/sdk-tools-client.md +560 -0
- package/dist/docs/api/sdk-ui-testing.md +231 -0
- package/dist/docs/api/sdk-ui.md +1269 -0
- package/dist/docs/api/sdk.md +2140 -0
- package/dist/docs/changelog-0.x.md +1156 -0
- package/dist/docs/changelog.md +236 -0
- package/dist/docs/cli-and-dev-server.md +217 -0
- package/dist/docs/cli-error-codes.md +154 -0
- package/dist/docs/cli-reference.md +2488 -0
- package/dist/docs/cli-simulation-testing.md +222 -0
- package/dist/docs/concepts/index.md +46 -0
- package/dist/docs/concepts/terminology.md +322 -0
- package/dist/docs/environment-variables.md +102 -0
- package/dist/docs/getting-started.md +145 -0
- package/dist/docs/guides/ai-facilitation.md +220 -0
- package/dist/docs/guides/capabilities.md +460 -0
- package/dist/docs/guides/endpoints.md +335 -0
- package/dist/docs/guides/engine-testing.md +477 -0
- package/dist/docs/guides/engine.md +527 -0
- package/dist/docs/guides/file-handling.md +405 -0
- package/dist/docs/guides/games.md +176 -0
- package/dist/docs/guides/global-settings.md +94 -0
- package/dist/docs/guides/guide.md +123 -0
- package/dist/docs/guides/hooks.md +183 -0
- package/dist/docs/guides/index.md +51 -0
- package/dist/docs/guides/internationalization.md +288 -0
- package/dist/docs/guides/llm-integration.md +635 -0
- package/dist/docs/guides/multi-team-games.md +586 -0
- package/dist/docs/guides/patterns.md +391 -0
- package/dist/docs/guides/presentation.md +196 -0
- package/dist/docs/guides/production-constraints.md +130 -0
- package/dist/docs/guides/scenario-editor.md +143 -0
- package/dist/docs/guides/scenarios.md +515 -0
- package/dist/docs/guides/session.md +972 -0
- package/dist/docs/guides/settings.md +458 -0
- package/dist/docs/guides/setup.md +193 -0
- package/dist/docs/guides/speech-generation.md +233 -0
- package/dist/docs/guides/starter-game.md +164 -0
- package/dist/docs/guides/testing.md +575 -0
- package/dist/docs/guides/tick-controller.md +569 -0
- package/dist/docs/guides/type-safety.md +516 -0
- package/dist/docs/guides/ui.md +1389 -0
- package/dist/docs/guides/upgrading.md +636 -0
- package/dist/docs/guides/validators.md +217 -0
- package/dist/docs/guides/waiting-room.md +244 -0
- package/dist/docs/index.md +41 -0
- package/dist/docs/recipes/act-on-the-session-from-an-endpoint.md +95 -0
- package/dist/docs/recipes/adapt-a-game-for-walkthroughs.md +133 -0
- package/dist/docs/recipes/adapt-ui-for-observers.md +74 -0
- package/dist/docs/recipes/call-endpoint-from-ui.md +109 -0
- package/dist/docs/recipes/check-a-package-from-a-script.md +117 -0
- package/dist/docs/recipes/create-capability.md +66 -0
- package/dist/docs/recipes/create-endpoint.md +127 -0
- package/dist/docs/recipes/create-engine.md +111 -0
- package/dist/docs/recipes/create-game.md +70 -0
- package/dist/docs/recipes/create-guide.md +75 -0
- package/dist/docs/recipes/create-hook.md +80 -0
- package/dist/docs/recipes/create-presentation.md +142 -0
- package/dist/docs/recipes/create-scenario-editor.md +102 -0
- package/dist/docs/recipes/create-scenario.md +98 -0
- package/dist/docs/recipes/create-session-ui.md +116 -0
- package/dist/docs/recipes/create-settings.md +88 -0
- package/dist/docs/recipes/create-setup.md +115 -0
- package/dist/docs/recipes/create-tick-controller.md +65 -0
- package/dist/docs/recipes/create-user-interface.md +96 -0
- package/dist/docs/recipes/create-validator.md +67 -0
- package/dist/docs/recipes/create-waiting-room-ui.md +109 -0
- package/dist/docs/recipes/declare-api-uses.md +67 -0
- package/dist/docs/recipes/design-state-for-concurrent-writes.md +96 -0
- package/dist/docs/recipes/distribute-package.md +80 -0
- package/dist/docs/recipes/e2e-testing.md +116 -0
- package/dist/docs/recipes/end-game-on-condition.md +154 -0
- package/dist/docs/recipes/fix-duplicate-packages.md +101 -0
- package/dist/docs/recipes/index.md +86 -0
- package/dist/docs/recipes/make-an-endpoint-external.md +101 -0
- package/dist/docs/recipes/negotiate-across-teams.md +164 -0
- package/dist/docs/recipes/observe-other-teams-state.md +119 -0
- package/dist/docs/recipes/publish-a-package.md +139 -0
- package/dist/docs/recipes/remember-a-viewers-choice.md +55 -0
- package/dist/docs/recipes/review-a-past-day.md +73 -0
- package/dist/docs/recipes/share-assets-across-scenarios.md +120 -0
- package/dist/docs/recipes/share-logic-between-engine-and-ui.md +130 -0
- package/dist/docs/recipes/show-all-teams-participants.md +109 -0
- package/dist/docs/recipes/start-from-an-empty-package.md +169 -0
- package/dist/docs/recipes/take-a-file-in-an-endpoint.md +82 -0
- package/dist/docs/recipes/test-a-multi-role-game.md +51 -0
- package/dist/docs/recipes/test-user-interface.md +95 -0
- package/dist/docs/recipes/test-with-engine.md +115 -0
- package/dist/docs/recipes/upload-and-display-files.md +148 -0
- package/dist/docs/recipes/use-request-play.md +65 -0
- package/dist/docs/recipes/use-request-tick.md +75 -0
- package/dist/docs/troubleshooting.md +816 -0
- package/dist/execution/blob-inputs.d.ts +57 -0
- package/dist/execution/bundle-reload.d.ts +42 -0
- package/dist/execution/config-resolver.d.ts +127 -0
- package/dist/execution/configuration-builder.d.ts +66 -0
- package/dist/execution/context-composition.d.ts +161 -0
- package/dist/execution/endpoint-actions.d.ts +9 -0
- package/dist/execution/endpoint-payloads.d.ts +32 -0
- package/dist/execution/endpoint-runner.d.ts +129 -0
- package/dist/execution/engine-state.d.ts +40 -0
- package/dist/execution/executor-callbacks.d.ts +56 -0
- package/dist/execution/executor.d.ts +436 -0
- package/dist/execution/gates.d.ts +45 -0
- package/dist/execution/hook-chain.d.ts +25 -0
- package/dist/execution/logic-calls.d.ts +190 -0
- package/dist/execution/logic-failure.d.ts +84 -0
- package/dist/execution/logic-loader.d.ts +54 -0
- package/dist/execution/logic-result.d.ts +76 -0
- package/dist/execution/tick-controller-call.d.ts +32 -0
- package/dist/execution/types.d.ts +48 -0
- package/dist/generation/ts-type.d.ts +39 -0
- package/dist/guide/locale.d.ts +12 -0
- package/dist/guide/video-registry.d.ts +42 -0
- package/dist/help-examples.d.ts +125 -0
- package/dist/host/adapter.d.ts +67 -0
- package/dist/host/host-channel.d.ts +222 -0
- package/dist/host/index.d.ts +20 -0
- package/dist/host/protocol.d.ts +783 -0
- package/dist/host/surfaces.d.ts +42 -0
- package/dist/host/theme.d.ts +55 -0
- package/dist/host.js +583 -0
- package/dist/prompts/index.d.ts +7 -0
- package/dist/prompts/schema-builder.d.ts +29 -0
- package/dist/prompts/types.d.ts +108 -0
- package/dist/prompts/validators.d.ts +32 -0
- package/dist/runtime/capability-scope.d.ts +6 -0
- package/dist/runtime/context-merge.d.ts +29 -0
- package/dist/runtime/context-projection.d.ts +41 -0
- package/dist/runtime/guarded-callbacks.d.ts +15 -0
- package/dist/runtime/index.d.ts +27 -0
- package/dist/runtime/manifest-version.d.ts +55 -0
- package/dist/runtime/tick-validation.d.ts +25 -0
- package/dist/runtime.js +346 -0
- package/dist/schema.json +1546 -0
- package/dist/server/vite-plugin.d.ts +46 -0
- package/dist/services/tts/client.d.ts +51 -0
- package/dist/services/tts/elevenlabs.d.ts +24 -0
- package/dist/services/tts/types.d.ts +44 -0
- package/dist/storage/asset-resolver.d.ts +49 -0
- package/dist/storage/blob-store.d.ts +41 -0
- package/dist/templates/endpoint/logic.test.ts.liquid +61 -0
- package/dist/templates/endpoint/logic.ts.liquid +25 -0
- package/dist/templates/engine/init.json.liquid +7 -0
- package/dist/templates/engine/logic-aggregate.test.ts.liquid +90 -0
- package/dist/templates/engine/logic-aggregate.ts.liquid +46 -0
- package/dist/templates/engine/logic.test.ts.liquid +61 -0
- package/dist/templates/engine/logic.ts.liquid +32 -0
- package/dist/templates/engine/run.json.liquid +7 -0
- package/dist/templates/guide/01-at-a-glance.md.liquid +19 -0
- package/dist/templates/guide/02-preparation.md.liquid +18 -0
- package/dist/templates/guide/03-running-the-session.md.liquid +37 -0
- package/dist/templates/hook/logic.test.ts.liquid +46 -0
- package/dist/templates/hook/logic.ts.liquid +12 -0
- package/dist/templates/package/CLAUDE.md.template +338 -0
- package/dist/templates/package/DESIGN.md.liquid +144 -0
- package/dist/templates/package/README.md.liquid +143 -0
- package/dist/templates/package/claude/rules/workflow-create-capability.md +26 -0
- package/dist/templates/package/claude/rules/workflow-create-endpoint.md +35 -0
- package/dist/templates/package/claude/rules/workflow-create-engine.md +35 -0
- package/dist/templates/package/claude/rules/workflow-create-guide.md +40 -0
- package/dist/templates/package/claude/rules/workflow-create-presentation.md +37 -0
- package/dist/templates/package/claude/rules/workflow-create-user-interface.md +31 -0
- package/dist/templates/package/claude/rules/workflow-publish-package.md +54 -0
- package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +30 -0
- package/dist/templates/package/claude/rules/workflow-update-sdk-version.md +43 -0
- package/dist/templates/package/claude/settings.json.template +16 -0
- package/dist/templates/package/gitignore.template +15 -0
- package/dist/templates/package/global-setup.ts.template +21 -0
- package/dist/templates/package/globals.d.ts.template +2 -0
- package/dist/templates/package/oxfmtrc.json.template +14 -0
- package/dist/templates/package/oxlintrc.json.template +238 -0
- package/dist/templates/package/package.json.liquid +65 -0
- package/dist/templates/package/playwright.config.ts.liquid +19 -0
- package/dist/templates/package/pnpm-workspace.yaml.template +27 -0
- package/dist/templates/package/test-setup.ts.liquid +7 -0
- package/dist/templates/package/tsconfig.json.liquid +15 -0
- package/dist/templates/package/vite.config.ts.liquid +19 -0
- package/dist/templates/package/vitest.config.ts.liquid +25 -0
- package/dist/templates/package/vitest.engine.config.ts.liquid +12 -0
- package/dist/templates/presentation/index.html.liquid +20 -0
- package/dist/templates/presentation/src/App.tsx.liquid +49 -0
- package/dist/templates/presentation/src/Slides.tsx.liquid +81 -0
- package/dist/templates/presentation/src/i18n.ts.liquid +54 -0
- package/dist/templates/presentation/src/main.tsx.liquid +14 -0
- package/dist/templates/scenario_editor/src/App.test.tsx.liquid +30 -0
- package/dist/templates/scenario_editor/src/App.tsx.liquid +95 -0
- package/dist/templates/scenario_editor/src/i18n.ts.liquid +44 -0
- package/dist/templates/session/src/App.test.tsx.liquid +60 -0
- package/dist/templates/session/src/App.tsx.liquid +128 -0
- package/dist/templates/session/src/i18n.ts.liquid +53 -0
- package/dist/templates/session/src/main.tsx.liquid +48 -0
- package/dist/templates/session/src/theme.ts.liquid +46 -0
- package/dist/templates/settings-editor/index.html.liquid +12 -0
- package/dist/templates/settings-editor/src/main.tsx.liquid +48 -0
- package/dist/templates/settings-editor/src/theme.ts.liquid +24 -0
- package/dist/templates/setup/src/App.test.tsx.liquid +39 -0
- package/dist/templates/setup/src/App.tsx.liquid +102 -0
- package/dist/templates/setup/src/i18n.ts.liquid +47 -0
- package/dist/templates/starter-game/capabilities/briefing/capability.sdk.json +18 -0
- package/dist/templates/starter-game/capabilities/plan/capability.sdk.json +17 -0
- package/dist/templates/starter-game/capabilities/results/capability.sdk.json +61 -0
- package/dist/templates/starter-game/capabilities/roles/capability.sdk.json +17 -0
- package/dist/templates/starter-game/capabilities/weather/capability.sdk.json +23 -0
- package/dist/templates/starter-game/engine/defaults.ts +81 -0
- package/dist/templates/starter-game/engine/engine.sdk.json +12 -0
- package/dist/templates/starter-game/engine/logic.test.ts +221 -0
- package/dist/templates/starter-game/engine/logic.ts +149 -0
- package/dist/templates/starter-game/engine/test-helpers.ts +74 -0
- package/dist/templates/starter-game/engine/types.ts +139 -0
- package/dist/templates/starter-game/guide/content/en/01-at-a-glance.md +51 -0
- package/dist/templates/starter-game/guide/content/en/02-preparation.md +35 -0
- package/dist/templates/starter-game/guide/content/en/03-running-the-day.md +58 -0
- package/dist/templates/starter-game/guide/guide.sdk.json +10 -0
- package/dist/templates/starter-game/guide/guide.test.ts +108 -0
- package/dist/templates/starter-game/hooks/assignproducts/defaults.ts +37 -0
- package/dist/templates/starter-game/hooks/assignproducts/hook.sdk.json +13 -0
- package/dist/templates/starter-game/hooks/assignproducts/logic/logic.test.ts +77 -0
- package/dist/templates/starter-game/hooks/assignproducts/logic/logic.ts +47 -0
- package/dist/templates/starter-game/hooks/assignproducts/types.ts +55 -0
- package/dist/templates/starter-game/package.json +68 -0
- package/dist/templates/starter-game/playwright.config.ts +19 -0
- package/dist/templates/starter-game/scenarios/heatwave/scenario.sdk.json +20 -0
- package/dist/templates/starter-game/scenarios/ordinary_week/scenario.sdk.json +12 -0
- package/dist/templates/starter-game/seriousgaming.sdk.json +23 -0
- package/dist/templates/starter-game/session/defaults.ts +80 -0
- package/dist/templates/starter-game/session/index.html +12 -0
- package/dist/templates/starter-game/session/session.sdk.json +11 -0
- package/dist/templates/starter-game/session/src/App.test.tsx +307 -0
- package/dist/templates/starter-game/session/src/App.tsx +309 -0
- package/dist/templates/starter-game/session/src/Section.tsx +37 -0
- package/dist/templates/starter-game/session/src/TeamDoor.tsx +96 -0
- package/dist/templates/starter-game/session/src/format.ts +8 -0
- package/dist/templates/starter-game/session/src/i18n.ts +51 -0
- package/dist/templates/starter-game/session/src/main.tsx +48 -0
- package/dist/templates/starter-game/session/src/theme.ts +45 -0
- package/dist/templates/starter-game/session/types.ts +135 -0
- package/dist/templates/starter-game/settings/engine/settings.sdk.json +50 -0
- package/dist/templates/starter-game/settings/menu/settings.sdk.json +78 -0
- package/dist/templates/starter-game/settings/session/settings.sdk.json +23 -0
- package/dist/templates/starter-game/settings/ui/settings.sdk.json +25 -0
- package/dist/templates/starter-game/test-setup.ts +7 -0
- package/dist/templates/starter-game/testing/e2e/game.spec.ts +139 -0
- package/dist/templates/starter-game/testing/e2e/global-setup.ts +21 -0
- package/dist/templates/starter-game/testing/engine/game.engine.test.ts +171 -0
- package/dist/templates/starter-game/tsconfig.json +19 -0
- package/dist/templates/starter-game/ui/defaults.ts +60 -0
- package/dist/templates/starter-game/ui/index.html +12 -0
- package/dist/templates/starter-game/ui/src/App.test.tsx +138 -0
- package/dist/templates/starter-game/ui/src/App.tsx +175 -0
- package/dist/templates/starter-game/ui/src/DayBar.test.tsx +78 -0
- package/dist/templates/starter-game/ui/src/DayBar.tsx +72 -0
- package/dist/templates/starter-game/ui/src/HistoryPanel.test.tsx +74 -0
- package/dist/templates/starter-game/ui/src/HistoryPanel.tsx +120 -0
- package/dist/templates/starter-game/ui/src/MakeRow.tsx +129 -0
- package/dist/templates/starter-game/ui/src/Section.tsx +37 -0
- package/dist/templates/starter-game/ui/src/ThemeToggle.tsx +49 -0
- package/dist/templates/starter-game/ui/src/TodayPanel.test.tsx +179 -0
- package/dist/templates/starter-game/ui/src/TodayPanel.tsx +92 -0
- package/dist/templates/starter-game/ui/src/YesterdayPanel.tsx +142 -0
- package/dist/templates/starter-game/ui/src/format.ts +12 -0
- package/dist/templates/starter-game/ui/src/i18n.ts +95 -0
- package/dist/templates/starter-game/ui/src/main.tsx +48 -0
- package/dist/templates/starter-game/ui/src/menu.ts +18 -0
- package/dist/templates/starter-game/ui/src/test-helpers.ts +58 -0
- package/dist/templates/starter-game/ui/src/theme.ts +45 -0
- package/dist/templates/starter-game/ui/src/writes.ts +43 -0
- package/dist/templates/starter-game/ui/types.ts +137 -0
- package/dist/templates/starter-game/ui/ui.sdk.json +11 -0
- package/dist/templates/starter-game/validators/capacity/defaults.ts +37 -0
- package/dist/templates/starter-game/validators/capacity/logic/logic.test.ts +96 -0
- package/dist/templates/starter-game/validators/capacity/logic/logic.ts +45 -0
- package/dist/templates/starter-game/validators/capacity/types.ts +55 -0
- package/dist/templates/starter-game/validators/capacity/validator.sdk.json +11 -0
- package/dist/templates/starter-game/vite.config.ts +19 -0
- package/dist/templates/starter-game/vitest.config.ts +15 -0
- package/dist/templates/starter-game/vitest.engine.config.ts +19 -0
- package/dist/templates/starter-game/waiting_room/defaults.ts +40 -0
- package/dist/templates/starter-game/waiting_room/index.html +12 -0
- package/dist/templates/starter-game/waiting_room/src/App.test.tsx +102 -0
- package/dist/templates/starter-game/waiting_room/src/App.tsx +194 -0
- package/dist/templates/starter-game/waiting_room/src/i18n.ts +33 -0
- package/dist/templates/starter-game/waiting_room/src/main.tsx +48 -0
- package/dist/templates/starter-game/waiting_room/src/theme.ts +45 -0
- package/dist/templates/starter-game/waiting_room/types.ts +59 -0
- package/dist/templates/starter-game/waiting_room/waiting_room.sdk.json +10 -0
- package/dist/templates/tick-controller/logic.ts.liquid +8 -0
- package/dist/templates/ui/index.html.liquid +12 -0
- package/dist/templates/ui/src/App.test.tsx.liquid +41 -0
- package/dist/templates/ui/src/App.tsx.liquid +103 -0
- package/dist/templates/ui/src/i18n.ts.liquid +47 -0
- package/dist/templates/ui/src/main.tsx.liquid +48 -0
- package/dist/templates/ui/src/theme.ts.liquid +46 -0
- package/dist/templates/validator/logic.test.ts.liquid +42 -0
- package/dist/templates/validator/logic.ts.liquid +21 -0
- package/dist/templates/waiting-room/index.html.liquid +12 -0
- package/dist/templates/waiting-room/src/App.test.tsx.liquid +57 -0
- package/dist/templates/waiting-room/src/App.tsx.liquid +118 -0
- package/dist/templates/waiting-room/src/i18n.ts.liquid +44 -0
- package/dist/templates/waiting-room/src/main.tsx.liquid +48 -0
- package/dist/templates/waiting-room/src/theme.ts.liquid +46 -0
- package/dist/templating/resource-metadata.d.ts +131 -0
- package/dist/types.d.ts +14 -0
- package/dist/utils/atomic-write.d.ts +40 -0
- package/dist/utils/cli-error.d.ts +64 -0
- package/dist/utils/document-parser-client.d.ts +20 -0
- package/dist/utils/env-loader.d.ts +40 -0
- package/dist/utils/error-codes.d.ts +335 -0
- package/dist/utils/errors.d.ts +19 -0
- package/dist/utils/global-settings.d.ts +65 -0
- package/dist/utils/llm-client.d.ts +34 -0
- package/dist/utils/logger.d.ts +36 -0
- package/dist/utils/output.d.ts +109 -0
- package/dist/utils/platform.d.ts +14 -0
- package/dist/utils/prompt.d.ts +36 -0
- package/dist/utils/real-path.d.ts +6 -0
- package/dist/utils/schema-properties.d.ts +35 -0
- package/dist/validation/ajv.d.ts +17 -0
- package/dist/validation/facilitator-guide-validator.d.ts +27 -0
- package/dist/validation/findings.d.ts +40 -0
- package/dist/validation/game-constraints.d.ts +10 -0
- package/dist/validation/game-validator.d.ts +34 -0
- package/dist/validation/package-validation.d.ts +41 -0
- package/dist/validation/package-validator.d.ts +19 -0
- package/dist/validation/resource-validator.d.ts +79 -0
- package/dist/validation/schema-defaults-validator.d.ts +29 -0
- package/dist/validation/schema-validation.d.ts +115 -0
- package/dist/validation/semver.d.ts +9 -0
- package/package.json +122 -3
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every call into author logic shares, whichever resource it runs.
|
|
3
|
+
*
|
|
4
|
+
* An engine, a tick controller, a hook, a validator and an endpoint are each
|
|
5
|
+
* handed the same five things beside their own arguments: a `meta` read from
|
|
6
|
+
* one session-wide source (§10.2, §5.7), the roster as the host holds it, the
|
|
7
|
+
* callbacks their `uses` allow, a bound on how long the runtime waits for
|
|
8
|
+
* them (§11.10, §15.4), and a mark on whatever they throw saying where it came
|
|
9
|
+
* from (#639). Kept apart from the executor so that each runner built on it
|
|
10
|
+
* gets them from one place, rather than five call sites each assembling their
|
|
11
|
+
* own copy and drifting.
|
|
12
|
+
*/
|
|
13
|
+
import type { ApiUse, ResolvedPackageManifest, LogicMeta, Participant, RunKind, RunMeta, SignatureCallbacks } from '@seriousgaming/sdk';
|
|
14
|
+
import { type ExecutorCallbacksDeps } from './executor-callbacks';
|
|
15
|
+
import { type LogicOrigin, type SourceMapRegistry } from './logic-failure';
|
|
16
|
+
import type { LogicKind, LogicResource } from './logic-loader';
|
|
17
|
+
import type { ExecutorDependencies } from './types';
|
|
18
|
+
/**
|
|
19
|
+
* Default bound on one call into author logic (§15.4, §14.4, §6.12).
|
|
20
|
+
*
|
|
21
|
+
* §11.10 bounds the tick; nothing bounded a validator, a hook chain or an
|
|
22
|
+
* endpoint, each of which runs author code on a path something is waiting on.
|
|
23
|
+
* A hung hook is the worst of the three: dispatches are serialised per team
|
|
24
|
+
* (§14.4), so one that never returns blocks every later signal for that team
|
|
25
|
+
* for the life of the session.
|
|
26
|
+
*
|
|
27
|
+
* Deployment-defined, per the spec; this is the authoring default.
|
|
28
|
+
*/
|
|
29
|
+
export declare const DEFAULT_LOGIC_EXECUTION_BOUND_MS = 30000;
|
|
30
|
+
export declare const DEFAULT_TICK_EXECUTION_BOUND_MS = 120000;
|
|
31
|
+
/**
|
|
32
|
+
* What a runner of one kind of resource needs from the executor that owns it:
|
|
33
|
+
* the package as loaded, its compiled logic, each resource's settings, and the
|
|
34
|
+
* calls every one of them shares.
|
|
35
|
+
*/
|
|
36
|
+
export interface LogicHost {
|
|
37
|
+
readonly calls: LogicCalls;
|
|
38
|
+
/** The loaded package, or null before the executor has loaded one. */
|
|
39
|
+
config(): ResolvedPackageManifest | null;
|
|
40
|
+
/** Whether a game is loaded: a package with no game runs nothing. */
|
|
41
|
+
initialised(): boolean;
|
|
42
|
+
load<T>(kind: LogicKind, identifier: string, resource: LogicResource | undefined, notFoundMessage: string): Promise<T>;
|
|
43
|
+
settingsFor(declaration: {
|
|
44
|
+
settings?: string[];
|
|
45
|
+
}): Record<string, Record<string, unknown>>;
|
|
46
|
+
sharedCapabilityIds(): string[];
|
|
47
|
+
}
|
|
48
|
+
export interface LogicCallsOptions {
|
|
49
|
+
packagePath: string;
|
|
50
|
+
/** Where `meta.now` is read from: the host's clock, so a fake one controls it. */
|
|
51
|
+
clock: {
|
|
52
|
+
now(): number;
|
|
53
|
+
};
|
|
54
|
+
deps: Pick<ExecutorDependencies, 'logicExecutionBoundMs' | 'tickExecutionBoundMs'>;
|
|
55
|
+
/** The loaded bundles' source maps, to read a thrown stack back to source. */
|
|
56
|
+
sourceMaps: SourceMapRegistry;
|
|
57
|
+
/** What the raw callbacks are built from, less what this class supplies. */
|
|
58
|
+
callbacks: Omit<ExecutorCallbacksDeps, 'readPastState' | 'getScopedTeamIndexes' | 'getAllTeamIndexes' | 'takePlatformFailure'>;
|
|
59
|
+
}
|
|
60
|
+
export declare class LogicCalls {
|
|
61
|
+
private readonly options;
|
|
62
|
+
/** The session locale, surfaced as `meta.locale`. */
|
|
63
|
+
locale: string;
|
|
64
|
+
/**
|
|
65
|
+
* The session's random seed, surfaced to logic as `meta.seed`. Fixed rather
|
|
66
|
+
* than drawn so a CLI run is reproducible by default: a game that wants a
|
|
67
|
+
* different world each session gets one from the host calling `setSeed`,
|
|
68
|
+
* which the dev server does and persists.
|
|
69
|
+
*/
|
|
70
|
+
seed: string;
|
|
71
|
+
/**
|
|
72
|
+
* Which kind of run this executor is driving, surfaced to logic as
|
|
73
|
+
* `meta.runKind`. Host-owned like the seed and the locale: the executor
|
|
74
|
+
* carries it and changes no behaviour on it, because deciding what a
|
|
75
|
+
* walkthrough should look like is the game's business, not ours.
|
|
76
|
+
*/
|
|
77
|
+
runKind: RunKind;
|
|
78
|
+
/**
|
|
79
|
+
* When the operation in progress started, or null between operations.
|
|
80
|
+
* Held so every logic call in one operation reads the same `meta.now`
|
|
81
|
+
* (§10.2). Set by {@link inOperation}, which serial callers alone use:
|
|
82
|
+
* an endpoint runs beside the queue, so it is handed its instant instead.
|
|
83
|
+
*/
|
|
84
|
+
private operationStartedAt;
|
|
85
|
+
/** The session's participants, every team's, as the host holds them. */
|
|
86
|
+
private rosterSource;
|
|
87
|
+
/**
|
|
88
|
+
* Where `getPastState` reads from (§12.5). Supplied by the host after
|
|
89
|
+
* construction, because the history lives in the session's team store and
|
|
90
|
+
* that store is built around the executor.
|
|
91
|
+
*/
|
|
92
|
+
private pastStateReader;
|
|
93
|
+
private teamIndexesForHistory;
|
|
94
|
+
/** Team indexes the resource now running is scoped to; null is the session. */
|
|
95
|
+
private scopedTeamIndexes;
|
|
96
|
+
/** See {@link setPlatformFailures}. */
|
|
97
|
+
private platformFailures;
|
|
98
|
+
constructor(options: LogicCallsOptions);
|
|
99
|
+
/**
|
|
100
|
+
* Run `work` as one operation: every logic call inside it reads the same
|
|
101
|
+
* `meta.now`, taken from the clock as it starts (§10.2). Nested calls join
|
|
102
|
+
* the operation already running rather than starting their own, so a
|
|
103
|
+
* cohort tick that runs each independent team separately, and the tick
|
|
104
|
+
* controller evaluated after it, all read one instant.
|
|
105
|
+
*/
|
|
106
|
+
inOperation<T>(work: () => Promise<T>): Promise<T>;
|
|
107
|
+
/** The instant the current operation started, or now when there is none. */
|
|
108
|
+
operationNow(): number;
|
|
109
|
+
/** The clock's reading, outside any operation. */
|
|
110
|
+
now(): number;
|
|
111
|
+
/**
|
|
112
|
+
* The session-wide half of `meta`, which every logic call receives.
|
|
113
|
+
*
|
|
114
|
+
* One builder rather than a literal per call site: `runKind` has to read
|
|
115
|
+
* the same everywhere within a run (§5.7), and five hand-written copies is
|
|
116
|
+
* five chances for a surface to disagree with the engine beside it.
|
|
117
|
+
*/
|
|
118
|
+
sessionMeta(tick: number): RunMeta;
|
|
119
|
+
/**
|
|
120
|
+
* The `meta` given to logic that runs outside the tick loop: hooks,
|
|
121
|
+
* endpoints and validators. No `tick`, because none of them runs as
|
|
122
|
+
* part of a tick.
|
|
123
|
+
*/
|
|
124
|
+
meta(now?: number): LogicMeta;
|
|
125
|
+
/** See {@link GameExecutor.setRosterSource}. */
|
|
126
|
+
setRosterSource(source: () => Participant[]): void;
|
|
127
|
+
/** Every participant in the session, as the host holds them. */
|
|
128
|
+
roster(): Participant[];
|
|
129
|
+
/**
|
|
130
|
+
* The participants on `teamIds`, in team order and then join order, as a
|
|
131
|
+
* fresh copy: a call that changes its copy changes no other call's, and
|
|
132
|
+
* not the roster (§10.2).
|
|
133
|
+
*/
|
|
134
|
+
participantsOn(teamIds: readonly string[]): Participant[];
|
|
135
|
+
/** See {@link GameExecutor.setHistoryAccess}. */
|
|
136
|
+
setHistoryAccess(access: {
|
|
137
|
+
read: NonNullable<ExecutorCallbacksDeps['readPastState']>;
|
|
138
|
+
allTeamIndexes: () => number[];
|
|
139
|
+
}): void;
|
|
140
|
+
/** See {@link GameExecutor.setPlatformFailures}. */
|
|
141
|
+
setPlatformFailures(take: NonNullable<ExecutorCallbacksDeps['takePlatformFailure']>): void;
|
|
142
|
+
/**
|
|
143
|
+
* Run something with `getPastState`'s notion of 'own team' pinned to
|
|
144
|
+
* `indexes`, restoring whatever was in force afterwards.
|
|
145
|
+
*
|
|
146
|
+
* Per-team work nests inside session-wide work (a tick loops over teams),
|
|
147
|
+
* so this saves and restores rather than clearing: leaving it null after a
|
|
148
|
+
* team's turn would silently widen the next read to the whole session.
|
|
149
|
+
*/
|
|
150
|
+
withScopedTeams<T>(indexes: number[] | null, run: () => Promise<T>): Promise<T>;
|
|
151
|
+
/**
|
|
152
|
+
* The callbacks a resource receives: the raw runtime callbacks, built
|
|
153
|
+
* fresh so they read the live game, with every one its `uses` does not
|
|
154
|
+
* declare replaced by a throwing stub.
|
|
155
|
+
*/
|
|
156
|
+
callbacksFor(resourceIdentifier: string, uses: readonly ApiUse[] | undefined): SignatureCallbacks;
|
|
157
|
+
/**
|
|
158
|
+
* Bound one call into author logic that runs as part of a tick, or of the
|
|
159
|
+
* initialisation a tick starts from (§11.10).
|
|
160
|
+
*
|
|
161
|
+
* Each call is bounded rather than the tick as a whole, because a result
|
|
162
|
+
* arriving after the bound must go nowhere: a race over one call discards
|
|
163
|
+
* it, where a race over the whole tick would let the executor carry on and
|
|
164
|
+
* commit the late result. The bound is longer than the per-call one,
|
|
165
|
+
* because an engine may make several LLM calls in one run.
|
|
166
|
+
*/
|
|
167
|
+
tickBound<T>(what: string, run: () => Promise<T>, origin?: LogicOrigin): Promise<T>;
|
|
168
|
+
/**
|
|
169
|
+
* Bound one call into author logic.
|
|
170
|
+
*
|
|
171
|
+
* §11.10 bounds the tick. Nothing bounded a validator, a hook or an
|
|
172
|
+
* endpoint, and each sits on a path something is waiting on: a validator
|
|
173
|
+
* holds a participant's write, an endpoint holds a UI's promise, and a
|
|
174
|
+
* hook chain — serialised per team (§14.4) — holds every later signal for
|
|
175
|
+
* that team.
|
|
176
|
+
*
|
|
177
|
+
* **This bounds the wait, not the execution.** A promise race cannot
|
|
178
|
+
* interrupt a bare loop inside the logic realm; terminating that needs
|
|
179
|
+
* isolation the runtime may not have (§3.2). Failing the waiting path is
|
|
180
|
+
* the half that is always achievable, and it is the half that keeps the
|
|
181
|
+
* session moving.
|
|
182
|
+
*/
|
|
183
|
+
bound<T>(what: string, run: () => Promise<T>, boundMs?: number, origin?: LogicOrigin): Promise<T>;
|
|
184
|
+
/**
|
|
185
|
+
* Run a call into author logic, marking anything it throws with where it
|
|
186
|
+
* came from (#639): the resource, the tick and team when there are ones,
|
|
187
|
+
* and the source line the bundle's map reads the stack back to.
|
|
188
|
+
*/
|
|
189
|
+
private call;
|
|
190
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where game logic threw (#639).
|
|
3
|
+
*
|
|
4
|
+
* The dev server runs each logic bundle compiled from the author's TypeScript,
|
|
5
|
+
* so a stack names a line in the bundle, not in anything the author wrote. The
|
|
6
|
+
* loader keeps each bundle's source map, and a failure is read back through it
|
|
7
|
+
* to the file, line and column of the source, plus the tick and team it threw
|
|
8
|
+
* for. Runtime-internal: nothing here is part of the specification, and a
|
|
9
|
+
* surface is never shown it.
|
|
10
|
+
*/
|
|
11
|
+
import { LLM_NOT_CONFIGURED } from '../utils/llm-client';
|
|
12
|
+
/** One resource's logic, by type and identifier. */
|
|
13
|
+
export interface LogicOrigin {
|
|
14
|
+
resource: {
|
|
15
|
+
type: string;
|
|
16
|
+
identifier: string;
|
|
17
|
+
};
|
|
18
|
+
tick?: number;
|
|
19
|
+
team?: {
|
|
20
|
+
teamId: string;
|
|
21
|
+
index: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** What a session result carries about logic that threw. */
|
|
25
|
+
export interface LogicFailure extends LogicOrigin {
|
|
26
|
+
message: string;
|
|
27
|
+
/** The source file, relative to the package root, with forward slashes. */
|
|
28
|
+
file?: string;
|
|
29
|
+
/** 1-based. */
|
|
30
|
+
line?: number;
|
|
31
|
+
/** 1-based. */
|
|
32
|
+
column?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Set when what logic threw is the environment's failure rather than the
|
|
35
|
+
* game's, so the command reports it as one.
|
|
36
|
+
*/
|
|
37
|
+
errorCode?: typeof LLM_NOT_CONFIGURED;
|
|
38
|
+
}
|
|
39
|
+
/** A position in a source file. */
|
|
40
|
+
export interface SourceLocation {
|
|
41
|
+
file: string;
|
|
42
|
+
line: number;
|
|
43
|
+
column: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Mark `error` as thrown by game logic. A thrown value that is not an object
|
|
47
|
+
* cannot carry the mark, so it is wrapped in an Error first; the value to
|
|
48
|
+
* rethrow is returned either way.
|
|
49
|
+
*/
|
|
50
|
+
export declare function markLogicFailure(error: unknown, failure: LogicFailure): unknown;
|
|
51
|
+
/** The logic failure `error` was marked with, if it was thrown by game logic. */
|
|
52
|
+
export declare function logicFailureOf(error: unknown): LogicFailure | undefined;
|
|
53
|
+
/** Carry a mark from one error to the error that replaces it, such as a wrapper. */
|
|
54
|
+
export declare function carryLogicFailure<T>(from: unknown, to: T): T;
|
|
55
|
+
/** The logic failure a session result carries beside its outcome, if any. */
|
|
56
|
+
export declare function logicErrorOf(result: unknown): LogicFailure | undefined;
|
|
57
|
+
/** A thrown value's message, read structurally: logic throws from another realm. */
|
|
58
|
+
export declare function thrownMessage(error: unknown): string;
|
|
59
|
+
/**
|
|
60
|
+
* The source maps of the bundles the dev server has evaluated, keyed by the
|
|
61
|
+
* filename each was compiled under, which is what its stack frames name.
|
|
62
|
+
*/
|
|
63
|
+
export declare class SourceMapRegistry {
|
|
64
|
+
private readonly maps;
|
|
65
|
+
/**
|
|
66
|
+
* Remember the inline source map at the end of `code`, compiled under
|
|
67
|
+
* `filename`. Its sources are relative to the bundle's directory, which is
|
|
68
|
+
* the directory of the entrypoint (see `Transpile`).
|
|
69
|
+
*/
|
|
70
|
+
register(filename: string, code: string): void;
|
|
71
|
+
clear(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Where `error` was thrown in source: the first stack frame inside a
|
|
74
|
+
* registered bundle that maps to the author's own code, or failing that to
|
|
75
|
+
* anything (such as a bundled dependency). Undefined when no frame is in a
|
|
76
|
+
* bundle, or the error carries no stack.
|
|
77
|
+
*/
|
|
78
|
+
locate(error: unknown): SourceLocation | undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The failure for logic that threw `error`: its message, its origin, and the
|
|
82
|
+
* source location `maps` finds, relative to `packagePath`.
|
|
83
|
+
*/
|
|
84
|
+
export declare function describeLogicFailure(error: unknown, origin: LogicOrigin, maps: SourceMapRegistry, packagePath: string): LogicFailure;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LogicLoader - loads and caches the compiled logic bundles the executor runs.
|
|
3
|
+
*
|
|
4
|
+
* Every resource kind that carries logic (the engine, tick controllers, hooks,
|
|
5
|
+
* validators, endpoints) is transpiled once, evaluated in the shared bare-V8
|
|
6
|
+
* context, and cached by identifier. The executor owns *which* resource maps to
|
|
7
|
+
* an identifier; this class owns the caches, the transpile/evaluate step, and
|
|
8
|
+
* the sandbox context.
|
|
9
|
+
*/
|
|
10
|
+
import { SourceMapRegistry } from './logic-failure';
|
|
11
|
+
import type { ExecutorDependencies } from './types';
|
|
12
|
+
/** The resource kinds that carry loadable logic. Each has its own cache. */
|
|
13
|
+
export type LogicKind = 'engine' | 'tickController' | 'hook' | 'validator' | 'endpoint';
|
|
14
|
+
/** The subset of a resource bundle the loader needs to locate its logic. */
|
|
15
|
+
export interface LogicResource {
|
|
16
|
+
rootDirectory: string;
|
|
17
|
+
logic: {
|
|
18
|
+
directory: string;
|
|
19
|
+
entrypoint: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** The dependencies the loader needs: a transpiler and a file reader. */
|
|
23
|
+
export type LogicLoaderDeps = Pick<ExecutorDependencies, 'transpile' | 'fs'>;
|
|
24
|
+
export declare class LogicLoader {
|
|
25
|
+
private readonly packagePath;
|
|
26
|
+
private readonly deps;
|
|
27
|
+
private readonly caches;
|
|
28
|
+
private logicContext?;
|
|
29
|
+
/** Each evaluated bundle's source map, to read a thrown stack back to source. */
|
|
30
|
+
readonly sourceMaps: SourceMapRegistry;
|
|
31
|
+
constructor(packagePath: string, deps: LogicLoaderDeps);
|
|
32
|
+
/**
|
|
33
|
+
* Load the logic exports for `identifier` of the given `kind`, from cache
|
|
34
|
+
* when present. `resource` is the bundle whose logic to compile; a missing
|
|
35
|
+
* resource throws `notFoundMessage`.
|
|
36
|
+
*/
|
|
37
|
+
load<T>(kind: LogicKind, identifier: string, resource: LogicResource | undefined, notFoundMessage: string): Promise<T>;
|
|
38
|
+
/** Drop every cached bundle (used when configuration or code reloads). */
|
|
39
|
+
clearAll(): void;
|
|
40
|
+
/** Drop a single cached bundle so its next load re-transpiles it. */
|
|
41
|
+
invalidate(kind: LogicKind, identifier: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* The shared bare-V8 global scope every logic bundle is evaluated in.
|
|
44
|
+
*
|
|
45
|
+
* A fresh vm context exposes only the ECMAScript intrinsics — the
|
|
46
|
+
* environment the production runtime guarantees (SPECIFICATION.md §3.2).
|
|
47
|
+
* Host globals such as `structuredClone`, `fetch`, `setTimeout`,
|
|
48
|
+
* `TextEncoder`, and `process` are absent, so logic that reaches for one
|
|
49
|
+
* throws a `ReferenceError` here exactly as it would in production, instead
|
|
50
|
+
* of silently working against Node's globals and only failing on deploy.
|
|
51
|
+
* (`console` is provided by a shim the transpiler compiles into each bundle.)
|
|
52
|
+
*/
|
|
53
|
+
private getLogicContext;
|
|
54
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ContextDeletePath, TickControllerResult } from '@seriousgaming/sdk';
|
|
2
|
+
import type { GameContext } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Read the capabilities patch out of a logic result (`{ capabilities }`).
|
|
5
|
+
*
|
|
6
|
+
* A top-level key other than those in `allowed` fails the call. The one a game
|
|
7
|
+
* written for the flat shape returns is a capability identifier, so without
|
|
8
|
+
* this its writes would be discarded without a word; the message says how to
|
|
9
|
+
* wrap them instead.
|
|
10
|
+
*/
|
|
11
|
+
export declare function readCapabilities(label: string, result: unknown, allowed?: readonly string[]): GameContext;
|
|
12
|
+
/**
|
|
13
|
+
* Read the paths a logic result removes (`deletes`), beside its capabilities.
|
|
14
|
+
*
|
|
15
|
+
* Each path is a `ContextDeletePath`, as a UI's `deletes` is (§9.5): segments
|
|
16
|
+
* joined by `.`, or an array of segments where a key could contain one. An
|
|
17
|
+
* absent `deletes` removes nothing. Anything else fails the call, because a
|
|
18
|
+
* malformed delete that was skipped would leave the entry the author meant to
|
|
19
|
+
* remove in place without a word.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readDeletes(label: string, result: unknown): ContextDeletePath[];
|
|
22
|
+
/** A delete path as an author would read it in a message. */
|
|
23
|
+
export declare function describeDeletePath(path: ContextDeletePath): string;
|
|
24
|
+
/** The capability a delete path removes something from: its first segment. */
|
|
25
|
+
export declare function deleteHead(path: ContextDeletePath): string;
|
|
26
|
+
/**
|
|
27
|
+
* Hold a logic result's `deletes` to what the resource may change (§7.4,
|
|
28
|
+
* §10.5), before anything is applied.
|
|
29
|
+
*
|
|
30
|
+
* A delete is a write, so the capability at the head of every path must be in
|
|
31
|
+
* `writes`. The test is the declaration, not a change of value: unlike a
|
|
32
|
+
* returned capability, a delete is never an echo of what the resource was
|
|
33
|
+
* handed, so there is no spread idiom to tolerate, and a delete under a
|
|
34
|
+
* capability the resource only reads is a mistake even when the path happens
|
|
35
|
+
* not to resolve. `target` says whose board the deletes land on: per-team logic
|
|
36
|
+
* may not reach a shared capability (§7.5), and an aggregate's or a
|
|
37
|
+
* session-scoped endpoint's `shared` result may reach nothing else.
|
|
38
|
+
*/
|
|
39
|
+
export declare function assertDeletesDeclared(label: string, deletes: readonly ContextDeletePath[], declaration: {
|
|
40
|
+
reads?: readonly string[];
|
|
41
|
+
writes?: readonly string[];
|
|
42
|
+
}, shared: ReadonlySet<string>, target: 'team' | 'shared'): void;
|
|
43
|
+
/**
|
|
44
|
+
* An engine result: its capabilities patch, the paths it removes, and its
|
|
45
|
+
* `state` when it returned one. `state` is `undefined` when the result left it
|
|
46
|
+
* out, which keeps the previous state; `null` is a value like any other.
|
|
47
|
+
*/
|
|
48
|
+
export interface EngineResultRead {
|
|
49
|
+
capabilities: GameContext;
|
|
50
|
+
/** Paths removed after the capabilities fold (§7.4). */
|
|
51
|
+
deletes: ContextDeletePath[];
|
|
52
|
+
state: unknown;
|
|
53
|
+
/** Whether a tick's result reported the game complete (§11). */
|
|
54
|
+
complete: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Read an engine result (`{ capabilities, deletes?, state? }`, and `complete?` from a
|
|
58
|
+
* tick's `Run` or `RunAggregate`). `Init` closes no round, so it has nothing to
|
|
59
|
+
* complete and `complete` there is an unknown key like any other.
|
|
60
|
+
*/
|
|
61
|
+
export declare function readEngineResult(label: string, result: unknown, phase?: 'init' | 'tick'): EngineResultRead;
|
|
62
|
+
/**
|
|
63
|
+
* Read an aggregate result (`{ shared: { capabilities }, teams: [{ capabilities }] }`)
|
|
64
|
+
* into the shared patch and one patch per team.
|
|
65
|
+
*/
|
|
66
|
+
export declare function readAggregateResult(label: string, result: unknown, teamCount: number, phase?: 'init' | 'tick'): {
|
|
67
|
+
shared: EngineResultRead;
|
|
68
|
+
teams: EngineResultRead[];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Read a tick controller's result, whose shape is closed (§11.12). An unknown
|
|
72
|
+
* key, or an `enabled` or `complete` that is not a boolean, fails the
|
|
73
|
+
* evaluation. A malformed `intervalMs` or `nextTickAt` is not refused here:
|
|
74
|
+
* §11.9 has the runtime clamp those instead.
|
|
75
|
+
*/
|
|
76
|
+
export declare function readTickControllerResult(label: string, result: unknown): TickControllerResult;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One evaluation of the game's tick controller (§11): what it is handed and
|
|
3
|
+
* how long the runtime waits for it.
|
|
4
|
+
*
|
|
5
|
+
* The controller is the one logic resource that judges several teams at once
|
|
6
|
+
* without writing anything, so its arguments are its own shape: the board of
|
|
7
|
+
* the team the host swapped in, each team's board projected as the
|
|
8
|
+
* controller's own is, and the waiting-room flag. What its answer means for
|
|
9
|
+
* the timers is the session's business; this module only asks the question.
|
|
10
|
+
*/
|
|
11
|
+
import type { TickControllerResult } from '@seriousgaming/sdk';
|
|
12
|
+
import type { LogicHost } from './logic-calls';
|
|
13
|
+
import type { GameContext } from './types';
|
|
14
|
+
export interface TickControllerHost extends LogicHost {
|
|
15
|
+
/** The board of the team the host swapped in before calling. */
|
|
16
|
+
board(): GameContext;
|
|
17
|
+
/** The tick last run, which `meta.tick` reports. */
|
|
18
|
+
lastTick(): number;
|
|
19
|
+
waitingRoomOpen(): boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Execute the tick controller for the current game and return its result.
|
|
23
|
+
* Returns null if no tick controller is configured.
|
|
24
|
+
*/
|
|
25
|
+
export declare function callTickController(host: TickControllerHost, teams: {
|
|
26
|
+
teamId: string;
|
|
27
|
+
index: number;
|
|
28
|
+
context: Record<string, unknown>;
|
|
29
|
+
}[], identity: {
|
|
30
|
+
teamId: string;
|
|
31
|
+
index: number;
|
|
32
|
+
}): Promise<TickControllerResult | null>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for game execution
|
|
3
|
+
*/
|
|
4
|
+
import type { ResolvedPackageManifest } from '@seriousgaming/sdk';
|
|
5
|
+
import type { ResolvedSettings, SessionSettingsOverrides } from './configuration-builder';
|
|
6
|
+
export type { ResolvedSettings, SessionSettingsOverrides };
|
|
7
|
+
export type GameContext = Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Injectable dependencies for GameExecutor.
|
|
10
|
+
* All I/O-heavy operations are abstracted behind this interface
|
|
11
|
+
* so that tests can substitute lightweight mocks.
|
|
12
|
+
*/
|
|
13
|
+
export interface ExecutorDependencies {
|
|
14
|
+
/** Transpile a TypeScript entrypoint into a CommonJS bundle string */
|
|
15
|
+
transpile: (options: {
|
|
16
|
+
entrypoint: string;
|
|
17
|
+
sourcemap?: boolean;
|
|
18
|
+
packageRoot?: string;
|
|
19
|
+
}) => Promise<string>;
|
|
20
|
+
/** Load and resolve the SDK configuration from a JSON path */
|
|
21
|
+
loadConfig: (configPath: string) => Promise<ResolvedPackageManifest>;
|
|
22
|
+
/** File-system read operations */
|
|
23
|
+
fs: {
|
|
24
|
+
existsSync: (path: string) => boolean;
|
|
25
|
+
readFile: (path: string, encoding: BufferEncoding) => Promise<string>;
|
|
26
|
+
};
|
|
27
|
+
/** Persistence for session-override layer */
|
|
28
|
+
configStore: {
|
|
29
|
+
save: (packagePath: string, configuration: SessionSettingsOverrides) => Promise<void>;
|
|
30
|
+
getPath: (packagePath: string) => string;
|
|
31
|
+
/** Record which scenario the saved configuration was built for (#439). */
|
|
32
|
+
saveScenario: (packagePath: string, scenarioId: string | null) => Promise<void>;
|
|
33
|
+
/** The recorded scenario, or `undefined` when nothing was recorded. */
|
|
34
|
+
readScenario: (packagePath: string) => string | null | undefined;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* How long one call into author logic may take before the runtime stops
|
|
38
|
+
* waiting on it (SPECIFICATION.md §15.4, §14.4, §6.12). Deployment-defined;
|
|
39
|
+
* omit for the default.
|
|
40
|
+
*/
|
|
41
|
+
logicExecutionBoundMs?: number;
|
|
42
|
+
/**
|
|
43
|
+
* How long one engine or tick-controller call may take before the tick is
|
|
44
|
+
* abandoned (SPECIFICATION.md §11.10). Deployment-defined; omit for the
|
|
45
|
+
* default.
|
|
46
|
+
*/
|
|
47
|
+
tickExecutionBoundMs?: number;
|
|
48
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tsType` on a capability's `variablesSchema` (#601): a property names a real
|
|
3
|
+
* TypeScript type, which the generated `types.ts` uses in place of what the
|
|
4
|
+
* schema alone would give (`{ [k: string]: unknown }` for a loose object).
|
|
5
|
+
*
|
|
6
|
+
* `json-schema-to-typescript` emits a `tsType` verbatim, so the only work is
|
|
7
|
+
* the path in an `import('…')` type. An author writes it relative to the
|
|
8
|
+
* capability's own directory, as any import in a file beside the bundle would
|
|
9
|
+
* be. The same capability is compiled into many `types.ts` files, each in a
|
|
10
|
+
* different directory, so the path is resolved to an absolute one when the
|
|
11
|
+
* capabilities are loaded and made relative to each output as it is written.
|
|
12
|
+
*
|
|
13
|
+
* A bare specifier (`import('some-package').Thing`) and a `tsType` with no
|
|
14
|
+
* import at all (`'low' | 'high'`) pass through unchanged.
|
|
15
|
+
*/
|
|
16
|
+
import type { SDKCapability } from '@seriousgaming/sdk';
|
|
17
|
+
/** Where a capability's bundle, and so the base of its `tsType` paths, lives. */
|
|
18
|
+
export declare function capabilityDirectory(workingDir: string, identifier: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* The capabilities with every relative `tsType` import resolved to an
|
|
21
|
+
* absolute path, from the capability's own directory. Capabilities with none
|
|
22
|
+
* are returned as they are.
|
|
23
|
+
*/
|
|
24
|
+
export declare function absolutiseTsTypes(capabilities: readonly SDKCapability[], workingDir: string): SDKCapability[];
|
|
25
|
+
/**
|
|
26
|
+
* A schema fragment with every absolute `tsType` import made relative to the
|
|
27
|
+
* file it is about to be written into.
|
|
28
|
+
*/
|
|
29
|
+
export declare function relativiseTsTypes<T>(schema: T, outputPath: string): T;
|
|
30
|
+
/**
|
|
31
|
+
* Check every `tsType` import a package's capabilities make: the module
|
|
32
|
+
* exists, and exports the name the type reads from it.
|
|
33
|
+
*
|
|
34
|
+
* A textual check rather than a compile, which is enough to catch the two
|
|
35
|
+
* mistakes worth catching before a whole-package `tsc` does: a path written
|
|
36
|
+
* relative to the wrong directory, and a misspelt or unexported name. The
|
|
37
|
+
* message names the capability, the `tsType` and where it looked.
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateTsTypes(capabilities: readonly SDKCapability[], workingDir: string): string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locale helpers for facilitator guides.
|
|
3
|
+
*
|
|
4
|
+
* This module is browser-safe: it is imported by both the CLI content
|
|
5
|
+
* validator and the dev server UI.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Pick the locale whose chapter set the others are measured against and
|
|
9
|
+
* fall back to (§18.2: 'en' when declared, otherwise the first declared
|
|
10
|
+
* locale).
|
|
11
|
+
*/
|
|
12
|
+
export declare function referenceLocale(locales: Record<string, unknown>): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Closed provider registry for facilitator guide video embeds.
|
|
3
|
+
*
|
|
4
|
+
* A video embed is a fenced code block with language `video` and a YAML-style
|
|
5
|
+
* body, validated against this registry:
|
|
6
|
+
*
|
|
7
|
+
* ```video
|
|
8
|
+
* provider: youtube
|
|
9
|
+
* id: dQw4w9WgXcQ
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* IDs are validated against a strict per-provider regex and never
|
|
13
|
+
* interpolated raw into a URL. Unknown providers or malformed blocks must
|
|
14
|
+
* render as an inert error block, never a passthrough.
|
|
15
|
+
*
|
|
16
|
+
* This module is browser-safe: it is imported by both the CLI content
|
|
17
|
+
* validator and the dev server UI renderer.
|
|
18
|
+
*/
|
|
19
|
+
export interface VideoProvider {
|
|
20
|
+
/** Strict pattern a video id must match before any URL is built */
|
|
21
|
+
idPattern: RegExp;
|
|
22
|
+
/** Embed URL template, only ever called with a pattern-validated id */
|
|
23
|
+
embedUrl: (id: string) => string;
|
|
24
|
+
/** Hosts the embed iframe may load from (for frame-src CSP) */
|
|
25
|
+
embedHosts: string[];
|
|
26
|
+
}
|
|
27
|
+
export declare const VIDEO_PROVIDERS: Record<string, VideoProvider>;
|
|
28
|
+
export type ParsedVideoBlock = {
|
|
29
|
+
ok: true;
|
|
30
|
+
provider: string;
|
|
31
|
+
id: string;
|
|
32
|
+
embedUrl: string;
|
|
33
|
+
} | {
|
|
34
|
+
ok: false;
|
|
35
|
+
error: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Parse and validate the body of a `video` fenced block. Returns a typed
|
|
39
|
+
* error (never throws) so renderers can show an inert error block and
|
|
40
|
+
* validators can surface the message.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseVideoBlock(body: string): ParsedVideoBlock;
|