@seriousgaming/sdk-tools 0.0.0-stage → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +93 -0
- package/README.md +38 -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 +27404 -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 +16920 -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 +218 -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 +241 -0
- package/dist/docs/cli-and-dev-server.md +217 -0
- package/dist/docs/cli-error-codes.md +156 -0
- package/dist/docs/cli-reference.md +2489 -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 +577 -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 +339 -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 +123 -3
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Running a tick (§9.3, §5.3): whether one may run, which teams it moves, and
|
|
3
|
+
* what each team's board and history hold afterwards.
|
|
4
|
+
*
|
|
5
|
+
* The mode decides the shape. A shared-state cohort has one clock and moves
|
|
6
|
+
* as one; an independent team moves from its own tick, so a cohort tick is
|
|
7
|
+
* each team's tick in turn and never pulls a lagging team forwards. The board
|
|
8
|
+
* a tick was submitted with is recorded as the round it closes, after the
|
|
9
|
+
* engine has run, so a tick that throws leaves neither a changed board nor a
|
|
10
|
+
* round behind. A participant's request passes the validator gate first, and
|
|
11
|
+
* the timers are re-evaluated for exactly the teams that moved.
|
|
12
|
+
*/
|
|
13
|
+
import type { Actor, TeamScope } from './protocol';
|
|
14
|
+
import type { SessionHost } from './session-host';
|
|
15
|
+
type TickHost = Pick<SessionHost, 'executor' | 'state' | 'participants' | 'faults' | 'timers' | 'mode' | 'tickLimit' | 'positionOf' | 'emit'>;
|
|
16
|
+
/** Run one tick for `scope`. Returns the tick it committed. */
|
|
17
|
+
export declare function tick(host: TickHost, scope: TeamScope & Actor): Promise<number>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session's automatic tick timers (§11): which teams share one, when the
|
|
3
|
+
* tick controller is asked again, and what a timer firing does.
|
|
4
|
+
*
|
|
5
|
+
* A timer is armed from the controller's answer and nothing else, so the
|
|
6
|
+
* whole of this module is deciding when to ask: after a tick, after a write
|
|
7
|
+
* that changed what the controller reads (§11.1a), after the cohort changes
|
|
8
|
+
* shape, and after an automatic tick was refused. Each team has its own timer
|
|
9
|
+
* in a multi-team independent session and the cohort shares one otherwise,
|
|
10
|
+
* and that grouping is decided here once, so a pause, a resume or an extension
|
|
11
|
+
* addressed to a team reaches the timer that actually serves it.
|
|
12
|
+
*/
|
|
13
|
+
import type { TimerState } from '@seriousgaming/sdk';
|
|
14
|
+
import type { MutationCommand, TeamScope } from './protocol';
|
|
15
|
+
import type { SessionHost } from './session-host';
|
|
16
|
+
type TimerHost = Pick<SessionHost, 'clock' | 'executor' | 'state' | 'mode' | 'teamBounds' | 'inSetup' | 'tickLimit' | 'positionOf' | 'report' | 'submit' | 'enqueue' | 'emitState'>;
|
|
17
|
+
export declare class SessionTimers {
|
|
18
|
+
private readonly host;
|
|
19
|
+
/** True while a tick runs, so a timer firing then is dropped (§11.1). */
|
|
20
|
+
ticking: boolean;
|
|
21
|
+
/** Automatic tick timers, keyed by team index, or {@link COHORT} (§11). */
|
|
22
|
+
private readonly timers;
|
|
23
|
+
constructor(host: TimerHost);
|
|
24
|
+
/** Cancel every timer, for a session that is stopping. */
|
|
25
|
+
stop(): void;
|
|
26
|
+
/** The timer serving the team at `position`, idle when it has none. */
|
|
27
|
+
stateAt(position: number): TimerState;
|
|
28
|
+
/** The projection's session-wide timer: the cohort's, absent per-team timers. */
|
|
29
|
+
cohort(): TimerState | null;
|
|
30
|
+
pause(scope: TeamScope): void;
|
|
31
|
+
resume(scope: TeamScope): Promise<void>;
|
|
32
|
+
extend(command: Extract<MutationCommand, {
|
|
33
|
+
type: 'extendTick';
|
|
34
|
+
}>): undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Evaluate every group serving one of `positions`. A `reevaluation` is
|
|
37
|
+
* the §11.1a kind, which keeps the schedule when the answer is unchanged.
|
|
38
|
+
*/
|
|
39
|
+
evaluateFor(positions: number[], reevaluation?: boolean): Promise<void>;
|
|
40
|
+
/** Evaluate every group afresh, dropping timers for teams that have gone. */
|
|
41
|
+
refresh(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* What the tick controller reads before `command` runs, for {@link retime}
|
|
44
|
+
* to compare against: null for a command that writes no context.
|
|
45
|
+
*/
|
|
46
|
+
readsBefore(command: MutationCommand): string[] | null;
|
|
47
|
+
/** What a settled mutation means for the automatic tick timers. */
|
|
48
|
+
retime(command: MutationCommand, readsBefore: string[] | null): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Which teams share a timer. Each team has its own in a multi-team
|
|
51
|
+
* independent session, because each keeps its own clock (§9.4a); every
|
|
52
|
+
* other session has one, for the cohort.
|
|
53
|
+
*/
|
|
54
|
+
private groups;
|
|
55
|
+
private timerFor;
|
|
56
|
+
/** The groups a timer command addresses: one team's, or every group when none is named. */
|
|
57
|
+
private groupsIn;
|
|
58
|
+
/** Whether a group can still tick at all: not complete, not at the limit. */
|
|
59
|
+
private canAutoTick;
|
|
60
|
+
/**
|
|
61
|
+
* Ask the tick controller about one group and act on the answer (§11.1).
|
|
62
|
+
*
|
|
63
|
+
* Judged against the group's first team's own context, with `teams`
|
|
64
|
+
* carrying the group's entries: every team's in shared-state mode, the one
|
|
65
|
+
* team's in independent mode or a single-team game. A controller that
|
|
66
|
+
* throws must not take a committed tick with it, so it is reported and the
|
|
67
|
+
* timer stops, and nothing else changes.
|
|
68
|
+
*/
|
|
69
|
+
private evaluate;
|
|
70
|
+
/**
|
|
71
|
+
* Each team's value of what the tick controller reads, to tell whether a
|
|
72
|
+
* write changed any of it (§11.1a). Null when it declares no reads, which
|
|
73
|
+
* means every write counts.
|
|
74
|
+
*/
|
|
75
|
+
private controllerReads;
|
|
76
|
+
/**
|
|
77
|
+
* An automatic tick. Dropped when a tick is already running (§11.1): that
|
|
78
|
+
* tick re-evaluates the controller when it settles, which reschedules.
|
|
79
|
+
* One that is refused or fails is followed by a fresh evaluation, so the
|
|
80
|
+
* timer is re-armed, or stopped when the group can no longer tick.
|
|
81
|
+
*/
|
|
82
|
+
private onFired;
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes to the boards from outside logic (§9.5, §9.5.1, §8.2): a team's
|
|
3
|
+
* board, the shared store, and the session's settings layer.
|
|
4
|
+
*
|
|
5
|
+
* What makes a write legal is composition rather than the write itself. A
|
|
6
|
+
* team board is a view of its own capabilities with the shared store spread
|
|
7
|
+
* over it (§7.5), so a team-addressed write may not quietly change a shared
|
|
8
|
+
* value the other teams also read, and a shared write re-composes every view
|
|
9
|
+
* at once. Each surface is entitled by its own `writes`, checked from the
|
|
10
|
+
* bundle rather than taken on the frame's word, and the engine's private
|
|
11
|
+
* state is out of every caller's reach. Those rules, and the validator gate
|
|
12
|
+
* a participant's write passes through, are applied here before anything is
|
|
13
|
+
* stored.
|
|
14
|
+
*/
|
|
15
|
+
import type { MutationCommand } from './protocol';
|
|
16
|
+
import type { ScenarioDrafts } from './scenario-drafts';
|
|
17
|
+
import type { SessionHost } from './session-host';
|
|
18
|
+
type WriteHost = Pick<SessionHost, 'executor' | 'state' | 'participants' | 'faults' | 'mode' | 'positionOf' | 'emit' | 'declaredSurface' | 'pendingChanges'>;
|
|
19
|
+
/** A team-addressed write (§9.5). Returns the tick it committed into. */
|
|
20
|
+
export declare function updateContext(host: WriteHost, command: Extract<MutationCommand, {
|
|
21
|
+
type: 'updateContext';
|
|
22
|
+
}>): Promise<number>;
|
|
23
|
+
/** A write to the shared store (§9.5.1). Returns the tick it committed into. */
|
|
24
|
+
export declare function updateSharedContext(host: WriteHost, command: Extract<MutationCommand, {
|
|
25
|
+
type: 'updateSharedContext';
|
|
26
|
+
}>): Promise<number>;
|
|
27
|
+
/** A change to the session's settings layer (§8.2). */
|
|
28
|
+
export declare function updateSettings(host: Pick<SessionHost, 'executor' | 'declaredSurface'>, command: Extract<MutationCommand, {
|
|
29
|
+
type: 'updateSettings';
|
|
30
|
+
}>): Promise<undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* An edit from the scenario editor, to its draft of the scenario it is open
|
|
33
|
+
* on (§6.5). Never to the session's layer: the draft belongs to no session.
|
|
34
|
+
* Reduced to what changed against the draft as it resolves now, as the
|
|
35
|
+
* session layer is, so an editor echoing back what it was sent stores nothing.
|
|
36
|
+
*/
|
|
37
|
+
export declare function updateScenarioDraft(host: Pick<SessionHost, 'executor' | 'declaredSurface'>, drafts: ScenarioDrafts, command: Extract<MutationCommand, {
|
|
38
|
+
type: 'updateScenarioDraft';
|
|
39
|
+
}>): Promise<undefined>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One live session, with no transport in it.
|
|
3
|
+
*
|
|
4
|
+
* This is the whole of what the old dev server called `server.ts` and
|
|
5
|
+
* `command-handlers.ts` minus the HTTP, the WebSocket, the Vite servers, the
|
|
6
|
+
* file watchers, and the persistence: 4,366 lines of fused concerns, of which
|
|
7
|
+
* the part that is actually about running a game is this.
|
|
8
|
+
*
|
|
9
|
+
* Everything that changes state goes through one queue, in submission order
|
|
10
|
+
* (§9.7 strategy 1, which the specification assigns to this runtime by name).
|
|
11
|
+
* Everything that reads bypasses it, because §9.7 requires that a read is never
|
|
12
|
+
* blocked behind a mutation. Those two sentences are the entire concurrency
|
|
13
|
+
* model, and they are enforced in one place rather than approximated by a lock
|
|
14
|
+
* here and a debounce there.
|
|
15
|
+
*
|
|
16
|
+
* Time arrives through {@link Clock}, so the tick schedule and its §11.8 bounds
|
|
17
|
+
* are testable without waiting for them. Nothing here touches the filesystem
|
|
18
|
+
* for session state: a session lives as long as its process, by design.
|
|
19
|
+
*
|
|
20
|
+
* The concerns a session is made of live beside it, each given the slice of
|
|
21
|
+
* the session it needs through {@link SessionHost}: the timers
|
|
22
|
+
* (`session-timers`), endpoint calls (`session-endpoints`), the validator
|
|
23
|
+
* gates (`session-gates`), writes to the boards (`session-writes`), the
|
|
24
|
+
* roster (`session-roster`), ticks (`session-ticks`) and rewinds
|
|
25
|
+
* (`session-rewind`). What stays here is the queue, the dispatch, the
|
|
26
|
+
* lifecycle and the projection.
|
|
27
|
+
*/
|
|
28
|
+
import type { ResolvedPackageManifest, RunKind, SDKFacilitatorGuide, SDKScenario, SignatureCallbacks } from '@seriousgaming/sdk';
|
|
29
|
+
import { type EndpointAuditEntry, type MutationResult, type ResolvedSettings, type StateProjection } from '@seriousgaming/sdk/projection';
|
|
30
|
+
import { type Clock } from './clock';
|
|
31
|
+
import { type PendingChanges } from './pending-changes';
|
|
32
|
+
import { type Command, type Event, type MutationCommand, type QueryCommand, type QueryResult } from './protocol';
|
|
33
|
+
import { type ParticipantCounts } from './session-roster';
|
|
34
|
+
export { participantCountsError, type ParticipantCounts } from './session-roster';
|
|
35
|
+
export type { WithLogicError, WithStale } from './session-refusals';
|
|
36
|
+
export interface SessionOptions {
|
|
37
|
+
packagePath: string;
|
|
38
|
+
/** Teams to start with. The manifest's bounds still apply (§5.4). */
|
|
39
|
+
teams?: number;
|
|
40
|
+
/** Participants each team is seeded with: one count for all, or one per team. */
|
|
41
|
+
participants?: ParticipantCounts;
|
|
42
|
+
/** Scenario to activate at initialisation; `null` opts out of the default. */
|
|
43
|
+
scenarioId?: string | null;
|
|
44
|
+
locale?: string;
|
|
45
|
+
seriousGamingApiKey?: string;
|
|
46
|
+
seriousGamingApiHost?: string;
|
|
47
|
+
elevenLabsApiKey?: string;
|
|
48
|
+
/** Injected so tick timing is testable. Defaults to the real clock. */
|
|
49
|
+
clock?: Clock;
|
|
50
|
+
/**
|
|
51
|
+
* Replace callbacks logic receives, such as `generateText`, so a test needs
|
|
52
|
+
* no platform key and gets the same answer every time.
|
|
53
|
+
*/
|
|
54
|
+
callbacks?: Partial<SignatureCallbacks>;
|
|
55
|
+
/**
|
|
56
|
+
* Neither read nor write `.seriousgaming-sdk/configuration.json`: resolve
|
|
57
|
+
* configuration from the package alone. For a test, which must not depend
|
|
58
|
+
* on what somebody last ran `sdk configure` with, nor leave a file behind.
|
|
59
|
+
*/
|
|
60
|
+
inMemory?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Which kind of run this is (§5.7). Defaults to `'session'`: the game being
|
|
63
|
+
* played. A `'walkthrough'` session is the disposable run beside it, and
|
|
64
|
+
* differs only in what it reports to logic and surfaces — it holds one
|
|
65
|
+
* team, starts at tick 0, and never opens the waiting room, but every
|
|
66
|
+
* operation on it is the ordinary one.
|
|
67
|
+
*/
|
|
68
|
+
runKind?: RunKind;
|
|
69
|
+
/**
|
|
70
|
+
* The run's surface storage key (§12.2), where it must outlive this
|
|
71
|
+
* session object: a walkthrough rebuilt by a reset is the same walkthrough
|
|
72
|
+
* to its viewers. Generated when omitted.
|
|
73
|
+
*/
|
|
74
|
+
sessionKey?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Re-initialise whenever an edit on disk applies only at initialisation,
|
|
77
|
+
* however far play has gone, rather than keeping the session on what it
|
|
78
|
+
* started with and recording the change as pending (#640). For a host that
|
|
79
|
+
* restarts the game on every edit, such as the hosted builder.
|
|
80
|
+
*/
|
|
81
|
+
reinitOnChange?: boolean;
|
|
82
|
+
}
|
|
83
|
+
/** The cause a state event carries when an edit on disk restarted the game. */
|
|
84
|
+
export declare const REINITIALISED_ON_CHANGE = "reinitialised-on-change";
|
|
85
|
+
/** What a reload of the package did to the session. */
|
|
86
|
+
export interface ReloadOutcome {
|
|
87
|
+
/**
|
|
88
|
+
* `live`: adopted with play kept where it was. `pending`: adopted in part,
|
|
89
|
+
* with the rest waiting for a re-initialisation. `reinitialised`: started
|
|
90
|
+
* over from the package. `failed`: nothing adopted, reported as an error.
|
|
91
|
+
*/
|
|
92
|
+
kind: 'live' | 'pending' | 'reinitialised' | 'failed';
|
|
93
|
+
/** What is waiting now, or what a re-initialisation just applied. */
|
|
94
|
+
pending: PendingChanges;
|
|
95
|
+
/** Capabilities adopted live, seeded with their schema defaults. */
|
|
96
|
+
added: string[];
|
|
97
|
+
}
|
|
98
|
+
export declare class Session {
|
|
99
|
+
private readonly queue;
|
|
100
|
+
private readonly faults;
|
|
101
|
+
private readonly participants;
|
|
102
|
+
private readonly executor;
|
|
103
|
+
private readonly state;
|
|
104
|
+
private readonly clock;
|
|
105
|
+
private options;
|
|
106
|
+
private readonly listeners;
|
|
107
|
+
/** Operator-facing failures, oldest first (§14.5, and tick failures). */
|
|
108
|
+
private readonly errors;
|
|
109
|
+
private seed;
|
|
110
|
+
/**
|
|
111
|
+
* The key every surface of this run is sent on `init` (§12.2). Random and
|
|
112
|
+
* independent of anything else the session holds, so it names nothing a
|
|
113
|
+
* host would act on.
|
|
114
|
+
*/
|
|
115
|
+
private readonly sessionKey;
|
|
116
|
+
/**
|
|
117
|
+
* Which kind of run this is (§5.7). Fixed at construction: `runKind` is a
|
|
118
|
+
* promise that every surface of one run reports the same value for its
|
|
119
|
+
* whole life, so there is no setter.
|
|
120
|
+
*/
|
|
121
|
+
private readonly runKind;
|
|
122
|
+
private locale;
|
|
123
|
+
private waitingRoomOpen;
|
|
124
|
+
/**
|
|
125
|
+
* The scenario asked for, which is not the one that ends up active.
|
|
126
|
+
* `undefined` takes the game's default; `null` deliberately opts out of it
|
|
127
|
+
* (§6.7). Collapsing the two leaves every game running with no scenario.
|
|
128
|
+
*/
|
|
129
|
+
private requestedScenarioId;
|
|
130
|
+
/** The scenario actually in force, resolved after initialisation. */
|
|
131
|
+
private scenarioId;
|
|
132
|
+
private started;
|
|
133
|
+
/** True while the game's `setup` slot still owes us a Play (§8.3). */
|
|
134
|
+
private holdingAtSetup;
|
|
135
|
+
/** Edits on disk that apply only at the next initialisation (#640). */
|
|
136
|
+
private pending;
|
|
137
|
+
/** The scenario editor's drafts, which belong to no session (§6.5). */
|
|
138
|
+
private readonly drafts;
|
|
139
|
+
/** What the parts below are handed of the session. */
|
|
140
|
+
private readonly host;
|
|
141
|
+
private readonly timers;
|
|
142
|
+
private readonly endpoints;
|
|
143
|
+
private readonly roster;
|
|
144
|
+
constructor(options: SessionOptions);
|
|
145
|
+
/**
|
|
146
|
+
* Load the package and bring the session to its first renderable state.
|
|
147
|
+
*
|
|
148
|
+
* For a game with a `setup` slot that is the configuration step,
|
|
149
|
+
* with no context built yet; for every other game it is tick 0 (§8.3).
|
|
150
|
+
*/
|
|
151
|
+
start(): Promise<void>;
|
|
152
|
+
stop(): Promise<void>;
|
|
153
|
+
/** Submit a state-changing command. Queued, in order, one at a time. */
|
|
154
|
+
submit(command: MutationCommand): Promise<MutationResult>;
|
|
155
|
+
/**
|
|
156
|
+
* Queue `work` as one operation: every logic call it makes reads the same
|
|
157
|
+
* `meta.now`, taken as it starts rather than as it was submitted (§10.2).
|
|
158
|
+
*/
|
|
159
|
+
private enqueue;
|
|
160
|
+
/**
|
|
161
|
+
* Move a fake clock forward by `byMs`, one due instant at a time.
|
|
162
|
+
*
|
|
163
|
+
* The clock runs everything due in one call, but an automatic tick is
|
|
164
|
+
* submitted rather than run, and the next one is scheduled only once it
|
|
165
|
+
* settles. Advancing straight to the target would run the first tick and
|
|
166
|
+
* then find nothing else due, so three minutes on a one-minute timer would
|
|
167
|
+
* tick once. Stepping to each due instant and settling there ticks three
|
|
168
|
+
* times, which is what three minutes means.
|
|
169
|
+
*/
|
|
170
|
+
private advanceClock;
|
|
171
|
+
/**
|
|
172
|
+
* Submit a command the runtime issues on its own behalf, which is dropped
|
|
173
|
+
* rather than queued when anything is in flight (§11.1).
|
|
174
|
+
*/
|
|
175
|
+
submitIfIdle(command: MutationCommand): Promise<MutationResult | null>;
|
|
176
|
+
/**
|
|
177
|
+
* Resolves once everything queued has run, including a tick an automatic
|
|
178
|
+
* timer submitted. For a caller that must observe a timer's effects.
|
|
179
|
+
*/
|
|
180
|
+
settled(): Promise<void>;
|
|
181
|
+
/** Answer a read. Never queued (§9.7). */
|
|
182
|
+
query(command: QueryCommand): Promise<QueryResult>;
|
|
183
|
+
/** Convenience for a caller that does not care which kind it is holding. */
|
|
184
|
+
run(command: Command): Promise<MutationResult | QueryResult>;
|
|
185
|
+
/** The §20.1 projection: one shape, recomputed on demand. */
|
|
186
|
+
project(): StateProjection;
|
|
187
|
+
/**
|
|
188
|
+
* The stored session-override layer (§8.2), as distinct from the resolved
|
|
189
|
+
* configuration on the projection. Sparse: it holds what was overridden.
|
|
190
|
+
*/
|
|
191
|
+
sessionOverrides(): ResolvedSettings;
|
|
192
|
+
/**
|
|
193
|
+
* The scenario editor's draft of a scenario, resolved (§6.5): what
|
|
194
|
+
* save-as-scenario captures from the editor. Null when no editor is open
|
|
195
|
+
* on it.
|
|
196
|
+
*/
|
|
197
|
+
scenarioDraft(scenarioId: string | null): ResolvedSettings | null;
|
|
198
|
+
/** A draft has been saved as its scenario, which now holds its edits. */
|
|
199
|
+
scenarioDraftSaved(scenarioId: string | null): void;
|
|
200
|
+
/**
|
|
201
|
+
* Every open draft, resolved, for the projection; nothing while none is.
|
|
202
|
+
* A draft of a scenario since deleted on disk is left out rather than
|
|
203
|
+
* resolved against nothing.
|
|
204
|
+
*/
|
|
205
|
+
private projectedDrafts;
|
|
206
|
+
/** Endpoint calls that changed something, oldest first (§6.12). */
|
|
207
|
+
endpointAuditLog(): readonly EndpointAuditEntry[];
|
|
208
|
+
/** Operator-facing failures since the session started, oldest first. */
|
|
209
|
+
diagnostics(): readonly string[];
|
|
210
|
+
/**
|
|
211
|
+
* Mark exactly these participants connected, and every other one not
|
|
212
|
+
* (§13.2).
|
|
213
|
+
*
|
|
214
|
+
* Presence is the host's to observe, not a command anybody sends: the host
|
|
215
|
+
* knows which surfaces are open, and a participant is connected while at
|
|
216
|
+
* least one surface bound to them is. Given the whole set rather than a
|
|
217
|
+
* change, so a re-initialisation that replaces every participant record
|
|
218
|
+
* is put right by the next call, with nothing to reconcile.
|
|
219
|
+
*/
|
|
220
|
+
syncPresence(connected: ReadonlySet<string>): void;
|
|
221
|
+
/** Edits on disk this session has not applied, each list empty when none is. */
|
|
222
|
+
pendingChanges(): PendingChanges;
|
|
223
|
+
/** True while the session is in its setup state, still owed a Play (§8.3, §9.0). */
|
|
224
|
+
get inSetup(): boolean;
|
|
225
|
+
/** The resolved package, for a shell that has to serve what it declares. */
|
|
226
|
+
packageConfiguration(): ResolvedPackageManifest | null;
|
|
227
|
+
/** The scenario in force, for resolving `asset:` references (§6.7). */
|
|
228
|
+
activeScenario(): SDKScenario | null;
|
|
229
|
+
/**
|
|
230
|
+
* Re-read the package's scenarios, after one has been written to disk.
|
|
231
|
+
*
|
|
232
|
+
* An author-time affordance (§6.7.1): saving a scenario changes the package,
|
|
233
|
+
* and the picker should show it without a restart.
|
|
234
|
+
*/
|
|
235
|
+
reloadScenarios(): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* Pick up edited logic from its next run. Queued, so a tick in flight
|
|
238
|
+
* finishes on the code it started with. Nothing already played is re-run.
|
|
239
|
+
*/
|
|
240
|
+
reloadLogic(): Promise<void>;
|
|
241
|
+
/**
|
|
242
|
+
* Re-resolve configuration from edited bundle files and the manifest.
|
|
243
|
+
*
|
|
244
|
+
* What a running session can adopt, it adopts, keeping play where it is. An
|
|
245
|
+
* edit that applies only at initialisation (a setting, a manifest field
|
|
246
|
+
* read at session creation, a capability removed or moved to another
|
|
247
|
+
* scope) re-initialises the session while nothing has been played, or
|
|
248
|
+
* always under {@link SessionOptions.reinitOnChange}. Otherwise the session
|
|
249
|
+
* keeps running on what it started with and records the edit as pending,
|
|
250
|
+
* which refuses what would advance play until somebody re-initialises
|
|
251
|
+
* (#640). A bundle that does not load or validate is reported, and the
|
|
252
|
+
* last good configuration stays in force.
|
|
253
|
+
*/
|
|
254
|
+
reloadBundles(): Promise<ReloadOutcome>;
|
|
255
|
+
/**
|
|
256
|
+
* Whether anything has been played: a tick committed and not since
|
|
257
|
+
* rewound. A session at its configuration step has played nothing.
|
|
258
|
+
*/
|
|
259
|
+
private hasPlayed;
|
|
260
|
+
/**
|
|
261
|
+
* Start the session over from the package as it is on disk, keeping the
|
|
262
|
+
* team count, the scenario and the locale, and returning play to tick 0.
|
|
263
|
+
* A session at its configuration step stays at it when the game still has
|
|
264
|
+
* one (§8.3).
|
|
265
|
+
*/
|
|
266
|
+
private applyPendingChanges;
|
|
267
|
+
/** The facilitator guide this package declares, or null (§6.9). */
|
|
268
|
+
guide(): SDKFacilitatorGuide | null;
|
|
269
|
+
subscribe(listener: (event: Event) => void): () => void;
|
|
270
|
+
private apply;
|
|
271
|
+
/** Returns the tick a write committed into, where that is meaningful. */
|
|
272
|
+
private dispatch;
|
|
273
|
+
private play;
|
|
274
|
+
/**
|
|
275
|
+
* Return to the configuration step (§8.3).
|
|
276
|
+
*
|
|
277
|
+
* Refused for a game with no `setup` slot: there would be nothing to show
|
|
278
|
+
* and no way back, which is a session you have to restart the process to
|
|
279
|
+
* recover.
|
|
280
|
+
*
|
|
281
|
+
* The session resets with it, because a configuration change reaches logic
|
|
282
|
+
* through `Init`. Leaving the teams where they were would show a
|
|
283
|
+
* configuration screen over a game already in progress, and then quietly
|
|
284
|
+
* discard the round they were in when somebody pressed Play.
|
|
285
|
+
*/
|
|
286
|
+
private reconfigure;
|
|
287
|
+
/**
|
|
288
|
+
* Start the session over from the package (§8.3).
|
|
289
|
+
*
|
|
290
|
+
* `reset` returns the session to its own tick 0; this rebuilds it. The
|
|
291
|
+
* scenario is resolved afresh, so omitting one goes back to the package's
|
|
292
|
+
* default rather than keeping whatever is active, and the team count and
|
|
293
|
+
* locale are resolved again too. What it does not do is restart the
|
|
294
|
+
* process: a browser attached to this session stays attached.
|
|
295
|
+
*/
|
|
296
|
+
private reinitialise;
|
|
297
|
+
private setWaitingRoom;
|
|
298
|
+
/**
|
|
299
|
+
* Activate a scenario, from the start (§6.7).
|
|
300
|
+
*
|
|
301
|
+
* A scenario is a different set of starting conditions, so switching one is
|
|
302
|
+
* a new session rather than an adjustment to the one in progress: its
|
|
303
|
+
* overrides reach the game through `Init`, and a session already several
|
|
304
|
+
* ticks in has passed the only moment they mean anything. Every team
|
|
305
|
+
* returns to tick 0, and a game with a configuration step returns to it.
|
|
306
|
+
*
|
|
307
|
+
* This is why a client should confirm before sending it. The runtime does
|
|
308
|
+
* not ask — a runtime that second-guessed a command it was given would be
|
|
309
|
+
* unusable from a script — but it does say plainly what it did.
|
|
310
|
+
*/
|
|
311
|
+
/** Open the scenario editor's draft of a scenario the package declares (§6.5). */
|
|
312
|
+
private editScenario;
|
|
313
|
+
private declaredScenarioIds;
|
|
314
|
+
private selectScenario;
|
|
315
|
+
/**
|
|
316
|
+
* Delete this run's blobs of the given retentions (§16.2).
|
|
317
|
+
*
|
|
318
|
+
* A walkthrough keeps its blobs in the package's store with the session's,
|
|
319
|
+
* and nothing records which run made one, so it deletes none: clearing on
|
|
320
|
+
* its behalf would clear the session's uploads too.
|
|
321
|
+
*/
|
|
322
|
+
private clearBlobs;
|
|
323
|
+
private setLocale;
|
|
324
|
+
/**
|
|
325
|
+
* Build tick-0 state for every team, and seed the histories.
|
|
326
|
+
*
|
|
327
|
+
* @param preserveShared Store captured before a re-initialisation, to put
|
|
328
|
+
* back afterwards (§7.5 rule 4). Omitted where re-seeding the store from
|
|
329
|
+
* capability defaults is the point, as it is for a reset.
|
|
330
|
+
*/
|
|
331
|
+
private buildInitialState;
|
|
332
|
+
private resolveMode;
|
|
333
|
+
/**
|
|
334
|
+
* The mode the game declared (§5.2).
|
|
335
|
+
*
|
|
336
|
+
* The team count is not consulted. Reporting a one-team session as a third
|
|
337
|
+
* `single` mode read as harmless, because with one team the two modes reach
|
|
338
|
+
* the same state, but it decided this session's ticks, undo and history
|
|
339
|
+
* from a quantity that was free to change, and it governed the `addTeam`
|
|
340
|
+
* guard from the very number that guard exists to hold still (#533).
|
|
341
|
+
*/
|
|
342
|
+
private mode;
|
|
343
|
+
/** What a surface reads of another team, which only shared state allows (§6.1). */
|
|
344
|
+
private crossTeamReadsOf;
|
|
345
|
+
/**
|
|
346
|
+
* The bounds as this host will actually enforce them (§5.4).
|
|
347
|
+
*
|
|
348
|
+
* A game declaring no maximum is capped at the number of teams it has,
|
|
349
|
+
* because an unbounded control on a local authoring host offers a facilitator
|
|
350
|
+
* a session it cannot usefully drive.
|
|
351
|
+
*/
|
|
352
|
+
private effectiveTeamBounds;
|
|
353
|
+
private teamBounds;
|
|
354
|
+
private tickLimit;
|
|
355
|
+
/** A game holds a configuration step exactly when it fills the `setup` slot (§8.3). */
|
|
356
|
+
private hasSetup;
|
|
357
|
+
/** Whether any tick has been committed and not since rewound. */
|
|
358
|
+
private hasTicked;
|
|
359
|
+
/** The team at a position, as an endpoint is told it (§6.12). */
|
|
360
|
+
private teamAt;
|
|
361
|
+
/** A team's display name as it reads now, a rename included (§5.4). */
|
|
362
|
+
private teamNameAt;
|
|
363
|
+
private sharedEngineState;
|
|
364
|
+
private sharedStore;
|
|
365
|
+
/** The stable index behind a team id, or undefined when it names no team. */
|
|
366
|
+
private indexOfTeamId;
|
|
367
|
+
private positionOf;
|
|
368
|
+
/**
|
|
369
|
+
* The `game` settings through every layer (§6.10, §8.2). Every runtime read
|
|
370
|
+
* of the tick limit, the team bounds and names, and `openOnStart` goes
|
|
371
|
+
* through here, so a scenario or the session can vary them.
|
|
372
|
+
*/
|
|
373
|
+
private settings;
|
|
374
|
+
private game;
|
|
375
|
+
private scenarioBeingEdited;
|
|
376
|
+
/**
|
|
377
|
+
* The game's name in the session locale, falling back through what the
|
|
378
|
+
* package declares (§18.2) rather than showing an identifier to a
|
|
379
|
+
* facilitator.
|
|
380
|
+
*/
|
|
381
|
+
private gameName;
|
|
382
|
+
private report;
|
|
383
|
+
private emitState;
|
|
384
|
+
private emit;
|
|
385
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
+
/**
|
|
3
|
+
* Locked settings (SPECIFICATION.md §6.1a): a property its schema marks
|
|
4
|
+
* `readOnly: true` keeps the game's own value. The lock is enforced where a
|
|
5
|
+
* value is written, a scenario or the session layer, and never where layers
|
|
6
|
+
* resolve: an override naming a locked value is refused, so none ever reaches
|
|
7
|
+
* the resolver. A locked object locks everything under it.
|
|
8
|
+
*/
|
|
9
|
+
/** The paths a settings schema locks, each as its keys below the resource. */
|
|
10
|
+
export declare function lockedPaths(schema: JSONSchema7 | undefined): string[][];
|
|
11
|
+
/** The locked paths an override of one settings resource names. */
|
|
12
|
+
export declare function lockedPathsNamed(override: unknown, schema: JSONSchema7 | undefined): string[][];
|
|
13
|
+
/** A locked value as a facilitator or an author reads it: `engine.Rate`. */
|
|
14
|
+
export declare function lockedSettingName(identifier: string, path: readonly string[]): string;
|
|
15
|
+
export declare function lockedSettingMessage(identifier: string, path: readonly string[]): string;
|
|
16
|
+
/**
|
|
17
|
+
* `settings` without the locked values that still hold the game's own, as a
|
|
18
|
+
* resolved snapshot always carries them. What a save-as-scenario writes, so
|
|
19
|
+
* the scenario never names a locked value; one that differs from the game's
|
|
20
|
+
* is left in place for validation to refuse.
|
|
21
|
+
*/
|
|
22
|
+
export declare function withoutLockedDefaults<T extends Record<string, unknown>>(settings: T, schemas: Record<string, JSONSchema7>): T;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Team name resolution.
|
|
3
|
+
*
|
|
4
|
+
* Author intent layers over the runtime default: the resolved `game`
|
|
5
|
+
* settings' `teams.defaultNames`, which a scenario or the session may set like
|
|
6
|
+
* any other setting, wins over the positional `Team N` fallback. Names are
|
|
7
|
+
* localised, so the active locale is tried first, then any locale the entry
|
|
8
|
+
* declares (an authored name in another language still beats `Team N`),
|
|
9
|
+
* before the fallback.
|
|
10
|
+
*
|
|
11
|
+
* Resolved names are advisory defaults: operators may rename teams at session
|
|
12
|
+
* setup.
|
|
13
|
+
*/
|
|
14
|
+
type LocalisedTeamName = Record<string, {
|
|
15
|
+
name: string;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the default name for a single team (zero-based index).
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveTeamName(index: number, defaultNames: readonly LocalisedTeamName[], locale: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Longest team name the host will accept.
|
|
23
|
+
*
|
|
24
|
+
* A team name is rendered in the host's own chrome and on print sheets, neither
|
|
25
|
+
* of which the game controls, so the ceiling is the host's to set. Players can
|
|
26
|
+
* rename their own team (#494) and no game code sees the name on its way
|
|
27
|
+
* through, so this is the only thing standing between a text field and a
|
|
28
|
+
* session header.
|
|
29
|
+
*/
|
|
30
|
+
export declare const MAX_TEAM_NAME_LENGTH = 60;
|
|
31
|
+
/**
|
|
32
|
+
* Per-session team name overrides, keyed by stable team index.
|
|
33
|
+
*
|
|
34
|
+
* A team's default name is resolved from the `game` settings, so
|
|
35
|
+
* a facilitator rename has nowhere to live in either. It is session state, not
|
|
36
|
+
* authored content: it lasts as long as the dev server process and is
|
|
37
|
+
* deliberately not written back to any `.sdk.json`.
|
|
38
|
+
*/
|
|
39
|
+
export declare const teamNameOverrides: Map<number, string>;
|
|
40
|
+
/**
|
|
41
|
+
* Discard every rename, restoring the authored defaults.
|
|
42
|
+
*
|
|
43
|
+
* Intended for tests. The overrides are module state, so they outlive the
|
|
44
|
+
* `DevServer` that collected them: an in-process test that starts a second
|
|
45
|
+
* server sees the first one's renames, the way `clearOwnWriteHistory` exists
|
|
46
|
+
* for the same reason in `atomic-write.ts`. A real dev server hosts one session
|
|
47
|
+
* per process, so nothing in normal use needs this.
|
|
48
|
+
*/
|
|
49
|
+
export declare function clearTeamNameOverrides(): void;
|
|
50
|
+
/** Resolve a team's display name, preferring a rename over the authored default. */
|
|
51
|
+
export declare function resolveTeamDisplayName(index: number, defaultNames: readonly LocalisedTeamName[], locale: string): string;
|
|
52
|
+
export {};
|