ravensight-playtest 0.8.2 → 0.9.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 +74 -46
- package/package.json +1 -1
- package/src/cli.js +29 -17
- package/src/commands/fakeCore.js +1 -0
- package/src/commands/hosted.js +68 -21
- package/src/commands/run.js +9 -3
- package/src/hosted/archivePreflight.js +9 -1
- package/src/hosted/recordedRun.js +201 -63
- package/src/hosted/status.js +27 -15
- package/src/run/args.js +2 -0
- package/src/run/resume.js +2 -1
- package/src/run/serveBuild.js +79 -20
- package/src/runDefaults.js +23 -2
|
@@ -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,47 @@ export async function readHostedQuote(filename) {
|
|
|
62
71
|
} finally { await handle.close(); }
|
|
63
72
|
}
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
+
function requestFor({ buildId, profileVersion, personas, controllers = COMBINED, standardProvider, includeVideo = false, includeTranscript = false, tier, minutes, focus }, profile) {
|
|
90
|
+
const combined = isCombined(controllers);
|
|
91
|
+
if (!combined && !same(controllers, COMPARISON)) fail('Choose a cloud playtest the server sells.');
|
|
92
|
+
const list = combined ? hostedPersonas(personas) : personas;
|
|
93
|
+
if (!id(buildId) || !id(profileVersion) || !Array.isArray(list) || !list.length || !list.every(slug)
|
|
94
|
+
|| new Set(list).size !== list.length) fail('Choose a validated build, a ready profile and persona slugs such as fresh-eyes.');
|
|
95
|
+
if (combined && (list[0] !== ALWAYS_INCLUDED_PERSONA || list.length > MAX_HOSTED_PERSONAS)) fail(`Choose at most ${MAX_HOSTED_PERSONAS} personas, ${ALWAYS_INCLUDED_PERSONA} included.`);
|
|
96
|
+
if (!combined && list.length !== 1) fail('A saved comparison names one persona.');
|
|
68
97
|
if (standardProvider !== undefined && !PROVIDERS.includes(standardProvider)) fail('Choose primary or alternate for the Geri model provider.');
|
|
69
98
|
if (typeof includeVideo !== 'boolean' || typeof includeTranscript !== 'boolean') fail('Choose explicit video and transcript options.');
|
|
70
|
-
|
|
99
|
+
if (tier !== undefined && (!combined || !TIERS.includes(tier))) fail(`Choose --tier from ${TIERS.join(', ')}.`);
|
|
100
|
+
if (minutes !== undefined && (!combined || !Number.isSafeInteger(minutes) || minutes < 1 || minutes > 120)) fail('Choose --minutes as whole minutes, from the tier minimum up to 120.');
|
|
101
|
+
return { kind: 'recorded_graphical', buildId, personas: [...list], controllers: [...controllers],
|
|
71
102
|
driver: profile.driver, runLength: 'standard', profileVersion, includeVideo, includeTranscript,
|
|
72
|
-
...(standardProvider === undefined ? {} : { standardProvider })
|
|
103
|
+
...(standardProvider === undefined ? {} : { standardProvider }),
|
|
104
|
+
...(combined && tier !== undefined ? { tier } : {}), ...(combined && minutes !== undefined ? { minutes } : {}),
|
|
105
|
+
...(combined && focus !== undefined ? { focus } : {}) };
|
|
73
106
|
}
|
|
74
107
|
|
|
75
|
-
async function available(api, gameId, profileVersion, standardProvider) {
|
|
108
|
+
async function available(api, gameId, profileVersion, standardProvider, controllers = COMBINED) {
|
|
76
109
|
const answer = await api.request('GET', `${base(gameId)}/run-capabilities`, { idempotent: true });
|
|
77
110
|
const caps = answer.body, recorded = caps?.recorded;
|
|
78
111
|
if (!recorded?.available || recorded.intakeEnabled !== true || !Array.isArray(recorded.profiles)
|
|
79
|
-
|| !Array.isArray(recorded.controllers) || !
|
|
80
|
-
fail('This server does not currently
|
|
112
|
+
|| !Array.isArray(recorded.controllers) || !controllers.every(value => recorded.controllers.includes(value))) {
|
|
113
|
+
fail(isCombined(controllers) ? 'This server does not currently sell cloud playtests where Geri and Freki play together. Nothing was charged.'
|
|
114
|
+
: 'This server does not currently advertise ready hosted Geri and Freki runs. Nothing was charged.');
|
|
81
115
|
}
|
|
82
116
|
// The same rule as "build upload": the one named, or the only one
|
|
83
117
|
// advertised; with several and none named, the error lists them.
|
|
@@ -98,9 +132,11 @@ function sum(rows, value) {
|
|
|
98
132
|
}
|
|
99
133
|
|
|
100
134
|
export function hostedConsent(quote, request, now = Date.now()) {
|
|
135
|
+
const combined = isCombined(request.controllers);
|
|
101
136
|
if (!quote || quote.kind !== 'recorded_graphical' || !/^hq_[a-f0-9-]{36}$/.test(quote.quoteId || '') || !hex(quote.planHash)
|
|
102
137
|
|| quote.buildId !== request.buildId || quote.profileVersion !== request.profileVersion || quote.driver !== request.driver
|
|
103
|
-
|| !same(quote.controllers,
|
|
138
|
+
|| !same(quote.controllers, request.controllers) || (combined && !same(quote.personas, request.personas))
|
|
139
|
+
|| quote.includeVideo !== request.includeVideo || quote.includeTranscript !== request.includeTranscript
|
|
104
140
|
|| quote.currency !== 'USD' || !Number.isSafeInteger(quote.expiresAt) || quote.expiresAt <= now
|
|
105
141
|
|| !['localPriceCents', 'computePriceCents', 'totalPriceCents', 'dueNowCents', 'alreadyReservedCents'].every(key => cents(quote[key]))
|
|
106
142
|
|| quote.totalPriceCents < 1 || BigInt(quote.localPriceCents) + BigInt(quote.computePriceCents) !== BigInt(quote.totalPriceCents)
|
|
@@ -109,21 +145,39 @@ export function hostedConsent(quote, request, now = Date.now()) {
|
|
|
109
145
|
|| !['refund', 'retain'].includes(quote.cancelAfterStart)) fail('The server quote changed or expired. Nothing was charged; request a fresh quote.');
|
|
110
146
|
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
147
|
|| 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.
|
|
114
|
-
|
|
148
|
+
|| !Array.isArray(quote.computeBreakdown) || quote.computeBreakdown.length !== (combined ? request.personas.length : 2)
|
|
149
|
+
|| !quote.computeBreakdown.every((row, index) => (combined ? row.controller === 'combined' && row.persona === request.personas[index] : row.controller === request.controllers[index])
|
|
150
|
+
&& row.profileVersion === request.profileVersion && cents(row.priceCents))
|
|
151
|
+
|| 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.');
|
|
152
|
+
if (combined && (quote.localBreakdown.length !== 1 || quote.localBreakdown[0].count !== request.personas.length
|
|
153
|
+
|| !Array.isArray(quote.personaPrices) || quote.personaPrices.length !== request.personas.length
|
|
154
|
+
|| !quote.personaPrices.every((row, i) => row.persona === request.personas[i] && cents(row.priceCents))
|
|
155
|
+
|| sum(quote.personaPrices, row => BigInt(row.priceCents)) !== quote.totalPriceCents
|
|
156
|
+
|| !TIERS.includes(quote.tier) || (request.tier !== undefined && quote.tier !== request.tier)
|
|
157
|
+
|| !Number.isSafeInteger(quote.minutes) || (request.minutes !== undefined && quote.minutes !== request.minutes)
|
|
158
|
+
|| !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.');
|
|
115
159
|
const explicit = request.standardProvider !== undefined;
|
|
116
160
|
if (explicit ? quote.standardProvider !== request.standardProvider || !hex(quote.standardProviderPolicyHash)
|
|
117
161
|
: Object.hasOwn(quote, 'standardProvider') || Object.hasOwn(quote, 'standardProviderPolicyHash')) {
|
|
118
162
|
fail('The quoted Geri provider policy does not match the requested choice. Nothing was charged.');
|
|
119
163
|
}
|
|
120
|
-
return Object.fromEntries([...CONSENT_KEYS, ...(explicit ? ['standardProvider', 'standardProviderPolicyHash'] : [])].map(key => [key, quote[key]]));
|
|
164
|
+
return Object.fromEntries([...CONSENT_KEYS, ...(combined ? ['personas', 'tier', 'minutes', 'focus', 'setupFeeCents', 'underScopeFeeCents'] : []), ...(explicit ? ['standardProvider', 'standardProviderPolicyHash'] : [])].map(key => [key, quote[key]]));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* What each persona costs in a combined quote: its play unit plus its own
|
|
169
|
+
* machine's compute, the two charges the server makes per persona.
|
|
170
|
+
* @returns {Array<{persona: string, priceCents: number}>}
|
|
171
|
+
*/
|
|
172
|
+
export function personaPrices(quote, request) {
|
|
173
|
+
if (!isCombined(request.controllers)) return [];
|
|
174
|
+
return quote.personaPrices.map(row => ({ persona: row.persona, priceCents: row.priceCents }));
|
|
121
175
|
}
|
|
122
176
|
|
|
123
177
|
export function validateHostedOffer(offer, apiUrl, now = Date.now()) {
|
|
124
178
|
if (offer?.schema !== 'ravensight-hosted-recorded-quote/v1' || !offer.request || !offer.quote || !id(offer.gameId) || offer.apiUrl !== origin(apiUrl)
|
|
125
179
|
|| 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
|
|
180
|
+
const request = requestFor({ ...offer.request }, { driver: offer.request.driver });
|
|
127
181
|
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
182
|
return offer;
|
|
129
183
|
}
|
|
@@ -133,7 +187,7 @@ export async function quoteHostedRun({ api, apiUrl, gameId, output, now = Date.n
|
|
|
133
187
|
try { await access(output); fail('That saved quote already exists. Choose a new output path; the original was preserved.'); }
|
|
134
188
|
catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
135
189
|
const { profile } = await available(api, gameId, options.profileVersion, options.standardProvider);
|
|
136
|
-
const request = requestFor({ ...options, profileVersion: profile.profileVersion }, profile);
|
|
190
|
+
const request = requestFor({ ...options, controllers: COMBINED, profileVersion: profile.profileVersion }, profile);
|
|
137
191
|
const response = await api.request('POST', `${base(gameId)}/quotes`, { body: request, idempotent: false });
|
|
138
192
|
if (response.status !== 200) fail('The server did not return a hosted quote. No admission was requested.');
|
|
139
193
|
const quote = response.body, consent = hostedConsent(quote, request, now());
|
|
@@ -145,6 +199,23 @@ export async function quoteHostedRun({ api, apiUrl, gameId, output, now = Date.n
|
|
|
145
199
|
|
|
146
200
|
export function hostedQuoteLines(offer) {
|
|
147
201
|
const { quote: q, request: r } = offer;
|
|
202
|
+
if (isCombined(r.controllers)) {
|
|
203
|
+
const focus = q.focus || {};
|
|
204
|
+
return [`Game ${offer.gameId}; build ${r.buildId}; profile ${r.profileVersion}.`,
|
|
205
|
+
'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.',
|
|
206
|
+
`Tier ${q.tier}, ${q.minutes} minutes of play per persona.`,
|
|
207
|
+
...(focus.start ? [`Start: ${printable(focus.start)}`] : []),
|
|
208
|
+
...(focus.focus?.length ? [`Focus: ${focus.focus.map(printable).join('; ')}`] : []),
|
|
209
|
+
...(focus.avoid?.length ? [`Avoid: ${focus.avoid.map(printable).join('; ')}`] : []),
|
|
210
|
+
...(r.standardProvider ? [`Geri's model provider: ${providerLabel(r.standardProvider)}; policy ${q.standardProviderPolicyHash}.`] : []),
|
|
211
|
+
...personaPrices(q, r).map(row => `${row.persona}${row.persona === ALWAYS_INCLUDED_PERSONA ? ' (always included)' : ''}: ${money(row.priceCents)}.`),
|
|
212
|
+
...(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.`] : []),
|
|
213
|
+
`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.`,
|
|
214
|
+
`Video: ${r.includeVideo ? 'included' : 'off'}. Cloud playtests save no transcript.`,
|
|
215
|
+
`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}.`,
|
|
216
|
+
`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.`,
|
|
217
|
+
`Quote expires ${new Date(q.expiresAt).toISOString()}.`];
|
|
218
|
+
}
|
|
148
219
|
return [`Game ${offer.gameId}; build ${r.buildId}; persona ${r.personas[0]}; profile ${r.profileVersion}.`,
|
|
149
220
|
`Two separate playthroughs: Geri (${r.standardProvider ? providerLabel(r.standardProvider) : 'server default model provider'}) then Freki.`,
|
|
150
221
|
...(r.standardProvider ? [`Geri provider policy: ${q.standardProviderPolicyHash}.`] : []),
|
|
@@ -182,14 +253,15 @@ async function clearIntent(journal) {
|
|
|
182
253
|
|
|
183
254
|
// A saved durable intent whose outcome is unknown is never retried here; only
|
|
184
255
|
// "hosted status" asks the server about it. The server receives a stable key.
|
|
185
|
-
export async function runHostedQuote({ filename, api, apiUrl, repoRoot, confirm, onPrepared = () => {}, now = Date.now, admit = admitHostedOffer }) {
|
|
256
|
+
export async function runHostedQuote({ filename, api, apiUrl, repoRoot, confirm, onPrepared = () => {}, now = Date.now, admit = admitHostedOffer, evenIfUnknown = false }) {
|
|
186
257
|
const offer = validateHostedOffer(await readHostedQuote(filename), apiUrl, now());
|
|
187
258
|
const journal = offerJournal(repoRoot, offer), prior = await readJournal(journal);
|
|
188
259
|
if (prior?.phase === 'charged_blocked' && admissionPattern.test(prior.admission?.admissionId || '')) {
|
|
189
260
|
fail(`This quote already started hosted run ${prior.admission.admissionId}. Check it with: ravensight-playtest hosted status ${prior.admission.admissionId}`);
|
|
190
261
|
}
|
|
191
262
|
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
|
-
|
|
263
|
+
await assertNoUnknownAdmission({ repoRoot, apiUrl, gameId: offer.gameId, evenIfUnknown });
|
|
264
|
+
const { profile, funding } = await available(api, offer.gameId, offer.request.profileVersion, offer.request.standardProvider, offer.request.controllers);
|
|
193
265
|
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.');
|
|
194
266
|
await onPrepared(offer);
|
|
195
267
|
if (typeof confirm !== 'function') fail('The full hosted quote must be confirmed before admission.');
|
|
@@ -197,25 +269,47 @@ export async function runHostedQuote({ filename, api, apiUrl, repoRoot, confirm,
|
|
|
197
269
|
return admit({ offer, api, apiUrl, repoRoot, now });
|
|
198
270
|
}
|
|
199
271
|
|
|
200
|
-
export const confirmQuestion = offer =>
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
|
|
272
|
+
export const confirmQuestion = offer => isCombined(offer.request.controllers)
|
|
273
|
+
? `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?`
|
|
274
|
+
: `Pay ${money(offer.quote.dueNowCents)} now (${money(offer.quote.totalPriceCents)} total) for the quoted Geri then Freki runs and the evidence options shown?`;
|
|
275
|
+
|
|
276
|
+
// Refusals the server makes with its own code that prove nothing was admitted
|
|
277
|
+
// under this key. Each one is thrown only before the server records an
|
|
278
|
+
// admission intent for the key, or from inside the admission transaction it
|
|
279
|
+
// then aborted (game_tracker hostedPlaytest/customer.js create,
|
|
280
|
+
// recordedCustomer.js create, recordedAdmission.js admit). A key the server
|
|
281
|
+
// already holds an intent for is answered by reconcile instead, and reconcile
|
|
282
|
+
// can throw none of these. So the answer is certain on the first POST and on a
|
|
283
|
+
// replay alike: the local intent is cleared. A 5xx or a status the server did
|
|
284
|
+
// not explain is not certain.
|
|
285
|
+
const CERTAIN_REFUSALS = new Set(['hosted_funding_required', 'recorded_setup_required', 'hosted_global_capacity',
|
|
286
|
+
'too_many_active_hosted_runs', 'hosted_daily_capacity', 'hosted_build_too_large', 'hosted_build_safety_hold',
|
|
287
|
+
'quote_expired', 'hosted_game_unavailable', 'hosted_studio_unavailable',
|
|
288
|
+
// The two explained 5xx: thrown before the intent exists, or inside a transaction that aborted.
|
|
289
|
+
'recorded_unavailable', 'hosted_execution_budget_unconfigured']);
|
|
212
290
|
export const CAPACITY_CODES = Object.freeze(['hosted_global_capacity', 'too_many_active_hosted_runs']);
|
|
213
291
|
// The server keeps an attempt it refused under the plan's key and answers a
|
|
214
|
-
// repeat with
|
|
292
|
+
// repeat with { state: 'failed', dispatchAllowed: false }, so that quote cannot
|
|
293
|
+
// start a run. Nothing was charged.
|
|
215
294
|
export const REFUSED_EARLIER = 'hosted_quote_refused_earlier';
|
|
216
295
|
|
|
217
296
|
export const certainRefusal = error => error instanceof ApiError
|
|
218
|
-
&& (error.status === 401 || error.status >= 400 && error.status <
|
|
297
|
+
&& (error.status === 401 || error.status >= 400 && error.status < 600 && CERTAIN_REFUSALS.has(error.code));
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Why an explained 4xx says nothing certain. These answers (a 404 from the game
|
|
301
|
+
* route or from the admission's own access check, a 403 for the role, a 409
|
|
302
|
+
* from the stored consent or plan check) also come back for a key the server
|
|
303
|
+
* already holds, possibly admitted and charged: a game deleted or retired,
|
|
304
|
+
* membership removed, or another account signed in. Null when not a 4xx.
|
|
305
|
+
*/
|
|
306
|
+
export function unclearRefusalReason(error) {
|
|
307
|
+
if (!(error instanceof ApiError) || error.status < 400 || error.status >= 500) return null;
|
|
308
|
+
if (error.status === 404 || error.code === 'not_found') return 'the server would not answer for this game or account (the game may have been deleted or retired, your membership removed, or another account is signed in)';
|
|
309
|
+
if (error.status === 403) return 'the signed-in account is not allowed to run hosted playtests for this game';
|
|
310
|
+
if (['quote_not_accepted', 'recorded_quote_changed', 'recorded_admission_conflict'].includes(error.code)) return 'the server\'s record for this quote does not match this request';
|
|
311
|
+
return `the server answered ${error.status}${error.code ? ` (${error.code})` : ''}`;
|
|
312
|
+
}
|
|
219
313
|
|
|
220
314
|
export function hostedRefusalMessage(error) {
|
|
221
315
|
const code = error?.code;
|
|
@@ -224,12 +318,10 @@ export function hostedRefusalMessage(error) {
|
|
|
224
318
|
const topUp = Number.isSafeInteger(f?.requiredTopUpCents) && f.requiredTopUpCents > 0 ? ` Add at least ${money(f.requiredTopUpCents)} of prepaid funds, then request a new quote.` : ' Add prepaid funds, then request a new quote.';
|
|
225
319
|
return `The server refused the run for funding. No run was started and nothing was charged.${topUp}`;
|
|
226
320
|
}
|
|
227
|
-
if (code === 'quote_not_accepted') return 'The server did not accept this consent for the quote. Nothing was charged; request a new quote.';
|
|
228
321
|
if (CAPACITY_CODES.includes(code)) return 'Hosted capacity is busy, so no run was started and nothing was charged. Run the same command again with --wait-for-capacity to wait for room and start then; it never charges twice. Adding funds does not increase capacity.';
|
|
229
322
|
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.';
|
|
230
323
|
if (code === 'recorded_setup_required') return `${error.message || 'Complete the playtest brief and choose an available persona.'} Nothing was charged.`;
|
|
231
|
-
if (code === '
|
|
232
|
-
if (code === 'quote_expired' || code === 'recorded_quote_changed') return 'The quote expired before the run was admitted. No run was started and nothing was charged; request a new quote.';
|
|
324
|
+
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.';
|
|
233
325
|
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.';
|
|
234
326
|
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.';
|
|
235
327
|
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.';
|
|
@@ -323,10 +415,10 @@ export async function admitHostedOffer({ offer, api, apiUrl, repoRoot, now = Dat
|
|
|
323
415
|
if (error.status === 401) throw error;
|
|
324
416
|
throw refusalError(error.code, error);
|
|
325
417
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
fail(`The admission's outcome is not known: ${unknownAdvice(journal)}`);
|
|
418
|
+
// Any other explained answer may follow an ambiguous commit the server
|
|
419
|
+
// then reconciled, so it is kept for "hosted status" like a lost reply.
|
|
420
|
+
const reason = unclearRefusalReason(error);
|
|
421
|
+
fail(`The admission's outcome is not known${reason ? `, because ${reason}` : ''}: ${unknownAdvice(journal)}`);
|
|
330
422
|
}
|
|
331
423
|
const read = answer ? readAdmissionAnswer(answer, offer.quote.totalPriceCents) : { kind: 'unknown' };
|
|
332
424
|
if (read.kind === 'refused_earlier') { await clearIntent(journal); throw refusalError(REFUSED_EARLIER); }
|
|
@@ -337,12 +429,20 @@ export async function admitHostedOffer({ offer, api, apiUrl, repoRoot, now = Dat
|
|
|
337
429
|
|
|
338
430
|
const unknownAdvice = journal => `the run may or may not have started. Preserve ${journal}; nothing was retried. Ask the server what happened with: ravensight-playtest hosted status`;
|
|
339
431
|
|
|
432
|
+
const createdTime = state => (Number.isFinite(Date.parse(state?.createdAt)) ? new Date(Date.parse(state.createdAt)).toISOString() : null);
|
|
433
|
+
const attemptName = state => `quote ${state.quoteId || 'unnamed'}${createdTime(state) ? `, attempt saved ${createdTime(state)}` : ''}`;
|
|
434
|
+
const newestFirst = (a, b) => (Date.parse(b.createdAt) || 0) - (Date.parse(a.createdAt) || 0);
|
|
435
|
+
|
|
340
436
|
/**
|
|
341
437
|
* Settle every saved admission intent whose outcome is unknown by asking the
|
|
342
438
|
* server, which answers from its own record under the same idempotency key.
|
|
343
439
|
* The question is only sent once the quote has expired, so it can report an
|
|
344
|
-
* admission but never start one.
|
|
345
|
-
* clears the intent
|
|
440
|
+
* admission but never start one. Only a certain answer that nothing was
|
|
441
|
+
* admitted clears the intent: { state: 'failed', dispatchAllowed: false }, or
|
|
442
|
+
* a refusal code the server throws only when it holds no intent for the key.
|
|
443
|
+
* A 404, 403 or 409 can come back for a key that was admitted, so it is kept.
|
|
444
|
+
* An admission is recorded; anything else is kept. Admitted rows come first,
|
|
445
|
+
* then the rest, each newest first.
|
|
346
446
|
*/
|
|
347
447
|
export async function resolveHostedIntents({ api, apiUrl, repoRoot, now = Date.now }) {
|
|
348
448
|
const dir = journalDir(repoRoot), here = origin(apiUrl), results = [];
|
|
@@ -358,53 +458,88 @@ export async function resolveHostedIntents({ api, apiUrl, repoRoot, now = Date.n
|
|
|
358
458
|
results.push({ journal, state: 'unreadable', message: `${journal} is not a hosted admission record this version can read. Nothing was sent.` });
|
|
359
459
|
continue;
|
|
360
460
|
}
|
|
461
|
+
const row = { journal, gameId: state.gameId, quoteId: state.quoteId || null, createdAt: createdTime(state) };
|
|
462
|
+
const game = `Game ${state.gameId}, ${attemptName(state)}`;
|
|
361
463
|
if (state.apiUrl !== here) {
|
|
362
|
-
results.push({
|
|
464
|
+
results.push({ ...row, state: 'other_api', message: `${journal} belongs to ${state.apiUrl}. Run this with --api-url ${state.apiUrl} to resolve it.` });
|
|
363
465
|
continue;
|
|
364
466
|
}
|
|
365
467
|
const created = Date.parse(state.createdAt);
|
|
366
468
|
const expiresAt = Number.isSafeInteger(state.quoteExpiresAt) ? state.quoteExpiresAt : (Number.isFinite(created) ? created + QUOTE_LIFETIME_MS : null);
|
|
367
469
|
const askAt = expiresAt === null ? null : expiresAt + SERVER_CLOCK_MARGIN_MS;
|
|
368
470
|
if (askAt === null || now() < askAt) {
|
|
369
|
-
results.push({
|
|
471
|
+
results.push({ ...row, state: 'wait', askAt,
|
|
370
472
|
message: askAt === null ? `${journal} has no readable time. Nothing was sent.`
|
|
371
|
-
:
|
|
473
|
+
: `${game}: asking before ${new Date(askAt).toISOString()} could still start the run, so nothing was sent. Run "hosted status" again after that time.` });
|
|
372
474
|
continue;
|
|
373
475
|
}
|
|
374
476
|
let answer;
|
|
375
477
|
try { answer = await postAdmission(api, state, `${journal}.reconcile-${now()}-${randomUUID().slice(0, 8)}.json`); }
|
|
376
478
|
catch (error) {
|
|
377
|
-
if (
|
|
479
|
+
if (error instanceof ApiError && error.status === 401) throw error;
|
|
480
|
+
if (certainRefusal(error)) {
|
|
378
481
|
await clearIntent(journal);
|
|
379
|
-
results.push({
|
|
380
|
-
message:
|
|
482
|
+
results.push({ ...row, state: 'not_admitted', code: error.code,
|
|
483
|
+
message: `${game}: the server refused that earlier attempt before admitting it (${error.code}). That attempt started no run and charged nothing; it says nothing about any other run. The record is cleared.` });
|
|
381
484
|
continue;
|
|
382
485
|
}
|
|
383
|
-
|
|
384
|
-
results.push({
|
|
486
|
+
const reason = unclearRefusalReason(error);
|
|
487
|
+
results.push({ ...row, state: 'unknown', ...(error instanceof ApiError ? { code: error.code || null, status: error.status } : {}),
|
|
488
|
+
message: reason
|
|
489
|
+
? `${game}: the outcome is still unknown, because ${reason}. It may have been admitted and charged. The record is kept and nothing was retried. Check the account you are signed in with and the game, then run "hosted status" again; if it persists, write to support@realityse.com with ${path.basename(journal)}.`
|
|
490
|
+
: `${game}: the server did not answer clearly (${error.code || error.message}). The record is kept; try again later.` });
|
|
385
491
|
continue;
|
|
386
492
|
}
|
|
387
493
|
const read = answer ? readAdmissionAnswer(answer, state.consent.totalPriceCents) : { kind: 'unknown' };
|
|
388
494
|
if (read.kind === 'refused_earlier') {
|
|
389
495
|
await clearIntent(journal);
|
|
390
|
-
results.push({
|
|
391
|
-
message:
|
|
496
|
+
results.push({ ...row, state: 'not_admitted', code: REFUSED_EARLIER,
|
|
497
|
+
message: `${game}: the server refused that earlier attempt. That attempt started no run and charged nothing; it says nothing about any other run. The record is cleared.` });
|
|
392
498
|
} else if (read.kind === 'admitted') {
|
|
393
499
|
await recordAdmitted(journal, state, read.ack);
|
|
394
|
-
results.push({
|
|
500
|
+
results.push({ ...row, state: 'admitted', admissionId: read.ack.admissionId, jobId: read.ack.jobId,
|
|
395
501
|
totalPriceCents: read.ack.totalPriceCents, runState: read.ack.state,
|
|
396
|
-
message:
|
|
502
|
+
message: `${game}: the run was admitted as ${read.ack.admissionId} (job ${read.ack.jobId}) and charged ${money(read.ack.totalPriceCents)}.` });
|
|
397
503
|
} else {
|
|
398
|
-
results.push({
|
|
399
|
-
message:
|
|
504
|
+
results.push({ ...row, state: 'unknown', ...(read.admissionId ? { admissionId: read.admissionId } : {}), ...(read.jobId ? { jobId: read.jobId } : {}),
|
|
505
|
+
message: `${game}: the server cannot state the outcome yet. The record is kept; nothing was retried.${namedRun(read)} If this persists, write to support@realityse.com with ${path.basename(journal)}.` });
|
|
400
506
|
}
|
|
401
507
|
}
|
|
402
|
-
|
|
508
|
+
const admitted = results.filter(r => r.state === 'admitted').sort(newestFirst);
|
|
509
|
+
return [...admitted, ...results.filter(r => r.state !== 'admitted').sort(newestFirst)];
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Saved admissions for this API and game whose outcome is still unknown. A new
|
|
514
|
+
* purchase is refused while any exists, because the earlier one may have been
|
|
515
|
+
* charged and only "hosted status" can say.
|
|
516
|
+
*/
|
|
517
|
+
export async function unknownAdmissions({ repoRoot, apiUrl, gameId }) {
|
|
518
|
+
const dir = journalDir(repoRoot), here = origin(apiUrl), rows = [];
|
|
519
|
+
let names = [];
|
|
520
|
+
try { names = (await readdir(dir)).filter(name => /^[a-f0-9]{64}\.json$/.test(name)).sort(); }
|
|
521
|
+
catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
522
|
+
for (const name of names) {
|
|
523
|
+
const state = await readJournal(path.join(dir, name));
|
|
524
|
+
if (state?.phase === 'admission_unknown' && state.apiUrl === here && state.gameId === gameId) {
|
|
525
|
+
rows.push({ journal: path.join(dir, name), quoteId: state.quoteId || null, createdAt: createdTime(state) });
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return rows.sort(newestFirst);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** Refuses a new hosted purchase while an earlier admission's outcome is unknown, unless overridden. */
|
|
532
|
+
export async function assertNoUnknownAdmission({ repoRoot, apiUrl, gameId, evenIfUnknown = false }) {
|
|
533
|
+
if (evenIfUnknown) return;
|
|
534
|
+
const rows = await unknownAdmissions({ repoRoot, apiUrl, gameId });
|
|
535
|
+
if (!rows.length) return;
|
|
536
|
+
const newest = rows[0], more = rows.length > 1 ? ` (and ${rows.length - 1} more)` : '';
|
|
537
|
+
throw new CliError(`An earlier hosted admission for game ${gameId} has no known outcome yet: ${attemptName(newest)}${more}. It may have been charged, so no new run was quoted or bought. Ask the server what happened first: ravensight-playtest hosted status. To buy another run anyway, pass --even-if-unknown. Nothing was charged.`, ExitCode.ENVIRONMENT);
|
|
403
538
|
}
|
|
404
539
|
|
|
405
540
|
// The terms a person accepted. A fresh quote taken while waiting for capacity
|
|
406
541
|
// must match them exactly, or nothing is admitted without asking again.
|
|
407
|
-
const TERMS = ['buildId', 'profileVersion', 'driver', 'controllers', 'includeVideo', 'includeTranscript', 'currency',
|
|
542
|
+
const TERMS = ['buildId', 'profileVersion', 'driver', 'controllers', 'personas', 'tier', 'minutes', 'focus', 'setupFeeCents', 'underScopeFeeCents', 'personaPrices', 'includeVideo', 'includeTranscript', 'currency',
|
|
408
543
|
'localPriceCents', 'computePriceCents', 'totalPriceCents', 'dueNowCents', 'alreadyReservedCents', 'localBreakdown',
|
|
409
544
|
'computeBreakdown', 'priceVersion', 'policyVersion', 'customerFailure', 'cancelAfterStart', 'standardProvider',
|
|
410
545
|
'standardProviderPolicyHash'];
|
|
@@ -412,7 +547,7 @@ const sameTerms = (a, b) => TERMS.every(key => same(a[key] ?? null, b[key] ?? nu
|
|
|
412
547
|
|
|
413
548
|
/** A fresh quote for exactly the request of an accepted offer. Charges nothing. */
|
|
414
549
|
export async function requoteOffer({ api, apiUrl, offer, now = Date.now }) {
|
|
415
|
-
const { profile, funding } = await available(api, offer.gameId, offer.request.profileVersion, offer.request.standardProvider);
|
|
550
|
+
const { profile, funding } = await available(api, offer.gameId, offer.request.profileVersion, offer.request.standardProvider, offer.request.controllers);
|
|
416
551
|
if (profile.driver !== offer.request.driver) fail('The server no longer advertises this build profile. No run was started and nothing was charged.');
|
|
417
552
|
const response = await api.request('POST', `${base(offer.gameId)}/quotes`, { body: offer.request, idempotent: false });
|
|
418
553
|
if (response.status !== 200) fail('The server did not return a hosted quote. No run was started and nothing was charged.');
|
|
@@ -483,11 +618,12 @@ export function eligibleHostedBuilds(builds, profiles, now = Date.now()) {
|
|
|
483
618
|
}
|
|
484
619
|
|
|
485
620
|
/**
|
|
486
|
-
* Quote a
|
|
487
|
-
*
|
|
488
|
-
* hand back the same offer shape `hosted quote`
|
|
621
|
+
* Quote a cloud playtest without a saved quote file: pick the build (the
|
|
622
|
+
* newest eligible one unless named), ask for a quote for fresh-eyes plus the
|
|
623
|
+
* named personas, check it, and hand back the same offer shape `hosted quote`
|
|
624
|
+
* saves. Charges nothing.
|
|
489
625
|
*/
|
|
490
|
-
export async function prepareHostedRun({ api, apiUrl, gameId, buildId,
|
|
626
|
+
export async function prepareHostedRun({ api, apiUrl, gameId, buildId, personas = [], tier, minutes, focus, includeVideo = false, includeTranscript = false, standardProvider, now = Date.now }) {
|
|
491
627
|
if (!id(gameId)) fail('Choose a game. Nothing was charged.');
|
|
492
628
|
const answer = await api.request('GET', `${base(gameId)}/run-capabilities`, { idempotent: true });
|
|
493
629
|
const recorded = answer.body?.recorded;
|
|
@@ -507,7 +643,7 @@ export async function prepareHostedRun({ api, apiUrl, gameId, buildId, persona,
|
|
|
507
643
|
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.');
|
|
508
644
|
}
|
|
509
645
|
const { profile, funding } = await available(api, gameId, build.profileVersion, standardProvider);
|
|
510
|
-
const request = requestFor({ buildId: build.buildId, profileVersion: build.profileVersion,
|
|
646
|
+
const request = requestFor({ buildId: build.buildId, profileVersion: build.profileVersion, personas, controllers: COMBINED, standardProvider, includeVideo, includeTranscript, tier, minutes, focus }, profile);
|
|
511
647
|
const response = await api.request('POST', `${base(gameId)}/quotes`, { body: request, idempotent: false });
|
|
512
648
|
if (response.status !== 200) fail('The server did not return a hosted quote. Nothing was charged.');
|
|
513
649
|
const quote = response.body, consent = hostedConsent(quote, request, now());
|
|
@@ -527,7 +663,9 @@ export function fundingShortfall(quote, funding) {
|
|
|
527
663
|
export function hostedConsentLines(offer) {
|
|
528
664
|
const q = offer.quote;
|
|
529
665
|
return [
|
|
530
|
-
|
|
666
|
+
isCombined(offer.request.controllers)
|
|
667
|
+
? '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.'
|
|
668
|
+
: '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.',
|
|
531
669
|
'The game runs without network access. Shared capacity, daily limits and the quoted runtime bounds still apply; funding does not guarantee an immediate start.',
|
|
532
670
|
`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.`,
|
|
533
671
|
'The build\'s validation hold is separate and is returned after safe cleanup. It does not reduce this price.',
|
package/src/hosted/status.js
CHANGED
|
@@ -40,7 +40,7 @@ export function hostedPlaytestStatus(admission, job = null, runs = [], now = Dat
|
|
|
40
40
|
} else if (job?.summary_report === 'ready' || admissionState === 'recorded_closed') {
|
|
41
41
|
phase = 'report-ready'; label = 'Report ready'; detail = 'The hosted run and report are complete.';
|
|
42
42
|
} else if (['aggregating', 'uploading'].includes(jobState) || ['reporting', 'uploading'].includes(aggregate?.state)) {
|
|
43
|
-
phase = 'analyzing'; label = 'Analyzing'; detail = 'Combining the completed playtests into
|
|
43
|
+
phase = 'analyzing'; label = 'Analyzing'; detail = 'Combining the completed playtests into one report.';
|
|
44
44
|
} else if (plays.some(row => ['reporting', 'uploading'].includes(row.state))) {
|
|
45
45
|
phase = 'capturing'; label = 'Capturing results'; detail = 'Saving the playtest report, evidence and requested media.';
|
|
46
46
|
} else if (plays.some(row => row.state === 'playing') || jobState === 'running') {
|
|
@@ -74,19 +74,27 @@ export function hostedPlaytestStatus(admission, job = null, runs = [], now = Dat
|
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* One row per
|
|
78
|
-
*
|
|
77
|
+
* One row per playtester, from the job's persona runs. A combined cloud
|
|
78
|
+
* playtest has one row per persona (each its own Geri and Freki run, named by
|
|
79
|
+
* the persona); an older comparison has one row per mode (Geri, Freki). A row
|
|
80
|
+
* whose run the server has not created yet reads as not started, and a row
|
|
81
|
+
* still waiting for a cloud machine carries its own queue place.
|
|
79
82
|
* @param {Array<object>} runs
|
|
80
83
|
* @param {Array<string>} [controllers]
|
|
84
|
+
* @param {{personas?: Array<string>, personaRuns?: Array<object>}} [admission]
|
|
81
85
|
*/
|
|
82
|
-
export function modeOutcomes(runs = [], controllers = ['standard', 'jev']) {
|
|
86
|
+
export function modeOutcomes(runs = [], controllers = ['standard', 'jev'], admission = {}) {
|
|
83
87
|
const plays = (Array.isArray(runs) ? runs : []).filter(row => row.module !== 'aggregate_report');
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
const combined = Array.isArray(controllers) && controllers.length === 1 && controllers[0] === 'combined';
|
|
89
|
+
const keys = combined ? (Array.isArray(admission?.personas) ? admission.personas : [...new Set(plays.map(row => row.persona))]) : controllers;
|
|
90
|
+
return keys.map(key => {
|
|
91
|
+
const run = (combined ? plays.find(row => row.persona === key) : plays.find(row => row.controller === key)) || null;
|
|
86
92
|
const report = run?.report || null;
|
|
93
|
+
const waiting = combined && Array.isArray(admission?.personaRuns) ? queueInfo(admission.personaRuns.find(row => row?.persona === key)) : null;
|
|
87
94
|
return {
|
|
88
|
-
mode:
|
|
89
|
-
name: DISPLAY_NAMES[
|
|
95
|
+
mode: combined ? 'combined' : key,
|
|
96
|
+
name: combined ? key : DISPLAY_NAMES[key] || 'Playtester',
|
|
97
|
+
...(combined ? { persona: key, queue: waiting } : {}),
|
|
90
98
|
runId: run?.run_id || null,
|
|
91
99
|
state: run?.state || 'not_started',
|
|
92
100
|
reason: run?.state_reason ? boundedReason(run.state_reason) : null,
|
|
@@ -98,8 +106,9 @@ export function modeOutcomes(runs = [], controllers = ['standard', 'jev']) {
|
|
|
98
106
|
});
|
|
99
107
|
}
|
|
100
108
|
|
|
101
|
-
/** "Geri: completed, 4 findings, video saved." */
|
|
102
|
-
export function modeLine(row) {
|
|
109
|
+
/** "Geri: completed, 4 findings, video saved." or "speedrunner: queued, position 2, ..." */
|
|
110
|
+
export function modeLine(row, now = Date.now()) {
|
|
111
|
+
if (row.queue && row.state === 'queued') return `${row.name}: ${queueLine(row.queue, now).replace(/^Queued/, 'queued')}`;
|
|
103
112
|
const parts = [row.state.replace(/_/g, ' ')];
|
|
104
113
|
if (row.findings !== null) parts.push(`${row.findings} finding${row.findings === 1 ? '' : 's'}`);
|
|
105
114
|
if (row.wouldContinue !== null) parts.push(row.wouldContinue ? 'would keep playing' : 'would stop playing');
|
|
@@ -108,11 +117,14 @@ export function modeLine(row) {
|
|
|
108
117
|
return `${row.name}: ${parts.join(', ')}.`;
|
|
109
118
|
}
|
|
110
119
|
|
|
111
|
-
// The server's FIFO queue for hosted runs (game_tracker
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
120
|
+
// The server's FIFO queue for hosted runs (game_tracker
|
|
121
|
+
// hostedPlaytest/directQueue.js forAdmission, added by recordedCustomer.js
|
|
122
|
+
// withQueue beside `queued: true` on the admission acknowledgement and on GET
|
|
123
|
+
// /hosted/runs/:admissionId). The CLI reads two of its fields here:
|
|
124
|
+
// `position` (1 is next in line, 0 is starting now) and `estimatedStartAt`
|
|
125
|
+
// (ISO, null while launches are paused). The rest is for the dashboard and is
|
|
126
|
+
// only type checked (recordedRun.js validQueue). An estimate already past
|
|
127
|
+
// also reads as starting now.
|
|
116
128
|
export function queueInfo(source) {
|
|
117
129
|
const q = source?.queue;
|
|
118
130
|
if (!q || typeof q !== 'object' || !Number.isSafeInteger(q.position) || q.position < 0) return null;
|
package/src/run/args.js
CHANGED
|
@@ -19,6 +19,8 @@ const VALUED = new Map([
|
|
|
19
19
|
['--compare-with', 'compareWith'],
|
|
20
20
|
['--build-url', 'buildUrl'],
|
|
21
21
|
['--build-dir', 'buildDir'],
|
|
22
|
+
// The page to open inside --build-dir when it has several .html files.
|
|
23
|
+
['--build-entry', 'buildEntry'],
|
|
22
24
|
['--godot-project', 'godotProject'],
|
|
23
25
|
// The Godot binary, as check and the driver docs take it. RAVENSIGHT_GODOT
|
|
24
26
|
// and GODOT still work when it is not given.
|
package/src/run/resume.js
CHANGED
|
@@ -120,7 +120,8 @@ export async function resumeJob({ api, gameId, jobId, job, runs, state, repoRoot
|
|
|
120
120
|
// process: serve the same folder again (or the one passed now) and play there.
|
|
121
121
|
let servedTarget = null;
|
|
122
122
|
if (driverName === 'playwright_web' && (options.buildDir || journal.buildDir)) {
|
|
123
|
-
|
|
123
|
+
const entry = options.buildEntry ?? (options.buildDir ? undefined : journal.buildEntry);
|
|
124
|
+
try { servedTarget = (await (injected.serveBuildDir || serveBuildDir)(options.buildDir || journal.buildDir, entry === undefined ? {} : { entry })).url; } catch (error) {
|
|
124
125
|
log(`${error.message} Pass --build-dir with the build folder, or --build-url.`);
|
|
125
126
|
return EXIT.ENVIRONMENT;
|
|
126
127
|
}
|