ravensight-playtest 0.11.1 → 0.13.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 +165 -15
- package/addons/mobile/Host/AppDelegate.swift +11 -0
- package/addons/mobile/RavensightMobile.xcodeproj/project.pbxproj +398 -0
- package/addons/mobile/RavensightMobile.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/addons/mobile/RavensightMobile.xcodeproj/xcshareddata/xcschemes/RavensightMobile.xcscheme +116 -0
- package/addons/mobile/UITests/MobileInputTests.swift +152 -0
- package/addons/mobile/project.yml +45 -0
- package/docs/ADAPTERS.md +5 -4
- package/docs/MOBILE.md +107 -0
- package/docs/NATIVE_RUNNER.md +7 -3
- package/package.json +9 -7
- package/src/api/client.js +10 -1
- package/src/cli.js +65 -8
- package/src/commands/check.js +17 -3
- package/src/commands/device.js +64 -0
- package/src/commands/hosted.js +31 -13
- package/src/commands/run.js +125 -16
- package/src/detect.js +17 -0
- package/src/hosted/archivePreflight.js +3 -3
- package/src/hosted/recordedRun.js +19 -3
- package/src/run/anygame/index.js +9 -3
- package/src/run/args.js +30 -0
- package/src/run/budgetReserve.js +98 -16
- package/src/run/choiceCheck.js +26 -7
- package/src/run/claimProtocol.js +27 -0
- package/src/run/completion.js +86 -0
- package/src/run/drivers/android.js +3 -0
- package/src/run/drivers/index.js +4 -0
- package/src/run/drivers/ios.js +3 -0
- package/src/run/drivers/mobile/adb.js +91 -0
- package/src/run/drivers/mobile/attempt.js +18 -0
- package/src/run/drivers/mobile/crash.js +115 -0
- package/src/run/drivers/mobile/frame.js +64 -0
- package/src/run/drivers/mobile/ios-helper.js +102 -0
- package/src/run/drivers/mobile/lock.js +32 -0
- package/src/run/drivers/mobile/native.js +227 -0
- package/src/run/drivers/mobile/preflight.js +80 -0
- package/src/run/drivers/mobile/process.js +57 -0
- package/src/run/drivers/mobile/recording.js +88 -0
- package/src/run/drivers/mobile/screenshot.js +34 -0
- package/src/run/drivers/mobile/simctl.js +60 -0
- package/src/run/drivers/mobile/target.js +53 -0
- package/src/run/drivers/web.js +118 -5
- package/src/run/honesty.js +66 -26
- package/src/run/inputMeasurement.js +49 -0
- package/src/run/livesite/browser.js +316 -0
- package/src/run/livesite/hosts.js +107 -0
- package/src/run/livesite/network.js +117 -0
- package/src/run/livesite/options.js +167 -0
- package/src/run/livesite/resolver.js +78 -0
- package/src/run/livesite/run.js +113 -0
- package/src/run/model.js +20 -27
- package/src/run/personaLoop.js +486 -95
- package/src/run/proxyClient.js +177 -0
- package/src/run/redaction.js +191 -0
- package/src/run/report.js +24 -2
- package/src/run/resume.js +63 -7
- package/src/run/screenshots.js +3 -1
- package/src/run/state.js +3 -1
- package/src/run/tooFast.js +116 -0
- package/src/run/tools.js +30 -4
- package/src/run/transcript.js +3 -1
- package/src/run/usage.js +3 -1
package/src/cli.js
CHANGED
|
@@ -53,9 +53,10 @@ async function loadRunner(name, exportName) {
|
|
|
53
53
|
export const RUNNER_HELP = `
|
|
54
54
|
Run options (parsed by the runner, see src/run/args.js):
|
|
55
55
|
--personas <list> comma separated persona slugs, default one (fresh-eyes); "personas" lists them
|
|
56
|
-
--driver <name> playwright_web, godot_driver
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
--driver <name> playwright_web, godot_driver, cli_stdio, android_driver or ios_driver.
|
|
57
|
+
android_driver and ios_driver play a local Android emulator or iOS Simulator
|
|
58
|
+
build given with --native-build and --device (see docs/MOBILE.md). desktop_driver,
|
|
59
|
+
unity_driver and unreal_driver remain experimental and need --driver-config
|
|
59
60
|
--no-record-video do not keep a video. A playwright_web or godot_driver run records one on this
|
|
60
61
|
machine by default (session.webm or session.mp4 in the run folder; Godot needs
|
|
61
62
|
ffmpeg); nothing is uploaded unless --upload-video is passed
|
|
@@ -69,10 +70,36 @@ Run options (parsed by the runner, see src/run/args.js):
|
|
|
69
70
|
For a game made for touch; the report says when a game wanted touch and the
|
|
70
71
|
run was played with a mouse
|
|
71
72
|
--build-url <url> the web build to play
|
|
73
|
+
--url <url> playtest a live web game by its address (staging or production) on this machine. A
|
|
74
|
+
public host must be verified for the game first (a TXT record, from the Playtest page,
|
|
75
|
+
Test a live URL); localhost and private addresses are a local dev server and need none.
|
|
76
|
+
The browser reaches only that host and the game's own Ravensight analytics; other
|
|
77
|
+
hosts are blocked and listed in the report
|
|
78
|
+
--login-email <email> sign in as this test account before play, in a separate unrecorded browser; the
|
|
79
|
+
playtester never sees the form, and the email shows as "test account" on screen
|
|
80
|
+
--login-password-env <NAME>
|
|
81
|
+
the environment variable that holds the test account's password (at least 6
|
|
82
|
+
characters). A password is never taken on the command line
|
|
83
|
+
--session-cookie-env <NAME>
|
|
84
|
+
instead of a password: the environment variable holding a test user's Cookie header
|
|
85
|
+
value (name=value; name2=value2), set for the start host only
|
|
86
|
+
--session-header-env <NAME>
|
|
87
|
+
instead of a password: the environment variable holding one header, Authorization or
|
|
88
|
+
X-..., as Name: value, sent to the start host only
|
|
89
|
+
--sign-in-url <url> the page with the sign-in form, on the same host (default the --url page)
|
|
90
|
+
--sign-in-selectors <json>
|
|
91
|
+
the sign-in form's fields when they are not found on their own, as JSON with any of
|
|
92
|
+
email, password, submit and signedIn, such as {"signedIn": "text=Sign out"}
|
|
72
93
|
--build-dir <dir> a web export folder to serve from this machine and play: index.html or its one
|
|
73
94
|
.html page, with wasm, Brotli and gzip engine files and threaded builds served right
|
|
74
95
|
--build-entry <file> the page to open inside --build-dir, when it has more than one .html file
|
|
75
96
|
--godot-project <dir> the Godot project directory
|
|
97
|
+
--native-build <path> Android APK or iOS simulator APP; uses the local native driver
|
|
98
|
+
--device <id> exact emulator serial/AVD or simulator UDID/name
|
|
99
|
+
--package <id> Android package override, checked against the APK
|
|
100
|
+
--bundle-id <id> iOS bundle override, checked against the APP
|
|
101
|
+
--portrait native portrait orientation (default)
|
|
102
|
+
--landscape native landscape orientation
|
|
76
103
|
--driver-config <file> JSON-RPC bridge configuration, or an experimental native driver's WebDriver configuration
|
|
77
104
|
--cli <command> the command that starts a text build (cli_stdio)
|
|
78
105
|
--controller <name> geri (the default, chooses every action itself) or freki (picks each action from a short list)
|
|
@@ -207,14 +234,17 @@ export function buildProgram() {
|
|
|
207
234
|
.option('--save-target <where>', 'where the game reads the save: localstorage:<key>, godot:user://<path>, idbfs:/<mount>/<path>, or hook (the default: the game reads it through window.RavensightPlaytest.save)')
|
|
208
235
|
.requiredOption('--output <file>', 'save the original quote and immutable consent here')
|
|
209
236
|
.option('--game <id>', 'game id, overriding this repo’s configuration')
|
|
210
|
-
.addOption(new Option('--geri-provider <name>', "Geri's model provider: primary or alternate (ravensight.io/legal/subprocessors names both); unavailable choices are refused").choices(['primary', 'alternate'])
|
|
211
|
-
.addOption(new Option('--standard-provider <name>').choices(['anthropic', 'openai']).hideHelp())
|
|
237
|
+
.addOption(new Option('--geri-provider <name>', "Geri's model provider: primary or alternate (ravensight.io/legal/subprocessors names both); unavailable choices are refused").choices(['primary', 'alternate']))
|
|
212
238
|
.option('--video', 'include hosted gameplay video in this quote')
|
|
239
|
+
// Never a URL: a live URL reaches the cloud only as a verified target, by its id (hosted.js HOSTED_URL_REFUSAL).
|
|
240
|
+
.addOption(new Option('--url <url>').hideHelp())
|
|
241
|
+
.addOption(new Option('--build-url <url>').hideHelp())
|
|
213
242
|
.action(capture(slot, async (options, command) => {
|
|
214
|
-
const { hostedQuote } = await import('./commands/hosted.js');
|
|
243
|
+
const { hostedQuote, HOSTED_URL_REFUSAL } = await import('./commands/hosted.js');
|
|
244
|
+
if (options.url !== undefined || options.buildUrl !== undefined) throw new CliError(HOSTED_URL_REFUSAL, ExitCode.ENVIRONMENT);
|
|
215
245
|
return hostedQuote(flagsFrom(command.optsWithGlobals(), { build: options.build, profile: options.profile,
|
|
216
246
|
persona: options.persona, personas: options.personas, tier: options.tier, minutes: options.minutes, start: options.start, focus: options.focus, avoid: options.avoid, save: options.save, saveTarget: options.saveTarget, output: options.output, game: options.game,
|
|
217
|
-
geriProvider: options.geriProvider,
|
|
247
|
+
geriProvider: options.geriProvider,
|
|
218
248
|
video: options.video }));
|
|
219
249
|
}));
|
|
220
250
|
common(hosted.command('run [quote-file]'))
|
|
@@ -236,8 +266,11 @@ export function buildProgram() {
|
|
|
236
266
|
// Hidden: the server now queues a funded run instead of refusing it for
|
|
237
267
|
// capacity. Kept so an older server's busy answer can still be waited out.
|
|
238
268
|
.addOption(new Option('--wait-for-capacity [minutes]', 'when hosted capacity is busy, ask again about once a minute and start when there is room, for up to this many minutes (default 60)').hideHelp())
|
|
269
|
+
.addOption(new Option('--url <url>').hideHelp())
|
|
270
|
+
.addOption(new Option('--build-url <url>').hideHelp())
|
|
239
271
|
.action(capture(slot, async (filename, options, command) => {
|
|
240
|
-
const { hostedRun, hostedRunDirect } = await import('./commands/hosted.js');
|
|
272
|
+
const { hostedRun, hostedRunDirect, HOSTED_URL_REFUSAL } = await import('./commands/hosted.js');
|
|
273
|
+
if (options.url !== undefined || options.buildUrl !== undefined) throw new CliError(HOSTED_URL_REFUSAL, ExitCode.ENVIRONMENT);
|
|
241
274
|
if (filename) {
|
|
242
275
|
const extra = ['build', 'persona', 'personas', 'tier', 'minutes', 'start', 'save', 'saveTarget', 'game', 'video'].filter(name => options[name] !== undefined).concat(['focus', 'avoid'].filter(name => options[name]?.length));
|
|
243
276
|
if (extra.length) throw new CliError(`A saved quote already fixes its build, personas and options. Drop --${extra.join(', --')}, or run "hosted run" without a quote file.`);
|
|
@@ -312,6 +345,23 @@ export function buildProgram() {
|
|
|
312
345
|
return logout(flagsFrom(options));
|
|
313
346
|
}));
|
|
314
347
|
|
|
348
|
+
const device = common(program.command('device').description('set up, list, boot and shut down local Android emulators and iOS Simulators'));
|
|
349
|
+
for (const [name, arg, about] of [
|
|
350
|
+
['list', '', 'list Android emulators, Android virtual devices and iOS Simulators on this machine'],
|
|
351
|
+
['boot', ' <name>', 'start the exact emulator or simulator named (needs --platform)'],
|
|
352
|
+
['shutdown', ' <name>', 'stop the exact emulator or simulator named, unless a run is using it (needs --platform)'],
|
|
353
|
+
['setup', ' <platform>', 'android: install the emulator and create a test device, asking first; ios: build the bundled input helper']
|
|
354
|
+
]) {
|
|
355
|
+
common(device.command(name + arg).description(about))
|
|
356
|
+
.option('--platform <platform>', 'android or ios')
|
|
357
|
+
.action(capture(slot, async (...args) => {
|
|
358
|
+
const value = arg ? args[0] : undefined;
|
|
359
|
+
const options = arg ? args[1] : args[0];
|
|
360
|
+
const { deviceCommand } = await import('./commands/device.js');
|
|
361
|
+
return deviceCommand(name, value, options);
|
|
362
|
+
}));
|
|
363
|
+
}
|
|
364
|
+
|
|
315
365
|
common(program.command('check').description('check this machine, this repo and this account'))
|
|
316
366
|
.option('--game <gameId>', 'check against this game instead of the linked one')
|
|
317
367
|
.addOption(new Option('--modules <list>', 'price this module list').argParser(list))
|
|
@@ -320,6 +370,12 @@ export function buildProgram() {
|
|
|
320
370
|
.option('--web', 'check the browser even when this repo is not linked to a web build')
|
|
321
371
|
.option('--driver <name>', 'check the setup for this driver instead of the configured one')
|
|
322
372
|
.option('--driver-config <file>', 'the experimental native driver config to probe instead of the configured one')
|
|
373
|
+
.option('--native-build <path>', 'Android APK or iOS simulator APP to inspect')
|
|
374
|
+
.option('--device <id>', 'exact native emulator or simulator')
|
|
375
|
+
.option('--package <id>', 'expected Android package')
|
|
376
|
+
.option('--bundle-id <id>', 'expected iOS bundle identifier')
|
|
377
|
+
.option('--portrait', 'native portrait orientation')
|
|
378
|
+
.option('--landscape', 'native landscape orientation')
|
|
323
379
|
.option('--godot-project <dir>', 'the Godot project a godot_driver run would play, read for controls with no text, fonts and a game state hook')
|
|
324
380
|
.option('--record-video', 'the run will pass --record-video, so the video row passes')
|
|
325
381
|
.option('--no-record-video', 'the run will pass --no-record-video, so the video row warns')
|
|
@@ -330,6 +386,7 @@ export function buildProgram() {
|
|
|
330
386
|
game: options.game,
|
|
331
387
|
driver: options.driver,
|
|
332
388
|
driverConfig: options.driverConfig,
|
|
389
|
+
nativeBuild: options.nativeBuild, device: options.device, package: options.package, bundleId: options.bundleId, portrait: options.portrait, landscape: options.landscape,
|
|
333
390
|
modules: options.modules,
|
|
334
391
|
personas: options.personas,
|
|
335
392
|
godotPath: options.godotPath,
|
package/src/commands/check.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { nativeTarget } from '../run/drivers/mobile/target.js';
|
|
2
|
+
import { nativeChecks } from '../run/drivers/mobile/preflight.js';
|
|
1
3
|
import { createClient } from '../api/client.js';
|
|
2
4
|
import { ApiError } from '../api/errors.js';
|
|
3
5
|
import { resolveApiUrl, paths } from '../paths.js';
|
|
@@ -226,7 +228,7 @@ export async function probeBrowser(importer, { url = null, timeoutMs } = {}) {
|
|
|
226
228
|
}
|
|
227
229
|
|
|
228
230
|
/** Said by `check` every time, in both outputs, because a customer asked. */
|
|
229
|
-
export const NO_CHARGE_NOTE = 'check reserves no units and starts no job:
|
|
231
|
+
export const NO_CHARGE_NOTE = 'check reserves no units and starts no job: API requests are free reads or estimates, and probes use your own local browser, native device or automation server. A native check installs and opens the selected test build.';
|
|
230
232
|
|
|
231
233
|
/** `Jump Bunny (g1)`, or just the id when the game has no name. */
|
|
232
234
|
const gameLabel = game => (game.name ? `${game.name} (${game.gameId})` : game.gameId);
|
|
@@ -242,6 +244,8 @@ const gameLabel = game => (game.name ? `${game.name} (${game.gameId})` : game.ga
|
|
|
242
244
|
export function plannedRun(flags = {}, config = null) {
|
|
243
245
|
const driverName = flags.driver || (config && config.driver) || 'playwright_web';
|
|
244
246
|
const build = (config && config.build) || {};
|
|
247
|
+
const mobile = nativeTarget(flags, config, driverName, flags.repoRoot || process.cwd());
|
|
248
|
+
if (mobile) return { driverName, native: false, target: mobile.build, nativePlan: mobile };
|
|
245
249
|
let target = null;
|
|
246
250
|
if (WEBDRIVER_NAMES.includes(driverName) || driverName === 'cli_stdio') {
|
|
247
251
|
target = flags.driverConfig || (build.kind === 'driver_config' ? build.ref : null) || null;
|
|
@@ -571,9 +575,19 @@ export async function runChecks(flags = {}, deps = {}) {
|
|
|
571
575
|
|
|
572
576
|
/* ---------------------------------------------- build and automation */
|
|
573
577
|
|
|
574
|
-
|
|
578
|
+
let plan;
|
|
579
|
+
try { plan = plannedRun(flags, config); }
|
|
580
|
+
catch (error) {
|
|
581
|
+
rows.push(row('native configuration', 'fail', error.message));
|
|
582
|
+
plan = { driverName: flags.driver || config?.driver || 'playwright_web', native: false, target: null, invalid: true };
|
|
583
|
+
}
|
|
575
584
|
facts.build.driver = plan.driverName;
|
|
576
|
-
if (plan.
|
|
585
|
+
if (plan.invalid) {
|
|
586
|
+
facts.build.ref = null;
|
|
587
|
+
} else if (plan.nativePlan) {
|
|
588
|
+
const checked = await (deps.nativeChecks || nativeChecks)(plan.nativePlan, { ...deps.nativeDeps, smoke: true, recordVideo: !flags.noRecordVideo });
|
|
589
|
+
rows.push(...checked.rows); facts.build.ref = plan.nativePlan.build; facts.native = checked.plan;
|
|
590
|
+
} else if (plan.native) {
|
|
577
591
|
const native = await automationChecks({ ...plan, repoRoot }, deps);
|
|
578
592
|
rows.push(...native.rows);
|
|
579
593
|
facts.build.ref = native.build.ref;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { createAdb } from '../run/drivers/mobile/adb.js';
|
|
3
|
+
import { createSimctl } from '../run/drivers/mobile/simctl.js';
|
|
4
|
+
import { sdkTool } from '../run/drivers/mobile/process.js';
|
|
5
|
+
import { buildIosHelper } from '../run/drivers/mobile/ios-helper.js';
|
|
6
|
+
import { lockDevice } from '../run/drivers/mobile/lock.js';
|
|
7
|
+
import { ui } from '../ui/index.js';
|
|
8
|
+
|
|
9
|
+
export async function listDevices({ adb = createAdb(), simctl = createSimctl(), platform = process.platform } = {}) {
|
|
10
|
+
const result = { android: [], avds: [], ios: [], errors: [] };
|
|
11
|
+
for (const [key, read] of [['android', () => adb.list()], ['avds', () => adb.avds()], ...(platform === 'darwin' ? [['ios', () => simctl.list()]] : [])]) {
|
|
12
|
+
try { result[key] = await read(); } catch (error) { result.errors.push({ platform: key, error: error.message }); }
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
export function androidImage({ platform = process.platform, arch = process.arch } = {}) {
|
|
17
|
+
return `system-images;android-35;google_apis;${platform === 'darwin' && arch === 'arm64' ? 'arm64-v8a' : 'x86_64'}`;
|
|
18
|
+
}
|
|
19
|
+
async function withInput(binary, args, input, timeout = 300000) {
|
|
20
|
+
const child = spawn(binary, args, { stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
|
|
21
|
+
let text = '';
|
|
22
|
+
child.stdout.on('data', b => { text = (text + b).slice(-4000); }); child.stderr.on('data', b => { text = (text + b).slice(-4000); });
|
|
23
|
+
const timer = setTimeout(() => child.kill('SIGKILL'), timeout);
|
|
24
|
+
try { await new Promise((resolve, reject) => { child.on('error', reject); child.on('close', code => code === 0 ? resolve() : reject(new Error(text || 'Android setup failed or timed out.'))); child.stdin.end(input); }); }
|
|
25
|
+
finally { clearTimeout(timer); }
|
|
26
|
+
}
|
|
27
|
+
export async function deviceCommand(action, value, flags = {}, deps = {}) {
|
|
28
|
+
const adb = deps.adb || createAdb(), simctl = deps.simctl || createSimctl(), log = deps.log || ui.info;
|
|
29
|
+
if (action === 'list') {
|
|
30
|
+
const result = await listDevices({ adb, simctl });
|
|
31
|
+
if (flags.json) ui.json(result);
|
|
32
|
+
else {
|
|
33
|
+
for (const d of [...result.android, ...result.ios]) log(`${d.platform} ${d.id} ${d.name} ${d.state}${d.avd ? ` (${d.avd})` : ''}`);
|
|
34
|
+
for (const name of result.avds) log(`Android AVD: ${name}`);
|
|
35
|
+
for (const error of result.errors) log(`${error.platform}: ${error.error}`);
|
|
36
|
+
}
|
|
37
|
+
return result.errors.length && !result.android.length && !result.ios.length && !result.avds.length ? 3 : 0;
|
|
38
|
+
}
|
|
39
|
+
if (action === 'setup') {
|
|
40
|
+
if (value === 'ios') { log('Building the local XCTest input helper. Xcode and an installed iOS Simulator runtime are required.'); await (deps.buildIosHelper || buildIosHelper)(); log('The iOS input helper is built. Run device list and boot a simulator.'); return 0; }
|
|
41
|
+
if (value !== 'android') throw new Error('Choose device setup android or device setup ios.');
|
|
42
|
+
const image = androidImage();
|
|
43
|
+
const confirm = deps.confirm || ui.confirm;
|
|
44
|
+
if (!flags.yes && !await confirm(`Install Android SDK components and ${image} (about 1 to 2 GB), then create a dedicated Ravensight_Playtest_API35 emulator?`)) { log('No SDK components were installed.'); return 0; }
|
|
45
|
+
// The SDK's license terms are the user's to read and accept, never ours:
|
|
46
|
+
// nothing is typed into a license prompt, so an unaccepted one fails here.
|
|
47
|
+
log('This installs only components whose Android SDK licenses you have already accepted. To read and accept them, run sdkmanager --licenses first.');
|
|
48
|
+
const licenseHint = error => new Error(`${error.message}\nIf sdkmanager asked about a license, read and accept it with sdkmanager --licenses, then run device setup android again.`);
|
|
49
|
+
await (deps.withInput || withInput)(await sdkTool('sdkmanager'), ['--install', 'platform-tools', 'emulator', 'build-tools;35.0.0', image], '').catch(error => { throw licenseHint(error); });
|
|
50
|
+
if (!(await adb.avds()).includes('Ravensight_Playtest_API35')) await (deps.withInput || withInput)(await sdkTool('avdmanager'), ['create', 'avd', '-n', 'Ravensight_Playtest_API35', '-k', image, '-d', 'pixel_6'], 'no\n').catch(error => { throw licenseHint(error); });
|
|
51
|
+
log('Android setup is ready. Run device boot Ravensight_Playtest_API35 --platform android.'); return 0;
|
|
52
|
+
}
|
|
53
|
+
if (!['android', 'ios'].includes(flags.platform)) throw new Error('Pass --platform android or --platform ios for device boot or shutdown.');
|
|
54
|
+
if (!value) throw new Error('Name the exact device to boot or shut down.');
|
|
55
|
+
const tool = flags.platform === 'android' ? adb : simctl;
|
|
56
|
+
if (action === 'boot') { const device = await tool.boot(value); log(`${flags.platform} ${device.id} is ready.`); return 0; }
|
|
57
|
+
if (action === 'shutdown') {
|
|
58
|
+
const device = await tool.select(value);
|
|
59
|
+
const unlock = await (deps.lock || lockDevice)(`${flags.platform}:${device.id}`);
|
|
60
|
+
try { await tool.shutdown(device.id); } finally { await unlock(); }
|
|
61
|
+
log(`${flags.platform} ${device.id} stopped.`); return 0;
|
|
62
|
+
}
|
|
63
|
+
throw new Error(`Unknown device action ${action}.`);
|
|
64
|
+
}
|
package/src/commands/hosted.js
CHANGED
|
@@ -9,7 +9,10 @@ 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, uploadSave } from '../hosted/recordedRun.js';
|
|
12
|
+
import { focusFor, providerRoles, uploadSave } from '../hosted/recordedRun.js';
|
|
13
|
+
|
|
14
|
+
/** Machine output names a Geri provider by its role, never by the server's wire id. */
|
|
15
|
+
const printJson = value => ui.json(providerRoles(value));
|
|
13
16
|
|
|
14
17
|
/** --tier, --minutes, --start, --focus and --avoid as the quote request takes them. */
|
|
15
18
|
export function scopeFrom(flags = {}) {
|
|
@@ -38,7 +41,21 @@ export function personasFrom(flags = {}) {
|
|
|
38
41
|
return hostedPersonas(named);
|
|
39
42
|
}
|
|
40
43
|
|
|
44
|
+
/**
|
|
45
|
+
* A cloud playtest plays an uploaded build or a verified live URL target, both by
|
|
46
|
+
* their id. Never a URL given here or a config's build ref: there is no
|
|
47
|
+
* unverified path to a cloud machine browsing a public host (owner, 2026-11-19).
|
|
48
|
+
*/
|
|
49
|
+
export const HOSTED_URL_REFUSAL = 'A cloud playtest plays an uploaded build or a verified live URL target, by its id (pt_build_...). '
|
|
50
|
+
+ 'To playtest a live URL in the cloud, verify its domain and add the URL as a target on the Playtest page, Test a live URL, then pass the target\'s id with --build. '
|
|
51
|
+
+ 'To play a URL on this machine instead: ravensight-playtest run --url <url>. Nothing was charged.';
|
|
52
|
+
export function assertHostedBuildId(build) {
|
|
53
|
+
if (build === undefined || build === null) return;
|
|
54
|
+
if (typeof build !== 'string' || !/^pt_build_[A-Za-z0-9-]{1,100}$/.test(build)) throw new CliError(HOSTED_URL_REFUSAL, ExitCode.ENVIRONMENT);
|
|
55
|
+
}
|
|
56
|
+
|
|
41
57
|
export async function hostedQuote(flags = {}, deps = {}) {
|
|
58
|
+
assertHostedBuildId(flags.build);
|
|
42
59
|
const context = deps.context || await createContext({ apiUrl: flags.apiUrl, repoRoot: flags.repoRoot, requireAuth: true });
|
|
43
60
|
// The same personas as "hosted run", so a quote and a run of the same build
|
|
44
61
|
// match: fresh-eyes always, plus any named.
|
|
@@ -48,9 +65,9 @@ export async function hostedQuote(flags = {}, deps = {}) {
|
|
|
48
65
|
const result = await quoteHostedRun({ api: context.api, apiUrl: context.api.apiUrl,
|
|
49
66
|
gameId, buildId: flags.build, profileVersion: flags.profile,
|
|
50
67
|
personas, ...await scopeWithSave(flags, { api: context.api, gameId, upload: deps.uploadSave }),
|
|
51
|
-
standardProvider: flags.geriProvider ? GERI_PROVIDERS[flags.geriProvider] :
|
|
68
|
+
standardProvider: flags.geriProvider ? GERI_PROVIDERS[flags.geriProvider] : undefined, includeVideo: Boolean(flags.video),
|
|
52
69
|
output: flags.output });
|
|
53
|
-
if (flags.json)
|
|
70
|
+
if (flags.json) printJson({ ...result, personas });
|
|
54
71
|
else {
|
|
55
72
|
if (personas.length === 1) ui.info(`Persona: ${ALWAYS_INCLUDED_PERSONA}, always included. Add others with --personas a,b.`);
|
|
56
73
|
hostedQuoteLines(result).forEach(line => ui.info(line));
|
|
@@ -72,7 +89,7 @@ export async function hostedRun(filename, flags = {}, deps = {}) {
|
|
|
72
89
|
onPrepared: offer => { if (!flags.json) hostedQuoteLines(offer).forEach(line => ui.info(line)); },
|
|
73
90
|
admit: admitter(flags, deps, maxWaitMs) });
|
|
74
91
|
if (result.state === 'declined') {
|
|
75
|
-
if (flags.json)
|
|
92
|
+
if (flags.json) printJson(result); else ui.info('Hosted quote declined. No admission was requested.');
|
|
76
93
|
return ExitCode.CANCELED;
|
|
77
94
|
}
|
|
78
95
|
const { offer: admittedOffer, ...admitted } = result, gameId = admittedOffer.gameId;
|
|
@@ -82,12 +99,12 @@ export async function hostedRun(filename, flags = {}, deps = {}) {
|
|
|
82
99
|
ui.info(`Check on it with: ravensight-playtest hosted status ${admitted.admissionId}`);
|
|
83
100
|
}
|
|
84
101
|
if (!flags.wait) {
|
|
85
|
-
if (flags.json)
|
|
102
|
+
if (flags.json) printJson(admitted);
|
|
86
103
|
else ui.info(`The server acknowledged the paid admission (${admitted.state}). This does not prove a worker started or produced gameplay or reports.`);
|
|
87
104
|
return ExitCode.OK;
|
|
88
105
|
}
|
|
89
106
|
const view = await waitForRun({ api, gameId, admissionId: admitted.admissionId, apiUrl, sleep, now, onPhase: phaseLine(flags) });
|
|
90
|
-
if (flags.json)
|
|
107
|
+
if (flags.json) printJson({ ...admitted, gameId, status: view });
|
|
91
108
|
else printOutcome(view);
|
|
92
109
|
return exitFor(view);
|
|
93
110
|
});
|
|
@@ -194,6 +211,7 @@ function admittedLines(admitted, now) {
|
|
|
194
211
|
* admission. The admission keeps the saved-quote path's journal and never retries.
|
|
195
212
|
*/
|
|
196
213
|
export async function hostedRunDirect(flags = {}, deps = {}) {
|
|
214
|
+
assertHostedBuildId(flags.build);
|
|
197
215
|
if (flags.json && !flags.yes && !deps.confirm) throw new CliError('A hosted run charges prepaid funds. Use --yes with --json. Nothing was charged.');
|
|
198
216
|
const maxWaitMs = capacityWaitMs(flags.waitForCapacity);
|
|
199
217
|
const context = deps.context || await createContext({ apiUrl: flags.apiUrl, repoRoot: flags.repoRoot, requireAuth: true });
|
|
@@ -215,7 +233,7 @@ export async function hostedRunDirect(flags = {}, deps = {}) {
|
|
|
215
233
|
}
|
|
216
234
|
const confirm = deps.confirm || (question => ui.confirm(question, { yes: Boolean(flags.yes) }));
|
|
217
235
|
if (!await confirm(confirmQuestion(offer))) {
|
|
218
|
-
if (flags.json)
|
|
236
|
+
if (flags.json) printJson({ state: 'declined', gameId, buildId: build.buildId, walletMutationRequested: false });
|
|
219
237
|
else ui.info('Declined. Nothing was charged.');
|
|
220
238
|
return ExitCode.CANCELED;
|
|
221
239
|
}
|
|
@@ -230,12 +248,12 @@ export async function hostedRunDirect(flags = {}, deps = {}) {
|
|
|
230
248
|
ui.info(`Check on it with: ravensight-playtest hosted status ${admitted.admissionId}`);
|
|
231
249
|
}
|
|
232
250
|
if (!flags.wait) {
|
|
233
|
-
if (flags.json)
|
|
251
|
+
if (flags.json) printJson(result);
|
|
234
252
|
else ui.info(`Report: ${reportUrl}`);
|
|
235
253
|
return ExitCode.OK;
|
|
236
254
|
}
|
|
237
255
|
const view = await waitForRun({ api, gameId, admissionId: admitted.admissionId, apiUrl, sleep, now, onPhase: phaseLine(flags) });
|
|
238
|
-
if (flags.json)
|
|
256
|
+
if (flags.json) printJson({ ...result, status: view });
|
|
239
257
|
else printOutcome(view);
|
|
240
258
|
return exitFor(view);
|
|
241
259
|
});
|
|
@@ -253,7 +271,7 @@ export async function hostedStatus(admissionId, flags = {}, deps = {}) {
|
|
|
253
271
|
const view = flags.wait
|
|
254
272
|
? await waitForRun({ api, gameId, admissionId, apiUrl, sleep, now, onPhase: phaseLine(flags) })
|
|
255
273
|
: statusView(gameId, apiUrl, await readHostedRun({ api, gameId, admissionId }), now());
|
|
256
|
-
if (flags.json)
|
|
274
|
+
if (flags.json) printJson(view); else printOutcome(view, now());
|
|
257
275
|
return flags.wait ? exitFor(view) : ExitCode.OK;
|
|
258
276
|
});
|
|
259
277
|
}
|
|
@@ -261,7 +279,7 @@ export async function hostedStatus(admissionId, flags = {}, deps = {}) {
|
|
|
261
279
|
/** "hosted status" with no run id: ask the server about every admission whose outcome is not known locally. */
|
|
262
280
|
async function resolvePending(context, flags, now) {
|
|
263
281
|
const results = await resolveHostedIntents({ api: context.api, apiUrl: context.api.apiUrl, repoRoot: context.repoRoot, now });
|
|
264
|
-
if (flags.json) {
|
|
282
|
+
if (flags.json) { printJson({ intents: results.map(({ message, ...row }) => row) }); }
|
|
265
283
|
else if (!results.length) ui.info('No hosted admission is waiting for an answer. Name a run to see it: ravensight-playtest hosted status <run-id>');
|
|
266
284
|
else pendingLines(results).forEach(line => ui.info(line));
|
|
267
285
|
return results.some(row => ['unknown', 'unreadable', 'wait', 'other_api'].includes(row.state)) ? ExitCode.ENVIRONMENT : ExitCode.OK;
|
|
@@ -307,13 +325,13 @@ export async function hostedCancel(admissionId, flags = {}, deps = {}) {
|
|
|
307
325
|
const confirm = deps.confirm || (question => ui.confirm(question, { yes: Boolean(flags.yes),
|
|
308
326
|
noTerminalMessage: 'No terminal to confirm in: pass --yes to cancel this run.' }));
|
|
309
327
|
if (!await confirm(`Cancel hosted run ${admissionId}? Work already completed follows the accepted policy; unstarted work is refunded during settlement.`)) {
|
|
310
|
-
if (flags.json)
|
|
328
|
+
if (flags.json) printJson({ state: 'kept', admissionId });
|
|
311
329
|
else ui.info('Nothing was canceled.');
|
|
312
330
|
return ExitCode.CANCELED;
|
|
313
331
|
}
|
|
314
332
|
await cancelHostedRun({ api, gameId, admissionId });
|
|
315
333
|
const view = statusView(gameId, apiUrl, await readHostedRun({ api, gameId, admissionId }), now());
|
|
316
|
-
if (flags.json)
|
|
334
|
+
if (flags.json) printJson(view);
|
|
317
335
|
else {
|
|
318
336
|
ui.ok(view.phase === 'canceled' ? `Hosted run ${admissionId} is canceled.` : `Cancellation requested for hosted run ${admissionId}.`);
|
|
319
337
|
printOutcome(view);
|