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{v as t}from"./sdk-contracts.js";import{g as n}from"./sdk-batch-runner.js";import{St as r}from"./sdk-io.js";import"./diagnostics.js";import{J as i,Z as a}from"./sdk-device.js";import{r as o}from"./recording-scope.js";import{i as s,n as c}from"./recording-stop-observation.js";import{n as l,t as u}from"./screen-recording-resource-store.js";import d from"node:fs";var f=e({readReplayableStoredCompletion:()=>y,resolveScreenRecordingStopRecovery:()=>m,screenRecordingManifestDevice:()=>g,screenRecordingManifestIsTerminal:()=>h});const p=[`clientOutPath`,`telemetryPath`,`warning`,`overlayWarning`];function m(e){let{resourcePath:t,record:n}=_(e);if(n.status!==`decoded`)return{kind:`none`};if(v(e,n.envelope),n.envelope.lifecycle!==`completed`)return{kind:`open`,resourcePath:t};let i=y(n.envelope.metadata);return i===void 0?(r({level:`warn`,phase:`screen_recording_completed_manifest_unreplayable`,data:{resourcePath:t}}),{kind:`none`}):{kind:`completed`,completion:i}}function h(e){let{record:t}=_(e);return t.status===`decoded`&&t.envelope.lifecycle===`completed`}function g(e){let{record:t}=_(e);return t.status===`decoded`?t.envelope.device:void 0}function _(e){let t=l.resolvePath(e.sessionStore.resolveSessionDir(e.sessionName));return{resourcePath:t,record:l.read(t)}}function v(e,n){if(n.sessionId!==e.sessionName)throw new t(`COMMAND_FAILED`,`Screen recording recovery record does not belong to the requested session`,{reason:`runtime-contract-invalid`});if(!a(n.device,i(e.device)))throw new t(`COMMAND_FAILED`,`Screen recording recovery device does not match the selected device`,{reason:`runtime-contract-invalid`})}function y(e){let t=e?.[u];if(!n(t)||!b(t)||!x(t)||!S(t))return;let r=t;return d.existsSync(r.outPath)?r:void 0}function b(e){return C(e.outPath)&&C(e.backend)&&T(e.startedAt)&&T(e.completedAt)&&(e.capturedDurationMs===void 0||T(e.capturedDurationMs))&&o(e.scope)&&typeof e.showTouches==`boolean`&&typeof e.recordOnlySession==`boolean`}function x(e){return p.every(t=>w(e[t]))&&D(e.activeSessionApp)&&k(e.chunks)}function S(e){return(e.stopObservation===void 0||c(e.stopObservation))&&(e.nativePathDisposition===void 0||s(e.nativePathDisposition))}function C(e){return typeof e==`string`&&e.length>0}function w(e){return e===void 0||C(e)}function T(e){return typeof e==`number`&&Number.isFinite(e)}function E(e){return!n(e)||!C(e.bundleId)?!1:w(e.name)}function D(e){return e===void 0||E(e)}function O(e){return Array.isArray(e)&&e.every(e=>n(e)&&Number.isFinite(e.index)&&C(e.path)&&w(e.clientOutPath))}function k(e){return e===void 0||O(e)}export{f as i,g as n,h as r,m as t};