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 • 2.31 kB
import{C as e}from"./sdk-io.js";import{t}from"./scoped-provider.js";import n from"node:path";const r=Object.freeze({authority:`local-lease`,available:!0,start:i,inspect:async(e,t)=>await d(e,t),stop:async({device:e,runnerSessionId:t,appBundleId:n,signal:r})=>{let{runAppleRunnerCommand:i}=await import(`./runner-operations-facade.js`).then(e=>e.t);await i(e,{command:`recordStop`,appBundleId:n},{signal:r,expectedRunnerSessionId:t})}});async function i({device:e,appBundleId:t,outputPath:n,fps:r,signal:i}){let{readRunnerSessionLiveness:s,runAppleRunnerCommand:c}=await import(`./runner-operations-facade.js`).then(e=>e.t),l=`agent-device-recording-${Date.now()}.mp4`,u=e.appleOs===`macos`||e.kind!==`device`?void 0:`tmp/${l}`,d=await c(e,{command:`recordStart`,outPath:a(e,n,l,u),...r===void 0?{}:{fps:r},appBundleId:t},{signal:i}),f=s(e.id);if(!f||f.liveness!==`ready`)throw Error(`Apple runner recording did not expose a durable runner session identity`);try{i?.throwIfAborted()}catch(n){throw await c(e,{command:`recordStop`,appBundleId:t},{expectedRunnerSessionId:f.sessionId}).catch(()=>{}),n}return o(f.sessionId,u,d)}function a(e,t,r,i){return e.appleOs===`macos`?t:i===void 0?n.basename(t):r}function o(e,t,n){return Object.freeze({runnerSessionId:e,...t===void 0?{}:{remotePath:t},...typeof n.recorderStartUptimeMs==`number`?{recorderStartUptimeMs:n.recorderStartUptimeMs}:{}})}const s=Object.freeze({authority:`scoped-provider`,available:!1,start:async()=>{throw Error(`Scoped Apple runner provider does not expose durable recording authority`)},inspect:async()=>`ownership-lost`,stop:async()=>{throw Error(`Scoped Apple runner recording authority is unavailable`)}}),c=t(r);function l(){return c.resolve()}async function u(e,t){return await c.run(e??s,t)}async function d(t,n){let{readRunnerSessionLiveness:r,readStaleRunnerLease:i,verifyLeaseRunnerPidIdentity:a}=await import(`./runner-operations-facade.js`).then(e=>e.t),o=r(t.id);if(o)return o.liveness===`gone`?`missing`:o.sessionId===n?`owned-alive`:`ownership-lost`;let s=await i(t.id);return s?s.sessionId===n?s.runnerPid===null||!e(s.runnerPid)?`missing`:await a(s,s.runnerPid)?`owned-alive`:`ownership-lost`:`ownership-lost`:`missing`}export{l as resolveAppleRunnerScreenRecordingTransport,u as withAppleRunnerScreenRecordingTransport};