ravensight-playtest 0.7.5 → 0.8.1
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 +57 -29
- package/docs/ADAPTERS.md +1 -1
- package/package.json +1 -1
- package/src/cli.js +25 -17
- package/src/commands/build.js +3 -1
- package/src/commands/hosted.js +100 -23
- package/src/commands/run.js +42 -10
- package/src/hosted/archivePreflight.js +112 -4
- package/src/hosted/buildStatus.js +2 -0
- package/src/hosted/buildUpload.js +22 -3
- package/src/hosted/recordedRun.js +272 -61
- package/src/hosted/status.js +26 -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
|
|
|
@@ -27,9 +27,14 @@ question, and nothing is charged.
|
|
|
27
27
|
| `--build <id>` | Use this build instead of the newest ready one. |
|
|
28
28
|
| `--persona <slug>` | The persona for both runs. Default `curious-kid`. |
|
|
29
29
|
| `--video`, `--transcript` | Save video or transcripts of both sessions in their reports. Priced in the quote. |
|
|
30
|
-
| `--wait` | Stay until the run finishes, printing each phase change, then each mode's outcome. |
|
|
30
|
+
| `--wait` | Stay until the run finishes, printing each phase change and the queue place while it waits, then each mode's outcome. Works with a saved quote file too. |
|
|
31
31
|
| `--game <id>` | Override the linked game. |
|
|
32
32
|
|
|
33
|
+
`hosted run` prints the hosted run id and job id as soon as the run is admitted.
|
|
34
|
+
A run waiting for a hosted machine shows its place, such as "Queued, position 2,
|
|
35
|
+
expected to start in about 14 minutes" or "Queued, starting now", and `--wait`
|
|
36
|
+
prints it again whenever it moves.
|
|
37
|
+
|
|
33
38
|
The phases are the dashboard's: queued, provisioning, running, capturing,
|
|
34
39
|
analyzing, then report ready, failed or canceled. `hosted status <id>` prints
|
|
35
40
|
the current one (`--wait` to follow it) with each mode's state and findings and
|
|
@@ -41,21 +46,34 @@ is refunded during settlement.
|
|
|
41
46
|
To review a quote before paying, save it and confirm it later:
|
|
42
47
|
|
|
43
48
|
```sh
|
|
44
|
-
ravensight-playtest hosted quote --game GAME --build BUILD --
|
|
45
|
-
ravensight-playtest hosted run hosted-quote.json
|
|
49
|
+
ravensight-playtest hosted quote --game GAME --build BUILD --video --output hosted-quote.json
|
|
50
|
+
ravensight-playtest hosted run hosted-quote.json --wait
|
|
46
51
|
```
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
`hosted quote` uses the same default persona as `hosted run`, `curious-kid`, and
|
|
54
|
+
says so; `--persona` names another.
|
|
55
|
+
|
|
56
|
+
`--profile` is needed only when the server advertises more than one build
|
|
57
|
+
profile; the error lists them. The quote names the full Geri then Freki price, prepaid amount, evidence
|
|
49
58
|
options, expiry and refund rules. It charges nothing. `hosted run` confirms
|
|
50
59
|
that saved quote before one admission request. Its durable journal blocks an
|
|
51
60
|
automatic second POST after an uncertain outcome; preserve it for reconciliation.
|
|
52
61
|
Both forms of `hosted run` keep that journal under `.ravensight/hosted-runs/`.
|
|
62
|
+
When the server refuses the run with its own reason (busy capacity, funding,
|
|
63
|
+
an expired quote), no run was started, nothing was charged and the journal is
|
|
64
|
+
cleared, so the same command can be run again; it sends the same idempotency
|
|
65
|
+
key, so the server can never admit it twice. Only an answer that never arrived
|
|
66
|
+
leaves the outcome unknown. Then `hosted status`, with no run id, asks the
|
|
67
|
+
server what happened once the quote has expired (so asking cannot start the
|
|
68
|
+
run), records the run if it was admitted, and clears the journal if it was not.
|
|
53
69
|
A charged-blocked acknowledgement does not prove gameplay or a report. This
|
|
54
70
|
command does not top up funds, change local run/report files or ask for model
|
|
55
71
|
proxy permission on the CLI credential.
|
|
56
72
|
|
|
57
|
-
On a server that advertises it as ready, `hosted quote --
|
|
58
|
-
selects
|
|
73
|
+
On a server that advertises it as ready, `hosted quote --geri-provider alternate`
|
|
74
|
+
selects Geri's alternate model provider, and `primary` selects the primary one.
|
|
75
|
+
The [subprocessors page](https://www.ravensight.io/legal/subprocessors/) names
|
|
76
|
+
both. The returned
|
|
59
77
|
provider and policy hash must match and remain in the saved consent; `hosted run`
|
|
60
78
|
has no provider override. Omitting the flag keeps the original default request
|
|
61
79
|
and consent wire. No choice falls back to another provider, and a CLI declaration
|
|
@@ -65,11 +83,16 @@ continues to use its local runner and original API contract.
|
|
|
65
83
|
The hosted build command source adds a local check before a paid upload:
|
|
66
84
|
|
|
67
85
|
```sh
|
|
68
|
-
ravensight-playtest build preflight ./game.zip --format web
|
|
69
|
-
ravensight-playtest build upload ./game.zip --game GAME --
|
|
86
|
+
ravensight-playtest build preflight ./game.zip --format web
|
|
87
|
+
ravensight-playtest build upload ./game.zip --game GAME --dry-run
|
|
70
88
|
ravensight-playtest build status --game GAME
|
|
71
89
|
```
|
|
72
90
|
|
|
91
|
+
`--entrypoint` names the file the game starts from. Without it, an `index.html`
|
|
92
|
+
at the root of the archive (or inside the one folder that holds everything) is
|
|
93
|
+
used, or else the only HTML file, and the command says which. When several
|
|
94
|
+
files could be the entry, it lists them and asks you to choose one.
|
|
95
|
+
|
|
73
96
|
`preflight` seeks through bounded ZIP metadata; it does not load a multi-GB
|
|
74
97
|
archive into memory. A saved server profile can be supplied with `--capacity`
|
|
75
98
|
for its declared limits. Upload uses the server's build profile when it
|
|
@@ -474,20 +497,20 @@ splitting the job in two is what gets everything played.
|
|
|
474
497
|
| `--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
498
|
| `--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
499
|
| `--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
|
|
500
|
+
| `--controller <name>` | One playthrough with `geri` or `freki` (CLI 0.8.0 or later). The server must advertise and quote that exact choice. |
|
|
501
|
+
| `--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
502
|
| `--record-video` | Capture the selected web or graphical Godot game locally. Does not upload the video. |
|
|
480
503
|
| `--upload-video` | Record and explicitly upload `session.webm` or `session.mp4` with the reports. |
|
|
481
504
|
| `--upload-transcript` | Upload `transcript.jsonl` as well as the reports. |
|
|
482
505
|
| `--dry-upload` | List every file and byte that would be sent, and send nothing. |
|
|
483
506
|
| `--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. |
|
|
507
|
+
| `--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
508
|
| `--headed`, `--headless` | Show or hide the browser. |
|
|
485
509
|
| `--verbose` | Print each turn. |
|
|
486
510
|
|
|
487
|
-
|
|
511
|
+
Two flags are accepted and reported as not applied by this release, rather
|
|
488
512
|
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
|
|
513
|
+
the proxy) and `--offline-upload` (uploads already queue). There is no spending flag: each run's model
|
|
491
514
|
budget is set by the server from what the job was charged, and `--budget-usd` is
|
|
492
515
|
an unknown option (the refusal says where the budget comes from).
|
|
493
516
|
|
|
@@ -1072,30 +1095,35 @@ import { createClient, packs, uploadRunDir } from 'ravensight-playtest';
|
|
|
1072
1095
|
|
|
1073
1096
|
MIT. Copyright Reality Software Entertainment.
|
|
1074
1097
|
|
|
1075
|
-
##
|
|
1098
|
+
## Geri and Freki
|
|
1099
|
+
|
|
1100
|
+
Two AI playtesters can play a persona run, at the same price per run:
|
|
1101
|
+
|
|
1102
|
+
- **Geri**, the reasoning playtester, studies each screen and chooses every
|
|
1103
|
+
action itself. It is the default.
|
|
1104
|
+
- **Freki**, the selecting playtester, picks each action from a short list. A
|
|
1105
|
+
screenshot observer proposes up to three actions, Ravensight selects one on
|
|
1106
|
+
the server, and the local driver executes only that choice. Ambiguous
|
|
1107
|
+
controls stop the run for review.
|
|
1076
1108
|
|
|
1077
|
-
The optional `--controller
|
|
1078
|
-
observer proposes actions, Ravensight selects one on the server, and the local
|
|
1079
|
-
driver executes only that choice. Ambiguous controls stop the run for review.
|
|
1109
|
+
The optional `--controller freki` mode uses the existing persona run.
|
|
1080
1110
|
Reports, screenshots and findings use the normal upload and review flow.
|
|
1081
1111
|
|
|
1082
1112
|
```sh
|
|
1083
|
-
ravensight-playtest run --driver playwright_web --controller
|
|
1113
|
+
ravensight-playtest run --driver playwright_web --controller freki --build-url https://your-game.example/ --max-actions 12 --headed
|
|
1084
1114
|
```
|
|
1085
1115
|
|
|
1086
1116
|
Sign in, initialize the project and save its expectations brief first. The server
|
|
1087
|
-
must advertise this
|
|
1117
|
+
must advertise this playtester in its content pack; otherwise the command stops
|
|
1088
1118
|
before registering a paid job. No provider key belongs in the CLI. Selection costs
|
|
1089
1119
|
share the existing persona-run budget and do not create another wallet charge.
|
|
1090
|
-
Resume preserves the
|
|
1120
|
+
Resume preserves the playtester recorded in the job journal.
|
|
1091
1121
|
|
|
1092
1122
|
### Recorded playthroughs and comparisons
|
|
1093
1123
|
|
|
1094
1124
|
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.
|
|
1125
|
+
matching server release for playtester plans; an older server is refused before
|
|
1126
|
+
purchase. These commands do not activate graphical AWS hosting.
|
|
1099
1127
|
|
|
1100
1128
|
To keep one playthrough's video on your computer:
|
|
1101
1129
|
|
|
@@ -1103,13 +1131,13 @@ To keep one playthrough's video on your computer:
|
|
|
1103
1131
|
ravensight-playtest run --driver playwright_web --build-url https://your-game.example/ --record-video
|
|
1104
1132
|
```
|
|
1105
1133
|
|
|
1106
|
-
To request two reports, one from
|
|
1134
|
+
To request two reports, one from Geri and one from Freki:
|
|
1107
1135
|
|
|
1108
1136
|
```sh
|
|
1109
|
-
ravensight-playtest run --driver playwright_web --build-url https://your-game.example/ --personas curious-kid --compare-with
|
|
1137
|
+
ravensight-playtest run --driver playwright_web --build-url https://your-game.example/ --personas curious-kid --compare-with freki --record-video
|
|
1110
1138
|
```
|
|
1111
1139
|
|
|
1112
|
-
The server quotes every persona/
|
|
1140
|
+
The server quotes every persona/playtester run before the CLI asks for payment.
|
|
1113
1141
|
Each keeps its own existing model budget and settlement rules. Two standard runs
|
|
1114
1142
|
at the current $1 unit price total $2; the displayed server quote is authoritative.
|
|
1115
1143
|
No comparison model call or extra recording fee is added. Use `--upload-video`
|
|
@@ -1142,7 +1170,7 @@ Older recordings and later byte-only uploads can show status as unreported.
|
|
|
1142
1170
|
Malformed local status is omitted so it cannot prevent an existing report from
|
|
1143
1171
|
being completed.
|
|
1144
1172
|
|
|
1145
|
-
Each
|
|
1173
|
+
Each playtester starts a separate game session and produces its own report.
|
|
1146
1174
|
Saved progress and random events may still differ; this is not a guaranteed
|
|
1147
1175
|
identical-state benchmark. The aggregate compares evidence-bearing findings and
|
|
1148
1176
|
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,41 +156,46 @@ 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
|
-
.
|
|
161
|
-
.
|
|
163
|
+
.option('--profile <version>', 'hosted profile to quote; optional when the server advertises exactly one, otherwise the error lists the choices')
|
|
164
|
+
.option('--persona <slug>', 'the persona that plays both runs (default: curious-kid, the same as hosted run)')
|
|
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')
|
|
177
182
|
.option('--video', 'save video of both game sessions in their reports')
|
|
178
|
-
.option('--wait', 'stay until the report is ready, printing each phase change')
|
|
183
|
+
.option('--wait', 'stay until the report is ready, printing each phase change (with or without a saved quote)')
|
|
184
|
+
// Hidden: the server now queues a funded run instead of refusing it for
|
|
185
|
+
// capacity. Kept so an older server's busy answer can still be waited out.
|
|
186
|
+
.addOption(new Option('--wait-for-capacity [minutes]', 'when hosted capacity is busy, ask again about once a minute and start when there is room, for up to this many minutes (default 60)').hideHelp())
|
|
179
187
|
.action(capture(slot, async (filename, options, command) => {
|
|
180
188
|
const { hostedRun, hostedRunDirect } = await import('./commands/hosted.js');
|
|
181
189
|
if (filename) {
|
|
182
|
-
const extra = ['build', 'persona', 'game', 'video'
|
|
190
|
+
const extra = ['build', 'persona', 'game', 'video'].filter(name => options[name] !== undefined);
|
|
183
191
|
if (extra.length) throw new CliError(`A saved quote already fixes its build, persona and options. Drop --${extra.join(', --')}, or run "hosted run" without a quote file.`);
|
|
184
|
-
return hostedRun(filename, flagsFrom(command.optsWithGlobals()));
|
|
192
|
+
return hostedRun(filename, flagsFrom(command.optsWithGlobals(), { wait: options.wait, waitForCapacity: options.waitForCapacity }));
|
|
185
193
|
}
|
|
186
194
|
return hostedRunDirect(flagsFrom(command.optsWithGlobals(), { build: options.build, persona: options.persona, game: options.game,
|
|
187
|
-
video: options.video, wait: options.wait }));
|
|
195
|
+
video: options.video, wait: options.wait, waitForCapacity: options.waitForCapacity }));
|
|
188
196
|
}));
|
|
189
|
-
common(hosted.command('status
|
|
190
|
-
.description('show the phase of one hosted run (queued, provisioning, running, capturing, analyzing, report ready, failed or canceled), each mode and the report link')
|
|
197
|
+
common(hosted.command('status [run-id]'))
|
|
198
|
+
.description('show the phase of one hosted run (queued, provisioning, running, capturing, analyzing, report ready, failed or canceled), each mode and the report link; with no run id, ask the server about any admission whose outcome is not known yet')
|
|
191
199
|
.option('--game <id>', 'game id, overriding this repo’s configuration')
|
|
192
200
|
.option('--wait', 'stay until the run finishes, printing each phase change')
|
|
193
201
|
.action(capture(slot, async (runId, options, command) => {
|
|
@@ -204,7 +212,7 @@ export function buildProgram() {
|
|
|
204
212
|
const build = common(program.command('build').description('check or upload a self-contained hosted game archive'));
|
|
205
213
|
build.command('preflight <archive>')
|
|
206
214
|
.description('check bounded ZIP metadata locally before any paid upload')
|
|
207
|
-
.
|
|
215
|
+
.option('--entrypoint <path>', 'entry file inside the ZIP (default: index.html at the root, or the only HTML file; several are listed to choose from)')
|
|
208
216
|
.option('--format <name>', 'web or godot-project without a selected capacity profile', 'web')
|
|
209
217
|
.option('--capacity <file>', 'saved profile JSON for a local capacity check; does not establish server readiness')
|
|
210
218
|
.action(capture(slot, async (archive, options, command) => {
|
|
@@ -221,7 +229,7 @@ export function buildProgram() {
|
|
|
221
229
|
build.command('upload <archive>')
|
|
222
230
|
.description('preflight and stream one private build upload after validation-hold consent')
|
|
223
231
|
.option('--profile <version>', 'server build profile to upload under; optional when the server advertises exactly one, otherwise the error lists the choices')
|
|
224
|
-
.
|
|
232
|
+
.option('--entrypoint <path>', 'entry file inside the ZIP (default: index.html at the root, or the only HTML file; several are listed to choose from)')
|
|
225
233
|
.option('--game <id>', 'game id, overriding this repo’s configuration')
|
|
226
234
|
.option('--journal <file>', 'preserve this original upload intent at the specified path')
|
|
227
235
|
.option('--dry-run', 'inspect and hash the archive without requesting a reservation')
|
package/src/commands/build.js
CHANGED
|
@@ -2,7 +2,7 @@ import { readFile, stat } from 'node:fs/promises';
|
|
|
2
2
|
import { createContext } from '../api/index.js';
|
|
3
3
|
import { resolveGameId } from '../config.js';
|
|
4
4
|
import { withAuthHandling } from '../auth/session.js';
|
|
5
|
-
import { preflightBuildArchive, limitsFromProfile } from '../hosted/archivePreflight.js';
|
|
5
|
+
import { preflightBuildArchive, limitsFromProfile, entrypointChoiceLine } from '../hosted/archivePreflight.js';
|
|
6
6
|
import { uploadHostedBuild } from '../hosted/buildUpload.js';
|
|
7
7
|
import { buildStatusLines, readHostedBuilds } from '../hosted/buildStatus.js';
|
|
8
8
|
import { CliError, ExitCode } from '../errors.js';
|
|
@@ -43,6 +43,7 @@ export async function buildPreflight(filename, flags = {}) {
|
|
|
43
43
|
requirements: profile?.capacity?.requirements });
|
|
44
44
|
if (flags.json) ui.json(result);
|
|
45
45
|
else {
|
|
46
|
+
if (result.entrypointChosen) ui.info(entrypointChoiceLine({ entrypoint: result.entrypoint, reason: result.entrypointChosen }));
|
|
46
47
|
ui.ok(`ZIP metadata passed: ${result.entries} entries; ${ui.bytes(result.archiveBytes)} uploaded, ${ui.bytes(result.expandedBytes)} expanded.`);
|
|
47
48
|
ui.info('No wallet charge or upload was requested. Server validation and runtime compatibility checks are still required.');
|
|
48
49
|
}
|
|
@@ -62,6 +63,7 @@ export async function buildUpload(filename, flags = {}, deps = {}) {
|
|
|
62
63
|
onPrepared: prepared => {
|
|
63
64
|
progress.stop();
|
|
64
65
|
if (flags.json) return;
|
|
66
|
+
if (prepared.entrypointChosen) ui.info(entrypointChoiceLine({ entrypoint: prepared.entrypoint, reason: prepared.entrypointChosen }));
|
|
65
67
|
ui.info(`Build profile: ${prepared.profileVersion}${flags.profile ? '' : ', the only one the server advertises'}.`);
|
|
66
68
|
ui.info(`ZIP metadata checked: ${prepared.entries} entries; ${ui.bytes(prepared.archiveBytes)} archive, ${ui.bytes(prepared.expandedBytes)} expanded.`);
|
|
67
69
|
const limit = prepared.limits;
|
package/src/commands/hosted.js
CHANGED
|
@@ -4,20 +4,26 @@ 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
|
|
8
|
-
|
|
7
|
+
hostedConsentLines, fundingShortfall, readHostedRun, cancelHostedRun, GERI_PROVIDERS, admitWithCapacityWait,
|
|
8
|
+
resolveHostedIntents } from '../hosted/recordedRun.js';
|
|
9
|
+
import { hostedPlaytestStatus, modeOutcomes, modeLine, TERMINAL_PHASES, queueInfo, queueLine } from '../hosted/status.js';
|
|
9
10
|
import { jobLink } from '../dashboard.js';
|
|
10
11
|
import { DEFAULT_PERSONAS } from '../runDefaults.js';
|
|
11
12
|
|
|
12
13
|
export async function hostedQuote(flags = {}, deps = {}) {
|
|
13
14
|
const context = deps.context || await createContext({ apiUrl: flags.apiUrl, repoRoot: flags.repoRoot, requireAuth: true });
|
|
15
|
+
// The same default as "hosted run", so a quote and a run of the same build
|
|
16
|
+
// match unless a persona is named.
|
|
17
|
+
const persona = flags.persona || DEFAULT_PERSONAS[0];
|
|
14
18
|
return withAuthHandling(context, async () => {
|
|
15
19
|
const result = await quoteHostedRun({ api: context.api, apiUrl: context.api.apiUrl,
|
|
16
20
|
gameId: resolveGameId(flags, context.config), buildId: flags.build, profileVersion: flags.profile,
|
|
17
|
-
persona
|
|
21
|
+
persona,
|
|
22
|
+
standardProvider: flags.geriProvider ? GERI_PROVIDERS[flags.geriProvider] : flags.standardProvider, includeVideo: Boolean(flags.video),
|
|
18
23
|
output: flags.output });
|
|
19
|
-
if (flags.json) ui.json(result);
|
|
24
|
+
if (flags.json) ui.json({ ...result, persona, personaDefaulted: !flags.persona });
|
|
20
25
|
else {
|
|
26
|
+
if (!flags.persona) ui.info(`Persona: ${persona}, the default. Choose another with --persona.`);
|
|
21
27
|
hostedQuoteLines(result).forEach(line => ui.info(line));
|
|
22
28
|
ui.ok(`Saved ${result.quoteFile}. No admission or charge was requested.`);
|
|
23
29
|
}
|
|
@@ -27,21 +33,65 @@ export async function hostedQuote(flags = {}, deps = {}) {
|
|
|
27
33
|
|
|
28
34
|
export async function hostedRun(filename, flags = {}, deps = {}) {
|
|
29
35
|
if (flags.json && !flags.yes && !deps.confirm) throw new CliError('Inspect the saved quote, then use --yes with --json. No admission was requested.');
|
|
36
|
+
const maxWaitMs = capacityWaitMs(flags.waitForCapacity);
|
|
30
37
|
const context = deps.context || await createContext({ apiUrl: flags.apiUrl, repoRoot: flags.repoRoot, requireAuth: true });
|
|
38
|
+
const now = deps.now || Date.now, sleep = deps.sleep || (() => sleepFor(POLL_MS));
|
|
31
39
|
return withAuthHandling(context, async () => {
|
|
32
|
-
const
|
|
40
|
+
const api = context.api, apiUrl = api.apiUrl;
|
|
41
|
+
const result = await runHostedQuote({ filename, api, apiUrl, repoRoot: context.repoRoot, now,
|
|
33
42
|
confirm: deps.confirm || (question => ui.confirm(question, { yes: Boolean(flags.yes) })),
|
|
34
|
-
onPrepared: offer => { if (!flags.json) hostedQuoteLines(offer).forEach(line => ui.info(line)); }
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
onPrepared: offer => { if (!flags.json) hostedQuoteLines(offer).forEach(line => ui.info(line)); },
|
|
44
|
+
admit: admitter(flags, deps, maxWaitMs) });
|
|
45
|
+
if (result.state === 'declined') {
|
|
46
|
+
if (flags.json) ui.json(result); else ui.info('Hosted quote declined. No admission was requested.');
|
|
47
|
+
return ExitCode.CANCELED;
|
|
48
|
+
}
|
|
49
|
+
const { offer: admittedOffer, ...admitted } = result, gameId = admittedOffer.gameId;
|
|
50
|
+
if (!flags.json) {
|
|
51
|
+
ui.ok(`Admission ${admitted.admissionId}; job ${admitted.jobId}. Saved ${admitted.journal}.`);
|
|
52
|
+
admittedLines(admitted, now());
|
|
53
|
+
ui.info(`Check on it with: ravensight-playtest hosted status ${admitted.admissionId}`);
|
|
54
|
+
}
|
|
55
|
+
if (!flags.wait) {
|
|
56
|
+
if (flags.json) ui.json(admitted);
|
|
57
|
+
else ui.info('The server acknowledged charged_blocked. This does not prove a worker started or produced gameplay or reports.');
|
|
58
|
+
return ExitCode.OK;
|
|
40
59
|
}
|
|
41
|
-
|
|
60
|
+
const view = await waitForRun({ api, gameId, admissionId: admitted.admissionId, apiUrl, sleep, now, onPhase: phaseLine(flags) });
|
|
61
|
+
if (flags.json) ui.json({ ...admitted, gameId, status: view });
|
|
62
|
+
else printOutcome(view);
|
|
63
|
+
return exitFor(view);
|
|
42
64
|
});
|
|
43
65
|
}
|
|
44
66
|
|
|
67
|
+
const CAPACITY_WAIT_DEFAULT_MINUTES = 60;
|
|
68
|
+
const CAPACITY_WAIT_MAX_MINUTES = 720;
|
|
69
|
+
|
|
70
|
+
/** --wait-for-capacity [minutes]: true for the default, or whole minutes up to 12 hours. */
|
|
71
|
+
export function capacityWaitMs(value) {
|
|
72
|
+
if (value === undefined || value === false) return null;
|
|
73
|
+
const minutes = value === true ? CAPACITY_WAIT_DEFAULT_MINUTES : Number(value);
|
|
74
|
+
if (!Number.isInteger(minutes) || minutes < 1 || minutes > CAPACITY_WAIT_MAX_MINUTES) {
|
|
75
|
+
throw new CliError(`--wait-for-capacity takes whole minutes from 1 to ${CAPACITY_WAIT_MAX_MINUTES} (default ${CAPACITY_WAIT_DEFAULT_MINUTES}); put a saved quote file before it. Nothing was charged.`);
|
|
76
|
+
}
|
|
77
|
+
return minutes * 60000;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const minutesText = ms => { const m = Math.round(ms / 60000); return m < 1 ? 'under a minute' : `${m} minute${m === 1 ? '' : 's'}`; };
|
|
81
|
+
const delayText = ms => { const s = Math.round(ms / 1000), m = Math.floor(s / 60); return m ? `${m} m ${s % 60} s` : `${s} s`; };
|
|
82
|
+
|
|
83
|
+
/** How an accepted offer is admitted: once, or waiting for capacity when asked. */
|
|
84
|
+
function admitter(flags, deps, maxWaitMs) {
|
|
85
|
+
return async args => {
|
|
86
|
+
if (maxWaitMs === null) return { ...await admitHostedOffer(args), offer: args.offer };
|
|
87
|
+
return admitWithCapacityWait({ ...args, maxWaitMs, sleep: deps.capacitySleep, random: deps.random,
|
|
88
|
+
onBusy: ({ delayMs, waitedMs }) => {
|
|
89
|
+
if (!flags.json) ui.info(`Hosted capacity is busy. No run was started and nothing was charged. Asking again in ${delayText(delayMs)} (waited ${minutesText(waitedMs)} of ${minutesText(maxWaitMs)}).`);
|
|
90
|
+
},
|
|
91
|
+
onRequote: offer => { if (!flags.json) ui.info(`Fresh quote ${offer.quote.quoteId} at the same price, ${dollars(offer.quote.totalPriceCents)}. The earlier attempt charged nothing.`); } });
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
45
95
|
const POLL_MS = 15000;
|
|
46
96
|
const dollars = cents => `$${(cents / 100).toFixed(2)}`;
|
|
47
97
|
const sleepFor = ms => new Promise(resolve => { const timer = setTimeout(resolve, ms); if (timer.unref) timer.unref(); });
|
|
@@ -65,12 +115,13 @@ function statusView(gameId, apiUrl, { admission, job, runs }, now = Date.now())
|
|
|
65
115
|
totalPriceCents: Number.isSafeInteger(admission.totalPriceCents) ? admission.totalPriceCents : null,
|
|
66
116
|
modes: modeOutcomes(runs, Array.isArray(admission.controllers) ? admission.controllers : ['standard', 'jev']),
|
|
67
117
|
summaryReport: job?.summary_report ?? null,
|
|
68
|
-
reportUrl: admission.jobId ? jobLink(gameId, admission.jobId, apiUrl) : null
|
|
118
|
+
reportUrl: admission.jobId ? jobLink(gameId, admission.jobId, apiUrl) : null,
|
|
119
|
+
queue: status.phase === 'queued' ? queueInfo(admission) : null
|
|
69
120
|
};
|
|
70
121
|
}
|
|
71
122
|
|
|
72
|
-
function printOutcome(view) {
|
|
73
|
-
ui.info(`${view.label}. ${view.detail}`);
|
|
123
|
+
function printOutcome(view, now = Date.now()) {
|
|
124
|
+
ui.info(view.queue ? queueLine(view.queue, now) : `${view.label}. ${view.detail}`);
|
|
74
125
|
if (view.failure) ui.info(`Reason: ${view.failure}`);
|
|
75
126
|
if (view.cancelRequested && view.phase !== 'canceled') ui.info('Cancellation was requested.');
|
|
76
127
|
if (TERMINAL_PHASES.includes(view.phase) || view.modes.some(row => row.state !== 'not_started')) view.modes.forEach(row => ui.info(modeLine(row)));
|
|
@@ -84,14 +135,22 @@ const exitFor = view => view.phase === 'canceled' ? ExitCode.CANCELED : view.pha
|
|
|
84
135
|
async function waitForRun({ api, gameId, admissionId, apiUrl, sleep, now, onPhase }) {
|
|
85
136
|
let last = null;
|
|
86
137
|
for (;;) {
|
|
87
|
-
const view = statusView(gameId, apiUrl, await readHostedRun({ api, gameId, admissionId }),
|
|
88
|
-
|
|
138
|
+
const at = now(), view = statusView(gameId, apiUrl, await readHostedRun({ api, gameId, admissionId }), at);
|
|
139
|
+
// In the queue, a new position or estimate is printed too, so the wait is visible.
|
|
140
|
+
const key = view.queue ? queueLine(view.queue, at) : view.phase;
|
|
141
|
+
if (key !== last) { last = key; onPhase(view, at); }
|
|
89
142
|
if (TERMINAL_PHASES.includes(view.phase)) return view;
|
|
90
143
|
await sleep();
|
|
91
144
|
}
|
|
92
145
|
}
|
|
93
146
|
|
|
94
|
-
const phaseLine = flags => row => { if (!flags.json) ui.info(`${row.label}: ${row.detail}`); };
|
|
147
|
+
const phaseLine = flags => (row, at = Date.now()) => { if (!flags.json) ui.info(row.queue ? queueLine(row.queue, at) : `${row.label}: ${row.detail}`); };
|
|
148
|
+
|
|
149
|
+
/** The job id at once, then the queue place when the server gave one. */
|
|
150
|
+
function admittedLines(admitted, now) {
|
|
151
|
+
const line = queueLine(admitted.queue, now);
|
|
152
|
+
if (line) ui.info(line);
|
|
153
|
+
}
|
|
95
154
|
|
|
96
155
|
/**
|
|
97
156
|
* `hosted run` with no saved quote: the newest eligible build (or --build), a
|
|
@@ -100,6 +159,7 @@ const phaseLine = flags => row => { if (!flags.json) ui.info(`${row.label}: ${ro
|
|
|
100
159
|
*/
|
|
101
160
|
export async function hostedRunDirect(flags = {}, deps = {}) {
|
|
102
161
|
if (flags.json && !flags.yes && !deps.confirm) throw new CliError('A hosted run charges prepaid funds. Use --yes with --json. Nothing was charged.');
|
|
162
|
+
const maxWaitMs = capacityWaitMs(flags.waitForCapacity);
|
|
103
163
|
const context = deps.context || await createContext({ apiUrl: flags.apiUrl, repoRoot: flags.repoRoot, requireAuth: true });
|
|
104
164
|
const now = deps.now || Date.now, sleep = deps.sleep || (() => sleepFor(POLL_MS));
|
|
105
165
|
return withAuthHandling(context, async () => {
|
|
@@ -122,13 +182,14 @@ export async function hostedRunDirect(flags = {}, deps = {}) {
|
|
|
122
182
|
else ui.info('Declined. Nothing was charged.');
|
|
123
183
|
return ExitCode.CANCELED;
|
|
124
184
|
}
|
|
125
|
-
const admitted = await
|
|
185
|
+
const { offer: admittedOffer, ...admitted } = await admitter(flags, deps, maxWaitMs)({ offer, api, apiUrl, repoRoot: context.repoRoot, now });
|
|
126
186
|
const reportUrl = jobLink(gameId, admitted.jobId, apiUrl);
|
|
127
187
|
const result = { state: admitted.state, admissionId: admitted.admissionId, jobId: admitted.jobId, gameId, buildId: build.buildId,
|
|
128
|
-
persona: offer.request.personas[0], totalPriceCents: admitted.totalPriceCents, dueNowCents:
|
|
129
|
-
journal: admitted.journal, reportUrl };
|
|
188
|
+
persona: offer.request.personas[0], totalPriceCents: admitted.totalPriceCents, dueNowCents: admittedOffer.quote.dueNowCents,
|
|
189
|
+
journal: admitted.journal, reportUrl, queue: admitted.queue || null };
|
|
130
190
|
if (!flags.json) {
|
|
131
|
-
ui.ok(`Paid ${dollars(
|
|
191
|
+
ui.ok(`Paid ${dollars(admittedOffer.quote.dueNowCents)}. Hosted run ${admitted.admissionId}, job ${admitted.jobId}.`);
|
|
192
|
+
admittedLines(admitted, now());
|
|
132
193
|
ui.info(`Check on it with: ravensight-playtest hosted status ${admitted.admissionId}`);
|
|
133
194
|
}
|
|
134
195
|
if (!flags.wait) {
|
|
@@ -146,16 +207,32 @@ export async function hostedRunDirect(flags = {}, deps = {}) {
|
|
|
146
207
|
export async function hostedStatus(admissionId, flags = {}, deps = {}) {
|
|
147
208
|
const context = deps.context || await createContext({ apiUrl: flags.apiUrl, repoRoot: flags.repoRoot, requireAuth: true });
|
|
148
209
|
const now = deps.now || Date.now, sleep = deps.sleep || (() => sleepFor(POLL_MS));
|
|
210
|
+
if (!admissionId) {
|
|
211
|
+
if (flags.wait) throw new CliError('Name the hosted run to wait for: hosted status <run-id> --wait.');
|
|
212
|
+
return withAuthHandling(context, () => resolvePending(context, flags, now));
|
|
213
|
+
}
|
|
149
214
|
return withAuthHandling(context, async () => {
|
|
150
215
|
const api = context.api, apiUrl = api.apiUrl, gameId = resolveGameId(flags, context.config);
|
|
151
216
|
const view = flags.wait
|
|
152
217
|
? await waitForRun({ api, gameId, admissionId, apiUrl, sleep, now, onPhase: phaseLine(flags) })
|
|
153
218
|
: statusView(gameId, apiUrl, await readHostedRun({ api, gameId, admissionId }), now());
|
|
154
|
-
if (flags.json) ui.json(view); else printOutcome(view);
|
|
219
|
+
if (flags.json) ui.json(view); else printOutcome(view, now());
|
|
155
220
|
return flags.wait ? exitFor(view) : ExitCode.OK;
|
|
156
221
|
});
|
|
157
222
|
}
|
|
158
223
|
|
|
224
|
+
/** "hosted status" with no run id: ask the server about every admission whose outcome is not known locally. */
|
|
225
|
+
async function resolvePending(context, flags, now) {
|
|
226
|
+
const results = await resolveHostedIntents({ api: context.api, apiUrl: context.api.apiUrl, repoRoot: context.repoRoot, now });
|
|
227
|
+
if (flags.json) { ui.json({ intents: results.map(({ message, ...row }) => row) }); }
|
|
228
|
+
else if (!results.length) ui.info('No hosted admission is waiting for an answer. Name a run to see it: ravensight-playtest hosted status <run-id>');
|
|
229
|
+
else for (const row of results) {
|
|
230
|
+
ui.info(row.message);
|
|
231
|
+
if (row.state === 'admitted') ui.info(`Check on it with: ravensight-playtest hosted status ${row.admissionId}`);
|
|
232
|
+
}
|
|
233
|
+
return results.some(row => ['unknown', 'unreadable', 'wait', 'other_api'].includes(row.state)) ? ExitCode.ENVIRONMENT : ExitCode.OK;
|
|
234
|
+
}
|
|
235
|
+
|
|
159
236
|
export async function hostedCancel(admissionId, flags = {}, deps = {}) {
|
|
160
237
|
if (flags.json && !flags.yes && !deps.confirm) throw new CliError('Use --yes with --json to cancel a hosted run. Nothing was canceled.');
|
|
161
238
|
const context = deps.context || await createContext({ apiUrl: flags.apiUrl, repoRoot: flags.repoRoot, requireAuth: true });
|