ravensight-playtest 0.18.0 → 0.20.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.
- package/README.md +202 -17
- package/addons/desktop/RavensightDesktop.swift +367 -0
- package/addons/mobile/UITests/MobileInputTests.swift +67 -1
- package/addons/ravensight_driver/driver.gd +557 -4
- package/docs/ADAPTERS.md +39 -7
- package/docs/DESKTOP.md +161 -0
- package/docs/MOBILE.md +30 -3
- package/docs/UNITY.md +189 -0
- package/docs/UNREAL.md +166 -0
- package/docs/godot-driver.md +109 -1
- package/package.json +15 -5
- package/src/cli.js +44 -11
- package/src/commands/build.js +40 -0
- package/src/commands/feature.js +1 -1
- package/src/commands/hosted.js +78 -9
- package/src/commands/run.js +65 -13
- package/src/commands/validate.js +1 -1
- package/src/hosted/archivePreflight.js +31 -4
- package/src/hosted/buildStatus.js +26 -0
- package/src/hosted/buildUpload.js +24 -9
- package/src/hosted/nativeBuild.js +87 -0
- package/src/hosted/recordedRun.js +15 -3
- package/src/run/anygame/genre.js +110 -25
- package/src/run/anygame/genre2d.js +139 -0
- package/src/run/anygame/index.js +9 -5
- package/src/run/anygame/scene3d.js +562 -0
- package/src/run/anygame/shared-hashes.json +4 -2
- package/src/run/anygame/shared.js +3 -3
- package/src/run/args.js +24 -4
- package/src/run/drivers/desktop/app.js +104 -0
- package/src/run/drivers/desktop/common.js +394 -0
- package/src/run/drivers/desktop/driver.js +455 -0
- package/src/run/drivers/desktop/helper.js +98 -0
- package/src/run/drivers/desktop/keys.js +124 -0
- package/src/run/drivers/desktop/output.js +107 -0
- package/src/run/drivers/desktop/preflight.js +134 -0
- package/src/run/drivers/desktop/runHome.js +158 -0
- package/src/run/drivers/desktop3d.js +106 -0
- package/src/run/drivers/desktopSequence.js +72 -0
- package/src/run/drivers/godot-3d.js +298 -0
- package/src/run/drivers/godot.js +473 -31
- package/src/run/drivers/index.js +6 -0
- package/src/run/drivers/mobile/adb.js +25 -1
- package/src/run/drivers/mobile/frame.js +3 -2
- package/src/run/drivers/mobile/gestures.js +76 -0
- package/src/run/drivers/mobile/lock.js +51 -11
- package/src/run/drivers/mobile/multitouch.js +150 -0
- package/src/run/drivers/mobile/native.js +231 -31
- package/src/run/drivers/mobile/preflight.js +14 -1
- package/src/run/drivers/mobile/target.js +22 -1
- package/src/run/drivers/stdio.js +154 -13
- package/src/run/drivers/unity/app.js +72 -0
- package/src/run/drivers/unity/engine.js +58 -0
- package/src/run/drivers/unity/link.js +108 -0
- package/src/run/drivers/unity/logs.js +76 -0
- package/src/run/drivers/unreal/app.js +40 -0
- package/src/run/drivers/unreal/driver.js +776 -0
- package/src/run/drivers/unreal/frames.js +243 -0
- package/src/run/drivers/unreal/logs.js +276 -0
- package/src/run/drivers/unreal/preflight.js +61 -0
- package/src/run/drivers/web.js +211 -13
- package/src/run/drivers/webdriver.js +81 -12
- package/src/run/endScreen.js +88 -0
- package/src/run/engineErrors.js +16 -0
- package/src/run/featureLoop.js +1 -1
- package/src/run/fingers.js +99 -0
- package/src/run/focusForKeys.js +54 -0
- package/src/run/godotTesterProbes.js +21 -2
- package/src/run/honesty.js +11 -1
- package/src/run/inputs.js +3 -3
- package/src/run/intent.js +12 -0
- package/src/run/launchArgs.js +58 -0
- package/src/run/pauseHook.js +617 -0
- package/src/run/personaLoop.js +164 -10
- package/src/run/pixels.js +22 -10
- package/src/run/planGuard.js +103 -0
- package/src/run/replay.js +7 -1
- package/src/run/reportChecks.js +24 -4
- package/src/run/resume.js +10 -2
- package/src/run/sessions.js +175 -0
- package/src/run/slowMotion.js +151 -0
- package/src/run/startFrom.js +448 -0
- package/src/run/testerProbes.js +36 -5
- package/src/run/tools.js +191 -10
- package/src/run/view3dState.js +125 -0
- package/src/run/web3d.js +375 -0
- package/src/run/world3d.js +164 -0
- package/templates/godot-3d/README.md +3 -2
package/src/commands/hosted.js
CHANGED
|
@@ -9,7 +9,11 @@ import { quoteHostedRun, runHostedQuote, hostedQuoteLines, prepareHostedRun, con
|
|
|
9
9
|
import { hostedPlaytestStatus, modeOutcomes, modeLine, TERMINAL_PHASES, queueInfo, queueLine } from '../hosted/status.js';
|
|
10
10
|
import { jobLink } from '../dashboard.js';
|
|
11
11
|
import { ALWAYS_INCLUDED_PERSONA, hostedPersonas } from '../runDefaults.js';
|
|
12
|
-
import { focusFor, providerRoles, uploadSave } from '../hosted/recordedRun.js';
|
|
12
|
+
import { focusFor, providerRoles, uploadSave, ANDROID_FOCUS_REFUSAL } from '../hosted/recordedRun.js';
|
|
13
|
+
import { ApiError } from '../api/errors.js';
|
|
14
|
+
import { uploadHostedBuild } from '../hosted/buildUpload.js';
|
|
15
|
+
import { waitForBuildValidation, readHostedBuilds, VALIDATED_STATE } from '../hosted/buildStatus.js';
|
|
16
|
+
import { ANDROID_FORMAT, ANDROID_UNAVAILABLE, ANDROID_UNAVAILABLE_CODE, androidProfiles, androidRefusalText, preflightApk } from '../hosted/nativeBuild.js';
|
|
13
17
|
|
|
14
18
|
/** Machine output names a Geri provider by its role, never by the server's wire id. */
|
|
15
19
|
const printJson = value => ui.json(providerRoles(value));
|
|
@@ -54,13 +58,64 @@ export function assertHostedBuildId(build) {
|
|
|
54
58
|
if (typeof build !== 'string' || !/^pt_build_[A-Za-z0-9-]{1,100}$/.test(build)) throw new CliError(HOSTED_URL_REFUSAL, ExitCode.ENVIRONMENT);
|
|
55
59
|
}
|
|
56
60
|
|
|
61
|
+
/** The server's refusal of an Android cloud playtest (503, nothing charged), printed in its own words. */
|
|
62
|
+
function androidRefusal(error) {
|
|
63
|
+
if (error instanceof ApiError && error.code === ANDROID_UNAVAILABLE_CODE) return new CliError(androidRefusalText(error), ExitCode.ENVIRONMENT);
|
|
64
|
+
return error;
|
|
65
|
+
}
|
|
66
|
+
const passAndroidRefusal = async fn => { try { return await fn(); } catch (error) { throw androidRefusal(error); } };
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* `hosted run --native-build game.apk`: the flags that cannot go with it,
|
|
70
|
+
* refused before any network call. An Android build is a new upload (not
|
|
71
|
+
* --build), plays offline with no web address (no --start, --save or
|
|
72
|
+
* --save-target) and takes no goals yet (no --focus or --avoid).
|
|
73
|
+
*/
|
|
74
|
+
export function assertNativeRunFlags(flags = {}) {
|
|
75
|
+
if (!flags.nativeBuild) return;
|
|
76
|
+
if (flags.build !== undefined) throw new CliError('--native-build uploads an Android build as a new build, and --build names one already uploaded. Use one of them. Nothing was uploaded or charged.', ExitCode.ENVIRONMENT);
|
|
77
|
+
if (flags.start !== undefined || flags.save !== undefined || flags.saveTarget !== undefined) {
|
|
78
|
+
throw new CliError(ANDROID_FOCUS_REFUSAL, ExitCode.ENVIRONMENT);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Upload an APK for a cloud playtest and wait for its archive check. Refused
|
|
84
|
+
* before any upload or hold when the server offers this studio no Android
|
|
85
|
+
* profile. Answers the checked build's id, or null when the hold was declined.
|
|
86
|
+
*/
|
|
87
|
+
async function uploadAndroidBuild({ api, apiUrl, gameId, repoRoot, flags, deps, confirm, sleep, now, sha256 }) {
|
|
88
|
+
const caps = (await api.request('GET', `/api/v1/games/${encodeURIComponent(gameId)}/playtest/hosted/run-capabilities`, { idempotent: true })).body;
|
|
89
|
+
if (!caps?.recorded?.available || !androidProfiles(caps.recorded.profiles).length) throw new CliError(ANDROID_UNAVAILABLE, ExitCode.ENVIRONMENT);
|
|
90
|
+
// The same APK uploaded before and still checked or being checked is used again: no second upload or hold.
|
|
91
|
+
const earlier = (await readHostedBuilds({ api, gameId })).find(row => row.sha256 === sha256 && row.format === ANDROID_FORMAT
|
|
92
|
+
&& [VALIDATED_STATE, 'awaiting_validation'].includes(row.state) && !row.rejection && !(Date.parse(row.expiresAt) <= now()));
|
|
93
|
+
if (earlier) {
|
|
94
|
+
if (!flags.json) ui.info(`Build ${earlier.buildId} is this same APK, uploaded before. Using it; nothing new is uploaded or held.`);
|
|
95
|
+
const build = earlier.state === VALIDATED_STATE ? earlier : await waitForBuildValidation({ api, gameId, buildId: earlier.buildId, sleep: deps.validationSleep || sleep, now });
|
|
96
|
+
return build.buildId;
|
|
97
|
+
}
|
|
98
|
+
const upload = await (deps.uploadBuild || uploadHostedBuild)({ filename: flags.nativeBuild, gameId, format: ANDROID_FORMAT, repoRoot, api, apiUrl,
|
|
99
|
+
fetchImpl: deps.fetch, confirm,
|
|
100
|
+
onPrepared: prepared => {
|
|
101
|
+
if (flags.json) return;
|
|
102
|
+
ui.info(`Android build ${flags.nativeBuild}: ${ui.bytes(prepared.archiveBytes)}, ${prepared.entries} entries, with an AndroidManifest.xml. The server checks its signature and launcher activity.`);
|
|
103
|
+
ui.info('Static validation hold: $0.49 from prepaid funds, returned after safe cleanup. The playtest is quoted separately once the build passes its check.');
|
|
104
|
+
} });
|
|
105
|
+
if (upload.state === 'declined') return null;
|
|
106
|
+
if (!flags.json) ui.info(`Uploaded ${upload.buildId}. Waiting for its archive check, which usually takes about a minute.`);
|
|
107
|
+
const build = await waitForBuildValidation({ api, gameId, buildId: upload.buildId, sleep: deps.validationSleep || sleep, now });
|
|
108
|
+
if (!flags.json) ui.ok(`Build ${build.buildId} passed its archive check.`);
|
|
109
|
+
return build.buildId;
|
|
110
|
+
}
|
|
111
|
+
|
|
57
112
|
export async function hostedQuote(flags = {}, deps = {}) {
|
|
58
113
|
assertHostedBuildId(flags.build);
|
|
59
114
|
const context = deps.context || await createContext({ apiUrl: flags.apiUrl, repoRoot: flags.repoRoot, requireAuth: true });
|
|
60
115
|
// The same personas as "hosted run", so a quote and a run of the same build
|
|
61
116
|
// match: fresh-eyes always, plus any named.
|
|
62
117
|
const personas = personasFrom(flags);
|
|
63
|
-
return withAuthHandling(context, async () => {
|
|
118
|
+
return withAuthHandling(context, () => passAndroidRefusal(async () => {
|
|
64
119
|
const gameId = resolveGameId(flags, context.config);
|
|
65
120
|
const result = await quoteHostedRun({ api: context.api, apiUrl: context.api.apiUrl,
|
|
66
121
|
gameId, buildId: flags.build, profileVersion: flags.profile,
|
|
@@ -74,7 +129,7 @@ export async function hostedQuote(flags = {}, deps = {}) {
|
|
|
74
129
|
ui.ok(`Saved ${result.quoteFile}. No admission or charge was requested.`);
|
|
75
130
|
}
|
|
76
131
|
return ExitCode.OK;
|
|
77
|
-
});
|
|
132
|
+
}));
|
|
78
133
|
}
|
|
79
134
|
|
|
80
135
|
export async function hostedRun(filename, flags = {}, deps = {}) {
|
|
@@ -212,17 +267,32 @@ function admittedLines(admitted, now) {
|
|
|
212
267
|
*/
|
|
213
268
|
export async function hostedRunDirect(flags = {}, deps = {}) {
|
|
214
269
|
assertHostedBuildId(flags.build);
|
|
270
|
+
assertNativeRunFlags(flags);
|
|
215
271
|
if (flags.json && !flags.yes && !deps.confirm) throw new CliError('A hosted run charges prepaid funds. Use --yes with --json. Nothing was charged.');
|
|
216
272
|
const maxWaitMs = capacityWaitMs(flags.waitForCapacity);
|
|
273
|
+
// The APK's own checks come first: nothing is sent for a file that cannot be an installable APK.
|
|
274
|
+
const apk = flags.nativeBuild ? await preflightApk(flags.nativeBuild) : null;
|
|
217
275
|
const context = deps.context || await createContext({ apiUrl: flags.apiUrl, repoRoot: flags.repoRoot, requireAuth: true });
|
|
218
276
|
const now = deps.now || Date.now, sleep = poller(deps);
|
|
219
|
-
return withAuthHandling(context, async () => {
|
|
277
|
+
return withAuthHandling(context, () => passAndroidRefusal(async () => {
|
|
220
278
|
const api = context.api, apiUrl = api.apiUrl, gameId = resolveGameId(flags, context.config);
|
|
221
279
|
await assertNoUnknownAdmission({ repoRoot: context.repoRoot, apiUrl, gameId, evenIfUnknown: Boolean(flags.evenIfUnknown) });
|
|
222
|
-
const
|
|
223
|
-
|
|
280
|
+
const confirm = deps.confirm || (question => ui.confirm(question, { yes: Boolean(flags.yes) }));
|
|
281
|
+
let buildId = flags.build;
|
|
282
|
+
if (flags.nativeBuild) {
|
|
283
|
+
buildId = await uploadAndroidBuild({ api, apiUrl, gameId, repoRoot: context.repoRoot, flags, deps, confirm, sleep, now, sha256: apk.sha256 });
|
|
284
|
+
if (!buildId) {
|
|
285
|
+
if (flags.json) printJson({ state: 'declined', gameId, walletMutationRequested: false });
|
|
286
|
+
else ui.info('Upload declined. Nothing was uploaded or charged.');
|
|
287
|
+
return ExitCode.CANCELED;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// An Android build takes no start, save or goals (refused above), so its scope is the tier and minutes only.
|
|
291
|
+
const scope = flags.nativeBuild ? scopeFrom({ tier: flags.tier, minutes: flags.minutes }) : await scopeWithSave(flags, { api, gameId, upload: deps.uploadSave });
|
|
292
|
+
const { offer, build, funding } = await prepareHostedRun({ api, apiUrl, gameId, buildId,
|
|
293
|
+
personas: personasFrom(flags), ...scope, includeVideo: Boolean(flags.video), now });
|
|
224
294
|
if (!flags.json) {
|
|
225
|
-
ui.info(`Build ${build.buildId}${build.entrypoint ? ` (${build.entrypoint})` : ''}${
|
|
295
|
+
ui.info(`Build ${build.buildId}${build.entrypoint ? ` (${build.entrypoint})` : ''}${buildId ? '' : ', the newest ready build'}.`);
|
|
226
296
|
hostedQuoteLines(offer).forEach(line => ui.info(line));
|
|
227
297
|
hostedConsentLines(offer).forEach(line => ui.info(line));
|
|
228
298
|
}
|
|
@@ -231,7 +301,6 @@ export async function hostedRunDirect(flags = {}, deps = {}) {
|
|
|
231
301
|
const topUp = short.requiredTopUpCents ? ` Add at least ${dollars(short.requiredTopUpCents)} of prepaid funds, then run this again.` : ' Add prepaid funds, then run this again.';
|
|
232
302
|
throw new CliError(`The balance does not meet this hosted run's funding requirement. Nothing was charged.${topUp}`, ExitCode.ENVIRONMENT);
|
|
233
303
|
}
|
|
234
|
-
const confirm = deps.confirm || (question => ui.confirm(question, { yes: Boolean(flags.yes) }));
|
|
235
304
|
if (!await confirm(confirmQuestion(offer))) {
|
|
236
305
|
if (flags.json) printJson({ state: 'declined', gameId, buildId: build.buildId, walletMutationRequested: false });
|
|
237
306
|
else ui.info('Declined. Nothing was charged.');
|
|
@@ -256,7 +325,7 @@ export async function hostedRunDirect(flags = {}, deps = {}) {
|
|
|
256
325
|
if (flags.json) printJson({ ...result, status: view });
|
|
257
326
|
else printOutcome(view);
|
|
258
327
|
return exitFor(view);
|
|
259
|
-
});
|
|
328
|
+
}));
|
|
260
329
|
}
|
|
261
330
|
|
|
262
331
|
export async function hostedStatus(admissionId, flags = {}, deps = {}) {
|
package/src/commands/run.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { nativeTarget,
|
|
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';
|
|
5
5
|
import { playClockFor } from '../run/playClock.js';
|
|
6
|
+
import { slowMotionPlan } from '../run/slowMotion.js';
|
|
6
7
|
import { PHONE_VIEWPORT } from '../run/phone.js';
|
|
7
8
|
import { randomUUID } from 'node:crypto';
|
|
8
9
|
import { mkdir, readFile, stat } from 'node:fs/promises';
|
|
@@ -49,6 +50,10 @@ import { readLiveSite } from '../run/livesite/options.js';
|
|
|
49
50
|
import { domainCheckRefusal, finishLiveSiteRun, pinRefusal } from '../run/livesite/run.js';
|
|
50
51
|
import { finishNetworkRun, networkRefusal, NETWORK_NOT_GRANTED } from '../run/networkRun.js';
|
|
51
52
|
import { redactingLog, redactValue } from '../run/redaction.js';
|
|
53
|
+
// [native hooks] A native local run's start and its sessions (../run/startFrom.js, ../run/sessions.js).
|
|
54
|
+
import { briefWithStart, resolveStart, startLines } from '../run/startFrom.js';
|
|
55
|
+
import { sessionShare, MIN_ACTIONS_PER_SESSION } from '../run/sessions.js';
|
|
56
|
+
import { launchArgsOf } from '../run/launchArgs.js';
|
|
52
57
|
|
|
53
58
|
/**
|
|
54
59
|
* `ravensight-playtest run`: register a job, play it, upload it, finish it.
|
|
@@ -228,7 +233,7 @@ async function run(flags, injected, deps, log) {
|
|
|
228
233
|
catch (error) { log(error.message); return EXIT.ENVIRONMENT; }
|
|
229
234
|
options.driverMode = options.nativePlan ? 'native' : 'webdriver';
|
|
230
235
|
if (options.nativePlan && controllers?.some(controller => controller !== 'standard')) {
|
|
231
|
-
log('Native
|
|
236
|
+
log('Native play currently supports Geri only. Use --controller geri. Nothing was registered or charged.'); return EXIT.ENVIRONMENT;
|
|
232
237
|
}
|
|
233
238
|
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
239
|
const served = await serveBuildDirOption({ options, driverName, log, serve: injected.serveBuildDir });
|
|
@@ -240,10 +245,22 @@ async function run(flags, injected, deps, log) {
|
|
|
240
245
|
log('Nothing was registered or charged.');
|
|
241
246
|
return EXIT.ENVIRONMENT;
|
|
242
247
|
}
|
|
248
|
+
// --save and --start-spec: the save files are read now, before anything is priced.
|
|
249
|
+
try { options.startFrom = await (injected.resolveStart || resolveStart)(options); }
|
|
250
|
+
catch (error) { log(error.message); log('Nothing was registered or charged.'); return EXIT.ENVIRONMENT; }
|
|
251
|
+
if (options.startFrom && options.nativePlan) options.nativePlan = { ...options.nativePlan, start: options.startFrom };
|
|
252
|
+
// A desktop game played as several sessions keeps a home of the run's own from its first launch (../run/drivers/desktop/runHome.js).
|
|
253
|
+
if (options.nativePlan && Number.isSafeInteger(options.sessions) && options.sessions > 1) options.nativePlan = { ...options.nativePlan, sessions: options.sessions };
|
|
254
|
+
// A desktop driver starts from a save, plays sessions and takes launch arguments only when it starts the game itself (--native-build).
|
|
255
|
+
if (DESKTOP_NATIVE_DRIVERS.includes(driverName) && !options.nativePlan && (options.startFrom || (Number.isSafeInteger(options.sessions) && options.sessions > 1) || options.launchArg !== undefined)) {
|
|
256
|
+
log(`--save, --start-spec, --sessions and --launch-arg need ${driverName} to start the game itself: pass the build with --native-build.`);
|
|
257
|
+
log('Nothing was registered or charged.');
|
|
258
|
+
return EXIT.ENVIRONMENT;
|
|
259
|
+
}
|
|
243
260
|
// --start opens a web build at a query or hash on its own address.
|
|
244
261
|
const target = withStart(resolveTarget(options, context.config, driverName, repoRoot), driverName === 'playwright_web' ? options.start : undefined);
|
|
245
262
|
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
|
|
263
|
+
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
264
|
return EXIT.ENVIRONMENT;
|
|
248
265
|
}
|
|
249
266
|
|
|
@@ -393,6 +410,8 @@ async function run(flags, injected, deps, log) {
|
|
|
393
410
|
if (runLength === 'long') log(longRunLine(options.longRunFactor));
|
|
394
411
|
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
412
|
for (const line of focusLines(options)) log(line);
|
|
413
|
+
for (const line of startLines(options.startFrom)) log(line);
|
|
414
|
+
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
415
|
for (const line of actionBudgetLines({ options, personas, pack, localBrief })) log(line);
|
|
397
416
|
for (const line of videoPlanLines(options, driverName)) log(line);
|
|
398
417
|
if (estimate.ok === false) {
|
|
@@ -473,7 +492,16 @@ async function run(flags, injected, deps, log) {
|
|
|
473
492
|
...(controllers ? { controllers } : {}),
|
|
474
493
|
driverMode: options.driverMode,
|
|
475
494
|
...(options.nativePlan ? { nativePlan: options.nativePlan } : {}),
|
|
495
|
+
// Where the run starts and its sessions (../run/startFrom.js, ../run/sessions.js): a resume plays the same.
|
|
496
|
+
// The start keeps this machine's file paths and hashes; the files are held to the hashes again when placed.
|
|
497
|
+
...(options.startFrom ? { startFrom: options.startFrom } : {}),
|
|
498
|
+
...(Number.isSafeInteger(options.sessions) && options.sessions > 1 ? { sessions: options.sessions } : {}),
|
|
499
|
+
// A Godot run's launch arguments (a native desktop run keeps its own in nativePlan.args).
|
|
500
|
+
...(driverName === 'godot_driver' && options.launchArg !== undefined ? { launchArgs: launchArgsOf(options) } : {}),
|
|
476
501
|
realtime: Boolean(options.realtime), phone: Boolean(options.phone),
|
|
502
|
+
// Slow motion (../run/slowMotion.js): a resume slows the game as the run asked.
|
|
503
|
+
...(options.timeScale !== undefined ? { timeScale: options.timeScale } : {}),
|
|
504
|
+
...(options.noSlowMotion === true ? { noSlowMotion: true } : {}),
|
|
477
505
|
recordVideo: recordingMode(options, driverName),
|
|
478
506
|
concurrency: options.concurrency ?? DEFAULT_CONCURRENCY,
|
|
479
507
|
uploadVideo: Boolean(options.uploadVideo),
|
|
@@ -917,6 +945,7 @@ export async function playPersonaRun({
|
|
|
917
945
|
|
|
918
946
|
const skill = skillFor(pack, 'persona_playtest');
|
|
919
947
|
const maxActions = resolveMaxActions(options, persona, pack, entry);
|
|
948
|
+
const sessionCount = sessionsFor(options, maxActions, log);
|
|
920
949
|
// Headless is right for a browser and wrong for Godot: a headless Godot
|
|
921
950
|
// routes no GUI input, so it is a smoke-test mode rather than a way to play.
|
|
922
951
|
const headless = driverName === 'godot_driver' ? options.headless === true : options.headed !== true;
|
|
@@ -924,7 +953,7 @@ export async function playPersonaRun({
|
|
|
924
953
|
const runTarget = entry.target || target;
|
|
925
954
|
let driver;
|
|
926
955
|
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 }));
|
|
956
|
+
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, launchArgs: launchArgsOf(options), slowMotion: slowMotionPlan(options) }));
|
|
928
957
|
} catch (error) {
|
|
929
958
|
// A driver that cannot even be built (the browser package missing, say) is
|
|
930
959
|
// what a new machine hits first. The run is completed as failed now, with
|
|
@@ -1003,7 +1032,8 @@ export async function playPersonaRun({
|
|
|
1003
1032
|
// pack's copy, which a pack bundle does not always carry.
|
|
1004
1033
|
// A feature scenario brings its own, built from the frozen specification.
|
|
1005
1034
|
// --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),
|
|
1035
|
+
brief: briefWithStart(briefWithFocus(entry.brief || brief || pack.brief || null, options), options.startFrom || null),
|
|
1036
|
+
sessions: sessionCount,
|
|
1007
1037
|
localBrief: usableLocalBrief(localBrief),
|
|
1008
1038
|
intentNotes: pack.intent_notes || [],
|
|
1009
1039
|
schemas: pack.schemas || [],
|
|
@@ -1015,8 +1045,8 @@ export async function playPersonaRun({
|
|
|
1015
1045
|
recordVideo: recordingMode(options, driverName),
|
|
1016
1046
|
edgePass: options.noEdgePass !== true,
|
|
1017
1047
|
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 })) } : {}),
|
|
1048
|
+
// 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.
|
|
1049
|
+
...(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
1050
|
// A run sold by the minute stops on the clock (../run/playClock.js).
|
|
1021
1051
|
playClock: playClockFor(options, entry),
|
|
1022
1052
|
...(options.phone === true && driverName === 'playwright_web' ? { viewport: PHONE_VIEWPORT } : {}),
|
|
@@ -1855,16 +1885,30 @@ export async function resolveSetup(deps, options, log) {
|
|
|
1855
1885
|
*
|
|
1856
1886
|
* @returns {Object}
|
|
1857
1887
|
*/
|
|
1858
|
-
|
|
1888
|
+
/**
|
|
1889
|
+
* The sessions a persona's run is played as (--sessions), fewer when its
|
|
1890
|
+
* action budget cannot give each one ten actions; said, never refused, since
|
|
1891
|
+
* the run is already paid for by now.
|
|
1892
|
+
*/
|
|
1893
|
+
export function sessionsFor(options = {}, maxActions = 0, log = () => {}) {
|
|
1894
|
+
const asked = Number.isSafeInteger(options.sessions) && options.sessions > 1 ? options.sessions : 1;
|
|
1895
|
+
if (asked === 1) return 1;
|
|
1896
|
+
if (!sessionShare(asked, maxActions).error) return asked;
|
|
1897
|
+
const fits = Math.max(1, Math.floor(maxActions / MIN_ACTIONS_PER_SESSION));
|
|
1898
|
+
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`}.`);
|
|
1899
|
+
return Math.min(asked, fits);
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
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, launchArgs = [], slowMotion = null }) {
|
|
1859
1903
|
// Only the browser driver sends key chords with a modifier.
|
|
1860
1904
|
const modifier = driverName === 'playwright_web' ? resolveKeyModifier(keyModifier).modifier : null;
|
|
1861
1905
|
const godot = driverName === 'godot_driver'
|
|
1862
1906
|
// Lockstep unless the game has to run in real time: every persona run on
|
|
1863
1907
|
// 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 } : {}) }
|
|
1908
|
+
? { pauseBetweenActions: realtime !== true, lockstep: realtime !== true, ...(Number.isInteger(entry.seed) ? { seed: entry.seed } : {}), ...(entry.trace_header ? { traceHeader: entry.trace_header } : {}), ...(godotPath ? { godotPath } : {}), ...(start ? { start } : {}), ...(launchArgs && launchArgs.length ? { launchArgs } : {}) }
|
|
1865
1909
|
: {};
|
|
1866
1910
|
return {
|
|
1867
|
-
...(
|
|
1911
|
+
...(NATIVE_DRIVERS.includes(driverName) ? { native, mode, ...(nativeLock ? { lock: nativeLock } : {}) } : {}),
|
|
1868
1912
|
headless,
|
|
1869
1913
|
...(modifier ? { modifier } : {}),
|
|
1870
1914
|
// A canvas game in the browser is parked between actions too, unless the
|
|
@@ -1879,6 +1923,14 @@ export function driverOptions({ headless, driverName, target, directory, entry,
|
|
|
1879
1923
|
// 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
1924
|
...(driverName === 'playwright_web' && apiUrl ? { ingestOrigins: ingestOriginsFor(apiUrl) } : {}),
|
|
1881
1925
|
...godot,
|
|
1926
|
+
// The SDK pause hook for native desktop builds, bridges whose config opts
|
|
1927
|
+
// in, and native mobile builds on an emulator or simulator (contract
|
|
1928
|
+
// section 12; ../run/pauseHook.js): parked between decisions, or only
|
|
1929
|
+
// recorded when the game has to run in real time.
|
|
1930
|
+
...(['desktop_driver', 'unity_driver', 'unreal_driver', 'cli_stdio', 'android_driver', 'ios_driver'].includes(driverName) ? { pauseHook: realtime === true ? 'realtime' : true } : {}),
|
|
1931
|
+
// Slow motion through the same hook (../run/slowMotion.js): a quarter speed while the persona decides on a
|
|
1932
|
+
// --realtime action game, the --time-scale share instead of a pause, or never with --no-slow-motion.
|
|
1933
|
+
...(slowMotion && ['desktop_driver', 'unity_driver', 'unreal_driver', 'cli_stdio', 'android_driver', 'ios_driver'].includes(driverName) ? { slowMotion } : {}),
|
|
1882
1934
|
playtest: {
|
|
1883
1935
|
token: entry.playtest_token || null,
|
|
1884
1936
|
runId: entry.run_id,
|
|
@@ -2068,7 +2120,7 @@ const RECORDING_DRIVERS = Object.freeze(['playwright_web', 'godot_driver']);
|
|
|
2068
2120
|
* @returns {boolean|'auto'}
|
|
2069
2121
|
*/
|
|
2070
2122
|
export function recordingMode(options = {}, driverName = '') {
|
|
2071
|
-
const native =
|
|
2123
|
+
const native = NATIVE_DRIVERS.includes(driverName) && options.driverMode === 'native';
|
|
2072
2124
|
if (options.recordVideo === true || options.uploadVideo === true) return true;
|
|
2073
2125
|
// A resumed job keeps what its journal says.
|
|
2074
2126
|
if (options.recordVideo === 'auto') return (native || RECORDING_DRIVERS.includes(driverName)) ? 'auto' : false;
|
|
@@ -2086,7 +2138,7 @@ export function recordingMode(options = {}, driverName = '') {
|
|
|
2086
2138
|
export function videoPlanLines(options = {}, driverName = '') {
|
|
2087
2139
|
if (driverName === 'cli_stdio') return [];
|
|
2088
2140
|
const mode = recordingMode(options, driverName);
|
|
2089
|
-
if (mode === false) return [(RECORDING_DRIVERS.includes(driverName) || (
|
|
2141
|
+
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
2142
|
if (options.uploadVideo === true) return ['A video of each run is recorded and uploaded with the reports (--upload-video).'];
|
|
2091
2143
|
if (mode === true) return ['A video of each run is kept on this machine, in its run folder. It is not uploaded.'];
|
|
2092
2144
|
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 +2167,7 @@ export async function videoSummaryLine({ directory, persona = '', options = {},
|
|
|
2115
2167
|
}
|
|
2116
2168
|
}
|
|
2117
2169
|
if (recordingMode(options, driverName) === false) {
|
|
2118
|
-
return `No video${who}: ${(RECORDING_DRIVERS.includes(driverName) || (
|
|
2170
|
+
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
2171
|
}
|
|
2120
2172
|
const meta = await readFile(path.join(directory, 'recording.json'), 'utf8').then(JSON.parse).catch(() => null);
|
|
2121
2173
|
const why = meta ? (meta.detail || meta.failure || meta.reason || 'the recording did not finish') : 'the run ended before a recording was made';
|
package/src/commands/validate.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
168
|
-
const
|
|
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 =
|
|
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
|
-
|
|
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
|
+
}
|