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.65 kB
import{v as e}from"./sdk-contracts.js";import{n as t,r as n}from"./script.js";import{h as r}from"./file.js";import{n as i}from"./shared.js";import a from"node:fs";import o from"node:path";const s=async e=>{let{positionals:t}=e;return t[0]===`export`?await l(e):c(e)};function c({positionals:t,flags:n}){if(t.length>1)throw new e(`INVALID_ARGS`,`replay accepts exactly one input path: replay <path>`);if(n.out!==void 0)throw new e(`INVALID_ARGS`,`replay --out is only supported with replay export.`);return!1}async function l({positionals:s,flags:c,host:l}){u(s,c);let d=s[1];if(!d)throw new e(`INVALID_ARGS`,`replay export requires an input path.`);let f=r(d,{cwd:l.cwd}),p=a.readFileSync(f,`utf8`),m=t(p),h=await(await import(`./replay-backend-registry.js`).then(e=>e.n)).getReplayBackend(`maestro`),g=h.exportReplayScript(m.actions,{actionLines:m.actionLines,metadata:n(p)}),_=typeof c.out==`string`?r(c.out,{cwd:l.cwd}):void 0;_&&(a.mkdirSync(o.dirname(_),{recursive:!0}),a.writeFileSync(_,g.yaml));for(let e of g.warnings)process.stderr.write(`Warning: line ${e.line}: ${e.message}\n`);return await i(c,{format:h.id,sourcePath:f,..._?{path:_}:{yaml:g.yaml},warnings:g.warnings},()=>_??g.yaml),!0}function u(t,n){if(t.length>2)throw new e(`INVALID_ARGS`,`replay export accepts exactly one input path: replay export <file.ad>`);if(n.replayUpdate)throw new e(`INVALID_ARGS`,`replay export does not support --update.`);if(n.replayMaestro)throw new e(`INVALID_ARGS`,`replay export reads .ad files; omit --maestro.`);if(n.replayEnv?.length)throw new e(`INVALID_ARGS`,`replay export does not evaluate --env substitutions.`)}export{s as replayCommand};