@dreamboard-games/cli 0.1.30-alpha.0 → 0.1.30-alpha.2

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