@dreamboard-games/cli 0.1.30-alpha.1 → 0.1.30-alpha.3

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 (163) hide show
  1. package/README.md +179 -22
  2. package/dist/agent-verifier/agent-workspace-verifier.mjs +30 -30
  3. package/dist/agent-verifier/agent-workspace-verifier.mjs.map +1 -0
  4. package/dist/agent-verifier/{chunk-JH22JNYD.mjs → chunk-3UKQVWLV.mjs} +82 -19
  5. package/dist/agent-verifier/chunk-3UKQVWLV.mjs.map +1 -0
  6. package/dist/agent-verifier/{chunk-4WD3YU2E.mjs → chunk-776W3UGV.mjs} +4 -3
  7. package/dist/agent-verifier/chunk-776W3UGV.mjs.map +1 -0
  8. package/dist/agent-verifier/{chunk-CJEEA6NJ.mjs → chunk-7WWGFAAU.mjs} +9 -10
  9. package/dist/agent-verifier/chunk-7WWGFAAU.mjs.map +1 -0
  10. package/dist/agent-verifier/{chunk-2SZHMP6F.mjs → chunk-A64ZZUZV.mjs} +6 -9
  11. package/dist/agent-verifier/chunk-A64ZZUZV.mjs.map +1 -0
  12. package/dist/agent-verifier/{chunk-6A5HRJMQ.mjs → chunk-E7SSWJXJ.mjs} +62 -99
  13. package/dist/agent-verifier/chunk-E7SSWJXJ.mjs.map +1 -0
  14. package/dist/agent-verifier/{chunk-2GBBP27W.mjs → chunk-F2DIOJJZ.mjs} +1 -0
  15. package/dist/agent-verifier/chunk-F2DIOJJZ.mjs.map +1 -0
  16. package/dist/agent-verifier/{chunk-CFU5EWIC.mjs → chunk-G42BGGG2.mjs} +7 -6
  17. package/dist/agent-verifier/chunk-G42BGGG2.mjs.map +1 -0
  18. package/dist/agent-verifier/{chunk-SHUMAVAP.mjs → chunk-H76MT5UR.mjs} +7 -9
  19. package/dist/agent-verifier/chunk-H76MT5UR.mjs.map +1 -0
  20. package/dist/agent-verifier/{chunk-7E65UQLY.mjs → chunk-HGMUAL33.mjs} +3 -2
  21. package/dist/agent-verifier/chunk-HGMUAL33.mjs.map +1 -0
  22. package/dist/agent-verifier/{chunk-LM3OZLZG.mjs → chunk-IAYRNVUC.mjs} +1 -0
  23. package/dist/agent-verifier/chunk-IAYRNVUC.mjs.map +1 -0
  24. package/dist/agent-verifier/{chunk-VYJTHSYR.mjs → chunk-JGT4P4UD.mjs} +2 -1
  25. package/dist/agent-verifier/chunk-JGT4P4UD.mjs.map +1 -0
  26. package/dist/agent-verifier/{chunk-CEDUHGNH.mjs → chunk-LUZ7KE6H.mjs} +8 -3
  27. package/dist/agent-verifier/chunk-LUZ7KE6H.mjs.map +1 -0
  28. package/dist/agent-verifier/{chunk-2E5P5NWG.mjs → chunk-NAK77WXW.mjs} +58 -126
  29. package/dist/agent-verifier/chunk-NAK77WXW.mjs.map +1 -0
  30. package/dist/agent-verifier/{chunk-SYPLYRGB.mjs → chunk-O4YCPU7C.mjs} +116 -15
  31. package/dist/agent-verifier/chunk-O4YCPU7C.mjs.map +1 -0
  32. package/dist/agent-verifier/{chunk-BVVNBJM4.mjs → chunk-S34FRJHS.mjs} +2 -1
  33. package/dist/agent-verifier/chunk-S34FRJHS.mjs.map +1 -0
  34. package/dist/agent-verifier/{chunk-HJFQDSTU.mjs → chunk-SH5JKYOB.mjs} +6 -5
  35. package/dist/agent-verifier/chunk-SH5JKYOB.mjs.map +1 -0
  36. package/dist/agent-verifier/chunk-SKI2ESE5.mjs +44 -0
  37. package/dist/agent-verifier/{chunk-MINCYHXN.mjs → chunk-TAEQKBJB.mjs} +1 -0
  38. package/dist/agent-verifier/chunk-TAEQKBJB.mjs.map +1 -0
  39. package/dist/agent-verifier/{chunk-CEQ2VJWN.mjs → chunk-UIOLGH4A.mjs} +2 -1
  40. package/dist/agent-verifier/chunk-UIOLGH4A.mjs.map +1 -0
  41. package/dist/agent-verifier/chunk-UIZNWRM6.mjs +2432 -0
  42. package/dist/agent-verifier/chunk-UIZNWRM6.mjs.map +1 -0
  43. package/dist/agent-verifier/{chunk-2QMNAVV4.mjs → chunk-VS573ERH.mjs} +2 -1
  44. package/dist/agent-verifier/chunk-VS573ERH.mjs.map +1 -0
  45. package/dist/agent-verifier/{chunk-EOQIV6PS.mjs → chunk-W3N3QJ4V.mjs} +75 -100
  46. package/dist/agent-verifier/chunk-W3N3QJ4V.mjs.map +1 -0
  47. package/dist/agent-verifier/{chunk-EIQWDQWJ.mjs → chunk-XGWCY624.mjs} +11 -12
  48. package/dist/agent-verifier/chunk-XGWCY624.mjs.map +1 -0
  49. package/dist/agent-verifier/{chunk-7653FPGJ.mjs → chunk-XQXDOBYB.mjs} +3 -2
  50. package/dist/agent-verifier/chunk-XQXDOBYB.mjs.map +1 -0
  51. package/dist/agent-verifier/{chunk-MRCUP5SW.mjs → chunk-YE7UAO3T.mjs} +1 -0
  52. package/dist/agent-verifier/chunk-YE7UAO3T.mjs.map +1 -0
  53. package/dist/agent-verifier/{chunk-RBDDIIPM.mjs → chunk-ZEELHSY3.mjs} +1 -0
  54. package/dist/agent-verifier/chunk-ZEELHSY3.mjs.map +1 -0
  55. package/dist/agent-verifier/{compile-5QSPIOUT.mjs → compile-TEQVA46V.mjs} +24 -25
  56. package/dist/agent-verifier/compile-TEQVA46V.mjs.map +1 -0
  57. package/dist/agent-verifier/{global-config-WX3ZZIVU.mjs → global-config-Y2NTSK4R.mjs} +6 -5
  58. package/dist/{keychain-backend-JHTXAKWC.js → agent-verifier/keychain-backend-SPQWGKZN.mjs} +2 -2
  59. package/dist/agent-verifier/keychain-backend-SPQWGKZN.mjs.map +1 -0
  60. package/dist/agent-verifier/{local-files-MTPLP62S.mjs → local-files-JFOQQZDL.mjs} +10 -11
  61. package/dist/agent-verifier/local-files-JFOQQZDL.mjs.map +1 -0
  62. package/dist/agent-verifier/local-typecheck-XVGWI75X.mjs +10 -0
  63. package/dist/agent-verifier/local-typecheck-XVGWI75X.mjs.map +1 -0
  64. package/dist/agent-verifier/{materialize-workspace-FKALAE2T.mjs → materialize-workspace-ZAVGQQSF.mjs} +17 -18
  65. package/dist/agent-verifier/materialize-workspace-ZAVGQQSF.mjs.map +1 -0
  66. package/dist/agent-verifier/{project-state-7GR6BQTQ.mjs → project-state-K576C2TE.mjs} +3 -2
  67. package/dist/agent-verifier/project-state-K576C2TE.mjs.map +1 -0
  68. package/dist/{prompt-GMZABCJC.js → agent-verifier/prompt-MJRJMOGQ.mjs} +2 -2
  69. package/dist/agent-verifier/prompt-MJRJMOGQ.mjs.map +1 -0
  70. package/dist/agent-verifier/{reducer-bundle-preflight-C73LEXI2.mjs → reducer-bundle-preflight-LXNJUBKL.mjs} +6 -9
  71. package/dist/agent-verifier/reducer-bundle-preflight-LXNJUBKL.mjs.map +1 -0
  72. package/dist/agent-verifier/reducer-contract-preflight-TUMQ43JV.mjs +11 -0
  73. package/dist/agent-verifier/reducer-contract-preflight-TUMQ43JV.mjs.map +1 -0
  74. package/dist/agent-verifier/{reducer-native-test-harness-GMWBUISX.mjs → reducer-native-test-harness-CHX5MBL5.mjs} +14 -17
  75. package/dist/agent-verifier/reducer-native-test-harness-CHX5MBL5.mjs.map +1 -0
  76. package/dist/agent-verifier/static-scaffold-R7SVDRQI.mjs +27 -0
  77. package/dist/agent-verifier/static-scaffold-R7SVDRQI.mjs.map +1 -0
  78. package/dist/agent-verifier/{sync-3DUQH32H.mjs → sync-THAI546U.mjs} +31 -37
  79. package/dist/agent-verifier/sync-THAI546U.mjs.map +1 -0
  80. package/dist/agent-verifier/{test-P4U5INTD.mjs → test-AFAQFKOB.mjs} +28 -31
  81. package/dist/agent-verifier/test-AFAQFKOB.mjs.map +1 -0
  82. package/dist/agent-verifier/workspace-codegen-2ZMQRIKJ.mjs +10 -0
  83. package/dist/agent-verifier/workspace-codegen-2ZMQRIKJ.mjs.map +1 -0
  84. package/dist/agent-verifier/{workspace-dependencies-HZ6VVS4G.mjs → workspace-dependencies-NOOQBK6I.mjs} +5 -4
  85. package/dist/agent-verifier/workspace-dependencies-NOOQBK6I.mjs.map +1 -0
  86. package/dist/{chunk-C6UAT6EH.js → chunk-N7XPNNUI.js} +9 -12
  87. package/dist/chunk-N7XPNNUI.js.map +1 -0
  88. package/dist/chunk-SEGVTWSK.js +44 -0
  89. package/dist/chunk-SEGVTWSK.js.map +1 -0
  90. package/dist/{chunk-RS7UXJZV.js → chunk-TAQKH67O.js} +21300 -35881
  91. package/dist/chunk-TAQKH67O.js.map +1 -0
  92. package/dist/{global-config-AGFBDFYD.js → global-config-S4ZIPECE.js} +3 -3
  93. package/dist/global-config-S4ZIPECE.js.map +1 -0
  94. package/dist/index.js +415 -37
  95. package/dist/index.js.map +1 -1
  96. package/dist/internal.js +3 -4
  97. package/dist/{agent-verifier/keychain-backend-TNOPQV3Z.mjs → keychain-backend-HDF4TZDL.js} +2 -1
  98. package/dist/{agent-verifier/prompt-3BAINGAQ.mjs → prompt-NDV3AE5L.js} +2 -1
  99. package/package.json +8 -7
  100. package/skills/dreamboard/references/building-your-first-game.md +510 -0
  101. package/skills/dreamboard/references/cli.md +104 -0
  102. package/skills/dreamboard/references/game-interface.md +548 -0
  103. package/skills/dreamboard/references/manifest-authoring.md +597 -0
  104. package/skills/dreamboard/references/quickstart.md +66 -0
  105. package/skills/dreamboard/references/reducer.md +864 -0
  106. package/skills/dreamboard/references/rule-authoring.md +147 -0
  107. package/skills/dreamboard/references/testing.md +249 -0
  108. package/skills/dreamboard/scripts/events-extract.mjs +218 -0
  109. package/dist/agent-verifier/chunk-54TAYXUD.mjs +0 -12
  110. package/dist/agent-verifier/chunk-6UUJEYDV.mjs +0 -213
  111. package/dist/agent-verifier/chunk-HBNDKQT5.mjs +0 -8381
  112. package/dist/agent-verifier/chunk-LI3ZR3BI.mjs +0 -41
  113. package/dist/agent-verifier/chunk-U6OJN7XS.mjs +0 -8092
  114. package/dist/agent-verifier/chunk-XYDL7GY6.mjs +0 -10
  115. package/dist/agent-verifier/local-typecheck-QFYYAZOK.mjs +0 -9
  116. package/dist/agent-verifier/reducer-contract-preflight-22X7DSZW.mjs +0 -10
  117. package/dist/agent-verifier/static-scaffold-AJMZZQWS.mjs +0 -28
  118. package/dist/agent-verifier/testing-5K2BJYF2.mjs +0 -674
  119. package/dist/agent-verifier/workspace-codegen-JDZJRSDV.mjs +0 -11
  120. package/dist/chunk-2H7UOFLK.js +0 -11
  121. package/dist/chunk-7FOO4AJI.js +0 -50
  122. package/dist/chunk-7FOO4AJI.js.map +0 -1
  123. package/dist/chunk-C6UAT6EH.js.map +0 -1
  124. package/dist/chunk-RS7UXJZV.js.map +0 -1
  125. package/dist/internal.d.ts +0 -311
  126. package/dist/runtime-packages/ui-host-runtime/src/actor-principal.ts +0 -71
  127. package/dist/runtime-packages/ui-host-runtime/src/browser-interaction.ts +0 -139
  128. package/dist/runtime-packages/ui-host-runtime/src/components/host-controls.tsx +0 -374
  129. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback-toaster.tsx +0 -266
  130. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback.tsx +0 -212
  131. package/dist/runtime-packages/ui-host-runtime/src/components/host-primitives.tsx +0 -271
  132. package/dist/runtime-packages/ui-host-runtime/src/components/host-session-metadata.tsx +0 -135
  133. package/dist/runtime-packages/ui-host-runtime/src/components/index.ts +0 -5
  134. package/dist/runtime-packages/ui-host-runtime/src/components/perf-overlay.tsx +0 -194
  135. package/dist/runtime-packages/ui-host-runtime/src/gameplay-authority-transport.ts +0 -626
  136. package/dist/runtime-packages/ui-host-runtime/src/host-controls.tsx +0 -1
  137. package/dist/runtime-packages/ui-host-runtime/src/host-feedback.tsx +0 -1
  138. package/dist/runtime-packages/ui-host-runtime/src/host-session-transport.ts +0 -294
  139. package/dist/runtime-packages/ui-host-runtime/src/index.ts +0 -3
  140. package/dist/runtime-packages/ui-host-runtime/src/logger.ts +0 -11
  141. package/dist/runtime-packages/ui-host-runtime/src/perf.ts +0 -324
  142. package/dist/runtime-packages/ui-host-runtime/src/plugin-bridge.ts +0 -195
  143. package/dist/runtime-packages/ui-host-runtime/src/plugin-health-check.ts +0 -138
  144. package/dist/runtime-packages/ui-host-runtime/src/plugin-messages.ts +0 -159
  145. package/dist/runtime-packages/ui-host-runtime/src/plugin-session-gateway.ts +0 -551
  146. package/dist/runtime-packages/ui-host-runtime/src/runtime/index.ts +0 -13
  147. package/dist/runtime-packages/ui-host-runtime/src/screenshot/projection-to-snapshot.ts +0 -122
  148. package/dist/runtime-packages/ui-host-runtime/src/screenshot/static-store-api.ts +0 -26
  149. package/dist/runtime-packages/ui-host-runtime/src/session-ingress-controller.ts +0 -583
  150. package/dist/runtime-packages/ui-host-runtime/src/session-ingress.ts +0 -219
  151. package/dist/runtime-packages/ui-host-runtime/src/session-live-runtime.ts +0 -117
  152. package/dist/runtime-packages/ui-host-runtime/src/session-model.ts +0 -431
  153. package/dist/runtime-packages/ui-host-runtime/src/session-projection.ts +0 -211
  154. package/dist/runtime-packages/ui-host-runtime/src/session-recovery.ts +0 -80
  155. package/dist/runtime-packages/ui-host-runtime/src/session-state-reducer.ts +0 -1034
  156. package/dist/runtime-packages/ui-host-runtime/src/sse-manager.ts +0 -416
  157. package/dist/runtime-packages/ui-host-runtime/src/unified-session-store.ts +0 -184
  158. package/dist/testing-KLSV6CPJ.js +0 -674
  159. package/dist/testing-KLSV6CPJ.js.map +0 -1
  160. /package/dist/{chunk-2H7UOFLK.js.map → agent-verifier/chunk-SKI2ESE5.mjs.map} +0 -0
  161. /package/dist/{global-config-AGFBDFYD.js.map → agent-verifier/global-config-Y2NTSK4R.mjs.map} +0 -0
  162. /package/dist/{keychain-backend-JHTXAKWC.js.map → keychain-backend-HDF4TZDL.js.map} +0 -0
  163. /package/dist/{prompt-GMZABCJC.js.map → prompt-NDV3AE5L.js.map} +0 -0
@@ -1,674 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- StaleContractArtifactError,
4
- isStaleContractArtifactError
5
- } from "./chunk-7FOO4AJI.js";
6
- import "./chunk-2H7UOFLK.js";
7
-
8
- // ../../node_modules/.pnpm/@dreamboard-games+sdk@0.4.0-alpha.0_@types+react-dom@19.2.3_@types+react@19.2.17__@type_b74cbe125b074769500a56e94fa7f664/node_modules/@dreamboard-games/sdk/dist/testing.js
9
- import { isDeepStrictEqual } from "util";
10
- function defineBase(definition) {
11
- return definition;
12
- }
13
- function defineScenario(definition) {
14
- return definition;
15
- }
16
- function isRecord(value) {
17
- return typeof value === "object" && value !== null && !Array.isArray(value);
18
- }
19
- function matchPartial(actual, expected, path = "value") {
20
- if (!isRecord(expected)) {
21
- return isDeepStrictEqual(actual, expected) ? null : `${path} does not match`;
22
- }
23
- if (!isRecord(actual)) {
24
- return `${path} is not an object`;
25
- }
26
- for (const [key, expectedValue] of Object.entries(expected)) {
27
- const actualValue = actual[key];
28
- if (!(key in actual)) {
29
- return `${path}.${key} is missing`;
30
- }
31
- const mismatch = matchPartial(actualValue, expectedValue, `${path}.${key}`);
32
- if (mismatch) {
33
- return mismatch;
34
- }
35
- }
36
- return null;
37
- }
38
- function asDescriptorList(actual) {
39
- if (!Array.isArray(actual)) {
40
- throw new Error("Expected interaction descriptor array.");
41
- }
42
- return actual;
43
- }
44
- function findInteraction(descriptors, interactionId) {
45
- return descriptors.find(
46
- (descriptor) => descriptor.interactionId === interactionId
47
- ) ?? null;
48
- }
49
- function assertDescriptorMatches(descriptor, opts) {
50
- if (!opts) {
51
- return;
52
- }
53
- const mismatch = matchPartial(descriptor, opts, "interaction");
54
- if (mismatch) {
55
- throw new Error(mismatch);
56
- }
57
- }
58
- function createSubmissionErrorMatcher(actual, expected, options) {
59
- const resolvePromise = () => {
60
- if (typeof actual === "function") {
61
- return Promise.resolve().then(() => actual());
62
- }
63
- return Promise.resolve(actual);
64
- };
65
- return resolvePromise().then(() => {
66
- throw new Error("Expected promise to reject.");
67
- }).catch((error) => {
68
- if (!(error instanceof Error)) {
69
- throw new Error("Expected rejection to be an Error.");
70
- }
71
- if (expected.errorCode !== void 0 && error.errorCode !== expected.errorCode) {
72
- throw new Error(
73
- `Expected rejection errorCode '${expected.errorCode}', received '${error.errorCode ?? "undefined"}'.${formatLastDiagnosticRejection(options)}`
74
- );
75
- }
76
- if (typeof expected.message === "string" && error.message !== expected.message) {
77
- throw new Error(
78
- `Expected rejection message '${expected.message}', received '${error.message}'.${formatLastDiagnosticRejection(
79
- options
80
- )}`
81
- );
82
- }
83
- if (expected.message instanceof RegExp && !expected.message.test(error.message)) {
84
- throw new Error(
85
- `Expected rejection message '${error.message}' to match ${String(
86
- expected.message
87
- )}.${formatLastDiagnosticRejection(options)}`
88
- );
89
- }
90
- });
91
- }
92
- function formatLastDiagnosticRejection(options) {
93
- const rejection = options.lastDiagnosticRejection?.();
94
- if (!rejection) return "";
95
- const rule = rejection.ruleId ? ` ruleId=${rejection.ruleId}` : "";
96
- const message = rejection.message ? ` message=${rejection.message}` : "";
97
- return `
98
- last rejection: errorCode=${rejection.errorCode}${rule}${message}`;
99
- }
100
- function assertLength(actual, expected) {
101
- if (actual === null || actual === void 0 || typeof actual.length !== "number") {
102
- throw new Error("toHaveLength expects a value with a numeric length.");
103
- }
104
- const length = actual.length;
105
- if (length !== expected) {
106
- throw new Error(`Expected length ${expected}, received ${length}.`);
107
- }
108
- }
109
- function formatInteractionExplanation(explanation) {
110
- if (!explanation) {
111
- return "";
112
- }
113
- const lines = [
114
- `availability: ${explanation.availability}`,
115
- ...explanation.rules.map((rule) => {
116
- const code = rule.errorCode ? ` (${rule.errorCode})` : "";
117
- const message = rule.message ? `: ${rule.message}` : "";
118
- return `rule ${rule.ruleId} ${rule.outcome}${code}${message}`;
119
- }),
120
- ...explanation.inputs.map(
121
- (input) => `input ${input.key} eligibleCount=${input.eligibleCount}`
122
- )
123
- ];
124
- return `
125
- ${lines.join("\n")}`;
126
- }
127
- function assertThrown(actual, predicate) {
128
- if (typeof actual !== "function") {
129
- throw new Error("toThrow expects a function.");
130
- }
131
- try {
132
- actual();
133
- } catch (error) {
134
- if (!(error instanceof Error)) {
135
- throw new Error("Thrown value is not an Error.");
136
- }
137
- if (predicate === void 0) {
138
- return;
139
- }
140
- if (typeof predicate === "string" && error.message !== predicate) {
141
- throw new Error(
142
- `Expected thrown message '${predicate}', received '${error.message}'.`
143
- );
144
- }
145
- if (predicate instanceof RegExp && !predicate.test(error.message)) {
146
- throw new Error(
147
- `Expected thrown message '${error.message}' to match ${String(predicate)}.`
148
- );
149
- }
150
- if (typeof predicate === "function" && !predicate(error)) {
151
- throw new Error("Thrown error did not satisfy predicate.");
152
- }
153
- return;
154
- }
155
- throw new Error("Expected function to throw.");
156
- }
157
- function createExpectApi(options = {}) {
158
- const buildMatchers = (actual) => ({
159
- toBe: (expected) => {
160
- if (actual !== expected) {
161
- throw new Error(
162
- `Expected '${String(actual)}' to be '${String(expected)}'.`
163
- );
164
- }
165
- },
166
- toEqual: (expected) => {
167
- if (!isDeepStrictEqual(actual, expected)) {
168
- throw new Error("Expected values to be deeply equal.");
169
- }
170
- },
171
- toMatchObject: (expected) => {
172
- const mismatch = matchPartial(actual, expected);
173
- if (mismatch) {
174
- throw new Error(mismatch);
175
- }
176
- },
177
- toBeDefined: () => {
178
- if (actual === void 0) {
179
- throw new Error("Expected value to be defined.");
180
- }
181
- },
182
- toBeUndefined: () => {
183
- if (actual !== void 0) {
184
- throw new Error(
185
- `Expected value to be undefined, but received '${String(actual)}'.`
186
- );
187
- }
188
- },
189
- toBeNull: () => {
190
- if (actual !== null) {
191
- throw new Error(
192
- `Expected value to be null, but received '${String(actual)}'.`
193
- );
194
- }
195
- },
196
- toContain: (expected) => {
197
- if (Array.isArray(actual)) {
198
- if (!actual.includes(expected)) {
199
- throw new Error("Expected array to contain value.");
200
- }
201
- return;
202
- }
203
- if (typeof actual === "string") {
204
- if (!actual.includes(String(expected))) {
205
- throw new Error("Expected string to contain value.");
206
- }
207
- return;
208
- }
209
- throw new Error("toContain expects an array or string actual value.");
210
- },
211
- toContainEqual: (expected) => {
212
- if (!Array.isArray(actual)) {
213
- throw new Error("toContainEqual expects an array actual value.");
214
- }
215
- if (!actual.some((value) => isDeepStrictEqual(value, expected))) {
216
- throw new Error("Expected array to contain an equal value.");
217
- }
218
- },
219
- toHaveLength: (expected) => {
220
- assertLength(actual, expected);
221
- },
222
- toBeGreaterThan: (expected) => {
223
- if (typeof actual !== "number") {
224
- throw new Error("toBeGreaterThan expects a number actual value.");
225
- }
226
- if (actual <= expected) {
227
- throw new Error(`Expected ${actual} to be > ${expected}.`);
228
- }
229
- },
230
- toBeGreaterThanOrEqual: (expected) => {
231
- if (typeof actual !== "number") {
232
- throw new Error(
233
- "toBeGreaterThanOrEqual expects a number actual value."
234
- );
235
- }
236
- if (actual < expected) {
237
- throw new Error(`Expected ${actual} to be >= ${expected}.`);
238
- }
239
- },
240
- toThrow: (predicate) => {
241
- assertThrown(actual, predicate);
242
- },
243
- toMatchSnapshot: (filename) => {
244
- if (!options.matchSnapshot) {
245
- throw new Error(
246
- "Snapshot matching is not configured for this expect API."
247
- );
248
- }
249
- options.matchSnapshot(filename, actual);
250
- },
251
- toRejectWith: (expected) => createSubmissionErrorMatcher(actual, expected, options),
252
- toHaveInteraction: (interactionId, opts) => {
253
- const descriptors = asDescriptorList(actual);
254
- const descriptor = findInteraction(descriptors, interactionId);
255
- if (!descriptor) {
256
- throw new Error(`Expected interaction '${interactionId}' to exist.`);
257
- }
258
- assertDescriptorMatches(descriptor, opts);
259
- },
260
- toBeGatedBy: (reason, opts) => {
261
- const descriptor = Array.isArray(actual) ? (() => {
262
- if (!opts?.interactionId) {
263
- throw new Error(
264
- "toBeGatedBy on a descriptor array requires opts.interactionId."
265
- );
266
- }
267
- return findInteraction(
268
- asDescriptorList(actual),
269
- opts.interactionId
270
- );
271
- })() : actual;
272
- if (!descriptor) {
273
- throw new Error("Expected interaction descriptor to exist.");
274
- }
275
- if (descriptor.availability?.status === "available") {
276
- throw new Error("Expected interaction to be unavailable.");
277
- }
278
- const actualReason = descriptor.availability?.status === "notYourTurn" || descriptor.availability?.status === "insufficientResources" || descriptor.availability?.status === "blocked" ? descriptor.availability.reason : void 0;
279
- if (actualReason !== reason) {
280
- throw new Error(
281
- `Expected unavailable reason '${reason}', received '${actualReason ?? "undefined"}'.`
282
- );
283
- }
284
- },
285
- toBeAvailable: (explanation) => {
286
- const descriptor = Array.isArray(actual) ? (() => {
287
- if (!explanation?.interactionId) {
288
- throw new Error(
289
- "toBeAvailable on a descriptor array requires an explanation."
290
- );
291
- }
292
- return findInteraction(
293
- asDescriptorList(actual),
294
- explanation.interactionId
295
- );
296
- })() : actual;
297
- if (!descriptor) {
298
- throw new Error(
299
- `Expected interaction descriptor to exist.${formatInteractionExplanation(
300
- explanation
301
- )}`
302
- );
303
- }
304
- if (descriptor.availability?.status !== "available") {
305
- throw new Error(
306
- `Expected interaction '${descriptor.interactionId ?? "unknown"}' to be available.${formatInteractionExplanation(
307
- explanation
308
- )}`
309
- );
310
- }
311
- },
312
- toBeActiveFor: (playerId, opts) => {
313
- const descriptor = Array.isArray(actual) ? (() => {
314
- if (!opts?.interactionId) {
315
- throw new Error(
316
- "toBeActiveFor on a descriptor array requires opts.interactionId."
317
- );
318
- }
319
- return findInteraction(
320
- asDescriptorList(actual),
321
- opts.interactionId
322
- );
323
- })() : actual;
324
- if (!descriptor) {
325
- throw new Error("Expected interaction descriptor to exist.");
326
- }
327
- if (descriptor.context?.to !== playerId) {
328
- throw new Error(
329
- `Expected interaction to target '${playerId}', received '${descriptor.context?.to ?? "undefined"}'.`
330
- );
331
- }
332
- if (descriptor.availability?.status !== "available") {
333
- throw new Error("Expected interaction to be available.");
334
- }
335
- },
336
- not: {
337
- toHaveInteraction: (interactionId) => {
338
- const descriptors = asDescriptorList(actual);
339
- if (findInteraction(descriptors, interactionId)) {
340
- throw new Error(
341
- `Expected interaction '${interactionId}' to be absent.`
342
- );
343
- }
344
- }
345
- }
346
- });
347
- return (actual) => buildMatchers(actual);
348
- }
349
- function cloneState(value) {
350
- return structuredClone(value);
351
- }
352
- function createSubmissionError(errorCode, message) {
353
- const error = new Error(message ?? "Interaction rejected");
354
- error.name = "SubmissionError";
355
- error.errorCode = errorCode;
356
- return error;
357
- }
358
- function summarizeWireTrace(trace) {
359
- return (trace ?? []).flatMap((entry) => {
360
- if (typeof entry !== "object" || entry === null) return [];
361
- const record = entry;
362
- switch (record.kind) {
363
- case "acceptedClientInput": {
364
- const input = typeof record.input === "object" && record.input !== null ? record.input : {};
365
- return [
366
- {
367
- kind: "acceptedClientInput",
368
- interactionId: String(input.interactionId ?? ""),
369
- playerId: String(input.playerId ?? "")
370
- }
371
- ];
372
- }
373
- case "appliedEffect": {
374
- const effect = typeof record.effect === "object" && record.effect !== null ? record.effect : {};
375
- return [
376
- {
377
- kind: "appliedInstruction",
378
- instruction: String(effect.kind ?? effect.type ?? "effect")
379
- }
380
- ];
381
- }
382
- case "rngConsumption":
383
- return [
384
- {
385
- kind: "rngConsumption",
386
- operation: String(record.operation ?? ""),
387
- traceEntry: String(record.traceEntry ?? "")
388
- }
389
- ];
390
- default:
391
- return [];
392
- }
393
- });
394
- }
395
- function readFlowState(state) {
396
- const flow = state.domain?.flow ?? {};
397
- return {
398
- currentPhase: flow.currentPhase ?? null,
399
- activePlayers: Array.isArray(flow.activePlayers) ? flow.activePlayers : []
400
- };
401
- }
402
- function resolvePlayerIds(options) {
403
- if (options.explicitPlayerIds && options.explicitPlayerIds.length > 0) {
404
- return [...options.explicitPlayerIds];
405
- }
406
- return Array.from(
407
- { length: options.baseState.fingerprint.players },
408
- (_, index) => `player-${index + 1}`
409
- );
410
- }
411
- function isWireZoneHandles(value) {
412
- return typeof value === "object" && value !== null;
413
- }
414
- function buildPluginSnapshot(options) {
415
- const projection = options.bundle.projectSeatsDynamic({
416
- state: options.state,
417
- playerIds: [options.playerId]
418
- });
419
- const flow = readFlowState(options.state);
420
- if (options.expectedPhase && flow.currentPhase !== options.expectedPhase) {
421
- throw new Error(
422
- `Expected base '${options.baseId}' to be in phase '${options.expectedPhase}', received '${flow.currentPhase ?? "null"}'.`
423
- );
424
- }
425
- const interactionsByRef = projection.interactionsByRef ?? {};
426
- const hydrateRefs = (refs) => (refs ?? []).map((ref) => interactionsByRef[ref]).filter(
427
- (descriptor) => Boolean(descriptor)
428
- );
429
- const seat = projection.seats?.[options.playerId];
430
- const zones = Object.fromEntries(
431
- Object.entries(
432
- seat?.zones ?? {}
433
- ).map(([zoneId, zoneValue]) => {
434
- const zone = isWireZoneHandles(zoneValue) ? zoneValue : {};
435
- return [
436
- zoneId,
437
- {
438
- cardIds: [...zone.cardIds ?? []],
439
- cardViewsById: { ...zone.cardViewsById ?? {} },
440
- playableByCardId: Object.fromEntries(
441
- Object.entries(zone.playableByCardId ?? {}).map(
442
- ([cardId, refs]) => [cardId, hydrateRefs(refs)]
443
- )
444
- )
445
- }
446
- ];
447
- })
448
- );
449
- return {
450
- view: seat?.view ?? null,
451
- gameplay: {
452
- currentPhase: flow.currentPhase,
453
- currentStage: projection.currentStage ?? null,
454
- activePlayers: flow.activePlayers,
455
- simultaneousPhase: projection.simultaneousPhase ?? null,
456
- availableInteractions: hydrateRefs(
457
- seat?.availableInteractionRefs
458
- ),
459
- zones
460
- },
461
- lobby: null,
462
- notifications: [],
463
- session: {
464
- sessionId: options.sessionId,
465
- controllablePlayerIds: [...options.playerIds],
466
- controllingPlayerId: options.playerId || null,
467
- userId: options.userId
468
- },
469
- history: null,
470
- syncId: options.version
471
- };
472
- }
473
- function createTestRuntime(options) {
474
- const baseState = options.baseStates[options.baseId];
475
- if (!baseState) {
476
- throw new Error(`Unknown test base '${options.baseId}'.`);
477
- }
478
- const expectedBaseStateFingerprint = options.expectedBaseStateFingerprint ?? baseState.fingerprint.contractFingerprint;
479
- if (options.contractFingerprint && expectedBaseStateFingerprint && options.contractFingerprint !== expectedBaseStateFingerprint) {
480
- throw new StaleContractArtifactError({
481
- artifact: "base-states",
482
- expected: options.contractFingerprint,
483
- found: expectedBaseStateFingerprint
484
- });
485
- }
486
- let currentState = cloneState(baseState.snapshot);
487
- const playerIds = resolvePlayerIds({
488
- baseState,
489
- explicitPlayerIds: options.playerIds
490
- });
491
- const userId = options.userId ?? "test-user";
492
- const sessionId = options.sessionId ?? "test-session";
493
- let version = 0;
494
- let submissionCounter = 0;
495
- let currentPlayerId = playerIds[0] ?? "";
496
- const diagnosticEvents = [];
497
- let lastDispatch = null;
498
- const stateListeners = /* @__PURE__ */ new Set();
499
- const sessionListeners = /* @__PURE__ */ new Set();
500
- const toReadySessionState = (snapshot) => ({
501
- ...snapshot.session,
502
- status: "ready"
503
- });
504
- let lastPluginSnapshot;
505
- let lastSessionState;
506
- const applyCurrentState = () => {
507
- const previousSession = lastSessionState;
508
- version += 1;
509
- lastPluginSnapshot = buildPluginSnapshot({
510
- state: currentState,
511
- bundle: options.bundle,
512
- playerId: currentPlayerId,
513
- playerIds,
514
- userId,
515
- sessionId,
516
- version,
517
- expectedPhase: version === 1 ? options.phase : void 0,
518
- baseId: options.baseId
519
- });
520
- lastSessionState = toReadySessionState(lastPluginSnapshot);
521
- for (const listener of stateListeners) {
522
- listener(lastPluginSnapshot);
523
- }
524
- if (!previousSession || previousSession.controllingPlayerId !== lastSessionState.controllingPlayerId || previousSession.controllablePlayerIds.join("\0") !== lastSessionState.controllablePlayerIds.join("\0")) {
525
- for (const listener of sessionListeners) {
526
- listener(lastSessionState);
527
- }
528
- }
529
- };
530
- applyCurrentState();
531
- const validate = async (playerId, interactionId, params = {}) => {
532
- const result = await options.bundle.validateInput({
533
- state: currentState,
534
- input: {
535
- kind: "interaction",
536
- playerId,
537
- interactionId,
538
- params
539
- }
540
- });
541
- return {
542
- valid: result.valid,
543
- errorCode: result.errorCode,
544
- message: result.message
545
- };
546
- };
547
- const submit = async (playerId, interactionId, params = {}) => {
548
- submissionCounter += 1;
549
- const submissionId = `sub-${submissionCounter}`;
550
- diagnosticEvents.push({
551
- type: "submitReceived",
552
- submissionId,
553
- playerId,
554
- interactionId,
555
- phase: readFlowState(currentState).currentPhase ?? ""
556
- });
557
- const validation = await validate(playerId, interactionId, params);
558
- if (!validation.valid) {
559
- diagnosticEvents.push({
560
- type: "submitRejected",
561
- submissionId,
562
- errorCode: validation.errorCode ?? "invalid-action",
563
- ...validation.message ? { message: validation.message } : {}
564
- });
565
- throw createSubmissionError(validation.errorCode, validation.message);
566
- }
567
- const result = await options.bundle.dispatch({
568
- state: currentState,
569
- input: {
570
- kind: "interaction",
571
- playerId,
572
- interactionId,
573
- params
574
- }
575
- });
576
- if (result.kind === "reject") {
577
- diagnosticEvents.push({
578
- type: "submitRejected",
579
- submissionId,
580
- errorCode: result.errorCode,
581
- ...result.message ? { message: result.message } : {}
582
- });
583
- throw createSubmissionError(result.errorCode, result.message);
584
- }
585
- const trace = summarizeWireTrace(result.trace);
586
- lastDispatch = { submissionId, trace };
587
- diagnosticEvents.push({
588
- type: "submitAccepted",
589
- submissionId,
590
- trace
591
- });
592
- currentState = cloneState(result.state);
593
- applyCurrentState();
594
- };
595
- const explain = (playerId, interactionId) => {
596
- if (!options.bundle.explainInteraction) {
597
- throw new Error(
598
- "This reducer bundle does not expose explainInteraction()."
599
- );
600
- }
601
- return options.bundle.explainInteraction({
602
- state: currentState,
603
- playerId,
604
- interactionId
605
- });
606
- };
607
- const setControllingPlayer = (playerId) => {
608
- if (!playerIds.includes(playerId)) {
609
- throw new Error(`Unknown controlling player '${playerId}'.`);
610
- }
611
- currentPlayerId = playerId;
612
- applyCurrentState();
613
- };
614
- const runtime = {
615
- validateInteraction: validate,
616
- submitInteraction: submit,
617
- getSessionState: () => lastSessionState,
618
- disconnect: () => void 0,
619
- switchPlayer: (playerId) => {
620
- setControllingPlayer(playerId);
621
- },
622
- getSnapshot: () => lastPluginSnapshot,
623
- subscribeToState: (listener) => {
624
- stateListeners.add(listener);
625
- return () => {
626
- stateListeners.delete(listener);
627
- };
628
- },
629
- _subscribeToSessionState: (listener) => {
630
- sessionListeners.add(listener);
631
- return () => {
632
- sessionListeners.delete(listener);
633
- };
634
- }
635
- };
636
- return {
637
- runtime,
638
- getSnapshot: () => lastPluginSnapshot,
639
- players: () => [...playerIds],
640
- seat: (index) => {
641
- if (!Number.isInteger(index) || index < 0 || index >= playerIds.length) {
642
- throw new Error(
643
- `seat(${index}) is out of range; base '${options.baseId}' has ${playerIds.length} player(s).`
644
- );
645
- }
646
- return playerIds[index];
647
- },
648
- submit,
649
- validate,
650
- explain,
651
- diagnostics: {
652
- get events() {
653
- return diagnosticEvents;
654
- },
655
- get lastDispatch() {
656
- return lastDispatch;
657
- },
658
- clear() {
659
- diagnosticEvents.length = 0;
660
- lastDispatch = null;
661
- }
662
- },
663
- setControllingPlayer
664
- };
665
- }
666
- export {
667
- StaleContractArtifactError,
668
- createExpectApi,
669
- createTestRuntime,
670
- defineBase,
671
- defineScenario,
672
- isStaleContractArtifactError
673
- };
674
- //# sourceMappingURL=testing-KLSV6CPJ.js.map