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 • 838 B
JavaScript
import{v as e}from"./sdk-contracts.js";import"./file.js";import{r as t,t as n}from"./verified-file.js";import r from"node:fs";import i from"node:path";function a(e,t){let n=i.dirname(e);r.existsSync(n)||r.mkdirSync(n,{recursive:!0}),c(e),s(e,o(t))}function o(e){return{maxBytes:u(e.AGENT_DEVICE_APP_LOG_MAX_BYTES,5242880),maxRotatedFiles:u(e.AGENT_DEVICE_APP_LOG_MAX_FILES,1)}}function s(e,t){let n=l(e);if(!(!n||n.size<t.maxBytes))for(let n=t.maxRotatedFiles;n>=1;--n){let t=n===1?e:`${e}.${n-1}`,i=`${e}.${n}`;l(t)&&(l(i)&&r.unlinkSync(i),r.renameSync(t,i))}}function c(e){l(e)}function l(r){let i=t(r);if(i?.isSymbolicLink())throw new e(`COMMAND_FAILED`,`App-log file must not be a symbolic link: ${r}`,{hint:n});return i}function u(e,t){let n=Number.parseInt(e??``,10);return Number.isInteger(n)&&n>0?n:t}export{o as n,s as r,a as t};