@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
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type TranspileOptions = {
|
|
2
|
+
entrypoint: string;
|
|
3
|
+
/**
|
|
4
|
+
* Append an inline source map, so a stack thrown inside the bundle can be
|
|
5
|
+
* read back against the source (#639). For logic the dev server runs, never
|
|
6
|
+
* for a built package.
|
|
7
|
+
*/
|
|
8
|
+
sourcemap?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The package root that a failure's diagnostics name files relative to.
|
|
11
|
+
* Defaults to the working directory.
|
|
12
|
+
*/
|
|
13
|
+
packageRoot?: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atomic file writes with own-write detection.
|
|
3
|
+
*
|
|
4
|
+
* Problem: the dev server watches config/state files with chokidar and also
|
|
5
|
+
* writes to them. Non-atomic writes (fs.writeFile) can leave truncated files
|
|
6
|
+
* mid-write, and the watcher can observe our own writes and trigger spurious
|
|
7
|
+
* reloads. The previous mitigation was a 150ms setTimeout guard, which races
|
|
8
|
+
* with chokidar's stability threshold.
|
|
9
|
+
*
|
|
10
|
+
* Solution:
|
|
11
|
+
* 1. Write to a sibling temp file, then rename over the destination. `rename`
|
|
12
|
+
* is atomic on POSIX and Windows (within the same directory), so readers —
|
|
13
|
+
* including the watcher — never observe a partial file.
|
|
14
|
+
* 2. Hash the content we just wrote and remember it in a small per-path ring
|
|
15
|
+
* buffer. When the watcher fires, it can read the file, hash the bytes,
|
|
16
|
+
* and skip reloads whose hash matches a recent own-write. No timing window
|
|
17
|
+
* to tune.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Atomically write `content` to `filePath`.
|
|
21
|
+
*
|
|
22
|
+
* Writes to a sibling temp file in the same directory, then renames over the
|
|
23
|
+
* destination. The parent directory is created if it doesn't exist. Records
|
|
24
|
+
* the content hash so subsequent watcher events can be identified as our own
|
|
25
|
+
* writes via {@link isOwnWrite}.
|
|
26
|
+
*/
|
|
27
|
+
export declare function atomicWriteFile(filePath: string, content: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns true if `content` matches a recent own-write of `filePath`.
|
|
30
|
+
*
|
|
31
|
+
* Watchers should call this after reading the file from disk to decide
|
|
32
|
+
* whether an observed change was caused by this process (and therefore
|
|
33
|
+
* should not trigger a reload).
|
|
34
|
+
*/
|
|
35
|
+
export declare function isOwnWrite(filePath: string, content: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Clears the recorded own-write hashes for a path (or all paths if omitted).
|
|
38
|
+
* Intended for tests.
|
|
39
|
+
*/
|
|
40
|
+
export declare function clearOwnWriteHistory(filePath?: string): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type DiagnosticCode, type ErrorCategory, type ErrorCode } from './error-codes';
|
|
2
|
+
/**
|
|
3
|
+
* One finding about the package, located as precisely as the check that made
|
|
4
|
+
* it can say (#639). A JSON pointer for a JSON file, a line and column for
|
|
5
|
+
* TypeScript.
|
|
6
|
+
*/
|
|
7
|
+
export interface Diagnostic {
|
|
8
|
+
severity: 'error' | 'warning';
|
|
9
|
+
/** One of `DIAGNOSTIC_CODES` in `error-codes.ts`; the contract, unlike the message. */
|
|
10
|
+
code: DiagnosticCode;
|
|
11
|
+
message: string;
|
|
12
|
+
/** Relative to the package root, with forward slashes. */
|
|
13
|
+
file?: string;
|
|
14
|
+
/** RFC 6901, into `file`, when `file` is JSON. */
|
|
15
|
+
pointer?: string;
|
|
16
|
+
/** 1-based, when `file` is source code. */
|
|
17
|
+
line?: number;
|
|
18
|
+
/** 1-based, when `file` is source code. */
|
|
19
|
+
column?: number;
|
|
20
|
+
resource?: {
|
|
21
|
+
type: string;
|
|
22
|
+
identifier: string;
|
|
23
|
+
};
|
|
24
|
+
hint?: string;
|
|
25
|
+
/** The tick a logic error was thrown in, when it was thrown in one. */
|
|
26
|
+
tick?: number;
|
|
27
|
+
/** The team whose logic threw, when one team's did. */
|
|
28
|
+
team?: {
|
|
29
|
+
teamId: string;
|
|
30
|
+
index: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Where a diagnostic points, as a person reads it: `file:line:column` for
|
|
35
|
+
* source, `file#pointer` for JSON, or nothing when it names no file.
|
|
36
|
+
*/
|
|
37
|
+
export declare function diagnosticLocation(diagnostic: Diagnostic): string | undefined;
|
|
38
|
+
export interface CliErrorOptions {
|
|
39
|
+
/** What to do about it, printed on its own line and carried in the envelope. */
|
|
40
|
+
hint?: string;
|
|
41
|
+
diagnostics?: Diagnostic[];
|
|
42
|
+
/** Structured detail a caller may branch on, such as a validator's rejections. */
|
|
43
|
+
details?: Record<string, unknown>;
|
|
44
|
+
cause?: unknown;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A command failure, with the stable code a script branches on.
|
|
48
|
+
*
|
|
49
|
+
* Command handlers throw this instead of printing and returning (or calling
|
|
50
|
+
* `process.exit`). The single catch in `cli.ts` turns it into the exit code its
|
|
51
|
+
* category maps to, and into the failure envelope under `--json`.
|
|
52
|
+
*
|
|
53
|
+
* The code is required, so the compiler catches a failure without one. The
|
|
54
|
+
* message is for people, may span lines, and is not part of the contract.
|
|
55
|
+
*/
|
|
56
|
+
export declare class CliError extends Error {
|
|
57
|
+
readonly code: ErrorCode;
|
|
58
|
+
readonly hint: string | undefined;
|
|
59
|
+
readonly diagnostics: Diagnostic[];
|
|
60
|
+
readonly details: Record<string, unknown> | undefined;
|
|
61
|
+
constructor(code: ErrorCode, message: string, options?: CliErrorOptions);
|
|
62
|
+
get category(): ErrorCategory;
|
|
63
|
+
get exitCode(): number;
|
|
64
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Parser Client - Extracts text content from documents for LLM consumption
|
|
3
|
+
*
|
|
4
|
+
* Currently supports PDF files using the unpdf library for local extraction.
|
|
5
|
+
*/
|
|
6
|
+
import type { ExtractTextResponse } from '@seriousgaming/sdk';
|
|
7
|
+
export declare class DocumentParserError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class DocumentParserClient {
|
|
11
|
+
/**
|
|
12
|
+
* Extract text content from a document.
|
|
13
|
+
*
|
|
14
|
+
* @param data - Raw binary data of the document
|
|
15
|
+
* @param mimeType - MIME type of the document
|
|
16
|
+
* @returns Extracted text content and source MIME type
|
|
17
|
+
*/
|
|
18
|
+
extractText(data: Buffer | Uint8Array, mimeType: string): Promise<ExtractTextResponse>;
|
|
19
|
+
private extractPdf;
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable loader
|
|
3
|
+
*
|
|
4
|
+
* Loads environment variables from .env file and process environment
|
|
5
|
+
* Cross-platform compatible (Windows, macOS, Linux)
|
|
6
|
+
*/
|
|
7
|
+
export interface EnvironmentConfig {
|
|
8
|
+
elevenLabsApiKey?: string;
|
|
9
|
+
ttsQuickModel?: string;
|
|
10
|
+
ttsStandardModel?: string;
|
|
11
|
+
ttsExpertModel?: string;
|
|
12
|
+
ttsVoicePresets?: Record<string, string>;
|
|
13
|
+
seriousGamingApiKey?: string;
|
|
14
|
+
seriousGamingApiHost?: string;
|
|
15
|
+
defaultPublisher?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parse .env file content
|
|
19
|
+
* Handles comments, empty lines, and quoted values
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseEnvFile(content: string): Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Load environment configuration from the global settings file, .env file and
|
|
24
|
+
* process environment.
|
|
25
|
+
*
|
|
26
|
+
* Priority (lowest to highest):
|
|
27
|
+
* 0. Global settings file (~/.seriousgaming-sdk/config.json)
|
|
28
|
+
* 1. .env file (if exists)
|
|
29
|
+
* 2. process.env
|
|
30
|
+
* 3. flag values
|
|
31
|
+
*
|
|
32
|
+
* @param workingDir - Directory to look for .env file
|
|
33
|
+
* @param flags - CLI flag values (highest priority)
|
|
34
|
+
* @returns Merged environment configuration
|
|
35
|
+
*/
|
|
36
|
+
export declare function loadEnvironmentConfig(workingDir: string, flags?: {
|
|
37
|
+
seriousGamingApiKey?: string;
|
|
38
|
+
seriousGamingApiHost?: string;
|
|
39
|
+
defaultPublisher?: string;
|
|
40
|
+
}): EnvironmentConfig;
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every code a failed command can report, with the category that decides its
|
|
3
|
+
* exit code.
|
|
4
|
+
*
|
|
5
|
+
* The codes are the contract (#639): a script or an agent branches on the
|
|
6
|
+
* code, never on the message, so a code is never renamed or moved to another
|
|
7
|
+
* category without a major version. Exported whole so the docs can list it
|
|
8
|
+
* from the source rather than from a copy (#645).
|
|
9
|
+
*/
|
|
10
|
+
/** What kind of failure a code is, which is what the exit code reports. */
|
|
11
|
+
export type ErrorCategory = 'internal' | 'usage' | 'package' | 'refused' | 'environment';
|
|
12
|
+
/**
|
|
13
|
+
* The exit code for each category. 0 is success and is no category's.
|
|
14
|
+
*
|
|
15
|
+
* - 1 `internal`: a bug in the CLI, never the caller's doing
|
|
16
|
+
* - 2 `usage`: the command was called wrongly: a bad flag or argument, missing
|
|
17
|
+
* input, or a prompt it needs and has no terminal to ask on
|
|
18
|
+
* - 3 `package`: the package is invalid: schema or validation failures, a
|
|
19
|
+
* logic file that will not bundle
|
|
20
|
+
* - 4 `refused`: the game refused: denied, a validator rejection, a conflict,
|
|
21
|
+
* a failed tick, a superseded write
|
|
22
|
+
* - 5 `environment`: something outside the package: no session, a port in use,
|
|
23
|
+
* a lock held, an out-of-date dev server, the platform unreachable
|
|
24
|
+
*/
|
|
25
|
+
export declare const EXIT_CODES: Readonly<Record<ErrorCategory, number>>;
|
|
26
|
+
export interface ErrorCodeEntry {
|
|
27
|
+
category: ErrorCategory;
|
|
28
|
+
/** One sentence saying when the code is reported. */
|
|
29
|
+
description: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const ERROR_CODES: {
|
|
32
|
+
readonly INTERNAL: {
|
|
33
|
+
readonly category: "internal";
|
|
34
|
+
readonly description: "An unexpected failure inside the CLI. Please report it.";
|
|
35
|
+
};
|
|
36
|
+
readonly USAGE_UNKNOWN_COMMAND: {
|
|
37
|
+
readonly category: "usage";
|
|
38
|
+
readonly description: "The command or subcommand does not exist.";
|
|
39
|
+
};
|
|
40
|
+
readonly USAGE_REMOVED_COMMAND: {
|
|
41
|
+
readonly category: "usage";
|
|
42
|
+
readonly description: "The command was removed in an earlier release; the hint names what replaces it.";
|
|
43
|
+
};
|
|
44
|
+
readonly USAGE_BAD_FLAG: {
|
|
45
|
+
readonly category: "usage";
|
|
46
|
+
readonly description: "A flag is unknown, has a value the command cannot use, or is combined with one it cannot be.";
|
|
47
|
+
};
|
|
48
|
+
readonly USAGE_BAD_ARGUMENT: {
|
|
49
|
+
readonly category: "usage";
|
|
50
|
+
readonly description: "A positional argument has a value the command cannot use.";
|
|
51
|
+
};
|
|
52
|
+
readonly USAGE_MISSING_ARGUMENT: {
|
|
53
|
+
readonly category: "usage";
|
|
54
|
+
readonly description: "A required argument or flag was not given.";
|
|
55
|
+
};
|
|
56
|
+
readonly USAGE_MISSING_INPUT: {
|
|
57
|
+
readonly category: "usage";
|
|
58
|
+
readonly description: "The command needs input (a JSON definition, settings or a patch) and none was given as an argument, with --file or on stdin.";
|
|
59
|
+
};
|
|
60
|
+
readonly USAGE_NOT_APPLICABLE: {
|
|
61
|
+
readonly category: "usage";
|
|
62
|
+
readonly description: "The command or flag does not apply to this package or session, such as --team on a single-team game.";
|
|
63
|
+
};
|
|
64
|
+
readonly PROMPT_REQUIRED: {
|
|
65
|
+
readonly category: "usage";
|
|
66
|
+
readonly description: "The command would have to ask a question, and prompts are off: there is no terminal, --json or SERIOUSGAMING_JSON is set, or CI is set.";
|
|
67
|
+
};
|
|
68
|
+
readonly INPUT_INVALID: {
|
|
69
|
+
readonly category: "usage";
|
|
70
|
+
readonly description: "Input given to the command is not valid JSON, or does not match the shape it must have.";
|
|
71
|
+
};
|
|
72
|
+
readonly FILE_NOT_FOUND: {
|
|
73
|
+
readonly category: "usage";
|
|
74
|
+
readonly description: "A file named on the command line does not exist or cannot be read.";
|
|
75
|
+
};
|
|
76
|
+
readonly RESOURCE_TYPE_UNKNOWN: {
|
|
77
|
+
readonly category: "usage";
|
|
78
|
+
readonly description: "The resource type does not exist, or does not support this operation.";
|
|
79
|
+
};
|
|
80
|
+
readonly RESOURCE_NOT_FOUND: {
|
|
81
|
+
readonly category: "usage";
|
|
82
|
+
readonly description: "The package has no resource of that type with that identifier.";
|
|
83
|
+
};
|
|
84
|
+
readonly RESOURCE_EXISTS: {
|
|
85
|
+
readonly category: "usage";
|
|
86
|
+
readonly description: "A resource with that identifier, or in that slot, already exists.";
|
|
87
|
+
};
|
|
88
|
+
readonly BUILD_NOT_FOUND: {
|
|
89
|
+
readonly category: "usage";
|
|
90
|
+
readonly description: "The build output or bundle the command reads is missing. Run `build` (or `package bundle`) first.";
|
|
91
|
+
};
|
|
92
|
+
readonly PUBLISHER_MISSING: {
|
|
93
|
+
readonly category: "usage";
|
|
94
|
+
readonly description: "No publisher was given with --publisher, SERIOUSGAMING_PUBLISHER or platform.defaultPublisher.";
|
|
95
|
+
};
|
|
96
|
+
readonly PACKAGE_INVALID: {
|
|
97
|
+
readonly category: "package";
|
|
98
|
+
readonly description: "The package fails validation. The diagnostics say where. As a diagnostic code, a finding no finer code describes yet.";
|
|
99
|
+
};
|
|
100
|
+
readonly MANIFEST_NOT_FOUND: {
|
|
101
|
+
readonly category: "package";
|
|
102
|
+
readonly description: "There is no seriousgaming.sdk.json (or package.json) where the command looked.";
|
|
103
|
+
};
|
|
104
|
+
readonly MANIFEST_INVALID: {
|
|
105
|
+
readonly category: "package";
|
|
106
|
+
readonly description: "seriousgaming.sdk.json or package.json cannot be read, or is not valid.";
|
|
107
|
+
};
|
|
108
|
+
readonly BUNDLE_INVALID: {
|
|
109
|
+
readonly category: "package";
|
|
110
|
+
readonly description: "A resource's bundle file (such as engine.sdk.json) cannot be read, or is not valid.";
|
|
111
|
+
};
|
|
112
|
+
readonly LOGIC_NODE_BUILTIN: {
|
|
113
|
+
readonly category: "package";
|
|
114
|
+
readonly description: "Game logic imports a Node built-in, which is absent in production: logic runs on the JavaScript language alone.";
|
|
115
|
+
};
|
|
116
|
+
readonly LOGIC_BUNDLE_FAILED: {
|
|
117
|
+
readonly category: "package";
|
|
118
|
+
readonly description: "A logic file does not bundle: a syntax error, or an import that does not resolve.";
|
|
119
|
+
};
|
|
120
|
+
readonly SCHEMA_INVALID: {
|
|
121
|
+
readonly category: "package";
|
|
122
|
+
readonly description: "A bundle or the manifest does not match the SDK's schema. The diagnostic's pointer names the value.";
|
|
123
|
+
};
|
|
124
|
+
readonly JSON_INVALID: {
|
|
125
|
+
readonly category: "package";
|
|
126
|
+
readonly description: "A bundle file is not valid JSON.";
|
|
127
|
+
};
|
|
128
|
+
readonly BUNDLE_MISSING: {
|
|
129
|
+
readonly category: "package";
|
|
130
|
+
readonly description: "A resource directory holds no bundle file.";
|
|
131
|
+
};
|
|
132
|
+
readonly REMOVED_FIELD: {
|
|
133
|
+
readonly category: "package";
|
|
134
|
+
readonly description: "A bundle or the manifest carries a field the SDK no longer reads. The hint says what replaced it.";
|
|
135
|
+
};
|
|
136
|
+
readonly LAYOUT_OUTDATED: {
|
|
137
|
+
readonly category: "package";
|
|
138
|
+
readonly description: "A directory or bundle file sits where an earlier version of the SDK kept it. The hint says where it goes now.";
|
|
139
|
+
};
|
|
140
|
+
readonly FEATURE_UNSUPPORTED: {
|
|
141
|
+
readonly category: "package";
|
|
142
|
+
readonly description: "The manifest's `requires` names an optional feature this version of the SDK does not support.";
|
|
143
|
+
};
|
|
144
|
+
readonly REFERENCE_UNKNOWN: {
|
|
145
|
+
readonly category: "package";
|
|
146
|
+
readonly description: "A `reads`, `writes`, `settings`, `configures` or `endpoints` entry names something the package does not declare.";
|
|
147
|
+
};
|
|
148
|
+
readonly SETTINGS_UNKNOWN: {
|
|
149
|
+
readonly category: "package";
|
|
150
|
+
readonly description: "A scenario overrides a settings resource the package does not declare.";
|
|
151
|
+
};
|
|
152
|
+
readonly SETTINGS_UNKNOWN_KEY: {
|
|
153
|
+
readonly category: "package";
|
|
154
|
+
readonly description: "A scenario overrides a key that its settings resource does not declare.";
|
|
155
|
+
};
|
|
156
|
+
readonly SETTINGS_INVALID: {
|
|
157
|
+
readonly category: "package";
|
|
158
|
+
readonly description: "A scenario's override does not match its settings resource's schema.";
|
|
159
|
+
};
|
|
160
|
+
readonly SETTINGS_RESERVED: {
|
|
161
|
+
readonly category: "package";
|
|
162
|
+
readonly description: "A settings resource is named `game`, which is reserved for the built-in game settings.";
|
|
163
|
+
};
|
|
164
|
+
readonly SETTINGS_LOCKED: {
|
|
165
|
+
readonly category: "package";
|
|
166
|
+
readonly description: "A scenario overrides a setting the game locks with `readOnly`, in its settings schema or its `gameSettingsConstraints`.";
|
|
167
|
+
};
|
|
168
|
+
readonly GAME_CONSTRAINT_INVALID: {
|
|
169
|
+
readonly category: "package";
|
|
170
|
+
readonly description: "A `gameSettingsConstraints` entry widens the SDK schema for the `game` settings rather than narrowing it.";
|
|
171
|
+
};
|
|
172
|
+
readonly GAME_CONSTRAINT_VIOLATED: {
|
|
173
|
+
readonly category: "package";
|
|
174
|
+
readonly description: "The game's own value for a `game` setting breaks its `gameSettingsConstraints`.";
|
|
175
|
+
};
|
|
176
|
+
readonly LOGIC_EXPORT_MISSING: {
|
|
177
|
+
readonly category: "package";
|
|
178
|
+
readonly description: "A logic file is missing, or does not export the functions its resource needs.";
|
|
179
|
+
};
|
|
180
|
+
readonly READ_NEVER_WRITTEN: {
|
|
181
|
+
readonly category: "package";
|
|
182
|
+
readonly description: "A warning: a resource reads a capability nothing in the package writes, so it only ever holds its defaults.";
|
|
183
|
+
};
|
|
184
|
+
readonly NO_TERMINATION: {
|
|
185
|
+
readonly category: "package";
|
|
186
|
+
readonly description: "A warning: the game declares neither `maxTicks` nor a tick controller, so only its engine can end it.";
|
|
187
|
+
};
|
|
188
|
+
readonly EDITOR_ENDPOINT_STATEFUL: {
|
|
189
|
+
readonly category: "package";
|
|
190
|
+
readonly description: "The scenario editor lists an endpoint that declares `reads`, `writes` or `actions`, which need a session the editor does not have.";
|
|
191
|
+
};
|
|
192
|
+
readonly EXTERNAL_REQUEST_NOT_OBJECT: {
|
|
193
|
+
readonly category: "package";
|
|
194
|
+
readonly description: "An external endpoint's `requestSchema` does not declare `\"type\": \"object\"` at the top, which a caller outside the game needs to pass named arguments.";
|
|
195
|
+
};
|
|
196
|
+
readonly ENDPOINT_UNREQUESTED: {
|
|
197
|
+
readonly category: "package";
|
|
198
|
+
readonly description: "A warning: an internal endpoint no user interface lists in its `endpoints`.";
|
|
199
|
+
};
|
|
200
|
+
readonly PLATFORM_REJECTED: {
|
|
201
|
+
readonly category: "package";
|
|
202
|
+
readonly description: "The platform refused the uploaded package as invalid.";
|
|
203
|
+
};
|
|
204
|
+
readonly VERSION_EXISTS: {
|
|
205
|
+
readonly category: "package";
|
|
206
|
+
readonly description: "The platform already has this version of the package. Bump it and publish again.";
|
|
207
|
+
};
|
|
208
|
+
readonly REFUSED_DENIED: {
|
|
209
|
+
readonly category: "refused";
|
|
210
|
+
readonly description: "The session refused the command (the 'denied' outcome).";
|
|
211
|
+
};
|
|
212
|
+
readonly REFUSED_VALIDATION: {
|
|
213
|
+
readonly category: "refused";
|
|
214
|
+
readonly description: "A validator rejected the write (the 'validation-rejected' outcome). error.details.rejections lists why.";
|
|
215
|
+
};
|
|
216
|
+
readonly REFUSED_CONFLICT: {
|
|
217
|
+
readonly category: "refused";
|
|
218
|
+
readonly description: "The write conflicted with a concurrent tick (the 'conflict' outcome).";
|
|
219
|
+
};
|
|
220
|
+
readonly REFUSED_SUPERSEDED: {
|
|
221
|
+
readonly category: "refused";
|
|
222
|
+
readonly description: "The write arrived after the tick it was for (the 'superseded' outcome).";
|
|
223
|
+
};
|
|
224
|
+
readonly TICK_FAILED: {
|
|
225
|
+
readonly category: "refused";
|
|
226
|
+
readonly description: "The tick failed, usually because game logic threw (the 'tick-failed' outcome).";
|
|
227
|
+
};
|
|
228
|
+
readonly SESSION_ERROR: {
|
|
229
|
+
readonly category: "refused";
|
|
230
|
+
readonly description: "The session failed the command unexpectedly (the 'error' outcome).";
|
|
231
|
+
};
|
|
232
|
+
readonly INVALID_REQUEST: {
|
|
233
|
+
readonly category: "refused";
|
|
234
|
+
readonly description: "The endpoint request failed its requestSchema, so the handler did not run.";
|
|
235
|
+
};
|
|
236
|
+
readonly HANDLER_ERROR: {
|
|
237
|
+
readonly category: "refused";
|
|
238
|
+
readonly description: "The endpoint's handler threw, or ran past its execution bound.";
|
|
239
|
+
};
|
|
240
|
+
readonly INVALID_RESPONSE: {
|
|
241
|
+
readonly category: "refused";
|
|
242
|
+
readonly description: "What the endpoint's handler returned broke its declaration.";
|
|
243
|
+
};
|
|
244
|
+
readonly LOGIC_ERROR: {
|
|
245
|
+
readonly category: "refused";
|
|
246
|
+
readonly description: "Game logic (an engine, hook, endpoint, validator or tick controller) threw. A diagnostic, not an error code: it sits in `diagnostics` under the command's TICK_FAILED, SESSION_ERROR or HANDLER_ERROR, with the file, line and column it threw at.";
|
|
247
|
+
};
|
|
248
|
+
readonly SETTINGS_STALE: {
|
|
249
|
+
readonly category: "refused";
|
|
250
|
+
readonly description: "The package changed on disk since the session started in a way that applies only at initialisation (a setting, a manifest field such as `teams`, or a capability removed or moved to another scope), so a command that advances or changes play was refused. Run `sdk init`.";
|
|
251
|
+
};
|
|
252
|
+
readonly NO_SESSION: {
|
|
253
|
+
readonly category: "environment";
|
|
254
|
+
readonly description: "No dev server is running for this package, and the command will not start one.";
|
|
255
|
+
};
|
|
256
|
+
readonly SESSION_STALE: {
|
|
257
|
+
readonly category: "environment";
|
|
258
|
+
readonly description: "The running session was started from an out-of-date package and must restart.";
|
|
259
|
+
};
|
|
260
|
+
readonly LOCK_HELD: {
|
|
261
|
+
readonly category: "environment";
|
|
262
|
+
readonly description: "A dev server is already running for this package.";
|
|
263
|
+
};
|
|
264
|
+
readonly PORT_IN_USE: {
|
|
265
|
+
readonly category: "environment";
|
|
266
|
+
readonly description: "No free port was found to listen on.";
|
|
267
|
+
};
|
|
268
|
+
readonly DEV_SERVER_OUTDATED: {
|
|
269
|
+
readonly category: "environment";
|
|
270
|
+
readonly description: "The running dev server does not understand the command: it is older than this CLI. Restart it.";
|
|
271
|
+
};
|
|
272
|
+
readonly DEV_SERVER_UNREACHABLE: {
|
|
273
|
+
readonly category: "environment";
|
|
274
|
+
readonly description: "The dev server the lock file names does not answer.";
|
|
275
|
+
};
|
|
276
|
+
readonly DEV_SERVER_UNRESPONSIVE: {
|
|
277
|
+
readonly category: "environment";
|
|
278
|
+
readonly description: "A dev server holds the lock and accepts connections but does not answer, most often because logic is stuck in a synchronous loop. Run `sdk dev stop`.";
|
|
279
|
+
};
|
|
280
|
+
readonly DEV_SERVER_START_FAILED: {
|
|
281
|
+
readonly category: "environment";
|
|
282
|
+
readonly description: "A dev server could not be started.";
|
|
283
|
+
};
|
|
284
|
+
readonly DEV_SERVER_STOP_FAILED: {
|
|
285
|
+
readonly category: "environment";
|
|
286
|
+
readonly description: "The dev server could not be stopped.";
|
|
287
|
+
};
|
|
288
|
+
readonly LLM_NOT_CONFIGURED: {
|
|
289
|
+
readonly category: "environment";
|
|
290
|
+
readonly description: "Logic called generateText, and the dev server or in-process session running it has no platform API key configured.";
|
|
291
|
+
};
|
|
292
|
+
readonly PLATFORM_UNREACHABLE: {
|
|
293
|
+
readonly category: "environment";
|
|
294
|
+
readonly description: "The Serious Gaming platform could not be reached.";
|
|
295
|
+
};
|
|
296
|
+
readonly PLATFORM_UNAUTHORISED: {
|
|
297
|
+
readonly category: "environment";
|
|
298
|
+
readonly description: "The platform refused the API key, or its holder lacks the role the call needs.";
|
|
299
|
+
};
|
|
300
|
+
readonly PLATFORM_ERROR: {
|
|
301
|
+
readonly category: "environment";
|
|
302
|
+
readonly description: "The platform failed the request.";
|
|
303
|
+
};
|
|
304
|
+
readonly API_KEY_MISSING: {
|
|
305
|
+
readonly category: "environment";
|
|
306
|
+
readonly description: "No API key is configured: set SERIOUSGAMING_API_KEY, add it to .env, or pass --api-key.";
|
|
307
|
+
};
|
|
308
|
+
readonly INSTALL_FAILED: {
|
|
309
|
+
readonly category: "environment";
|
|
310
|
+
readonly description: "Installing a new package's dependencies failed.";
|
|
311
|
+
};
|
|
312
|
+
readonly SDK_INCOMPLETE: {
|
|
313
|
+
readonly category: "environment";
|
|
314
|
+
readonly description: "This install of the SDK tools is missing files it ships with, such as its docs.";
|
|
315
|
+
};
|
|
316
|
+
readonly SETTINGS_FILE_INVALID: {
|
|
317
|
+
readonly category: "environment";
|
|
318
|
+
readonly description: "The global settings file (~/.seriousgaming-sdk/config.json) cannot be parsed.";
|
|
319
|
+
};
|
|
320
|
+
readonly WRITE_FAILED: {
|
|
321
|
+
readonly category: "environment";
|
|
322
|
+
readonly description: "A file or directory could not be written, moved or removed.";
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
export type ErrorCode = keyof typeof ERROR_CODES;
|
|
326
|
+
/**
|
|
327
|
+
* The codes a diagnostic carries: one finding each, located in a file. A
|
|
328
|
+
* failure's `error.code` says what kind of failure it was; its diagnostics say
|
|
329
|
+
* what was found and where. LOGIC_ERROR is only ever a diagnostic.
|
|
330
|
+
*/
|
|
331
|
+
export declare const DIAGNOSTIC_CODES: readonly ["PACKAGE_INVALID", "SCHEMA_INVALID", "JSON_INVALID", "BUNDLE_MISSING", "REMOVED_FIELD", "LAYOUT_OUTDATED", "FEATURE_UNSUPPORTED", "REFERENCE_UNKNOWN", "SETTINGS_UNKNOWN", "SETTINGS_UNKNOWN_KEY", "SETTINGS_INVALID", "SETTINGS_RESERVED", "SETTINGS_LOCKED", "GAME_CONSTRAINT_INVALID", "GAME_CONSTRAINT_VIOLATED", "LOGIC_EXPORT_MISSING", "LOGIC_NODE_BUILTIN", "LOGIC_BUNDLE_FAILED", "READ_NEVER_WRITTEN", "NO_TERMINATION", "EDITOR_ENDPOINT_STATEFUL", "EXTERNAL_REQUEST_NOT_OBJECT", "ENDPOINT_UNREQUESTED", "LOGIC_ERROR"];
|
|
332
|
+
export type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[number];
|
|
333
|
+
export declare function categoryOf(code: ErrorCode): ErrorCategory;
|
|
334
|
+
export declare function exitCodeOf(code: ErrorCode): number;
|
|
335
|
+
export declare function isErrorCode(value: unknown): value is ErrorCode;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for narrowing an unknown caught value to its reportable parts.
|
|
3
|
+
*
|
|
4
|
+
* `catch (error: unknown)` is the correct shape, but the
|
|
5
|
+
* `error instanceof Error ? error.message : 'Unknown error'` extraction it
|
|
6
|
+
* forces recurs throughout the dev server. This collapses it to one call.
|
|
7
|
+
*/
|
|
8
|
+
/** The message of a caught value, or `fallback` when it carries none. */
|
|
9
|
+
export declare function errorMessage(error: unknown, fallback?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* A refusal the caller cannot retry their way out of: the team count is at the
|
|
12
|
+
* maximum, a shared-state session has already ticked, or the participant named
|
|
13
|
+
* is not where the caller thinks. Mapped to a terminal `{ kind: 'denied' }`
|
|
14
|
+
* mutation outcome (SPECIFICATION.md §12.5.1), which tells a surface to explain
|
|
15
|
+
* itself rather than loop.
|
|
16
|
+
*/
|
|
17
|
+
export declare class DeniedError extends Error {
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global settings loader
|
|
3
|
+
*
|
|
4
|
+
* Reads the user-owned global settings file at `~/.seriousgaming-sdk/config.json`
|
|
5
|
+
* (override with the `SERIOUSGAMING_SDK_CONFIG` environment variable). The file
|
|
6
|
+
* stores API keys and defaults once so every project picks them up.
|
|
7
|
+
*
|
|
8
|
+
* This is the lowest-priority configuration source: `.env` files, environment
|
|
9
|
+
* variables, and CLI flags all override it (see env-loader.ts). The file is
|
|
10
|
+
* plaintext and must not be committed to git.
|
|
11
|
+
*
|
|
12
|
+
* Cross-platform: `os.homedir()` resolves the home directory on Windows, macOS
|
|
13
|
+
* and Linux without any platform branching.
|
|
14
|
+
*/
|
|
15
|
+
import type { GlobalSettings } from '@seriousgaming/sdk';
|
|
16
|
+
/** Environment variable that overrides the global settings file location. */
|
|
17
|
+
export declare const GLOBAL_SETTINGS_ENV_VAR = "SERIOUSGAMING_SDK_CONFIG";
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the absolute path to the global settings file.
|
|
20
|
+
*
|
|
21
|
+
* Uses `SERIOUSGAMING_SDK_CONFIG` if set (which must be an absolute path),
|
|
22
|
+
* otherwise `~/.seriousgaming-sdk/config.json`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveGlobalSettingsPath(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Load and parse the global settings file.
|
|
27
|
+
*
|
|
28
|
+
* Returns an empty object if the file does not exist. A malformed file is
|
|
29
|
+
* surfaced as a warning and treated as empty, so a broken global file never
|
|
30
|
+
* blocks a command that has its keys available from another source.
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadGlobalSettings(path?: string): GlobalSettings;
|
|
33
|
+
/**
|
|
34
|
+
* Load the settings for a read-modify-write.
|
|
35
|
+
*
|
|
36
|
+
* Unlike {@link loadGlobalSettings}, a file that exists but cannot be read or
|
|
37
|
+
* parsed is an error rather than an empty object. The lenient reader is
|
|
38
|
+
* correct on the read path, where a broken global file must not block a
|
|
39
|
+
* command whose keys come from elsewhere; on the write path it would serialise
|
|
40
|
+
* that empty object back over the file and destroy every key it failed to
|
|
41
|
+
* parse, which is how a stray `config set` used to take an API key with it
|
|
42
|
+
* (#538).
|
|
43
|
+
*/
|
|
44
|
+
export declare function loadGlobalSettingsForWrite(path?: string): GlobalSettings;
|
|
45
|
+
/**
|
|
46
|
+
* Write global settings to disk, creating the parent directory if needed and
|
|
47
|
+
* applying a restrictive file mode on platforms that support it (POSIX).
|
|
48
|
+
*
|
|
49
|
+
* The write goes to a sibling temporary file and is renamed into place, so an
|
|
50
|
+
* interrupted write cannot leave a truncated settings file behind. A truncated
|
|
51
|
+
* file is unparseable, and an unparseable file is one a later `config set` has
|
|
52
|
+
* to refuse rather than repair (#538).
|
|
53
|
+
*/
|
|
54
|
+
export declare function saveGlobalSettings(settings: GlobalSettings, path?: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Read a single dot-path value from a settings object. Returns `undefined`
|
|
57
|
+
* when the key is not set. Throws if the key is not a recognised setting.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getGlobalSetting(settings: GlobalSettings, key: string): string | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Return a new settings object with the dot-path key set to `value`,
|
|
62
|
+
* creating intermediate objects as needed. Throws if the key is not a
|
|
63
|
+
* recognised setting.
|
|
64
|
+
*/
|
|
65
|
+
export declare function setGlobalSetting(settings: GlobalSettings, key: string, value: string): GlobalSettings;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Client - generates text through the Serious Gaming platform's LLM API.
|
|
3
|
+
*
|
|
4
|
+
* POSTs spec §17.3 LLMGenerateOptions to `<host>/api/v0/llm/generate`, which
|
|
5
|
+
* runs the same generateText pipeline production game code uses. Tier-to-model
|
|
6
|
+
* resolution (with fallback), prompt caching, and content-sequence validation
|
|
7
|
+
* all happen server-side; this client is a thin authenticated pass-through.
|
|
8
|
+
*/
|
|
9
|
+
import type { LLMGenerateOptions, LLMResponse } from '@seriousgaming/sdk';
|
|
10
|
+
export declare const LLM_NOT_CONFIGURED = "LLM_NOT_CONFIGURED";
|
|
11
|
+
/** How to configure the key, for a command reporting LLM_NOT_CONFIGURED. */
|
|
12
|
+
export declare const LLM_NOT_CONFIGURED_HINT: string;
|
|
13
|
+
export declare class LLMClientError extends Error {
|
|
14
|
+
/** Set when the failure is the environment's, not the call's. */
|
|
15
|
+
readonly code?: typeof LLM_NOT_CONFIGURED | undefined;
|
|
16
|
+
constructor(message: string,
|
|
17
|
+
/** Set when the failure is the environment's, not the call's. */
|
|
18
|
+
code?: typeof LLM_NOT_CONFIGURED | undefined);
|
|
19
|
+
}
|
|
20
|
+
export interface LLMClientConfig {
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
apiHost?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare class LLMClient {
|
|
25
|
+
private apiKey?;
|
|
26
|
+
private apiHost;
|
|
27
|
+
constructor(config: LLMClientConfig);
|
|
28
|
+
/**
|
|
29
|
+
* Generate text through the platform LLM API.
|
|
30
|
+
* Supports both simple string prompts and complex options.
|
|
31
|
+
*/
|
|
32
|
+
generateText(optionsOrPrompt: LLMGenerateOptions | string): Promise<LLMResponse>;
|
|
33
|
+
private mapErrorMessage;
|
|
34
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple logging utility with verbose mode support
|
|
3
|
+
* Avoids external dependencies by using native console methods
|
|
4
|
+
*/
|
|
5
|
+
export declare function setVerboseMode(verbose: boolean): void;
|
|
6
|
+
export declare function getVerboseMode(): boolean;
|
|
7
|
+
export declare const logger: {
|
|
8
|
+
/**
|
|
9
|
+
* Log a message that should always appear (errors)
|
|
10
|
+
*/
|
|
11
|
+
error: (message: string, ...args: unknown[]) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Log a warning message (always appears)
|
|
14
|
+
*/
|
|
15
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Log a success message (always appears)
|
|
18
|
+
*/
|
|
19
|
+
success: (message: string, ...args: unknown[]) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Log an info message (only in verbose mode)
|
|
22
|
+
*/
|
|
23
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Log a debug message (only in verbose mode)
|
|
26
|
+
*/
|
|
27
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Log output section header
|
|
30
|
+
*/
|
|
31
|
+
section: (message: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Log a blank line (only in verbose mode)
|
|
34
|
+
*/
|
|
35
|
+
newline: () => void;
|
|
36
|
+
};
|