fix(mobile): validate device.setPermission's name and state before the device call

Merged
KA
10d ago
+64-8

What and why

  • device.openApp({ permissions }) checks permission names and states, but device.setPermission sent them straight to agent-device, so 'camra' failed as ENGINE_FAILURE ("settings permission requires a target: ...").
  • setPermission now runs the same check first: a bad name (naming the nearest one), a bad state, or a missing state is INVALID_ARGUMENT, and no device command is sent.
  • The reference gets a Throws table for setPermission.

Issue

Fixes #1603

Verified

Ran it locally: yes - built CLI on an iPhone 16 simulator (iOS 18.5), scratch target on com.apple.Preferences, plus pnpm --filter @e2e-dev/mobile run test and pnpm check.

mainthis branch
setPermission('camra', 'grant')ENGINE_FAILURE: permission camra grant failed: settings permission requires a target: all|camera|...INVALID_ARGUMENT: device.setPermission has unknown key "camra"; did you mean "camera"?
setPermission('camera', 'allow')ENGINE_FAILURE: ... Invalid permission state: allow. Use <grant|deny|reset> ...INVALID_ARGUMENT: device.setPermission.camera must be one of grant, deny, reset, got "allow"
setPermission('camera', 'reset')passespasses

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.