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 • 1.32 kB
import{M as e,Tn as t}from"./sdk-batch.js";import{i as n}from"./screen-recording-session-resource.js";async function r(e){let t;try{return t=await e.gateway.bind({device:i(e.envelope),intent:{kind:`exact-owner`,owner:e.envelope.owner,fence:e.envelope.fence},scope:e.scope}),e.scope.signal.throwIfAborted(),e.create(t)}catch(e){throw t&&await t[Symbol.asyncDispose](),e}}function i(e){return{platform:e.device.family,id:e.device.id,name:e.device.id,kind:e.device.kind,...e.device.target===void 0?{}:{target:e.device.target},...e.device.appleOs===void 0?{}:{appleOs:e.device.appleOs},...e.device.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.device.iosPhysicalDeviceBackend}}}function a(e){return n.recoverOne({sessionsDir:e.sessionsDir,scope:e.scope,acquisitionDeadlineMs:e.acquisitionDeadlineMs,onDiagnostic:e.onDiagnostic,acquireControl:async(t,n)=>await o(e.gateway,t,n)},e.resourcePath)}async function o(n,i,a){return await r({gateway:n,envelope:i,scope:a,create:n=>s({runtime:t(n,e),dispose:async()=>await n[Symbol.asyncDispose]()})})}function s(e){return Object.freeze({reattach:async t=>await e.runtime.operations.screenRecordingReattach({envelope:t}),cleanup:async t=>await e.runtime.operations.screenRecordingCleanup({envelope:t}),[Symbol.asyncDispose]:e.dispose})}export{a as n,r,s as t};