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.44 kB
JavaScript
import{v as e}from"./sdk-contracts.js";import{n as t,r as n}from"./session-paths.js";import r from"node:fs";import i from"node:path";function a(e){return i.join(e,`runner.log`)}function o(e){return i.join(e,`test-artifacts`)}function s(e,t){let r=n(t&&t.length>0?t:`unknown`);return i.join(e,`requests`,`${r}.ndjson`)}function c(e){return{path:s(e.sessionDir,e.requestId),ref:{session:e.session,requestId:e.requestId&&e.requestId.length>0?e.requestId:`unknown`}}}function l(e,t){return s(u(i.join(e,`remote-diagnostics`),t.session),t.requestId)}function u(r,a){if(!t(a))throw new e(`INVALID_ARGS`,`Invalid session name ${JSON.stringify(a)}: a session name cannot be empty, ".", or "..".`);return i.join(r,n(a))}function d(e,t){return i.join(u(e,t),`app.log`)}function f(e,t){return i.join(u(e,t),`app-log.pid`)}function p(e){let t=i.resolve(e.sessionsDir),n=i.resolve(e.pathname);if(i.basename(n)!==e.basename)throw Error(`${e.label} is outside the daemon-owned sessions directory`);if(r.existsSync(t)&&r.existsSync(i.dirname(n))){let a=r.realpathSync.native(t),o=r.realpathSync.native(i.dirname(n));if(o!==a&&!o.startsWith(`${a}${i.sep}`))throw Error(`${e.label} resolves outside the daemon-owned sessions directory`);return i.join(o,e.basename)}if(n!==t&&!n.startsWith(`${t}${i.sep}`))throw Error(`${e.label} is outside the daemon-owned sessions directory`);return n}export{u as a,a as c,f as i,o as l,l as n,c as o,d as r,s,p as t};