ravensight-playtest 0.8.3 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +280 -66
  2. package/addons/ravensight_driver/driver.gd +666 -21
  3. package/docs/ADAPTERS.md +11 -7
  4. package/docs/NATIVE_RUNNER.md +3 -1
  5. package/docs/godot-driver.md +127 -13
  6. package/package.json +8 -6
  7. package/src/api/client.js +4 -3
  8. package/src/cli.js +84 -25
  9. package/src/commands/check.js +30 -4
  10. package/src/commands/fakeCore.js +1 -0
  11. package/src/commands/hosted.js +41 -12
  12. package/src/commands/init.js +17 -1
  13. package/src/commands/run.js +209 -14
  14. package/src/commands/upload.js +6 -2
  15. package/src/commands/validate.js +1 -1
  16. package/src/commands/validateHosted.js +50 -5
  17. package/src/config.js +33 -2
  18. package/src/hosted/archivePreflight.js +7 -7
  19. package/src/hosted/buildUpload.js +89 -8
  20. package/src/hosted/recordedRun.js +141 -26
  21. package/src/hosted/status.js +19 -10
  22. package/src/run/actionSelector.js +14 -3
  23. package/src/run/aggregate.js +57 -3
  24. package/src/run/anygame/controlbook.js +179 -0
  25. package/src/run/anygame/genre.js +179 -0
  26. package/src/run/anygame/index.js +258 -0
  27. package/src/run/anygame/language.js +336 -0
  28. package/src/run/anygame/memory.js +330 -0
  29. package/src/run/anygame/shared-hashes.json +10 -0
  30. package/src/run/anygame/shared.js +24 -0
  31. package/src/run/anygame/sound.js +342 -0
  32. package/src/run/args.js +75 -8
  33. package/src/run/choiceCheck.js +312 -0
  34. package/src/run/context.js +254 -13
  35. package/src/run/drivers/godot-observation.js +93 -6
  36. package/src/run/drivers/godot.js +769 -46
  37. package/src/run/drivers/recording.js +24 -4
  38. package/src/run/drivers/web.js +1242 -77
  39. package/src/run/edgePass.js +731 -0
  40. package/src/run/fixLoop.js +5 -4
  41. package/src/run/focus.js +65 -0
  42. package/src/run/gamepad.js +108 -0
  43. package/src/run/godotEdgePass.js +235 -0
  44. package/src/run/godotTesterProbes.js +192 -0
  45. package/src/run/headings.js +21 -0
  46. package/src/run/honesty.js +544 -0
  47. package/src/run/inputs.js +256 -0
  48. package/src/run/marks.js +142 -0
  49. package/src/run/personaLoop.js +1000 -79
  50. package/src/run/phone.js +7 -0
  51. package/src/run/pixels.js +215 -0
  52. package/src/run/playClock.js +162 -0
  53. package/src/run/readiness.js +585 -0
  54. package/src/run/refusal.js +67 -0
  55. package/src/run/regions.js +119 -0
  56. package/src/run/report.js +14 -2
  57. package/src/run/reportChecks.js +472 -0
  58. package/src/run/resume.js +3 -2
  59. package/src/run/screenshots.js +161 -0
  60. package/src/run/strip.js +114 -0
  61. package/src/run/testerLedger.js +312 -0
  62. package/src/run/testerProbes.js +584 -0
  63. package/src/run/thinRun.js +102 -0
  64. package/src/run/timeFreeze.js +79 -0
  65. package/src/run/tools.js +454 -29
  66. package/src/runDefaults.js +24 -2
@@ -11,6 +11,7 @@ import { detectGodotBinary, majorMinor } from '../godot.js';
11
11
  import { buildPack, HOSTED_GODOT, PACK_NAME } from '../simulation/godotPack.js';
12
12
  import { defaultBase } from './validate.js';
13
13
  import { DIMENSION_3D, dimensionGate } from '../run/dimension.js';
14
+ import { queueInfo, queueLine } from '../hosted/status.js';
14
15
 
15
16
  /**
16
17
  * `ravensight-playtest validate <branch> --hosted`: two uploaded Godot builds, the
@@ -27,6 +28,11 @@ export const DEFAULT_STEPS = 300;
27
28
  export const MAX_STEPS = 10000;
28
29
  const POLL_MS = 15000;
29
30
  const WAIT_MS = 80 * 60 * 1000;
31
+ // The longest this command waits in all, line included. The server's own line ends
32
+ // sooner (six hours, and 45 minutes more for the second machine), so this is a ceiling.
33
+ export const QUEUE_WAIT_MS = 8 * 60 * 60 * 1000;
34
+ // Reads that failed in a row before the command stops waiting.
35
+ export const MAX_POLL_FAILURES = 20;
30
36
  const money = cents => `$${(cents / 100).toFixed(2)}`;
31
37
  const BUILD_POLL_MS = 5000;
32
38
  const BUILD_WAIT_MS = 15 * 60 * 1000;
@@ -66,6 +72,16 @@ export function comparisonLines(pair) {
66
72
  return lines;
67
73
  }
68
74
 
75
+ /**
76
+ * "Queued, position 2, expected to start in about 14 minutes." for an open comparison
77
+ * the server says is waiting for a machine (`queued` and `queue`, the fields a cloud
78
+ * playtest carries), or null. A cancel or a review is said elsewhere.
79
+ */
80
+ export function queuedLine(pair, now = Date.now()) {
81
+ if (!pair || pair.state !== 'open' || pair.cancelRequested || pair.underReview || pair.queued !== true) return null;
82
+ return queueLine(queueInfo(pair), now);
83
+ }
84
+
69
85
  /** A ready build of these exact bytes is reused, so a retry pays no second deposit. */
70
86
  async function ensureBuild({ api, gameId, built, sleep, fetchImpl, log, label, clock, created: createdIds }) {
71
87
  const manifest = { sha256: built.sha256, bytes: built.bytes, entrypoint: PACK_NAME, args: [] };
@@ -264,7 +280,10 @@ export async function validateHostedCommand(head, flags = {}, injected = {}) {
264
280
  await release();
265
281
  return EXIT.ENVIRONMENT;
266
282
  }
267
- log(`Comparison ${pair.pairId} started.`);
283
+ // A paid comparison is never refused for a busy service: it waits in line for a
284
+ // cloud machine, and says its place and estimated start as a cloud playtest does.
285
+ let said = queuedLine(pair, clock());
286
+ log(said ? `Comparison ${pair.pairId} is paid for and waiting for a cloud machine. ${said}` : `Comparison ${pair.pairId} started.`);
268
287
  const link = jobLink(gameId, pair.base.jobId, setup.apiUrl);
269
288
  if (link) log(`Follow it at ${link}`);
270
289
  if (flags.wait === false) {
@@ -272,10 +291,33 @@ export async function validateHostedCommand(head, flags = {}, injected = {}) {
272
291
  return EXIT.OK;
273
292
  }
274
293
 
275
- const deadline = clock() + WAIT_MS;
276
- while (pair.state !== 'settled' && !pair.underReview && clock() < deadline) {
294
+ // Two clocks, both this command's own. `ceiling` is absolute and set once: nothing
295
+ // the server answers can move it. `deadline` is the run's wait; it restarts once,
296
+ // when the comparison leaves the line, and never past the ceiling.
297
+ const ceiling = clock() + QUEUE_WAIT_MS;
298
+ let deadline = Math.min(ceiling, clock() + WAIT_MS);
299
+ let failures = 0;
300
+ while (pair.state !== 'settled' && !pair.underReview) {
301
+ const at = clock();
302
+ if (at >= ceiling || (!said && at >= deadline)) break;
277
303
  await sleep(POLL_MS);
278
- try { pair = await api.hosted.readPair(gameId, pair.pairId); } catch (error) { if (error.status === 404) throw error; }
304
+ let fresh;
305
+ try { fresh = await api.hosted.readPair(gameId, pair.pairId); } catch (error) {
306
+ if (error.status === 404) throw error;
307
+ // A read that failed says nothing new: it extends no wait, and too many in a row end it.
308
+ failures += 1;
309
+ if (failures >= MAX_POLL_FAILURES) break;
310
+ continue;
311
+ }
312
+ failures = 0;
313
+ pair = fresh;
314
+ const line = queuedLine(pair, clock());
315
+ if (line && line !== said) log(line);
316
+ if (!line && said) {
317
+ deadline = Math.min(ceiling, clock() + WAIT_MS);
318
+ if (pair.state !== 'settled') log('A cloud machine is free: this comparison is running.');
319
+ }
320
+ said = line;
279
321
  }
280
322
  if (flags.json) console.log(JSON.stringify(pair));
281
323
  if (pair.state !== 'settled' && pair.underReview) {
@@ -283,7 +325,10 @@ export async function validateHostedCommand(head, flags = {}, injected = {}) {
283
325
  return EXIT.OK;
284
326
  }
285
327
  if (pair.state !== 'settled') {
286
- log(`Comparison ${pair.pairId} is still running. The job page shows it when it finishes.`);
328
+ // Giving up waiting changes nothing on the server: no cancel and no refund.
329
+ const where = link ? `Check it at ${link}` : 'The job page shows it when it finishes';
330
+ log(said ? `Comparison ${pair.pairId} (job ${pair.base.jobId}) is still waiting for a cloud machine. It is paid for and keeps its place. ${where}.`
331
+ : `Comparison ${pair.pairId} (job ${pair.base.jobId}) is still running. ${where}.`);
287
332
  return EXIT.OK;
288
333
  }
289
334
  for (const line of comparisonLines(pair)) log(line);
package/src/config.js CHANGED
@@ -19,7 +19,8 @@ export const CONFIG_VERSION = 1;
19
19
  * @property {string} [driver] - playwright_web, godot_driver or cli_stdio
20
20
  * @property {Object} [build] - `{ kind, ref }`
21
21
  * @property {string[]} [personas]
22
- * @property {Object} [uploads] - `{ video: boolean, transcript: boolean }`
22
+ * @property {Object} [uploads] - `{ video: boolean, step_log: boolean }`; an
23
+ * older `transcript` key is ignored (see stepLogSetting)
23
24
  * @property {number} [max_actions]
24
25
  * @property {number} [concurrency]
25
26
  */
@@ -32,12 +33,42 @@ export function defaultConfig(gameId, extra = {}) {
32
33
  driver: 'playwright_web',
33
34
  build: { kind: '', ref: '' },
34
35
  personas: [],
35
- uploads: { video: false, transcript: false },
36
+ uploads: { video: false, step_log: true },
36
37
  concurrency: 2,
37
38
  ...extra
38
39
  };
39
40
  }
40
41
 
42
+ /**
43
+ * What the project config says about uploading a persona run's step log
44
+ * (transcript.jsonl). Only `uploads.step_log` is read. The older
45
+ * `uploads.transcript` is not: `init` wrote `"transcript": false` into every
46
+ * config before 0.10.0 whether or not anyone chose it, so it was never a
47
+ * choice, and since 0.10.0 the step log uploads by default for every project.
48
+ *
49
+ * @param {LocalConfig|null} config
50
+ * @returns {{upload: boolean|null, key: 'step_log'|null}} null when the config says nothing
51
+ */
52
+ export function stepLogSetting(config) {
53
+ const uploads = config && config.uploads && typeof config.uploads === 'object' ? config.uploads : {};
54
+ if (typeof uploads.step_log === 'boolean') return { upload: uploads.step_log, key: 'step_log' };
55
+ return { upload: null, key: null };
56
+ }
57
+
58
+ /** The step log in a few words, the same in every line that mentions it. */
59
+ export const STEP_LOG_WHAT = 'transcript.jsonl: the inputs sent, what each screen showed and the persona\'s notes';
60
+
61
+ /** How to keep the step log on this machine, the same everywhere. */
62
+ export const STEP_LOG_OFF = 'To keep it on this machine, set "uploads": { "step_log": false } in .ravensight/config.json or pass --no-upload-step-log.';
63
+
64
+ /**
65
+ * The one line that says the step log uploads, why, for how long, and how to stop it.
66
+ * @returns {string}
67
+ */
68
+ export function stepLogUploadsLine() {
69
+ return `The step log (${STEP_LOG_WHAT}) uploads with the reports so the dashboard can show the evidence report, and is kept 90 days. ${STEP_LOG_OFF}`;
70
+ }
71
+
41
72
  /**
42
73
  * Read the repo's config, or null when this repo has never been linked.
43
74
  * @param {{repoRoot?: string}} [options]
@@ -186,13 +186,13 @@ 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 and upload that output, or run a local playtest with --driver unity_driver',
190
- unreal: 'this is an Unreal Engine build, and Unreal has no supported web export, so a cloud playtest cannot play it. Run a local playtest with --driver unreal_driver',
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 with --driver godot_driver',
192
- love: 'this is a LÖVE game file. Cloud playtests play web builds: package it with love.js and upload that folder, or run a local playtest with --driver desktop_driver',
193
- android: 'this is an Android app. Android builds play only in a local playtest: --driver android_driver on your own device or emulator',
194
- ios: 'this is an iOS app. iOS builds play only in a local playtest: --driver ios_driver on your own device or simulator',
195
- desktop: 'this is a desktop program, not a web build. Cloud playtests play web builds only (HTML and WebAssembly): build for the web, or run a local playtest with --driver desktop_driver'
189
+ unity: 'this is a Unity desktop or mobile build, and native Unity builds cannot be playtested today. Cloud and local playtests play web builds: build for the Web platform in Unity and upload that output; the export settings are at ravensight.io/docs/#playtest-unity',
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
+ 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
+ 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',
193
+ android: 'this is an Android app, and native mobile builds cannot be playtested today. Cloud and local playtests play web builds: build your game for the web and upload that output',
194
+ ios: 'this is an iOS app, and native mobile builds cannot be playtested today. Cloud and local playtests play web builds: build your game for the web and upload that output',
195
+ desktop: 'this is a desktop program, not a web build, and native desktop builds cannot be playtested today. Cloud and local playtests play web builds (HTML and WebAssembly): build for the web and upload that output'
196
196
  });
197
197
  const any = (paths, pattern) => paths.some(name => pattern.test(name));
198
198
 
@@ -43,6 +43,78 @@ export async function putArchive(archive, transfer, { fetchImpl = globalThis.fet
43
43
  } finally { stream.destroy(); }
44
44
  }
45
45
 
46
+ const S3_HOST = /^[a-z0-9.-]+\.s3\.[a-z0-9-]+\.amazonaws\.com$/;
47
+ // A part is tried a few times; a URL the storage refuses (it expired with the
48
+ // credentials that signed it) is signed again once per part.
49
+ export const PART_TRIES = 4;
50
+ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
51
+
52
+ /** One part of a multipart upload as the server signed it: its number, exact length and private S3 URL. */
53
+ function signedPart(part, { number, bytes, uploadId }) {
54
+ let url;
55
+ try { url = new URL(part?.url); } catch { fail('The server did not return a supported private S3 upload destination. Preserve the original upload journal.'); }
56
+ if (part.partNumber !== number || part.bytes !== bytes || url.protocol !== 'https:' || url.username || url.password || url.hash || !S3_HOST.test(url.hostname)
57
+ || url.searchParams.get('partNumber') !== String(number) || url.searchParams.get('uploadId') !== uploadId
58
+ || !/^\d{8}T\d{6}Z$/.test(url.searchParams.get('X-Amz-Date') || '')) fail('The upload parts do not match the inspected archive. Preserve the original upload journal.');
59
+ return { number, bytes, url: url.href };
60
+ }
61
+
62
+ /**
63
+ * The plan of a multipart upload, checked against the archive: every part in
64
+ * order, each of the server's part size but the last, adding up to the
65
+ * archive's exact length. A build over the server's single upload size (300
66
+ * MiB today) is sent this way, up to 4 GiB.
67
+ */
68
+ export function multipartPlan(upload, { size, uploadExpiresAt }, now = Date.now()) {
69
+ const partBytes = upload?.partBytes, uploadId = upload?.uploadId, until = Date.parse(uploadExpiresAt);
70
+ if (upload?.method !== 'MULTIPART' || !Number.isSafeInteger(partBytes) || partBytes < 5 * 1024 * 1024 || typeof uploadId !== 'string' || !uploadId || uploadId.length > 2048
71
+ || !Number.isSafeInteger(size) || size < 1 || !Array.isArray(upload.parts)) fail('The server did not return a supported multipart upload. Preserve the original upload journal.');
72
+ const count = Math.ceil(size / partBytes);
73
+ if (upload.parts.length !== count || count > 10000) fail('The upload parts do not match the inspected archive. Preserve the original upload journal.');
74
+ if (!Number.isFinite(until) || until <= now) fail('The original upload window has expired. Do not create a replacement reservation automatically.');
75
+ const bytesOf = number => (number < count ? partBytes : size - partBytes * (count - 1));
76
+ return { uploadId, partBytes, count, expiresAt: until, bytesOf, parts: upload.parts.map((part, i) => signedPart(part, { number: i + 1, bytes: bytesOf(i + 1), uploadId })) };
77
+ }
78
+
79
+ /**
80
+ * Send every part in order and answer `[{ partNumber, etag }]` for the
81
+ * completion. Each part streams from the archive with its exact length. A part
82
+ * that fails is sent again (the same bytes; S3 keeps the last), and a part
83
+ * whose URL storage refuses is signed again by `resign(partNumber)`, once.
84
+ */
85
+ export async function putParts(archive, plan, { fetchImpl = globalThis.fetch, signal, onProgress, resign, sleepImpl = sleep } = {}) {
86
+ await archive.check();
87
+ const done = [];
88
+ let sent = 0;
89
+ for (const first of plan.parts) {
90
+ let part = first, resigned = false;
91
+ const start = (part.number - 1) * plan.partBytes;
92
+ for (let attempt = 1; ; attempt++) {
93
+ const remaining = plan.expiresAt - Date.now();
94
+ if (remaining <= 0) fail('The original upload window has expired.');
95
+ const deadline = AbortSignal.timeout(Math.min(remaining, 2147483647));
96
+ const stream = Readable.from(archive.chunks({ start, end: start + part.bytes, onProgress: completed => onProgress?.(sent + completed, archive.size) }), { objectMode: false, highWaterMark: 65536 });
97
+ let status = 0, etag = null, network = null;
98
+ try {
99
+ const response = await fetchImpl(part.url, { method: 'PUT', headers: { 'content-length': String(part.bytes) }, body: stream, duplex: 'half', redirect: 'error', signal: signal ? AbortSignal.any([signal, deadline]) : deadline });
100
+ status = response.status; etag = response.headers.get('etag');
101
+ await response.arrayBuffer().catch(() => {});
102
+ } catch (error) {
103
+ if (signal?.aborted) throw error;
104
+ network = error;
105
+ } finally { stream.destroy(); }
106
+ if (status >= 200 && status < 300 && typeof etag === 'string' && /^"?[A-Za-z0-9+/=_-]{1,128}"?$/.test(etag)) { done.push({ partNumber: part.number, etag }); sent += part.bytes; break; }
107
+ // Refused: most often a URL that outlived the credentials that signed it. Ask for a fresh one, once.
108
+ if (status === 403 && typeof resign === 'function' && !resigned) { resigned = true; part = signedPart(await resign(part.number), { number: part.number, bytes: part.bytes, uploadId: plan.uploadId }); continue; }
109
+ const again = network || status >= 500 || status === 429 || status === 408;
110
+ if (!again || attempt >= PART_TRIES) fail(`Part ${part.number} of ${plan.count} of the original archive upload ${network ? 'could not be sent' : `returned HTTP ${status}`}. Preserve the journal; no replacement reservation was requested.`);
111
+ await sleepImpl(Math.min(30000, 1000 * 2 ** (attempt - 1)));
112
+ }
113
+ }
114
+ await archive.check();
115
+ return done;
116
+ }
117
+
46
118
  // Server text is one plain sentence; still print it as one bounded line.
47
119
  const serverSentence = text => printable(String(text || '')).replace(/\s+/g, ' ').trim().slice(0, 300);
48
120
 
@@ -91,7 +163,9 @@ export async function uploadHostedBuild({ filename, gameId, profileVersion, entr
91
163
  if (!caps?.recorded?.available || !Array.isArray(profiles)) fail('Recorded game uploads are not available for this game.');
92
164
  profileVersion = chooseProfile(profiles, profileVersion);
93
165
  const matching = profiles.filter(profile => profile.profileVersion === profileVersion);
94
- const profile = matching[0], limits = profile.capacity ? limitsFromProfile(profile) : buildLimits(caps.limits);
166
+ // A cloud playtest build may be as large as the largest tier: the server's cloud limits when it
167
+ // sends them (an older server sends only the 64 MiB ones).
168
+ const profile = matching[0], limits = profile.capacity ? limitsFromProfile(profile) : buildLimits(caps.cloudLimits ? { ...caps.cloudLimits } : caps.limits);
95
169
  const offer = profile.reservationOffer;
96
170
  if (!offer || offer.amountCents !== 49 || offer.currency !== 'USD' || offer.purpose !== 'validation_hold'
97
171
  || offer.refund !== 'after_cleanup' || !/^[a-f0-9]{64}$/.test(offer.version || '')) fail('The server did not provide the supported validation-hold offer.');
@@ -130,17 +204,24 @@ export async function uploadHostedBuild({ filename, gameId, profileVersion, entr
130
204
  const answer = body(await api.request('POST', `${base(gameId)}/builds`, { body: input, headers: { 'Idempotency-Key': state.idempotencyKey }, idempotent: false }));
131
205
  if (!/^pt_build_[a-f0-9-]{1,100}$/.test(answer?.build?.buildId || '')) fail('The upload reservation response needs reconciliation.');
132
206
  state.buildId = answer.build.buildId; state.phase = 'reserved'; await writeJson(journal, state, { mode: 0o600 });
133
- const transfer = singlePut(answer.upload, { size: archive.size, sha256, uploadExpiresAt: answer.uploadExpiresAt });
134
- state.phase = 'upload_unknown'; await writeJson(journal, state, { mode: 0o600 });
135
- onProgress({ phase: 'upload', completedBytes: 0, totalBytes: archive.size });
136
- await putArchive(archive, transfer, { fetchImpl, signal,
137
- onProgress: (completedBytes, totalBytes) => onProgress({ phase: 'upload', completedBytes, totalBytes }) });
207
+ // A build over the server's single upload size arrives as a multipart plan: its parts are sent in order.
208
+ const multipart = answer.upload?.method === 'MULTIPART';
209
+ const plan = multipart ? multipartPlan(answer.upload, { size: archive.size, uploadExpiresAt: answer.uploadExpiresAt }) : null;
210
+ const transfer = multipart ? null : singlePut(answer.upload, { size: archive.size, sha256, uploadExpiresAt: answer.uploadExpiresAt });
211
+ state.phase = 'upload_unknown'; if (multipart) state.multipart = { parts: plan.count, partBytes: plan.partBytes }; await writeJson(journal, state, { mode: 0o600 });
212
+ onProgress({ phase: 'upload', completedBytes: 0, totalBytes: archive.size, ...(multipart ? { parts: plan.count } : {}) });
213
+ const progress = (completedBytes, totalBytes) => onProgress({ phase: 'upload', completedBytes, totalBytes });
214
+ let parts = null;
215
+ if (multipart) {
216
+ const resign = async number => body(await api.request('POST', `${base(gameId)}/builds/${encodeURIComponent(state.buildId)}/parts`, { body: { partNumbers: [number] }, idempotent: true }))?.parts?.[0];
217
+ parts = await putParts(archive, plan, { fetchImpl, signal, onProgress: progress, resign });
218
+ } else await putArchive(archive, transfer, { fetchImpl, signal, onProgress: progress });
138
219
  state.phase = 'uploaded'; await writeJson(journal, state, { mode: 0o600 });
139
220
  onProgress({ phase: 'completion' });
140
- const completed = body(await api.request('POST', `${base(gameId)}/builds/${encodeURIComponent(state.buildId)}/complete`, { idempotent: true }));
221
+ const completed = body(await api.request('POST', `${base(gameId)}/builds/${encodeURIComponent(state.buildId)}/complete`, { ...(parts ? { body: { parts } } : {}), idempotent: true }));
141
222
  state.phase = 'awaiting_validation'; state.serverBuild = completed; await writeJson(journal, state, { mode: 0o600 });
142
223
  return { state: state.phase, buildId: state.buildId, journal, walletMutationRequested: true, validationHoldCents: offer.amountCents,
143
- multipartSupported: false, uploadResumeSupported: false, gameplayStarted: false };
224
+ multipartSupported: true, multipartParts: plan ? plan.count : 0, uploadResumeSupported: false, gameplayStarted: false };
144
225
  } catch (error) {
145
226
  // A definite refusal before any hold (the server checks the daily build
146
227
  // check limit inside the same transaction): nothing to reconcile, so
@@ -8,10 +8,19 @@ import { printable } from '../ui/index.js';
8
8
  import { chooseProfile } from './buildUpload.js';
9
9
  import { displayName } from '../run/controllers.js';
10
10
  import { queueInfo } from './status.js';
11
+ import { ALWAYS_INCLUDED_PERSONA, MAX_HOSTED_PERSONAS, hostedPersonas } from '../runDefaults.js';
11
12
 
12
13
  const MAX_QUOTE_BYTES = 1024 * 1024;
13
14
  const CONSENT_KEYS = ['quoteId', 'planHash', 'profileVersion', 'controllers', 'includeVideo', 'includeTranscript',
14
15
  'totalPriceCents', 'dueNowCents', 'priceVersion', 'policyVersion'];
16
+ // The cloud playtest customers buy: one playtester per persona, Geri planning
17
+ // and Freki acting in the same run (the server's wire id `combined`). The
18
+ // separate Geri then Freki comparison stays readable for saved quotes and
19
+ // evaluation, but nothing in the CLI offers it any more.
20
+ export const COMBINED = Object.freeze(['combined']);
21
+ export const COMPARISON = Object.freeze(['standard', 'jev']);
22
+ const isCombined = controllers => same(controllers, COMBINED);
23
+ const slug = value => typeof value === 'string' && value.length <= 48 && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value);
15
24
  const PROVIDERS = ['anthropic', 'openai'];
16
25
  // Customers choose Geri's model provider by role, never by vendor name. The
17
26
  // server's wire values stay; ravensight.io/legal/subprocessors names both.
@@ -62,22 +71,83 @@ export async function readHostedQuote(filename) {
62
71
  } finally { await handle.close(); }
63
72
  }
64
73
 
65
- function requestFor({ buildId, profileVersion, persona, standardProvider, includeVideo = false, includeTranscript = false }, profile) {
66
- if (!id(buildId) || !id(profileVersion) || typeof persona !== 'string' || persona.length > 48
67
- || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(persona)) fail('Choose a validated build, ready profile and one persona.');
74
+ /**
75
+ * The quote request. A combined playtest names fresh-eyes first and each
76
+ * other persona once; a comparison (saved by an older CLI) names one persona.
77
+ */
78
+ export const TIERS = Object.freeze(['jam', 'small', 'medium', 'large']);
79
+ const plainLine = value => typeof value === 'string' && value.trim().length > 0 && value.length <= 200 && !/[\u0000-\u001f\u007f]/.test(value);
80
+ /** The focus block: a start query or hash, and up to five focus and avoid lines. */
81
+ export function focusFor({ start, focus = [], avoid = [] } = {}) {
82
+ if (start !== undefined && start !== null && start !== '' && (typeof start !== 'string' || !/^[?#][^\s\\]{0,199}$/.test(start))) fail('Choose --start as a query or hash on the build, such as ?level=3 or #boss.');
83
+ for (const [name, list] of [['--focus', focus], ['--avoid', avoid]]) {
84
+ if (!Array.isArray(list) || list.length > 5 || !list.every(plainLine)) fail(`Give ${name} at most five times, each plain text of at most 200 characters.`);
85
+ }
86
+ return { ...(start ? { start } : {}), focus: focus.map(x => x.trim()), avoid: avoid.map(x => x.trim()) };
87
+ }
88
+
89
+ /** The largest save file a cloud playtest starts from (the server's bound). */
90
+ export const MAX_SAVE_BYTES = 1024 * 1024;
91
+
92
+ /**
93
+ * Where the game reads its save, from --save-target:
94
+ * hook the game reads it itself (window.RavensightPlaytest.save)
95
+ * localstorage:<key> one localStorage key, the file as UTF-8 text
96
+ * godot:user://<path> a file in a Godot web export's user:// folder
97
+ * idbfs:/<mount>/<path> a file in an engine's browser file storage
98
+ */
99
+ export function saveTargetFor(value = 'hook') {
100
+ const v = String(value);
101
+ if (v === 'hook') return { kind: 'hook' };
102
+ if (v.startsWith('localstorage:') && v.length > 13) return { kind: 'local_storage', key: v.slice(13) };
103
+ if (v.startsWith('godot:user://') && v.length > 13) return { kind: 'godot_user', path: v.slice(6) };
104
+ if (v.startsWith('idbfs:/') && v.length > 7) return { kind: 'idbfs', path: v.slice(6) };
105
+ fail('Choose --save-target as hook, localstorage:<key>, godot:user://<path> or idbfs:/<mount>/<path>. Nothing was uploaded or charged.');
106
+ }
107
+
108
+ /**
109
+ * Upload a save file for a cloud playtest to start from, and answer the
110
+ * server's record of it. Free: nothing is quoted or charged here.
111
+ */
112
+ export async function uploadSave({ api, gameId, file, target, readFileImpl = readFile }) {
113
+ const where = saveTargetFor(target);
114
+ let data;
115
+ try { data = await readFileImpl(file); } catch { fail(`The save file ${printable(String(file))} could not be read. Nothing was uploaded or charged.`); }
116
+ if (!data.length) fail('The save file is empty. Nothing was uploaded or charged.');
117
+ if (data.length > MAX_SAVE_BYTES) fail(`A save file may be at most ${MAX_SAVE_BYTES / 1024} KiB; this one is ${Math.ceil(data.length / 1024)} KiB. Nothing was uploaded or charged.`);
118
+ const name = path.basename(String(file)).replace(/[^A-Za-z0-9._ -]/g, '_').replace(/^[^A-Za-z0-9]+/, '').slice(0, 100) || 'save';
119
+ const answer = await api.request('POST', `${base(gameId)}/saves`, { body: { name, target: where, data: data.toString('base64') }, idempotent: false });
120
+ const save = answer.body?.save;
121
+ if (!/^pt_save_[a-f0-9-]{36}$/.test(save?.saveId || '') || save.bytes !== data.length) fail('The server did not record the save file. Nothing was charged.');
122
+ return save;
123
+ }
124
+
125
+ function requestFor({ buildId, profileVersion, personas, controllers = COMBINED, standardProvider, includeVideo = false, includeTranscript = false, tier, minutes, focus }, profile) {
126
+ const combined = isCombined(controllers);
127
+ if (!combined && !same(controllers, COMPARISON)) fail('Choose a cloud playtest the server sells.');
128
+ const list = combined ? hostedPersonas(personas) : personas;
129
+ if (!id(buildId) || !id(profileVersion) || !Array.isArray(list) || !list.length || !list.every(slug)
130
+ || new Set(list).size !== list.length) fail('Choose a validated build, a ready profile and persona slugs such as fresh-eyes.');
131
+ if (combined && (list[0] !== ALWAYS_INCLUDED_PERSONA || list.length > MAX_HOSTED_PERSONAS)) fail(`Choose at most ${MAX_HOSTED_PERSONAS} personas, ${ALWAYS_INCLUDED_PERSONA} included.`);
132
+ if (!combined && list.length !== 1) fail('A saved comparison names one persona.');
68
133
  if (standardProvider !== undefined && !PROVIDERS.includes(standardProvider)) fail('Choose primary or alternate for the Geri model provider.');
69
134
  if (typeof includeVideo !== 'boolean' || typeof includeTranscript !== 'boolean') fail('Choose explicit video and transcript options.');
70
- return { kind: 'recorded_graphical', buildId, personas: [persona], controllers: ['standard', 'jev'],
135
+ if (tier !== undefined && (!combined || !TIERS.includes(tier))) fail(`Choose --tier from ${TIERS.join(', ')}.`);
136
+ if (minutes !== undefined && (!combined || !Number.isSafeInteger(minutes) || minutes < 1 || minutes > 120)) fail('Choose --minutes as whole minutes, from the tier minimum up to 120.');
137
+ return { kind: 'recorded_graphical', buildId, personas: [...list], controllers: [...controllers],
71
138
  driver: profile.driver, runLength: 'standard', profileVersion, includeVideo, includeTranscript,
72
- ...(standardProvider === undefined ? {} : { standardProvider }) };
139
+ ...(standardProvider === undefined ? {} : { standardProvider }),
140
+ ...(combined && tier !== undefined ? { tier } : {}), ...(combined && minutes !== undefined ? { minutes } : {}),
141
+ ...(combined && focus !== undefined ? { focus } : {}) };
73
142
  }
74
143
 
75
- async function available(api, gameId, profileVersion, standardProvider) {
144
+ async function available(api, gameId, profileVersion, standardProvider, controllers = COMBINED) {
76
145
  const answer = await api.request('GET', `${base(gameId)}/run-capabilities`, { idempotent: true });
77
146
  const caps = answer.body, recorded = caps?.recorded;
78
147
  if (!recorded?.available || recorded.intakeEnabled !== true || !Array.isArray(recorded.profiles)
79
- || !Array.isArray(recorded.controllers) || !['standard', 'jev'].every(value => recorded.controllers.includes(value))) {
80
- fail('This server does not currently advertise ready hosted Geri and Freki runs. Nothing was charged.');
148
+ || !Array.isArray(recorded.controllers) || !controllers.every(value => recorded.controllers.includes(value))) {
149
+ fail(isCombined(controllers) ? 'This server does not currently sell cloud playtests where Geri and Freki play together. Nothing was charged.'
150
+ : 'This server does not currently advertise ready hosted Geri and Freki runs. Nothing was charged.');
81
151
  }
82
152
  // The same rule as "build upload": the one named, or the only one
83
153
  // advertised; with several and none named, the error lists them.
@@ -98,9 +168,11 @@ function sum(rows, value) {
98
168
  }
99
169
 
100
170
  export function hostedConsent(quote, request, now = Date.now()) {
171
+ const combined = isCombined(request.controllers);
101
172
  if (!quote || quote.kind !== 'recorded_graphical' || !/^hq_[a-f0-9-]{36}$/.test(quote.quoteId || '') || !hex(quote.planHash)
102
173
  || quote.buildId !== request.buildId || quote.profileVersion !== request.profileVersion || quote.driver !== request.driver
103
- || !same(quote.controllers, ['standard', 'jev']) || quote.includeVideo !== request.includeVideo || quote.includeTranscript !== request.includeTranscript
174
+ || !same(quote.controllers, request.controllers) || (combined && !same(quote.personas, request.personas))
175
+ || quote.includeVideo !== request.includeVideo || quote.includeTranscript !== request.includeTranscript
104
176
  || quote.currency !== 'USD' || !Number.isSafeInteger(quote.expiresAt) || quote.expiresAt <= now
105
177
  || !['localPriceCents', 'computePriceCents', 'totalPriceCents', 'dueNowCents', 'alreadyReservedCents'].every(key => cents(quote[key]))
106
178
  || quote.totalPriceCents < 1 || BigInt(quote.localPriceCents) + BigInt(quote.computePriceCents) !== BigInt(quote.totalPriceCents)
@@ -109,21 +181,41 @@ export function hostedConsent(quote, request, now = Date.now()) {
109
181
  || !['refund', 'retain'].includes(quote.cancelAfterStart)) fail('The server quote changed or expired. Nothing was charged; request a fresh quote.');
110
182
  if (!Array.isArray(quote.localBreakdown) || !quote.localBreakdown.length || !quote.localBreakdown.every(row => id(row.unit) && cents(row.unitCents) && Number.isSafeInteger(row.count) && row.count > 0)
111
183
  || sum(quote.localBreakdown, row => BigInt(row.count) * BigInt(row.unitCents)) !== quote.localPriceCents
112
- || !Array.isArray(quote.computeBreakdown) || quote.computeBreakdown.length !== 2
113
- || !quote.computeBreakdown.every((row, index) => row.controller === request.controllers[index] && row.profileVersion === request.profileVersion && cents(row.priceCents))
114
- || sum(quote.computeBreakdown, row => BigInt(row.priceCents)) !== quote.computePriceCents) fail('The server did not quote every Geri and Freki price. Nothing was charged.');
184
+ || !Array.isArray(quote.computeBreakdown) || quote.computeBreakdown.length !== (combined ? request.personas.length : 2)
185
+ || !quote.computeBreakdown.every((row, index) => (combined ? row.controller === 'combined' && row.persona === request.personas[index] : row.controller === request.controllers[index])
186
+ && row.profileVersion === request.profileVersion && cents(row.priceCents))
187
+ || sum(quote.computeBreakdown, row => BigInt(row.priceCents)) !== quote.computePriceCents) fail(combined ? 'The server did not quote a price for every persona. Nothing was charged.' : 'The server did not quote every Geri and Freki price. Nothing was charged.');
188
+ if (combined && (quote.localBreakdown.length !== 1 || quote.localBreakdown[0].count !== request.personas.length
189
+ || !Array.isArray(quote.personaPrices) || quote.personaPrices.length !== request.personas.length
190
+ || !quote.personaPrices.every((row, i) => row.persona === request.personas[i] && cents(row.priceCents))
191
+ || sum(quote.personaPrices, row => BigInt(row.priceCents)) !== quote.totalPriceCents
192
+ || !TIERS.includes(quote.tier) || (request.tier !== undefined && quote.tier !== request.tier)
193
+ || !Number.isSafeInteger(quote.minutes) || (request.minutes !== undefined && quote.minutes !== request.minutes)
194
+ || !cents(quote.setupFeeCents) || !cents(quote.underScopeFeeCents) || !quote.focus || typeof quote.focus !== 'object')) fail('The server did not quote a price for every persona. Nothing was charged.');
195
+ // A quote that starts from a save names the save this request uploaded, and no other.
196
+ if (combined && (request.focus?.save ? quote.focus.save?.saveId !== request.focus.save.saveId : quote.focus.save !== undefined)) fail('The quote does not start from the save file this command uploaded. Nothing was charged; request a fresh quote.');
115
197
  const explicit = request.standardProvider !== undefined;
116
198
  if (explicit ? quote.standardProvider !== request.standardProvider || !hex(quote.standardProviderPolicyHash)
117
199
  : Object.hasOwn(quote, 'standardProvider') || Object.hasOwn(quote, 'standardProviderPolicyHash')) {
118
200
  fail('The quoted Geri provider policy does not match the requested choice. Nothing was charged.');
119
201
  }
120
- return Object.fromEntries([...CONSENT_KEYS, ...(explicit ? ['standardProvider', 'standardProviderPolicyHash'] : [])].map(key => [key, quote[key]]));
202
+ return Object.fromEntries([...CONSENT_KEYS, ...(combined ? ['personas', 'tier', 'minutes', 'focus', 'setupFeeCents', 'underScopeFeeCents'] : []), ...(explicit ? ['standardProvider', 'standardProviderPolicyHash'] : [])].map(key => [key, quote[key]]));
203
+ }
204
+
205
+ /**
206
+ * What each persona costs in a combined quote: its play unit plus its own
207
+ * machine's compute, the two charges the server makes per persona.
208
+ * @returns {Array<{persona: string, priceCents: number}>}
209
+ */
210
+ export function personaPrices(quote, request) {
211
+ if (!isCombined(request.controllers)) return [];
212
+ return quote.personaPrices.map(row => ({ persona: row.persona, priceCents: row.priceCents }));
121
213
  }
122
214
 
123
215
  export function validateHostedOffer(offer, apiUrl, now = Date.now()) {
124
216
  if (offer?.schema !== 'ravensight-hosted-recorded-quote/v1' || !offer.request || !offer.quote || !id(offer.gameId) || offer.apiUrl !== origin(apiUrl)
125
217
  || offer.integrity !== digest({ apiUrl: offer.apiUrl, gameId: offer.gameId, request: offer.request, quote: offer.quote, consent: offer.consent })) fail('The saved quote does not match this API or its original contents. Nothing was charged.');
126
- const request = requestFor({ ...offer.request, persona: offer.request.personas?.[0] }, { driver: offer.request.driver });
218
+ const request = requestFor({ ...offer.request }, { driver: offer.request.driver });
127
219
  if (!same(request, offer.request) || !same(hostedConsent(offer.quote, request, now), offer.consent)) fail('The saved quote request or consent changed. Nothing was charged.');
128
220
  return offer;
129
221
  }
@@ -133,7 +225,7 @@ export async function quoteHostedRun({ api, apiUrl, gameId, output, now = Date.n
133
225
  try { await access(output); fail('That saved quote already exists. Choose a new output path; the original was preserved.'); }
134
226
  catch (error) { if (error.code !== 'ENOENT') throw error; }
135
227
  const { profile } = await available(api, gameId, options.profileVersion, options.standardProvider);
136
- const request = requestFor({ ...options, profileVersion: profile.profileVersion }, profile);
228
+ const request = requestFor({ ...options, controllers: COMBINED, profileVersion: profile.profileVersion }, profile);
137
229
  const response = await api.request('POST', `${base(gameId)}/quotes`, { body: request, idempotent: false });
138
230
  if (response.status !== 200) fail('The server did not return a hosted quote. No admission was requested.');
139
231
  const quote = response.body, consent = hostedConsent(quote, request, now());
@@ -145,6 +237,24 @@ export async function quoteHostedRun({ api, apiUrl, gameId, output, now = Date.n
145
237
 
146
238
  export function hostedQuoteLines(offer) {
147
239
  const { quote: q, request: r } = offer;
240
+ if (isCombined(r.controllers)) {
241
+ const focus = q.focus || {};
242
+ return [`Game ${offer.gameId}; build ${r.buildId}; profile ${r.profileVersion}.`,
243
+ '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.',
244
+ `Tier ${q.tier}, ${q.minutes} minutes of play per persona.`,
245
+ ...(focus.start ? [`Start: ${printable(focus.start)}`] : []),
246
+ ...(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'}.`] : []),
247
+ ...(focus.focus?.length ? [`Focus: ${focus.focus.map(printable).join('; ')}`] : []),
248
+ ...(focus.avoid?.length ? [`Avoid: ${focus.avoid.map(printable).join('; ')}`] : []),
249
+ ...(r.standardProvider ? [`Geri's model provider: ${providerLabel(r.standardProvider)}; policy ${q.standardProviderPolicyHash}.`] : []),
250
+ ...personaPrices(q, r).map(row => `${row.persona}${row.persona === ALWAYS_INCLUDED_PERSONA ? ' (always included)' : ''}: ${money(row.priceCents)}.`),
251
+ ...(q.setupFeeCents ? [`Includes a non-refundable setup fee: ${money(q.setupFeeCents)} (${money(q.setupFeeCents / r.personas.length)} a persona). It is kept even when a persona is refunded, unless it never got a machine.`] : []),
252
+ `Total ${money(q.totalPriceCents)} for ${r.personas.length} persona${r.personas.length === 1 ? '' : 's'}; already reserved ${money(q.alreadyReservedCents)}; due now ${money(q.dueNowCents)} from prepaid funds. No top-up is performed.`,
253
+ `Video: ${r.includeVideo ? 'included' : 'off'}. Cloud playtests save no transcript.`,
254
+ `If a persona fails or is canceled, the per run refund policy applies to that persona: customer failure ${q.customerFailure}, cancellation after start ${q.cancelAfterStart}. Price ${q.priceVersion}; refund policy ${q.policyVersion}.`,
255
+ `If the build is too large for this tier, that persona stops early and keeps the machine time and model spend it used plus a ${money(q.underScopeFeeCents)} fee; the rest of its price is refunded and the report names the tier to choose.`,
256
+ `Quote expires ${new Date(q.expiresAt).toISOString()}.`];
257
+ }
148
258
  return [`Game ${offer.gameId}; build ${r.buildId}; persona ${r.personas[0]}; profile ${r.profileVersion}.`,
149
259
  `Two separate playthroughs: Geri (${r.standardProvider ? providerLabel(r.standardProvider) : 'server default model provider'}) then Freki.`,
150
260
  ...(r.standardProvider ? [`Geri provider policy: ${q.standardProviderPolicyHash}.`] : []),
@@ -190,7 +300,7 @@ export async function runHostedQuote({ filename, api, apiUrl, repoRoot, confirm,
190
300
  }
191
301
  if (prior) fail(`This quote's earlier admission has no known outcome yet (${journal}). Ask the server what happened with: ravensight-playtest hosted status. No request was repeated.`);
192
302
  await assertNoUnknownAdmission({ repoRoot, apiUrl, gameId: offer.gameId, evenIfUnknown });
193
- const { profile, funding } = await available(api, offer.gameId, offer.request.profileVersion, offer.request.standardProvider);
303
+ const { profile, funding } = await available(api, offer.gameId, offer.request.profileVersion, offer.request.standardProvider, offer.request.controllers);
194
304
  if (profile.driver !== offer.request.driver || funding?.eligible === false || offer.quote.funding?.eligible === false) fail('The server no longer advertises this profile or sufficient prepaid funding. Nothing was charged.');
195
305
  await onPrepared(offer);
196
306
  if (typeof confirm !== 'function') fail('The full hosted quote must be confirmed before admission.');
@@ -198,7 +308,9 @@ export async function runHostedQuote({ filename, api, apiUrl, repoRoot, confirm,
198
308
  return admit({ offer, api, apiUrl, repoRoot, now });
199
309
  }
200
310
 
201
- export const confirmQuestion = offer => `Pay ${money(offer.quote.dueNowCents)} now (${money(offer.quote.totalPriceCents)} total) for the quoted Geri then Freki runs and the evidence options shown?`;
311
+ export const confirmQuestion = offer => isCombined(offer.request.controllers)
312
+ ? `Pay ${money(offer.quote.dueNowCents)} now (${money(offer.quote.totalPriceCents)} total) for ${offer.request.personas.length} persona${offer.request.personas.length === 1 ? '' : 's'}, one playtester each, and the evidence options shown?`
313
+ : `Pay ${money(offer.quote.dueNowCents)} now (${money(offer.quote.totalPriceCents)} total) for the quoted Geri then Freki runs and the evidence options shown?`;
202
314
 
203
315
  // Refusals the server makes with its own code that prove nothing was admitted
204
316
  // under this key. Each one is thrown only before the server records an
@@ -249,7 +361,7 @@ export function hostedRefusalMessage(error) {
249
361
  if (code === 'hosted_daily_capacity') return 'Today\'s hosted run allowance is used up. No run was started and nothing was charged. Try again after the daily limit resets at 00:00 UTC.';
250
362
  if (code === 'recorded_setup_required') return `${error.message || 'Complete the playtest brief and choose an available persona.'} Nothing was charged.`;
251
363
  if (code === 'quote_expired') return 'The quote expired before the run was admitted. No run was started and nothing was charged; request a new quote.';
252
- if (code === 'hosted_build_too_large') return 'This build is too large to play on a hosted machine: hosted playtests play builds up to 300 MiB unpacked. Make the build smaller and upload it again. Nothing was charged.';
364
+ if (code === 'hosted_build_too_large') return 'This build is too large to play on a hosted machine: cloud playtests play builds up to 4 GB unpacked, on the Large tier. Make the build smaller and upload it again. Nothing was charged.';
253
365
  if (code === 'hosted_build_safety_hold') return 'This build was stopped for safety during a hosted playtest and cannot run again until an admin reviews and clears it in the dashboard. Nothing was charged.';
254
366
  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.';
255
367
  return 'Hosted playtests are not available right now. Nothing was charged.';
@@ -466,7 +578,7 @@ export async function assertNoUnknownAdmission({ repoRoot, apiUrl, gameId, evenI
466
578
 
467
579
  // The terms a person accepted. A fresh quote taken while waiting for capacity
468
580
  // must match them exactly, or nothing is admitted without asking again.
469
- const TERMS = ['buildId', 'profileVersion', 'driver', 'controllers', 'includeVideo', 'includeTranscript', 'currency',
581
+ const TERMS = ['buildId', 'profileVersion', 'driver', 'controllers', 'personas', 'tier', 'minutes', 'focus', 'setupFeeCents', 'underScopeFeeCents', 'personaPrices', 'includeVideo', 'includeTranscript', 'currency',
470
582
  'localPriceCents', 'computePriceCents', 'totalPriceCents', 'dueNowCents', 'alreadyReservedCents', 'localBreakdown',
471
583
  'computeBreakdown', 'priceVersion', 'policyVersion', 'customerFailure', 'cancelAfterStart', 'standardProvider',
472
584
  'standardProviderPolicyHash'];
@@ -474,7 +586,7 @@ const sameTerms = (a, b) => TERMS.every(key => same(a[key] ?? null, b[key] ?? nu
474
586
 
475
587
  /** A fresh quote for exactly the request of an accepted offer. Charges nothing. */
476
588
  export async function requoteOffer({ api, apiUrl, offer, now = Date.now }) {
477
- const { profile, funding } = await available(api, offer.gameId, offer.request.profileVersion, offer.request.standardProvider);
589
+ const { profile, funding } = await available(api, offer.gameId, offer.request.profileVersion, offer.request.standardProvider, offer.request.controllers);
478
590
  if (profile.driver !== offer.request.driver) fail('The server no longer advertises this build profile. No run was started and nothing was charged.');
479
591
  const response = await api.request('POST', `${base(offer.gameId)}/quotes`, { body: offer.request, idempotent: false });
480
592
  if (response.status !== 200) fail('The server did not return a hosted quote. No run was started and nothing was charged.');
@@ -545,11 +657,12 @@ export function eligibleHostedBuilds(builds, profiles, now = Date.now()) {
545
657
  }
546
658
 
547
659
  /**
548
- * Quote a recorded Standard then Jev run without a saved quote file: pick the
549
- * build (the newest eligible one unless named), ask for a quote, check it, and
550
- * hand back the same offer shape `hosted quote` saves. Charges nothing.
660
+ * Quote a cloud playtest without a saved quote file: pick the build (the
661
+ * newest eligible one unless named), ask for a quote for fresh-eyes plus the
662
+ * named personas, check it, and hand back the same offer shape `hosted quote`
663
+ * saves. Charges nothing.
551
664
  */
552
- export async function prepareHostedRun({ api, apiUrl, gameId, buildId, persona, includeVideo = false, includeTranscript = false, standardProvider, now = Date.now }) {
665
+ export async function prepareHostedRun({ api, apiUrl, gameId, buildId, personas = [], tier, minutes, focus, includeVideo = false, includeTranscript = false, standardProvider, now = Date.now }) {
553
666
  if (!id(gameId)) fail('Choose a game. Nothing was charged.');
554
667
  const answer = await api.request('GET', `${base(gameId)}/run-capabilities`, { idempotent: true });
555
668
  const recorded = answer.body?.recorded;
@@ -569,7 +682,7 @@ export async function prepareHostedRun({ api, apiUrl, gameId, buildId, persona,
569
682
  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.');
570
683
  }
571
684
  const { profile, funding } = await available(api, gameId, build.profileVersion, standardProvider);
572
- const request = requestFor({ buildId: build.buildId, profileVersion: build.profileVersion, persona, standardProvider, includeVideo, includeTranscript }, profile);
685
+ const request = requestFor({ buildId: build.buildId, profileVersion: build.profileVersion, personas, controllers: COMBINED, standardProvider, includeVideo, includeTranscript, tier, minutes, focus }, profile);
573
686
  const response = await api.request('POST', `${base(gameId)}/quotes`, { body: request, idempotent: false });
574
687
  if (response.status !== 200) fail('The server did not return a hosted quote. Nothing was charged.');
575
688
  const quote = response.body, consent = hostedConsent(quote, request, now());
@@ -589,7 +702,9 @@ export function fundingShortfall(quote, funding) {
589
702
  export function hostedConsentLines(offer) {
590
703
  const q = offer.quote;
591
704
  return [
592
- 'One persona plays the same build twice, once with Geri and once with Freki, on isolated hosted machines. These are AI playtests, not human feedback.',
705
+ isCombined(offer.request.controllers)
706
+ ? 'Each persona is one AI playtester, Geri and Freki together, on its own isolated cloud machine. These are AI playtests, not human feedback. The whole total is reserved now; a persona that never starts is refunded.'
707
+ : 'One persona plays the same build twice, once with Geri and once with Freki, on isolated hosted machines. These are AI playtests, not human feedback.',
593
708
  'The game runs without network access. Shared capacity, daily limits and the quoted runtime bounds still apply; funding does not guarantee an immediate start.',
594
709
  `If the build fails, hosted compute is ${q.customerFailure === 'refund' ? 'refunded' : 'kept'}. Canceling after a confirmed start ${q.cancelAfterStart === 'refund' ? 'refunds' : 'keeps'} that run's compute charge. Unstarted work is refunded during settlement.`,
595
710
  'The build\'s validation hold is separate and is returned after safe cleanup. It does not reduce this price.',