vibedgames 0.8.1 → 0.10.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 (96) hide show
  1. package/README.md +17 -8
  2. package/assets/align-framing.py +242 -0
  3. package/assets/render-model.py +406 -0
  4. package/assets/tilemap-editor.html +630 -0
  5. package/dist/THIRD_PARTY_NOTICES.txt +59 -7
  6. package/dist/chunk-2KVQJKIZ.js +6495 -0
  7. package/dist/chunk-2SBBKY5C.js +16993 -0
  8. package/dist/chunk-2ZKS7V72.js +170 -0
  9. package/dist/{chunk-RAUJA3OY.js → chunk-3HGBIUM5.js} +21 -18
  10. package/dist/chunk-3UGGMFJJ.js +22 -0
  11. package/dist/{chunk-I6O4HIDY.js → chunk-42K3BJJH.js} +163 -131
  12. package/dist/chunk-43P4U7CB.js +104 -0
  13. package/dist/chunk-4FJXCS3K.js +741 -0
  14. package/dist/{chunk-NC5XCGYU.js → chunk-4UU622RK.js} +6 -5
  15. package/dist/{chunk-2QBYTIMH.js → chunk-5535KDYI.js} +1 -1
  16. package/dist/chunk-5YPLKGY3.js +87 -0
  17. package/dist/chunk-6KXXZXSO.js +475 -0
  18. package/dist/chunk-7RPLQWR2.js +91 -0
  19. package/dist/{chunk-C2IRIRAA.js → chunk-A556KALN.js} +15 -14
  20. package/dist/{chunk-N3XAUFKH.js → chunk-ABTUEIRC.js} +576 -301
  21. package/dist/{chunk-PEUP4MZR.js → chunk-AWJNAGPE.js} +6 -3
  22. package/dist/{chunk-QGEITHUP.js → chunk-BN3Q7UEC.js} +22 -19
  23. package/dist/chunk-BZOMEG3X.js +412 -0
  24. package/dist/{chunk-ZYCSYJWX.js → chunk-COSLGSVO.js} +14 -24
  25. package/dist/{chunk-PQDBCZRT.js → chunk-CTY2WZQK.js} +204 -158
  26. package/dist/{chunk-CU7UY5YJ.js → chunk-D2RF35HJ.js} +1 -1
  27. package/dist/chunk-DB7WVFS7.js +80 -0
  28. package/dist/chunk-DOOQUFPG.js +73 -0
  29. package/dist/chunk-E3FJUPLT.js +177 -0
  30. package/dist/chunk-E7NDOZ27.js +428 -0
  31. package/dist/chunk-F42QKWBB.js +39 -0
  32. package/dist/chunk-FXXVXDTW.js +168 -0
  33. package/dist/{chunk-VFFOT7KD.js → chunk-G66HRVDW.js} +1 -1
  34. package/dist/{chunk-CAKBGDCY.js → chunk-GKDUYJ7R.js} +5 -0
  35. package/dist/chunk-GLEW7VJQ.js +45 -0
  36. package/dist/{chunk-MGIASPED.js → chunk-H2C4QUTG.js} +9 -8
  37. package/dist/{chunk-HCMTSR7E.js → chunk-HRKVAXNN.js} +21 -17
  38. package/dist/{chunk-TLRL6FHW.js → chunk-HSMG6U7J.js} +10 -9
  39. package/dist/chunk-HX5Q63UA.js +48 -0
  40. package/dist/chunk-HYOXGNWS.js +53 -0
  41. package/dist/chunk-I5LELJSK.js +22 -0
  42. package/dist/{chunk-6FZPPUQH.js → chunk-JN4WZCR7.js} +5 -4
  43. package/dist/{chunk-QJZ72MSY.js → chunk-K36EOII3.js} +7 -6
  44. package/dist/chunk-KAGVI3CE.js +62 -0
  45. package/dist/chunk-KJK5CB6E.js +58 -0
  46. package/dist/chunk-KLFBAFXD.js +25 -0
  47. package/dist/{chunk-7MKUR7Y3.js → chunk-LONQWRTR.js} +112 -81
  48. package/dist/chunk-LORGE2NB.js +2484 -0
  49. package/dist/{chunk-HKA5LBYW.js → chunk-MEAO33XW.js} +22 -19
  50. package/dist/{chunk-PM5UOIKR.js → chunk-MR5KIFI7.js} +22 -21
  51. package/dist/{chunk-GCX5KQ6A.js → chunk-N2UHAQXC.js} +18 -11
  52. package/dist/chunk-NCX6LYNJ.js +117 -0
  53. package/dist/chunk-OGX4DKIS.js +215 -0
  54. package/dist/chunk-OPUCUUID.js +41 -0
  55. package/dist/chunk-Q2QC6KAZ.js +132 -0
  56. package/dist/{chunk-2GL2WJZX.js → chunk-Q3XQPNF6.js} +14 -14
  57. package/dist/{chunk-RYFO3ZPO.js → chunk-Q5NZNXJE.js} +15 -12
  58. package/dist/{chunk-JT2AU24K.js → chunk-QARXJGI5.js} +1 -1
  59. package/dist/chunk-QLCVLCPM.js +126 -0
  60. package/dist/chunk-R2WVORGD.js +91 -0
  61. package/dist/chunk-RKS7SI5L.js +64 -0
  62. package/dist/{chunk-4BGCA3W7.js → chunk-RPJR3S5S.js} +32 -18
  63. package/dist/chunk-RPSUFZAG.js +3307 -0
  64. package/dist/chunk-RRI23NK2.js +40 -0
  65. package/dist/chunk-S7HYWITX.js +57 -0
  66. package/dist/chunk-SBXCK2I2.js +48 -0
  67. package/dist/chunk-SUSX3QIA.js +62 -0
  68. package/dist/{chunk-PHEDW6C7.js → chunk-SXYQL4GK.js} +16 -7
  69. package/dist/{chunk-ZI6PKVXG.js → chunk-TMPBGXT4.js} +6 -5
  70. package/dist/chunk-TXOE5UY5.js +72 -0
  71. package/dist/chunk-U6DTE5IX.js +124 -0
  72. package/dist/chunk-UPHB5HWO.js +115 -0
  73. package/dist/chunk-UQ7VO6B3.js +91 -0
  74. package/dist/chunk-VB4WLJR2.js +47 -0
  75. package/dist/{chunk-FNYBZNW2.js → chunk-VIEKOGKG.js} +21 -3
  76. package/dist/{chunk-QIVCBUYD.js → chunk-VZEJ2ZHE.js} +18 -18
  77. package/dist/chunk-X75Y7LUW.js +126 -0
  78. package/dist/{chunk-Z4Z24FWO.js → chunk-YNCYMWER.js} +8 -5
  79. package/dist/chunk-ZHLPE6LI.js +71 -0
  80. package/dist/index.js +48 -34
  81. package/package.json +32 -16
  82. package/templates/none/src/main.ts +4 -0
  83. package/templates/none/vite.config.ts +0 -2
  84. package/templates/phaser/src/main.ts +0 -1
  85. package/templates/phaser/src/scenes/game-scene.ts +10 -8
  86. package/templates/phaser/vite.config.ts +0 -2
  87. package/templates/react-r3f/src/app.tsx +3 -1
  88. package/templates/react-r3f/src/main.tsx +1 -0
  89. package/templates/react-r3f/vite.config.ts +0 -2
  90. package/templates/threejs/src/main.ts +10 -1
  91. package/templates/threejs/vite.config.ts +0 -2
  92. package/LICENSE +0 -21
  93. package/dist/chunk-AYJQVZXY.js +0 -39
  94. package/dist/chunk-J6PKNPI2.js +0 -26
  95. package/dist/chunk-MJQSHP3Y.js +0 -415
  96. package/dist/chunk-MYFLYNPO.js +0 -68
@@ -8,39 +8,42 @@ import {
8
8
  ensureAgentBrowser,
9
9
  projectSessionId,
10
10
  resolveGameUrl
11
- } from "./chunk-4BGCA3W7.js";
12
- import "./chunk-GCX5KQ6A.js";
13
- import "./chunk-6FZPPUQH.js";
14
- import "./chunk-2QBYTIMH.js";
15
- import "./chunk-ZI6PKVXG.js";
11
+ } from "./chunk-RPJR3S5S.js";
12
+ import "./chunk-N2UHAQXC.js";
13
+ import "./chunk-TMPBGXT4.js";
14
+ import {
15
+ assertKnownFlags
16
+ } from "./chunk-RZ4DIJQW.js";
17
+ import "./chunk-JN4WZCR7.js";
16
18
  import {
17
19
  authErrorCode,
18
20
  createClient
19
- } from "./chunk-PQDBCZRT.js";
20
- import "./chunk-Z4Z24FWO.js";
21
- import "./chunk-PEUP4MZR.js";
21
+ } from "./chunk-CTY2WZQK.js";
22
+ import "./chunk-E3FJUPLT.js";
23
+ import {
24
+ getBaseUrl,
25
+ getToken
26
+ } from "./chunk-Q5NZNXJE.js";
22
27
  import {
23
28
  outputArgs,
24
29
  writeStructured
25
- } from "./chunk-ZYCSYJWX.js";
30
+ } from "./chunk-COSLGSVO.js";
26
31
  import {
27
- assertKnownFlags
28
- } from "./chunk-RZ4DIJQW.js";
29
- import {
30
- getBaseUrl,
31
- getToken
32
- } from "./chunk-RYFO3ZPO.js";
32
+ defineCommand
33
+ } from "./chunk-MBXCVCC4.js";
34
+ import "./chunk-5535KDYI.js";
33
35
  import {
34
36
  consola
35
- } from "./chunk-CU7UY5YJ.js";
37
+ } from "./chunk-D2RF35HJ.js";
38
+ import "./chunk-YNCYMWER.js";
39
+ import "./chunk-AWJNAGPE.js";
36
40
  import {
37
41
  isJsonObject,
38
- isJsonString
39
- } from "./chunk-J6PKNPI2.js";
40
- import {
41
- defineCommand
42
- } from "./chunk-MBXCVCC4.js";
43
- import "./chunk-CAKBGDCY.js";
42
+ isJsonString,
43
+ parseJson
44
+ } from "./chunk-RPSUFZAG.js";
45
+ import "./chunk-2SBBKY5C.js";
46
+ import "./chunk-GKDUYJ7R.js";
44
47
 
45
48
  // src/lib/playtest/browser.ts
46
49
  import { spawnSync } from "node:child_process";
@@ -94,7 +97,7 @@ var GameBrowser = class {
94
97
  }
95
98
  let parsed;
96
99
  try {
97
- parsed = JSON.parse(text);
100
+ parsed = parseJson(text);
98
101
  } catch {
99
102
  throw new HarnessError(`\`${args[0]} --json\` did not return JSON: ${text.slice(0, 200)}`);
100
103
  }
@@ -115,12 +118,6 @@ var GameBrowser = class {
115
118
  evaluate(expression) {
116
119
  return this.payload(["eval", expression], "result");
117
120
  }
118
- /**
119
- * Navigate and wait for the diagnostics contract. Logs are cleared BEFORE
120
- * navigating so boot errors belong to this run. Waits for the CONTRACT,
121
- * not for frames: most games boot into a menu where the loop hasn't
122
- * started, so frames only advance once setState('active-play') has run.
123
- */
124
121
  boot(url, headed, whenAbsent) {
125
122
  this.run(["console", "--clear"]);
126
123
  this.run(["errors", "--clear"]);
@@ -132,12 +129,6 @@ var GameBrowser = class {
132
129
  throw new HarnessError(whenAbsent);
133
130
  }
134
131
  }
135
- /**
136
- * Two ways a game can honour a seed: a `seed()` hook that restarts the run,
137
- * or a `?seed=` boot param for games whose scene is single-start. Calling
138
- * an absent hook would leave the run unseeded while the report still
139
- * claimed the seed, so detect which one this game implements.
140
- */
141
132
  applySeed(seed, headed) {
142
133
  const probe = this.evaluate(
143
134
  "({ hasSeedHook: typeof window.__GAME_TEST_HOOKS__?.seed === 'function', href: location.href })"
@@ -362,11 +353,11 @@ var shiftedKey = (code, key) => {
362
353
  };
363
354
  var keyFields = (code) => {
364
355
  const letter = /^Key(?<letter>[A-Z])$/u.exec(code)?.groups?.letter;
365
- if (letter) {
356
+ if (letter !== void 0 && letter !== "") {
366
357
  return [letter.codePointAt(0) ?? 0, letter.toLowerCase()];
367
358
  }
368
359
  const digit = /^Digit(?<digit>[0-9])$/u.exec(code)?.groups?.digit;
369
- if (digit) {
360
+ if (digit !== void 0 && digit !== "") {
370
361
  return [48 + Number(digit), digit];
371
362
  }
372
363
  const keyCode = NAMED_KEYS.get(code);
@@ -550,7 +541,7 @@ var parseControls = (raw, source) => {
550
541
  moves[label] = readMoveOption(option, `${source} move.${label}`);
551
542
  }
552
543
  if (!Object.values(moves).some(
553
- (option) => option.keys.length > 0 || option.pointer || option.reflex
544
+ (option) => option.keys.length > 0 || option.pointer !== null || option.reflex
554
545
  )) {
555
546
  fail(`${source}: no \`move\` option holds any input, so the playtester could never move.`);
556
547
  }
@@ -592,7 +583,7 @@ var readControlsArg = (value) => {
592
583
  }
593
584
  let raw;
594
585
  try {
595
- raw = JSON.parse(text);
586
+ raw = parseJson(text);
596
587
  } catch (error) {
597
588
  fail(
598
589
  `--controls ${value} isn't valid JSON: ${error instanceof Error ? error.message : String(error)}`
@@ -626,15 +617,35 @@ var browserEnv = () => {
626
617
  return type === "pointerdown" ? "mousedown" : "mouseup";
627
618
  };
628
619
  let lastPointer = null;
620
+ const isJson = (value) => {
621
+ if (value === null || Number.isFinite(value)) {
622
+ return true;
623
+ }
624
+ if (Array.isArray(value)) {
625
+ return value.every((item) => isJson(item));
626
+ }
627
+ const tag = Object.prototype.toString.call(value);
628
+ return tag === "[object String]" || tag === "[object Boolean]" || tag === "[object Object]" && value instanceof Object && Object.values(value).every((item) => isJson(item));
629
+ };
630
+ const readJson = (text) => {
631
+ const value = JSON.parse(text);
632
+ if (!isJson(value)) {
633
+ throw new TypeError("not JSON");
634
+ }
635
+ return value;
636
+ };
629
637
  const isFunction = (value) => Object.prototype.toString.call(value) === "[object Function]";
630
638
  return {
631
- caf: (id) => window.cancelAnimationFrame(id),
632
- delay: (ms) => (
633
- // oxlint-disable-next-line promise/avoid-new -- the page has no timers/promises; wrapping setTimeout is the only way to await a delay there
634
- new Promise((resolve) => {
635
- window.setTimeout(resolve, ms);
636
- })
637
- ),
639
+ caf: (id) => {
640
+ window.cancelAnimationFrame(id);
641
+ },
642
+ delay: async (ms) => {
643
+ const { promise, resolve } = Promise.withResolvers();
644
+ window.setTimeout(() => {
645
+ resolve(ms);
646
+ }, ms);
647
+ await promise;
648
+ },
638
649
  dispatchKey: (type, init) => {
639
650
  const target = document.activeElement ?? document.body ?? window;
640
651
  target.dispatchEvent(new KeyboardEvent(type, init));
@@ -669,7 +680,7 @@ var browserEnv = () => {
669
680
  target.dispatchEvent(new PointerEvent(type, init));
670
681
  target.dispatchEvent(new MouseEvent(mouseType(type), init));
671
682
  },
672
- fetch: (url, init) => window.fetch(url, init),
683
+ fetch: async (url, init) => await window.fetch(url, init),
673
684
  live: () => window.__GAME_DIAGNOSTICS__ ?? null,
674
685
  now: () => Date.now(),
675
686
  publish: (result) => {
@@ -683,7 +694,7 @@ var browserEnv = () => {
683
694
  },
684
695
  snapshot: () => {
685
696
  try {
686
- return JSON.parse(JSON.stringify(window.__GAME_DIAGNOSTICS__ ?? null));
697
+ return readJson(JSON.stringify(window.__GAME_DIAGNOSTICS__ ?? null));
687
698
  } catch {
688
699
  return null;
689
700
  }
@@ -692,6 +703,24 @@ var browserEnv = () => {
692
703
  };
693
704
  var inPageAgent = (config, env) => {
694
705
  const isObject = (value) => Object(value) === value && !Array.isArray(value);
706
+ const isText = (value) => Object.prototype.toString.call(value) === "[object String]";
707
+ const isJson = (value) => {
708
+ if (value === null || Number.isFinite(value)) {
709
+ return true;
710
+ }
711
+ if (Array.isArray(value)) {
712
+ return value.every((item) => isJson(item));
713
+ }
714
+ const tag = Object.prototype.toString.call(value);
715
+ return tag === "[object String]" || tag === "[object Boolean]" || tag === "[object Object]" && value instanceof Object && Object.values(value).every((item) => isJson(item));
716
+ };
717
+ const readJson = (text) => {
718
+ const value = JSON.parse(text);
719
+ if (!isJson(value)) {
720
+ throw new TypeError("not JSON");
721
+ }
722
+ return value;
723
+ };
695
724
  const round2 = (value) => Number(value.toFixed(2));
696
725
  const started = env.now();
697
726
  const usage = {
@@ -846,7 +875,7 @@ var inPageAgent = (config, env) => {
846
875
  const parseDecision = (text, offered) => {
847
876
  let body;
848
877
  try {
849
- body = JSON.parse(text);
878
+ body = readJson(text);
850
879
  } catch {
851
880
  throw new Error(`decision response was not JSON: ${text.slice(0, 200)}`);
852
881
  }
@@ -855,7 +884,7 @@ var inPageAgent = (config, env) => {
855
884
  throw new Error(`decision response had no answers: ${text.slice(0, 200)}`);
856
885
  }
857
886
  const move2 = answerFor(answers, "move");
858
- const choice = String(move2.choice ?? "");
887
+ const choice = isText(move2.choice) ? move2.choice : "";
859
888
  if (!Object.hasOwn(offered, choice)) {
860
889
  throw new Error(`decision model answered \`move\` outside the offered options: ${choice}`);
861
890
  }
@@ -904,7 +933,7 @@ var inPageAgent = (config, env) => {
904
933
  }
905
934
  const offered = offeredMoves(state.tick.index);
906
935
  const body = JSON.stringify({ model: config.model, questions: questions(offered), state });
907
- for (let attempt = 0; ; attempt += 1) {
936
+ const ask = async (attempt) => {
908
937
  let response = null;
909
938
  let failure = "";
910
939
  try {
@@ -922,7 +951,7 @@ var inPageAgent = (config, env) => {
922
951
  } catch (error) {
923
952
  failure = error instanceof Error ? error.message : String(error);
924
953
  }
925
- if (response?.ok) {
954
+ if (response?.ok === true) {
926
955
  const text = await response.text();
927
956
  return parseDecision(text, offered);
928
957
  }
@@ -935,14 +964,15 @@ var inPageAgent = (config, env) => {
935
964
  throw new Error(`decision failed after ${attempt + 1} attempts: ${reason}`);
936
965
  }
937
966
  await env.delay(500 * 2 ** attempt);
938
- }
967
+ return await ask(attempt + 1);
968
+ };
969
+ return await ask(0);
939
970
  };
940
971
  const pointerFrom = (input) => {
941
972
  if (!input) {
942
973
  return null;
943
974
  }
944
- const x = Number(input.x);
945
- const y = Number(input.y);
975
+ const { x, y } = input;
946
976
  if (!Number.isFinite(x) || !Number.isFinite(y)) {
947
977
  return null;
948
978
  }
@@ -1079,17 +1109,16 @@ var inPageAgent = (config, env) => {
1079
1109
  };
1080
1110
  const run = async () => {
1081
1111
  rafId = env.raf(frame);
1082
- let game = env.snapshot();
1083
- for (let tick = 0; tick < config.ticks; tick += 1) {
1084
- if (stopped) {
1085
- break;
1112
+ const play = async (tick, game) => {
1113
+ if (tick >= config.ticks || stopped) {
1114
+ return;
1086
1115
  }
1087
1116
  const t0 = env.now();
1088
1117
  const decision = await decide(stateFor(game, tick));
1089
1118
  const decisionMs = env.now() - t0;
1090
1119
  record(decision, decisionMs);
1091
1120
  if (stopped) {
1092
- break;
1121
+ return;
1093
1122
  }
1094
1123
  if (pending) {
1095
1124
  const remaining = config.tickMs - (env.now() - pending.appliedAt);
@@ -1115,13 +1144,14 @@ var inPageAgent = (config, env) => {
1115
1144
  reflexStuck: false,
1116
1145
  tick
1117
1146
  };
1118
- game = env.snapshot();
1119
1147
  if (measured.complete) {
1120
1148
  result.completedAtTick = Math.max(0, tick - 1);
1121
1149
  pending = null;
1122
- break;
1150
+ return;
1123
1151
  }
1124
- }
1152
+ await play(tick + 1, env.snapshot());
1153
+ };
1154
+ await play(0, env.snapshot());
1125
1155
  if (pending && !stopped) {
1126
1156
  await env.delay(Math.max(config.tickMs, config.finalHoldMs));
1127
1157
  const measured = flush();
@@ -1357,13 +1387,13 @@ var resultFromAgent = (published, epsilon = THRESHOLDS.displacement * THRESHOLDS
1357
1387
  var runInPage = async (browser, opts, session) => {
1358
1388
  browser.inject(agentSource(agentConfig(opts, session)));
1359
1389
  const deadline = Date.now() + budgetMs(opts);
1360
- for (; ; ) {
1390
+ const waitForAgent = async () => {
1361
1391
  const status = browser.agentStatus();
1362
1392
  if (!status) {
1363
1393
  throw new HarnessError("the page lost the agent; it probably navigated mid-run.");
1364
1394
  }
1365
1395
  if (status.done) {
1366
- break;
1396
+ return;
1367
1397
  }
1368
1398
  if (Date.now() > deadline) {
1369
1399
  browser.stopAgent();
@@ -1372,11 +1402,16 @@ var runInPage = async (browser, opts, session) => {
1372
1402
  );
1373
1403
  }
1374
1404
  await delay(POLL_MS);
1375
- }
1405
+ await waitForAgent();
1406
+ };
1407
+ await waitForAgent();
1376
1408
  return resultFromAgent(browser.agentResult(), motionEpsilon(opts.controls));
1377
1409
  };
1378
1410
  var summarizeProgress = (timeline) => {
1379
- const scored = timeline.map((entry) => entry.progress).filter((p) => p !== null);
1411
+ const scored = timeline.flatMap((entry) => {
1412
+ const p = entry.progress;
1413
+ return p === null ? [] : [p];
1414
+ });
1380
1415
  const [first] = scored;
1381
1416
  const last = scored.at(-1);
1382
1417
  if (first === void 0 || last === void 0) {
@@ -1433,12 +1468,9 @@ var buildReport = (opts, input) => {
1433
1468
  distanceTravelled: round(run.metrics.distance),
1434
1469
  framesAdvanced: (last ? last.frame : before.frame) - before.frame,
1435
1470
  goal: opts.controls.goal,
1436
- // Which GPU rasterized the run. Under software rendering the functional
1437
- // checks still hold; any frame-rate read from the run does not.
1438
1471
  gpu: input.gpu,
1439
1472
  longestStuckRun: run.metrics.longestStuckRun,
1440
1473
  maxTickDisplacement: round(run.metrics.maxTickDisplacement),
1441
- // The gate `maxTickDisplacement` was held to, so the number reads in context.
1442
1474
  minDisplacement: displacementGate(opts.controls),
1443
1475
  model: {
1444
1476
  calls: run.usage.calls,
@@ -1452,8 +1484,6 @@ var buildReport = (opts, input) => {
1452
1484
  scoreAfter: last ? last.score : before.score,
1453
1485
  scoreBefore: before.score,
1454
1486
  seed: input.seed,
1455
- // How the seed actually landed, so a reader can tell a real seeded run
1456
- // from one where the hook quietly did nothing.
1457
1487
  seedApplied: input.seedApplied,
1458
1488
  stuckTicks: run.metrics.stuckTicks,
1459
1489
  target: input.target,
@@ -1584,13 +1614,17 @@ var numberArg = (raw, flag, check, hint) => {
1584
1614
  }
1585
1615
  return value;
1586
1616
  };
1587
- var settingsFrom = (args) => {
1588
- if (!args.url && !args.game) {
1617
+ var isFilled = (value) => value !== void 0 && value !== "";
1618
+ var assertOneTarget = (args) => {
1619
+ if (!isFilled(args.url) && !isFilled(args.game)) {
1589
1620
  throw new HarnessError("Pass --url <url> or --game <slug>.");
1590
1621
  }
1591
- if (args.url && args.game) {
1622
+ if (isFilled(args.url) && isFilled(args.game)) {
1592
1623
  throw new HarnessError("Pass either --url or --game, not both.");
1593
1624
  }
1625
+ };
1626
+ var settingsFrom = (args) => {
1627
+ assertOneTarget(args);
1594
1628
  if (args.goal !== void 0 && args.goal.trim() === "") {
1595
1629
  throw new HarnessError("`--goal` must not be empty.");
1596
1630
  }
@@ -1612,7 +1646,7 @@ var settingsFrom = (args) => {
1612
1646
  model: args.model,
1613
1647
  pinMove: args.pinMove ?? null,
1614
1648
  seed: numberArg(args.seed, "--seed", Number.isFinite, "a finite number"),
1615
- target: args.game ? `game:${args.game}` : args.url ?? "",
1649
+ target: isFilled(args.game) ? `game:${args.game ?? ""}` : args.url ?? "",
1616
1650
  tickMs: numberArg(
1617
1651
  args.tickMs,
1618
1652
  "--tick-ms",
@@ -1629,10 +1663,7 @@ var settingsFrom = (args) => {
1629
1663
  };
1630
1664
  };
1631
1665
  var chooseControls = (settings, manifest) => {
1632
- let controls = settings.explicitControls;
1633
- if (!controls) {
1634
- controls = manifest === null ? PRESETS.get(DEFAULT_PRESET) : parseControls(manifest, "window.__GAME_PLAYTEST__");
1635
- }
1666
+ const controls = settings.explicitControls ?? (manifest === null ? PRESETS.get(DEFAULT_PRESET) : parseControls(manifest, "window.__GAME_PLAYTEST__"));
1636
1667
  if (!controls) {
1637
1668
  throw new HarnessError("no control scheme available.");
1638
1669
  }
@@ -1707,7 +1738,7 @@ var playtestRunCommand = defineCommand({
1707
1738
  consola.error(error instanceof Error ? error.message : String(error));
1708
1739
  process.exit(HARNESS_FAILURE);
1709
1740
  }
1710
- if (!getToken()) {
1741
+ if ((getToken() ?? "") === "") {
1711
1742
  consola.warn("Not logged in. Run `vg login` to authenticate.");
1712
1743
  process.exit(1);
1713
1744
  }