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.02 kB
JavaScript
import{$t as e,Qt as t,Zt as n,nn as r,tn as i}from"./sdk-batch.js";import{v as a}from"./sdk-contracts.js";import{m as o}from"./observability.js";function s(a){if(a.area===`frames`)return Object.freeze({kind:`frames`,request:a,use:n});if(a.area===`memory`)return a.action===`snapshot`?Object.freeze({kind:`memory-snapshot`,request:a,use:e}):Object.freeze({kind:`memory-sample`,request:a,use:t});if(a.area===`trace`)return a.action===`start`?Object.freeze({kind:`capture-start`,request:a,use:i}):Object.freeze({kind:`capture-stop`,request:a});switch(a.action){case`start`:return Object.freeze({kind:`capture-start`,request:a,use:i});case`stop`:return Object.freeze({kind:`capture-stop`,request:a});case`report`:return Object.freeze({kind:`profile-report`,request:a,use:r})}}function c(e){let t=e.positionals??[],n=t[0]?.toLowerCase();if(n===`frames`){let r=t[1]?.toLowerCase();if(r!==void 0&&r!==`sample`||t.length>2||e.kind!==void 0)throw new a(`INVALID_ARGS`,`perf action must be frames, memory sample|snapshot, cpu profile start|stop|report, or trace start|stop`);return Object.freeze({area:n,action:`sample`})}if(n===`memory`)return l(t,e);if(n===`cpu`)return u(t,e.outPath);if(n===`trace`)return d(t,e.outPath);throw new a(`INVALID_ARGS`,`perf requires frames, memory, cpu, or trace`)}function l(e,t){let n=(e[1]??`sample`).toLowerCase();if(n!==`sample`&&n!==`snapshot`)throw new a(`INVALID_ARGS`,`perf memory requires sample or snapshot`);if(t.kind!==void 0&&n!==`snapshot`)throw new a(`INVALID_ARGS`,`--kind is only supported with perf memory snapshot`);if(n===`sample`&&e.length>2)throw new a(`INVALID_ARGS`,`perf memory sample does not accept additional positionals`);if(n===`snapshot`&&e.length>3)throw new a(`INVALID_ARGS`,`perf memory snapshot accepts at most one positional kind`);let r=t.kind??e[2];if(r!==void 0&&!o(r))throw new a(`INVALID_ARGS`,`perf memory snapshot --kind must be android-hprof or memgraph`);return Object.freeze({area:`memory`,action:n,...r===void 0?{}:{kind:r},...t.outPath===void 0?{}:{outPath:t.outPath}})}function u(e,t){if(e[1]?.toLowerCase()!==`profile`)throw new a(`INVALID_ARGS`,`perf cpu requires profile`);let n=e[2]?.toLowerCase();if(n!==`start`&&n!==`stop`&&n!==`report`)throw new a(`INVALID_ARGS`,`perf cpu profile action must be start, stop, or report`);let r=e[3]?.toLowerCase();if(r!==`xctrace`&&r!==`simpleperf`)throw new a(`INVALID_ARGS`,`perf cpu profile requires --kind xctrace or simpleperf`);let i=t??e[5];return Object.freeze({area:`cpu`,subject:`profile`,action:n,kind:r,...e[4]?{template:e[4]}:{},...i?{outPath:i}:{},...e[6]?{tracePath:e[6]}:{}})}function d(e,t){let n=e[1]?.toLowerCase();if(n!==`start`&&n!==`stop`)throw new a(`INVALID_ARGS`,`perf trace action must be start or stop`);let r=e[2]?.toLowerCase();if(r!==`xctrace`&&r!==`perfetto`)throw new a(`INVALID_ARGS`,`perf trace requires --kind xctrace or perfetto`);let i=t??e[4];return Object.freeze({area:`trace`,action:n,kind:r,...e[3]?{template:e[3]}:{},...i?{outPath:i}:{}})}export{s as n,c as t};