48 Commits

Author SHA1 Message Date
Michał Pierzchała 33083b5a86 chore: codebase cleanup pass (dedup, types, dead code, cycles) (#420)
* refactor: remove dead code and unused exports

- Delete interaction-get.ts, interaction-is.ts, interaction-selector.ts (superseded by selector-runtime dispatchers)
- Remove handleWaitCommand and its private helpers from snapshot-wait.ts (replaced by dispatchWaitViaRuntime)
- Remove unused distanceFromSafeViewportBand/isRectWithinSafeViewportBand from rect-visibility
- Trim Linux platform barrel to only the re-export still in use (snapshotLinux)

* refactor: consolidate duplicated helpers

- Move sleep() to utils/timeouts.ts; remove 6 duplicate implementations
- Use existing isApplePlatform() helper for ios||macos checks (5 sites)
- Export trimRuntimeValue from runtime-hints; drop duplicate trimRuntimeString
- Merge normalizeTextSurfaceType/normalizeType into single text-surface helper
- Remove pointless isScrollableContainerType wrapper

* refactor: consolidate accidentally-duplicated type definitions

- SnapshotDiffLine/Summary: single definition in utils/snapshot-diff, re-exported from capture-snapshot
- FindLocator: single definition in utils/finders, re-exported from client-types
- JsonRpc envelope in http-server now uses JsonRpcRequestEnvelope/JsonRpcId from contracts
- Inline 'primary'|'secondary'|'middle' literals replaced with ClickButton (internal sites only)

* refactor: strengthen weak types and fix DEVICE_IN_USE downgrade bug

- Add toAppErrorCode() validator and DEVICE_IN_USE to AppErrorCode union
- Replace 'as any' casts on wire error codes with the validator (daemon-error, daemon-client, request-router, http-server)
- Type Metro worker payload as MetroTunnelResponseMessage
- Type xctestrun plist parsing with explicit partial schema
- Narrow 'details.stderr' via typeof checks on Android error paths
- Type runner-session parseRunnerResponse with RunnerResponsePayload

Bug fix: handler emitted 'DEVICE_IN_USE' but router cast silently downgraded to
'COMMAND_FAILED' because the code was missing from AppErrorCode. Clients can now
react to same-device contention.

* refactor: collapse redundant 'ignore' comments in empty catch blocks

- Replace 16 instances of 3-line catch { // ignore } with 1-line catch {}
- Remove one self-describing 'Re-export public API' comment

Specific 'ignore shutdown races' / 'ignore malformed pid files' style comments
that name concrete failure modes are kept.

* refactor: eliminate circular dependencies by extracting shared types to leaves

Resolves all 44 cycles reported by madge. Pattern throughout: extract shared
type into a leaf module; both producer and consumer import from the leaf;
original module re-exports for API stability.

New leaf type modules:
- src/runtime-contract.ts (AgentDeviceRuntime, CommandContext, ...)
- src/metro-types.ts (MetroRuntimeHints, MetroBridgeResult, ...)
- src/commands/runtime-types.ts (CommandResult, RuntimeCommand, ...)
- src/commands/diagnostics-types.ts
- src/cli/commands/router-types.ts (ClientCommandParams, ...)
- src/core/interactor-types.ts (Interactor, BackMode, ...)
- src/platforms/ios/runner-session-types.ts (RunnerSession)
- src/utils/screenshot-diff-region-types.ts (MutableDiffRegion)
- src/daemon/handlers/record-trace-types.ts

madge --circular now reports 0 cycles (was 44). No runtime behavior changes.

* fix: preserve wire error codes verbatim (addresses codex review)

The initial weak-types pass validated wire error codes against a closed
union, silently downgrading any unknown code to COMMAND_FAILED. This
dropped signals like AMBIGUOUS_MATCH that handlers emit and clients are
documented to handle (skills/agent-device/references/exploration.md).

- Widen AppErrorCode to 'KnownAppErrorCode | (string & {})' so autocomplete
  of known codes is preserved while any wire code flows through
- toAppErrorCode now preserves any non-empty code; fallback only when
  undefined or empty
- Add AMBIGUOUS_MATCH to KnownAppErrorCode (documented public code)
- Add test coverage for preservation and fallback behavior

* refactor: address review follow-ups

- Add DEVICE_IN_USE to the batch error taxonomy in exploration.md (now
  observable by clients after earlier fix, needs agent-facing guidance)
- Delete one-line src/platforms/linux/index.ts barrel; both consumers
  (core/dispatch, daemon/handlers/snapshot-capture) now import from
  platforms/linux/snapshot directly
- Replace inline { tenantId; runId; leaseId } shapes with MetroBridgeScope
  alias at client-types, metro, and cli/commands/connection-runtime
- Consolidate remaining inline setTimeout wrappers onto utils/timeouts.ts#sleep
  (12 files, ~18 sites). Left test files and the runtime-clock aware helper
  in commands/selector-read-utils alone. Also removes the local sleepMs
  helper from daemon-client.ts.

* refactor: address low-priority review follow-ups

- daemon-client RPC error path: stringify any non-null data.code instead
  of only forwarding strings. Preserves numeric codes from hypothetical
  future proxies/servers; for first-party daemon today this is a no-op
  since handlers already emit strings.
- errors.ts: expand AppErrorCode comment to call out the exhaustiveness
  tradeoff of the '(string & {})' widening for SDK consumers.
2026-04-17 13:22:46 +02:00
Michał Pierzchała 63ab9d625c fix: propagate remote config through remote flows (#422)
* fix: propagate remote config through commands

* fix: complete remote React Native flow

* test: cover remote install source lease reuse

* fix: honor remote config session scope

* refactor: drop remote react native shortcut

* docs: simplify remote tenancy skill flow

* docs: use trusted artifact placeholders

* docs: prune remote tenancy prompt note
2026-04-17 12:26:42 +02:00
Michał Pierzchała 1b71dfee4c fix: defer remote connect lease and metro setup (#417) 2026-04-16 17:53:04 +02:00
Michał Pierzchała 47a1529e98 feat: add remote connect lifecycle (#407) 2026-04-13 14:11:40 +02:00
Michał Pierzchała 8e42f2e654 fix: harden public API boundaries (#399) 2026-04-11 21:01:09 +02:00
Michał Pierzchała ffd472a5bf feat: expose typed client command methods (#380) 2026-04-11 16:24:16 +02:00
Michał Pierzchała 20021c3d1c refactor: reduce duplication and simplify codebase (#374)
* refactor: reduce duplication and simplify codebase

Eliminate copy-pasted functions, inline error boilerplate, and repeated
patterns across daemon handlers and platform modules.

Key changes:
- Deduplicate isEnvTruthy, displayNodeLabel, roundPercent into single sources
- Extract throwDaemonError helper for client/CLI daemon response errors
- Add sessionNotFoundResponse/unsupportedOperationResponse helpers and
  adopt errorResponse() across ~30 handler files (-565 lines)
- Unify BATCH_PARENT_FLAG_KEYS/REPLAY_PARENT_FLAG_KEYS into shared
  mergeParentFlags helper in handler-utils
- Extract createLinuxToolResolver for screenshot/clipboard tool detection
- Remove stale type-sync comments from contracts.ts and metro.ts

* refactor: deeper structural simplification pass

Bigger wins from restructuring, not just mechanical dedup:

- cli.ts: move logTailStopper to try/finally (eliminates 28 duplicate
  calls), extract writeCommandCliOutput/writeLogsCliOutput/writeNetworkCliOutput
  from 350-line if/else chain, fix remaining throwDaemonError site
- session-store.ts: replace 67-line sanitizeFlags destructure/reconstruct
  with 10-line pick-from-array loop
- record-trace: extract finalizeRecordingOverlay helper, replacing 4
  copies of the telemetry+overlay block across ios/android/recording files
- Deduplicate normalizeText (finders.ts + selectors-match.ts)
- Fix isEnvTruthy to preserve whitespace-tolerant parsing (.trim())

* fix: ensure logTailStopper runs before process.exit

process.exit() does not unwind the stack, so finally blocks are
skipped. Restore explicit logTailStopper() calls before each
process.exit() to prevent leaking the background daemon log tail
process. The finally block remains as a safety net for normal
return paths.

Also refactor writeCommandCliOutput to return an exit code instead
of calling process.exit() directly, keeping the exit decision in
the caller where cleanup is visible.

* refactor: simplify daemon failure responses

* refactor: remove redundant daemon response cast
2026-04-11 12:53:53 +02:00
Michał Pierzchała 8df45b69a8 fix: make snapshot refs visible-first (#337)
* fix: make snapshot refs visible-first

* fix: handle zero-height visible rects

* refactor: simplify scrollintoview success handling

* feat: hint hidden scroll content in snapshots

* refactor: simplify snapshot output helpers

* feat: add hidden scroll-area hints to snapshots

* refactor: keep scroll containers in interactive snapshots

* perf: reuse Android snapshot tree for scroll hints

* refactor: trim hidden scroll hint scope

* refactor: unify mobile visible-first snapshot semantics

* fix: suppress noisy system scroll-container labels

* refactor: unify scroll indicator heuristics

* refactor: trim android hinting overhead

* fix: avoid viewport-sized ancestor promotion for ref taps

* refactor: dedupe viewport helpers and clarify hint naming
2026-04-01 19:00:02 +02:00
Michał Pierzchała 8aea3e0902 feat: improve snapshot diff and network exploration ergonomics (#326)
* feat: improve snapshot diff and network exploration ergonomics

* refactor: tighten snapshot diff guidance and Android log correlation
2026-03-31 19:37:26 +02:00
Michał Pierzchała 58e64933fb feat: add lightweight upgrade check (#324)
* feat: add lightweight upgrade check

* refactor: simplify upgrade check

* refactor: remove update-check test DI
2026-03-31 15:20:27 +02:00
Michał Pierzchała 497a54deb7 test: expand replay coverage and CI reporting with JUnit (#317)
* test: add benchmark .ad scripts for iOS and Android (02-06)

Add 10 new replay scripts covering deep navigation, scroll discovery,
text input & keyboard, app lifecycle, and swipe gestures for both
iOS simulator and Android emulator. Each script combines multiple
command types (snapshot, click, wait, is, find, get, scroll,
scrollintoview, swipe, back, home, keyboard, screenshot, appstate)
to provide comprehensive baseline coverage for version-over-version
comparison.

https://claude.ai/code/session_01VkHLzVc7NULQFaWHnhuBCm

* test: move replay benchmarks out of CI suite

* test: trim replay benchmark script comments

* test: relaunch replay app opens

* fix: stop focusing iOS simulator for screenshots

* fix: open Simulator app on cold boot

* test: trim iOS cold boot coverage

* test: move replay benchmarks into integration suites

* ci: align Android emulator with local setup

* ci: raise iOS replay daemon timeout

* test: add replay junit reports

* ci: use supported Android emulator profile

* fix: stabilize replay cleanup and Android CI flows

* test: trim flaky replay coverage

* fix: exclude replay tests from daemon request timeout

* test: relax android scroll discovery replay

* refactor: rename ios simulator app opener

* ci: remove obsolete android replay timeout override

* test: remove duplicate android replay opens

* test: relax ios swipe replay assertion

* ci: move full replay suites to nightly

* ci: extract shared replay workflow setup

* ci: fail nightly replay jobs on test errors

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-03-30 11:45:49 +02:00
Michał Pierzchała 7a5e1dca75 refactor: P3 polish — Interactor type safety, error response builder, OXC (#316)
* refactor: polish improvements from codebase review (P3)

- Export Interactor type and add `satisfies Interactor` to both return
  objects in getInteractor() for compile-time completeness checking
- Create errorResponse/successResponse builder in handlers/response.ts
  and adopt it in 5 representative handler files (find, record-trace,
  interaction-press, session-deploy, snapshot-wait)
- Add ESLint with typescript-eslint, fix unused imports and trivial
  lint issues, configure rules to warn for stylistic patterns

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor: complete P3 items — consolidate runner files, document macOS exports, standardize dispatch

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address P3 review feedback — remove invalid ESLint rules, dead code, unused export

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: replace eslint and prettier with oxc

* chore: tighten oxc config and upgrade typescript

* refactor: extract ios runner contract helpers

* docs: tighten agent guidance and add check scripts

* fix: resolve post-rebase validation issues

* fix: remove shell interpolation from metro launcher

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:43:24 +02:00
Michał Pierzchała 017ac817ff refactor: P1 structural improvements — move interactors to core, consolidate selectors, rename client-shared (#314)
* refactor: structural improvements from codebase review (P1)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor: complete P1 items — split CLI commands, decompose handlers, consolidate artifacts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor: simplify CLI and daemon facades

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 12:53:15 +02:00
Michał Pierzchała 90b8544c75 feat: improve cli batch output and acknowledgments (#280)
* feat: improve cli batch output and acknowledgments

* docs: clarify skill guidance for cheaper models

* fix: move success messages into command responses

* refactor: add shared success message helpers

* refactor: address PR review follow-ups

* refactor: reuse daemon success payloads
2026-03-27 10:34:31 +01:00
Michał Pierzchała c393ffe612 feat: add light test runner for .ad scripts (#266)
* feat: add metadata-aware ad test runner

* test: migrate platform integrations to replay suites

* fix: stop macos runner during close

* fix: harden ad test runner

* fix: tighten ad test runner retries and reporting

* refactor: tighten replay test suite runtime

* test: cover replay suite helpers

* docs: trim replay test guidance in skill

* refactor: extract replay test cli helpers
2026-03-26 19:21:16 +01:00
Michał Pierzchała aebc59b2a6 feat: streamline remote metro open flow (#240)
* feat: streamline remote metro open flow

* fix: honor remote config defaults and cli precedence
2026-03-20 14:07:17 +01:00
Daniel Williams 3f9eee0704 feat: add diff screenshot command for pixel-level image comparison (#214)
* fix: rebase PR 214 onto main

* fix: clean up screenshot diff output handling

* refactor: split android screenshot module

* chore: remove clack prompts dependency

* chore: format command schema

* refactor: unify user path resolution

* fix: let android screenshot ui settle

---------

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2026-03-17 19:14:45 +01:00
Michał Pierzchała 2be4de0a75 chore: prettier 2026-03-17 18:18:53 +01:00
Michał Pierzchała c874eeb4a5 feat: centralize CLI option resolution (#223)
* 0.7.22

* feat: centralize CLI option resolution

* refactor: introduce canonical CLI option specs

* fix: preserve enum config parsing in option specs

* docs: clarify canonical config values

* fix: honor config-backed session bindings
2026-03-14 20:55:59 +01:00
Michał Pierzchała c34639ec4d feat: share session lock policy across clients (#222)
* 0.7.22

* fix: add cli session binding lock mode

* fix: add cli session lock flags

* fix: preserve batch platform inheritance

* chore: clean up cli binding flow

* docs: update session-bound automation guidance

* feat: simplify session lock policy

* feat: share session lock policy across clients

* docs: add shared session lock examples

* refactor: simplify session lock policy helpers

* test: cover shared session lock policy cases

* test: cover strip mode router dispatch
2026-03-14 20:46:15 +01:00
Michał Pierzchała 34b9579b51 Add typed TypeScript daemon client (#218)
* feat: add typed daemon client

* chore: tighten client package exports

* fix: preserve open and screenshot cli flags

* feat: expose runtime open and install-source client flows

* feat: expose retained materialization paths in client

* feat: complete typed client cleanup

* fix: fall back to XML plist parsing
2026-03-14 14:19:16 +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 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 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 b685a0b259 Add remote HTTP daemon mode with lease admission controls (#136)
* fix: add daemon remote HTTP server mode with isolation controls

* feat: add tenant lease lifecycle and admission control

* refactor: simplify lease scope and rpc method routing

* fix: correct smoke expectations for close without session
2026-02-25 18:25:15 +01:00
Michał Pierzchała f512b7d69c feat: add network dump command for session app traffic (#120)
* feat: add network dump command for session app traffic

* fix: restore cli branch block after rebase conflict
2026-02-25 16:17:08 +01:00
Michał Pierzchała ef20dea6bc feat: add AndroidTV and tvOS target support (#125)
* feat: add AndroidTV and tvOS target support

* feat: enable tvOS runner interactions

* refactor: unify apple target handling and tvOS capability gates

* refactor: remove hardcoded tvOS app-switcher sleep

* fix: align tvOS capabilities and docs for simulator-only helpers

* feat: improve AppleTV and AndroidTV physical device detection

* refactor: simplify tv target detection helpers
2026-02-25 14:55:54 +01:00
Michał Pierzchała 996d1fca2f feat: add session perf metrics command (#121)
* feat: add session perf metrics command

* refactor: simplify open perf result shaping

* docs: improve perf guidance in docs and skill

* docs: split perf guidance into skill reference
2026-02-25 13:49:59 +01:00
Michał Pierzchała ab338263ed feat: add clipboard read and write commands (#122) 2026-02-25 13:01:33 +01:00
Michał Pierzchała 55065488f6 feat: improve logs debugging workflow (#111) 2026-02-22 15:52:26 +01:00
Michał Pierzchała e638e0ac60 feat: add full session log coverage and diagnostics workflows (#106)
* feat: add full session log coverage with doctor and marker tooling

* chore: split logs skill guidance into reference doc
2026-02-22 10:35:41 +01:00
Michał Pierzchała 87a11bd765 feat: add diff snapshot command (#81)
* feat: add snapshot diff command and snapshot efficiency guidance

* chore: polish snapshot diff baseline output

* fix: trim diff output context and normalize +/- indentation

* fix: normalize unchanged context indentation in diff output

* fix: preserve snapshot indentation in diff formatter

* fix: honor diff snapshot -i flatten mode
2026-02-20 18:37:28 +01:00
Michał Pierzchała a46d3d6e1e fix: resolve replay script paths from caller cwd (#77) 2026-02-18 20:50:34 +01:00
Michał Pierzchała feeee5e414 feat: add unified node diagnostics and error normalization (#73)
* feat: add unified node diagnostics and error normalization

* chore: clarify diagnostics session scope and retry logging docs

* chore: simplify and de-stale AGENTS guidance

* chore: add diagnostics context for settings actions
2026-02-18 19:40:45 +01:00
Michał Pierzchała 99cc68463c fix: align press/click behavior and honor fast press cadence on iOS (#70)
* fix: align press and click semantics and reduce iOS tap latency

* perf: batch repeated iOS taps in runner

* perf: add opt-in tap batching for repeated iOS presses

* perf: batch repeated iOS swipes in runner

* fix: preserve interaction series semantics in record/replay

* test: cover click/press interaction handler paths

* refactor: dedupe replay and interaction series helpers

* fix: unify press/click double-tap behavior

* refactor: add interactor doubleTap and alias docs

* refactor: normalize click alias to press path
2026-02-18 16:02:45 +01:00
Michał Pierzchała 94477dd998 feat: add daemon-native JSON batch execution (#69)
* feat: add daemon-native JSON batch command for agent workflows

* docs: add agent batching guides across readme website and skills

* chore: remove batch stdin source and related docs

* fix: harden batch step normalization and flag sanitization

* refactor: simplify batch execution and validation reuse

* docs: rename batching guidance and links
2026-02-18 11:45:19 +01:00
Michał Pierzchała ac078905c6 refactor: stabilize iOS app/session and daemon startup flows (#64)
* refactor: stabilize iOS app/session and daemon startup flows

* fix: wait for android app launch completion

* fix: address review findings for iOS appstate and daemon flows

* fixups
2026-02-16 18:19:17 +01:00
Michał Pierzchała 5709f8d3dd fix: support command-specific help output (#59)
* fix: add command-specific CLI help routing

* fix: omit empty command flag section in help
2026-02-16 11:13:38 +01:00
Michał Pierzchała 57062c8664 Refactor CLI command schema and strict flag validation (#57)
* Refactor CLI command schema and strict flag validation

* Tighten parser positional handling and ref flag validation

* Fix strict no-command flags and negative positional parsing

* simplify command schema internals and ref flag guards
2026-02-14 14:40:30 +01:00
Michał Pierzchała 3ddd3a1ef5 Complete issue #39 boot diagnostics, telemetry, and boot command (#46)
* Complete issue #39 phase diagnostics telemetry and boot command

* Address review findings for boot diagnostics and command gating

* Use agent-device boot preflight in iOS CI workflow

* Run iOS boot preflight via source CLI in CI
2026-02-12 15:00:27 +01:00
Zhongjin Lu 31a639ab5f feat: add version flags and unify version lookup (#44)
Co-authored-by: Zhongjin Lu <zhongjin.lu@mondorobotics.com>
2026-02-11 17:02:47 +01:00
Michał Pierzchała 1ecbec9012 feat: replay --save-script for self-updating e2e tests; add it assertions; add DSL with selectors (#24)
* feat:  for self-healing e2e tests;  assertions

* rework ad scripts
2026-02-09 11:01:19 +01:00
Michał Pierzchała 22bfcee0dc feat: normalize Android snapshots (#16) 2026-02-06 09:26:30 +01:00
Michał Pierzchała 2b8b936186 feat: appstate and apps --metadata 2026-02-03 16:10:21 +01:00
Michał Pierzchała 988593dc42 feat: find 2026-02-03 10:46:38 +01:00
Michał Pierzchała bf7ee21897 add apps and devices commands 2026-02-02 15:12:23 +01:00
Michał Pierzchała f060fc7fca snapshot accessibility tree 2026-01-30 21:05:58 +01:00
Michał Pierzchała 4da4745a6c initial commit 2026-01-30 19:41:00 +01:00