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.65 kB
JavaScript
import{r as e}from"./rolldown-runtime.js";import{J as t,St as n,X as r,Z as i,dt as a,it as o,pt as s,rt as c}from"./sdk-io.js";import"./diagnostics.js";import"./command.js";import{m as l}from"./adb-executor.js";import{t as u}from"./device-shell.js";import{c as d}from"./adb-transport.js";import"./mechanics.js";import{createHash as f,randomUUID as p}from"node:crypto";import{constants as m}from"node:fs";import h from"node:os";import g from"node:path";import{access as _,mkdir as v,mkdtemp as y,open as b,readFile as x,readdir as S,rename as C,rm as w,stat as T,writeFile as E}from"node:fs/promises";var D=e({});function O(e){u(e,`adb`)}l({get environment(){return r().env},files:{access:async e=>await _(e),ensureDirectory:async e=>{await v(e,{recursive:!0})},isExecutable:async e=>{try{return await _(e,m.X_OK),!0}catch{return!1}},makeTempDirectory:async e=>await y(g.join(h.tmpdir(),e)),readBytes:async e=>await x(e),readDirectory:async e=>await S(e),readText:async e=>await x(e,`utf8`),remove:async(e,t)=>await w(e,t),stat:async e=>{let t=await T(e);return{isFile:t.isFile(),size:t.size}},sha256:e=>f(`sha256`).update(e).digest(`hex`),writeAtomicText:async(e,t,n=384)=>{let r=g.dirname(e),i=g.join(r,`.${g.basename(e)}.${p()}.tmp`),a,o=!1;try{a=await b(i,`wx`,n),await a.writeFile(t,`utf8`),await a.sync(),await a.close(),a=void 0,await C(i,e),o=!0;let s;try{s=await b(r,`r`),await s.sync()}catch{}finally{s&&await s.close().catch(()=>{})}}finally{a&&await a.close().catch(()=>{}),o||await w(i,{force:!0}).catch(()=>{})}},writeBytes:async(e,t)=>await E(e,t)},execAdb:async(e,t)=>{O(e.command);let n=d(e,t,r().env);return await c(`adb`,n.args,{...n.options,detached:process.platform!==`win32`})},spawnAdb:(e,t)=>{O(e.command);let n=d(e,t,r().env),i=o(`adb`,n.args,{...n.options,allowFailure:!0,captureOutput:!1});return i.wait.catch(()=>{}),i.child},withAdbCommandExecutorOverride:a,withoutAdbCommandExecutorOverride:s,coerceAdbResult:t,execFailureDetails:i,emitDiagnostic:n,imeRecoveryMarkers:{write:async(e,t)=>{let{writeAndroidTestImeRecoveryMarker:n}=await import(`./mechanics.js`).then(e=>e.r);return await n(e,t)},clear:async(e,t)=>{let{clearAndroidTestImeRecoveryMarker:n}=await import(`./mechanics.js`).then(e=>e.r);await n(e,t)},read:async e=>{let{readAndroidTestImeRecoveryMarkers:t}=await import(`./mechanics.js`).then(e=>e.r);return await t(e)}},resolveHelperArtifact:async e=>{let{resolveAndroidHelperArtifact:t}=await import(`./mechanics.js`).then(e=>e.r);return await t(e)},ensureHelperInstalled:async(e,t)=>{let{makeEnsureAndroidHelperInstalled:n}=await import(`./mechanics.js`).then(e=>e.r);return await n(e)(t)}});export{D as t};