UNPKG

agent-device

Version:

Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.

1 lines • 3.71 kB
import{r as e}from"./rolldown-runtime.js";import{v as t}from"./sdk-contracts.js";var n=e({TV_REMOTE_ANDROID_KEYCODE_PATTERN:()=>o,TV_REMOTE_BUTTONS:()=>a,TV_REMOTE_BUTTON_USAGE:()=>s,isTvRemoteButton:()=>l,parseTvRemoteButton:()=>c,toAndroidTvRemoteKeyevent:()=>m,toAppleTvRemoteButton:()=>p,toVegaTvRemoteKey:()=>h,tvRemoteButtonsForPlatform:()=>f,tvRemoteDurationMode:()=>_});const r={android:`longpress`,apple:`exact`,vega:`exact`},i={up:{aliases:[],androidKeyevent:`KEYCODE_DPAD_UP`,appleRemoteButton:`up`,vegaKey:`KEY_UP`},down:{aliases:[],androidKeyevent:`KEYCODE_DPAD_DOWN`,appleRemoteButton:`down`,vegaKey:`KEY_DOWN`},left:{aliases:[],androidKeyevent:`KEYCODE_DPAD_LEFT`,appleRemoteButton:`left`,vegaKey:`KEY_LEFT`},right:{aliases:[],androidKeyevent:`KEYCODE_DPAD_RIGHT`,appleRemoteButton:`right`,vegaKey:`KEY_RIGHT`},select:{aliases:[`ok`,`center`,`enter`],androidKeyevent:`KEYCODE_DPAD_CENTER`,appleRemoteButton:`select`,vegaKey:`KEY_ENTER`},menu:{aliases:[],androidKeyevent:`KEYCODE_MENU`,appleRemoteButton:`menu`,vegaKey:`KEY_MENU`},home:{aliases:[],androidKeyevent:`KEYCODE_HOME`,appleRemoteButton:`home`,vegaKey:`KEY_HOMEPAGE`},back:{aliases:[],androidKeyevent:`KEYCODE_BACK`,appleRemoteButton:`menu`,vegaKey:`KEY_BACK`},"volume-up":{aliases:[],androidKeyevent:`24`},"volume-down":{aliases:[],androidKeyevent:`25`},mute:{aliases:[],androidKeyevent:`164`},power:{aliases:[],androidKeyevent:`26`},sleep:{aliases:[],androidKeyevent:`223`},wake:{aliases:[],androidKeyevent:`224`},"media-play-pause":{aliases:[],androidKeyevent:`85`},"media-play":{aliases:[],androidKeyevent:`126`},"media-pause":{aliases:[],androidKeyevent:`127`},"media-stop":{aliases:[],androidKeyevent:`86`},"media-next":{aliases:[],androidKeyevent:`87`},"media-previous":{aliases:[],androidKeyevent:`88`},"media-rewind":{aliases:[],androidKeyevent:`89`},"media-fast-forward":{aliases:[],androidKeyevent:`90`},"channel-up":{aliases:[],androidKeyevent:`166`},"channel-down":{aliases:[],androidKeyevent:`167`},"last-channel":{aliases:[],androidKeyevent:`229`},guide:{aliases:[],androidKeyevent:`172`},info:{aliases:[],androidKeyevent:`165`},captions:{aliases:[],androidKeyevent:`175`},"tv-input":{aliases:[],androidKeyevent:`178`},"color-red":{aliases:[],androidKeyevent:`183`},"color-green":{aliases:[],androidKeyevent:`184`},"color-yellow":{aliases:[],androidKeyevent:`185`},"color-blue":{aliases:[],androidKeyevent:`186`}},a=Object.keys(i),o=/^android-keycode:(?:[1-9][0-9]{0,8}|1[0-9]{9}|20[0-9]{8}|21[0-3][0-9]{7}|214[0-6][0-9]{6}|2147[0-3][0-9]{5}|21474[0-7][0-9]{4}|214748[0-2][0-9]{3}|2147483[0-5][0-9]{2}|21474836[0-3][0-9]|214748364[0-7])(?![\s\S])/,s=`<${a.join(`|`)}|android-keycode:<n>>`;function c(e){let n=e?.toLowerCase();if(l(n))return n;let r=n?v.get(n):void 0;if(r)return r;throw new t(`INVALID_ARGS`,`tv-remote button must be one of: ${a.join(`, `)}, or android-keycode:<n> with n from 1 to 2147483647.`)}function l(e){return u(e)||d(e)}function u(e){return typeof e==`string`&&Object.hasOwn(i,e)}function d(e){return typeof e==`string`&&o.test(e)}function f(e){let t=e===`apple`?`appleRemoteButton`:`vegaKey`;return a.filter(e=>t in i[e])}function p(e){let t=u(e)?i[e]:void 0;if(t&&`appleRemoteButton`in t)return t.appleRemoteButton;throw g(e,`tvOS`)}function m(e){return u(e)?i[e].androidKeyevent:e.slice(16)}function h(e){let t=u(e)?i[e]:void 0;if(t&&`vegaKey`in t)return t.vegaKey;throw g(e,`Vega OS`)}function g(e,n){return new t(`UNSUPPORTED_OPERATION`,`TV remote button ${e} is not supported on ${n}.`,{reason:`unsupported-platform-leaf`})}function _(e){return r[e]}const v=new Map(a.flatMap(e=>i[e].aliases.map(t=>[t,e])));export{c as a,h as c,n as d,l as i,f as l,a as n,m as o,s as r,p as s,o as t,_ as u};