@threenative/playtest 0.2.0 → 0.3.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.
@@ -0,0 +1,581 @@
1
+ import { IPlaytestObservationSnapshot, IPlaytestSetupRequest, JsonValue, IPlaytestBridgeDescription, IPlaytestBridgeReady, IPlaytestSampleRequest } from '../protocol.js';
2
+ import { b as IPlaytestScenario, s as IPlaytestObservations, r as IPlaytestFramebufferCoverageObservation, j as IPlaytestCaptureProvenance, y as IPlaytestSetupApplication, l as IPlaytestDeviceMetricsObservation, e as IPlaytestDiagnostic, w as IPlaytestProtocolDiagnostic, i as IPlaytestArtifactRequest, v as IPlaytestPointer } from '../diagnostics-D89qJhf0.js';
3
+ import { Page } from 'playwright';
4
+ import { I as IStandalonePlaytestConfig, b as IRunnerConsoleEntry, c as ILabeledPlaytestSample, d as IMovementSampleInterval, a as IStandalonePlaytestReport } from '../shared-Ax3-pneQ.js';
5
+ export { e as IPlaytestFlagHelp, f as IPlaytestServerConfig, g as IRunStepSamples, M as ManagedServerError, P as PLAYTEST_FLAGS, h as PlaytestCliUsageError, i as failedDiagnosticsAssertion, j as formatUsage, p as parseStandalonePlaytestArgs } from '../shared-Ax3-pneQ.js';
6
+ import { ChildProcess } from 'node:child_process';
7
+
8
+ declare function preflightDisplay(config: Pick<IStandalonePlaytestConfig, "headless">, scenario: Pick<IPlaytestScenario, "artifacts" | "assert" | "steps">, environment?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): IPlaytestDiagnostic | undefined;
9
+ declare function buildReport(config: IStandalonePlaytestConfig, scenario: IPlaytestScenario, beforeSnapshot: IPlaytestObservationSnapshot | undefined, afterSnapshot: IPlaytestObservationSnapshot | undefined, consoleEntries: IRunnerConsoleEntry[], networkEntries: Array<{
10
+ method: string;
11
+ url: string;
12
+ }>, pathLength?: number | undefined, hud?: Record<string, {
13
+ after?: unknown;
14
+ before?: unknown;
15
+ }>, runtimeReady?: boolean, visual?: IPlaytestObservations["visual"], labeledSamples?: readonly ILabeledPlaytestSample[], framebufferCoverage?: IPlaytestFramebufferCoverageObservation | undefined, capture?: IPlaytestCaptureProvenance | undefined, captureFailure?: {
16
+ code: "TN_CAPTURE_BLANK";
17
+ label: string;
18
+ reason: string;
19
+ } | undefined, movementSamples?: readonly IMovementSampleInterval[], setup?: IPlaytestSetupApplication | undefined, deviceMetrics?: IPlaytestDeviceMetricsObservation | undefined, movementBaselineSnapshot?: IPlaytestObservationSnapshot | undefined, startup?: IStandalonePlaytestReport["startup"]): IStandalonePlaytestReport;
20
+
21
+ /** The only seam between assertion orchestration and an application bridge. */
22
+ interface IBridgeTransport {
23
+ readonly capabilities: readonly string[];
24
+ call<T>(method: string, argument?: unknown, timeoutMs?: number): Promise<T>;
25
+ close(): Promise<void>;
26
+ waitForBridge(timeoutMs: number): Promise<boolean>;
27
+ }
28
+ /**
29
+ * The budget for one `advance` call: the round-trip allowance plus time for the ticks themselves.
30
+ *
31
+ * Every other bridge method is a request and a reply, so `operationTimeoutMs` fits. `advance` runs
32
+ * the game loop N times before replying, so its honest bound grows with N. Fixed at 5 s it failed
33
+ * `starter-game-over` — 600 ticks in one call — on a two-core runner, and reported it as
34
+ * `TN_PLAYTEST_OPERATION_TIMEOUT`, which reads as a hung page rather than a slow one.
35
+ */
36
+ declare function advanceTimeoutMs(ticks: number, perTickMs?: number): number;
37
+ declare class PlaytestBridgeError extends Error {
38
+ readonly diagnostic: IPlaytestProtocolDiagnostic;
39
+ constructor(diagnostic: IPlaytestProtocolDiagnostic);
40
+ }
41
+ interface IPlaytestBridgeClient {
42
+ advance(ticks: number): Promise<void>;
43
+ applySetup(request: IPlaytestSetupRequest): Promise<void>;
44
+ close(): Promise<void>;
45
+ drainEvents(limit?: number): Promise<JsonValue[]>;
46
+ description: IPlaytestBridgeDescription;
47
+ /** Re-reads the bridge's readiness, including startup progress when it reports any. */
48
+ readiness(): Promise<IPlaytestBridgeReady>;
49
+ sample(request: IPlaytestSampleRequest): Promise<IPlaytestObservationSnapshot>;
50
+ }
51
+ declare class PlaywrightTransport implements IBridgeTransport {
52
+ private readonly page;
53
+ private readonly operationTimeoutMs;
54
+ readonly capabilities: readonly ["browser.canvas", "browser.console", "browser.dom", "browser.input", "browser.network", "browser.screenshot", "browser.trace", "runtime.diagnostics", "runtime.ui"];
55
+ constructor(page: Page, operationTimeoutMs?: number);
56
+ call<T>(method: string, argument?: unknown, timeoutMs?: number): Promise<T>;
57
+ close(): Promise<void>;
58
+ waitForBridge(timeoutMs: number): Promise<boolean>;
59
+ }
60
+ declare function connectPlaytestBridge(page: Page, scenario: IPlaytestScenario, timeoutMs?: number): Promise<IPlaytestBridgeClient | undefined>;
61
+ /**
62
+ * How long to wait for the page to install its playtest bridge.
63
+ *
64
+ * The bridge appears during application startup, not during a request/response round trip, so
65
+ * `operationTimeoutMs` is the wrong budget for it by construction — the same mistake, in the same
66
+ * direction, as timing a bulk `advance` with it. On a software-rendered two-core runner the
67
+ * scaffolded starter spends seconds in first-use compilation before the bridge exists, and the run
68
+ * was reported as `TN_PLAYTEST_BRIDGE_MISSING` with `frames: 0`: not a page without a bridge, a
69
+ * page that had not finished booting yet.
70
+ *
71
+ * One operation plus the startup budget, matching `advanceTimeoutMs`. A page that genuinely
72
+ * installs no bridge still fails with the same diagnostic, just later.
73
+ */
74
+ declare function bridgeWaitTimeoutMs(operationMs?: number): number;
75
+ declare function connectPlaytestBridgeTransport(transport: IBridgeTransport, scenario: IPlaytestScenario, timeoutMs?: number): Promise<IPlaytestBridgeClient | undefined>;
76
+
77
+ /** Capture the largest rendered canvas without composited DOM overlays. */
78
+ declare function captureVisualSurface(page: Page, artifactPath?: string): Promise<Buffer | undefined>;
79
+ /**
80
+ * The core bridge is installed before an async scene load completes, so its describe/ready
81
+ * handshake can finish one browser frame before the fixed-step loop starts. Retry only that
82
+ * exact startup race; a stopped loop that does not recover remains a runner failure.
83
+ */
84
+ declare function advanceFixedStep(page: Page, bridge: Pick<IPlaytestBridgeClient, "advance">, ticks: number): Promise<void>;
85
+ declare function playtestStepDrivesMovement(step: IPlaytestScenario["steps"][number], hasHeldInput: boolean): boolean;
86
+
87
+ /**
88
+ * A published diagnostic that is unmistakably a *readout* rather than an error.
89
+ *
90
+ * The bridge's `diagnostics` channel is typed `() => JsonValue[]` and the generated project
91
+ * AGENTS.md says it "returns current runtime diagnostics", so a game publishes its debug HUD
92
+ * through it — that is the documented use. Every entry then landed in `recentRuntimeErrors`, and
93
+ * a proof with `noRuntimeDiagnostics` failed the build for owning a frame counter. Round 9 lost
94
+ * a sealed scenario to `{id:"fps",label:"FPS",value:30}` being counted as a runtime error.
95
+ *
96
+ * This does **not** guess. Ambiguous entries stay errors, because this package fails closed and
97
+ * an error counter that quietly stops counting is the exact defect it exists to prevent. Only
98
+ * the unambiguous readout shape — a labelled scalar, carrying no error marker — is reclassified,
99
+ * and nothing is dropped: readouts move to `runtimeReadouts` on the same object and stay observable.
100
+ */
101
+ declare function isRuntimeReadout(entry: unknown): boolean;
102
+
103
+ declare function resolveManagedServerCommand(config: IStandalonePlaytestConfig, dynamicPort?: number): string;
104
+ declare function substituteManagedPort(command: string, port: number): string;
105
+ /**
106
+ * Await one teardown step, but never longer than `timeoutMs`. Returns true when the step
107
+ * finished (or there was nothing to do) and false when it ran out of time, so the caller can
108
+ * escalate. Teardown runs after the report is written, so a step that hangs costs the process
109
+ * its exit rather than costing the run its result.
110
+ */
111
+ declare function boundedTeardownStep(step: Promise<unknown> | undefined, timeoutMs: number): Promise<boolean>;
112
+ interface IPageLifecycle {
113
+ closed: boolean;
114
+ crashed: boolean;
115
+ /** Every main-frame navigation, including the run's own initial one. */
116
+ frameNavigations: string[];
117
+ /** Main-frame navigations after the handshake settled — the ones that break a run. */
118
+ navigations: string[];
119
+ settled: boolean;
120
+ /** The last console lines before the failure, which is where a device loss announces itself. */
121
+ tail: string[];
122
+ }
123
+ /**
124
+ * Playwright reports a crashed renderer and a navigated document with the same
125
+ * "Execution context was destroyed" message, and the two have opposite fixes: a crash is an
126
+ * environment or content problem, a navigation is the page moving under the run. The listeners
127
+ * on the page record which one happened, so the report names it rather than falling through to
128
+ * the unexplained-error catch-all. Returns undefined when the error is neither, leaving it to
129
+ * propagate untouched.
130
+ */
131
+ declare function pageLifecycleDiagnostic(error: unknown, lifecycle: IPageLifecycle, url: string): IPlaytestProtocolDiagnostic | undefined;
132
+ /**
133
+ * Navigate and complete the bridge handshake, re-navigating when the page reloads itself
134
+ * before the handshake finishes. This never retries past the handshake: no observation has
135
+ * been taken and no assertion has been evaluated yet, so a reattempt cannot hide a failure.
136
+ * A bridge that is genuinely missing or incompatible still fails on its own diagnostic, and
137
+ * an exhausted retry budget fails closed on TN_PLAYTEST_PAGE_NAVIGATED rather than passing.
138
+ */
139
+ declare function openPageAndConnectBridge(page: Page, config: IStandalonePlaytestConfig, scenario: IPlaytestScenario): Promise<IPlaytestBridgeClient | undefined>;
140
+
141
+ declare const STANDALONE_PLAYTEST_OBSERVATION_FIELDS: readonly ["components", "componentSeries", "console", "effectLogBefore", "framebufferCoverage", "hud", "network", "physicsDebugSeries", "performanceSeries", "renderChain", "physicsDebugBefore", "resources", "resourceSeries", "runtimeDiagnostics", "runtimeDiagnosticsBefore", "runtimeObservations", "signals", "signalSeries", "visual"];
142
+
143
+ declare function handlePlaytestSignal(teardown: (stopManagedServer: boolean) => Promise<void>, setExitCode?: (code: number) => void, exit?: (code: number) => void, target?: string, writeMessage?: (message: string) => void): Promise<void>;
144
+ declare function writeCaptureProvenance(artifactDirectory: string, provenance: IPlaytestCaptureProvenance): Promise<void>;
145
+ /**
146
+ * Diagnostics name `console.json` and `runtime-trace.json`, and `artifacts.console`,
147
+ * `artifacts.network` and `artifacts.runtimeTrace` accept a request for them. Neither was
148
+ * written: a build hitting TN_PLAYTEST_CONSOLE_ERROR found the artifact directory holding
149
+ * only `after.png` and `capture.json`, and had to reconstruct the errors from provenance.
150
+ * A message that names a file the runner never writes sends the reader somewhere empty, so
151
+ * write each one whenever it has content or was asked for.
152
+ */
153
+ declare function writeObservationArtifacts(artifactDirectory: string, requested: IPlaytestArtifactRequest | undefined, observations: {
154
+ console: readonly unknown[];
155
+ network: readonly unknown[];
156
+ runtimeTrace: {
157
+ readonly recentRuntimeErrors?: readonly unknown[];
158
+ readonly [key: string]: unknown;
159
+ } | undefined;
160
+ }): Promise<readonly string[]>;
161
+ interface IStandalonePlaytestRunOptions {
162
+ managedServer?: ChildProcess;
163
+ }
164
+ declare function runStandalonePlaytest(config: IStandalonePlaytestConfig, options?: IStandalonePlaytestRunOptions): Promise<IStandalonePlaytestReport>;
165
+ declare function runStandalonePlaytests(config: IStandalonePlaytestConfig): Promise<readonly IStandalonePlaytestReport[]>;
166
+ declare function batchArtifactDirectory(base: string, scenarioPath: string, index: number): string;
167
+ declare function resolveManagedServerConfig(config: IStandalonePlaytestConfig): Promise<IStandalonePlaytestConfig>;
168
+
169
+ declare const WEBGPU_BROWSER_ARGS: readonly ["--ozone-platform=x11", "--enable-unsafe-webgpu", "--disable-gpu-sandbox", "--ignore-gpu-blocklist", "--enable-features=Vulkan"];
170
+ /** Allow performance probes to sample render work instead of Xvfb's compositor cadence. */
171
+ declare const PERFORMANCE_BROWSER_ARGS: readonly ["--disable-frame-rate-limit", "--disable-gpu-vsync"];
172
+ declare function resolveBrowserArguments(browserArgs: readonly string[] | undefined): string[];
173
+ /**
174
+ * Name a software adapter from what `adapter.info` reported. Every field is searched because
175
+ * which one carries the giveaway depends on the platform: Linux Dawn puts `swiftshader` in
176
+ * `architecture`, Mesa reports `llvmpipe` in `description`, and a headless Windows run says
177
+ * `Microsoft Basic Render Driver` in `device`.
178
+ */
179
+ declare function softwareAdapterName(adapter: Readonly<Record<string, string>> | undefined): string | undefined;
180
+ interface IBrowserPointerChange {
181
+ isPrimary: boolean;
182
+ pointer: Required<IPlaytestPointer>;
183
+ type: "pointerdown" | "pointermove" | "pointerup";
184
+ }
185
+ declare function reconcileBrowserPointers(previous: ReadonlyMap<number, Required<IPlaytestPointer>>, next: readonly IPlaytestPointer[]): IBrowserPointerChange[];
186
+
187
+ interface IAndroidDriverOptions {
188
+ activity: string;
189
+ adbPath?: string;
190
+ packageName: string;
191
+ serial?: string;
192
+ /**
193
+ * The rotation between the touchscreen's raw axes and the frame the app draws in, when the
194
+ * device cannot be asked.
195
+ *
196
+ * Normally this is read from the window — `dumpsys window`'s `mRotation`, inverted, and then
197
+ * `dumpsys input`'s `SurfaceOrientation` and the `user_rotation` setting behind it. Those two
198
+ * older sources are why this option exists: an orientation-locked game on a device whose
199
+ * display never rotated reads 0 from both while its window is turned 90° from the panel, so an
200
+ * injected touch lands somewhere else entirely and every input assertion fails for a reason
201
+ * that has nothing to do with the game.
202
+ *
203
+ * Set explicitly to make such a run reproducible, and say so in the evidence. Fails closed on
204
+ * anything but 0, 1, 2 or 3.
205
+ */
206
+ touchRotation?: number;
207
+ }
208
+ interface IAndroidDriver {
209
+ captureConsole(): Promise<Array<{
210
+ text: string;
211
+ type: string;
212
+ }>>;
213
+ /** The device this driver is bound to, when it knows; reported next to its metric samples. */
214
+ deviceSerial?(): string | undefined;
215
+ isAlive(): Promise<boolean>;
216
+ prepare(endpoint: string, mailboxRoot?: string, viewport?: {
217
+ height: number;
218
+ width: number;
219
+ }): Promise<void>;
220
+ readFile?(path: string): Promise<string | undefined>;
221
+ removeFile?(path: string): Promise<void>;
222
+ /** Raw adb passthrough, so the host can measure the device itself. Read-only probes only. */
223
+ runAdb?(args: readonly string[]): Promise<string>;
224
+ screenshot(path: string): Promise<void>;
225
+ setPointers?(pointers: readonly IAndroidPointer[]): Promise<IAndroidPointerInjection>;
226
+ startScreenRecording?(): Promise<void>;
227
+ /** One OS tap in viewport pixels. Works on emulators and physical devices alike. */
228
+ tap?(x: number, y: number): Promise<void>;
229
+ /** Put the soft keyboard away, and report whether one was up. */
230
+ hideKeyboard?(): Promise<boolean>;
231
+ stop(): Promise<void>;
232
+ stopScreenRecording?(path: string): Promise<void>;
233
+ writeFile?(path: string, contents: string): Promise<void>;
234
+ }
235
+ interface IAndroidPointer {
236
+ buttons?: number;
237
+ id: number;
238
+ x: number;
239
+ y: number;
240
+ }
241
+ interface IAndroidPointerInjection {
242
+ activeIds: number[];
243
+ injection: "adb-emu-event-protocol-b";
244
+ rotation: number;
245
+ trackingIds: number[];
246
+ }
247
+ declare class AdbAndroidDriver implements IAndroidDriver {
248
+ private readonly options;
249
+ private static readonly COVERAGE_VIDEO_PATH;
250
+ private readonly adbPath;
251
+ private screenrecord?;
252
+ private screenrecordError?;
253
+ private readonly touchSlots;
254
+ private nextTrackingId;
255
+ private rotation?;
256
+ private viewportPresented;
257
+ constructor(options: IAndroidDriverOptions);
258
+ prepare(endpoint: string, mailboxRoot?: string, viewport?: {
259
+ height: number;
260
+ width: number;
261
+ }): Promise<void>;
262
+ /**
263
+ * Put the device into the scenario's viewport, and fail closed if it did not take.
264
+ *
265
+ * A silent failure here is the expensive one: the run continues, the touches arrive, the
266
+ * assertions go red, and the report blames the game for a device that was never showing the
267
+ * viewport the scenario asked for.
268
+ */
269
+ private presentViewport;
270
+ tap(x: number, y: number): Promise<void>;
271
+ /**
272
+ * Dismiss the soft keyboard and wait for it to actually be gone.
273
+ *
274
+ * Measured on the physical Pixel 8: focusing a text field opens the IME, the WebView reflows
275
+ * into the space left above it, and the page's centred menu rides up — so a coordinate computed
276
+ * against the scenario's viewport now points at the keyboard. A tap there does not merely miss
277
+ * the control; it types a character into the field it meant to submit.
278
+ *
279
+ * BACK is the dismissal the platform guarantees. The wait is the point: the reflow happens on
280
+ * the next layout pass, and a click sent into the middle of it lands wherever the menu was
281
+ * halfway through moving.
282
+ */
283
+ hideKeyboard(): Promise<boolean>;
284
+ captureConsole(): Promise<Array<{
285
+ text: string;
286
+ type: string;
287
+ }>>;
288
+ screenshot(path: string): Promise<void>;
289
+ startScreenRecording(): Promise<void>;
290
+ stopScreenRecording(path: string): Promise<void>;
291
+ isAlive(): Promise<boolean>;
292
+ setPointers(pointers: readonly IAndroidPointer[]): Promise<IAndroidPointerInjection>;
293
+ readFile(path: string): Promise<string | undefined>;
294
+ removeFile(path: string): Promise<void>;
295
+ stop(): Promise<void>;
296
+ private readRotation;
297
+ writeFile(path: string, contents: string): Promise<void>;
298
+ deviceSerial(): string | undefined;
299
+ /**
300
+ * The device-metrics probes read `dumpsys`, `logcat` and sysfs through here. Deliberately a
301
+ * thin passthrough rather than a metrics API: the parsing belongs to deviceMetrics.ts, which
302
+ * is unit-tested against real captured device output.
303
+ */
304
+ runAdb(args: readonly string[]): Promise<string>;
305
+ private adb;
306
+ private waitForScreenRecorder;
307
+ private abortScreenRecording;
308
+ private serialArgs;
309
+ }
310
+ declare function parseAndroidConsole(output: string): Array<{
311
+ text: string;
312
+ type: string;
313
+ }>;
314
+ /**
315
+ * Splits slot identity from coordinates into separate synced `adb emu event send` batches.
316
+ *
317
+ * The emulator console drops ABS_MT_POSITION_X/Y from any batch that also carries an
318
+ * ABS_MT_TRACKING_ID: the command reports `OK` and the coordinates never reach the device, so
319
+ * every contact lands at (0, 0) and a two-finger gesture reads as two touches in the same
320
+ * screen half — the exact failure that made the simultaneous-touch proof unprovable.
321
+ * Confirmed against `getevent -lt /dev/input/event2` on emulator 36.6.11 with the android-35
322
+ * google_apis image. Identity goes first so a slot exists before it is positioned.
323
+ */
324
+ declare function androidTouchBatches(identity: readonly string[], positions: readonly string[]): string[][];
325
+ /**
326
+ * The touch rotation for the window `dumpsys window` just described, or `undefined`.
327
+ *
328
+ * `mRotation` says how far the window's content is turned from the panel's natural frame.
329
+ * {@link rotatedTouchPosition} converts the other way — a point in that content back to the
330
+ * panel's raw axes — so the value it needs is the inverse, and handing it `mRotation` directly
331
+ * is a 180-degree error on either odd rotation.
332
+ *
333
+ * This is the source of truth because it describes the *window*. `dumpsys input`'s
334
+ * `SurfaceOrientation` is absent on the emulator, and `user_rotation` is the user's preference:
335
+ * an orientation-locked game on a device the user never turned reads 0 there while its window
336
+ * is turned 90 degrees off the panel, so every injected touch lands somewhere else.
337
+ */
338
+ declare function touchRotationFromWindowDump(dump: string): number | undefined;
339
+ /**
340
+ * Make the device present a scenario's declared viewport, one device pixel per CSS pixel.
341
+ *
342
+ * A scenario's `viewport` is a declared test condition, and the browser target honours it by
343
+ * sizing the window. Without the same courtesy here, a UI page lays out at whatever CSS viewport
344
+ * the device's density happens to give — 914x411 on a 2400x1080 panel at 420dpi — and a step
345
+ * that names a point in viewport pixels lands on whatever the device's own layout put there.
346
+ * Nothing about that failure looks like a coordinate problem: the touch arrives, the host
347
+ * hit-tests it honestly, and the control simply is not where the scenario said.
348
+ *
349
+ * Density 160 is the whole mechanism: it makes `devicePixelRatio` 1, so a viewport pixel, a CSS
350
+ * pixel and a device pixel are the same pixel and the page lays out exactly as it does on web.
351
+ * The size is written in the panel's natural frame, which is why it is transposed for the
352
+ * portrait-natural devices every phone and emulator here happens to be.
353
+ */
354
+ declare function viewportPresentationCommands(viewport: {
355
+ height: number;
356
+ width: number;
357
+ }, physical: {
358
+ height: number;
359
+ width: number;
360
+ }): string[][];
361
+ /**
362
+ * One OS-level tap, in the display's current orientation.
363
+ *
364
+ * With the viewport presented, that orientation *is* the scenario's viewport and the coordinate
365
+ * needs no rotation — which is the second reason to prefer this over the emulator's pointer
366
+ * protocol. The first is that `adb emu event send` exists only on emulators, and a click step
367
+ * that only works on an emulator is a click step that does not work.
368
+ */
369
+ declare function tapCommand(x: number, y: number): string[];
370
+ /** Whether an input method window is on screen, from `dumpsys input_method`. */
371
+ declare function keyboardIsShown(dump: string): boolean;
372
+ /**
373
+ * Undo the presentation.
374
+ *
375
+ * `reset` and never the numbers read beforehand: a run that crashed between reading and writing
376
+ * would restore a size it had already replaced, and leave the device quietly wrong for whoever
377
+ * measures on it next.
378
+ */
379
+ declare function viewportRestoreCommands(): string[][];
380
+ declare function rotatedTouchPosition(x: number, y: number, rotation: number): [number, number];
381
+ declare function discoverAdb(environment?: NodeJS.ProcessEnv): string;
382
+
383
+ declare const ANDROID_TRANSPORT_CAPABILITIES: readonly ["browser.console", "browser.input", "browser.screenshot", "device.metrics", "runtime.diagnostics"];
384
+ interface IDeviceMailbox {
385
+ read(path: string): Promise<string | undefined>;
386
+ remove(path: string): Promise<void>;
387
+ write(path: string, contents: string): Promise<void>;
388
+ }
389
+ interface IDeviceMailboxPaths {
390
+ request: string;
391
+ response: string;
392
+ }
393
+ interface IDevicePlaytestTransport extends IBridgeTransport {
394
+ start(): Promise<void>;
395
+ }
396
+ declare class DeviceBridgeTransport implements IDevicePlaytestTransport {
397
+ readonly capabilities: readonly ["browser.console", "browser.input", "browser.screenshot", "device.metrics", "runtime.diagnostics"];
398
+ readonly endpoint: URL;
399
+ private connected;
400
+ private nextId;
401
+ private readonly pending;
402
+ private readonly queue;
403
+ private server?;
404
+ private waiters;
405
+ constructor(endpoint: string);
406
+ start(): Promise<void>;
407
+ call<T>(method: string, argument?: unknown): Promise<T>;
408
+ close(): Promise<void>;
409
+ waitForBridge(timeoutMs: number): Promise<boolean>;
410
+ private handle;
411
+ private markConnected;
412
+ }
413
+ declare class DeviceMailboxTransport implements IDevicePlaytestTransport {
414
+ private readonly mailbox;
415
+ private readonly paths;
416
+ private readonly operationTimeoutMs;
417
+ readonly capabilities: readonly ["browser.console", "browser.input", "browser.screenshot", "device.metrics", "runtime.diagnostics"];
418
+ private connected;
419
+ private closed;
420
+ private nextId;
421
+ constructor(mailbox: IDeviceMailbox, paths: IDeviceMailboxPaths, operationTimeoutMs?: number);
422
+ start(): Promise<void>;
423
+ call<T>(method: string, argument?: unknown): Promise<T>;
424
+ close(): Promise<void>;
425
+ waitForBridge(timeoutMs: number): Promise<boolean>;
426
+ private waitForResponse;
427
+ private readResponse;
428
+ }
429
+ declare function androidMailboxPaths(packageName: string, root?: string): IDeviceMailboxPaths;
430
+ /**
431
+ * Names what stopped answering when an operation times out (PRD-167).
432
+ *
433
+ * A timed-out operation is ambiguous between two failures with different owners: a host whose
434
+ * process died mid-run, and a live host whose mailbox stopped polling. When the driver can prove
435
+ * the process exited, the diagnostic says so and carries the host's last console lines — a crash
436
+ * message must not be hidden behind a generic timeout.
437
+ */
438
+ declare function deviceTimeoutDiagnostic(diagnostic: IPlaytestProtocolDiagnostic, hostAlive: boolean | undefined, lastConsoleLines: readonly string[]): IPlaytestProtocolDiagnostic;
439
+ declare function deviceMailboxPaths(root: string): IDeviceMailboxPaths;
440
+ declare function validateDeviceEndpoint(value: string): URL;
441
+
442
+ interface IAndroidPlaytestDependencies {
443
+ abortSignal?: AbortSignal;
444
+ driver?: IAndroidDriver;
445
+ transport?: IDevicePlaytestTransport;
446
+ }
447
+ interface IDevicePlaytestDriver {
448
+ captureConsole(): Promise<Array<{
449
+ text: string;
450
+ type: string;
451
+ }>>;
452
+ deviceSerial?(): string | undefined;
453
+ isAlive(): Promise<boolean>;
454
+ prepare(endpoint: string, mailboxRoot?: string, viewport?: {
455
+ height: number;
456
+ width: number;
457
+ }): Promise<void>;
458
+ readFile?(path: string): Promise<string | undefined>;
459
+ removeFile?(path: string): Promise<void>;
460
+ runAdb?(args: readonly string[]): Promise<string>;
461
+ screenshot(path: string): Promise<void>;
462
+ setPointers?(pointers: readonly IAndroidPointer[]): Promise<IAndroidPointerInjection>;
463
+ tap?(x: number, y: number): Promise<void>;
464
+ hideKeyboard?(): Promise<boolean>;
465
+ startScreenRecording?(): Promise<void>;
466
+ stop(): Promise<void>;
467
+ stopScreenRecording?(path: string): Promise<void>;
468
+ writeFile?(path: string, contents: string): Promise<void>;
469
+ }
470
+ interface IDevicePlaytestTarget {
471
+ abortCleanup?: () => Promise<void>;
472
+ abortSignal?: AbortSignal;
473
+ driver: IDevicePlaytestDriver;
474
+ mailboxPaths: ReturnType<typeof androidMailboxPaths>;
475
+ name: "android" | "desktop" | "ios";
476
+ processName: string;
477
+ transport?: IDevicePlaytestTransport;
478
+ }
479
+ declare function runAndroidPlaytest(config: IStandalonePlaytestConfig, dependencies?: IAndroidPlaytestDependencies): Promise<IStandalonePlaytestReport>;
480
+ declare function runDevicePlaytest(config: IStandalonePlaytestConfig, target: IDevicePlaytestTarget): Promise<IStandalonePlaytestReport>;
481
+
482
+ interface IDesktopPlaytestDriverOptions {
483
+ args?: readonly string[];
484
+ cwd?: string;
485
+ env?: NodeJS.ProcessEnv;
486
+ executable: string;
487
+ mailboxRoot?: string;
488
+ screenshotTimeoutMs?: number;
489
+ }
490
+ /** A local mailbox implementation with atomic request writes. */
491
+ declare class LocalDeviceMailbox {
492
+ read(path: string): Promise<string | undefined>;
493
+ remove(path: string): Promise<void>;
494
+ write(path: string, contents: string): Promise<void>;
495
+ }
496
+ /**
497
+ * Launches a packaged native desktop game and exposes the same driver contract as device runs.
498
+ * The native runtime consumes TN_PLAYTEST_MAILBOX_ROOT before it evaluates the game entry.
499
+ */
500
+ declare class DesktopPlaytestDriver implements IDevicePlaytestDriver {
501
+ private readonly options;
502
+ private child?;
503
+ private mailboxRoot?;
504
+ private readonly consoleEntries;
505
+ private readonly pendingOutput;
506
+ constructor(options: IDesktopPlaytestDriverOptions);
507
+ captureConsole(): Promise<Array<{
508
+ text: string;
509
+ type: string;
510
+ }>>;
511
+ isAlive(): Promise<boolean>;
512
+ prepare(_endpoint: string, mailboxRoot?: string): Promise<void>;
513
+ screenshot(path: string): Promise<void>;
514
+ stop(): Promise<void>;
515
+ private recordOutput;
516
+ private flushOutput;
517
+ }
518
+
519
+ interface IDesktopPlaytestDependencies {
520
+ driver?: IDevicePlaytestDriver;
521
+ mailboxRoot?: string;
522
+ transport?: IDevicePlaytestTransport;
523
+ }
524
+ declare function runDesktopPlaytest(config: IStandalonePlaytestConfig, dependencies?: IDesktopPlaytestDependencies): Promise<IStandalonePlaytestReport>;
525
+
526
+ declare function initStandalonePlaytest(projectPath?: string): Promise<{
527
+ created: string[];
528
+ }>;
529
+
530
+ type IosTransportKind = "device" | "simulator";
531
+ interface IIosDriverOptions {
532
+ appPath: string;
533
+ bundleId: string;
534
+ device?: string;
535
+ transport: IosTransportKind;
536
+ xcrunPath?: string;
537
+ }
538
+ interface IIosCommandOptions {
539
+ env?: NodeJS.ProcessEnv;
540
+ }
541
+ type IRunIosCommand = (args: readonly string[], options?: IIosCommandOptions) => Promise<string>;
542
+ declare class XcrunIosDriver implements IDevicePlaytestDriver {
543
+ private readonly options;
544
+ private readonly run;
545
+ private mailboxRoot?;
546
+ private pid?;
547
+ private suppressedResponse?;
548
+ constructor(options: IIosDriverOptions, run?: IRunIosCommand);
549
+ prepare(endpoint: string, mailboxRoot?: string): Promise<void>;
550
+ captureConsole(): Promise<Array<{
551
+ text: string;
552
+ type: string;
553
+ }>>;
554
+ isAlive(): Promise<boolean>;
555
+ screenshot(path: string): Promise<void>;
556
+ readFile(path: string): Promise<string | undefined>;
557
+ removeFile(path: string): Promise<void>;
558
+ stop(): Promise<void>;
559
+ writeFile(path: string, contents: string): Promise<void>;
560
+ getMailboxRoot(): string;
561
+ private prepareSimulator;
562
+ private prepareDevice;
563
+ private device;
564
+ private processName;
565
+ private mailboxPath;
566
+ }
567
+ declare function parseLaunchedPid(output: string): string;
568
+
569
+ interface IIosPlaytestDependencies {
570
+ abortSignal?: AbortSignal;
571
+ driver?: IDevicePlaytestDriver & {
572
+ getMailboxRoot?(): string;
573
+ };
574
+ transport?: IDevicePlaytestTransport;
575
+ }
576
+ declare function runIosPlaytest(config: IStandalonePlaytestConfig, dependencies?: IIosPlaytestDependencies): Promise<IStandalonePlaytestReport>;
577
+
578
+ declare function requireAssertions(value: IPlaytestScenario["assert"], scenarioPath: string): NonNullable<IPlaytestScenario["assert"]>;
579
+ declare function recordToScenario(value: unknown, scenarioPath?: string, oracleValue?: unknown): IPlaytestScenario;
580
+
581
+ export { ANDROID_TRANSPORT_CAPABILITIES, AdbAndroidDriver, DesktopPlaytestDriver, DeviceBridgeTransport, DeviceMailboxTransport, type IAndroidDriver, type IAndroidDriverOptions, type IAndroidPlaytestDependencies, type IAndroidPointer, type IAndroidPointerInjection, type IBridgeTransport, type IBrowserPointerChange, type IDesktopPlaytestDependencies, type IDesktopPlaytestDriverOptions, type IDeviceMailbox, type IDeviceMailboxPaths, type IDevicePlaytestDriver, type IDevicePlaytestTarget, type IDevicePlaytestTransport, type IIosCommandOptions, type IIosDriverOptions, type IIosPlaytestDependencies, ILabeledPlaytestSample, IMovementSampleInterval, type IPlaytestBridgeClient, type IRunIosCommand, IRunnerConsoleEntry, IStandalonePlaytestConfig, IStandalonePlaytestReport, type IStandalonePlaytestRunOptions, type IosTransportKind, LocalDeviceMailbox, PERFORMANCE_BROWSER_ARGS, PlaytestBridgeError, PlaywrightTransport, STANDALONE_PLAYTEST_OBSERVATION_FIELDS, WEBGPU_BROWSER_ARGS, XcrunIosDriver, advanceFixedStep, advanceTimeoutMs, androidMailboxPaths, androidTouchBatches, batchArtifactDirectory, boundedTeardownStep, bridgeWaitTimeoutMs, buildReport, captureVisualSurface, connectPlaytestBridge, connectPlaytestBridgeTransport, deviceMailboxPaths, deviceTimeoutDiagnostic, discoverAdb, handlePlaytestSignal, initStandalonePlaytest, isRuntimeReadout, keyboardIsShown, openPageAndConnectBridge, pageLifecycleDiagnostic, parseAndroidConsole, parseLaunchedPid, playtestStepDrivesMovement, preflightDisplay, reconcileBrowserPointers, recordToScenario, requireAssertions, resolveBrowserArguments, resolveManagedServerCommand, resolveManagedServerConfig, rotatedTouchPosition, runAndroidPlaytest, runDesktopPlaytest, runDevicePlaytest, runIosPlaytest, runStandalonePlaytest, runStandalonePlaytests, softwareAdapterName, substituteManagedPort, tapCommand, touchRotationFromWindowDump, validateDeviceEndpoint, viewportPresentationCommands, viewportRestoreCommands, writeCaptureProvenance, writeObservationArtifacts };