Files
software-mansion__argent/eslint.config.mjs
Mateusz Ścianek b8afbed183 feat(tv): Apple TV (tvOS) and Android TV support (#374)
Adds end-to-end support for driving **Apple TV (tvOS)** and **Android TV
(leanback)** targets through argent, using a focus-driven interaction
model (TVs have no touchscreen — interaction is moving a focus highlight
with the remote).

This PR was reworked after review to **reuse the existing cross-platform
tool surface and the `tv-remote` tool from the Vega/Fire TV work
(#366)** rather than ship a separate family of `tv-*` tools.

## What this delivers

TV targets are driven by the **same cross-platform tools as every other
platform**, routed through the existing `dispatchByPlatform` fork
mechanism — there are no dedicated
`tv-describe`/`tv-navigate`/`tv-type`/`tv-set-focus` tools:

- **`describe`** — on a `runtimeKind: "tv"` target, returns the
focus-driven view (focused + focusable elements) instead of a tap tree.
On Android TV it auto-falls-back to the full `uiautomator` tree when the
RN focus engine exposes nothing.
- **`tv-remote`** — the cross-platform remote/D-pad tool from #366, now
extended with `ios` (Apple TV HID daemon) and `android` (Android TV adb
keyevents) branches alongside the existing `vega` branch. Single button,
a `repeat`, or a whole path (`["up","right","select"]`) in one call.
- **`keyboard`** — types into the focused field on a TV target (named
keys are rejected there — they're navigation, which belongs to
`tv-remote`).
- **`button`** stays hardware-only (phones/tablets); it is not a TV
tool.

**Apple TV** runs two native daemons (in-sim AX service + host-side HID
daemon), shipped via the `argent-private` submodule. **Android TV**
reuses the same tool surface, adb-backed (`input keyevent`, `uiautomator
dump`, `input text`).

## Remote vocabulary parity

`tv-remote` exposes the full 16-button vocabulary
(`up`/`down`/`left`/`right`/`select`/`back`/`home`/`menu`/`playPause`/`rewind`/`fastForward`/`next`/`previous`/`volumeUp`/`volumeDown`/`mute`):

| | Apple TV | Android TV | Vega |
|---|---|---|---|
| D-pad / select / back / menu / home / playPause | ✅ | ✅ | ✅ |
| media-transport + volume/mute | ❌ rejected | ✅ | ✅ |

Media-transport/volume keys **genuinely work on Android TV** (real
keycodes — verified live: `volumeUp` moved `STREAM_MUSIC`, `mute`
toggled per `dumpsys audio`). On the **Apple TV simulator** they are
**rejected with a clear error**: on-device testing confirmed the tvOS
sim's HID stack silently drops Consumer-Control events, so returning
success would be a lie.

## Key design points
- **tvOS UDIDs are UUID-shaped and indistinguishable from iOS by
shape.** Handled with `runtimeKind` detection (tvOS runtime string for
Apple TV; `pm list features` leanback/television for Android TV — *not*
`ro.build.characteristics`, which lies on TV emulators).
- Converted launch-app / restart-app / screenshot / screenshot-diff /
run-sequence from **eager** to **lazy** service resolution, so a tvOS
target never spins up (and hangs on) the iOS-only simulator-server /
native-devtools blueprints.
- Native injection selects the platform-matched (TVOSSIMULATOR) dylib
slice; daemons recycle across sim reboots and app relaunches so
injection and focus survive.
- SKILL.md footprint minimized per review: the two TV skills were
collapsed into a single lean **`argent-tv-interact`** (~40 lines).

## Verification
- `npm run build`, ESLint, Prettier, and the full tool-server suite
(**1565 tests**) all pass; CI green (incl. the Apple TV / Android TV /
Vega e2e jobs).
- Core flows verified live against real apps on both an Apple TV 4K
simulator and a Google ATV emulator.

## Dependency / merge order
Pins the `argent-private` submodule to the tip of its `feat/tv-support`
branch (software-mansion/argent-private#20). **Merge that PR to `main`
first, then bump the submodule pointer here to the merged SHA before
merging this PR.**

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 14:59:37 +02:00

110 lines
4.3 KiB
JavaScript

// @ts-check
import eslint from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";
export default tseslint.config(
{
// Not linted: build outputs, deps, generated/copied assets, and the
// argent-private submodule (it has its own repo and CI). Mirrors the
// ignores in .prettierignore + .gitignore.
ignores: [
"**/dist/",
"**/node_modules/",
"**/*.tsbuildinfo",
"packages/argent-private/",
"packages/argent/bin/",
"packages/argent/dylibs/",
"packages/argent/assets/",
"packages/argent/skills/",
"packages/argent/agents/",
"packages/argent/rules/",
"packages/native-devtools-ios/bin/",
"packages/native-devtools-ios/dylibs/",
// Downloaded Perfetto trace-processor bundle (git-ignored build artifact,
// fetched by download-trace-processor.sh) — generated, not ours to lint.
"packages/native-devtools-android/assets/trace-processor/",
"coverage/",
],
},
// Keep the gate honest: a stale or unjustified `eslint-disable` is a hard
// error, so suppressions can't quietly pile up or be used to dodge a rule.
{
linterOptions: {
reportUnusedDisableDirectives: "error",
},
},
// Type-aware linting for the TypeScript sources — this is where the value is
// (floating promises, misused promises, throwing non-Errors, etc.).
{
files: ["**/*.ts", "**/*.mts", "**/*.cts"],
extends: [eslint.configs.recommended, ...tseslint.configs.recommendedTypeChecked],
languageOptions: {
parserOptions: {
// Explicit project list rather than `projectService`: each package keeps
// its test files in a separate tsconfig.test.json (which projectService
// does not auto-discover), so we point the type-aware parser at both.
project: ["packages/*/tsconfig.json", "packages/*/tsconfig.test.json"],
tsconfigRootDir: import.meta.dirname,
},
globals: { ...globals.node },
},
rules: {
// --- Kept on, tuned ---
// Catch the real promise hazards (a promise used in a condition or
// spread) while skipping the noisy void-return variant that flags
// legitimate async callbacks (event handlers, array iteration, etc.).
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
// Allow intentionally-unused identifiers when prefixed with `_`.
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
// --- Parked: pre-existing debt, out of scope for the initial rollout ---
// These flag broad classes of existing code (mostly `any` flowing across
// untyped boundaries, and stylistic cleanups). Turned off now so the gate
// is green; ratchet each back to "error" in follow-up passes.
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-require-imports": "off",
},
},
// Test files lean on mocks/stubs and partial fixtures; relax the rules that
// fight that without losing the promise-correctness checks.
{
files: ["**/*.test.ts", "**/*.spec.ts", "**/test/**", "**/tests/**"],
rules: {
"@typescript-eslint/no-base-to-string": "off",
"no-empty": "off",
},
},
// Plain JS — this config plus the loosely-typed build/dev scripts. No type
// information available, so disable the type-checked rules for these.
{
files: ["**/*.js", "**/*.mjs", "**/*.cjs"],
extends: [eslint.configs.recommended, tseslint.configs.disableTypeChecked],
languageOptions: {
globals: { ...globals.node },
},
}
);