ravensight-playtest 0.18.0 → 0.19.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 (85) hide show
  1. package/README.md +160 -16
  2. package/addons/desktop/RavensightDesktop.swift +367 -0
  3. package/addons/mobile/UITests/MobileInputTests.swift +67 -1
  4. package/addons/ravensight_driver/driver.gd +557 -4
  5. package/docs/ADAPTERS.md +37 -7
  6. package/docs/DESKTOP.md +117 -0
  7. package/docs/MOBILE.md +30 -3
  8. package/docs/UNITY.md +149 -0
  9. package/docs/UNREAL.md +123 -0
  10. package/docs/godot-driver.md +98 -1
  11. package/package.json +15 -5
  12. package/src/cli.js +26 -10
  13. package/src/commands/build.js +40 -0
  14. package/src/commands/feature.js +1 -1
  15. package/src/commands/hosted.js +78 -9
  16. package/src/commands/run.js +47 -13
  17. package/src/commands/validate.js +1 -1
  18. package/src/hosted/archivePreflight.js +31 -4
  19. package/src/hosted/buildStatus.js +26 -0
  20. package/src/hosted/buildUpload.js +24 -9
  21. package/src/hosted/nativeBuild.js +87 -0
  22. package/src/hosted/recordedRun.js +15 -3
  23. package/src/run/anygame/genre.js +98 -24
  24. package/src/run/anygame/genre2d.js +108 -0
  25. package/src/run/anygame/index.js +7 -4
  26. package/src/run/anygame/scene3d.js +562 -0
  27. package/src/run/anygame/shared-hashes.json +4 -2
  28. package/src/run/anygame/shared.js +3 -3
  29. package/src/run/args.js +15 -4
  30. package/src/run/drivers/desktop/app.js +104 -0
  31. package/src/run/drivers/desktop/common.js +336 -0
  32. package/src/run/drivers/desktop/driver.js +383 -0
  33. package/src/run/drivers/desktop/helper.js +98 -0
  34. package/src/run/drivers/desktop/keys.js +124 -0
  35. package/src/run/drivers/desktop/output.js +107 -0
  36. package/src/run/drivers/desktop/preflight.js +134 -0
  37. package/src/run/drivers/desktop3d.js +106 -0
  38. package/src/run/drivers/desktopSequence.js +72 -0
  39. package/src/run/drivers/godot-3d.js +298 -0
  40. package/src/run/drivers/godot.js +465 -30
  41. package/src/run/drivers/index.js +6 -0
  42. package/src/run/drivers/mobile/adb.js +25 -1
  43. package/src/run/drivers/mobile/frame.js +3 -2
  44. package/src/run/drivers/mobile/gestures.js +76 -0
  45. package/src/run/drivers/mobile/lock.js +51 -11
  46. package/src/run/drivers/mobile/multitouch.js +150 -0
  47. package/src/run/drivers/mobile/native.js +229 -31
  48. package/src/run/drivers/mobile/preflight.js +14 -1
  49. package/src/run/drivers/mobile/target.js +21 -1
  50. package/src/run/drivers/stdio.js +150 -12
  51. package/src/run/drivers/unity/app.js +72 -0
  52. package/src/run/drivers/unity/engine.js +58 -0
  53. package/src/run/drivers/unity/link.js +108 -0
  54. package/src/run/drivers/unity/logs.js +76 -0
  55. package/src/run/drivers/unreal/app.js +40 -0
  56. package/src/run/drivers/unreal/driver.js +686 -0
  57. package/src/run/drivers/unreal/frames.js +243 -0
  58. package/src/run/drivers/unreal/logs.js +276 -0
  59. package/src/run/drivers/unreal/preflight.js +61 -0
  60. package/src/run/drivers/web.js +211 -13
  61. package/src/run/drivers/webdriver.js +79 -12
  62. package/src/run/endScreen.js +88 -0
  63. package/src/run/engineErrors.js +16 -0
  64. package/src/run/featureLoop.js +1 -1
  65. package/src/run/fingers.js +99 -0
  66. package/src/run/focusForKeys.js +54 -0
  67. package/src/run/godotTesterProbes.js +21 -2
  68. package/src/run/honesty.js +11 -1
  69. package/src/run/inputs.js +3 -3
  70. package/src/run/intent.js +12 -0
  71. package/src/run/pauseHook.js +494 -0
  72. package/src/run/personaLoop.js +139 -10
  73. package/src/run/pixels.js +22 -10
  74. package/src/run/planGuard.js +103 -0
  75. package/src/run/replay.js +5 -1
  76. package/src/run/reportChecks.js +17 -4
  77. package/src/run/resume.js +6 -2
  78. package/src/run/sessions.js +170 -0
  79. package/src/run/startFrom.js +415 -0
  80. package/src/run/testerProbes.js +36 -5
  81. package/src/run/tools.js +191 -10
  82. package/src/run/view3dState.js +125 -0
  83. package/src/run/web3d.js +375 -0
  84. package/src/run/world3d.js +164 -0
  85. package/templates/godot-3d/README.md +3 -2
@@ -1,4 +1,4 @@
1
- import { nativeTarget, MOBILE_DRIVERS } from '../run/drivers/mobile/target.js';
1
+ import { nativeTarget, NATIVE_DRIVERS, DESKTOP_NATIVE_DRIVERS } from '../run/drivers/mobile/target.js';
2
2
  import { nativeChecks } from '../run/drivers/mobile/preflight.js';
3
3
  import { buildIdentity, readRunNotes } from '../run/gameMemory.js';
4
4
  import { recordingForCompletion, recordingCompletionBody } from '../upload/recording.js';
@@ -49,6 +49,9 @@ import { readLiveSite } from '../run/livesite/options.js';
49
49
  import { domainCheckRefusal, finishLiveSiteRun, pinRefusal } from '../run/livesite/run.js';
50
50
  import { finishNetworkRun, networkRefusal, NETWORK_NOT_GRANTED } from '../run/networkRun.js';
51
51
  import { redactingLog, redactValue } from '../run/redaction.js';
52
+ // [native hooks] A native local run's start and its sessions (../run/startFrom.js, ../run/sessions.js).
53
+ import { briefWithStart, resolveStart, startLines } from '../run/startFrom.js';
54
+ import { sessionShare, MIN_ACTIONS_PER_SESSION } from '../run/sessions.js';
52
55
 
53
56
  /**
54
57
  * `ravensight-playtest run`: register a job, play it, upload it, finish it.
@@ -228,7 +231,7 @@ async function run(flags, injected, deps, log) {
228
231
  catch (error) { log(error.message); return EXIT.ENVIRONMENT; }
229
232
  options.driverMode = options.nativePlan ? 'native' : 'webdriver';
230
233
  if (options.nativePlan && controllers?.some(controller => controller !== 'standard')) {
231
- log('Native mobile play currently supports Geri only. Use --controller geri. Nothing was registered or charged.'); return EXIT.ENVIRONMENT;
234
+ log('Native play currently supports Geri only. Use --controller geri. Nothing was registered or charged.'); return EXIT.ENVIRONMENT;
232
235
  }
233
236
  if (controllers?.length > 1 && !['playwright_web', 'godot_driver'].includes(driverName)) { log('Comparisons currently require a web or Godot build. Nothing was charged.'); return EXIT.ENVIRONMENT; }
234
237
  const served = await serveBuildDirOption({ options, driverName, log, serve: injected.serveBuildDir });
@@ -240,10 +243,14 @@ async function run(flags, injected, deps, log) {
240
243
  log('Nothing was registered or charged.');
241
244
  return EXIT.ENVIRONMENT;
242
245
  }
246
+ // --save and --start-spec: the save files are read now, before anything is priced.
247
+ try { options.startFrom = await (injected.resolveStart || resolveStart)(options); }
248
+ catch (error) { log(error.message); log('Nothing was registered or charged.'); return EXIT.ENVIRONMENT; }
249
+ if (options.startFrom && options.nativePlan) options.nativePlan = { ...options.nativePlan, start: options.startFrom };
243
250
  // --start opens a web build at a query or hash on its own address.
244
251
  const target = withStart(resolveTarget(options, context.config, driverName, repoRoot), driverName === 'playwright_web' ? options.start : undefined);
245
252
  if (!target) {
246
- log('Point the run at a build: --build-url or --build-dir for web, --godot-project for Godot, --native-build for an APK or simulator APP, or --driver-config for a bridge.');
253
+ log('Point the run at a build: --build-url or --build-dir for web, --godot-project for Godot, --native-build for an APK, a simulator APP, a packaged Unreal Mac app, a Unity Mac player or any other desktop game, or --driver-config for a bridge.');
247
254
  return EXIT.ENVIRONMENT;
248
255
  }
249
256
 
@@ -393,6 +400,8 @@ async function run(flags, injected, deps, log) {
393
400
  if (runLength === 'long') log(longRunLine(options.longRunFactor));
394
401
  if (tierRun) log(`Each persona plays on the ${options.tier} tier's allowance${Number.isSafeInteger(options.minutes) ? ` for up to ${options.minutes} minutes` : ''}: its own model budget, action count and wall clock, set by the server.`);
395
402
  for (const line of focusLines(options)) log(line);
403
+ for (const line of startLines(options.startFrom)) log(line);
404
+ if (Number.isSafeInteger(options.sessions) && options.sessions > 1) log(`Sessions: ${options.sessions}. Each persona's run is played as ${options.sessions} launches of the game, closed and started again on its own saved data, inside the same action budget and clock; nothing more is charged.`);
396
405
  for (const line of actionBudgetLines({ options, personas, pack, localBrief })) log(line);
397
406
  for (const line of videoPlanLines(options, driverName)) log(line);
398
407
  if (estimate.ok === false) {
@@ -473,6 +482,10 @@ async function run(flags, injected, deps, log) {
473
482
  ...(controllers ? { controllers } : {}),
474
483
  driverMode: options.driverMode,
475
484
  ...(options.nativePlan ? { nativePlan: options.nativePlan } : {}),
485
+ // Where the run starts and its sessions (../run/startFrom.js, ../run/sessions.js): a resume plays the same.
486
+ // The start keeps this machine's file paths and hashes; the files are held to the hashes again when placed.
487
+ ...(options.startFrom ? { startFrom: options.startFrom } : {}),
488
+ ...(Number.isSafeInteger(options.sessions) && options.sessions > 1 ? { sessions: options.sessions } : {}),
476
489
  realtime: Boolean(options.realtime), phone: Boolean(options.phone),
477
490
  recordVideo: recordingMode(options, driverName),
478
491
  concurrency: options.concurrency ?? DEFAULT_CONCURRENCY,
@@ -917,6 +930,7 @@ export async function playPersonaRun({
917
930
 
918
931
  const skill = skillFor(pack, 'persona_playtest');
919
932
  const maxActions = resolveMaxActions(options, persona, pack, entry);
933
+ const sessionCount = sessionsFor(options, maxActions, log);
920
934
  // Headless is right for a browser and wrong for Godot: a headless Godot
921
935
  // routes no GUI input, so it is a smoke-test mode rather than a way to play.
922
936
  const headless = driverName === 'godot_driver' ? options.headless === true : options.headed !== true;
@@ -924,7 +938,7 @@ export async function playPersonaRun({
924
938
  const runTarget = entry.target || target;
925
939
  let driver;
926
940
  try {
927
- driver = await makeDriver(driverName, driverOptions({ headless, driverName, target: runTarget, directory, entry, jobId, keyModifier: options.keyModifier, godotPath: options.godotPath, realtime: options.realtime, phone: options.phone, native: options.nativePlan, mode: options.driverMode, nativeLock, liveSite: options.liveSite || null, apiUrl, network: options.network || null }));
941
+ driver = await makeDriver(driverName, driverOptions({ headless, driverName, target: runTarget, directory, entry, jobId, keyModifier: options.keyModifier, godotPath: options.godotPath, realtime: options.realtime, phone: options.phone, native: options.nativePlan, mode: options.driverMode, nativeLock, liveSite: options.liveSite || null, apiUrl, network: options.network || null, start: options.startFrom || null }));
928
942
  } catch (error) {
929
943
  // A driver that cannot even be built (the browser package missing, say) is
930
944
  // what a new machine hits first. The run is completed as failed now, with
@@ -1003,7 +1017,8 @@ export async function playPersonaRun({
1003
1017
  // pack's copy, which a pack bundle does not always carry.
1004
1018
  // A feature scenario brings its own, built from the frozen specification.
1005
1019
  // --focus and --avoid ride in a copy of the brief the persona reads; the brief itself is unchanged.
1006
- brief: briefWithFocus(entry.brief || brief || pack.brief || null, options),
1020
+ brief: briefWithStart(briefWithFocus(entry.brief || brief || pack.brief || null, options), options.startFrom || null),
1021
+ sessions: sessionCount,
1007
1022
  localBrief: usableLocalBrief(localBrief),
1008
1023
  intentNotes: pack.intent_notes || [],
1009
1024
  schemas: pack.schemas || [],
@@ -1015,8 +1030,8 @@ export async function playPersonaRun({
1015
1030
  recordVideo: recordingMode(options, driverName),
1016
1031
  edgePass: options.noEdgePass !== true,
1017
1032
  replayFindings: options.noReplay !== true,
1018
- // A web run's findings are replayed in a second browser of the same kind, on the same target, with no recording.
1019
- ...(driverName === 'playwright_web' ? { replayDriver: () => makeDriver(driverName, driverOptions({ headless, driverName, target: runTarget, directory, entry, jobId, keyModifier: options.keyModifier, godotPath: options.godotPath, realtime: options.realtime, phone: options.phone, native: options.nativePlan, mode: options.driverMode, nativeLock, liveSite: options.liveSite || null, apiUrl, network: options.network || null })) } : {}),
1033
+ // A web run's findings are replayed in a second browser of the same kind, on the same target, with no recording; a local Unreal run's in a fresh launch of the same build.
1034
+ ...(driverName === 'playwright_web' || (DESKTOP_NATIVE_DRIVERS.includes(driverName) && options.driverMode === 'native') ? { replayDriver: () => makeDriver(driverName, driverOptions({ headless, driverName, target: runTarget, directory, entry, jobId, keyModifier: options.keyModifier, godotPath: options.godotPath, realtime: options.realtime, phone: options.phone, native: options.nativePlan, mode: options.driverMode, nativeLock, liveSite: options.liveSite || null, apiUrl, network: options.network || null })) } : {}),
1020
1035
  // A run sold by the minute stops on the clock (../run/playClock.js).
1021
1036
  playClock: playClockFor(options, entry),
1022
1037
  ...(options.phone === true && driverName === 'playwright_web' ? { viewport: PHONE_VIEWPORT } : {}),
@@ -1855,16 +1870,30 @@ export async function resolveSetup(deps, options, log) {
1855
1870
  *
1856
1871
  * @returns {Object}
1857
1872
  */
1858
- export function driverOptions({ headless, driverName, target, directory, entry, jobId, keyModifier, godotPath, realtime, phone = false, native = null, mode = 'webdriver', nativeLock, liveSite = null, apiUrl = null, network = null }) {
1873
+ /**
1874
+ * The sessions a persona's run is played as (--sessions), fewer when its
1875
+ * action budget cannot give each one ten actions; said, never refused, since
1876
+ * the run is already paid for by now.
1877
+ */
1878
+ export function sessionsFor(options = {}, maxActions = 0, log = () => {}) {
1879
+ const asked = Number.isSafeInteger(options.sessions) && options.sessions > 1 ? options.sessions : 1;
1880
+ if (asked === 1) return 1;
1881
+ if (!sessionShare(asked, maxActions).error) return asked;
1882
+ const fits = Math.max(1, Math.floor(maxActions / MIN_ACTIONS_PER_SESSION));
1883
+ log(`${asked} sessions would leave fewer than ${MIN_ACTIONS_PER_SESSION} of this persona's ${maxActions} actions each; playing ${fits === 1 ? 'one session' : `${fits} sessions`}.`);
1884
+ return Math.min(asked, fits);
1885
+ }
1886
+
1887
+ export function driverOptions({ headless, driverName, target, directory, entry, jobId, keyModifier, godotPath, realtime, phone = false, native = null, mode = 'webdriver', nativeLock, liveSite = null, apiUrl = null, network = null, start = null }) {
1859
1888
  // Only the browser driver sends key chords with a modifier.
1860
1889
  const modifier = driverName === 'playwright_web' ? resolveKeyModifier(keyModifier).modifier : null;
1861
1890
  const godot = driverName === 'godot_driver'
1862
1891
  // Lockstep unless the game has to run in real time: every persona run on
1863
1892
  // Godot is seeded, on fixed ticks, and leaves a trace.jsonl to replay.
1864
- ? { pauseBetweenActions: realtime !== true, lockstep: realtime !== true, ...(Number.isInteger(entry.seed) ? { seed: entry.seed } : {}), ...(entry.trace_header ? { traceHeader: entry.trace_header } : {}), ...(godotPath ? { godotPath } : {}) }
1893
+ ? { pauseBetweenActions: realtime !== true, lockstep: realtime !== true, ...(Number.isInteger(entry.seed) ? { seed: entry.seed } : {}), ...(entry.trace_header ? { traceHeader: entry.trace_header } : {}), ...(godotPath ? { godotPath } : {}), ...(start ? { start } : {}) }
1865
1894
  : {};
1866
1895
  return {
1867
- ...(MOBILE_DRIVERS.includes(driverName) ? { native, mode, ...(nativeLock ? { lock: nativeLock } : {}) } : {}),
1896
+ ...(NATIVE_DRIVERS.includes(driverName) ? { native, mode, ...(nativeLock ? { lock: nativeLock } : {}) } : {}),
1868
1897
  headless,
1869
1898
  ...(modifier ? { modifier } : {}),
1870
1899
  // A canvas game in the browser is parked between actions too, unless the
@@ -1879,6 +1908,11 @@ export function driverOptions({ headless, driverName, target, directory, entry,
1879
1908
  // The Ravensight ingest origins the game's own SDK session can go to: the SDKs' default and this run's API (../run/sdkSession.js).
1880
1909
  ...(driverName === 'playwright_web' && apiUrl ? { ingestOrigins: ingestOriginsFor(apiUrl) } : {}),
1881
1910
  ...godot,
1911
+ // The SDK pause hook for native desktop builds, bridges whose config opts
1912
+ // in, and native mobile builds on an emulator or simulator (contract
1913
+ // section 12; ../run/pauseHook.js): parked between decisions, or only
1914
+ // recorded when the game has to run in real time.
1915
+ ...(['desktop_driver', 'unity_driver', 'unreal_driver', 'cli_stdio', 'android_driver', 'ios_driver'].includes(driverName) ? { pauseHook: realtime === true ? 'realtime' : true } : {}),
1882
1916
  playtest: {
1883
1917
  token: entry.playtest_token || null,
1884
1918
  runId: entry.run_id,
@@ -2068,7 +2102,7 @@ const RECORDING_DRIVERS = Object.freeze(['playwright_web', 'godot_driver']);
2068
2102
  * @returns {boolean|'auto'}
2069
2103
  */
2070
2104
  export function recordingMode(options = {}, driverName = '') {
2071
- const native = MOBILE_DRIVERS.includes(driverName) && options.driverMode === 'native';
2105
+ const native = NATIVE_DRIVERS.includes(driverName) && options.driverMode === 'native';
2072
2106
  if (options.recordVideo === true || options.uploadVideo === true) return true;
2073
2107
  // A resumed job keeps what its journal says.
2074
2108
  if (options.recordVideo === 'auto') return (native || RECORDING_DRIVERS.includes(driverName)) ? 'auto' : false;
@@ -2086,7 +2120,7 @@ export function recordingMode(options = {}, driverName = '') {
2086
2120
  export function videoPlanLines(options = {}, driverName = '') {
2087
2121
  if (driverName === 'cli_stdio') return [];
2088
2122
  const mode = recordingMode(options, driverName);
2089
- if (mode === false) return [(RECORDING_DRIVERS.includes(driverName) || (MOBILE_DRIVERS.includes(driverName) && options.driverMode === 'native')) ? NO_VIDEO_LINE : `No video will be recorded: ${driverName} cannot record what it plays.`];
2123
+ if (mode === false) return [(RECORDING_DRIVERS.includes(driverName) || (NATIVE_DRIVERS.includes(driverName) && options.driverMode === 'native')) ? NO_VIDEO_LINE : `No video will be recorded: ${driverName} cannot record what it plays.`];
2090
2124
  if (options.uploadVideo === true) return ['A video of each run is recorded and uploaded with the reports (--upload-video).'];
2091
2125
  if (mode === true) return ['A video of each run is kept on this machine, in its run folder. It is not uploaded.'];
2092
2126
  return [`A video of each run is kept on this machine, in its run folder${driverName === 'godot_driver' ? ' (Godot needs ffmpeg for it)' : ''}. It is not uploaded; --upload-video sends it, --no-record-video turns it off.`];
@@ -2115,7 +2149,7 @@ export async function videoSummaryLine({ directory, persona = '', options = {},
2115
2149
  }
2116
2150
  }
2117
2151
  if (recordingMode(options, driverName) === false) {
2118
- return `No video${who}: ${(RECORDING_DRIVERS.includes(driverName) || (MOBILE_DRIVERS.includes(driverName) && options.driverMode === 'native')) ? 'turned off with --no-record-video' : `${driverName || 'this driver'} cannot record what it plays`}.`;
2152
+ return `No video${who}: ${(RECORDING_DRIVERS.includes(driverName) || (NATIVE_DRIVERS.includes(driverName) && options.driverMode === 'native')) ? 'turned off with --no-record-video' : `${driverName || 'this driver'} cannot record what it plays`}.`;
2119
2153
  }
2120
2154
  const meta = await readFile(path.join(directory, 'recording.json'), 'utf8').then(JSON.parse).catch(() => null);
2121
2155
  const why = meta ? (meta.detail || meta.failure || meta.reason || 'the recording did not finish') : 'the run ended before a recording was made';
@@ -186,7 +186,7 @@ export async function validateCommand(head, flags = {}, injected = {}) {
186
186
  log(`${name}: ${refusal} Nothing was charged.`);
187
187
  return EXIT.ENVIRONMENT;
188
188
  }
189
- if (dimension === DIMENSION_3D && name === headRef) log('3D Alpha: a proof of concept on one template. It is priced as any validation is, and a persona plays with keys and input actions, never mouse look.');
189
+ if (dimension === DIMENSION_3D && name === headRef) log('3D Alpha: a proof of concept on one template. It is priced as any validation is, and a persona plays with keys, input actions, mouse look and a gamepad.');
190
190
  }
191
191
  }
192
192
  for (const [name, checked] of [[baseRef, baseCheckout], [headRef, headCheckout]]) {
@@ -186,7 +186,7 @@ async function nativeHeader(archive, file, format, requirements) {
186
186
  // do instead. Asked only once a web upload has already failed (no entry page,
187
187
  // or an entry file that is not a page), so it never refuses a web build.
188
188
  const NATIVE_ADVICE = Object.freeze({
189
- unity: 'this is a Unity desktop or mobile build. Cloud playtests play web builds: build for the Web platform in Unity and upload that output; the export settings are at ravensight.io/docs/playtest/#playtest-unity. A Unity Android emulator or iOS Simulator build can be playtested on this machine with --driver android_driver or ios_driver; a Unity desktop build cannot be playtested today',
189
+ unity: 'this is a Unity desktop or mobile build. Cloud playtests play web builds: build for the Web platform in Unity and upload that output; the export settings are at ravensight.io/docs/playtest/#playtest-unity. A Unity Android emulator or iOS Simulator build can be playtested on this machine with --driver android_driver or ios_driver, and a Unity macOS player on a Mac (docs/UNITY.md); a Unity Windows or Linux desktop build cannot be playtested today',
190
190
  unreal: 'this is an Unreal Engine build. Native builds cannot be playtested today and Unreal has no supported web export, so no playtest can play it. Cloud and local playtests play web builds',
191
191
  godot: 'this is a Godot desktop export. Cloud playtests play web builds: export with the Web preset and upload that folder, or run a local playtest of the Godot project itself with --driver godot_driver',
192
192
  love: 'this is a LÖVE game file. Cloud playtests play web builds: package it with love.js and upload that folder. A native LÖVE build cannot be playtested today',
@@ -225,7 +225,29 @@ function nativeEntryKind(entrypoint) {
225
225
  return null;
226
226
  }
227
227
 
228
- export async function inspectBuildArchive(archive, { limits: supplied, format, entrypoint, requirements } = {}) {
228
+ // A native build gets the native advice whatever its size. The archive size,
229
+ // entry count and per-file limits are a web build's limits, and an Unreal or
230
+ // Unity export is often over them, so when a web check refuses, the names are
231
+ // read once more with only this parser's own bounds (the same bounded metadata
232
+ // reads) and a native build is refused with its advice instead. Only on the
233
+ // refusal path, so an accepted build reads nothing more. Anything that cannot
234
+ // be read here keeps the original refusal.
235
+ async function nativeAdviceInstead(archive, format, entrypoint) {
236
+ if (format !== 'web') return;
237
+ let names;
238
+ try { names = await archiveFileNames(archive, { ...LEGACY_BUILD_LIMITS, archiveBytes: archive.size, files: MAX_ENTRIES }); }
239
+ catch { return; }
240
+ if (typeof entrypoint === 'string' ? names.includes(entrypoint) : names.some(name => name.endsWith('.html'))) return;
241
+ const kind = nativeBuildKind(names);
242
+ if (kind) reject(NATIVE_ADVICE[kind]);
243
+ }
244
+
245
+ export async function inspectBuildArchive(archive, options = {}) {
246
+ try { return await inspectArchive(archive, options); }
247
+ catch (error) { await nativeAdviceInstead(archive, options.format, options.entrypoint); throw error; }
248
+ }
249
+
250
+ async function inspectArchive(archive, { limits: supplied, format, entrypoint, requirements } = {}) {
229
251
  const limits = buildLimits(supplied);
230
252
  if (!['web', 'godot-project', 'linux-executable', 'windows-executable'].includes(format)) reject('the selected runtime format is unsupported');
231
253
  if (format === 'web' && typeof entrypoint === 'string' && !/\.html?$/i.test(entrypoint) && nativeEntryKind(entrypoint)) reject(NATIVE_ADVICE[nativeEntryKind(entrypoint)]);
@@ -282,7 +304,7 @@ export async function inspectBuildArchive(archive, { limits: supplied, format, e
282
304
  // The file names in the central directory, read with the same bounded
283
305
  // metadata reads as the full inspection. Only names: inspectBuildArchive still
284
306
  // checks every entry once the entry file is chosen.
285
- async function archiveFileNames(archive, limits) {
307
+ export async function archiveFileNames(archive, limits) {
286
308
  const dir = await directory(archive, limits), names = [];
287
309
  let cursor = dir.offset;
288
310
  for (let index = 0; index < dir.count; index++) {
@@ -320,7 +342,12 @@ const finderMetadata = name => {
320
342
  return parts[0] === '__MACOSX' || last.startsWith('._') || last === '.DS_Store';
321
343
  };
322
344
 
323
- export async function chooseEntrypoint(archive, { limits: supplied, format } = {}) {
345
+ export async function chooseEntrypoint(archive, options = {}) {
346
+ try { return await chooseEntry(archive, options); }
347
+ catch (error) { await nativeAdviceInstead(archive, options.format); throw error; }
348
+ }
349
+
350
+ async function chooseEntry(archive, { limits: supplied, format } = {}) {
324
351
  const kind = ENTRY_KINDS[format];
325
352
  if (!kind) throw new CliError('Choose the entry file inside the ZIP with --entrypoint. No upload reservation was requested.');
326
353
  const names = (await archiveFileNames(archive, buildLimits(supplied))).filter(name => !finderMetadata(name));
@@ -1,3 +1,4 @@
1
+ import { CliError, ExitCode } from '../errors.js';
1
2
  import { printable } from '../ui/index.js';
2
3
 
3
4
  const base = game => `/api/v1/games/${encodeURIComponent(game)}/playtest/hosted`;
@@ -35,3 +36,28 @@ export async function readHostedBuilds({ api, gameId, buildId }) {
35
36
  .sort((a, b) => (Date.parse(b.createdAt) || 0) - (Date.parse(a.createdAt) || 0));
36
37
  return buildId ? builds.filter(build => build.buildId === buildId) : builds;
37
38
  }
39
+
40
+ export const VALIDATED_STATE = 'graphical_static_validated';
41
+ export const VALIDATION_WAIT_MS = 10 * 60000;
42
+
43
+ /**
44
+ * Wait for a just uploaded build's archive check: the build once it passed,
45
+ * or a refusal with the server's own sentence for why it was not accepted.
46
+ * Reads only; nothing is quoted or charged here. `sleep` waits between reads.
47
+ */
48
+ export async function waitForBuildValidation({ api, gameId, buildId, sleep, now = Date.now, maxWaitMs = VALIDATION_WAIT_MS, onWaiting = () => {} }) {
49
+ const started = now();
50
+ for (let reads = 1; ; reads++) {
51
+ const [build] = await readHostedBuilds({ api, gameId, buildId });
52
+ if (build?.state === VALIDATED_STATE) return build;
53
+ if (build?.rejection?.message || ['rejected', 'deleting'].includes(build?.state)) {
54
+ const why = build?.rejection?.message ? ` ${line(build.rejection.message)}` : '';
55
+ throw new CliError(`Build ${line(buildId)} was not accepted.${why} Its validation hold comes back after cleanup. No playtest was quoted or charged.`);
56
+ }
57
+ if (now() - started >= maxWaitMs) {
58
+ throw new CliError(`The archive check of build ${line(buildId)} did not finish within ${Math.round(maxWaitMs / 60000)} minutes. No playtest was quoted or charged. See where it stands with: ravensight-playtest build status ${line(buildId)}, then start the playtest with: ravensight-playtest hosted run --build ${line(buildId)}`, ExitCode.ENVIRONMENT);
59
+ }
60
+ onWaiting({ build: build || null, reads });
61
+ await sleep();
62
+ }
63
+ }
@@ -2,12 +2,13 @@ import { createHash, randomUUID } from 'node:crypto';
2
2
  import { mkdir, open, rm } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import { Readable } from 'node:stream';
5
- import { CliError } from '../errors.js';
5
+ import { CliError, ExitCode } from '../errors.js';
6
6
  import { ApiError } from '../api/errors.js';
7
7
  import { writeJson } from '../fsutil.js';
8
8
  import { printable } from '../ui/index.js';
9
9
  import { uploadHostAllowed } from '../upload/host.js';
10
10
  import { openBuildArchive, inspectBuildArchive, buildLimits, limitsFromProfile, chooseEntrypoint } from './archivePreflight.js';
11
+ import { ANDROID_FORMAT, ANDROID_ENTRYPOINT, ANDROID_UNAVAILABLE, ANDROID_UNAVAILABLE_CODE, androidProfiles, apkByteLimit, inspectApk, androidRefusalText } from './nativeBuild.js';
11
12
 
12
13
  const fail = message => { throw new CliError(message); };
13
14
  const base = game => `/api/v1/games/${encodeURIComponent(game)}/playtest/hosted`;
@@ -157,18 +158,25 @@ async function journalOnce(filename, value) {
157
158
 
158
159
  // All metadata checks and a streamed checksum precede the confirmation and
159
160
  // the only wallet-mutating POST. No model or gameplay API is called here.
161
+ // `format: 'android-apk'` uploads an Android APK as it is, under the Android
162
+ // profile the server offers this studio (none offered: refused before any hold).
160
163
  export async function uploadHostedBuild({ filename, gameId, profileVersion, entrypoint, repoRoot, api,
161
- apiUrl, journalPath, dryRun = false, confirm, onPrepared = () => {}, onProgress = () => {}, fetchImpl, signal } = {}) {
164
+ apiUrl, journalPath, dryRun = false, confirm, onPrepared = () => {}, onProgress = () => {}, fetchImpl, signal, format } = {}) {
165
+ const android = format === ANDROID_FORMAT;
162
166
  if (!gameId || typeof confirm !== 'function') fail('Choose a game and upload confirmation.');
163
167
  onProgress({ phase: 'capabilities' });
164
168
  const caps = body(await api.request('GET', `${base(gameId)}/capabilities`, { idempotent: true }));
165
169
  const profiles = caps?.recorded?.profiles;
170
+ if (android && (!caps?.recorded?.available || !androidProfiles(profiles).length)) throw new CliError(ANDROID_UNAVAILABLE, ExitCode.ENVIRONMENT);
166
171
  if (!caps?.recorded?.available || !Array.isArray(profiles)) fail('Recorded game uploads are not available for this game.');
167
- profileVersion = chooseProfile(profiles, profileVersion);
168
- const matching = profiles.filter(profile => profile.profileVersion === profileVersion);
172
+ // An Android build goes only under an Android profile, and a web build never does.
173
+ const offered = android ? androidProfiles(profiles) : profiles.filter(profile => profile?.format !== ANDROID_FORMAT);
174
+ profileVersion = chooseProfile(offered, profileVersion);
175
+ const matching = offered.filter(profile => profile.profileVersion === profileVersion);
169
176
  // A cloud playtest build may be as large as the largest tier: the server's cloud limits when it
170
- // sends them (an older server sends only the 64 MiB ones).
171
- const profile = matching[0], limits = profile.capacity ? limitsFromProfile(profile) : buildLimits(caps.cloudLimits ? { ...caps.cloudLimits } : caps.limits);
177
+ // sends them (an older server sends only the 64 MiB ones). An APK is held to its profile's upload size.
178
+ const profile = matching[0], limits = android ? { archiveBytes: apkByteLimit(profile, caps) }
179
+ : profile.capacity ? limitsFromProfile(profile) : buildLimits(caps.cloudLimits ? { ...caps.cloudLimits } : caps.limits);
172
180
  const offer = profile.reservationOffer;
173
181
  if (!offer || offer.amountCents !== 49 || offer.currency !== 'USD' || offer.purpose !== 'validation_hold'
174
182
  || offer.refund !== 'after_cleanup' || !/^[a-f0-9]{64}$/.test(offer.version || '')) fail('The server did not provide the supported validation-hold offer.');
@@ -181,9 +189,11 @@ export async function uploadHostedBuild({ filename, gameId, profileVersion, entr
181
189
  onProgress({ phase: 'preflight' });
182
190
  // No --entrypoint: an index.html at the root, or the only candidate, is
183
191
  // used and said so; several candidates are listed, never guessed.
184
- const chosen = entrypoint ? null : await chooseEntrypoint(archive, { limits, format: profile.format });
192
+ const chosen = entrypoint || android ? null : await chooseEntrypoint(archive, { limits, format: profile.format });
185
193
  if (chosen) entrypoint = chosen.entrypoint;
186
- const measurement = await inspectBuildArchive(archive, { limits, format: profile.format, entrypoint, requirements: profile.capacity?.requirements });
194
+ if (android) entrypoint = ANDROID_ENTRYPOINT;
195
+ const measurement = android ? await inspectApk(archive, { archiveBytes: limits.archiveBytes, file: filename })
196
+ : await inspectBuildArchive(archive, { limits, format: profile.format, entrypoint, requirements: profile.capacity?.requirements });
187
197
  onProgress({ phase: 'hash', completedBytes: 0, totalBytes: archive.size });
188
198
  const sha256 = await archive.sha256({ onProgress: (completedBytes, totalBytes) => onProgress({ phase: 'hash', completedBytes, totalBytes }) });
189
199
  const prepared = { ...measurement, sha256, profileVersion, limits, capacity: profile.capacity || null,
@@ -195,7 +205,7 @@ export async function uploadHostedBuild({ filename, gameId, profileVersion, entr
195
205
  return { state: 'declined', walletMutationRequested: false };
196
206
  }
197
207
  await archive.check();
198
- const input = { sha256, bytes: archive.size, entrypoint, args: [], reservation: { amountCents: offer.amountCents, version: offer.version },
208
+ const input = { sha256, bytes: archive.size, entrypoint, ...(android ? {} : { args: [] }), reservation: { amountCents: offer.amountCents, version: offer.version },
199
209
  validation: { kind: 'recorded_graphical', format: profile.format, profileVersion, selfContained: true } };
200
210
  const identity = createHash('sha256').update(JSON.stringify({ apiUrl, gameId, sha256, profileVersion, entrypoint })).digest('hex');
201
211
  const journal = journalPath || path.join(repoRoot, '.ravensight', 'hosted-uploads', identity + '.json');
@@ -233,6 +243,11 @@ export async function uploadHostedBuild({ filename, gameId, profileVersion, entr
233
243
  await rm(journal, { force: true });
234
244
  fail(serverSentence(error.message === error.code ? '' : error.message) || 'Your studio has used today\'s build checks. The next one is available at 00:00 UTC. Nothing was charged.');
235
245
  }
246
+ // Android cloud playtests switched off for this studio: refused before any hold, so nothing to reconcile.
247
+ if (error instanceof ApiError && error.code === ANDROID_UNAVAILABLE_CODE && state.phase === 'reservation_unknown') {
248
+ await rm(journal, { force: true });
249
+ throw new CliError(androidRefusalText(error), ExitCode.ENVIRONMENT);
250
+ }
236
251
  if (error instanceof ApiError && [401, 403].includes(error.status)) {
237
252
  error.message += ` Original upload journal: ${journal}; no replacement reservation was requested.`;
238
253
  throw error;
@@ -0,0 +1,87 @@
1
+ import { lstat } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { CliError, ExitCode } from '../errors.js';
4
+ import { printable, bytes } from '../ui/index.js';
5
+ import { openBuildArchive, archiveFileNames, LEGACY_BUILD_LIMITS } from './archivePreflight.js';
6
+
7
+ /**
8
+ * A cloud playtest of an Android build (`hosted run --native-build game.apk`).
9
+ * The APK itself is the uploaded archive, unchanged: an APK is a ZIP. Nothing
10
+ * here runs the APK or any Android tool; the local checks read the file's
11
+ * first bytes and its ZIP directory only. The server validates the rest
12
+ * (signature, launcher activity, manifest, permissions).
13
+ */
14
+ export const ANDROID_FORMAT = 'android-apk';
15
+ export const ANDROID_DRIVER = 'android_driver';
16
+ export const ANDROID_ENTRYPOINT = 'AndroidManifest.xml';
17
+ export const ANDROID_UNAVAILABLE = 'Cloud playtests of Android builds are not available for this studio yet. Nothing was uploaded or charged.';
18
+ export const ANDROID_UNAVAILABLE_CODE = 'android_cloud_unavailable';
19
+
20
+ const NOTHING = 'Nothing was uploaded or charged.';
21
+ const fail = message => { throw new CliError(message, ExitCode.ENVIRONMENT); };
22
+ const named = file => printable(String(file));
23
+
24
+ /** The profiles the server offers this studio for an Android build. Empty when it offers none. */
25
+ export function androidProfiles(profiles) {
26
+ return (Array.isArray(profiles) ? profiles : [])
27
+ .filter(profile => profile?.format === ANDROID_FORMAT && profile.driver === ANDROID_DRIVER && typeof profile.profileVersion === 'string' && profile.profileVersion);
28
+ }
29
+
30
+ /**
31
+ * The largest APK the server takes: the profile's own upload limit when it
32
+ * gives one, otherwise the limit a web build is held to.
33
+ */
34
+ export function apkByteLimit(profile, caps = {}) {
35
+ const whole = value => Number.isSafeInteger(value) && value > 0;
36
+ return [profile?.capacity?.uploadLimits?.archiveBytes, profile?.uploadLimits?.archiveBytes,
37
+ caps?.cloudLimits?.archiveBytes, caps?.limits?.archiveBytes].find(whole) ?? LEGACY_BUILD_LIMITS.archiveBytes;
38
+ }
39
+
40
+ /** The path names a readable .apk file. A bundle (.aab) is refused with what to upload instead. */
41
+ export async function checkApkPath(file) {
42
+ if (typeof file !== 'string' || !file) fail(`Name the Android build to upload with --native-build game.apk. ${NOTHING}`);
43
+ let info;
44
+ try { info = await lstat(file); }
45
+ catch { fail(`The Android build ${named(file)} was not found. ${NOTHING}`); }
46
+ const extension = path.extname(file).toLowerCase();
47
+ if (extension === '.aab') fail(`${named(file)} is an Android App Bundle (.aab), which a device cannot install. Upload the installable .apk built from the bundle. ${NOTHING}`);
48
+ if (!info.isFile()) fail(`${named(file)} is not a regular file. --native-build takes an Android .apk file. ${NOTHING}`);
49
+ if (extension !== '.apk') fail(`A cloud playtest of a native build takes an Android .apk file, and ${named(file)} is not one. ${NOTHING}`);
50
+ }
51
+
52
+ /**
53
+ * Checks an open APK: within the size limit, a ZIP from its first bytes, and
54
+ * an AndroidManifest.xml at its root. Reads the ZIP directory only.
55
+ */
56
+ export async function inspectApk(archive, { archiveBytes = Number.MAX_SAFE_INTEGER, file = 'The APK' } = {}) {
57
+ if (archive.size > archiveBytes) fail(`${named(file)} is ${bytes(archive.size)}, and a cloud playtest takes an APK of at most ${bytes(archiveBytes)}. ${NOTHING}`);
58
+ const head = archive.size >= 4 ? await archive.read(0, 4) : Buffer.alloc(0);
59
+ if (head.length !== 4 || head.readUInt32LE(0) !== 0x04034b50) fail(`${named(file)} is not a valid APK: an APK is a ZIP archive, and this file is not one. ${NOTHING}`);
60
+ let names;
61
+ try { names = await archiveFileNames(archive, { ...LEGACY_BUILD_LIMITS, archiveBytes: archive.size, files: 1_000_000, zip64: true }); }
62
+ catch (error) {
63
+ if (error instanceof CliError) fail(`${named(file)} is not a valid APK: its ZIP directory could not be read. ${NOTHING}`);
64
+ throw error;
65
+ }
66
+ if (!names.includes(ANDROID_ENTRYPOINT)) fail(`${named(file)} is not a valid APK: it has no ${ANDROID_ENTRYPOINT} at its root. ${NOTHING}`);
67
+ return { archiveBytes: archive.size, entries: names.length, files: names.length, format: ANDROID_FORMAT, entrypoint: ANDROID_ENTRYPOINT,
68
+ metadataVerified: true, contentsVerified: false, serverValidationRequired: true, runtimeCompatibilityProven: false };
69
+ }
70
+
71
+ /** Every local check before any network call: the path, then the file's own bytes, and its hash. No size limit yet; the server's comes later. */
72
+ export async function preflightApk(file) {
73
+ await checkApkPath(file);
74
+ const archive = await openBuildArchive(file);
75
+ try { return { ...await inspectApk(archive, { file }), sha256: await archive.sha256() }; }
76
+ finally { await archive.close(); }
77
+ }
78
+
79
+ /**
80
+ * The server's own sentence for an Android refusal, ending with what was not
81
+ * charged. The server's code means nothing was charged.
82
+ */
83
+ export function androidRefusalText(error) {
84
+ const said = typeof error?.message === 'string' && error.message !== error.code ? printable(error.message).replace(/\s+/g, ' ').trim().slice(0, 300) : '';
85
+ if (!said) return 'Cloud playtests of Android builds are not available right now. Nothing was charged.';
86
+ return /Nothing was (?:uploaded or )?charged\./.test(said) ? said : `${said} Nothing was charged.`;
87
+ }
@@ -6,6 +6,7 @@ import { ApiError } from '../api/errors.js';
6
6
  import { stableStringify } from '../fsutil.js';
7
7
  import { printable } from '../ui/index.js';
8
8
  import { chooseProfile } from './buildUpload.js';
9
+ import { ANDROID_DRIVER, ANDROID_FORMAT, ANDROID_UNAVAILABLE_CODE, androidRefusalText } from './nativeBuild.js';
9
10
  import { displayName } from '../run/controllers.js';
10
11
  import { queueInfo } from './status.js';
11
12
  import { ALWAYS_INCLUDED_PERSONA, MAX_HOSTED_PERSONAS, hostedPersonas } from '../runDefaults.js';
@@ -102,6 +103,9 @@ export function focusFor({ start, focus = [], avoid = [] } = {}) {
102
103
  return { ...(start ? { start } : {}), focus: focus.map(x => x.trim()), avoid: avoid.map(x => x.trim()) };
103
104
  }
104
105
 
106
+ /** Why a cloud playtest of an Android build takes no --start, --save or --save-target. Its --focus and --avoid goals are taken. */
107
+ export const ANDROID_FOCUS_REFUSAL = 'A cloud playtest of an Android build plays on an Android device in the cloud with its network off. It has no web address to start from and takes no save file, so drop --start, --save and --save-target. --focus and --avoid are taken. Nothing was uploaded or charged.';
108
+
105
109
  /** The largest save file a cloud playtest starts from (the server's bound). */
106
110
  export const MAX_SAVE_BYTES = 1024 * 1024;
107
111
 
@@ -150,6 +154,9 @@ function requestFor({ buildId, profileVersion, personas, controllers = COMBINED,
150
154
  if (typeof includeVideo !== 'boolean' || typeof includeTranscript !== 'boolean') fail('Choose explicit video and transcript options.');
151
155
  if (tier !== undefined && (!combined || !TIERS.includes(tier))) fail(`Choose --tier from ${TIERS.join(', ')}.`);
152
156
  if (minutes !== undefined && (!combined || !Number.isSafeInteger(minutes) || minutes < 1 || minutes > 120)) fail('Choose --minutes as whole minutes, from the tier minimum up to 120.');
157
+ // An Android build plays on a device with its network off and has no web address: no start and no save. Its goals,
158
+ // --focus and --avoid, are taken as on any combined playtest (the server's focus block).
159
+ if (profile.driver === ANDROID_DRIVER && focus !== undefined && (focus.start || focus.save)) fail(ANDROID_FOCUS_REFUSAL);
153
160
  return { kind: 'recorded_graphical', buildId, personas: [...list], controllers: [...controllers],
154
161
  driver: profile.driver, runLength: 'standard', profileVersion, includeVideo, includeTranscript,
155
162
  ...(standardProvider === undefined ? {} : { standardProvider }),
@@ -169,7 +176,7 @@ async function available(api, gameId, profileVersion, standardProvider, controll
169
176
  // advertised; with several and none named, the error lists them.
170
177
  const chosen = chooseProfile(recorded.profiles, profileVersion);
171
178
  const matches = recorded.profiles.filter(value => value.profileVersion === chosen);
172
- if (matches.length !== 1 || !['playwright_web', 'godot_driver'].includes(matches[0].driver)) fail('Choose exactly one currently advertised ready hosted profile. Nothing was charged.');
179
+ if (matches.length !== 1 || !['playwright_web', 'godot_driver', ANDROID_DRIVER].includes(matches[0].driver)) fail('Choose exactly one currently advertised ready hosted profile. Nothing was charged.');
173
180
  if (standardProvider !== undefined && (!PROVIDERS.includes(standardProvider)
174
181
  || !Array.isArray(recorded.standardProviders) || !recorded.standardProviders.includes(standardProvider))) {
175
182
  fail(`This server does not advertise Geri on the ${providerLabel(standardProvider)} as ready. No provider fallback or charge was requested.`);
@@ -257,6 +264,7 @@ export function hostedQuoteLines(offer) {
257
264
  const focus = q.focus || {};
258
265
  return [`Game ${offer.gameId}; build ${r.buildId}; profile ${r.profileVersion}.`,
259
266
  'One playtester per persona: Geri and Freki play your game together, Geri thinks and Freki acts. Each persona plays on its own cloud machine, at the same time as the others, and one report covers them all.',
267
+ ...(r.driver === ANDROID_DRIVER ? ['An Android build: each persona plays it on an Android device in the cloud, with the device\'s network off.'] : []),
260
268
  `Tier ${q.tier}, ${q.minutes} minutes of play per persona.`,
261
269
  ...(focus.start ? [`Start: ${printable(focus.start)}`] : []),
262
270
  ...(focus.save ? [`Start from the save file: ${printable(String(focus.save.name))} (${Number(focus.save.bytes) || 0} bytes), ${focus.save.target?.kind === 'hook' ? 'read by the game through the playtest save hook' : focus.save.target?.kind === 'local_storage' ? 'placed in local storage before the game loads' : 'placed in the game\'s browser file storage before the game loads'}.`] : []),
@@ -344,7 +352,9 @@ const CERTAIN_REFUSALS = new Set(['hosted_funding_required', 'recorded_setup_req
344
352
  'recorded_unavailable', 'hosted_execution_budget_unconfigured',
345
353
  // The free load check of the build (game_tracker loadCheck.js gate), answered after the replay
346
354
  // lookup and before any intent is written, reserved or charged.
347
- 'hosted_load_check_running', 'hosted_load_check_failed', 'hosted_load_check_unavailable']);
355
+ 'hosted_load_check_running', 'hosted_load_check_failed', 'hosted_load_check_unavailable',
356
+ // Cloud playtests of Android builds switched off for this studio (503): refused before anything is charged.
357
+ ANDROID_UNAVAILABLE_CODE]);
348
358
  export const CAPACITY_CODES = Object.freeze(['hosted_global_capacity', 'too_many_active_hosted_runs']);
349
359
  export const LOAD_CHECK_RUNNING = 'hosted_load_check_running';
350
360
  // The server keeps an attempt it refused under the plan's key and answers a
@@ -388,6 +398,7 @@ export function hostedRefusalMessage(error) {
388
398
  if (code === LOAD_CHECK_RUNNING) return said('We are checking that this build loads on one of our cloud machines before anything is charged. The check is free. Nothing was charged. Run the same command again in a minute.');
389
399
  if (code === 'hosted_load_check_failed') return said('This build did not load on our cloud machine, so the cloud playtest was not started. Nothing was charged. Fix the build and upload it again.');
390
400
  if (code === 'hosted_load_check_unavailable') return said('We could not finish checking this build on a cloud machine just now. That is on our side, not the build. Nothing was charged. Try again later.');
401
+ if (code === ANDROID_UNAVAILABLE_CODE) return androidRefusalText(error);
391
402
  if (code === REFUSED_EARLIER) return 'The server already refused an earlier attempt with this quote, so it will not start a run from it. No run was started and nothing was charged; request a new quote, or use "hosted run" without a quote file.';
392
403
  return 'Hosted playtests are not available right now. Nothing was charged.';
393
404
  }
@@ -729,7 +740,8 @@ export async function prepareHostedRun({ api, apiUrl, gameId, buildId, personas
729
740
  if (!build && refused) fail(`Build ${buildId} was not accepted: ${printable(String(refused.rejection.message)).replace(/\s+/g, ' ').slice(0, 300)} Nothing was charged.`);
730
741
  if (!build) fail(`Build ${buildId} is not ready for a hosted run: it has to pass its static archive check on a ready profile and not have expired. Nothing was charged.`);
731
742
  } else {
732
- build = eligible[0];
743
+ // The newest web or Godot build: an Android build is played only when named or sent with --native-build.
744
+ build = eligible.find(row => row.format !== ANDROID_FORMAT);
733
745
  if (!build) fail('No build is ready for a hosted run. Upload one with "build upload" and wait for its static archive check. Nothing was charged.');
734
746
  }
735
747
  const { profile, funding } = await available(api, gameId, build.profileVersion, standardProvider);