@dreamboard-games/sdk 0.4.0-alpha.8 → 0.5.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +49 -11
  2. package/dist/authoring/index.d.ts +6 -14
  3. package/dist/authoring/index.js +11 -547
  4. package/dist/authoring/index.js.map +1 -1
  5. package/dist/authoring-compiler.d.ts +27 -0
  6. package/dist/authoring-compiler.js +11 -0
  7. package/dist/authoring-compiler.js.map +1 -0
  8. package/dist/authoring-materialize-cli.d.ts +1 -0
  9. package/dist/authoring-materialize-cli.js +45 -0
  10. package/dist/authoring-materialize-cli.js.map +1 -0
  11. package/dist/browser-interaction.d.ts +22 -22
  12. package/dist/{chunk-3BLN5POZ.js → chunk-2GQIALJL.js} +51 -15
  13. package/dist/chunk-2GQIALJL.js.map +1 -0
  14. package/dist/chunk-533O7C4L.js +7095 -0
  15. package/dist/chunk-533O7C4L.js.map +1 -0
  16. package/dist/{chunk-44N3T2A5.js → chunk-6LMESVGT.js} +9 -28
  17. package/dist/chunk-6LMESVGT.js.map +1 -0
  18. package/dist/{chunk-ZYONCTZ2.js → chunk-DQS2EG5E.js} +3 -3
  19. package/dist/{chunk-ZYONCTZ2.js.map → chunk-DQS2EG5E.js.map} +1 -1
  20. package/dist/chunk-EOEA3I64.js +1864 -0
  21. package/dist/chunk-EOEA3I64.js.map +1 -0
  22. package/dist/{chunk-B2YBS3SG.js → chunk-FL67RDID.js} +41 -13
  23. package/dist/chunk-FL67RDID.js.map +1 -0
  24. package/dist/{chunk-2TAKLJJD.js → chunk-HIH6Y4FA.js} +222 -1267
  25. package/dist/chunk-HIH6Y4FA.js.map +1 -0
  26. package/dist/chunk-HUK4234C.js +166 -0
  27. package/dist/chunk-HUK4234C.js.map +1 -0
  28. package/dist/chunk-KGV2EUNN.js +532 -0
  29. package/dist/chunk-KGV2EUNN.js.map +1 -0
  30. package/dist/{chunk-VTK4TIXC.js → chunk-KRJPRYEA.js} +49 -4
  31. package/dist/chunk-KRJPRYEA.js.map +1 -0
  32. package/dist/chunk-KWHOFBDM.js +9 -0
  33. package/dist/chunk-KWHOFBDM.js.map +1 -0
  34. package/dist/{chunk-UC2UXAC6.js → chunk-LMHCGCA6.js} +2 -2
  35. package/dist/{chunk-XV27IQHA.js → chunk-N33CGX2F.js} +15 -85
  36. package/dist/chunk-N33CGX2F.js.map +1 -0
  37. package/dist/chunk-TXELBVTG.js +32 -0
  38. package/dist/chunk-TXELBVTG.js.map +1 -0
  39. package/dist/{chunk-2TRZSZGD.js → chunk-VRRR6QZT.js} +9 -12
  40. package/dist/chunk-VRRR6QZT.js.map +1 -0
  41. package/dist/chunk-VWTKGIYF.js +90 -0
  42. package/dist/chunk-VWTKGIYF.js.map +1 -0
  43. package/dist/{chunk-IYX5OO2K.js → chunk-XFMSLL3P.js} +133 -61
  44. package/dist/chunk-XFMSLL3P.js.map +1 -0
  45. package/dist/{chunk-YGQTL63W.js → chunk-ZSTCUJKZ.js} +4 -4
  46. package/dist/chunk-ZSTCUJKZ.js.map +1 -0
  47. package/dist/codegen.js +1 -1
  48. package/dist/{components-BTwSIjXj.d.ts → components-CNAt5J1p.d.ts} +1 -1
  49. package/dist/definitions-bZSBaPjj.d.ts +300 -0
  50. package/dist/{diagnostics-1BWjRo6-.d.ts → diagnostics-DIi3ina7.d.ts} +2 -1
  51. package/dist/digest.d.ts +8 -0
  52. package/dist/{index-CFTjJIXd.d.ts → index-CR69MyWr.d.ts} +2 -2
  53. package/dist/{index.d-C0PKOVbh.d.ts → index.d-Bw8AOcgp.d.ts} +532 -225
  54. package/dist/index.js +2 -2
  55. package/dist/package-set.d.ts +2 -2
  56. package/dist/package-set.js +2 -2
  57. package/dist/plugin-runtime-contract.d.ts +17 -0
  58. package/dist/plugin-runtime-contract.js +94 -0
  59. package/dist/plugin-runtime-contract.js.map +1 -0
  60. package/dist/{protocol-nS2ojsGr.d.ts → protocol-CVaSqPgX.d.ts} +54 -47
  61. package/dist/reducer/advanced.d.ts +5 -4
  62. package/dist/reducer/advanced.js +14 -108
  63. package/dist/reducer/advanced.js.map +1 -1
  64. package/dist/reducer-contract.d.ts +1 -1
  65. package/dist/reducer-contract.js +6 -4
  66. package/dist/reducer.d.ts +20 -98
  67. package/dist/reducer.js +28 -6050
  68. package/dist/reducer.js.map +1 -1
  69. package/dist/reference-games/index.d.ts +6 -198
  70. package/dist/reference-games/index.js +18 -200
  71. package/dist/reference-games/index.js.map +1 -1
  72. package/dist/runtime/primitives.d.ts +3 -3
  73. package/dist/runtime/primitives.js +5 -5
  74. package/dist/runtime/runtime-api.d.ts +1 -1
  75. package/dist/runtime/workspace-contract.d.ts +343 -11
  76. package/dist/runtime/workspace-contract.js +12 -6
  77. package/dist/{runtime-Dkfm1x2r.d.ts → runtime-C7Z2acNU.d.ts} +67 -31
  78. package/dist/{runtime-api-C6aWo9c0.d.ts → runtime-api-CgPuEVeF.d.ts} +4 -13
  79. package/dist/runtime.d.ts +7 -7
  80. package/dist/runtime.js +15 -11
  81. package/dist/runtime.js.map +1 -1
  82. package/dist/schema.d.ts +405 -0
  83. package/dist/{stale-contract-artifact-error-C5AaZPJ8.d.ts → stale-contract-artifact-error-XLaweZtF.d.ts} +1 -1
  84. package/dist/testing-compiler.d.ts +37 -0
  85. package/dist/testing-compiler.js +272 -0
  86. package/dist/testing-compiler.js.map +1 -0
  87. package/dist/testing-runtime.d.ts +98 -21
  88. package/dist/testing-runtime.js +154 -95
  89. package/dist/testing-runtime.js.map +1 -1
  90. package/dist/testing.d.ts +197 -156
  91. package/dist/testing.js +660 -372
  92. package/dist/testing.js.map +1 -1
  93. package/dist/types-DN4O7kH_.d.ts +122 -0
  94. package/dist/{types-CTeN_QAk.d.ts → types-q1Guidm5.d.ts} +4 -5
  95. package/dist/types.d.ts +0 -1
  96. package/dist/ui/components.d.ts +3 -2
  97. package/dist/ui/components.js +1 -1
  98. package/dist/ui/plugin-styles.css +1 -1
  99. package/dist/{ui-contract-Ue6SywvO.d.ts → ui-contract-BC4JpysE.d.ts} +2 -6
  100. package/dist/ui.d.ts +4 -3
  101. package/dist/ui.js +2 -2
  102. package/dist/{views-Qx-EHBP8.d.ts → views-D2Cfzr3h.d.ts} +17 -5
  103. package/package.json +41 -22
  104. package/REFERENCE.md +0 -22884
  105. package/dist/chunk-2TAKLJJD.js.map +0 -1
  106. package/dist/chunk-2TRZSZGD.js.map +0 -1
  107. package/dist/chunk-3BLN5POZ.js.map +0 -1
  108. package/dist/chunk-3OZMHZK3.js +0 -40
  109. package/dist/chunk-3OZMHZK3.js.map +0 -1
  110. package/dist/chunk-44N3T2A5.js.map +0 -1
  111. package/dist/chunk-5CQIJHGF.js +0 -663
  112. package/dist/chunk-5CQIJHGF.js.map +0 -1
  113. package/dist/chunk-B2YBS3SG.js.map +0 -1
  114. package/dist/chunk-IYX5OO2K.js.map +0 -1
  115. package/dist/chunk-VTK4TIXC.js.map +0 -1
  116. package/dist/chunk-VTNEWMWJ.js +0 -12
  117. package/dist/chunk-VTNEWMWJ.js.map +0 -1
  118. package/dist/chunk-XV27IQHA.js.map +0 -1
  119. package/dist/chunk-YGQTL63W.js.map +0 -1
  120. package/dist/types-B_3pObUV.d.ts +0 -192
  121. /package/dist/{chunk-UC2UXAC6.js.map → chunk-LMHCGCA6.js.map} +0 -0
@@ -0,0 +1,272 @@
1
+ import "./chunk-PZ5AY32C.js";
2
+
3
+ // src/testing/compile-scenario-replay.ts
4
+ import { createHash } from "crypto";
5
+ import { createRequire } from "module";
6
+ import {
7
+ lstat,
8
+ mkdtemp,
9
+ readFile,
10
+ realpath,
11
+ rm,
12
+ stat,
13
+ writeFile
14
+ } from "fs/promises";
15
+ import { tmpdir } from "os";
16
+ import path from "path";
17
+ import { pathToFileURL } from "url";
18
+ import { build } from "esbuild";
19
+ var scenarioSourceDigestVersion = "dreamboard-scenario-source-closure@1";
20
+ var syntheticSourceFile = "__dreamboard_compile_scenario_replay__.ts";
21
+ async function compileScenarioReplay(options) {
22
+ const source = await resolveScenarioSource(options.scenarioPath);
23
+ const syntheticSource = buildSyntheticSource(source);
24
+ const [
25
+ reducerEntry,
26
+ reducerAdvancedEntry,
27
+ testingEntry,
28
+ testingRuntimeEntry,
29
+ typesEntry
30
+ ] = await Promise.all([
31
+ resolveCurrentSdkFacade("reducer"),
32
+ resolveCurrentSdkFacade("reducer/advanced"),
33
+ resolveCurrentSdkFacade("testing"),
34
+ resolveCurrentSdkFacade("testing-runtime"),
35
+ resolveCurrentSdkFacade("types")
36
+ ]);
37
+ const bundled = await build({
38
+ absWorkingDir: source.projectRoot,
39
+ stdin: {
40
+ contents: syntheticSource,
41
+ loader: "ts",
42
+ resolveDir: source.projectRoot,
43
+ sourcefile: syntheticSourceFile
44
+ },
45
+ bundle: true,
46
+ alias: {
47
+ "@dreamboard-games/sdk/reducer": reducerEntry,
48
+ "@dreamboard-games/sdk/reducer/advanced": reducerAdvancedEntry,
49
+ "@dreamboard-games/sdk/testing": testingEntry,
50
+ "@dreamboard-games/sdk/testing-runtime": testingRuntimeEntry,
51
+ "@dreamboard-games/sdk/types": typesEntry,
52
+ zod: createRequire(import.meta.url).resolve("zod")
53
+ },
54
+ format: "esm",
55
+ platform: "node",
56
+ target: "node24",
57
+ sourcemap: "inline",
58
+ metafile: true,
59
+ write: false,
60
+ logLevel: "silent"
61
+ });
62
+ const output = bundled.outputFiles?.[0];
63
+ if (!output || !bundled.metafile) {
64
+ throw new Error("Scenario replay compilation did not produce a bundle.");
65
+ }
66
+ const sourceDigest = await digestSourceClosure({
67
+ projectRoot: source.projectRoot,
68
+ inputPaths: Object.keys(bundled.metafile.inputs)
69
+ });
70
+ const tempRoot = await mkdtemp(
71
+ path.join(tmpdir(), "dreamboard-compiled-scenario-")
72
+ );
73
+ const outputPath = path.join(tempRoot, "compiled-scenario.mjs");
74
+ try {
75
+ await writeFile(outputPath, output.text);
76
+ const loaded = await import(`${pathToFileURL(outputPath).href}?source=${sourceDigest.slice(7, 19)}`);
77
+ if (typeof loaded.compile !== "function") {
78
+ throw new Error("Scenario replay bundle is missing compile().");
79
+ }
80
+ const materialized = await loaded.compile({
81
+ ...options.at === void 0 ? {} : { at: options.at },
82
+ scenarioPath: source.relativeScenarioPath,
83
+ sourceDigest
84
+ });
85
+ const compiled = {
86
+ schemaVersion: 1,
87
+ scenario: {
88
+ path: source.relativeScenarioPath,
89
+ sourceDigest
90
+ },
91
+ definition: materialized.definition,
92
+ checkpoint: materialized.checkpoint,
93
+ expected: materialized.expected
94
+ };
95
+ return assertSerializableCompiledReplay(compiled);
96
+ } finally {
97
+ await rm(tempRoot, { recursive: true, force: true });
98
+ }
99
+ }
100
+ async function resolveCurrentSdkFacade(name) {
101
+ const candidates = [
102
+ path.resolve(import.meta.dirname, `../${name}.ts`),
103
+ path.resolve(import.meta.dirname, `${name}.js`)
104
+ ];
105
+ for (const candidate of candidates) {
106
+ if (await isFile(candidate)) return candidate;
107
+ }
108
+ throw new Error(
109
+ `Could not resolve the current @dreamboard-games/sdk/${name} facade from ${import.meta.dirname}.`
110
+ );
111
+ }
112
+ async function resolveScenarioSource(requestedPath) {
113
+ if (typeof requestedPath !== "string" || requestedPath.length === 0) {
114
+ throw new Error("scenarioPath must be a non-empty string.");
115
+ }
116
+ const requestedAbsolute = path.resolve(process.cwd(), requestedPath);
117
+ const requestedStats = await lstat(requestedAbsolute).catch((error) => {
118
+ if (isMissingPathError(error)) return null;
119
+ throw error;
120
+ });
121
+ if (!requestedStats?.isFile()) {
122
+ throw new Error(`Scenario path does not name a file: ${requestedPath}.`);
123
+ }
124
+ const scenarioPath = await realpath(requestedAbsolute);
125
+ const projectRoot = await findProjectRoot(path.dirname(scenarioPath));
126
+ const canonicalProjectRoot = await realpath(projectRoot);
127
+ const scenarioRoot = path.join(canonicalProjectRoot, "test", "scenarios");
128
+ const canonicalScenarioRoot = await realpath(scenarioRoot).catch((error) => {
129
+ if (isMissingPathError(error)) return null;
130
+ throw error;
131
+ });
132
+ if (canonicalScenarioRoot === null || !isWithinDirectory(canonicalScenarioRoot, scenarioPath) || !scenarioPath.endsWith(".scenario.ts")) {
133
+ throw new Error(
134
+ "scenarioPath must resolve to test/scenarios/**/*.scenario.ts inside one game package."
135
+ );
136
+ }
137
+ const gamePath = path.join(canonicalProjectRoot, "app", "game.ts");
138
+ if (!await isFile(gamePath)) {
139
+ throw new Error(`Game package is missing ${gamePath}.`);
140
+ }
141
+ return {
142
+ projectRoot: canonicalProjectRoot,
143
+ scenarioPath,
144
+ relativeScenarioPath: toPosix(
145
+ path.relative(canonicalProjectRoot, scenarioPath)
146
+ ),
147
+ gamePath
148
+ };
149
+ }
150
+ async function findProjectRoot(start) {
151
+ let current = path.resolve(start);
152
+ for (; ; ) {
153
+ if (await isFile(path.join(current, "package.json")) && await isFile(path.join(current, "app", "game.ts"))) {
154
+ return current;
155
+ }
156
+ const parent = path.dirname(current);
157
+ if (parent === current) {
158
+ throw new Error(
159
+ "Could not find a game package containing package.json and app/game.ts."
160
+ );
161
+ }
162
+ current = parent;
163
+ }
164
+ }
165
+ function buildSyntheticSource(source) {
166
+ const gameSpecifier = localImportSpecifier(
167
+ source.projectRoot,
168
+ source.gamePath
169
+ );
170
+ const scenarioSpecifier = localImportSpecifier(
171
+ source.projectRoot,
172
+ source.scenarioPath
173
+ );
174
+ return [
175
+ `import * as gameModule from ${JSON.stringify(gameSpecifier)};`,
176
+ `import * as scenarioModule from ${JSON.stringify(scenarioSpecifier)};`,
177
+ 'import { inspectScenario, toScenarioReplayDefinition } from "@dreamboard-games/sdk/testing";',
178
+ 'import { digestScenarioProjection, scenarioProjectionParityFromInspectNode } from "@dreamboard-games/sdk/testing-runtime";',
179
+ "const game = gameModule.game ?? gameModule.default;",
180
+ "const scenario = scenarioModule.scenario ?? scenarioModule.default;",
181
+ "export async function compile(options) {",
182
+ " if (!game || !scenario) {",
183
+ ' throw new Error("Compiled scenario entry is missing game or scenario authority.");',
184
+ " }",
185
+ " const definition = toScenarioReplayDefinition(scenario);",
186
+ " const checkpoint = typeof options.at === 'string' ? scenario.checkpoints?.[options.at] : options.at;",
187
+ " if (typeof options.at === 'string' && checkpoint === undefined) {",
188
+ " const available = Object.keys(scenario.checkpoints ?? {}).sort();",
189
+ " throw new Error(`Unknown checkpoint '${options.at}'; available checkpoints: ${available.join(', ') || 'none'}.`);",
190
+ " }",
191
+ " const inspected = await inspectScenario({",
192
+ " game,",
193
+ " scenario: definition,",
194
+ " identity: {",
195
+ " id: definition.id,",
196
+ " path: options.scenarioPath,",
197
+ " sourceDigest: options.sourceDigest,",
198
+ " },",
199
+ ' perspective: { kind: "spectator" },',
200
+ " ...(checkpoint === undefined ? {} : { at: checkpoint }),",
201
+ " });",
202
+ " return {",
203
+ " definition,",
204
+ " checkpoint: inspected.node.checkpoint,",
205
+ " expected: {",
206
+ " checkpointDigest: inspected.node.checkpointDigest,",
207
+ " publicProjectionDigest: digestScenarioProjection(",
208
+ " scenarioProjectionParityFromInspectNode(inspected.node),",
209
+ " ),",
210
+ " },",
211
+ " };",
212
+ "}"
213
+ ].join("\n");
214
+ }
215
+ async function digestSourceClosure(options) {
216
+ const syntheticPath = path.resolve(options.projectRoot, syntheticSourceFile);
217
+ const localPaths = options.inputPaths.map(
218
+ (inputPath) => path.isAbsolute(inputPath) ? inputPath : path.resolve(options.projectRoot, inputPath)
219
+ ).filter(
220
+ (inputPath) => inputPath !== syntheticPath && isWithinDirectory(options.projectRoot, inputPath) && !toPosix(path.relative(options.projectRoot, inputPath)).split("/").includes("node_modules")
221
+ );
222
+ const inputs = await Promise.all(
223
+ [...new Set(localPaths)].map(async (inputPath) => {
224
+ const content = await readFile(inputPath);
225
+ return {
226
+ path: toPosix(path.relative(options.projectRoot, inputPath)),
227
+ sha256: createHash("sha256").update(content).digest("hex")
228
+ };
229
+ })
230
+ );
231
+ inputs.sort(
232
+ (left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0
233
+ );
234
+ return `sha256:${createHash("sha256").update(
235
+ JSON.stringify({
236
+ digestVersion: scenarioSourceDigestVersion,
237
+ inputs
238
+ })
239
+ ).digest("hex")}`;
240
+ }
241
+ function assertSerializableCompiledReplay(value) {
242
+ const serialized = JSON.stringify(value);
243
+ const parsed = JSON.parse(serialized);
244
+ if (parsed.schemaVersion !== 1 || !/^sha256:[a-f0-9]{64}$/.test(parsed.scenario.sourceDigest) || !/^sha256:[a-f0-9]{64}$/.test(parsed.expected.checkpointDigest) || !/^sha256:[a-f0-9]{64}$/.test(parsed.expected.publicProjectionDigest)) {
245
+ throw new Error("Compiled scenario replay failed digest validation.");
246
+ }
247
+ return parsed;
248
+ }
249
+ function localImportSpecifier(projectRoot, filePath) {
250
+ const relative = toPosix(path.relative(projectRoot, filePath));
251
+ return relative.startsWith(".") ? relative : `./${relative}`;
252
+ }
253
+ function isWithinDirectory(directory, filePath) {
254
+ const relative = path.relative(directory, filePath);
255
+ return relative !== "" && relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
256
+ }
257
+ async function isFile(filePath) {
258
+ return stat(filePath).then((value) => value.isFile()).catch((error) => {
259
+ if (isMissingPathError(error)) return false;
260
+ throw error;
261
+ });
262
+ }
263
+ function isMissingPathError(error) {
264
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
265
+ }
266
+ function toPosix(value) {
267
+ return value.split(path.sep).join("/");
268
+ }
269
+ export {
270
+ compileScenarioReplay
271
+ };
272
+ //# sourceMappingURL=testing-compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/testing/compile-scenario-replay.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { createRequire } from \"node:module\";\nimport {\n lstat,\n mkdtemp,\n readFile,\n realpath,\n rm,\n stat,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { build } from \"esbuild\";\nimport type {\n ScenarioCheckpoint,\n ScenarioCheckpointSelector,\n ScenarioReplayDefinition,\n} from \"./definitions.js\";\nimport type { ScenarioDefinitionGameLike } from \"./scenario-definition-validation.js\";\n\nexport type CompiledScenarioReplay<\n Game extends ScenarioDefinitionGameLike = ScenarioDefinitionGameLike,\n> = {\n readonly schemaVersion: 1;\n readonly scenario: {\n readonly path: string;\n /** Covers the local game/scenario module graph, including assertions. */\n readonly sourceDigest: `sha256:${string}`;\n };\n /** Canonical serializable scenario projection; never contains `then`. */\n readonly definition: ScenarioReplayDefinition<Game>;\n readonly checkpoint: ScenarioCheckpoint;\n readonly expected: {\n readonly checkpointDigest: `sha256:${string}`;\n readonly publicProjectionDigest: `sha256:${string}`;\n };\n};\n\nexport type CompileScenarioReplayOptions = {\n readonly scenarioPath: string;\n readonly at?: ScenarioCheckpointSelector;\n};\n\ntype SyntheticCompileResult = Omit<\n CompiledScenarioReplay,\n \"schemaVersion\" | \"scenario\"\n>;\n\ntype SyntheticCompileModule = {\n readonly compile: (options: {\n readonly at?: ScenarioCheckpointSelector;\n readonly scenarioPath: string;\n readonly sourceDigest: `sha256:${string}`;\n }) => Promise<SyntheticCompileResult>;\n};\n\ntype ScenarioSource = {\n readonly projectRoot: string;\n readonly scenarioPath: string;\n readonly relativeScenarioPath: string;\n readonly gamePath: string;\n};\n\nconst scenarioSourceDigestVersion = \"dreamboard-scenario-source-closure@1\";\nconst syntheticSourceFile = \"__dreamboard_compile_scenario_replay__.ts\";\n\n/**\n * Compile one authored scenario into the trusted, serializable replay DTO used\n * by dev-host, Workbench, demo, and performance adapters.\n *\n * The DTO may contain sealed/private command parameters. It must never cross a\n * player, spectator, browser, or ordinary-log boundary.\n */\nexport async function compileScenarioReplay(\n options: CompileScenarioReplayOptions,\n): Promise<CompiledScenarioReplay> {\n const source = await resolveScenarioSource(options.scenarioPath);\n const syntheticSource = buildSyntheticSource(source);\n const [\n reducerEntry,\n reducerAdvancedEntry,\n testingEntry,\n testingRuntimeEntry,\n typesEntry,\n ] = await Promise.all([\n resolveCurrentSdkFacade(\"reducer\"),\n resolveCurrentSdkFacade(\"reducer/advanced\"),\n resolveCurrentSdkFacade(\"testing\"),\n resolveCurrentSdkFacade(\"testing-runtime\"),\n resolveCurrentSdkFacade(\"types\"),\n ]);\n const bundled = await build({\n absWorkingDir: source.projectRoot,\n stdin: {\n contents: syntheticSource,\n loader: \"ts\",\n resolveDir: source.projectRoot,\n sourcefile: syntheticSourceFile,\n },\n bundle: true,\n alias: {\n \"@dreamboard-games/sdk/reducer\": reducerEntry,\n \"@dreamboard-games/sdk/reducer/advanced\": reducerAdvancedEntry,\n \"@dreamboard-games/sdk/testing\": testingEntry,\n \"@dreamboard-games/sdk/testing-runtime\": testingRuntimeEntry,\n \"@dreamboard-games/sdk/types\": typesEntry,\n zod: createRequire(import.meta.url).resolve(\"zod\"),\n },\n format: \"esm\",\n platform: \"node\",\n target: \"node24\",\n sourcemap: \"inline\",\n metafile: true,\n write: false,\n logLevel: \"silent\",\n });\n const output = bundled.outputFiles?.[0];\n if (!output || !bundled.metafile) {\n throw new Error(\"Scenario replay compilation did not produce a bundle.\");\n }\n const sourceDigest = await digestSourceClosure({\n projectRoot: source.projectRoot,\n inputPaths: Object.keys(bundled.metafile.inputs),\n });\n\n const tempRoot = await mkdtemp(\n path.join(tmpdir(), \"dreamboard-compiled-scenario-\"),\n );\n const outputPath = path.join(tempRoot, \"compiled-scenario.mjs\");\n try {\n await writeFile(outputPath, output.text);\n const loaded = (await import(\n `${pathToFileURL(outputPath).href}?source=${sourceDigest.slice(7, 19)}`\n )) as SyntheticCompileModule;\n if (typeof loaded.compile !== \"function\") {\n throw new Error(\"Scenario replay bundle is missing compile().\");\n }\n const materialized = await loaded.compile({\n ...(options.at === undefined ? {} : { at: options.at }),\n scenarioPath: source.relativeScenarioPath,\n sourceDigest,\n });\n const compiled = {\n schemaVersion: 1,\n scenario: {\n path: source.relativeScenarioPath,\n sourceDigest,\n },\n definition: materialized.definition,\n checkpoint: materialized.checkpoint,\n expected: materialized.expected,\n } satisfies CompiledScenarioReplay;\n return assertSerializableCompiledReplay(compiled);\n } finally {\n await rm(tempRoot, { recursive: true, force: true });\n }\n}\n\nasync function resolveCurrentSdkFacade(name: string): Promise<string> {\n const candidates = [\n path.resolve(import.meta.dirname, `../${name}.ts`),\n path.resolve(import.meta.dirname, `${name}.js`),\n ];\n for (const candidate of candidates) {\n if (await isFile(candidate)) return candidate;\n }\n throw new Error(\n `Could not resolve the current @dreamboard-games/sdk/${name} facade from ${import.meta.dirname}.`,\n );\n}\n\nasync function resolveScenarioSource(\n requestedPath: string,\n): Promise<ScenarioSource> {\n if (typeof requestedPath !== \"string\" || requestedPath.length === 0) {\n throw new Error(\"scenarioPath must be a non-empty string.\");\n }\n const requestedAbsolute = path.resolve(process.cwd(), requestedPath);\n const requestedStats = await lstat(requestedAbsolute).catch((error) => {\n if (isMissingPathError(error)) return null;\n throw error;\n });\n if (!requestedStats?.isFile()) {\n throw new Error(`Scenario path does not name a file: ${requestedPath}.`);\n }\n const scenarioPath = await realpath(requestedAbsolute);\n const projectRoot = await findProjectRoot(path.dirname(scenarioPath));\n const canonicalProjectRoot = await realpath(projectRoot);\n const scenarioRoot = path.join(canonicalProjectRoot, \"test\", \"scenarios\");\n const canonicalScenarioRoot = await realpath(scenarioRoot).catch((error) => {\n if (isMissingPathError(error)) return null;\n throw error;\n });\n if (\n canonicalScenarioRoot === null ||\n !isWithinDirectory(canonicalScenarioRoot, scenarioPath) ||\n !scenarioPath.endsWith(\".scenario.ts\")\n ) {\n throw new Error(\n \"scenarioPath must resolve to test/scenarios/**/*.scenario.ts inside one game package.\",\n );\n }\n const gamePath = path.join(canonicalProjectRoot, \"app\", \"game.ts\");\n if (!(await isFile(gamePath))) {\n throw new Error(`Game package is missing ${gamePath}.`);\n }\n return {\n projectRoot: canonicalProjectRoot,\n scenarioPath,\n relativeScenarioPath: toPosix(\n path.relative(canonicalProjectRoot, scenarioPath),\n ),\n gamePath,\n };\n}\n\nasync function findProjectRoot(start: string): Promise<string> {\n let current = path.resolve(start);\n for (;;) {\n if (\n (await isFile(path.join(current, \"package.json\"))) &&\n (await isFile(path.join(current, \"app\", \"game.ts\")))\n ) {\n return current;\n }\n const parent = path.dirname(current);\n if (parent === current) {\n throw new Error(\n \"Could not find a game package containing package.json and app/game.ts.\",\n );\n }\n current = parent;\n }\n}\n\nfunction buildSyntheticSource(source: ScenarioSource): string {\n const gameSpecifier = localImportSpecifier(\n source.projectRoot,\n source.gamePath,\n );\n const scenarioSpecifier = localImportSpecifier(\n source.projectRoot,\n source.scenarioPath,\n );\n return [\n `import * as gameModule from ${JSON.stringify(gameSpecifier)};`,\n `import * as scenarioModule from ${JSON.stringify(scenarioSpecifier)};`,\n 'import { inspectScenario, toScenarioReplayDefinition } from \"@dreamboard-games/sdk/testing\";',\n 'import { digestScenarioProjection, scenarioProjectionParityFromInspectNode } from \"@dreamboard-games/sdk/testing-runtime\";',\n \"const game = gameModule.game ?? gameModule.default;\",\n \"const scenario = scenarioModule.scenario ?? scenarioModule.default;\",\n \"export async function compile(options) {\",\n \" if (!game || !scenario) {\",\n ' throw new Error(\"Compiled scenario entry is missing game or scenario authority.\");',\n \" }\",\n \" const definition = toScenarioReplayDefinition(scenario);\",\n \" const checkpoint = typeof options.at === 'string' ? scenario.checkpoints?.[options.at] : options.at;\",\n \" if (typeof options.at === 'string' && checkpoint === undefined) {\",\n \" const available = Object.keys(scenario.checkpoints ?? {}).sort();\",\n \" throw new Error(`Unknown checkpoint '${options.at}'; available checkpoints: ${available.join(', ') || 'none'}.`);\",\n \" }\",\n \" const inspected = await inspectScenario({\",\n \" game,\",\n \" scenario: definition,\",\n \" identity: {\",\n \" id: definition.id,\",\n \" path: options.scenarioPath,\",\n \" sourceDigest: options.sourceDigest,\",\n \" },\",\n ' perspective: { kind: \"spectator\" },',\n \" ...(checkpoint === undefined ? {} : { at: checkpoint }),\",\n \" });\",\n \" return {\",\n \" definition,\",\n \" checkpoint: inspected.node.checkpoint,\",\n \" expected: {\",\n \" checkpointDigest: inspected.node.checkpointDigest,\",\n \" publicProjectionDigest: digestScenarioProjection(\",\n \" scenarioProjectionParityFromInspectNode(inspected.node),\",\n \" ),\",\n \" },\",\n \" };\",\n \"}\",\n ].join(\"\\n\");\n}\n\nasync function digestSourceClosure(options: {\n readonly projectRoot: string;\n readonly inputPaths: readonly string[];\n}): Promise<`sha256:${string}`> {\n const syntheticPath = path.resolve(options.projectRoot, syntheticSourceFile);\n const localPaths = options.inputPaths\n .map((inputPath) =>\n path.isAbsolute(inputPath)\n ? inputPath\n : path.resolve(options.projectRoot, inputPath),\n )\n .filter(\n (inputPath) =>\n inputPath !== syntheticPath &&\n isWithinDirectory(options.projectRoot, inputPath) &&\n !toPosix(path.relative(options.projectRoot, inputPath))\n .split(\"/\")\n .includes(\"node_modules\"),\n );\n const inputs = await Promise.all(\n [...new Set(localPaths)].map(async (inputPath) => {\n const content = await readFile(inputPath);\n return {\n path: toPosix(path.relative(options.projectRoot, inputPath)),\n sha256: createHash(\"sha256\").update(content).digest(\"hex\"),\n };\n }),\n );\n inputs.sort((left, right) =>\n left.path < right.path ? -1 : left.path > right.path ? 1 : 0,\n );\n return `sha256:${createHash(\"sha256\")\n .update(\n JSON.stringify({\n digestVersion: scenarioSourceDigestVersion,\n inputs,\n }),\n )\n .digest(\"hex\")}`;\n}\n\nfunction assertSerializableCompiledReplay(\n value: CompiledScenarioReplay,\n): CompiledScenarioReplay {\n const serialized = JSON.stringify(value);\n const parsed = JSON.parse(serialized) as CompiledScenarioReplay;\n if (\n parsed.schemaVersion !== 1 ||\n !/^sha256:[a-f0-9]{64}$/.test(parsed.scenario.sourceDigest) ||\n !/^sha256:[a-f0-9]{64}$/.test(parsed.expected.checkpointDigest) ||\n !/^sha256:[a-f0-9]{64}$/.test(parsed.expected.publicProjectionDigest)\n ) {\n throw new Error(\"Compiled scenario replay failed digest validation.\");\n }\n return parsed;\n}\n\nfunction localImportSpecifier(projectRoot: string, filePath: string): string {\n const relative = toPosix(path.relative(projectRoot, filePath));\n return relative.startsWith(\".\") ? relative : `./${relative}`;\n}\n\nfunction isWithinDirectory(directory: string, filePath: string): boolean {\n const relative = path.relative(directory, filePath);\n return (\n relative !== \"\" &&\n relative !== \"..\" &&\n !relative.startsWith(`..${path.sep}`) &&\n !path.isAbsolute(relative)\n );\n}\n\nasync function isFile(filePath: string): Promise<boolean> {\n return stat(filePath)\n .then((value) => value.isFile())\n .catch((error) => {\n if (isMissingPathError(error)) return false;\n throw error;\n });\n}\n\nfunction isMissingPathError(error: unknown): boolean {\n return (\n typeof error === \"object\" &&\n error !== null &&\n \"code\" in error &&\n (error as { readonly code?: unknown }).code === \"ENOENT\"\n );\n}\n\nfunction toPosix(value: string): string {\n return value.split(path.sep).join(\"/\");\n}\n"],"mappings":";;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAC9B,SAAS,aAAa;AAmDtB,IAAM,8BAA8B;AACpC,IAAM,sBAAsB;AAS5B,eAAsB,sBACpB,SACiC;AACjC,QAAM,SAAS,MAAM,sBAAsB,QAAQ,YAAY;AAC/D,QAAM,kBAAkB,qBAAqB,MAAM;AACnD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,MAAM,QAAQ,IAAI;AAAA,IACpB,wBAAwB,SAAS;AAAA,IACjC,wBAAwB,kBAAkB;AAAA,IAC1C,wBAAwB,SAAS;AAAA,IACjC,wBAAwB,iBAAiB;AAAA,IACzC,wBAAwB,OAAO;AAAA,EACjC,CAAC;AACD,QAAM,UAAU,MAAM,MAAM;AAAA,IAC1B,eAAe,OAAO;AAAA,IACtB,OAAO;AAAA,MACL,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,YAAY;AAAA,IACd;AAAA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KAAK;AACvC,QAAM,SAAS,KAAK,MAAM,UAAU;AACpC,MACE,OAAO,kBAAkB,KACzB,CAAC,wBAAwB,KAAK,OAAO,SAAS,YAAY,KAC1D,CAAC,wBAAwB,KAAK,OAAO,SAAS,gBAAgB,KAC9D,CAAC,wBAAwB,KAAK,OAAO,SAAS,sBAAsB,GACpE;AACA,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AACA,SAAO;AACT;AAEA,SAAS,qBAAqB,aAAqB,UAA0B;AAC3E,QAAM,WAAW,QAAQ,KAAK,SAAS,aAAa,QAAQ,CAAC;AAC7D,SAAO,SAAS,WAAW,GAAG,IAAI,WAAW,KAAK,QAAQ;AAC5D;AAEA,SAAS,kBAAkB,WAAmB,UAA2B;AACvE,QAAM,WAAW,KAAK,SAAS,WAAW,QAAQ;AAClD,SACE,aAAa,MACb,aAAa,QACb,CAAC,SAAS,WAAW,KAAK,KAAK,GAAG,EAAE,KACpC,CAAC,KAAK,WAAW,QAAQ;AAE7B;AAEA,eAAe,OAAO,UAAoC;AACxD,SAAO,KAAK,QAAQ,EACjB,KAAK,CAAC,UAAU,MAAM,OAAO,CAAC,EAC9B,MAAM,CAAC,UAAU;AAChB,QAAI,mBAAmB,KAAK,EAAG,QAAO;AACtC,UAAM;AAAA,EACR,CAAC;AACL;AAEA,SAAS,mBAAmB,OAAyB;AACnD,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACT,MAAsC,SAAS;AAEpD;AAEA,SAAS,QAAQ,OAAuB;AACtC,SAAO,MAAM,MAAM,KAAK,GAAG,EAAE,KAAK,GAAG;AACvC;","names":[]}
@@ -1,32 +1,109 @@
1
- import { w as wire } from './index.d-C0PKOVbh.js';
2
- import { a as BaseDefinition, S as ScenarioDefinition, R as ReducerScenarioBundle } from './types-B_3pObUV.js';
1
+ import { D as DispatchTraceSummaryEntry } from './diagnostics-DIi3ina7.js';
2
+ import { o as ScenarioDefinitionGameLike, n as ScenarioDefinition } from './definitions-bZSBaPjj.js';
3
+ import { i as Sha256Digest, d as InspectNode } from './types-DN4O7kH_.js';
4
+ export { h as ScenarioRuntimeCheckpointMaterialization, m as materializeScenarioRuntimeCheckpoint } from './types-DN4O7kH_.js';
3
5
  import 'zod';
4
- import './diagnostics-1BWjRo6-.js';
6
+ import './views-D2Cfzr3h.js';
7
+ import './runtime-C7Z2acNU.js';
8
+ import './types.js';
9
+ import './protocol-CVaSqPgX.js';
10
+ import './index.d-Bw8AOcgp.js';
5
11
 
6
- type BaseStateArtifact = {
7
- readonly snapshot: wire.ReducerSessionState;
8
- readonly fingerprint: {
9
- readonly players: number;
10
- readonly contractFingerprint?: string;
12
+ type GameLike = {
13
+ readonly phases: Readonly<Record<string, unknown>>;
14
+ };
15
+ declare function resolveScenarioCommandParams(options: {
16
+ readonly game: GameLike;
17
+ readonly phase: string;
18
+ readonly interactionId: string;
19
+ readonly params: unknown;
20
+ readonly playerIds: readonly string[];
21
+ readonly path: string;
22
+ }): Record<string, unknown>;
23
+
24
+ type ScenarioProjectionInteractionInput = {
25
+ readonly key: string;
26
+ readonly kind: string;
27
+ readonly domain: unknown;
28
+ };
29
+ /** Shared SDK normalization for inspect DTOs and backend parity projections. */
30
+ declare function scenarioProjectionInputMetadata(input: ScenarioProjectionInteractionInput): {
31
+ readonly key: string;
32
+ readonly kind: string;
33
+ readonly eligibleCount: number | "lazy";
34
+ };
35
+ type ScenarioProjectionParity = {
36
+ readonly perspective: "spectator" | {
37
+ readonly seat: number;
38
+ };
39
+ readonly flow: {
40
+ readonly phase: string;
41
+ readonly step: string | null;
42
+ readonly activeSeats: readonly number[];
43
+ readonly pendingSeats: readonly number[];
44
+ readonly continuationWaiterSeats: readonly number[];
45
+ readonly blockedBy: readonly {
46
+ readonly actorSeat: number;
47
+ readonly blockerSeats: readonly number[];
48
+ }[];
11
49
  };
50
+ readonly view: unknown;
51
+ readonly interactions: readonly {
52
+ readonly actorSeat: number;
53
+ readonly interactionId: string;
54
+ readonly availability: {
55
+ readonly status: string;
56
+ readonly code?: string;
57
+ readonly reason?: string;
58
+ };
59
+ readonly inputs: readonly {
60
+ readonly key: string;
61
+ readonly kind: string;
62
+ readonly eligibleCount: number | "lazy";
63
+ }[];
64
+ }[];
12
65
  };
13
- type CandidateVerificationBase = BaseStateArtifact | (BaseDefinition & Partial<BaseStateArtifact>);
14
- type CandidateVerificationScenario = ScenarioDefinition;
15
- type CandidateVerificationInput = {
16
- readonly manifest?: unknown;
17
- readonly bases: Readonly<Record<string, CandidateVerificationBase>> | readonly CandidateVerificationBase[];
18
- readonly scenarios: Readonly<Record<string, CandidateVerificationScenario>> | readonly CandidateVerificationScenario[];
19
- readonly reducer: ReducerScenarioBundle;
66
+ /**
67
+ * Canonical local/backend parity authority. It deliberately excludes raw
68
+ * reducer public/private state, interaction explanations, entropy, and trace:
69
+ * backend gameplay frames expose the selected projection, not reducer state.
70
+ */
71
+ declare function scenarioProjectionParityFromInspectNode(node: InspectNode): ScenarioProjectionParity;
72
+ declare function digestScenarioProjection(projection: ScenarioProjectionParity): Sha256Digest;
73
+
74
+ type CandidateVerificationScenario<Game extends ScenarioDefinitionGameLike> = ScenarioDefinition<Game>;
75
+ type CandidateVerificationInput<Game extends ScenarioDefinitionGameLike> = {
76
+ /** The authored reducer game definition used by production dispatch. */
77
+ readonly reducer: Game;
78
+ readonly scenarios: Readonly<Record<string, CandidateVerificationScenario<Game>>> | readonly CandidateVerificationScenario<Game>[];
20
79
  readonly maxScenarios?: number;
21
80
  readonly maxStepsPerScenario?: number;
22
81
  };
82
+ type CandidateVerificationReplayDiagnostic = {
83
+ readonly kind: "replay";
84
+ readonly message: string;
85
+ readonly scenarioId?: string;
86
+ readonly segment?: "given" | "when";
87
+ readonly index?: number;
88
+ readonly interactionId?: string;
89
+ readonly errorCode?: string;
90
+ readonly reducerMessage?: string;
91
+ readonly trace?: readonly DispatchTraceSummaryEntry[];
92
+ };
93
+ type CandidateVerificationAssertionDiagnostic = {
94
+ readonly kind: "assertion";
95
+ readonly message: string;
96
+ };
97
+ type CandidateVerificationLimitDiagnostic = {
98
+ readonly kind: "limit";
99
+ readonly message: string;
100
+ readonly actualSteps: number;
101
+ readonly maxStepsPerScenario: number;
102
+ };
23
103
  type CandidateVerificationScenarioResult = {
24
104
  readonly id: string;
25
105
  readonly status: "passed" | "failed";
26
- readonly diagnostic?: {
27
- readonly kind: "assertion";
28
- readonly message: string;
29
- };
106
+ readonly diagnostic?: CandidateVerificationReplayDiagnostic | CandidateVerificationAssertionDiagnostic | CandidateVerificationLimitDiagnostic;
30
107
  };
31
108
  type CandidateVerificationResult = {
32
109
  readonly status: "passed" | "failed";
@@ -37,6 +114,6 @@ type CandidateVerificationResult = {
37
114
  readonly scenarios: readonly CandidateVerificationScenarioResult[];
38
115
  };
39
116
  };
40
- declare function runCandidateVerification(input: CandidateVerificationInput): Promise<CandidateVerificationResult>;
117
+ declare function runCandidateVerification<const Game extends ScenarioDefinitionGameLike>(input: CandidateVerificationInput<Game>): Promise<CandidateVerificationResult>;
41
118
 
42
- export { type CandidateVerificationBase, type CandidateVerificationInput, type CandidateVerificationResult, type CandidateVerificationScenario, type CandidateVerificationScenarioResult, runCandidateVerification };
119
+ export { type CandidateVerificationAssertionDiagnostic, type CandidateVerificationInput, type CandidateVerificationLimitDiagnostic, type CandidateVerificationReplayDiagnostic, type CandidateVerificationResult, type CandidateVerificationScenario, type CandidateVerificationScenarioResult, type ScenarioProjectionInteractionInput, type ScenarioProjectionParity, digestScenarioProjection, resolveScenarioCommandParams, runCandidateVerification, scenarioProjectionInputMetadata, scenarioProjectionParityFromInspectNode };