ravensight-playtest 0.7.5 → 0.8.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 +33 -25
- package/docs/ADAPTERS.md +1 -1
- package/package.json +1 -1
- package/src/cli.js +13 -8
- package/src/commands/hosted.js +3 -2
- package/src/commands/run.js +42 -10
- package/src/hosted/archivePreflight.js +47 -2
- package/src/hosted/buildStatus.js +2 -0
- package/src/hosted/buildUpload.js +15 -1
- package/src/hosted/recordedRun.js +21 -12
- package/src/hosted/status.js +5 -4
- package/src/run/comparison.js +7 -5
- package/src/run/controllers.js +14 -2
- package/src/run/drivers/web.js +45 -3
- package/src/run/personaLoop.js +89 -4
- package/src/run/resume.js +11 -1
- package/src/run/serveBuild.js +137 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# ravensight-playtest
|
|
2
2
|
|
|
3
3
|
Hosted playtests run your uploaded build on our machines instead of yours. One
|
|
4
|
-
persona plays it twice, once with
|
|
4
|
+
persona plays it twice, once with Geri and once with Freki, and the dashboard
|
|
5
5
|
gets a report for each and a comparison. They use a separate command from the
|
|
6
6
|
local `run`:
|
|
7
7
|
|
|
@@ -41,11 +41,12 @@ is refunded during settlement.
|
|
|
41
41
|
To review a quote before paying, save it and confirm it later:
|
|
42
42
|
|
|
43
43
|
```sh
|
|
44
|
-
ravensight-playtest hosted quote --game GAME --build BUILD --
|
|
44
|
+
ravensight-playtest hosted quote --game GAME --build BUILD --persona curious-kid --video --output hosted-quote.json
|
|
45
45
|
ravensight-playtest hosted run hosted-quote.json
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
`--profile` is needed only when the server advertises more than one build
|
|
49
|
+
profile; the error lists them. The quote names the full Geri then Freki price, prepaid amount, evidence
|
|
49
50
|
options, expiry and refund rules. It charges nothing. `hosted run` confirms
|
|
50
51
|
that saved quote before one admission request. Its durable journal blocks an
|
|
51
52
|
automatic second POST after an uncertain outcome; preserve it for reconciliation.
|
|
@@ -54,8 +55,10 @@ A charged-blocked acknowledgement does not prove gameplay or a report. This
|
|
|
54
55
|
command does not top up funds, change local run/report files or ask for model
|
|
55
56
|
proxy permission on the CLI credential.
|
|
56
57
|
|
|
57
|
-
On a server that advertises it as ready, `hosted quote --
|
|
58
|
-
selects
|
|
58
|
+
On a server that advertises it as ready, `hosted quote --geri-provider alternate`
|
|
59
|
+
selects Geri's alternate model provider, and `primary` selects the primary one.
|
|
60
|
+
The [subprocessors page](https://www.ravensight.io/legal/subprocessors/) names
|
|
61
|
+
both. The returned
|
|
59
62
|
provider and policy hash must match and remain in the saved consent; `hosted run`
|
|
60
63
|
has no provider override. Omitting the flag keeps the original default request
|
|
61
64
|
and consent wire. No choice falls back to another provider, and a CLI declaration
|
|
@@ -474,20 +477,20 @@ splitting the job in two is what gets everything played.
|
|
|
474
477
|
| `--max-actions <n>` | Lower the actions one persona may take. It can only lower the persona's own patience (and the server's per run ceiling), never raise it. |
|
|
475
478
|
| `--long` | A long persona run: twice the actions, model budget and wall time of a standard run, at twice the price. The price is read from the estimate and confirmed before any charge. |
|
|
476
479
|
| `--concurrency <n>` | Personas at once. Default the number `init` wrote, which is what `check` recommends for this machine. |
|
|
477
|
-
| `--controller <name>` | One playthrough
|
|
478
|
-
| `--compare-with
|
|
480
|
+
| `--controller <name>` | One playthrough with `geri` or `freki` (CLI 0.8.0 or later). The server must advertise and quote that exact choice. |
|
|
481
|
+
| `--compare-with freki` | Separate Geri and Freki playthroughs for each chosen persona. Shows their combined quote before purchase. Comparisons run one playthrough at a time. |
|
|
479
482
|
| `--record-video` | Capture the selected web or graphical Godot game locally. Does not upload the video. |
|
|
480
483
|
| `--upload-video` | Record and explicitly upload `session.webm` or `session.mp4` with the reports. |
|
|
481
484
|
| `--upload-transcript` | Upload `transcript.jsonl` as well as the reports. |
|
|
482
485
|
| `--dry-upload` | List every file and byte that would be sent, and send nothing. |
|
|
483
486
|
| `--key-modifier <meta\|control>` | The modifier the browser driver uses for editing shortcuts such as select all. Defaults to this machine's own (Command on macOS, Control elsewhere); set it when the browser's platform is not this machine's. `RAVENSIGHT_KEY_MODIFIER` does the same. |
|
|
487
|
+
| `--build-dir <dir>` | Serve an exported web build folder from this machine and play it: `index.html`, or the folder's one `.html` page (a Godot export named after the project). The local server sends `application/wasm`, Content-Encoding for Unity's Brotli and gzip files (`.br`, `.gz`), and cross-origin isolation, so threaded Godot, love.js and Emscripten builds get SharedArrayBuffer. `resume` serves the same folder again. Not with `--build-url`. |
|
|
484
488
|
| `--headed`, `--headless` | Show or hide the browser. |
|
|
485
489
|
| `--verbose` | Print each turn. |
|
|
486
490
|
|
|
487
|
-
|
|
491
|
+
Two flags are accepted and reported as not applied by this release, rather
|
|
488
492
|
than silently ignored: `--quality` (the model tier is the server's, enforced at
|
|
489
|
-
the proxy)
|
|
490
|
-
the build and pass `--build-url`). There is no spending flag: each run's model
|
|
493
|
+
the proxy) and `--offline-upload` (uploads already queue). There is no spending flag: each run's model
|
|
491
494
|
budget is set by the server from what the job was charged, and `--budget-usd` is
|
|
492
495
|
an unknown option (the refusal says where the budget comes from).
|
|
493
496
|
|
|
@@ -1072,30 +1075,35 @@ import { createClient, packs, uploadRunDir } from 'ravensight-playtest';
|
|
|
1072
1075
|
|
|
1073
1076
|
MIT. Copyright Reality Software Entertainment.
|
|
1074
1077
|
|
|
1075
|
-
##
|
|
1078
|
+
## Geri and Freki
|
|
1076
1079
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
+
Two AI playtesters can play a persona run, at the same price per run:
|
|
1081
|
+
|
|
1082
|
+
- **Geri**, the reasoning playtester, studies each screen and chooses every
|
|
1083
|
+
action itself. It is the default.
|
|
1084
|
+
- **Freki**, the selecting playtester, picks each action from a short list. A
|
|
1085
|
+
screenshot observer proposes up to three actions, Ravensight selects one on
|
|
1086
|
+
the server, and the local driver executes only that choice. Ambiguous
|
|
1087
|
+
controls stop the run for review.
|
|
1088
|
+
|
|
1089
|
+
The optional `--controller freki` mode uses the existing persona run.
|
|
1080
1090
|
Reports, screenshots and findings use the normal upload and review flow.
|
|
1081
1091
|
|
|
1082
1092
|
```sh
|
|
1083
|
-
ravensight-playtest run --driver playwright_web --controller
|
|
1093
|
+
ravensight-playtest run --driver playwright_web --controller freki --build-url https://your-game.example/ --max-actions 12 --headed
|
|
1084
1094
|
```
|
|
1085
1095
|
|
|
1086
1096
|
Sign in, initialize the project and save its expectations brief first. The server
|
|
1087
|
-
must advertise this
|
|
1097
|
+
must advertise this playtester in its content pack; otherwise the command stops
|
|
1088
1098
|
before registering a paid job. No provider key belongs in the CLI. Selection costs
|
|
1089
1099
|
share the existing persona-run budget and do not create another wallet charge.
|
|
1090
|
-
Resume preserves the
|
|
1100
|
+
Resume preserves the playtester recorded in the job journal.
|
|
1091
1101
|
|
|
1092
1102
|
### Recorded playthroughs and comparisons
|
|
1093
1103
|
|
|
1094
1104
|
The `0.5.0` candidate adds local recording and explicit comparisons. It requires a
|
|
1095
|
-
matching server release for
|
|
1096
|
-
purchase.
|
|
1097
|
-
provider access, pricing and acceptance are complete. These commands do not
|
|
1098
|
-
activate graphical AWS hosting.
|
|
1105
|
+
matching server release for playtester plans; an older server is refused before
|
|
1106
|
+
purchase. These commands do not activate graphical AWS hosting.
|
|
1099
1107
|
|
|
1100
1108
|
To keep one playthrough's video on your computer:
|
|
1101
1109
|
|
|
@@ -1103,13 +1111,13 @@ To keep one playthrough's video on your computer:
|
|
|
1103
1111
|
ravensight-playtest run --driver playwright_web --build-url https://your-game.example/ --record-video
|
|
1104
1112
|
```
|
|
1105
1113
|
|
|
1106
|
-
To request two reports, one from
|
|
1114
|
+
To request two reports, one from Geri and one from Freki:
|
|
1107
1115
|
|
|
1108
1116
|
```sh
|
|
1109
|
-
ravensight-playtest run --driver playwright_web --build-url https://your-game.example/ --personas curious-kid --compare-with
|
|
1117
|
+
ravensight-playtest run --driver playwright_web --build-url https://your-game.example/ --personas curious-kid --compare-with freki --record-video
|
|
1110
1118
|
```
|
|
1111
1119
|
|
|
1112
|
-
The server quotes every persona/
|
|
1120
|
+
The server quotes every persona/playtester run before the CLI asks for payment.
|
|
1113
1121
|
Each keeps its own existing model budget and settlement rules. Two standard runs
|
|
1114
1122
|
at the current $1 unit price total $2; the displayed server quote is authoritative.
|
|
1115
1123
|
No comparison model call or extra recording fee is added. Use `--upload-video`
|
|
@@ -1142,7 +1150,7 @@ Older recordings and later byte-only uploads can show status as unreported.
|
|
|
1142
1150
|
Malformed local status is omitted so it cannot prevent an existing report from
|
|
1143
1151
|
being completed.
|
|
1144
1152
|
|
|
1145
|
-
Each
|
|
1153
|
+
Each playtester starts a separate game session and produces its own report.
|
|
1146
1154
|
Saved progress and random events may still differ; this is not a guaranteed
|
|
1147
1155
|
identical-state benchmark. The aggregate compares evidence-bearing findings and
|
|
1148
1156
|
marks missing, failed or partial playthroughs as inconclusive. Agreement between
|
package/docs/ADAPTERS.md
CHANGED
|
@@ -20,7 +20,7 @@ ravensight-playtest run --driver playwright_web --build-url https://your-game.ex
|
|
|
20
20
|
ravensight-playtest run --driver godot_driver --godot-project ./your-game
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
`--controller
|
|
23
|
+
`--controller freki` plays with Freki, the selecting playtester, when the server supports it. Screen interpretation proposes up to three actions and a separate selector chooses one. `--controller geri` plays with Geri, which chooses every action itself. Uncertain decisions stop for review. Provider credentials stay on Ravensight. A completed playtest report is evidence for human review, not proof that a game is bug-free.
|
|
24
24
|
|
|
25
25
|
## Desktop and mobile
|
|
26
26
|
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -54,10 +54,13 @@ export const RUNNER_HELP = `
|
|
|
54
54
|
Run options (parsed by the runner, see src/run/args.js):
|
|
55
55
|
--personas <list> comma separated persona slugs, default one (curious-kid); "personas" lists them
|
|
56
56
|
--driver <name> playwright_web, godot_driver, desktop_driver, unity_driver, unreal_driver, android_driver, ios_driver or cli_stdio
|
|
57
|
-
--controller <name> one
|
|
58
|
-
|
|
57
|
+
--controller <name> one playtester: geri (studies each screen and chooses every action itself)
|
|
58
|
+
or freki (picks each action from a short list of choices), if enabled
|
|
59
|
+
--compare-with freki separate Geri and Freki playthroughs; quotes every run
|
|
59
60
|
--record-video record this game locally; --upload-video also uploads it
|
|
60
61
|
--build-url <url> the web build to play
|
|
62
|
+
--build-dir <dir> a web export folder to serve from this machine and play: index.html or its one
|
|
63
|
+
.html page, with wasm, Brotli and gzip engine files and threaded builds served right
|
|
61
64
|
--godot-project <dir> the Godot project directory
|
|
62
65
|
--driver-config <file> local WebDriver or JSON-RPC bridge configuration
|
|
63
66
|
--max-actions <n> lower the actions one persona may take; it can only lower the persona's own patience, never raise it
|
|
@@ -77,7 +80,7 @@ Run options (parsed by the runner, see src/run/args.js):
|
|
|
77
80
|
charged even if the build or the server turns out to be down
|
|
78
81
|
|
|
79
82
|
Accepted and reported as not applied by this release:
|
|
80
|
-
--quality, --offline-upload
|
|
83
|
+
--quality, --offline-upload
|
|
81
84
|
|
|
82
85
|
There is no spending flag: each run's model budget is set by the server from
|
|
83
86
|
what the job was charged.
|
|
@@ -153,24 +156,26 @@ function withoutFirst(values, value) {
|
|
|
153
156
|
export function buildProgram() {
|
|
154
157
|
const program = new Command();
|
|
155
158
|
const slot = { code: ExitCode.OK };
|
|
156
|
-
const hosted = common(program.command('hosted').description('run a server-hosted
|
|
159
|
+
const hosted = common(program.command('hosted').description('run a server-hosted Geri and Freki playtest: quote, run, status and cancel'));
|
|
157
160
|
hosted.command('quote')
|
|
158
161
|
.description('save a full hosted quote without charging or admitting a run')
|
|
159
162
|
.requiredOption('--build <id>', 'an existing validated hosted build')
|
|
160
|
-
.
|
|
163
|
+
.option('--profile <version>', 'hosted profile to quote; optional when the server advertises exactly one, otherwise the error lists the choices')
|
|
161
164
|
.requiredOption('--persona <slug>', 'one available persona for both separate playthroughs')
|
|
162
165
|
.requiredOption('--output <file>', 'save the original quote and immutable consent here')
|
|
163
166
|
.option('--game <id>', 'game id, overriding this repo’s configuration')
|
|
164
|
-
.addOption(new Option('--
|
|
167
|
+
.addOption(new Option('--geri-provider <name>', "Geri's model provider: primary or alternate (ravensight.io/legal/subprocessors names both); unavailable choices are refused").choices(['primary', 'alternate']).conflicts('standardProvider'))
|
|
168
|
+
.addOption(new Option('--standard-provider <name>').choices(['anthropic', 'openai']).hideHelp())
|
|
165
169
|
.option('--video', 'include hosted gameplay video in this quote')
|
|
166
170
|
.action(capture(slot, async (options, command) => {
|
|
167
171
|
const { hostedQuote } = await import('./commands/hosted.js');
|
|
168
172
|
return hostedQuote(flagsFrom(command.optsWithGlobals(), { build: options.build, profile: options.profile,
|
|
169
|
-
persona: options.persona, output: options.output, game: options.game,
|
|
173
|
+
persona: options.persona, output: options.output, game: options.game,
|
|
174
|
+
geriProvider: options.geriProvider, standardProvider: options.standardProvider,
|
|
170
175
|
video: options.video }));
|
|
171
176
|
}));
|
|
172
177
|
common(hosted.command('run [quote-file]'))
|
|
173
|
-
.description('quote the newest ready build (or --build), confirm the price, and start one hosted
|
|
178
|
+
.description('quote the newest ready build (or --build), confirm the price, and start one hosted Geri and Freki run; with a saved quote file, confirm that quote instead. Never retries an unknown outcome')
|
|
174
179
|
.option('--build <id>', 'a build that passed its static archive check (default: the newest one)')
|
|
175
180
|
.option('--persona <slug>', 'the persona that plays both runs (default: curious-kid)')
|
|
176
181
|
.option('--game <id>', 'game id, overriding this repo’s configuration')
|
package/src/commands/hosted.js
CHANGED
|
@@ -4,7 +4,7 @@ import { withAuthHandling } from '../auth/session.js';
|
|
|
4
4
|
import { CliError, ExitCode } from '../errors.js';
|
|
5
5
|
import { ui } from '../ui/index.js';
|
|
6
6
|
import { quoteHostedRun, runHostedQuote, hostedQuoteLines, prepareHostedRun, admitHostedOffer, confirmQuestion,
|
|
7
|
-
hostedConsentLines, fundingShortfall, readHostedRun, cancelHostedRun } from '../hosted/recordedRun.js';
|
|
7
|
+
hostedConsentLines, fundingShortfall, readHostedRun, cancelHostedRun, GERI_PROVIDERS } from '../hosted/recordedRun.js';
|
|
8
8
|
import { hostedPlaytestStatus, modeOutcomes, modeLine, TERMINAL_PHASES } from '../hosted/status.js';
|
|
9
9
|
import { jobLink } from '../dashboard.js';
|
|
10
10
|
import { DEFAULT_PERSONAS } from '../runDefaults.js';
|
|
@@ -14,7 +14,8 @@ export async function hostedQuote(flags = {}, deps = {}) {
|
|
|
14
14
|
return withAuthHandling(context, async () => {
|
|
15
15
|
const result = await quoteHostedRun({ api: context.api, apiUrl: context.api.apiUrl,
|
|
16
16
|
gameId: resolveGameId(flags, context.config), buildId: flags.build, profileVersion: flags.profile,
|
|
17
|
-
persona: flags.persona,
|
|
17
|
+
persona: flags.persona,
|
|
18
|
+
standardProvider: flags.geriProvider ? GERI_PROVIDERS[flags.geriProvider] : flags.standardProvider, includeVideo: Boolean(flags.video),
|
|
18
19
|
output: flags.output });
|
|
19
20
|
if (flags.json) ui.json(result);
|
|
20
21
|
else {
|
package/src/commands/run.js
CHANGED
|
@@ -7,7 +7,7 @@ import { reportPrOutcomes } from '../run/labsOutcome.js';
|
|
|
7
7
|
import { finishJob } from '../run/settle.js';
|
|
8
8
|
import { driverStartReason, failureReason } from '../run/failureReason.js';
|
|
9
9
|
import { optionsFrom, unknownOptionNotes } from '../run/args.js';
|
|
10
|
-
import { controllerPlan, quoteMatchesPlan, runsMatchPlan } from '../run/controllers.js';
|
|
10
|
+
import { controllerPlan, displayName, quoteMatchesPlan, runsMatchPlan, wireId } from '../run/controllers.js';
|
|
11
11
|
import { getDeps } from '../run/deps.js';
|
|
12
12
|
import { createDriver } from '../run/drivers/index.js';
|
|
13
13
|
import EXIT from '../run/exit.js';
|
|
@@ -32,6 +32,7 @@ import { bold } from '../ui/index.js';
|
|
|
32
32
|
import { reconcileDroppedFindings } from '../run/dropped.js';
|
|
33
33
|
import * as stateFile from '../run/state.js';
|
|
34
34
|
import { emitRunEvents } from '../run/synthetic.js';
|
|
35
|
+
import { serveBuildDir } from '../run/serveBuild.js';
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* `ravensight-playtest run`: register a job, play it, upload it, finish it.
|
|
@@ -114,13 +115,16 @@ async function run(flags, injected, deps, log) {
|
|
|
114
115
|
let controllers;
|
|
115
116
|
try { controllers = controllerPlan(options); } catch (error) { log(error.message); return EXIT.ENVIRONMENT; }
|
|
116
117
|
options.controllers = controllers;
|
|
118
|
+
if (options.controller) options.controller = wireId(options.controller);
|
|
117
119
|
const keyModifier = resolveKeyModifier(options.keyModifier);
|
|
118
120
|
if (keyModifier.error) { log(keyModifier.error); return EXIT.ENVIRONMENT; }
|
|
119
121
|
const driverName = options.driver || (context.config && context.config.driver) || 'playwright_web';
|
|
120
122
|
if (controllers?.length > 1 && !['playwright_web', 'godot_driver'].includes(driverName)) { log('Comparisons currently require a web or Godot build. Nothing was charged.'); return EXIT.ENVIRONMENT; }
|
|
123
|
+
const served = await serveBuildDirOption({ options, driverName, log, serve: injected.serveBuildDir });
|
|
124
|
+
if (served === false) return EXIT.ENVIRONMENT;
|
|
121
125
|
const target = resolveTarget(options, context.config, driverName, repoRoot);
|
|
122
126
|
if (!target) {
|
|
123
|
-
log('Point the run at a build: --build-url for a web build, --godot-project for Godot, or --driver-config for a native or text bridge.');
|
|
127
|
+
log('Point the run at a build: --build-url or --build-dir for a web build, --godot-project for Godot, or --driver-config for a native or text bridge.');
|
|
124
128
|
return EXIT.ENVIRONMENT;
|
|
125
129
|
}
|
|
126
130
|
|
|
@@ -173,7 +177,7 @@ async function run(flags, injected, deps, log) {
|
|
|
173
177
|
}
|
|
174
178
|
const modules = [...RUN_MODULES];
|
|
175
179
|
const pack = await deps.packs.get({ api, gameId, modules });
|
|
176
|
-
if (controllers && (!pack.routing?.controller_plans || controllers.some(controller => !pack.routing?.action_controllers?.includes(controller)))) { log('This server does not currently support the requested
|
|
180
|
+
if (controllers && (!pack.routing?.controller_plans || controllers.some(controller => !pack.routing?.action_controllers?.includes(controller)))) { log('This server does not currently support the requested playtesters. No job was registered or charged.'); return EXIT.ENVIRONMENT; }
|
|
177
181
|
const personaSlugs = resolvePersonas(options, context.config, pack);
|
|
178
182
|
const unknownSlugs = unknownPersonas(personaSlugs, pack.personas || []);
|
|
179
183
|
if (unknownSlugs.length > 0) {
|
|
@@ -226,9 +230,9 @@ async function run(flags, injected, deps, log) {
|
|
|
226
230
|
}
|
|
227
231
|
throw error;
|
|
228
232
|
}
|
|
229
|
-
if (!quoteMatchesPlan(estimate, controllers, personaSlugs)) { log('The server did not quote every requested
|
|
230
|
-
if (controllers) log(`
|
|
231
|
-
if (controllers?.length > 1) log('Each
|
|
233
|
+
if (!quoteMatchesPlan(estimate, controllers, personaSlugs)) { log('The server did not quote every requested playtester run. Nothing was registered or charged.'); return EXIT.ENVIRONMENT; }
|
|
234
|
+
if (controllers) log(`Playtesters: ${controllers.map(displayName).join(' + ')}. ${personas.length * controllers.length} independent playthrough(s); each run is included in the total quote.`);
|
|
235
|
+
if (controllers?.length > 1) log('Each playtester gets a fresh game process or browser session. Server-side game progress and randomness may differ; comparison is evidence, not proof of identical starting state.');
|
|
232
236
|
// A long run is its own unit on the server. An older server that ignores
|
|
233
237
|
// run_length prices a standard run, and confirming that would buy a run
|
|
234
238
|
// the CLI then plays as long.
|
|
@@ -309,6 +313,7 @@ async function run(flags, injected, deps, log) {
|
|
|
309
313
|
modules,
|
|
310
314
|
driver: driverName,
|
|
311
315
|
target,
|
|
316
|
+
...(served ? { buildDir: served.root } : {}),
|
|
312
317
|
priceCents: registered.price && registered.price.price_cents,
|
|
313
318
|
options: {
|
|
314
319
|
maxActions: options.maxActions ?? null,
|
|
@@ -329,7 +334,7 @@ async function run(flags, injected, deps, log) {
|
|
|
329
334
|
}
|
|
330
335
|
await stateFile.save(repoRoot, journal);
|
|
331
336
|
if (!runsMatchPlan(registered.runs || [], controllers, personaSlugs)) {
|
|
332
|
-
log(`The registered
|
|
337
|
+
log(`The registered playtester plan does not match the quote. Job ${jobId} is saved for reconciliation; no playthrough or model call was started.`);
|
|
333
338
|
return EXIT.FAILED;
|
|
334
339
|
}
|
|
335
340
|
log(`job ${jobId}${registered.replayed ? ' (replayed)' : ''}: ${formatCents(registered.price && registered.price.price_cents)} charged. ${directory}`);
|
|
@@ -469,12 +474,39 @@ export function unusedFlagWarnings(options) {
|
|
|
469
474
|
if (options.offlineUpload !== undefined) {
|
|
470
475
|
warnings.push('--offline-upload is not applied by this release: uploads already queue and can be drained later with "ravensight-playtest upload <job>".');
|
|
471
476
|
}
|
|
472
|
-
if (options.buildDir !== undefined) {
|
|
473
|
-
warnings.push('--build-dir is not applied by this release: serve the build and pass --build-url instead.');
|
|
474
|
-
}
|
|
475
477
|
return warnings;
|
|
476
478
|
}
|
|
477
479
|
|
|
480
|
+
/**
|
|
481
|
+
* `--build-dir`: serve an exported web build from this machine and point the
|
|
482
|
+
* run at it, with the headers engines' web exports need (see
|
|
483
|
+
* ../run/serveBuild.js). Answers the served build, null when the flag is not
|
|
484
|
+
* given, or false after saying why it cannot be used; nothing is registered
|
|
485
|
+
* or charged either way.
|
|
486
|
+
*
|
|
487
|
+
* @returns {Promise<{url: string, root: string, entry: string}|null|false>}
|
|
488
|
+
*/
|
|
489
|
+
export async function serveBuildDirOption({ options, driverName, log, serve = serveBuildDir }) {
|
|
490
|
+
if (options.buildDir === undefined) return null;
|
|
491
|
+
if (driverName !== 'playwright_web') {
|
|
492
|
+
log(`--build-dir serves a web build, and this run uses ${driverName}. Nothing was registered or charged.`);
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
if (options.buildUrl) {
|
|
496
|
+
log('Pass --build-dir or --build-url, not both. Nothing was registered or charged.');
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
try {
|
|
500
|
+
const served = await serve(options.buildDir);
|
|
501
|
+
options.buildUrl = served.url;
|
|
502
|
+
log(`Serving ${served.root} at ${served.url} (wasm, compressed engine files and cross-origin isolation for threaded builds).`);
|
|
503
|
+
return served;
|
|
504
|
+
} catch (error) {
|
|
505
|
+
log(`${error.message} Nothing was registered or charged.`);
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
478
510
|
/**
|
|
479
511
|
* Play every unfinished run of a registered job, aggregate, finish.
|
|
480
512
|
*
|
|
@@ -182,14 +182,58 @@ async function nativeHeader(archive, file, format, requirements) {
|
|
|
182
182
|
return { os, architecture, binaryFormat, runtimeCompatibilityProven: false };
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
// What a build that is not a web build is, by file names alone, and what to
|
|
186
|
+
// do instead. Asked only once a web upload has already failed (no entry page,
|
|
187
|
+
// or an entry file that is not a page), so it never refuses a web build.
|
|
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'
|
|
196
|
+
});
|
|
197
|
+
const any = (paths, pattern) => paths.some(name => pattern.test(name));
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The engine or platform a non-web build came from, or null.
|
|
201
|
+
* @param {string[]} names archive file names
|
|
202
|
+
* @returns {keyof NATIVE_ADVICE|null}
|
|
203
|
+
*/
|
|
204
|
+
export function nativeBuildKind(names) {
|
|
205
|
+
const paths = names.map(name => name.toLowerCase());
|
|
206
|
+
if (any(paths, /\.(?:apk|aab)$/)) return 'android';
|
|
207
|
+
if (any(paths, /\.ipa$|(?:^|\/)payload\/[^/]+\.app\//)) return 'ios';
|
|
208
|
+
if (any(paths, /\.uproject$|(?:^|\/)engine\/binaries\/|(?:^|\/)content\/paks\/[^/]+\.(?:pak|utoc|ucas)$/)) return 'unreal';
|
|
209
|
+
if (any(paths, /(?:^|\/)(?:unityplayer|gameassembly)\.(?:dll|so|dylib)$|(?:^|\/)[^/]+_data\/(?:globalgamemanagers|data\.unity3d|managed\/|il2cpp_data\/)|\.app\/contents\/resources\/data\/(?:globalgamemanagers|data\.unity3d)$/)) return 'unity';
|
|
210
|
+
if (any(paths, /\.love$/)) return 'love';
|
|
211
|
+
if (any(paths, /\.pck$/) && !any(paths, /\.wasm$/) && any(paths, /\.(?:exe|x86_64|x86_32|arm64|arm32)$|\.app\/contents\/macos\//)) return 'godot';
|
|
212
|
+
if (any(paths, /\.(?:exe|dll|so|dylib|x86_64|x86_32|appimage|msi)$|\.app\/contents\/macos\//)) return 'desktop';
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** The entry-file kind of a web upload that names a program or package. */
|
|
217
|
+
function nativeEntryKind(entrypoint) {
|
|
218
|
+
const name = String(entrypoint || '').toLowerCase();
|
|
219
|
+
if (/\.(?:apk|aab)$/.test(name)) return 'android';
|
|
220
|
+
if (/\.ipa$/.test(name)) return 'ios';
|
|
221
|
+
if (/\.uproject$/.test(name)) return 'unreal';
|
|
222
|
+
if (/(?:^|\/)project\.godot$|\.pck$/.test(name)) return 'godot';
|
|
223
|
+
if (/\.love$/.test(name)) return 'love';
|
|
224
|
+
if (/\.(?:exe|x86_64|x86_32|arm64|app|appimage|dll|so|dylib)$/.test(name)) return 'desktop';
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
|
|
185
228
|
export async function inspectBuildArchive(archive, { limits: supplied, format, entrypoint, requirements } = {}) {
|
|
186
229
|
const limits = buildLimits(supplied);
|
|
187
230
|
if (!['web', 'godot-project', 'linux-executable', 'windows-executable'].includes(format)) reject('the selected runtime format is unsupported');
|
|
231
|
+
if (format === 'web' && typeof entrypoint === 'string' && !/\.html?$/i.test(entrypoint) && nativeEntryKind(entrypoint)) reject(NATIVE_ADVICE[nativeEntryKind(entrypoint)]);
|
|
188
232
|
if (typeof entrypoint !== 'string' || entrypoint.length > 240 || !/^[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)*$/.test(entrypoint)) reject('the entrypoint does not match the current server path policy');
|
|
189
233
|
const wanted = safePath(entrypoint, limits.depth);
|
|
190
234
|
if (format === 'web' && !wanted.endsWith('.html') || format === 'godot-project' && wanted.split('/').at(-1) !== 'project.godot'
|
|
191
235
|
|| format === 'windows-executable' && !wanted.toLowerCase().endsWith('.exe')) reject('the entrypoint does not match the selected format');
|
|
192
|
-
const dir = await directory(archive, limits), paths = new Map(), explicit = new Set(), ranges = [];
|
|
236
|
+
const dir = await directory(archive, limits), paths = new Map(), explicit = new Set(), ranges = [], fileNames = [];
|
|
193
237
|
let cursor = dir.offset, expandedBytes = 0, files = 0, found = false, pathBytes = 0, nativeFile;
|
|
194
238
|
for (let index = 0; index < dir.count; index++) {
|
|
195
239
|
const h = await archive.read(cursor, 46);
|
|
@@ -221,10 +265,11 @@ export async function inspectBuildArchive(archive, { limits: supplied, format, e
|
|
|
221
265
|
const dataEnd = size.offset + 30 + nameBytes + local.readUInt16LE(28) + size.compressed;
|
|
222
266
|
if (!Number.isSafeInteger(dataEnd) || dataEnd > dir.offset) reject('file data overlaps the ZIP directory');
|
|
223
267
|
ranges.push([size.offset, dataEnd]);
|
|
224
|
-
if (!isDirectory) { files++; if (name === wanted) { if (!size.expanded) reject('the entrypoint is empty'); found = true;
|
|
268
|
+
if (!isDirectory) { files++; if (fileNames.length < 5000) fileNames.push(name); if (name === wanted) { if (!size.expanded) reject('the entrypoint is empty'); found = true;
|
|
225
269
|
nativeFile = { ...size, method, dataOffset: size.offset + 30 + nameBytes + local.readUInt16LE(28), dataEnd }; } }
|
|
226
270
|
cursor += 46 + nameBytes + extraBytes + commentBytes;
|
|
227
271
|
}
|
|
272
|
+
if (!found && format === 'web' && nativeBuildKind(fileNames)) reject(NATIVE_ADVICE[nativeBuildKind(fileNames)]);
|
|
228
273
|
if (cursor !== dir.offset + dir.size || !found) reject('the declared entrypoint is absent or the directory is inconsistent');
|
|
229
274
|
ranges.sort((a, b) => a[0] - b[0]);
|
|
230
275
|
for (let i = 1; i < ranges.length; i++) if (ranges[i][0] < ranges[i - 1][1]) reject('ZIP file data overlaps');
|
|
@@ -19,6 +19,8 @@ export function buildStatusLines(build) {
|
|
|
19
19
|
const state = build?.state === 'deleting' && build.rejection ? 'not accepted, being removed' : (LABELS[build?.state] || line(build?.state) || 'unknown');
|
|
20
20
|
const lines = [`${line(build?.buildId)}${build?.entrypoint ? ` (${line(build.entrypoint)})` : ''}: ${state}.`];
|
|
21
21
|
if (build?.rejection?.message) lines.push(` Why: ${line(build.rejection.message)}`);
|
|
22
|
+
// Waiting for the daily build check limit to reset: the server says when.
|
|
23
|
+
else if (build?.state === 'awaiting_validation' && build.waiting?.message) lines.push(` Waiting: ${line(build.waiting.message)}`);
|
|
22
24
|
else if (build?.state === 'awaiting_validation') lines.push(' Validation is required before a run. Check again in a minute.');
|
|
23
25
|
if (build?.holdReturn?.message) lines.push(` ${line(build.holdReturn.message)}`);
|
|
24
26
|
if (build?.safetyHold) lines.push(' A run of this build was stopped by the safety check, so it cannot be quoted until that hold is cleared.');
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
-
import { mkdir, open } from 'node:fs/promises';
|
|
2
|
+
import { mkdir, open, rm } from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { Readable } from 'node:stream';
|
|
5
5
|
import { CliError } from '../errors.js';
|
|
6
6
|
import { ApiError } from '../api/errors.js';
|
|
7
7
|
import { writeJson } from '../fsutil.js';
|
|
8
|
+
import { printable } from '../ui/index.js';
|
|
8
9
|
import { openBuildArchive, inspectBuildArchive, buildLimits, limitsFromProfile } from './archivePreflight.js';
|
|
9
10
|
|
|
10
11
|
const fail = message => { throw new CliError(message); };
|
|
@@ -42,6 +43,9 @@ export async function putArchive(archive, transfer, { fetchImpl = globalThis.fet
|
|
|
42
43
|
} finally { stream.destroy(); }
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
// Server text is one plain sentence; still print it as one bounded line.
|
|
47
|
+
const serverSentence = text => printable(String(text || '')).replace(/\s+/g, ' ').trim().slice(0, 300);
|
|
48
|
+
|
|
45
49
|
/**
|
|
46
50
|
* The profile to upload under: the one named, or the only one advertised. With
|
|
47
51
|
* several and none named, the error lists them so the person can pick one.
|
|
@@ -92,6 +96,9 @@ export async function uploadHostedBuild({ filename, gameId, profileVersion, entr
|
|
|
92
96
|
if (!offer || offer.amountCents !== 49 || offer.currency !== 'USD' || offer.purpose !== 'validation_hold'
|
|
93
97
|
|| offer.refund !== 'after_cleanup' || !/^[a-f0-9]{64}$/.test(offer.version || '')) fail('The server did not provide the supported validation-hold offer.');
|
|
94
98
|
if (caps.funding?.eligible === false) fail('The server reports insufficient prepaid funding. No reservation or top-up was requested.');
|
|
99
|
+
// Today's build checks are used up: the server would refuse the upload, so
|
|
100
|
+
// say why and when before any archive work or hold.
|
|
101
|
+
if (caps.validationLimit?.available === false) fail(`${serverSentence(caps.validationLimit.message) || 'Your studio has used today\'s build checks. The next one is available at 00:00 UTC.'} No reservation was requested.`);
|
|
95
102
|
const archive = await openBuildArchive(filename, { signal });
|
|
96
103
|
try {
|
|
97
104
|
onProgress({ phase: 'preflight' });
|
|
@@ -130,6 +137,13 @@ export async function uploadHostedBuild({ filename, gameId, profileVersion, entr
|
|
|
130
137
|
return { state: state.phase, buildId: state.buildId, journal, walletMutationRequested: true, validationHoldCents: offer.amountCents,
|
|
131
138
|
multipartSupported: false, uploadResumeSupported: false, gameplayStarted: false };
|
|
132
139
|
} catch (error) {
|
|
140
|
+
// A definite refusal before any hold (the server checks the daily build
|
|
141
|
+
// check limit inside the same transaction): nothing to reconcile, so
|
|
142
|
+
// the journal goes and the same upload can be tried after the reset.
|
|
143
|
+
if (error instanceof ApiError && error.code === 'hosted_validation_limit' && state.phase === 'reservation_unknown') {
|
|
144
|
+
await rm(journal, { force: true });
|
|
145
|
+
fail(serverSentence(error.message === error.code ? '' : error.message) || 'Your studio has used today\'s build checks. The next one is available at 00:00 UTC. Nothing was charged.');
|
|
146
|
+
}
|
|
133
147
|
if (error instanceof ApiError && [401, 403].includes(error.status)) {
|
|
134
148
|
error.message += ` Original upload journal: ${journal}; no replacement reservation was requested.`;
|
|
135
149
|
throw error;
|
|
@@ -5,11 +5,17 @@ import { CliError, ExitCode } from '../errors.js';
|
|
|
5
5
|
import { ApiError } from '../api/errors.js';
|
|
6
6
|
import { stableStringify } from '../fsutil.js';
|
|
7
7
|
import { printable } from '../ui/index.js';
|
|
8
|
+
import { chooseProfile } from './buildUpload.js';
|
|
9
|
+
import { displayName } from '../run/controllers.js';
|
|
8
10
|
|
|
9
11
|
const MAX_QUOTE_BYTES = 1024 * 1024;
|
|
10
12
|
const CONSENT_KEYS = ['quoteId', 'planHash', 'profileVersion', 'controllers', 'includeVideo', 'includeTranscript',
|
|
11
13
|
'totalPriceCents', 'dueNowCents', 'priceVersion', 'policyVersion'];
|
|
12
14
|
const PROVIDERS = ['anthropic', 'openai'];
|
|
15
|
+
// Customers choose Geri's model provider by role, never by vendor name. The
|
|
16
|
+
// server's wire values stay; ravensight.io/legal/subprocessors names both.
|
|
17
|
+
export const GERI_PROVIDERS = Object.freeze({ primary: 'anthropic', alternate: 'openai' });
|
|
18
|
+
const providerLabel = wire => ({ anthropic: 'primary model provider', openai: 'alternate model provider' }[wire] || 'model provider');
|
|
13
19
|
const base = game => `/api/v1/games/${encodeURIComponent(game)}/playtest/hosted`;
|
|
14
20
|
const digest = value => createHash('sha256').update(stableStringify(value)).digest('hex');
|
|
15
21
|
const fail = message => { throw new CliError(message); };
|
|
@@ -58,7 +64,7 @@ export async function readHostedQuote(filename) {
|
|
|
58
64
|
function requestFor({ buildId, profileVersion, persona, standardProvider, includeVideo = false, includeTranscript = false }, profile) {
|
|
59
65
|
if (!id(buildId) || !id(profileVersion) || typeof persona !== 'string' || persona.length > 48
|
|
60
66
|
|| !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(persona)) fail('Choose a validated build, ready profile and one persona.');
|
|
61
|
-
if (standardProvider !== undefined && !PROVIDERS.includes(standardProvider)) fail('Choose
|
|
67
|
+
if (standardProvider !== undefined && !PROVIDERS.includes(standardProvider)) fail('Choose primary or alternate for the Geri model provider.');
|
|
62
68
|
if (typeof includeVideo !== 'boolean' || typeof includeTranscript !== 'boolean') fail('Choose explicit video and transcript options.');
|
|
63
69
|
return { kind: 'recorded_graphical', buildId, personas: [persona], controllers: ['standard', 'jev'],
|
|
64
70
|
driver: profile.driver, runLength: 'standard', profileVersion, includeVideo, includeTranscript,
|
|
@@ -70,13 +76,16 @@ async function available(api, gameId, profileVersion, standardProvider) {
|
|
|
70
76
|
const caps = answer.body, recorded = caps?.recorded;
|
|
71
77
|
if (!recorded?.available || recorded.intakeEnabled !== true || !Array.isArray(recorded.profiles)
|
|
72
78
|
|| !Array.isArray(recorded.controllers) || !['standard', 'jev'].every(value => recorded.controllers.includes(value))) {
|
|
73
|
-
fail('This server does not currently advertise ready
|
|
79
|
+
fail('This server does not currently advertise ready hosted Geri and Freki runs. Nothing was charged.');
|
|
74
80
|
}
|
|
75
|
-
|
|
81
|
+
// The same rule as "build upload": the one named, or the only one
|
|
82
|
+
// advertised; with several and none named, the error lists them.
|
|
83
|
+
const chosen = chooseProfile(recorded.profiles, profileVersion);
|
|
84
|
+
const matches = recorded.profiles.filter(value => value.profileVersion === chosen);
|
|
76
85
|
if (matches.length !== 1 || !['playwright_web', 'godot_driver'].includes(matches[0].driver)) fail('Choose exactly one currently advertised ready hosted profile. Nothing was charged.');
|
|
77
86
|
if (standardProvider !== undefined && (!PROVIDERS.includes(standardProvider)
|
|
78
87
|
|| !Array.isArray(recorded.standardProviders) || !recorded.standardProviders.includes(standardProvider))) {
|
|
79
|
-
fail(`This server does not advertise
|
|
88
|
+
fail(`This server does not advertise Geri on the ${providerLabel(standardProvider)} as ready. No provider fallback or charge was requested.`);
|
|
80
89
|
}
|
|
81
90
|
return { profile: matches[0], funding: caps.funding };
|
|
82
91
|
}
|
|
@@ -101,11 +110,11 @@ export function hostedConsent(quote, request, now = Date.now()) {
|
|
|
101
110
|
|| sum(quote.localBreakdown, row => BigInt(row.count) * BigInt(row.unitCents)) !== quote.localPriceCents
|
|
102
111
|
|| !Array.isArray(quote.computeBreakdown) || quote.computeBreakdown.length !== 2
|
|
103
112
|
|| !quote.computeBreakdown.every((row, index) => row.controller === request.controllers[index] && row.profileVersion === request.profileVersion && cents(row.priceCents))
|
|
104
|
-
|| sum(quote.computeBreakdown, row => BigInt(row.priceCents)) !== quote.computePriceCents) fail('The server did not quote every
|
|
113
|
+
|| sum(quote.computeBreakdown, row => BigInt(row.priceCents)) !== quote.computePriceCents) fail('The server did not quote every Geri and Freki price. Nothing was charged.');
|
|
105
114
|
const explicit = request.standardProvider !== undefined;
|
|
106
115
|
if (explicit ? quote.standardProvider !== request.standardProvider || !hex(quote.standardProviderPolicyHash)
|
|
107
116
|
: Object.hasOwn(quote, 'standardProvider') || Object.hasOwn(quote, 'standardProviderPolicyHash')) {
|
|
108
|
-
fail('The quoted
|
|
117
|
+
fail('The quoted Geri provider policy does not match the requested choice. Nothing was charged.');
|
|
109
118
|
}
|
|
110
119
|
return Object.fromEntries([...CONSENT_KEYS, ...(explicit ? ['standardProvider', 'standardProviderPolicyHash'] : [])].map(key => [key, quote[key]]));
|
|
111
120
|
}
|
|
@@ -123,7 +132,7 @@ export async function quoteHostedRun({ api, apiUrl, gameId, output, now = Date.n
|
|
|
123
132
|
try { await access(output); fail('That saved quote already exists. Choose a new output path; the original was preserved.'); }
|
|
124
133
|
catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
125
134
|
const { profile } = await available(api, gameId, options.profileVersion, options.standardProvider);
|
|
126
|
-
const request = requestFor(options, profile);
|
|
135
|
+
const request = requestFor({ ...options, profileVersion: profile.profileVersion }, profile);
|
|
127
136
|
const response = await api.request('POST', `${base(gameId)}/quotes`, { body: request, idempotent: false });
|
|
128
137
|
if (response.status !== 200) fail('The server did not return a hosted quote. No admission was requested.');
|
|
129
138
|
const quote = response.body, consent = hostedConsent(quote, request, now());
|
|
@@ -136,10 +145,10 @@ export async function quoteHostedRun({ api, apiUrl, gameId, output, now = Date.n
|
|
|
136
145
|
export function hostedQuoteLines(offer) {
|
|
137
146
|
const { quote: q, request: r } = offer;
|
|
138
147
|
return [`Game ${offer.gameId}; build ${r.buildId}; persona ${r.personas[0]}; profile ${r.profileVersion}.`,
|
|
139
|
-
`Two separate playthroughs:
|
|
140
|
-
...(r.standardProvider ? [`
|
|
148
|
+
`Two separate playthroughs: Geri (${r.standardProvider ? providerLabel(r.standardProvider) : 'server default model provider'}) then Freki.`,
|
|
149
|
+
...(r.standardProvider ? [`Geri provider policy: ${q.standardProviderPolicyHash}.`] : []),
|
|
141
150
|
...q.localBreakdown.map(row => `${row.count} ${row.unit} at ${money(row.unitCents)} each: ${money(row.count * row.unitCents)}.`),
|
|
142
|
-
...q.computeBreakdown.map(row => `${row.controller} hosted compute: ${money(row.priceCents)}.`),
|
|
151
|
+
...q.computeBreakdown.map(row => `${displayName(row.controller)} hosted compute: ${money(row.priceCents)}.`),
|
|
143
152
|
`Total ${money(q.totalPriceCents)}; already reserved ${money(q.alreadyReservedCents)}; due now ${money(q.dueNowCents)} from prepaid funds. No top-up is performed.`,
|
|
144
153
|
`Video: ${r.includeVideo ? 'included' : 'off'}. Hosted runs save no transcript.`,
|
|
145
154
|
`Customer failure: ${q.customerFailure}; cancellation after start: ${q.cancelAfterStart}. Price ${q.priceVersion}; refund policy ${q.policyVersion}.`,
|
|
@@ -162,7 +171,7 @@ export async function runHostedQuote({ filename, api, apiUrl, repoRoot, confirm,
|
|
|
162
171
|
return admitHostedOffer({ offer, api, apiUrl, repoRoot, now });
|
|
163
172
|
}
|
|
164
173
|
|
|
165
|
-
export const confirmQuestion = offer => `Pay ${money(offer.quote.dueNowCents)} now (${money(offer.quote.totalPriceCents)} total) for the quoted
|
|
174
|
+
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?`;
|
|
166
175
|
|
|
167
176
|
// Refusals the server makes before any charge: the quote or consent was not
|
|
168
177
|
// accepted, funding or capacity said no, or the quote is gone. The original
|
|
@@ -288,7 +297,7 @@ export function fundingShortfall(quote, funding) {
|
|
|
288
297
|
export function hostedConsentLines(offer) {
|
|
289
298
|
const q = offer.quote;
|
|
290
299
|
return [
|
|
291
|
-
'One persona plays the same build twice, once with
|
|
300
|
+
'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.',
|
|
292
301
|
'The game runs without network access. Shared capacity, daily limits and the quoted runtime bounds still apply; funding does not guarantee an immediate start.',
|
|
293
302
|
`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.`,
|
|
294
303
|
'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
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// words. Change both together. The admission owns the provider and payment
|
|
6
6
|
// lifecycle; the job and its runs own gameplay, report capture and aggregation.
|
|
7
7
|
|
|
8
|
+
import { DISPLAY_NAMES } from '../run/controllers.js';
|
|
9
|
+
|
|
8
10
|
const FAILED = new Set(['failed', 'budget_exceeded', 'interrupted', 'stalled', 'refused']);
|
|
9
11
|
const CANCELED = new Set(['canceled']);
|
|
10
12
|
const boundedReason = value => String(value || '').replace(/\s+/g, ' ').trim().slice(0, 240);
|
|
@@ -70,10 +72,9 @@ export function hostedPlaytestStatus(admission, job = null, runs = [], now = Dat
|
|
|
70
72
|
};
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
const MODE_NAMES = Object.freeze({ standard: 'Standard', jev: 'Jev' });
|
|
74
75
|
|
|
75
76
|
/**
|
|
76
|
-
* One row per hosted mode (
|
|
77
|
+
* One row per hosted mode (Geri, Freki), from the job's persona runs. A mode
|
|
77
78
|
* whose run the server has not created yet reads as not started.
|
|
78
79
|
* @param {Array<object>} runs
|
|
79
80
|
* @param {Array<string>} [controllers]
|
|
@@ -85,7 +86,7 @@ export function modeOutcomes(runs = [], controllers = ['standard', 'jev']) {
|
|
|
85
86
|
const report = run?.report || null;
|
|
86
87
|
return {
|
|
87
88
|
mode: controller,
|
|
88
|
-
name:
|
|
89
|
+
name: DISPLAY_NAMES[controller] || 'Playtester',
|
|
89
90
|
runId: run?.run_id || null,
|
|
90
91
|
state: run?.state || 'not_started',
|
|
91
92
|
reason: run?.state_reason ? boundedReason(run.state_reason) : null,
|
|
@@ -97,7 +98,7 @@ export function modeOutcomes(runs = [], controllers = ['standard', 'jev']) {
|
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
|
|
100
|
-
/** "
|
|
101
|
+
/** "Geri: completed, 4 findings, video saved." */
|
|
101
102
|
export function modeLine(row) {
|
|
102
103
|
const parts = [row.state.replace(/_/g, ' ')];
|
|
103
104
|
if (row.findings !== null) parts.push(`${row.findings} finding${row.findings === 1 ? '' : 's'}`);
|
package/src/run/comparison.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// Deterministic comparison of the reports already paid for. No new model call.
|
|
2
|
+
// The JSON keeps the wire ids; the markdown a person reads names the playtesters.
|
|
3
|
+
import { displayName } from './controllers.js';
|
|
2
4
|
export function compareControllers(runs) {
|
|
3
5
|
const planned = runs.filter(run => run.controller);
|
|
4
6
|
const controllers = [...new Set(planned.map(run => run.controller))];
|
|
@@ -19,14 +21,14 @@ export function compareControllers(runs) {
|
|
|
19
21
|
const findings = [...groups.values()].map(group => ({ ...group,
|
|
20
22
|
match: new Set(group.occurrences.map(row => row.controller)).size > 1 ? 'reported_by_multiple_controllers' : 'reported_by_one_controller' }));
|
|
21
23
|
return { schema_version: '1.0', controllers, status: rows.some(row => row.partial) ? 'inconclusive' : 'reports_complete',
|
|
22
|
-
limits: ['
|
|
24
|
+
limits: ['Playtesters use separate game sessions. Server saves and random state are not proven identical.', 'Matches use the same persona, category and exact normalized title. Agreement does not verify a bug; absence does not prove a pass.'], runs: rows, findings };
|
|
23
25
|
}
|
|
24
26
|
export function comparisonMarkdown(comparison) {
|
|
25
27
|
if (!comparison) return '';
|
|
26
28
|
const safe = value => String(value ?? '').replace(/[\r\n|]/g, ' ');
|
|
27
|
-
return '\n\n##
|
|
29
|
+
return '\n\n## Playtester comparison\n\n' + comparison.limits.join(' ') + '\n\n' +
|
|
28
30
|
(comparison.status === 'inconclusive' ? 'At least one playthrough is missing or partial. This comparison is inconclusive.\n\n' : '') +
|
|
29
|
-
'|
|
|
30
|
-
comparison.runs.map(row => `| ${safe(row.controller)} | ${safe(row.persona)} | ${safe(row.run_id)} | ${row.partial ? 'Incomplete' : 'Complete'} |`).join('\n') +
|
|
31
|
-
'\n\n' + comparison.findings.map(group => `- ${safe(group.title)}: ${[...new Set(group.occurrences.map(row => row.controller))].join(', ')} (${group.occurrences.map(row => safe(row.run_id)).join(', ')}).`).join('\n');
|
|
31
|
+
'| Playtester | Persona | Run | Report |\n| --- | --- | --- | --- |\n' +
|
|
32
|
+
comparison.runs.map(row => `| ${safe(displayName(row.controller))} | ${safe(row.persona)} | ${safe(row.run_id)} | ${row.partial ? 'Incomplete' : 'Complete'} |`).join('\n') +
|
|
33
|
+
'\n\n' + comparison.findings.map(group => `- ${safe(group.title)}: ${[...new Set(group.occurrences.map(row => displayName(row.controller)))].join(', ')} (${group.occurrences.map(row => safe(row.run_id)).join(', ')}).`).join('\n');
|
|
32
34
|
}
|
package/src/run/controllers.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
export const CONTROLLERS = ['standard', 'jev', 'rune'];
|
|
2
|
+
// The playtesters by name. `geri` and `freki` are the documented flag values;
|
|
3
|
+
// the server's wire ids `standard` and `jev` stay accepted as hidden aliases
|
|
4
|
+
// so older scripts and saved jobs keep working. Every value is mapped to its
|
|
5
|
+
// wire id before it reaches the server or a journal.
|
|
6
|
+
export const DISPLAY_NAMES = Object.freeze({ standard: 'Geri', jev: 'Freki', rune: 'Experimental playtester' });
|
|
7
|
+
const ALIASES = Object.freeze({ geri: 'standard', freki: 'jev', standard: 'standard', jev: 'jev', rune: 'rune' });
|
|
8
|
+
/** The wire id for a flag value, or the value unchanged when it names nothing known. */
|
|
9
|
+
export function wireId(value) {
|
|
10
|
+
const key = String(value).trim().toLowerCase();
|
|
11
|
+
return Object.hasOwn(ALIASES, key) ? ALIASES[key] : String(value);
|
|
12
|
+
}
|
|
13
|
+
export function displayName(id) { return DISPLAY_NAMES[id] || 'Playtester'; }
|
|
2
14
|
export function controllerPlan(options = {}) {
|
|
3
15
|
if (options.compareWith && options.controller) throw new Error('Use --controller for one playthrough or --compare-with for a comparison.');
|
|
4
16
|
if (!options.compareWith && !options.controller) return null;
|
|
5
|
-
const plan = options.compareWith ? ['standard', ...String(options.compareWith).split(',')] : [options.controller];
|
|
6
|
-
if (plan.length > 3 || plan.some(x => !CONTROLLERS.includes(x)) || new Set(plan).size !== plan.length) throw new Error('Choose
|
|
17
|
+
const plan = (options.compareWith ? ['standard', ...String(options.compareWith).split(',')] : [options.controller]).map(wireId);
|
|
18
|
+
if (plan.length > 3 || plan.some(x => !CONTROLLERS.includes(x)) || new Set(plan).size !== plan.length) throw new Error('Choose geri or freki once each. --compare-with freki plays Geri and Freki separately.');
|
|
7
19
|
return plan;
|
|
8
20
|
}
|
|
9
21
|
export function quoteMatchesPlan(quote, plan, personas) {
|
package/src/run/drivers/web.js
CHANGED
|
@@ -1166,6 +1166,47 @@ export const CHECK_PLAYTEST_IDENTITY = Object.freeze({ token: 'check', runId: nu
|
|
|
1166
1166
|
* the one the platform implies
|
|
1167
1167
|
* @returns {Object} a driver
|
|
1168
1168
|
*/
|
|
1169
|
+
/**
|
|
1170
|
+
* The share of the viewport a visible canvas must cover for the persona to
|
|
1171
|
+
* need a picture of it. An engine's web page is often a canvas plus a little
|
|
1172
|
+
* text (love.js prints a title, a fullscreen button and a hint; Emscripten
|
|
1173
|
+
* and Unity pages a status line), and that text alone can pass the thin
|
|
1174
|
+
* observation bar, so the game itself, everything that happens in the canvas,
|
|
1175
|
+
* was never shown to the persona: a love.js run quit on "a blank canvas" that
|
|
1176
|
+
* was drawing the game the whole time.
|
|
1177
|
+
*/
|
|
1178
|
+
export const LARGE_CANVAS_SHARE = 0.15;
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Serialised by Playwright, so it must not close over anything. Whether a
|
|
1182
|
+
* visible canvas covers at least `share` of the viewport.
|
|
1183
|
+
* @param {number} share
|
|
1184
|
+
* @returns {boolean}
|
|
1185
|
+
*/
|
|
1186
|
+
/* c8 ignore start */
|
|
1187
|
+
export function pageHasLargeCanvas(share) {
|
|
1188
|
+
const area = window.innerWidth * window.innerHeight;
|
|
1189
|
+
if (!area) return false;
|
|
1190
|
+
for (const canvas of document.querySelectorAll('canvas')) {
|
|
1191
|
+
const box = canvas.getBoundingClientRect();
|
|
1192
|
+
const w = Math.max(0, Math.min(box.right, window.innerWidth) - Math.max(box.left, 0));
|
|
1193
|
+
const h = Math.max(0, Math.min(box.bottom, window.innerHeight) - Math.max(box.top, 0));
|
|
1194
|
+
const style = window.getComputedStyle(canvas);
|
|
1195
|
+
if (style.visibility !== 'hidden' && style.display !== 'none' && Number(style.opacity) > 0 && (w * h) / area >= share) return true;
|
|
1196
|
+
}
|
|
1197
|
+
return false;
|
|
1198
|
+
}
|
|
1199
|
+
/* c8 ignore stop */
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* Whether an observation needs a picture: a thin text observation, or a game
|
|
1203
|
+
* drawn in a large canvas. A page that cannot answer is treated as no canvas.
|
|
1204
|
+
*/
|
|
1205
|
+
export async function needsFrame(page, text) {
|
|
1206
|
+
if (String(text).trim().length < THIN_OBSERVATION_CHARS) return true;
|
|
1207
|
+
try { return (await page.evaluate(pageHasLargeCanvas, LARGE_CANVAS_SHARE)) === true; } catch { return false; }
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1169
1210
|
export function createWebDriver({ importer, headless = true, playtest = null, platform = process.platform, modifier = null, recording = {}, now = () => Date.now(), inspectVideo = probeVideo } = {}) {
|
|
1170
1211
|
const editModifier = modifier === 'Meta' || modifier === 'Control' ? modifier : platformModifier(platform);
|
|
1171
1212
|
let browser = null;
|
|
@@ -1454,7 +1495,7 @@ export function createWebDriver({ importer, headless = true, playtest = null, pl
|
|
|
1454
1495
|
async function currentHash(current) {
|
|
1455
1496
|
const snap = await snapshotText();
|
|
1456
1497
|
const after = { text: hashText(snap, shownText(snap)) };
|
|
1457
|
-
if (
|
|
1498
|
+
if (await needsFrame(current, snap.text)) {
|
|
1458
1499
|
const frame = await current.screenshot({ type: OBSERVATION_FRAME.type, quality: OBSERVATION_FRAME.quality, timeout: ACTION_TIMEOUT_MS });
|
|
1459
1500
|
after.screenshotBase64 = frame.toString('base64');
|
|
1460
1501
|
}
|
|
@@ -1864,8 +1905,9 @@ export function createWebDriver({ importer, headless = true, playtest = null, pl
|
|
|
1864
1905
|
}
|
|
1865
1906
|
// Canvas builds (a Godot or Unity web export is one <canvas> and
|
|
1866
1907
|
// nothing else) have no accessibility tree worth reading, so vision
|
|
1867
|
-
// is the only way to play them. Spend an image only then
|
|
1868
|
-
|
|
1908
|
+
// is the only way to play them. Spend an image only then: on a thin
|
|
1909
|
+
// page, or on any page whose game is a large canvas.
|
|
1910
|
+
if (await needsFrame(current, text)) {
|
|
1869
1911
|
try {
|
|
1870
1912
|
const buffer = await current.screenshot({ type: OBSERVATION_FRAME.type, quality: OBSERVATION_FRAME.quality, timeout: ACTION_TIMEOUT_MS });
|
|
1871
1913
|
observation.screenshotBase64 = buffer.toString('base64');
|
package/src/run/personaLoop.js
CHANGED
|
@@ -350,6 +350,18 @@ export async function runPersona(args) {
|
|
|
350
350
|
// worth keeping, by the same rule as a 402 during play.
|
|
351
351
|
const play = { actionsTaken: outcome.actionsTaken, quitReason: 'cost_cap', quitDetail: String(error.message || '') };
|
|
352
352
|
await writeSomeReport({ outcome, runDirectory, persona, driverName, target, notes, screenshots, actionRecords, play, skill, ledger, runId, jobId, startedAt, endedAt: new Date().toISOString(), log, preservedMarkdown: error.completedReportMarkdown });
|
|
353
|
+
} else if (error && error.reportIncomplete && !args.signal?.aborted) {
|
|
354
|
+
// The run played; only the report step could not finish. Its notes are
|
|
355
|
+
// the report, by the same rule as a 402 in the report step. Under budget
|
|
356
|
+
// pressure that is a budget stop; otherwise the run is marked failed, so
|
|
357
|
+
// the unit is refunded, and the report still carries what it saw.
|
|
358
|
+
outcome.state = error.budgetPressure ? 'budget_exceeded' : 'failed';
|
|
359
|
+
outcome.quitReason = error.budgetPressure ? 'cost_cap' : 'error';
|
|
360
|
+
const actionsTaken = Math.max(outcome.actionsTaken || 0, actionLogFrom(actionRecords).length);
|
|
361
|
+
const play = { actionsTaken, quitReason: outcome.quitReason, quitDetail: safeErrorDetail(error, localBrief) };
|
|
362
|
+
await writeSomeReport({ outcome, runDirectory, persona, driverName, target, notes, screenshots, actionRecords, play, skill, ledger, runId, jobId, startedAt,
|
|
363
|
+
endedAt: new Date().toISOString(), log, quitReason: outcome.quitReason, reason: REPORT_INCOMPLETE_REASON, bareReason: REPORT_INCOMPLETE_REASON,
|
|
364
|
+
preservedMarkdown: error.completedReportMarkdown });
|
|
353
365
|
} else if (error instanceof ProxyError && error.isClosed) {
|
|
354
366
|
outcome.state = 'canceled';
|
|
355
367
|
outcome.quitReason = 'error';
|
|
@@ -906,6 +918,11 @@ async function reportPhase({
|
|
|
906
918
|
let maxTokens = REPORT_MAX_TOKENS;
|
|
907
919
|
let shrunk = false;
|
|
908
920
|
let lastCandidate = null;
|
|
921
|
+
// The largest output ceiling a turn has already been cut off at. A retry
|
|
922
|
+
// below it is built to fail (pt_run_ed0941d6a976a93efa46: cut off at 4096,
|
|
923
|
+
// then asked again at 2326 and cut off again), so no retry goes below it.
|
|
924
|
+
let cutOffAt = 0;
|
|
925
|
+
let cutOffs = 0;
|
|
909
926
|
for (let attempt = 1; ; attempt += 1) {
|
|
910
927
|
let answer;
|
|
911
928
|
const askedAt = Date.now();
|
|
@@ -924,8 +941,14 @@ async function reportPhase({
|
|
|
924
941
|
} catch (error) {
|
|
925
942
|
if (!(error instanceof ProxyError && error.isBudget)) throw error;
|
|
926
943
|
const bodyChars = JSON.stringify({ messages, system, tools: REPORT_TOOLS, max_tokens: maxTokens, stream: true }).length;
|
|
927
|
-
const
|
|
928
|
-
|
|
944
|
+
const fits = shrunk ? null : reportTokensThatFit(error, maxTokens, bodyChars);
|
|
945
|
+
// After a cut-off, only a ceiling at least as large as the one that was
|
|
946
|
+
// cut off is worth paying for. Anything less goes to the step-log report.
|
|
947
|
+
const smaller = fits && fits >= cutOffAt ? fits : null;
|
|
948
|
+
if (fits && !smaller && !lastCandidate) {
|
|
949
|
+
log(`the report was cut off at ${cutOffAt} output tokens and the remaining model budget only fits ${fits}, which would be cut off too, so the report is written from the notes instead.`);
|
|
950
|
+
transcript.write({ kind: 'report_cut_off_no_room', cut_off_at: cutOffAt, fits });
|
|
951
|
+
} else if (!smaller && !shrunk && !lastCandidate) {
|
|
929
952
|
log(hasBudgetFigures(error)
|
|
930
953
|
? `even the smallest report (${REPORT_MIN_TOKENS} output tokens) does not fit the remaining model budget once the request itself is paid for, so the report is written from the notes instead.`
|
|
931
954
|
: 'the report turn was refused for budget with no budget figures in the refusal, so there is nothing to size a retry from; the report is written from the notes instead.');
|
|
@@ -935,6 +958,9 @@ async function reportPhase({
|
|
|
935
958
|
transcript.write({ kind: 'report_budget_retry', attempt, max_tokens: smaller, figures: error.figures || {} });
|
|
936
959
|
log(`the report turn did not fit the remaining model budget; asking again with an output ceiling of ${smaller} tokens.`);
|
|
937
960
|
maxTokens = smaller;
|
|
961
|
+
// A smaller ceiling needs a shorter report: say so, or the model
|
|
962
|
+
// writes the same length and is cut off.
|
|
963
|
+
askShorter(messages, smaller);
|
|
938
964
|
continue;
|
|
939
965
|
}
|
|
940
966
|
// A report already written on an earlier turn is the report, with its
|
|
@@ -1049,6 +1075,26 @@ async function reportPhase({
|
|
|
1049
1075
|
...missingSections.map(section => `report.md has no "${section}" section`)
|
|
1050
1076
|
];
|
|
1051
1077
|
|
|
1078
|
+
const cutOff = answer.stopReason === 'max_tokens';
|
|
1079
|
+
if (cutOff) {
|
|
1080
|
+
cutOffs += 1;
|
|
1081
|
+
cutOffAt = Math.max(cutOffAt, maxTokens);
|
|
1082
|
+
transcript.write({ kind: 'report_cut_off', attempt, max_tokens: maxTokens, cut_offs: cutOffs });
|
|
1083
|
+
// With its repair spent, a report.json already written beats another
|
|
1084
|
+
// metered turn; the server has the final word on it, as after a repair.
|
|
1085
|
+
if (lastCandidate && (repaired || cutOffs >= 2)) {
|
|
1086
|
+
report = lastCandidate;
|
|
1087
|
+
log(`the report turn was cut off at ${maxTokens} output tokens; keeping the report.json already written (${lint.length} problem(s)).`);
|
|
1088
|
+
break;
|
|
1089
|
+
}
|
|
1090
|
+
if (cutOffs >= 2) {
|
|
1091
|
+
log(`the report turn was cut off at its output limit twice (${maxTokens} tokens), so the report is written from the notes instead.`);
|
|
1092
|
+
throw reportIncomplete({ markdown, secrets, budgetPressure: shrunk || play.budgetWarned || play.budgetExceeded || play.reserveStopped,
|
|
1093
|
+
message: `The report step was cut off at its ${maxTokens} token output limit twice.` });
|
|
1094
|
+
}
|
|
1095
|
+
log(`the report turn was cut off at ${maxTokens} output tokens; asking once more for a shorter report with the same ceiling.`);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1052
1098
|
// Every tool_use the next request echoes back needs its tool_result, or
|
|
1053
1099
|
// the API refuses the request. A write cut off at the token limit is
|
|
1054
1100
|
// malformed: it was not saved, and it is answered so.
|
|
@@ -1060,11 +1106,16 @@ async function reportPhase({
|
|
|
1060
1106
|
continued = true;
|
|
1061
1107
|
messages.push({ role: 'assistant', content: assistantContent(answer) });
|
|
1062
1108
|
messages.push({ role: 'user', content: toolResults.concat([{ type: 'text', text: CONTINUE_WITH_JSON }]) });
|
|
1109
|
+
if (cutOff) askShorter(messages, maxTokens);
|
|
1063
1110
|
continue;
|
|
1064
1111
|
}
|
|
1065
1112
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1113
|
+
// A first cut-off on the repair turn still gets its one shorter retry.
|
|
1114
|
+
if (repaired && !(cutOff && cutOffs === 1)) {
|
|
1115
|
+
// No report.json after the repair: the run still played, so the notes
|
|
1116
|
+
// become the report rather than an empty one.
|
|
1117
|
+
if (!candidate) throw reportIncomplete({ markdown, secrets, budgetPressure: shrunk || play.budgetWarned || play.budgetExceeded || play.reserveStopped,
|
|
1118
|
+
message: `the report step did not produce a valid report.json: ${lint.join('; ')}` });
|
|
1068
1119
|
// Still imperfect after the repair: keep it, record the lint, and let
|
|
1069
1120
|
// the server have the final word. It validates the same schema and
|
|
1070
1121
|
// drops unevidenced findings itself, so this is a report with known
|
|
@@ -1082,6 +1133,7 @@ async function reportPhase({
|
|
|
1082
1133
|
role: 'user',
|
|
1083
1134
|
content: toolResults.concat([{ type: 'text', text: repairInstruction(validation.details, evidenceProblems, missingSections) }])
|
|
1084
1135
|
});
|
|
1136
|
+
if (cutOff) askShorter(messages, maxTokens);
|
|
1085
1137
|
}
|
|
1086
1138
|
|
|
1087
1139
|
// One bounded look at the evidence: each blocker or major (at most
|
|
@@ -1318,6 +1370,39 @@ export function buildReportRequest({ skill, persona, brief, localBrief = {}, int
|
|
|
1318
1370
|
return { system, messages: [{ role: 'user', content: [{ type: 'text', text: scrubSecrets(text, secrets) }] }] };
|
|
1319
1371
|
}
|
|
1320
1372
|
|
|
1373
|
+
/** What a report turn is told when its ceiling is tight or it was cut off. */
|
|
1374
|
+
export function shorterReportInstruction(maxTokens) {
|
|
1375
|
+
return `Your report has to fit in ${maxTokens} output tokens, and the last one did not. Write it much shorter: at most 5 findings, each description and repro step one or two short sentences, `
|
|
1376
|
+
+ 'and a report.md of about 250 words that keeps its four sections. Write the files in one turn and do not restate the notes.';
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/** Add the shorter-report instruction to the last user message, which is the next request's question. */
|
|
1380
|
+
function askShorter(messages, maxTokens) {
|
|
1381
|
+
const last = messages[messages.length - 1];
|
|
1382
|
+
if (!last || last.role !== 'user') return;
|
|
1383
|
+
const text = shorterReportInstruction(maxTokens);
|
|
1384
|
+
const content = typeof last.content === 'string' ? [{ type: 'text', text: last.content }] : [...(last.content || [])];
|
|
1385
|
+
if (content.some(block => block && block.type === 'text' && block.text === text)) return;
|
|
1386
|
+
messages[messages.length - 1] = { ...last, content: [...content, { type: 'text', text }] };
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* The report step could not finish: the caller writes the report from the
|
|
1391
|
+
* step log (notes, screenshots and actions), because a run that played never
|
|
1392
|
+
* comes back empty. A report.md completed on the way is kept as a draft.
|
|
1393
|
+
*/
|
|
1394
|
+
function reportIncomplete({ markdown, secrets, budgetPressure, message }) {
|
|
1395
|
+
const error = Object.assign(new Error(message), { reportIncomplete: true, budgetPressure: Boolean(budgetPressure) });
|
|
1396
|
+
if (typeof markdown === 'string' && markdown.trim()) {
|
|
1397
|
+
const safeMarkdown = scrubSecrets(markdown, secrets);
|
|
1398
|
+
if (Buffer.byteLength(safeMarkdown, 'utf8') <= 256 * 1024 && scanForSecrets(safeMarkdown).length === 0) error.completedReportMarkdown = safeMarkdown;
|
|
1399
|
+
}
|
|
1400
|
+
return error;
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
/** The reason a step-log report gives when the report step could not finish. */
|
|
1404
|
+
export const REPORT_INCOMPLETE_REASON = 'The report step could not finish within its output limit and the run\'s model budget. What the persona saw is below, and report.json carries the notes as unreviewed findings.';
|
|
1405
|
+
|
|
1321
1406
|
/** The smallest output ceiling worth retrying a report turn with. */
|
|
1322
1407
|
export const REPORT_MIN_TOKENS = 1536;
|
|
1323
1408
|
|
package/src/run/resume.js
CHANGED
|
@@ -9,6 +9,7 @@ import { reconcileDroppedFindings } from './dropped.js';
|
|
|
9
9
|
import { createReportValidator, writeReportFiles } from './report.js';
|
|
10
10
|
import * as stateFile from './state.js';
|
|
11
11
|
import { playJob, resolvePersonas } from '../commands/run.js';
|
|
12
|
+
import { serveBuildDir } from './serveBuild.js';
|
|
12
13
|
|
|
13
14
|
/** Server states that only a live process can be in, and this one is resuming it. */
|
|
14
15
|
const ABANDONED_MID_RUN = Object.freeze(['launching', 'playing']);
|
|
@@ -115,7 +116,16 @@ export async function resumeJob({ api, gameId, jobId, job, runs, state, repoRoot
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
const driverName = journal.driver || options.driver || 'playwright_web';
|
|
118
|
-
|
|
119
|
+
// A build served by `run --build-dir` lived on a port that died with that
|
|
120
|
+
// process: serve the same folder again (or the one passed now) and play there.
|
|
121
|
+
let servedTarget = null;
|
|
122
|
+
if (driverName === 'playwright_web' && (options.buildDir || journal.buildDir)) {
|
|
123
|
+
try { servedTarget = (await (injected.serveBuildDir || serveBuildDir)(options.buildDir || journal.buildDir)).url; } catch (error) {
|
|
124
|
+
log(`${error.message} Pass --build-dir with the build folder, or --build-url.`);
|
|
125
|
+
return EXIT.ENVIRONMENT;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const target = servedTarget || journal.target || options.buildUrl || options.godotProject;
|
|
119
129
|
if (!target) {
|
|
120
130
|
log('The journal does not say what this job was pointed at. Pass --build-url or --godot-project.');
|
|
121
131
|
return EXIT.ENVIRONMENT;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import { lstat, readdir, readFile, realpath, stat } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { CliError } from '../errors.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The local web server behind `run --build-dir`: an exported web build served
|
|
8
|
+
* from 127.0.0.1 on a free port, with the headers engines' web exports need
|
|
9
|
+
* and a static file server usually does not send.
|
|
10
|
+
*
|
|
11
|
+
* - `application/wasm` for `.wasm`, so the browser compiles while it downloads.
|
|
12
|
+
* - Content-Encoding for an engine's pre-compressed files (`x.wasm.br`,
|
|
13
|
+
* `x.framework.js.gz`), with the type of the file inside. Unity's Brotli and
|
|
14
|
+
* gzip builds refuse to start without it.
|
|
15
|
+
* - Cross-origin isolation on every response (COOP `same-origin`, COEP
|
|
16
|
+
* `credentialless`), so a threaded export (Godot with threads, love.js,
|
|
17
|
+
* Emscripten `-pthread`) gets SharedArrayBuffer. `credentialless` rather than
|
|
18
|
+
* `require-corp`: a local game may still load a font or image from another
|
|
19
|
+
* host, and that should keep working, without cookies.
|
|
20
|
+
* - `no-store`, so a rebuilt export is never played from a stale cache.
|
|
21
|
+
*
|
|
22
|
+
* It reads only files under the build folder (no symlink out of it), answers
|
|
23
|
+
* GET and HEAD only, and listens on the loopback address only.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export const CONTENT_TYPES = Object.freeze({
|
|
27
|
+
'.html': 'text/html; charset=utf-8', '.htm': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8',
|
|
28
|
+
'.mjs': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.json': 'application/json',
|
|
29
|
+
'.map': 'application/json', '.wasm': 'application/wasm', '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg',
|
|
30
|
+
'.gif': 'image/gif', '.svg': 'image/svg+xml', '.webp': 'image/webp', '.ico': 'image/x-icon', '.mp3': 'audio/mpeg',
|
|
31
|
+
'.ogg': 'audio/ogg', '.wav': 'audio/wav', '.m4a': 'audio/mp4', '.mp4': 'video/mp4', '.webm': 'video/webm',
|
|
32
|
+
'.woff': 'font/woff', '.woff2': 'font/woff2', '.ttf': 'font/ttf', '.otf': 'font/otf', '.txt': 'text/plain; charset=utf-8',
|
|
33
|
+
'.xml': 'application/xml', '.pck': 'application/octet-stream', '.data': 'application/octet-stream',
|
|
34
|
+
'.mem': 'application/octet-stream', '.unityweb': 'application/octet-stream'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const ENCODINGS = Object.freeze({ '.br': 'br', '.gz': 'gzip' });
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The type and encoding a file is served with. `.unityweb` is Unity's own
|
|
41
|
+
* fallback format, decoded by its loader, so it is sent as it is.
|
|
42
|
+
* @param {string} file
|
|
43
|
+
* @returns {Record<string, string>}
|
|
44
|
+
*/
|
|
45
|
+
export function contentHeaders(file) {
|
|
46
|
+
const ext = path.extname(file).toLowerCase();
|
|
47
|
+
const encoding = ENCODINGS[ext];
|
|
48
|
+
if (encoding) {
|
|
49
|
+
const inner = path.extname(file.slice(0, -ext.length)).toLowerCase();
|
|
50
|
+
if (inner && CONTENT_TYPES[inner]) return { 'content-type': CONTENT_TYPES[inner], 'content-encoding': encoding };
|
|
51
|
+
}
|
|
52
|
+
return { 'content-type': CONTENT_TYPES[ext] || 'application/octet-stream' };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Headers on every response. */
|
|
56
|
+
export const ISOLATION_HEADERS = Object.freeze({
|
|
57
|
+
'cache-control': 'no-store',
|
|
58
|
+
'cross-origin-opener-policy': 'same-origin',
|
|
59
|
+
'cross-origin-embedder-policy': 'credentialless',
|
|
60
|
+
'cross-origin-resource-policy': 'same-origin',
|
|
61
|
+
'x-content-type-options': 'nosniff'
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The page to open in a build folder: `index.html` when there is one,
|
|
66
|
+
* otherwise the only `.html` file at the top (a Godot export keeps its
|
|
67
|
+
* project name, `jump-bunny.html`). Null when there is no single page.
|
|
68
|
+
* @param {string[]} names the folder's top-level file names
|
|
69
|
+
* @returns {string|null}
|
|
70
|
+
*/
|
|
71
|
+
export function pickEntry(names) {
|
|
72
|
+
if (names.includes('index.html')) return 'index.html';
|
|
73
|
+
const pages = names.filter(name => /\.html?$/i.test(name));
|
|
74
|
+
return pages.length === 1 ? pages[0] : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Start serving a build folder.
|
|
79
|
+
* @param {string} dir
|
|
80
|
+
* @param {{entry?: string|null, host?: string}} [options]
|
|
81
|
+
* @returns {Promise<{url: string, origin: string, entry: string, root: string, close: () => Promise<void>}>}
|
|
82
|
+
*/
|
|
83
|
+
export async function serveBuildDir(dir, { entry = null, host = '127.0.0.1' } = {}) {
|
|
84
|
+
let root;
|
|
85
|
+
try {
|
|
86
|
+
root = await realpath(path.resolve(dir));
|
|
87
|
+
if (!(await stat(root)).isDirectory()) throw new Error('not a directory');
|
|
88
|
+
} catch {
|
|
89
|
+
throw new CliError(`--build-dir ${dir} is not a folder. Point it at the folder your engine exported for the web (the one with the .html page).`);
|
|
90
|
+
}
|
|
91
|
+
const names = (await readdir(root, { withFileTypes: true })).filter(item => item.isFile()).map(item => item.name);
|
|
92
|
+
const page = entry || pickEntry(names);
|
|
93
|
+
if (!page) {
|
|
94
|
+
throw new CliError(`--build-dir ${dir} has no index.html and no single .html page. Export the game for the web, or name its page in the folder${names.some(name => /\.html?$/i.test(name)) ? ' (there is more than one .html file: open the right one with --build-url)' : ''}.`);
|
|
95
|
+
}
|
|
96
|
+
const server = createServer((req, res) => {
|
|
97
|
+
respond(root, req, res).catch(() => { if (!res.headersSent) res.writeHead(500, ISOLATION_HEADERS); res.end(); });
|
|
98
|
+
});
|
|
99
|
+
await new Promise((resolve, reject) => {
|
|
100
|
+
server.once('error', reject);
|
|
101
|
+
server.listen(0, host, resolve);
|
|
102
|
+
});
|
|
103
|
+
// The server lives as long as the run that started it, and never keeps the
|
|
104
|
+
// process alive on its own once the run is over.
|
|
105
|
+
server.unref();
|
|
106
|
+
const origin = `http://${host}:${server.address().port}`;
|
|
107
|
+
const url = `${origin}/${page.split('/').map(encodeURIComponent).join('/')}`;
|
|
108
|
+
return { url, origin, entry: page, root, close: () => new Promise(resolve => server.close(() => resolve())) };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function respond(root, req, res) {
|
|
112
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
113
|
+
res.writeHead(405, { ...ISOLATION_HEADERS, allow: 'GET, HEAD' });
|
|
114
|
+
return res.end();
|
|
115
|
+
}
|
|
116
|
+
let rel;
|
|
117
|
+
try { rel = decodeURIComponent(new URL(req.url, 'http://local').pathname); } catch {
|
|
118
|
+
res.writeHead(400, ISOLATION_HEADERS);
|
|
119
|
+
return res.end();
|
|
120
|
+
}
|
|
121
|
+
if (rel.includes('\0')) { res.writeHead(400, ISOLATION_HEADERS); return res.end(); }
|
|
122
|
+
if (rel.endsWith('/')) rel += 'index.html';
|
|
123
|
+
const file = path.resolve(root, '.' + rel);
|
|
124
|
+
if (file !== root && !file.startsWith(root + path.sep)) { res.writeHead(404, ISOLATION_HEADERS); return res.end(); }
|
|
125
|
+
let real;
|
|
126
|
+
try {
|
|
127
|
+
const info = await lstat(file);
|
|
128
|
+
real = await realpath(file);
|
|
129
|
+
if (!real.startsWith(root + path.sep) || !(await stat(real)).isFile() || (!info.isFile() && !info.isSymbolicLink())) throw new Error('outside');
|
|
130
|
+
} catch {
|
|
131
|
+
res.writeHead(404, ISOLATION_HEADERS);
|
|
132
|
+
return res.end();
|
|
133
|
+
}
|
|
134
|
+
const body = await readFile(real);
|
|
135
|
+
res.writeHead(200, { ...contentHeaders(real), ...ISOLATION_HEADERS, 'content-length': body.length });
|
|
136
|
+
res.end(req.method === 'HEAD' ? undefined : body);
|
|
137
|
+
}
|