Commit Graph

806 Commits

Author SHA1 Message Date
Michał Pierzchała 8be5fa21a2 test: deduplicate CLI capture helpers (#450) 2026-04-26 15:13:20 -04:00
Michał Pierzchała f07e82e308 chore: add fallow quality gate (#449)
* chore: add fallow quality gate

* fix: refresh pnpm lockfile
2026-04-26 13:53:35 -04:00
Michał Pierzchała d1f5d919a8 0.13.3 v0.13.3 2026-04-26 12:11:47 -04:00
Michał Pierzchała 2e2b9af8c3 chore: drop hosted runtime entrypoints (#448) 2026-04-26 12:02:13 -04:00
Michał Pierzchała 53750084a7 refactor: finish companion tunnel naming (#446) 2026-04-26 11:42:30 -04:00
Michał Pierzchała d8c058eaf5 0.13.2 v0.13.2 2026-04-25 20:31:45 -04:00
Michał Pierzchała 48264caafa refactor: extract companion tunnel core (#442) 2026-04-25 20:31:21 -04:00
Michał Pierzchała adf1d06afc refactor: avoid duplicate packet metadata (#445) 2026-04-25 20:31:12 -04:00
Michał Pierzchała f926d2c9e1 feat: add cloud remote auth flow (#443) 2026-04-25 20:25:55 -04:00
Michał Pierzchała 3645479454 feat: export observability helpers (#444) 2026-04-25 20:24:01 -04:00
Michał Pierzchała 21d648f94a 0.13.1 v0.13.1 2026-04-25 19:31:14 -04:00
Michał Pierzchała 5cea4dd0b1 feat: pass through GitHub Actions artifact install sources (#437) 2026-04-25 19:30:51 -04:00
Michał Pierzchała 4ddd29cb5c feat: add Metro reload command (#440) 2026-04-25 19:30:24 -04:00
Michał Pierzchała 6c7e8323e1 fix: support remote Android React DevTools tunnel (#438)
* 0.13.0

* fix: support remote android react devtools tunnel
2026-04-25 19:30:12 -04:00
Aziz Becha 18cbc6ced0 fix: use sh fences for .ad scripts in replay-e2e docs (#436)
Shiki's default bundle has no `ad` grammar, so rspress build failed on
three code fences in replay-e2e.md. Aligns them with the rest of the
file, which already uses ```sh for .ad script content.
2026-04-25 16:37:08 -04:00
Michał Pierzchała b0813cad84 feat: add react devtools passthrough (#435)
* feat: add react devtools passthrough

* docs: clarify react devtools passthrough

* fix: preserve react devtools global flags

* docs: add react devtools validation guidance

* docs: simplify react devtools validation notes
2026-04-24 18:54:14 -04:00
Kacper Mikołajczak 2062bffc64 feat: parametrise .ad replay scripts (#433)
* feat: parametrise .ad replay scripts

Support ${VAR} substitution with env header directives and CLI -e
overrides so flows can be reused across app variants, environments,
and devices without duplicating the script.

Precedence (high->low): CLI -e > AD_* shell env > file-local env >
built-ins (AD_PLATFORM, AD_SESSION, AD_FILENAME, AD_DEVICE,
AD_ARTIFACTS). Supports ${VAR:-default} fallback, \${ escape, and
fails with file:line on unresolved vars.

* refactor: harden .ad replay parametrisation

Tighten the parametrisation surface introduced in the feat commit after
an internal review pass:

- Reserve the AD_* namespace for built-ins. User env (file env, CLI -e,
  shell AD_VAR_*) can no longer define AD_* keys, which closes a built-in
  shadowing vector (e.g. AD_VAR_AD_SESSION).
- Change the shell-env prefix from AD_* to AD_VAR_* so unrelated CI
  secrets that happen to start with AD_ (AD_TOKEN, AD_SECRET_KEY) are
  not auto-imported into replay scripts.
- Extend the replay -u guard to also reject scripts with \${VAR}
  substitutions in any action, not just those with env directives, so
  the writer never silently drops substitutions on heal-rewrite.
- Reword DX-unfriendly regex errors ("must match /^[A-Z_]...$/" ->
  "must be uppercase letters, digits, and underscores, e.g. APP_ID").
- Docs rewrite with precedence table, three recipes, fallback/escape
  examples, and a Notes block covering replay -u limitation, remote
  daemon caveat, no nested fallback, and loud typo behaviour.
- Additional unit tests: namespace reservation on every path, shell
  prefix migration, \${VAR} round-trip preservation through
  writeReplayScript, green-path integration test with a fake invoke.

* fix: collect .ad replay shell env on the CLI, not the daemon

Review feedback (https://github.com/callstackincubator/agent-device/pull/433#discussion_r3130695225):
the daemon was reading AD_VAR_* from its own process.env, which meant
"AD_VAR_K=V agent-device replay" only worked if V was set when the
daemon started, and never worked for remote daemons.

The client now filters process.env for AD_VAR_* at request time and
ships the result as replayShellEnv on the DaemonRequest flags. The
daemon prefers the request value when present and falls back to its
own process.env for direct-daemon callers (internal tests).

Adds two integration tests pinning both paths and updates the docs
Notes block to reflect the new behaviour.

* fix: thread per-attempt artifacts dir into AD_ARTIFACTS under test

Review feedback (https://github.com/callstackincubator/agent-device/pull/433#discussion_r3130695235):
AD_ARTIFACTS is documented as available under "agent-device test", but
buildReplayBuiltinVars was only reading the raw flags.artifactsDir.
Under the default artifacts layout the flag is unset and \${AD_ARTIFACTS}
failed; when set with --artifacts-dir it pointed at the suite root, not
the resolved per-attempt directory the test runner actually writes to.

Plumb the attempt-level artifacts dir from session-test.ts through the
runReplay callback (via runReplayTestAttempt) down into the nested
replay request's flags.artifactsDir. The daemon side is unchanged -
buildReplayBuiltinVars just now sees the right value.

Extracts the nested-request flag merge into a testable helper
(buildNestedReplayFlags) to close the coverage gap between the test
harness and the replay runtime.

* refactor: DRY .ad replay parametrisation internals

- Share VAR_KEY_RE between session-replay-vars and session-replay-script
  instead of re-declaring the same /^[A-Z_][A-Z0-9_]*$/ in each.
- Fold resolveReplayFlags + resolveReplayRuntime into a single generic
  resolveStringProps<T>; the two were near-identical object-walkers.
- Un-export parseReplayEnvLine (was only used inside its own module).
- Table-drive the four "reject AD_* namespace" tests with test.each
  instead of four near-duplicate test blocks.
- Extract runReplayFixture helper for runReplayScriptFile integration
  tests; each test is now ~10 lines instead of ~30.

No behaviour change. 812 tests still green.

* docs: clarify replay built-in variables

* test: cover replay env serialization

---------

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
2026-04-24 18:54:03 -04:00
Michał Pierzchała 22936fd628 fix: use artifacts route for daemon downloads (#434) 2026-04-24 17:52:42 -04:00
Michał Pierzchała d6b8b12acf docs: improve agent discoverability for observability (#431)
* 0.12.9

* docs: improve agent discoverability for observability

* docs: add debugging and profiling guide
2026-04-21 09:48:45 -04:00
Michał Pierzchała bb24567582 fix: improve android snapshot freshness (#430)
* fix: improve android snapshot freshness

* fix: tune android snapshot freshness mitigation

* fix: keep android ref refresh best-effort
2026-04-20 11:03:25 +02:00
Michał Pierzchała 57ba479e51 fix: add screenshot max-size flag (#428) 2026-04-18 19:30:39 +02:00
Michał Pierzchała 77365ab708 refactor: simplify Android hidden-content hints (#427) 2026-04-18 19:13:22 +02:00
Michał Pierzchała ee6cc7cc5b fix: use bridge metro runtime descriptors (#425) 2026-04-17 20:01:20 +02:00
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 bbfddc36c6 chore: add npm package metadata (#424) 2026-04-17 13:11:42 +02:00
Michał Pierzchała 67337e2f0a 0.12.8 v0.12.8 2026-04-17 12:51:54 +02:00
Michał Pierzchała add43ec4f4 fix: prevent rslib publish chunk collisions (#423) 2026-04-17 12:51:34 +02:00
Michał Pierzchała 1eddf53ae9 0.12.7 v0.12.7 2026-04-17 12:26:53 +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 3c8cbcbcfc build: allow manual iOS runner release workflow (#421) 2026-04-17 10:11:45 +02:00
Michał Pierzchała 8bc9d34576 build: fix release workflow temp path expressions (#419) 2026-04-16 18:28:08 +02:00
Michał Pierzchała a53ba204ac 0.12.6 v0.12.6 2026-04-16 18:16:57 +02:00
Michał Pierzchała 4bc6443605 build: publish iOS simulator runner release assets (#418)
* build: publish iOS simulator runner release assets

* build: switch iOS runner release asset to tar.gz

* build: resolve iOS runner from xctestrun metadata
2026-04-16 18:15:44 +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 f0eb8c6d4f feat: add runtime admin, batch, diagnostics, and recording commands (#416)
* feat: add runtime admin and orchestration commands

* feat: add runtime diagnostics commands

* refactor: clean up runtime router surface

* refactor: remove runtime cleanup dead weight

* fix: clean up admin install temp inputs on resolve failure
2026-04-16 17:41:16 +02:00
Michał Pierzchała afcd375323 feat: add runtime system and gesture commands (#415) 2026-04-16 15:32:17 +02:00
Michał Pierzchała 2c41225b7b feat: add runtime app commands (#414) 2026-04-16 14:41:10 +02:00
Michał Pierzchała 94d44d5a4f 0.12.5 v0.12.5 2026-04-16 13:03:56 +02:00
Michał Pierzchała 8bcefb754a feat: add runtime command boundary (#412)
* feat: add runtime command boundary

* refactor: harden runtime command boundary

* fix: address runtime boundary review

* fix: preserve selector snapshot flags

* fix: preserve selector get and screenshot cleanup

* fix: harden runtime boundary follow-ups

* fix: close runtime parity gaps

* test: harden android replay navigation

* fix: close screenshot surface edge cases

* test: harden packaged runtime API smoke

* fix: close runtime review edge cases

* test: isolate CLI state dir in unit helpers
2026-04-16 13:03:31 +02:00
Michał Pierzchała 5868ace77b fix: optimize remote install artifact uploads (#413)
* fix: optimize remote install artifact uploads

* refactor: clean up upload client flow

* fix: fall back after direct upload failure

* docs: correct ios install source examples
2026-04-16 12:25:50 +02:00
Michał Pierzchała 364844e01d feat: add recording quality flag (#409)
* feat: add recording quality flag

* test: cover quality edge cases

* fix: scale transform translation in resize

* fix: narrow recording quality flag
2026-04-15 13:18:57 +02:00
Michał Pierzchała 8f7375f788 ci: remove redundant Linux validation and fix unit hang (#411)
* ci: remove redundant linux validation job

* test: add bridge scope to packaged metro smoke
2026-04-15 13:01:09 +02:00
Michał Pierzchała f3a9632491 0.12.4 v0.12.4 2026-04-13 17:32:36 +02:00
Michał Pierzchała e99bbb526e fix: include lease scope in Metro bridge calls (#408) 2026-04-13 17:32:23 +02:00
Michał Pierzchała ac01393a9e 0.12.3 v0.12.3 2026-04-13 14:12:21 +02:00
Michał Pierzchała 39a09f95c4 feat: export Android app parsers (#406) 2026-04-13 14:11:53 +02:00
Michał Pierzchała 47a1529e98 feat: add remote connect lifecycle (#407) 2026-04-13 14:11:40 +02:00
Michał Pierzchała 17317d01ac fix: support saved screenshot diffs (#404) 2026-04-12 14:09:55 +02:00
Michał Pierzchała 657945d241 0.12.2 v0.12.2 2026-04-12 12:45:32 +02:00
Michał Pierzchała 3e0a7b56bb feat: enrich screenshot diff guidance (#403)
* feat: enrich screenshot diff guidance

* fix: address screenshot diff review feedback

* docs: organize screenshot diff skill guidance

* refactor: prune screenshot diff result metadata

* refactor: tighten screenshot diff readout

* refactor: generalize screenshot diff heuristics

* feat: add compact screenshot diff hints

* refactor: prune screenshot diff guidance output
2026-04-12 12:45:15 +02:00