@slack/radar-mcp 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +24 -7
  2. package/dist/mcp/flags-tools.d.ts +14 -9
  3. package/dist/mcp/flags-tools.js +70 -20
  4. package/dist/mcp/index.js +17 -10
  5. package/dist/mcp/platform-detect.d.ts +2 -0
  6. package/dist/mcp/platform-detect.js +2 -0
  7. package/dist/mcp/tools.js +4 -3
  8. package/dist/mcp/web-child-env.d.ts +1 -0
  9. package/dist/mcp/web-child-env.js +32 -0
  10. package/dist/shared/android-dashboard-screen.d.ts +15 -0
  11. package/dist/shared/android-dashboard-screen.js +48 -0
  12. package/dist/shared/android.d.ts +50 -0
  13. package/dist/shared/android.js +248 -35
  14. package/dist/shared/dashboard-screen.d.ts +35 -0
  15. package/dist/shared/dashboard-screen.js +12 -0
  16. package/dist/shared/ios-dashboard-screen.d.ts +32 -0
  17. package/dist/shared/ios-dashboard-screen.js +266 -0
  18. package/dist/shared/ios.d.ts +72 -0
  19. package/dist/shared/ios.js +313 -0
  20. package/dist/shared/platform.d.ts +3 -0
  21. package/dist/shared/platform.js +16 -0
  22. package/dist/shared/screen-artifacts.d.ts +10 -0
  23. package/dist/shared/screen-artifacts.js +57 -0
  24. package/dist/shared/screen.d.ts +20 -5
  25. package/dist/shared/screen.js +35 -39
  26. package/dist/shared/transport.d.ts +38 -0
  27. package/dist/shared/webapp.d.ts +1 -0
  28. package/dist/shared/webapp.js +2 -0
  29. package/dist/web/bin.js +5 -1
  30. package/dist/web/public/index.html +51 -11
  31. package/dist/web/public/next/app.js +16 -4
  32. package/dist/web/public/next/db.js +292 -39
  33. package/dist/web/public/next/flags.js +306 -48
  34. package/dist/web/public/next/registry.js +18 -10
  35. package/dist/web/public/next/screen.js +76 -11
  36. package/dist/web/public/next/store.js +280 -36
  37. package/dist/web/server.d.ts +26 -3
  38. package/dist/web/server.js +397 -179
  39. package/package.json +3 -2
@@ -1,7 +1,8 @@
1
- import { execSync, execFileSync } from "child_process";
1
+ import { execFile, execSync, execFileSync } from "child_process";
2
2
  import fs from "fs";
3
3
  import os from "os";
4
4
  import path from "path";
5
+ import { promisify } from "util";
5
6
  import { readDebugLogBuffer } from "./debug-log.js";
6
7
  import { filterLogLines, getCaptureFilePath, isCapturing, readRecentLogs, registerCleanup, rotateCaptureIfNeeded, startCapture, stopCapture, } from "./logcat-capture.js";
7
8
  import { RADAR_PORT, RADAR_VERSION } from "./constants.js";
@@ -66,6 +67,35 @@ export function resolveAdbPath() {
66
67
  // Module-level resolution, done once at import time. The MCP process lifetime
67
68
  // is short enough (session-scoped) that we do not need to re-resolve.
68
69
  const ADB = resolveAdbPath();
70
+ // Promisified execFile for the *Async transport methods below. argv form (no shell), so an
71
+ // interpolated value can never break out of a command string, and stdout/stderr are captured
72
+ // rather than inherited, matching the stdio discipline execsync-stdio.test.mjs pins.
73
+ const execFileAsync = promisify(execFile);
74
+ // One wording for a missing adb on the forward path, shared by the sync and async rebuilds so
75
+ // the two cannot drift.
76
+ const ADB_NOT_FOUND_FORWARD_ERROR = "adb binary not found. Set ANDROID_HOME or install Android SDK platform-tools. Searched: PATH, $ANDROID_HOME/platform-tools/adb, ~/Library/Android/sdk/platform-tools/adb, ~/Android/Sdk/platform-tools/adb, /usr/local/bin/adb, /opt/homebrew/bin/adb.";
77
+ // The device-side `ps` pipeline both debug-build probes run. See psDebugBuildProbe's doc
78
+ // comment for why the `|| exit 9` and the trailing `|| true` are each load-bearing.
79
+ const PS_DEBUG_BUILD_SCRIPT = 'out=$(ps -A -o USER,NAME) || exit 9; echo "$out" | grep Slack | grep debug || true';
80
+ // The enable broadcast, in argv form so the sync and async activate paths send the exact
81
+ // same command.
82
+ function enableBroadcastArgs(userId, timeoutMinutes) {
83
+ return [
84
+ "shell",
85
+ "am",
86
+ "broadcast",
87
+ "--user",
88
+ userId,
89
+ "-a",
90
+ ENABLE_ACTION,
91
+ "--ei",
92
+ "timeout_minutes",
93
+ String(timeoutMinutes),
94
+ "--es",
95
+ "mcp_version",
96
+ RADAR_VERSION,
97
+ ];
98
+ }
69
99
  /**
70
100
  * Parse the output of `ps -A -o USER,NAME` to extract the Android user ID
71
101
  * for the debug build process. When multiple profiles are running, prefers
@@ -130,6 +160,8 @@ export function parseAdbDevicesOutput(raw) {
130
160
  }
131
161
  export class AndroidTransport {
132
162
  platform = "android";
163
+ // The Android debug build serves Radar's HTTP API through the adb-forwarded local socket.
164
+ supportsRadarHttpTools = true;
133
165
  // adb reaches the app's databases and shared prefs through run-as, so the DB and prefs tools
134
166
  // (which shell to adb themselves) are cleared to run.
135
167
  supportsLocalFileAccess = true;
@@ -154,8 +186,7 @@ export class AndroidTransport {
154
186
  // never trust the cache (see reassertForward's doc comment on shared-transport.ts).
155
187
  rebuildForward() {
156
188
  if (!ADB) {
157
- this.lastForwardError =
158
- "adb binary not found. Set ANDROID_HOME or install Android SDK platform-tools. Searched: PATH, $ANDROID_HOME/platform-tools/adb, ~/Library/Android/sdk/platform-tools/adb, ~/Android/Sdk/platform-tools/adb, /usr/local/bin/adb, /opt/homebrew/bin/adb.";
189
+ this.lastForwardError = ADB_NOT_FOUND_FORWARD_ERROR;
159
190
  return false;
160
191
  }
161
192
  // Drop any existing mapping first. Re-issuing `adb forward` over a stale mapping
@@ -203,12 +234,8 @@ export class AndroidTransport {
203
234
  encoding: "utf-8",
204
235
  stdio: ["ignore", "pipe", "ignore"],
205
236
  });
206
- const wanted = `${serial} tcp:${RADAR_PORT} localabstract:${SOCKET_NAME}`;
207
- if (list.split("\n").some((line) => line.trim() === wanted)) {
208
- this.portForwarded = true;
209
- this.lastForwardError = null;
237
+ if (this.recordForwardIfListed(list, serial))
210
238
  return true;
211
- }
212
239
  }
213
240
  catch {
214
241
  // Listing failed; fall through to the unconditional rebuild below, which
@@ -217,6 +244,66 @@ export class AndroidTransport {
217
244
  }
218
245
  return this.rebuildForward();
219
246
  }
247
+ // The listing check reassertForward and reassertForwardAsync share: when the live mapping
248
+ // already points our RADAR_PORT at our pinned serial, record it good and skip the rebuild.
249
+ recordForwardIfListed(list, serial) {
250
+ const wanted = `${serial} tcp:${RADAR_PORT} localabstract:${SOCKET_NAME}`;
251
+ if (!list.split("\n").some((line) => line.trim() === wanted))
252
+ return false;
253
+ this.portForwarded = true;
254
+ this.lastForwardError = null;
255
+ return true;
256
+ }
257
+ /**
258
+ * reassertForward, off the event loop. Same listing-first-then-rebuild logic and the same
259
+ * state fields, but every adb call runs through execFileAsync so a caller that must keep
260
+ * serving HTTP while adb is slow (the dashboard's boot-arm chain) is never blocked, even
261
+ * inside a single call. The sync twin stays for the MCP request paths, which have nothing
262
+ * else to do while adb runs.
263
+ */
264
+ async reassertForwardAsync() {
265
+ const serial = process.env.ANDROID_SERIAL;
266
+ if (serial && ADB) {
267
+ try {
268
+ const { stdout } = await execFileAsync(ADB, ["forward", "--list"], {
269
+ timeout: 5000,
270
+ encoding: "utf-8",
271
+ });
272
+ if (this.recordForwardIfListed(stdout, serial))
273
+ return true;
274
+ }
275
+ catch {
276
+ // Listing failed; fall through to the rebuild, exactly like the sync twin.
277
+ }
278
+ }
279
+ return this.rebuildForwardAsync();
280
+ }
281
+ // rebuildForward, off the event loop. Mirrors the sync twin step for step: drop any
282
+ // existing mapping (failure is harmless), then add ours and record the outcome.
283
+ async rebuildForwardAsync() {
284
+ if (!ADB) {
285
+ this.lastForwardError = ADB_NOT_FOUND_FORWARD_ERROR;
286
+ return false;
287
+ }
288
+ try {
289
+ await execFileAsync(ADB, ["forward", "--remove", `tcp:${RADAR_PORT}`], { timeout: 5000 });
290
+ }
291
+ catch {
292
+ // No existing mapping, or adb hiccup; the add below surfaces real failures.
293
+ }
294
+ try {
295
+ await execFileAsync(ADB, ["forward", `tcp:${RADAR_PORT}`, `localabstract:${SOCKET_NAME}`], {
296
+ timeout: 5000,
297
+ });
298
+ this.portForwarded = true;
299
+ this.lastForwardError = null;
300
+ return true;
301
+ }
302
+ catch (e) {
303
+ this.lastForwardError = e.message;
304
+ return false;
305
+ }
306
+ }
220
307
  getLastForwardError() {
221
308
  return this.lastForwardError;
222
309
  }
@@ -230,25 +317,86 @@ export class AndroidTransport {
230
317
  return;
231
318
  try {
232
319
  const userId = this.detectDebugBuildUser();
233
- execSync(`${ADB} shell am broadcast --user ${userId} -a ${ENABLE_ACTION} --ei timeout_minutes ${timeout} --es mcp_version ${RADAR_VERSION}`, { timeout: 5000, stdio: ["ignore", "ignore", "pipe"] });
234
- this.currentTimeoutMinutes = timeout;
235
- this.radarEnabled = true;
236
- this.lastActivateError = null;
237
- // Start streaming logcat to a session-scoped file so reads are not
238
- // subject to the device ring buffer rotating under load.
239
- registerCleanup();
240
- startCapture(ADB);
320
+ // Same taller ceiling as the async twin: the broadcast waits for ordered delivery and a
321
+ // cold debug build can hold completion past 5 seconds.
322
+ execFileSync(ADB, enableBroadcastArgs(userId, timeout), {
323
+ timeout: 15000,
324
+ stdio: ["ignore", "ignore", "pipe"],
325
+ });
326
+ this.recordActivateSuccess(timeout);
327
+ }
328
+ catch (e) {
329
+ this.recordActivateFailure(e);
330
+ }
331
+ }
332
+ /**
333
+ * activate, off the event loop. Same skip guard, the same broadcast argv, and the same
334
+ * state recording as the sync twin, but the `ps` user detection and the broadcast run
335
+ * through execFileAsync so a caller serving HTTP (the dashboard's boot-arm chain) keeps
336
+ * answering while adb runs.
337
+ */
338
+ async activateAsync(timeoutMinutes) {
339
+ if (!ADB) {
340
+ this.lastActivateError = "adb binary not found";
341
+ return;
342
+ }
343
+ const timeout = timeoutMinutes || this.currentTimeoutMinutes;
344
+ if (this.radarEnabled && timeout === this.currentTimeoutMinutes)
345
+ return;
346
+ try {
347
+ const userId = await this.detectDebugBuildUserAsync();
348
+ // The broadcast waits for ordered delivery, and a cold debug build has been observed to
349
+ // hold completion past 5 seconds; a killed broadcast reads as a failed arm, so this one
350
+ // call gets a taller ceiling than the quick adb queries.
351
+ await execFileAsync(ADB, enableBroadcastArgs(userId, timeout), { timeout: 15000 });
352
+ this.recordActivateSuccess(timeout);
241
353
  }
242
354
  catch (e) {
243
- // Broadcast failed, device may not be connected. Recorded so the enable
244
- // path can report it instead of claiming success with a failing ping.
245
- // radarEnabled drops too: a prior success no longer proves the device
246
- // side is armed, and leaving it true would make every later activate()
247
- // early-return and never re-send the broadcast.
248
- this.radarEnabled = false;
249
- this.lastActivateError = e.message;
355
+ this.recordActivateFailure(e);
250
356
  }
251
357
  }
358
+ /**
359
+ * Whether the device-side Radar server's abstract socket exists right now, read from the
360
+ * device's own socket table so the answer does not travel through the adb forward. Through a
361
+ * forward every failure collapses to a connection reset, because the HOST adb server accepts
362
+ * the TCP connection unconditionally and only then discovers the device side is absent, so a
363
+ * ping cannot tell "no session exists" from "a session exists and the probe failed". This read
364
+ * can. "unknown" (adb missing, or the table could not be read) leaves the caller its safe branch.
365
+ */
366
+ async radarSocketPresentAsync() {
367
+ if (!ADB)
368
+ return "unknown";
369
+ try {
370
+ const { stdout } = await execFileAsync(ADB, ["shell", "cat", "/proc/net/unix"], {
371
+ timeout: 5000,
372
+ });
373
+ // The @ pins the match to the abstract-namespace entry the forward targets (the table
374
+ // renders abstract sockets as @name), not any path merely containing the name.
375
+ return stdout.includes(`@${SOCKET_NAME}`) ? "present" : "absent";
376
+ }
377
+ catch {
378
+ return "unknown";
379
+ }
380
+ }
381
+ // A broadcast landed: record the session state and start streaming logcat to a
382
+ // session-scoped file so reads are not subject to the device ring buffer rotating
383
+ // under load. Shared by activate and activateAsync so the two cannot drift.
384
+ recordActivateSuccess(timeout) {
385
+ this.currentTimeoutMinutes = timeout;
386
+ this.radarEnabled = true;
387
+ this.lastActivateError = null;
388
+ registerCleanup();
389
+ if (ADB)
390
+ startCapture(ADB);
391
+ }
392
+ // Broadcast failed, device may not be connected. Recorded so the enable path can report
393
+ // it instead of claiming success with a failing ping. radarEnabled drops too: a prior
394
+ // success no longer proves the device side is armed, and leaving it true would make every
395
+ // later activate() early-return and never re-send the broadcast.
396
+ recordActivateFailure(e) {
397
+ this.radarEnabled = false;
398
+ this.lastActivateError = e.message;
399
+ }
252
400
  getLastActivateError() {
253
401
  return this.lastActivateError;
254
402
  }
@@ -396,7 +544,12 @@ export class AndroidTransport {
396
544
  // scoped to a profile we could not detect, and appending this profile's
397
545
  // run to it would mix profiles in one file. Rotating is the safe default.
398
546
  const profileChanged = this.detectedUserId !== userId;
399
- execSync(`${ADB} shell am broadcast --user ${userId} -a ${ENABLE_ACTION} --ei timeout_minutes ${timeout} --es mcp_version ${RADAR_VERSION}`, { timeout: 5000, stdio: ["ignore", "ignore", "pipe"] });
547
+ // The same argv and the same tall ceiling as activate's twins: the broadcast waits for
548
+ // ordered delivery and a cold debug build can hold completion past 5 seconds.
549
+ execFileSync(ADB, enableBroadcastArgs(userId, timeout), {
550
+ timeout: 15000,
551
+ stdio: ["ignore", "ignore", "pipe"],
552
+ });
400
553
  this.detectedUserId = userId;
401
554
  this.currentTimeoutMinutes = timeout;
402
555
  this.radarEnabled = true;
@@ -437,6 +590,24 @@ export class AndroidTransport {
437
590
  return null;
438
591
  }
439
592
  }
593
+ // listDevices, off the event loop. Same parse, the same selected-device reconciliation,
594
+ // and the same [] / null distinction as the sync twin.
595
+ async listDevicesAsync() {
596
+ if (!ADB)
597
+ return [];
598
+ try {
599
+ const { stdout } = await execFileAsync(ADB, ["devices", "-l"], {
600
+ timeout: 5000,
601
+ encoding: "utf-8",
602
+ });
603
+ const devices = parseAdbDevicesOutput(stdout);
604
+ this.reconcileSelectedDevice(devices);
605
+ return devices;
606
+ }
607
+ catch {
608
+ return null;
609
+ }
610
+ }
440
611
  // Drop the recorded selection if its serial is no longer in the attached list, so
441
612
  // getSelectedDevice() (read by /health and the dashboard header) never claims a
442
613
  // device that has disconnected. Deliberately does NOT touch process.env.ANDROID_SERIAL
@@ -451,7 +622,18 @@ export class AndroidTransport {
451
622
  this.selectedDevice = null;
452
623
  }
453
624
  selectDevice(serial) {
454
- const devices = this.listDevices();
625
+ return this.pickFromListing(this.listDevices(), serial);
626
+ }
627
+ /**
628
+ * selectDevice, off the event loop. The listing runs through execFileAsync; the pick
629
+ * itself is the exact code the sync twin runs (pickFromListing), so the two cannot
630
+ * disagree about which device wins.
631
+ */
632
+ async selectDeviceAsync(serial) {
633
+ return this.pickFromListing(await this.listDevicesAsync(), serial);
634
+ }
635
+ // Everything selectDevice decides once a listing (or its failure, null) is in hand.
636
+ pickFromListing(devices, serial) {
455
637
  if (devices === null) {
456
638
  return {
457
639
  ok: false,
@@ -474,7 +656,7 @@ export class AndroidTransport {
474
656
  const match = attached.find((d) => d.serial === serial);
475
657
  if (match) {
476
658
  this.pin(match.serial, match.label);
477
- return { ok: true, serial: match.serial, switched: switchedTo(match.serial) };
659
+ return { ok: true, serial: match.serial, switched: switchedTo(match.serial), devices };
478
660
  }
479
661
  const list = attached.length > 0 ? listAttached() : "none";
480
662
  return {
@@ -490,7 +672,7 @@ export class AndroidTransport {
490
672
  const stillAttached = attached.find((d) => d.serial === pinned);
491
673
  if (stillAttached) {
492
674
  this.pin(stillAttached.serial, stillAttached.label);
493
- return { ok: true, serial: stillAttached.serial, switched: switchedTo(stillAttached.serial) };
675
+ return { ok: true, serial: stillAttached.serial, switched: switchedTo(stillAttached.serial), devices };
494
676
  }
495
677
  // The pinned device detached. Drop the stale env pin AND the recorded selection so
496
678
  // /health does not keep claiming a device that is gone.
@@ -500,7 +682,7 @@ export class AndroidTransport {
500
682
  // (c) Exactly one attached device: auto-pin it.
501
683
  if (attached.length === 1) {
502
684
  this.pin(attached[0].serial, attached[0].label);
503
- return { ok: true, serial: attached[0].serial, switched: switchedTo(attached[0].serial) };
685
+ return { ok: true, serial: attached[0].serial, switched: switchedTo(attached[0].serial), devices };
504
686
  }
505
687
  // (d) Zero devices (or a fake adb that does not answer `devices -l`): no-op. The
506
688
  // existing ensureForward failure path reports no-device cleanly, and returning
@@ -508,7 +690,7 @@ export class AndroidTransport {
508
690
  if (attached.length === 0) {
509
691
  // Nothing attached: clear any recorded selection so /health reports no device.
510
692
  this.selectedDevice = null;
511
- return { ok: true, serial: null };
693
+ return { ok: true, serial: null, devices };
512
694
  }
513
695
  // (e) 2+ attached devices with no explicit choice: ambiguous. The transport error stays a
514
696
  // neutral, surface-agnostic core; each caller (MCP, web) appends its own retry guidance.
@@ -553,7 +735,29 @@ export class AndroidTransport {
553
735
  if (!ADB)
554
736
  return { state: "unknown", lines: "" };
555
737
  try {
556
- const ps = execSync(`${ADB} shell 'out=$(ps -A -o USER,NAME) || exit 9; echo "$out" | grep Slack | grep debug || true'`, { timeout: timeoutMs, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
738
+ const ps = execSync(`${ADB} shell '${PS_DEBUG_BUILD_SCRIPT}'`, {
739
+ timeout: timeoutMs,
740
+ encoding: "utf-8",
741
+ stdio: ["ignore", "pipe", "pipe"],
742
+ }).trim();
743
+ return ps.length > 0
744
+ ? { state: "running", lines: ps }
745
+ : { state: "stopped", lines: "" };
746
+ }
747
+ catch {
748
+ return { state: "unknown", lines: "" };
749
+ }
750
+ }
751
+ // psDebugBuildProbe, off the event loop. Same script, same tri-state classification.
752
+ async psDebugBuildProbeAsync(timeoutMs = PS_PROBE_TIMEOUT_MS) {
753
+ if (!ADB)
754
+ return { state: "unknown", lines: "" };
755
+ try {
756
+ const { stdout } = await execFileAsync(ADB, ["shell", PS_DEBUG_BUILD_SCRIPT], {
757
+ timeout: timeoutMs,
758
+ encoding: "utf-8",
759
+ });
760
+ const ps = stdout.trim();
557
761
  return ps.length > 0
558
762
  ? { state: "running", lines: ps }
559
763
  : { state: "stopped", lines: "" };
@@ -570,13 +774,22 @@ export class AndroidTransport {
570
774
  detectDebugBuildUser() {
571
775
  if (this.detectedUserId !== null)
572
776
  return this.detectedUserId;
573
- const ps = this.psDebugBuildLine();
777
+ return this.cacheUserFromPs(this.psDebugBuildLine());
778
+ }
779
+ // detectDebugBuildUser, off the event loop. Same cache, same fallback rules.
780
+ async detectDebugBuildUserAsync() {
781
+ if (this.detectedUserId !== null)
782
+ return this.detectedUserId;
783
+ const probe = await this.psDebugBuildProbeAsync();
784
+ return this.cacheUserFromPs(probe.state === "running" ? probe.lines : null);
785
+ }
786
+ // Cache only when a debug-build process was actually seen. Caching the "0"
787
+ // fallback would pin every later enable to user 0 for the process lifetime,
788
+ // so a work-profile build (user 10) launched after a failed detect would
789
+ // never receive the enable broadcast.
790
+ cacheUserFromPs(ps) {
574
791
  if (!ps)
575
792
  return "0";
576
- // Cache only when a debug-build process was actually seen. Caching the "0"
577
- // fallback would pin every later enable to user 0 for the process lifetime,
578
- // so a work-profile build (user 10) launched after a failed detect would
579
- // never receive the enable broadcast.
580
793
  const match = ps.match(/u(\d+)_/);
581
794
  if (!match)
582
795
  return "0";
@@ -0,0 +1,35 @@
1
+ import type { DeviceTransport } from "./transport.js";
2
+ export interface DashboardScreenCapabilities {
3
+ screenshot: boolean;
4
+ liveCast: boolean;
5
+ snapshotCast: boolean;
6
+ recording: boolean;
7
+ ffmpeg: boolean;
8
+ scrcpy: boolean;
9
+ installHint: string | null;
10
+ platform: string;
11
+ }
12
+ /**
13
+ * Shared screen contract used by the dashboard. Platform implementations own every capture
14
+ * command and recording lifecycle detail; HTTP routes only enforce consent and serialize results.
15
+ */
16
+ export interface DashboardScreenController {
17
+ capabilities(): DashboardScreenCapabilities;
18
+ refreshCapabilities(): Promise<void>;
19
+ captureScreenshot(): Promise<Buffer | null>;
20
+ startRecording(): Promise<string | null>;
21
+ stopRecording(): Promise<string | null>;
22
+ isRecording(): boolean;
23
+ redetect(): Promise<string>;
24
+ reset(): void;
25
+ /**
26
+ * The safe subset of reset(): drop cached detection/capability state so the next capture
27
+ * re-detects, WITHOUT stopping recordings or deleting artifacts. This is what a same-device
28
+ * re-arm needs; reset() is reserved for real session boundaries (device swap, first enable
29
+ * of the process).
30
+ */
31
+ resetDetection(): void;
32
+ resolveRecording(file: string): string | null;
33
+ registerCleanup(): void;
34
+ }
35
+ export declare function createDashboardScreenController(transport: DeviceTransport): DashboardScreenController;
@@ -0,0 +1,12 @@
1
+ import { AndroidDashboardScreenController } from "./android-dashboard-screen.js";
2
+ import { IosDashboardScreenController } from "./ios-dashboard-screen.js";
3
+ export function createDashboardScreenController(transport) {
4
+ switch (transport.platform) {
5
+ case "android":
6
+ return new AndroidDashboardScreenController();
7
+ case "ios":
8
+ return new IosDashboardScreenController(transport);
9
+ default:
10
+ throw new Error(`Screen capture is not supported for platform: ${transport.platform}`);
11
+ }
12
+ }
@@ -0,0 +1,32 @@
1
+ import type { DashboardScreenCapabilities, DashboardScreenController } from "./dashboard-screen.js";
2
+ import type { DeviceTransport } from "./transport.js";
3
+ export interface IosRecordingHandle {
4
+ readonly started: Promise<void>;
5
+ isRunning(): boolean;
6
+ stop(): Promise<void>;
7
+ kill(): void;
8
+ }
9
+ export type IosRecordingStarter = (simulatorUdid: string, outputPath: string) => IosRecordingHandle;
10
+ /** Start simctl's open-ended recorder and expose its readiness/finalization lifecycle. */
11
+ export declare function startIosSimulatorRecording(simulatorUdid: string, outputPath: string): IosRecordingHandle;
12
+ /** iOS Simulator's dashboard capture implementation, isolated around simctl. */
13
+ export declare class IosDashboardScreenController implements DashboardScreenController {
14
+ private readonly transport;
15
+ private readonly startSimulatorRecording;
16
+ private recording;
17
+ private cleanupRegistered;
18
+ private caps;
19
+ constructor(transport: DeviceTransport, startSimulatorRecording?: IosRecordingStarter);
20
+ capabilities(): DashboardScreenCapabilities;
21
+ refreshCapabilities(): Promise<void>;
22
+ private buildCaps;
23
+ captureScreenshot(): Promise<Buffer | null>;
24
+ startRecording(): Promise<string | null>;
25
+ stopRecording(): Promise<string | null>;
26
+ isRecording(): boolean;
27
+ redetect(): Promise<string>;
28
+ reset(): void;
29
+ resetDetection(): void;
30
+ resolveRecording(file: string): string | null;
31
+ registerCleanup(): void;
32
+ }