Repository navigation
fix(devices): agents can test the mobile app on remote device hosts #25121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d2e64b0
b34965a
512f512
053d14c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ import { | |
| LOCAL_DEVICE_HOST_LABEL, | ||
| type ThreadId, | ||
| } from "@t3tools/contracts"; | ||
| import { extractPng } from "@t3tools/shared/png"; | ||
| import { SshCommandError } from "@t3tools/ssh/errors"; | ||
| import * as FileSystem from "effect/FileSystem"; | ||
| import { resolveNodeExecutable, nodeRuntimeUnavailableMessage } from "@t3tools/shared/nodeRuntime"; | ||
|
|
@@ -757,7 +758,16 @@ export const makeWithHosts = Effect.fn("DeviceService.makeWithHosts")(function* | |
| const screenshot: DeviceService["Service"]["screenshot"] = Effect.fn("DeviceService.screenshot")( | ||
| function* (input) { | ||
| const { ready, device } = yield* resolveDevice(input.hostId, input.deviceId); | ||
| return { device, png: yield* ready.devices.screenshot(device) }; | ||
| const bytes = yield* ready.devices.screenshot(device); | ||
| const png = extractPng(bytes); | ||
| if (png === undefined) { | ||
| return yield* new DeviceOperationError({ | ||
| operation: "screenshot", | ||
| reason: "hub_rejected", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Give incomplete screenshots a specific error message. If
|
||
| cause: `The hub returned ${bytes.length} bytes without a complete PNG.`, | ||
| }); | ||
| } | ||
| return { device, png }; | ||
| }, | ||
| ); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| const PNG_SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10]; | ||
|
|
||
| /** | ||
| * Returns the first complete PNG in `bytes`, or undefined. `adb exec-out screencap -p` can print | ||
| * warnings, such as a foldable's multiple displays, around the image. | ||
| */ | ||
| export const extractPng = <Buffer extends ArrayBufferLike>( | ||
| bytes: Uint8Array<Buffer>, | ||
| ): Uint8Array<Buffer> | undefined => { | ||
| const start = bytes.findIndex((_, index) => | ||
| PNG_SIGNATURE.every((value, offset) => bytes[index + offset] === value), | ||
| ); | ||
| if (start < 0) return undefined; | ||
| const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); | ||
| for (let chunk = start + PNG_SIGNATURE.length; chunk + 12 <= bytes.length;) { | ||
| const end = chunk + 12 + view.getUint32(chunk); | ||
| if (end > bytes.length) return undefined; | ||
| if (String.fromCharCode(...bytes.subarray(chunk + 4, chunk + 8)) === "IEND") { | ||
| return bytes.subarray(start, end); | ||
| } | ||
| chunk = end; | ||
| } | ||
| return undefined; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Require a shared origin before reusing the backend.
If this task's healthy backend was started without
--share, a split device has noshared on tailnet:origin for the pairing step. Reuse the backend for a split layout only when it already has that origin. Otherwise, restart it with--share.🧰 Tools
🪛 SkillSpector (2.12.0)
[warning] 53: [RA2] Session Persistence: Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
Remediation: Remove any persistence mechanisms (cron jobs, startup scripts, state files). Skills should not maintain state across sessions without explicit user consent.
(Rogue Agent (RA2))