230 Commits

Author SHA1 Message Date
Michał Pierzchała 479537f36f 0.7.20 v0.7.20 2026-03-12 17:29:55 +01:00
Michał Pierzchała 884e48ba27 fix: harden Android runtime relaunch flows (#211)
* fix: harden Android runtime relaunch flows

* docs: clarify mobile QA skill flows
2026-03-12 17:29:40 +01:00
Michał Pierzchała b8cad6b226 0.7.19 v0.7.19 2026-03-12 15:45:14 +01:00
Michał Pierzchała 967f71fc77 fix: prevent auto-selection of physical iOS devices when simulators are available (#210)
* fix: prevent auto-selection of physical iOS devices when simulators are available

When running with --platform ios and a physical iPhone connected but no
simulators booted, the tool would connect to the physical device instead
of booting a simulator. Add a safeguard in resolveTargetDevice that
rejects auto-selected physical devices and falls back to
findBootableIosSimulator, which queries simctl without the isAvailable
filter to find any bootable simulator.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: handle empty device list and filter unavailable simulators in fallback

- Extract resolveIosDevice() so the iOS fallback logic is testable via
  dependency injection without module mocking
- Catch DEVICE_NOT_FOUND from selectDevice when no explicit selector was
  used, so the simulator fallback runs even when listIosDevices returns
  an empty list (all simulators filtered by isAvailable)
- Restore isAvailable check in findBootableIosSimulator to avoid
  returning simulators with missing runtimes that cannot boot
- Add 8 tests covering: physical-device rejection, empty-list recovery,
  explicit-selector passthrough, and normal simulator-present path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 15:44:52 +01:00
Michał Pierzchała 76cf675d1e 0.7.18 v0.7.18 2026-03-12 14:31:23 +01:00
Michał Pierzchała ce1f37113e fix: prefer simulators/emulators over physical devices in auto-selection (#209)
Physical iOS devices always report booted=true, so the "prefer booted"
tiebreaker would pick them over unbooted simulators. This caused sessions
to bind to a connected iPhone instead of a simulator when no explicit
device selector (--udid/--device/--serial) was provided.

Now, when multiple candidates exist and no explicit device was requested,
physical devices are filtered out if virtual alternatives are available.
The simulator is then booted on demand by the existing ensureBootedSimulator
flow.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 14:30:38 +01:00
Michał Pierzchała 51667d5b96 0.7.17 v0.7.17 2026-03-12 13:39:29 +01:00
Michał Pierzchała 990a02bec6 fix: increase Android emulator AVD name resolution timeout to 10s (#208)
The 1.5s per-command timeout in resolveAndroidEmulatorAvdName was too
aggressive for emulators over remote adb daemon transport, causing
open --relaunch to fail during device discovery.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 13:38:48 +01:00
Michał Pierzchała 0f18a0ffa2 0.7.16 v0.7.16 2026-03-12 13:05:49 +01:00
Michał Pierzchała 7131fc1fe7 fix: quote sh -c script in adb shell to prevent argument splitting (#207)
adb shell concatenates all arguments with spaces into a single string
for the remote shell. Without quoting, the && in the mkdir/cat script
was interpreted as a command separator, causing mkdir to run with no
arguments ("mkdir: Needs 1 argument").

Wrapping the script in single quotes ensures the remote device shell
passes the entire command as one argument to sh -c.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 13:03:41 +01:00
Michał Pierzchała 9df2567d94 fix: detect persistent iOS simulator launch failures early with actionable hints (#206)
When `xcrun simctl launch` fails with FBSOpenApplicationServiceErrorDomain
code=4 persistently (e.g. architecture mismatch), all 30 retries would fail
identically, wasting 30 seconds before surfacing a generic error. Now we bail
after 3 consecutive identical FBS failures, probe the simulator for root cause
(app not installed, device binary on simulator, etc.), and surface an actionable
hint. Also reduces maxAttempts from 30 to 10 as a secondary safety net.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 13:00:34 +01:00
Michał Pierzchała c3fb690acb 0.7.15 v0.7.15 2026-03-12 12:29:10 +01:00
Michał Pierzchała 3bb5e6c6a8 fix: prevent APK file paths from being used as package names in adb run-as (#204)
resolveAndroidApp treated any input containing a dot as a package name,
which caused APK file paths (e.g. /path/to/app-debug.apk) to flow through
as appId into runtime hints, failing with a misleading "app not debuggable"
diagnosis. Android package names never contain slashes, so exclude paths
with '/' from the dot-based package heuristic.

Also differentiate probe failures in writeAndroidDevPrefs: check
isAndroidRunAsDeniedOutput on the probe result so connectivity/transport
errors are not misattributed to debuggability.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 12:28:22 +01:00
Michał Pierzchała 3847958067 fix: serve artifact downloads at /upload/{id} to fix proxy 404 (#205)
The artifact download endpoint was at GET /artifacts/{id}, but proxies
in the sandbox → proxy → daemon architecture only forward known paths
(/rpc, /health, /upload). Move downloads to GET /upload/{id} so they
share the already-forwarded /upload path (POST for uploads, GET for
downloads).

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 12:28:11 +01:00
Michał Pierzchała 2522984aa9 0.7.14 v0.7.14 2026-03-11 16:11:08 +01:00
Michał Pierzchała ee7f81b8ab fix: write android runtime hints via stdin (#203) 2026-03-11 16:10:57 +01:00
Michał Pierzchała 55d69f7729 0.7.13 v0.7.13 2026-03-11 14:56:43 +01:00
Michał Pierzchała 3763772734 fix: clarify android runtime hint failures (#202) 2026-03-11 14:56:15 +01:00
Michał Pierzchała f23df4d9c8 docs: add missing command reference entries (#201)
* docs: add missing command reference entries

* docs: clarify wait ref behavior
2026-03-10 12:59:36 +01:00
Michał Pierzchała e2bf4ef7a1 docs: add missing command reference entries (#200) 2026-03-10 12:29:05 +01:00
Michał Pierzchała 63d9f0021c refactor: extract daemon orchestration into dedicated modules (#160) (#198)
Restore src/daemon.ts to thin-router entrypoint by extracting:
- server-lifecycle.ts: lock/info file management, code signature, env parsing
- request-router.ts: request dispatch orchestration across handlers
- transport.ts: socket server, listen helpers, disconnect/abort logic

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 10:27:17 +01:00
Michał Pierzchała 12d54989b3 0.7.12 v0.7.12 2026-03-09 19:50:59 +01:00
Michał Pierzchała 8b36c2a56c feat: support remote runtime hints and artifact retrieval (#199)
* feat: add remote runtime hints and artifact retrieval

* fix: apply session runtime transport hints on open

* fix: secure and time out artifact downloads
2026-03-09 19:50:40 +01:00
Michał Pierzchała 150399ec0c 0.7.11 v0.7.11 2026-03-09 17:35:07 +01:00
Michał Pierzchała a463106eea fix: avoid canceling active HTTP RPC requests (#196) 2026-03-09 17:34:52 +01:00
Michał Pierzchała 51158c56ce 0.7.10 v0.7.10 2026-03-09 16:37:53 +01:00
Michał Pierzchała 4a22da9e4b fix: propagate AbortSignal on cancellation to stop iOS runner promptly (#194)
* fix: propagate AbortSignal on request cancellation to stop iOS runner promptly

When a client disconnects (socket close or HTTP connection drop), in-flight
iOS runner operations now receive an AbortSignal that immediately interrupts
pending HTTP fetches, retry delays, and retry loops—ensuring detached
xcodebuild/runner processes are not driven after the parent workflow is canceled.

Closes #193

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: ensure HTTP disconnect cancellation always propagates

* fix: rethrow canceled runner waits before fallback

* fix: harden cancellation tracking and propagation

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:37:22 +01:00
Michał Pierzchała 780ecbc7a4 feat: support installing local artifacts over remote daemon transport (#192)
* feat: support installing local artifacts over remote daemon transport

When the CLI runs on a different machine than the daemon (via
AGENT_DEVICE_DAEMON_BASE_URL), install/reinstall commands now
transparently upload local app binaries (.apk/.ipa/.aab) and app
bundles (.app dirs) to the daemon before installing. No new flags
required — same CLI ergonomics.

- Add POST /upload endpoint to daemon HTTP server with auth and
  streaming file/tar reception
- Add client-side upload helper with timeout and tar packing for
  .app directories
- Intercept install/reinstall in sendToDaemon for remote daemons,
  upload artifact, rewrite positional path
- Clean up uploaded temp files after install completes (or fails)
  with 5-minute safety-net auto-cleanup for abandoned uploads
- Sanitize artifact filenames to prevent path traversal

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: harden remote artifact upload flow

* refactor: split upload registry from receiver

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 16:10:31 +01:00
Jonathan Sweet 21b6b61757 test: add unit tests for dispatch-series helper functions (#190)
* test(dispatch-series): add comprehensive unit tests for helper functions

* test(dispatch-series): mock setTimeout instead of measuring elapsed time
2026-03-06 17:06:02 +01:00
Michał Pierzchała 151f36bf34 0.7.9 v0.7.9 2026-03-06 15:40:43 +01:00
Muhammad Mugni Hadi b79bd86017 fix: remove trailing commas in Swift for Xcode <16.3 compatibility (#186)
* fix: remove trailing commas in Swift for Xcode <16.3 compatibility

Remove trailing commas from function/initializer argument lists in the
iOS XCUITest runner Swift source files. SE-0439 trailing commas in
comma-separated lists require Swift 6.1+ (Xcode 16.3+), but the runner
is compiled locally by users who may have older Xcode versions.

Users with Xcode 16.2 (Swift 6.0.3) encounter build failures:
  error: unexpected ',' separator

This causes the runner to never start, surfacing as:
  Error (COMMAND_FAILED): Runner did not accept connection (simctl spawn)

Files fixed (12 trailing commas removed):
- RunnerTests+Snapshot.swift (5)
- RunnerTests+Transport.swift (2)
- RunnerTests+CommandExecution.swift (1)
- RunnerTests+ScreenRecorder.swift (2)
- RunnerTests.swift (2)

Verified: pnpm build:xcuitest passes (TEST BUILD SUCCEEDED).

* ci: guard iOS runner trailing-comma syntax

---------

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2026-03-06 15:40:18 +01:00
Michał Pierzchała 3bafc24f05 fix: support explicit remote daemon endpoints (#189)
* fix: support remote daemon base url

* fix: harden remote daemon endpoint handling

* docs: update remote daemon skill guidance
2026-03-06 15:40:06 +01:00
Michał Pierzchała 9ca4e07feb chore: tighten ios screenshot fallback diagnostics 2026-03-06 14:02:58 +01:00
Michał Pierzchała 1d875bacdc fix: harden ios screenshot fallback timeouts 2026-03-06 14:01:00 +01:00
Michał Pierzchała 4df80afbc5 fix: strip pre-PNG garbage from Android screenshots on multi-display devices (#185)
* fix: strip pre-PNG garbage from Android screenshots on multi-display devices

On Android emulators with multiple displays (e.g. Galaxy Z Fold), `adb
exec-out screencap -p` writes a warning to stdout before the PNG data,
producing corrupt files.  Locate the PNG signature in the buffer and
discard everything before it.

https://claude.ai/code/session_01Lfb3WKqXCSqYtCg8dbS8JW

* refactor: simplify PNG stripping and test scripts

- Remove unnecessary ternary; subarray(0) is a no-op
- Replace hex-encoded printf mock scripts with file-based payloads

https://claude.ai/code/session_01Lfb3WKqXCSqYtCg8dbS8JW

* fix: trim Android screenshot output to complete PNG payload

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-04 10:10:47 +01:00
Michał Pierzchała e248c87634 test: lock find click JSON response to exact deterministic key set (#183)
Add strict key-set assertions to find click handler tests to prevent
accidental schema drift in the machine-consumed JSON response.

Closes #182

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 20:28:10 +01:00
Michał Pierzchała 22deb54ddb feat: add --shutdown option to close command for iOS simulator teardown (#176)
* feat: add --shutdown option to close command for iOS simulator teardown (#172)

When --shutdown is passed, close ends the session then runs xcrun simctl
shutdown on the associated simulator. Shutdown result (success, exitCode,
stdout, stderr) is included in the JSON response data.

The option is silently ignored for non-simulator targets (physical iOS
devices, Android). A shutdownSimulator override is injected into
handleSessionCommands for testability.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: document close --shutdown option for iOS simulator teardown

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: keep close --shutdown successful when simulator shutdown fails

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 20:00:10 +01:00
Michał Pierzchała bb06bafc65 feat: add ensure-simulator command for scoped iOS device sets (#179)
* feat: add ensure-simulator command for scoped iOS device sets (#169)

Adds a new first-class `ensure-simulator` command that ensures an iOS
simulator exists (and optionally boots it) inside a scoped device set,
without requiring custom simctl scripting outside agent-device.

Usage:
  agent-device ensure-simulator --device "iPhone 16" [--runtime <id>] [--boot] [--ios-simulator-device-set <path>]

JSON output includes udid, device, runtime, ios_simulator_device_set,
and whether the simulator was created vs reused.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: document ensure-simulator in commands reference and skill

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 19:39:52 +01:00
Michał Pierzchała 427093d0b0 fix: return deterministic matched-target metadata for find click responses (#178)
* fix: return deterministic matched-target metadata for find click responses (#170)

On success, build the response from the matched snapshot node rather than
passing through whatever the underlying click/press handler returns.
Response now includes: ref, locator, query, and x/y derived from the
matched element's rect — all stable across runs.

Also makes `dispatch` injectable in `handleFindCommands` (matching the
pattern in `handleInteractionCommands`) and adds tests that assert the
deterministic shape and verify that non-deterministic platform runner
data does not bleed into the response.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: document find click response shape in selectors and skill references

Add response shape documentation for `find "<query>" click --json` to:
- website/docs/docs/selectors.md (new "Response shape (click)" section)
- skills/agent-device/SKILL.md (guardrail note)
- skills/agent-device/references/snapshot-refs.md (new "find click response" section)

Follows the fix in #178 that made the response deterministic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 19:39:31 +01:00
Michał Pierzchała 8d4c9149a6 fix: retry alert accept/dismiss on transient 'alert not found' errors (#177)
* fix: retry alert accept/dismiss on transient 'alert not found' errors

Adds a 2 s internal retry window for `alert accept` and `alert dismiss`
when the runner returns "alert not found" or "no alert". Errors from
other causes break the loop immediately and are re-thrown unchanged.
Also injects `runnerCommand` as an optional param to enable unit testing
without spawning a real runner.

Closes #171

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: document alert accept/dismiss retry behaviour in skill and permissions reference

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 19:39:22 +01:00
Michał Pierzchała 43cb8cdb5d fix: enrich DEVICE_NOT_FOUND error for empty scoped iOS simulator sets (#175)
* fix: enrich DEVICE_NOT_FOUND error for empty scoped iOS simulator sets (#168)

When selectDevice finds no candidates and a simulatorSetPath context is
provided for iOS, throw a detailed error including the set path and a
suggested xcrun simctl --set ... create command to provision the first
simulator.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: note enriched DEVICE_NOT_FOUND guidance for empty scoped iOS simulator sets

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 19:37:58 +01:00
Michał Pierzchała a51f8193f2 feat: include device_udid and ios_simulator_device_set in iOS JSON payloads (#180)
Add device identity fields to open, appstate, and session_list responses
for iOS targets, enabling isolation verification in concurrent multi-session
runs without extra simctl calls.

Closes #173

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 19:36:01 +01:00
Michał Pierzchała 5f941c13f6 refactor: split app-log backend into process/stream/platform modules (#161) (#174)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 18:46:22 +01:00
Michał Pierzchała 5628693aa3 fix: stabilize iOS simulator screenshot capture (#167)
* fix: stabilize iOS simulator screenshot capture

* refactor: extract iOS screenshot module

* fix: fallback to runner for flaky iOS simulator screenshots

* chore: harden simulator runner screenshot path resolution

* refactor: simplify simulator screenshot fallback flow
2026-03-03 18:15:49 +01:00
Michał Pierzchała d269da37e3 refactor: split dispatch into command-family modules (#157) (#164)
Extract resolveTargetDevice, series/jitter helpers, and push payload
parsing into dedicated modules to reduce dispatch.ts from ~706 to ~564 LOC.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 18:11:14 +01:00
Michał Pierzchała c6910823df fix: harden daemon startup retries (#166) 2026-03-03 17:21:43 +01:00
Michał Pierzchała d38ddc6bb0 refactor: split iOS runner-client into focused modules (#163)
Break the 1129-LOC runner-client.ts into cohesive modules:
- runner-errors.ts: error classification, hints, error builders
- runner-xctestrun.ts: xctestrun discovery, build, preparation, build settings
- runner-transport.ts: HTTP transport, endpoint resolution, connection waiting
- runner-session.ts: session lifecycle, process management, device validation
- runner-client.ts: thin orchestration + re-exports (preserves all public API)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 14:44:11 +01:00
Michał Pierzchała b6b7c6228a refactor: split session replay helpers into focused modules (#153) 2026-03-03 14:41:35 +01:00
Michał Pierzchała 1a3ae62510 refactor: split Android platform module into focused submodules (#162)
Break down the monolithic `src/platforms/android/index.ts` (~1533 LOC) into
focused submodules to improve maintainability and targeted code review.

New submodules:
- `adb.ts` (21 LOC) — shared helpers: adbArgs, ensureAdb, sleep, isClipboardShellUnsupported
- `app-lifecycle.ts` (507 LOC) — app resolve/list/open/close/install/reinstall/appstate + bundletool
- `input-actions.ts` (378 LOC) — press/swipe/longPress/type/fill/scroll/scrollIntoView
- `device-input-state.ts` (184 LOC) — keyboard state/dismiss + clipboard read/write
- `settings.ts` (314 LOC) — appearance/permission/fingerprint/wifi/airplane/location
- `notifications.ts` (61 LOC) — push notification broadcast
- `snapshot.ts` (98 LOC) — snapshot + screenshot + UI hierarchy dump
- `index.ts` (43 LOC) — thin re-export layer preserving all public exports

Closes #154

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 14:41:10 +01:00
Michał Pierzchała 674a221865 0.7.6 v0.7.6 2026-03-03 14:14:47 +01:00