Class: Melaya::PhoneAPI
- Inherits:
-
Object
- Object
- Melaya::PhoneAPI
- Defined in:
- lib/melaya/phone.rb
Overview
Phone API — pair and control Android devices connected to the Melaya runner.
Agents use these endpoints to drive a paired phone (tap, type, read screen state, launch apps) via the Melaya APK.
Maps to /api/v1/private/phone/*.
Instance Method Summary collapse
-
#initialize(http) ⇒ PhoneAPI
constructor
A new instance of PhoneAPI.
-
#list_apps ⇒ Object
GET /api/v1/private/phone/apps List installed apps on the paired phone.
-
#list_devices ⇒ Object
GET /api/v1/private/phone/devices List all paired phone devices for the authenticated user.
-
#pair ⇒ Object
POST /api/v1/private/phone/pair Start phone device pairing — generates a pairing code for the Melaya APK.
-
#register_active_run(run_id) ⇒ Object
POST /api/v1/private/phone/active-run Register the currently active pipeline run on the phone (used by agents).
-
#revoke_device(device_id) ⇒ Object
DELETE /api/v1/private/phone/devices/:deviceId Revoke a paired phone device by ID.
-
#screen_tree ⇒ Object
GET /api/v1/private/phone/screen-tree Get the current accessibility tree from the paired phone's screen.
-
#set_allowed_apps(package_names) ⇒ Object
PUT /api/v1/private/phone/apps/allowed Set the allowlist of apps that agents are permitted to interact with.
Constructor Details
#initialize(http) ⇒ PhoneAPI
Returns a new instance of PhoneAPI.
19 20 21 |
# File 'lib/melaya/phone.rb', line 19 def initialize(http) @http = http end |
Instance Method Details
#list_apps ⇒ Object
GET /api/v1/private/phone/apps List installed apps on the paired phone.
50 51 52 |
# File 'lib/melaya/phone.rb', line 50 def list_apps @http.get("/api/v1/private/phone/apps").dig("result", "apps") || [] end |
#list_devices ⇒ Object
GET /api/v1/private/phone/devices List all paired phone devices for the authenticated user.
31 32 33 |
# File 'lib/melaya/phone.rb', line 31 def list_devices @http.get("/api/v1/private/phone/devices").fetch("devices", []) end |
#pair ⇒ Object
POST /api/v1/private/phone/pair Start phone device pairing — generates a pairing code for the Melaya APK.
25 26 27 |
# File 'lib/melaya/phone.rb', line 25 def pair @http.post("/api/v1/private/phone/pair") end |
#register_active_run(run_id) ⇒ Object
POST /api/v1/private/phone/active-run Register the currently active pipeline run on the phone (used by agents).
65 66 67 |
# File 'lib/melaya/phone.rb', line 65 def register_active_run(run_id) @http.post("/api/v1/private/phone/active-run", "runId" => run_id) end |
#revoke_device(device_id) ⇒ Object
DELETE /api/v1/private/phone/devices/:deviceId Revoke a paired phone device by ID.
38 39 40 |
# File 'lib/melaya/phone.rb', line 38 def revoke_device(device_id) @http.delete("/api/v1/private/phone/devices/#{enc(device_id)}") end |
#screen_tree ⇒ Object
GET /api/v1/private/phone/screen-tree Get the current accessibility tree from the paired phone's screen.
44 45 46 |
# File 'lib/melaya/phone.rb', line 44 def screen_tree @http.get("/api/v1/private/phone/screen-tree") end |
#set_allowed_apps(package_names) ⇒ Object
PUT /api/v1/private/phone/apps/allowed Set the allowlist of apps that agents are permitted to interact with.
57 58 59 60 |
# File 'lib/melaya/phone.rb', line 57 def set_allowed_apps(package_names) apps = package_names.map { |package| { "package" => package } } @http.put("/api/v1/private/phone/apps/allowed", "apps" => apps) end |