agent-device 0.21.19 → 0.21.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.19.apk → agent-device-android-ime-helper-0.21.20.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.20.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.19.manifest.json → agent-device-android-ime-helper-0.21.20.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.19.apk → agent-device-android-snapshot-helper-0.21.20.apk} +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.20.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.19.manifest.json → agent-device-android-snapshot-helper-0.21.20.manifest.json} +6 -6
  7. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +12 -0
  8. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +1 -14
  9. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +14 -16
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +40 -14
  11. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +20 -5
  12. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +2 -15
  13. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +10 -25
  14. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFoldProjection.swift +1 -18
  15. package/dist/src/adapter.js +1 -1
  16. package/dist/src/adb-failure.js +1 -1
  17. package/dist/src/agent-browser-process-record.js +1 -1
  18. package/dist/src/agent-browser-provider.js +1 -1
  19. package/dist/src/agent-browser-tool.js +1 -1
  20. package/dist/src/agent-device-client.js +2 -2
  21. package/dist/src/alert-runtime.js +1 -1
  22. package/dist/src/alert.js +1 -0
  23. package/dist/src/android-input-ownership.js +1 -1
  24. package/dist/src/app-launch.js +2 -2
  25. package/dist/src/app-lifecycle.js +1 -1
  26. package/dist/src/app-resolution.js +2 -2
  27. package/dist/src/apple-runner-platform.js +1 -1
  28. package/dist/src/archive.js +2 -2
  29. package/dist/src/browser-launch.js +1 -1
  30. package/dist/src/cache.js +1 -1
  31. package/dist/src/cli-config.js +1 -1
  32. package/dist/src/cli-help.js +287 -301
  33. package/dist/src/cli-runner.js +1 -1
  34. package/dist/src/cli.js +1 -1
  35. package/dist/src/client-metro-companion.js +1 -1
  36. package/dist/src/client-metro.js +1 -1
  37. package/dist/src/client-types.d.ts +14 -2
  38. package/dist/src/{scroll-command.d.ts → cloud-artifacts.d.ts} +242 -238
  39. package/dist/src/command-schema.js +3 -3
  40. package/dist/src/command-tools.js +2 -2
  41. package/dist/src/command.js +1 -1
  42. package/dist/src/config.js +1 -1
  43. package/dist/src/connection-runtime.js +1 -1
  44. package/dist/src/daemon-client-lifecycle.js +1 -1
  45. package/dist/src/daemon-client-transport.js +1 -1
  46. package/dist/src/daemon-registration.js +1 -1
  47. package/dist/src/debug-symbols-facade.js +3 -3
  48. package/dist/src/device-rotation.js +1 -1
  49. package/dist/src/devicectl.js +1 -1
  50. package/dist/src/display-inventory.js +1 -1
  51. package/dist/src/exec.js +1 -1
  52. package/dist/src/hdc.js +1 -1
  53. package/dist/src/helper.js +2 -2
  54. package/dist/src/host.js +1 -1
  55. package/dist/src/index.d.ts +1 -1
  56. package/dist/src/interactor.js +5 -5
  57. package/dist/src/interactor2.js +1 -1
  58. package/dist/src/internal/bin.js +1 -1
  59. package/dist/src/internal/daemon.js +2 -2
  60. package/dist/src/launch-confirmation.js +1 -0
  61. package/dist/src/limrun-runtime-dependencies.js +1 -1
  62. package/dist/src/limrun.d.ts +50 -42
  63. package/dist/src/mechanics.js +16 -16
  64. package/dist/src/owner-identity.js +1 -1
  65. package/dist/src/perf-facade.js +1 -1
  66. package/dist/src/perf-target.js +1 -1
  67. package/dist/src/physical-device-control.js +1 -1
  68. package/dist/src/platform-runtime-android-adb-host.js +1 -1
  69. package/dist/src/platform-runtime-app-log-process.js +1 -1
  70. package/dist/src/platform-runtime-host.js +1 -1
  71. package/dist/src/platform-runtime-operation-host.js +2 -2
  72. package/dist/src/platform-runtime-runtime-hints.js +1 -1
  73. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  74. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  75. package/dist/src/provider-session-ownership.js +1 -1
  76. package/dist/src/provider-webdriver.js +1 -1
  77. package/dist/src/registry.js +20 -4
  78. package/dist/src/result-serialization.js +1 -1
  79. package/dist/src/runner-cache-metadata.js +3 -3
  80. package/dist/src/runner-client.js +1 -1
  81. package/dist/src/runner-dev-tools-security.js +1 -1
  82. package/dist/src/runner-device-readiness.js +1 -1
  83. package/dist/src/runner-disposal.js +1 -1
  84. package/dist/src/runner-error-classification.js +1 -1
  85. package/dist/src/runner-exchange.js +1 -1
  86. package/dist/src/runner-operations-facade.js +1 -1
  87. package/dist/src/runner-session-types.js +1 -1
  88. package/dist/src/runner-start-budget.js +1 -1
  89. package/dist/src/runner-startup-transport.js +1 -1
  90. package/dist/src/runner-xctestrun.js +1 -1
  91. package/dist/src/runtime.js +1 -1
  92. package/dist/src/runtime10.js +1 -1
  93. package/dist/src/runtime2.js +1 -1
  94. package/dist/src/runtime4.js +5 -5
  95. package/dist/src/screenshot-result.js +1 -1
  96. package/dist/src/screenshot-runtime.js +1 -1
  97. package/dist/src/screenshot3.js +1 -1
  98. package/dist/src/sdk-contracts.d.ts +2 -0
  99. package/dist/src/sdk-contracts.js +2 -2
  100. package/dist/src/sdk-selectors.d.ts +4 -4
  101. package/dist/src/session2.js +1 -1
  102. package/dist/src/simulator-boot.js +1 -1
  103. package/dist/src/simulator.js +1 -1
  104. package/dist/src/snapshot-runtime.js +1 -1
  105. package/dist/src/tool-provider.js +3 -3
  106. package/dist/src/tool-provider2.js +1 -1
  107. package/dist/src/tool-provider3.js +1 -1
  108. package/dist/src/toolchain-probe.js +1 -1
  109. package/dist/src/update-check.js +1 -1
  110. package/dist/src/video.js +1 -1
  111. package/package.json +1 -1
  112. package/server.json +2 -2
  113. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.19.apk.sha256 +0 -1
  114. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.19.apk.sha256 +0 -1
@@ -1,3 +1,3 @@
1
- import{p as e}from"./sdk-device.js";import{c as t}from"./exec.js";import"./command.js";const n=`launchd_sim`,r={LC_ALL:`C`},i=/^(\d+)\s+([A-Za-z]{3} [A-Za-z]{3} +\d{1,2} \d{2}:\d{2}:\d{2} \d{4})\s+(.+)$/,a=/^[A-Za-z]{3} ([A-Za-z]{3}) +(\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/,o=new Map([[`Jan`,0],[`Feb`,1],[`Mar`,2],[`Apr`,3],[`May`,4],[`Jun`,5],[`Jul`,6],[`Aug`,7],[`Sep`,8],[`Oct`,9],[`Nov`,10],[`Dec`,11]]);async function s(t){if(!e(t)||t.kind!==`simulator`)return{observed:!1,reason:`unsupported-device`};let n=await c();if(n.length===0)return{observed:!1,reason:`unobserved`};let r=d(await l(n),t.id);return r===void 0?{observed:!1,reason:`unobserved`}:{observed:!0,bootedAtMs:r}}async function c(){let e=await u(`/usr/bin/pgrep`,[`-x`,n]);return e===void 0?[]:e.split(`
1
+ import{p as e}from"./sdk-device.js";import{l as t}from"./exec.js";import"./command.js";const n=`launchd_sim`,r={LC_ALL:`C`},i=/^(\d+)\s+([A-Za-z]{3} [A-Za-z]{3} +\d{1,2} \d{2}:\d{2}:\d{2} \d{4})\s+(.+)$/,a=/^[A-Za-z]{3} ([A-Za-z]{3}) +(\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/,o=new Map([[`Jan`,0],[`Feb`,1],[`Mar`,2],[`Apr`,3],[`May`,4],[`Jun`,5],[`Jul`,6],[`Aug`,7],[`Sep`,8],[`Oct`,9],[`Nov`,10],[`Dec`,11]]);async function s(t){if(!e(t)||t.kind!==`simulator`)return{observed:!1,reason:`unsupported-device`};let n=await c();if(n.length===0)return{observed:!1,reason:`unobserved`};let r=d(await l(n),t.id);return r===void 0?{observed:!1,reason:`unobserved`}:{observed:!0,bootedAtMs:r}}async function c(){let e=await u(`/usr/bin/pgrep`,[`-x`,n]);return e===void 0?[]:e.split(`
2
2
  `).map(e=>Number.parseInt(e.trim(),10)).filter(e=>Number.isInteger(e)&&e>0)}async function l(e){return await u(`/bin/ps`,[`-p`,e.join(`,`),`-o`,`pid=,lstart=,command=`],r)??``}async function u(e,n,r){try{let i=await t(e,[...n],{allowFailure:!0,timeoutMs:2e3,...r?{env:r}:{}});return i.exitCode===0?i.stdout:void 0}catch{return}}function d(e,t){let n=Date.now(),r;for(let i of e.split(`
3
3
  `)){let e=f(i,t);e===void 0||e>n||(r===void 0||e>r)&&(r=e)}return r}function f(e,t){let[,n,r]=i.exec(e)?.slice(1)??[];if(n!==void 0&&r!==void 0&&p(r,t))return m(n)}function p(e,t){let[r,...i]=e.trim().split(/\s+/);return r!==void 0&&r.split(`/`).pop()===n&&i.some(e=>e.includes(t))}function m(e){let[,t,n,r,i,s,c]=a.exec(e.trim())??[],l=t===void 0?void 0:o.get(t);if(l===void 0)return;let u=new Date(Number(c),l,Number(n),Number(r),Number(i),Number(s)).getTime();return Number.isFinite(u)?u:void 0}export{s as observeSimulatorBootTimeMs};
@@ -1 +1 @@
1
- import{N as e}from"./sdk-contracts.js";import{a as t,n}from"./exec.js";import"./command.js";import{i as r,n as i}from"./retry.js";import{t as a}from"./ttl-memo.js";import{n as o,t as s}from"./boot-diagnostics.js";import{t as c}from"./scoped-provider.js";import{l,r as u,u as d}from"./config.js";import{a as f,o as p}from"./tool-provider.js";import{n as m,r as h}from"./simctl.js";const g=c(void 0);async function _(e,t){return await g.run(e,t)}const v=a({ttlMs:5e3});function y(e){return`${e.id}|${e.simulatorSetPath??``}`}function b(e){return v.get(y(e))===!0}function x(e){v.set(y(e),!0)}function S(t,n){if(t.kind!==`simulator`)throw new e(`UNSUPPORTED_OPERATION`,`${n} is only supported on iOS simulators`)}async function C(e={}){await f(`open`,[`-a`,`Simulator`],{allowFailure:!0,signal:e.signal,timeoutMs:d})}async function w(a,c={}){if(a.kind!==`simulator`)return;c.signal?.throwIfAborted();let l=g.resolve();if(l){await l(a),c.signal?.throwIfAborted();return}if((b(a)?`Booted`:await T(a,c.signal))===`Booted`){x(a);return}let d=i.fromTimeoutMs(u),f,h;try{await r(async({deadline:r})=>{if(r?.isExpired())throw new e(`COMMAND_FAILED`,`iOS simulator boot deadline exceeded`,{timeoutMs:u});let i=Math.max(1e3,r?.remainingMs()??18e4);f=await p(m(a,[`boot`,a.id]),{allowFailure:!0,signal:c.signal,timeoutMs:i});let o=`${f.stdout}\n${f.stderr}`.toLowerCase(),s=o.includes(`already booted`)||o.includes(`current state: booted`);if(f.exitCode!==0&&!s)throw new e(`COMMAND_FAILED`,`simctl boot failed`,n(f));h=await p(m(a,[`bootstatus`,a.id,`-b`]),{allowFailure:!0,signal:c.signal,timeoutMs:i}),t(h,`simctl bootstatus failed`);let l=await T(a,c.signal);if(l!==`Booted`)throw new e(`COMMAND_FAILED`,`Simulator is still booting`,{state:l})},{maxAttempts:3,baseDelayMs:500,maxDelayMs:2e3,jitter:.2,shouldRetry:e=>{let t=o({error:e,stdout:h?.stdout??f?.stdout,stderr:h?.stderr??f?.stderr,context:{platform:`ios`,phase:`boot`}});return t!==`IOS_BOOT_TIMEOUT`&&t!==`CI_RESOURCE_STARVATION_SUSPECTED`}},{deadline:d,phase:`boot`,signal:c.signal,classifyReason:e=>o({error:e,stdout:h?.stdout??f?.stdout,stderr:h?.stderr??f?.stderr,context:{platform:`ios`,phase:`boot`}})})}catch(t){let n=o({error:t,stdout:h?.stdout??f?.stdout,stderr:h?.stderr??f?.stderr,context:{platform:`ios`,phase:`boot`}});throw new e(`COMMAND_FAILED`,`iOS simulator failed to boot`,{platform:`ios`,deviceId:a.id,timeoutMs:u,elapsedMs:d.elapsedMs(),reason:n,hint:s(n),boot:f,bootstatus:h})}x(a),await C({signal:c.signal})}async function T(e,t){let n=m(e,[`list`,`devices`,`-j`]),r=await p(n,{allowFailure:!0,signal:t,timeoutMs:l});return r.exitCode===0?h(r.stdout,e.id):null}export{_ as a,b as i,x as n,S as r,w as t};
1
+ import{N as e}from"./sdk-contracts.js";import{o as t,r as n}from"./exec.js";import"./command.js";import{i as r,n as i}from"./retry.js";import{t as a}from"./ttl-memo.js";import{n as o,t as s}from"./boot-diagnostics.js";import{t as c}from"./scoped-provider.js";import{l,r as u,u as d}from"./config.js";import{a as f,o as p}from"./tool-provider.js";import{n as m,r as h}from"./simctl.js";const g=c(void 0);async function _(e,t){return await g.run(e,t)}const v=a({ttlMs:5e3});function y(e){return`${e.id}|${e.simulatorSetPath??``}`}function b(e){return v.get(y(e))===!0}function x(e){v.set(y(e),!0)}function S(t,n){if(t.kind!==`simulator`)throw new e(`UNSUPPORTED_OPERATION`,`${n} is only supported on iOS simulators`)}async function C(e={}){await f(`open`,[`-a`,`Simulator`],{allowFailure:!0,signal:e.signal,timeoutMs:d})}async function w(a,c={}){if(a.kind!==`simulator`)return;c.signal?.throwIfAborted();let l=g.resolve();if(l){await l(a),c.signal?.throwIfAborted();return}if((b(a)?`Booted`:await T(a,c.signal))===`Booted`){x(a);return}let d=i.fromTimeoutMs(u),f,h;try{await r(async({deadline:r})=>{if(r?.isExpired())throw new e(`COMMAND_FAILED`,`iOS simulator boot deadline exceeded`,{timeoutMs:u});let i=Math.max(1e3,r?.remainingMs()??18e4);f=await p(m(a,[`boot`,a.id]),{allowFailure:!0,signal:c.signal,timeoutMs:i});let o=`${f.stdout}\n${f.stderr}`.toLowerCase(),s=o.includes(`already booted`)||o.includes(`current state: booted`);if(f.exitCode!==0&&!s)throw new e(`COMMAND_FAILED`,`simctl boot failed`,n(f));h=await p(m(a,[`bootstatus`,a.id,`-b`]),{allowFailure:!0,signal:c.signal,timeoutMs:i}),t(h,`simctl bootstatus failed`);let l=await T(a,c.signal);if(l!==`Booted`)throw new e(`COMMAND_FAILED`,`Simulator is still booting`,{state:l})},{maxAttempts:3,baseDelayMs:500,maxDelayMs:2e3,jitter:.2,shouldRetry:e=>{let t=o({error:e,stdout:h?.stdout??f?.stdout,stderr:h?.stderr??f?.stderr,context:{platform:`ios`,phase:`boot`}});return t!==`IOS_BOOT_TIMEOUT`&&t!==`CI_RESOURCE_STARVATION_SUSPECTED`}},{deadline:d,phase:`boot`,signal:c.signal,classifyReason:e=>o({error:e,stdout:h?.stdout??f?.stdout,stderr:h?.stderr??f?.stderr,context:{platform:`ios`,phase:`boot`}})})}catch(t){let n=o({error:t,stdout:h?.stdout??f?.stdout,stderr:h?.stderr??f?.stderr,context:{platform:`ios`,phase:`boot`}});throw new e(`COMMAND_FAILED`,`iOS simulator failed to boot`,{platform:`ios`,deviceId:a.id,timeoutMs:u,elapsedMs:d.elapsedMs(),reason:n,hint:s(n),boot:f,bootstatus:h})}x(a),await C({signal:c.signal})}async function T(e,t){let n=m(e,[`list`,`devices`,`-j`]),r=await p(n,{allowFailure:!0,signal:t,timeoutMs:l});return r.exitCode===0?h(r.stdout,e.id):null}export{_ as a,b as i,x as n,S as r,w as t};
@@ -1 +1 @@
1
- import{N as e,O as t,g as n,q as r}from"./sdk-contracts.js";import"./capture.js";import{r as i}from"./snapshot-capture-annotations.js";import{i as a}from"./snapshot-diagnostics.js";import{f as o}from"./android-input-ownership.js";import{C as s}from"./sdk-device.js";import{s as c}from"./session-store.js";import{l,u}from"./target-evidence.js";import{n as d}from"./success-text.js";import{r as f}from"./diagnostics.js";import"./diagnostics2.js";import{n as p}from"./android-snapshot-quality.js";import{i as m}from"./android-system-chrome.js";import{r as h}from"./request-cancel.js";import"./request.js";import{D as g,a as _,h as v,o as y,s as b,u as x}from"./session-snapshot.js";import{a as S,i as C,r as w,t as T}from"./screenshot-runtime.js";import{a as E}from"./session-routing.js";import{s as D,t as O}from"./quality-warnings.js";import{n as k,o as A,r as j}from"./snapshot-runtime-binding.js";import M from"node:path";import{promises as N}from"node:fs";import P from"node:os";function F(e){return{captureFailed:!0,error:e}}function I(e){return{path:e,overlayRefsRequested:!0,overlayRefsAnnotated:!1,overlayRefSource:`unavailable`}}function L(e,t){let n={path:e,overlayRefsRequested:!0,overlayRefSource:`session-snapshot`};return R(t)?{...n,overlayRefsAnnotated:!0,overlayRefs:t}:{...n,overlayRefsAnnotated:!1,overlayRefs:[]}}function R(e){return e.length>0}function z(e,t){return{path:e,overlayRefsRequested:!0,overlayRefsAnnotated:!1,overlayRefSource:`session-snapshot`,overlayAnnotationError:t}}function B(e){return`captureFailed`in e?{overlayRefCount:void 0,overlayRefsAnnotated:void 0}:{overlayRefCount:`overlayRefs`in e?e.overlayRefs.length:0,overlayRefsAnnotated:e.overlayRefsAnnotated}}function ee(e){return p(e)===`accessibility-timeout`}async function V(e){if(e.command!==`snapshot`||e.device.platform!==`android`)return;let t=r(e.error);if(ee(t))return{ok:!1,error:{...t,details:{...t.details??{},androidSnapshotTimeoutScreenshot:await H(e)}}}}async function H(t){try{let n=await C({device:t.device,overlayRefs:!1,inspectFacts:t.inspectFacts,bindDevice:t.bindDevice});if(!n.ok)throw new e(`UNSUPPORTED_OPERATION`,`The target does not support screenshot capture, so no timeout evidence was taken.`);let r=await N.mkdtemp(M.join(P.tmpdir(),`agent-device-android-snapshot-timeout-`)),i=M.join(r,`snapshot-timeout-overlay-refs.png`);await n.runtime.captureScreenshot({outPath:i,options:{appBundleId:t.session?.appBundleId,stabilize:!1,surface:t.session?.surface},execution:w(v(t.logPath,{screenshotNoStabilize:!0},t.session?.appBundleId,t.session?.trace?.outPath))}),await N.access(i);let a=await U(i,t.session);return f({level:`warn`,phase:`android_snapshot_timeout_screenshot_captured`,data:{path:i,...B(a)}}),a}catch(e){let t=r(e);return f({level:`warn`,phase:`android_snapshot_timeout_screenshot_failed`,data:{error:t.message}}),F(t.message)}}async function U(e,t){if(!t?.snapshot)return I(e);try{return L(e,await S({screenshotPath:e,snapshot:t.snapshot}))}catch(t){let n=r(t);return f({level:`warn`,phase:`android_snapshot_timeout_screenshot_overlay_failed`,data:{path:e,error:n.message}}),z(e,n.message)}}function W(e){let{verdict:t,appBundleId:n,latch:r}=e;return!t||t.backend===`android-helper`?{latch:r}:t.state===`healthy`?{latch:void 0}:t.state!==`recovered`||t.reasonCode===`requested-backend`?{latch:r}:t.reasonCode===`deferred`?r!==void 0&&r.appBundleId===n?{latch:r}:{warning:O(t.backend),latch:{appBundleId:n}}:{latch:{appBundleId:n}}}function G(e){let{session:t,data:n,verdict:r,internalObservation:i}=e;if(i||!t)return n;let a=W({verdict:r,appBundleId:t.appBundleId,latch:t.recoveredSnapshotWarningLatch});return t.recoveredSnapshotWarningLatch=a.latch,a.warning?{...n,warnings:[a.warning,...d(n)]}:n}async function K(e){let t=await k(e,e.command);if(!t.ok)return t.response;let{session:n,device:r,snapshotScope:i}=t;return await A(n,r,async()=>{let{req:a,sessionName:s,logPath:c,sessionStore:l}=e,u={},d=q({req:a,sessionName:s,logPath:c,sessionStore:l,session:n,device:r,snapshotScope:i,capturedQuality:u,captureSnapshotData:t.captureSnapshot}),f;try{f=await e.execute({runtime:d,sessionName:s,req:a,snapshotScope:i})}catch(t){let i=await V({error:t,command:e.command,logPath:c,session:n,device:r,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(!i)throw t;return i}te({req:a,sessionName:s,sessionStore:l,result:f.record});let p=G({session:l.get(s),data:f.data,verdict:u.value,internalObservation:a.internal?.observationOnly===!0});return{ok:!0,data:o(f.data,p)}},e.platformResourceCleanup)}function q(e){let{req:t,sessionName:n,logPath:r,sessionStore:i,session:a,device:o,snapshotScope:s}=e;return x({backend:$({req:t,logPath:r,session:a,device:o,snapshotScope:s,capturedQuality:e.capturedQuality,captureSnapshotData:e.captureSnapshotData}),...u(`snapshot`),signal:h(t.meta?.requestId),sessions:y({sessionName:n,getSession:()=>i.get(n),recordOptions:{includeSnapshot:!0},setRecord:e=>{let r=ne(e),a=i.get(n);i.set(n,J({current:a,sessionName:n,sessionScope:E(t),device:o,record:r,refScopedSnapshot:Y(t),issuesRefsToClient:t.command===`snapshot`&&t.internal?.observationOnly!==!0}))}})})}function J(e){let{current:t,sessionName:n,sessionScope:r,device:i,record:a,refScopedSnapshot:o}=e,s=X(t,a,o),c=s?t.snapshot:a.snapshot,l=j({session:t,sessionName:n,sessionScope:r,device:i,snapshot:c,appBundleId:a.appBundleId});return _(l,{scopeSource:Q({current:t,keepCurrentSnapshot:s,refScopedSnapshot:o}),keptCurrentSnapshot:s,previousGeneration:t?.snapshotGeneration}),Z(l,s,e.issuesRefsToClient),a.appName&&(l.appName=a.appName),l}function Y(e){return e.flags?.snapshotScope?.trim().startsWith(`@`)===!0}function X(e,t,n){return n&&t.snapshot?.nodes.length===0&&e?.snapshot!==void 0}function Z(e,t,n){!t&&n&&g(e)}function Q(e){let{current:t,keepCurrentSnapshot:n,refScopedSnapshot:r}=e;if(r)return n?t?.snapshotScopeSource:t?.snapshotScopeSource??t?.snapshot}function $(e){let{req:t,logPath:n,session:r,device:o,snapshotScope:c}=e;return{platform:s(o),captureSnapshot:async(s,l)=>{let u=await b({device:o,session:r,flags:t.flags,outPath:l?.outPath??t.flags?.out,logPath:n,snapshotScope:c,signal:s.signal,captureData:e.captureSnapshotData}),d=i(u);e.capturedQuality.value=d.quality;let f=a(r);return{snapshot:u.snapshot,...d,...f?{snapshotDiagnostics:f}:{},appName:r?.appBundleId?r.appName??r.appBundleId:void 0,appBundleId:r?.appBundleId}}}}function te(e){let t=e.sessionStore.get(e.sessionName);t&&e.sessionStore.recordAction(t,{command:e.req.command,positionals:e.req.positionals??[],flags:e.req.flags??{},result:re(e.result),interactiveObservation:c(e.req)})}function ne(t){if(!t.snapshot)throw new e(`UNKNOWN`,`snapshot runtime did not produce session state`);return t}function re(e){return e.kind===`snapshot`?{nodes:e.nodes,truncated:e.truncated}:{mode:e.mode,baselineInitialized:e.baselineInitialized,summary:e.summary}}async function ie(e){let t=e.session;if(!t||!D(e.verdict)||e.req.internal?.observationOnly===!0)return;let n=await ae({...e,session:t});if(n!==void 0)return{path:n,artifact:{field:`fallbackScreenshotPath`,artifactType:`screenshot`,path:n,fileName:`snapshot-fallback.png`}}}async function ae(e){let{req:t,session:n}=e;try{let r=await C({device:n.device,overlayRefs:!1,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});return r.ok?(await T({session:n,sessionName:e.sessionName,captureScreenshot:r.runtime.captureScreenshot,dispatchContext:v(e.logPath,t.flags,n.appBundleId,n.trace?.outPath,t.meta?.requestId,t.meta)})).path:void 0}catch{return}}async function oe(e){let r={},i=await K({...e,command:`snapshot`,execute:async({runtime:i,sessionName:a,req:s,snapshotScope:c})=>{let l=await i.capture.snapshot({session:a,...t(s.flags,n),scope:c});l.targetActivation&&(r.targetActivation??=l.targetActivation);let u=se(s,e.sessionStore.get(a)),d=m(l.nodes),f=o(l,d===l.nodes?l:{...l,nodes:d}),p=await ie({req:s,session:e.sessionStore.get(a),sessionName:a,logPath:e.logPath,verdict:l.snapshotQuality,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice}),h=o(f,p?{...f,fallbackScreenshotPath:p.path,artifacts:[p.artifact]}:f);return{data:u===void 0?h:o(h,{...h,refsGeneration:u}),record:{kind:`snapshot`,nodes:l.nodes.length,truncated:l.truncated}}}});return l(i,r)}function se(e,t){return e.internal?.observationOnly===!0?void 0:t?.snapshotGeneration}export{K as n,oe as t};
1
+ import{N as e,O as t,g as n,q as r}from"./sdk-contracts.js";import"./capture.js";import{r as i}from"./snapshot-capture-annotations.js";import{i as a}from"./snapshot-diagnostics.js";import{f as o}from"./android-input-ownership.js";import{C as s}from"./sdk-device.js";import{s as c}from"./session-store.js";import{l,u}from"./target-evidence.js";import{n as d}from"./success-text.js";import{r as f}from"./diagnostics.js";import"./diagnostics2.js";import{n as p}from"./android-snapshot-quality.js";import{i as m}from"./android-system-chrome.js";import{r as h}from"./request-cancel.js";import"./request.js";import{D as g,a as _,h as v,o as y,s as b,u as x}from"./session-snapshot.js";import{a as S,i as C,r as w,t as T}from"./screenshot-runtime.js";import{a as E}from"./session-routing.js";import{s as D,t as O}from"./quality-warnings.js";import{n as k,o as A,r as j}from"./snapshot-runtime-binding.js";import M from"node:path";import{promises as N}from"node:fs";import P from"node:os";function F(e){return{captureFailed:!0,error:e}}function I(e){return{path:e,overlayRefsRequested:!0,overlayRefsAnnotated:!1,overlayRefSource:`unavailable`}}function L(e,t){let n={path:e,overlayRefsRequested:!0,overlayRefSource:`session-snapshot`};return R(t)?{...n,overlayRefsAnnotated:!0,overlayRefs:t}:{...n,overlayRefsAnnotated:!1,overlayRefs:[]}}function R(e){return e.length>0}function z(e,t){return{path:e,overlayRefsRequested:!0,overlayRefsAnnotated:!1,overlayRefSource:`session-snapshot`,overlayAnnotationError:t}}function B(e){return`captureFailed`in e?{overlayRefCount:void 0,overlayRefsAnnotated:void 0}:{overlayRefCount:`overlayRefs`in e?e.overlayRefs.length:0,overlayRefsAnnotated:e.overlayRefsAnnotated}}function ee(e){return p(e)===`accessibility-timeout`}async function V(e){if(e.command!==`snapshot`||e.device.platform!==`android`)return;let t=r(e.error);if(ee(t))return{ok:!1,error:{...t,details:{...t.details??{},androidSnapshotTimeoutScreenshot:await H(e)}}}}async function H(t){try{let n=await C({device:t.device,overlayRefs:!1,inspectFacts:t.inspectFacts,bindDevice:t.bindDevice});if(!n.ok)throw new e(`UNSUPPORTED_OPERATION`,`The target does not support screenshot capture, so no timeout evidence was taken.`);let r=await N.mkdtemp(M.join(P.tmpdir(),`agent-device-android-snapshot-timeout-`)),i=M.join(r,`snapshot-timeout-overlay-refs.png`);await n.runtime.captureScreenshot({outPath:i,options:{appBundleId:t.session?.appBundleId,stabilize:!1,surface:t.session?.surface},execution:w(v(t.logPath,{screenshotNoStabilize:!0},t.session?.appBundleId,t.session?.trace?.outPath))}),await N.access(i);let a=await U(i,t.session);return f({level:`warn`,phase:`android_snapshot_timeout_screenshot_captured`,data:{path:i,...B(a)}}),a}catch(e){let t=r(e);return f({level:`warn`,phase:`android_snapshot_timeout_screenshot_failed`,data:{error:t.message}}),F(t.message)}}async function U(e,t){if(!t?.snapshot)return I(e);try{return L(e,await S({screenshotPath:e,snapshot:t.snapshot}))}catch(t){let n=r(t);return f({level:`warn`,phase:`android_snapshot_timeout_screenshot_overlay_failed`,data:{path:e,error:n.message}}),z(e,n.message)}}function W(e){let{verdict:t,appBundleId:n,latch:r}=e;return!t||t.backend===`android-helper`?{latch:r}:t.state===`healthy`?{latch:void 0}:t.state!==`recovered`||t.reasonCode===`requested-backend`?{latch:r}:t.reasonCode===`deferred`?r!==void 0&&r.appBundleId===n?{latch:r}:{warning:O(t.backend),latch:{appBundleId:n}}:{latch:{appBundleId:n}}}function G(e){let{session:t,data:n,verdict:r,internalObservation:i}=e;if(i||!t)return n;let a=W({verdict:r,appBundleId:t.appBundleId,latch:t.recoveredSnapshotWarningLatch});return t.recoveredSnapshotWarningLatch=a.latch,a.warning?{...n,warnings:[a.warning,...d(n)]}:n}async function K(e){let t=await k(e,e.command);if(!t.ok)return t.response;let{session:n,device:r,snapshotScope:i}=t;return await A(n,r,async()=>{let{req:a,sessionName:s,logPath:c,sessionStore:l}=e,u={},d=q({req:a,sessionName:s,logPath:c,sessionStore:l,session:n,device:r,snapshotScope:i,capturedQuality:u,captureSnapshotData:t.captureSnapshot}),f;try{f=await e.execute({runtime:d,sessionName:s,req:a,snapshotScope:i})}catch(t){let i=await V({error:t,command:e.command,logPath:c,session:n,device:r,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(!i)throw t;return i}te({req:a,sessionName:s,sessionStore:l,result:f.record});let p=G({session:l.get(s),data:f.data,verdict:u.value,internalObservation:a.internal?.observationOnly===!0});return{ok:!0,data:o(f.data,p)}},e.platformResourceCleanup)}function q(e){let{req:t,sessionName:n,logPath:r,sessionStore:i,session:a,device:o,snapshotScope:s}=e;return x({backend:$({req:t,logPath:r,session:a,device:o,snapshotScope:s,capturedQuality:e.capturedQuality,captureSnapshotData:e.captureSnapshotData}),...u(`snapshot`),signal:h(t.meta?.requestId),sessions:y({sessionName:n,getSession:()=>i.get(n),recordOptions:{includeSnapshot:!0},setRecord:e=>{let r=ne(e),a=i.get(n);i.set(n,J({current:a,sessionName:n,sessionScope:E(t),device:o,record:r,refScopedSnapshot:Y(t),issuesRefsToClient:t.command===`snapshot`&&t.internal?.observationOnly!==!0}))}})})}function J(e){let{current:t,sessionName:n,sessionScope:r,device:i,record:a,refScopedSnapshot:o}=e,s=X(t,a,o),c=s?t.snapshot:a.snapshot,l=j({session:t,sessionName:n,sessionScope:r,device:i,snapshot:c,appBundleId:a.appBundleId});return _(l,{scopeSource:Q({current:t,keepCurrentSnapshot:s,refScopedSnapshot:o}),keptCurrentSnapshot:s,previousGeneration:t?.snapshotGeneration}),Z(l,s,e.issuesRefsToClient),a.appName&&(l.appName=a.appName),l}function Y(e){return e.flags?.snapshotScope?.trim().startsWith(`@`)===!0}function X(e,t,n){return n&&t.snapshot?.nodes.length===0&&e?.snapshot!==void 0}function Z(e,t,n){!t&&n&&g(e)}function Q(e){let{current:t,keepCurrentSnapshot:n,refScopedSnapshot:r}=e;if(r)return n?t?.snapshotScopeSource:t?.snapshotScopeSource??t?.snapshot}function $(e){let{req:t,logPath:n,session:r,device:o,snapshotScope:c}=e;return{platform:s(o),captureSnapshot:async(s,l)=>{let u=await b({device:o,session:r,flags:t.flags,outPath:l?.outPath??t.flags?.out,logPath:n,snapshotScope:c,signal:s.signal,captureData:e.captureSnapshotData}),d=i(u);e.capturedQuality.value=d.quality;let f=a(r);return{snapshot:u.snapshot,...d,...f?{snapshotDiagnostics:f}:{},appName:r?.appBundleId?r.appName??r.appBundleId:void 0,appBundleId:r?.appBundleId}}}}function te(e){let t=e.sessionStore.get(e.sessionName);t&&e.sessionStore.recordAction(t,{command:e.req.command,positionals:e.req.positionals??[],flags:e.req.flags??{},result:re(e.result),interactiveObservation:c(e.req)})}function ne(t){if(!t.snapshot)throw new e(`UNKNOWN`,`snapshot runtime did not produce session state`);return t}function re(e){return e.kind===`snapshot`?{nodes:e.nodes,truncated:e.truncated}:{mode:e.mode,baselineInitialized:e.baselineInitialized,summary:e.summary}}async function ie(e){let t=e.session;if(!t||!D(e.verdict)||e.req.internal?.observationOnly===!0)return;let n=await ae({...e,session:t});if(n===void 0)return;let{path:r,displayRotation:i}=n;return{path:r,artifact:{field:`fallbackScreenshotPath`,artifactType:`screenshot`,path:r,fileName:`snapshot-fallback.png`,...i?{displayRotation:i}:{}}}}async function ae(e){let{req:t,session:n}=e;try{let r=await C({device:n.device,overlayRefs:!1,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});return r.ok?await T({session:n,sessionName:e.sessionName,captureScreenshot:r.runtime.captureScreenshot,dispatchContext:v(e.logPath,t.flags,n.appBundleId,n.trace?.outPath,t.meta?.requestId,t.meta)}):void 0}catch{return}}async function oe(e){let r={},i=await K({...e,command:`snapshot`,execute:async({runtime:i,sessionName:a,req:s,snapshotScope:c})=>{let l=await i.capture.snapshot({session:a,...t(s.flags,n),scope:c});l.targetActivation&&(r.targetActivation??=l.targetActivation);let u=se(s,e.sessionStore.get(a)),d=m(l.nodes),f=o(l,d===l.nodes?l:{...l,nodes:d}),p=await ie({req:s,session:e.sessionStore.get(a),sessionName:a,logPath:e.logPath,verdict:l.snapshotQuality,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice}),h=o(f,p?{...f,fallbackScreenshotPath:p.path,artifacts:[p.artifact]}:f);return{data:u===void 0?h:o(h,{...h,refsGeneration:u}),record:{kind:`snapshot`,nodes:l.nodes.length,truncated:l.truncated}}}});return l(i,r)}function se(e,t){return e.internal?.observationOnly===!0?void 0:t?.snapshotGeneration}export{K as n,oe as t};
@@ -1,4 +1,4 @@
1
- import{N as e}from"./sdk-contracts.js";import{a as t,c as n,h as r,t as i}from"./exec.js";import"./command.js";import{t as a}from"./scoped-provider.js";import{f as o,u as s}from"./host-file.js";import c from"node:path";function l(e,t){return t===`user-installed`?e.filter(e=>!e.bundleId.startsWith(`com.apple.`)):e}function u(n,r){return{openBundle:async(e,t)=>{await n(`open`,d(e,t))},openTarget:async e=>{await n(`open`,[e])},readClipboard:async()=>t(await n(`pbpaste`,[],{allowFailure:!0}),`Failed to read macOS clipboard`).stdout.replaceAll(`\r
1
+ import{N as e}from"./sdk-contracts.js";import{g as t,l as n,o as r,t as i}from"./exec.js";import"./command.js";import{t as a}from"./scoped-provider.js";import{f as o,u as s}from"./host-file.js";import c from"node:path";function l(e,t){return t===`user-installed`?e.filter(e=>!e.bundleId.startsWith(`com.apple.`)):e}function u(t,n){return{openBundle:async(e,n)=>{await t(`open`,d(e,n))},openTarget:async e=>{await t(`open`,[e])},readClipboard:async()=>r(await t(`pbpaste`,[],{allowFailure:!0}),`Failed to read macOS clipboard`).stdout.replaceAll(`\r
2
2
  `,`
3
- `).replace(/\n$/,``),writeClipboard:async e=>{t(await n(`pbcopy`,[],{allowFailure:!0,stdin:e}),`Failed to write macOS clipboard`)},readDarkMode:async()=>{let r=t(await n(`osascript`,[`-e`,`tell application "System Events" to tell appearance preferences to get dark mode`],{allowFailure:!0}),`Failed to read macOS appearance`),i=r.stdout.trim().toLowerCase();if(i===`true`)return!0;if(i===`false`)return!1;throw new e(`COMMAND_FAILED`,`Unable to determine current macOS appearance from osascript output: ${r.stdout.trim()}`)},setDarkMode:async e=>{t(await n(`osascript`,[`-e`,`tell application "System Events" to tell appearance preferences to set dark mode to ${e?`true`:`false`}`],{allowFailure:!0}),`Failed to set macOS appearance`)},listApps:async e=>await f(n,r,e)}}function d(e,t){let n=[`-b`,e];return t&&n.push(t),n}async function f(e,t,n){let r=[`/Applications`,`/System/Applications`,c.join(o(),`Applications`)],i=new Set;for(let t of r){if(!(await s(t).catch(()=>null))?.isDirectory())continue;let n=await e(`find`,[t,`-maxdepth`,`4`,`-type`,`d`,`-name`,`*.app`],{allowFailure:!0});if(n.exitCode===0)for(let e of n.stdout.split(`
4
- `)){let t=e.trim();t&&i.add(t)}}return l((await Promise.all(Array.from(i).map(async e=>{let n=await p(e,t).catch(()=>({})),r=n.bundleId;return r?{bundleId:r,name:n.appName??c.basename(e,`.app`)}:null}))).filter(e=>e!==null).sort((e,t)=>e.name.localeCompare(t.name)),n)}async function p(e,t){for(let n of[c.join(e,`Contents`,`Info.plist`),c.join(e,`Info.plist`)]){let e=await t(n),r=m(e,`CFBundleIdentifier`),i=m(e,`CFBundleDisplayName`),a=m(e,`CFBundleName`);if(r||i||a)return{bundleId:r,appName:i??a}}return{}}function m(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function h(e){return Object.freeze([`simctl`,...e])}async function g(e,t,n){return await e(`xcrun`,[...h(t)],n)}function _(e){return Object.freeze(e.slice(1))}const v={runCommand:n,simctl:{run:async(e,t)=>await g(n,e,t)},devicectl:{run:async(e,t)=>await n(`xcrun`,[`devicectl`,...e],t)},plist:{readJson:async(e,t)=>await A(n,e,t)},macosHost:u(n,async e=>await A(n,e)),whichCommand:r},y=a(v,D);function b(e={}){let t={...v,...e},n=e.plist??{readJson:async(e,n)=>await A(t.runCommand,e,n)};return{...t,simctl:e.simctl??{run:async(e,n)=>await g(t.runCommand,e,n)},devicectl:e.devicectl??{run:async(e,n)=>await t.runCommand(`xcrun`,[`devicectl`,...e],n)},plist:n,macosHost:e.macosHost??u(t.runCommand,async e=>await n.readJson(e))}}function x(e){return y.resolve(e)}async function S(e,t){return await y.run(e,t)}function C(){return y.hasScope()}async function w(e,t,n){return await x().runCommand(e,t,n)}async function T(e,t){let n=x();if(e[0]===`simctl`)return await n.simctl.run(_(e),t);let[r,...i]=e;return r===`devicectl`?await n.devicectl.run(i,t):await w(`xcrun`,[...e],t)}async function E(e,t){return await x().plist?.readJson(e,t)??null}function D(e){return b({...e,runCommand:O(e.runCommand),simctl:{run:k(e.simctl.run)},devicectl:{run:k(e.devicectl.run)},...e.macosHelper?{macosHelper:{run:k(e.macosHelper.run)}}:{}})}function O(e){return async(t,n,r)=>i(await e(t,n,r))}function k(e){return async(t,n)=>i(await e(t,n))}async function A(e,t,n){try{let r=await e(`plutil`,[`-convert`,`json`,`-o`,`-`,t],{allowFailure:!0,signal:n});return r.exitCode!==0||!r.stdout.trim()?null:JSON.parse(r.stdout)}catch{return n?.throwIfAborted(),null}}export{w as a,S as c,x as i,l,C as n,T as o,E as r,h as s,b as t};
3
+ `).replace(/\n$/,``),writeClipboard:async e=>{r(await t(`pbcopy`,[],{allowFailure:!0,stdin:e}),`Failed to write macOS clipboard`)},readDarkMode:async()=>{let n=r(await t(`osascript`,[`-e`,`tell application "System Events" to tell appearance preferences to get dark mode`],{allowFailure:!0}),`Failed to read macOS appearance`),i=n.stdout.trim().toLowerCase();if(i===`true`)return!0;if(i===`false`)return!1;throw new e(`COMMAND_FAILED`,`Unable to determine current macOS appearance from osascript output: ${n.stdout.trim()}`)},setDarkMode:async e=>{r(await t(`osascript`,[`-e`,`tell application "System Events" to tell appearance preferences to set dark mode to ${e?`true`:`false`}`],{allowFailure:!0}),`Failed to set macOS appearance`)},listApps:async e=>await f(t,n,e)}}function d(e,t){let n=[`-b`,e];return t&&n.push(t),n}async function f(e,t,n){let r=[`/Applications`,`/System/Applications`,c.join(o(),`Applications`)],i=new Set;for(let t of r){if(!(await s(t).catch(()=>null))?.isDirectory())continue;let n=await e(`find`,[t,`-maxdepth`,`4`,`-type`,`d`,`-name`,`*.app`],{allowFailure:!0});if(n.exitCode===0)for(let e of n.stdout.split(`
4
+ `)){let t=e.trim();t&&i.add(t)}}return l((await Promise.all(Array.from(i).map(async e=>{let n=await p(e,t).catch(()=>({})),r=n.bundleId;return r?{bundleId:r,name:n.appName??c.basename(e,`.app`)}:null}))).filter(e=>e!==null).sort((e,t)=>e.name.localeCompare(t.name)),n)}async function p(e,t){for(let n of[c.join(e,`Contents`,`Info.plist`),c.join(e,`Info.plist`)]){let e=await t(n),r=m(e,`CFBundleIdentifier`),i=m(e,`CFBundleDisplayName`),a=m(e,`CFBundleName`);if(r||i||a)return{bundleId:r,appName:i??a}}return{}}function m(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function h(e){return Object.freeze([`simctl`,...e])}async function g(e,t,n){return await e(`xcrun`,[...h(t)],n)}function _(e){return Object.freeze(e.slice(1))}const v={runCommand:n,simctl:{run:async(e,t)=>await g(n,e,t)},devicectl:{run:async(e,t)=>await n(`xcrun`,[`devicectl`,...e],t)},plist:{readJson:async(e,t)=>await A(n,e,t)},macosHost:u(n,async e=>await A(n,e)),whichCommand:t},y=a(v,D);function b(e={}){let t={...v,...e},n=e.plist??{readJson:async(e,n)=>await A(t.runCommand,e,n)};return{...t,simctl:e.simctl??{run:async(e,n)=>await g(t.runCommand,e,n)},devicectl:e.devicectl??{run:async(e,n)=>await t.runCommand(`xcrun`,[`devicectl`,...e],n)},plist:n,macosHost:e.macosHost??u(t.runCommand,async e=>await n.readJson(e))}}function x(e){return y.resolve(e)}async function S(e,t){return await y.run(e,t)}function C(){return y.hasScope()}async function w(e,t,n){return await x().runCommand(e,t,n)}async function T(e,t){let n=x();if(e[0]===`simctl`)return await n.simctl.run(_(e),t);let[r,...i]=e;return r===`devicectl`?await n.devicectl.run(i,t):await w(`xcrun`,[...e],t)}async function E(e,t){return await x().plist?.readJson(e,t)??null}function D(e){return b({...e,runCommand:O(e.runCommand),simctl:{run:k(e.simctl.run)},devicectl:{run:k(e.devicectl.run)},...e.macosHelper?{macosHelper:{run:k(e.macosHelper.run)}}:{}})}function O(e){return async(t,n,r)=>i(await e(t,n,r))}function k(e){return async(t,n)=>i(await e(t,n))}async function A(e,t,n){try{let r=await e(`plutil`,[`-convert`,`json`,`-o`,`-`,t],{allowFailure:!0,signal:n});return r.exitCode!==0||!r.stdout.trim()?null:JSON.parse(r.stdout)}catch{return n?.throwIfAborted(),null}}export{w as a,S as c,x as i,l,C as n,T as o,E as r,h as s,b as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime.js";import{N as t}from"./sdk-contracts.js";import{r as n}from"./diagnostics.js";import{c as r}from"./owner-identity.js";import{c as i,h as a}from"./exec.js";import{t as o}from"./timeouts.js";import"./diagnostics2.js";import"./command.js";import"./process.js";import"./retry.js";import{t as s}from"./scoped-provider.js";var c=e({createLocalLinuxToolProvider:()=>d,resolveLinuxToolProvider:()=>f,runLinuxToolCommand:()=>m,withLinuxToolProvider:()=>p});const l={runCommand:i,whichCommand:a,desktop:h(i,a),clipboard:g(i,a),screenshot:_(i,a)},u=s(l,d);function d(e={}){let t={...l,...e};return{...t,desktop:e.desktop??h(t.runCommand,t.whichCommand),clipboard:e.clipboard??g(t.runCommand,t.whichCommand),screenshot:e.screenshot??_(t.runCommand,t.whichCommand)}}function f(e){return u.resolve(e)}async function p(e,t){return await u.run(e,t)}async function m(e,t,n){return await f().runCommand(e,t,n)}function h(e,t){return{async openTarget(r){if(r.includes(`://`)||r.startsWith(`/`)){await e(`xdg-open`,[r]);return}if(await t(r)){e(r,[],{allowFailure:!0}).catch(e=>{n({level:`warn`,phase:`linux_app_launch`,data:{app:r,error:String(e)}})}),await o(500);return}await e(`xdg-open`,[r],{allowFailure:!0})},async closeApp(n){if(await t(`wmctrl`)){await e(`wmctrl`,[`-c`,n],{allowFailure:!0});return}await e(`pkill`,[`-x`,n],{allowFailure:!0})}}}function g(e,t){return{async readText(){let n=await w(t,y),r=x[n];return(await e(r.cmd,r.args,r.options)).stdout},async writeText(n){let r=await w(t,y),i=S[r](n);await e(i.cmd,i.args,i.options)}}}function _(e,t){return{async capture(n){let r=await w(t,b),i=C[r](n);await e(i.cmd,i.args,i.options)}}}const v=5e3,y={wayland:[{tool:`wl-clipboard`,command:`wl-paste`}],x11:[{tool:`xclip`,command:`xclip`},{tool:`xsel`,command:`xsel`}],waylandError:`wl-paste (wl-clipboard) is required for clipboard access on Wayland. Install via your package manager.`,x11Error:`xclip or xsel is required for clipboard access on X11. Install via your package manager.`},b={wayland:[{tool:`grim`,command:`grim`},{tool:`gnome-screenshot`,command:`gnome-screenshot`}],x11:[{tool:`scrot`,command:`scrot`},{tool:`import`,command:`import`},{tool:`gnome-screenshot`,command:`gnome-screenshot`}],waylandError:`grim or gnome-screenshot is required for screenshots on Wayland. Install via your package manager.`,x11Error:`scrot, import (ImageMagick), or gnome-screenshot is required for screenshots on X11. Install via your package manager.`},x={"wl-clipboard":{cmd:`wl-paste`,args:[`--no-newline`],options:{allowFailure:!0,timeoutMs:v}},xclip:{cmd:`xclip`,args:[`-selection`,`clipboard`,`-o`],options:{allowFailure:!0,timeoutMs:v}},xsel:{cmd:`xsel`,args:[`--clipboard`,`--output`],options:{allowFailure:!0,timeoutMs:v}}},S={"wl-clipboard":e=>({cmd:`wl-copy`,args:[`--`,e],options:{allowFailure:!1,timeoutMs:v}}),xclip:e=>({cmd:`xclip`,args:[`-selection`,`clipboard`],options:{allowFailure:!1,timeoutMs:v,stdin:e}}),xsel:e=>({cmd:`xsel`,args:[`--clipboard`,`--input`],options:{allowFailure:!1,timeoutMs:v,stdin:e}})},C={grim:e=>({cmd:`grim`,args:[e]}),scrot:e=>({cmd:`scrot`,args:[e]}),import:e=>({cmd:`import`,args:[`-window`,`root`,e]}),"gnome-screenshot":e=>({cmd:`gnome-screenshot`,args:[`-f`,e]})};async function w(e,n){let r=T()?`wayland`:`x11`;for(let t of n[r])if(await e(t.command))return t.tool;throw new t(`TOOL_MISSING`,r===`wayland`?n.waylandError:n.x11Error)}function T(){let e=r();return!!e.WAYLAND_DISPLAY||e.XDG_SESSION_TYPE===`wayland`}export{m as n,c as r,f as t};
1
+ import{r as e}from"./rolldown-runtime.js";import{N as t}from"./sdk-contracts.js";import{r as n}from"./diagnostics.js";import{c as r}from"./owner-identity.js";import{g as i,l as a}from"./exec.js";import{t as o}from"./timeouts.js";import"./diagnostics2.js";import"./command.js";import"./process.js";import"./retry.js";import{t as s}from"./scoped-provider.js";var c=e({createLocalLinuxToolProvider:()=>d,resolveLinuxToolProvider:()=>f,runLinuxToolCommand:()=>m,withLinuxToolProvider:()=>p});const l={runCommand:a,whichCommand:i,desktop:h(a,i),clipboard:g(a,i),screenshot:_(a,i)},u=s(l,d);function d(e={}){let t={...l,...e};return{...t,desktop:e.desktop??h(t.runCommand,t.whichCommand),clipboard:e.clipboard??g(t.runCommand,t.whichCommand),screenshot:e.screenshot??_(t.runCommand,t.whichCommand)}}function f(e){return u.resolve(e)}async function p(e,t){return await u.run(e,t)}async function m(e,t,n){return await f().runCommand(e,t,n)}function h(e,t){return{async openTarget(r){if(r.includes(`://`)||r.startsWith(`/`)){await e(`xdg-open`,[r]);return}if(await t(r)){e(r,[],{allowFailure:!0}).catch(e=>{n({level:`warn`,phase:`linux_app_launch`,data:{app:r,error:String(e)}})}),await o(500);return}await e(`xdg-open`,[r],{allowFailure:!0})},async closeApp(n){if(await t(`wmctrl`)){await e(`wmctrl`,[`-c`,n],{allowFailure:!0});return}await e(`pkill`,[`-x`,n],{allowFailure:!0})}}}function g(e,t){return{async readText(){let n=await w(t,y),r=x[n];return(await e(r.cmd,r.args,r.options)).stdout},async writeText(n){let r=await w(t,y),i=S[r](n);await e(i.cmd,i.args,i.options)}}}function _(e,t){return{async capture(n){let r=await w(t,b),i=C[r](n);await e(i.cmd,i.args,i.options)}}}const v=5e3,y={wayland:[{tool:`wl-clipboard`,command:`wl-paste`}],x11:[{tool:`xclip`,command:`xclip`},{tool:`xsel`,command:`xsel`}],waylandError:`wl-paste (wl-clipboard) is required for clipboard access on Wayland. Install via your package manager.`,x11Error:`xclip or xsel is required for clipboard access on X11. Install via your package manager.`},b={wayland:[{tool:`grim`,command:`grim`},{tool:`gnome-screenshot`,command:`gnome-screenshot`}],x11:[{tool:`scrot`,command:`scrot`},{tool:`import`,command:`import`},{tool:`gnome-screenshot`,command:`gnome-screenshot`}],waylandError:`grim or gnome-screenshot is required for screenshots on Wayland. Install via your package manager.`,x11Error:`scrot, import (ImageMagick), or gnome-screenshot is required for screenshots on X11. Install via your package manager.`},x={"wl-clipboard":{cmd:`wl-paste`,args:[`--no-newline`],options:{allowFailure:!0,timeoutMs:v}},xclip:{cmd:`xclip`,args:[`-selection`,`clipboard`,`-o`],options:{allowFailure:!0,timeoutMs:v}},xsel:{cmd:`xsel`,args:[`--clipboard`,`--output`],options:{allowFailure:!0,timeoutMs:v}}},S={"wl-clipboard":e=>({cmd:`wl-copy`,args:[`--`,e],options:{allowFailure:!1,timeoutMs:v}}),xclip:e=>({cmd:`xclip`,args:[`-selection`,`clipboard`],options:{allowFailure:!1,timeoutMs:v,stdin:e}}),xsel:e=>({cmd:`xsel`,args:[`--clipboard`,`--input`],options:{allowFailure:!1,timeoutMs:v,stdin:e}})},C={grim:e=>({cmd:`grim`,args:[e]}),scrot:e=>({cmd:`scrot`,args:[e]}),import:e=>({cmd:`import`,args:[`-window`,`root`,e]}),"gnome-screenshot":e=>({cmd:`gnome-screenshot`,args:[`-f`,e]})};async function w(e,n){let r=T()?`wayland`:`x11`;for(let t of n[r])if(await e(t.command))return t.tool;throw new t(`TOOL_MISSING`,r===`wayland`?n.waylandError:n.x11Error)}function T(){let e=r();return!!e.WAYLAND_DISPLAY||e.XDG_SESSION_TYPE===`wayland`}export{m as n,c as r,f as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime.js";import{c as t,h as n,i as r}from"./exec.js";import"./command.js";import{t as i}from"./scoped-provider.js";import{f as a}from"./host-file.js";import o from"node:path";var s=e({createLocalVegaToolProvider:()=>d,resolveVegaToolProvider:()=>f,withVegaToolProvider:()=>p});const c={run:async(e,n)=>await t(await h()??`vega`,e,n),isAvailable:async()=>!!await h()},l=d(),u=i(l);function d(e=c){return{isAvailable:async()=>await e.isAvailable(),version:async t=>await e.run([`--version`],t),listDevices:async t=>await e.run([`device`,`list`],t),checkConnected:async(t,n)=>await e.run([`device`,`is-connected`,`--device`,t],n),launchApp:async(t,n,r)=>await e.run([`device`,`launch-app`,`--device`,t,`--appName`,n],r),terminateApp:async(t,n,r)=>await e.run([`device`,`terminate-app`,`--device`,t,`--appName`,n],r),pressRemote:async(t,n,r,i)=>await e.run([`device`,`run-cmd`,`--device`,t,`--command`,[`inputd-cli`,`button_press`,n,...r===void 0?[]:[`--holdDuration`,String(r)]].join(` `)],i)}}function f(e){return u.resolve(e)}async function p(e,t){return await u.run(e,t)}let m;async function h(){if(m)return m;if(await n(`vega`))return m=`vega`,m;let e=o.join(a(),`vega`,`bin`,`vega`);return await r(e)&&(m=e),m}export{s as n,f as t};
1
+ import{r as e}from"./rolldown-runtime.js";import{a as t,g as n,l as r}from"./exec.js";import"./command.js";import{t as i}from"./scoped-provider.js";import{f as a}from"./host-file.js";import o from"node:path";var s=e({createLocalVegaToolProvider:()=>d,resolveVegaToolProvider:()=>f,withVegaToolProvider:()=>p});const c={run:async(e,t)=>await r(await h()??`vega`,e,t),isAvailable:async()=>!!await h()},l=d(),u=i(l);function d(e=c){return{isAvailable:async()=>await e.isAvailable(),version:async t=>await e.run([`--version`],t),listDevices:async t=>await e.run([`device`,`list`],t),checkConnected:async(t,n)=>await e.run([`device`,`is-connected`,`--device`,t],n),launchApp:async(t,n,r)=>await e.run([`device`,`launch-app`,`--device`,t,`--appName`,n],r),terminateApp:async(t,n,r)=>await e.run([`device`,`terminate-app`,`--device`,t,`--appName`,n],r),pressRemote:async(t,n,r,i)=>await e.run([`device`,`run-cmd`,`--device`,t,`--command`,[`inputd-cli`,`button_press`,n,...r===void 0?[]:[`--holdDuration`,String(r)]].join(` `)],i)}}function f(e){return u.resolve(e)}async function p(e,t){return await u.run(e,t)}let m;async function h(){if(m)return m;if(await n(`vega`))return m=`vega`,m;let e=o.join(a(),`vega`,`bin`,`vega`);return await t(e)&&(m=e),m}export{s as n,f as t};
@@ -1,2 +1,2 @@
1
- import{c as e}from"./exec.js";import"./command.js";const t=3e3;async function n(n,i){try{let a=await e(n,i,{allowFailure:!0,timeoutMs:t});return a.exitCode===0?r(a.stdout):void 0}catch{return}}function r(e){return e.split(`
1
+ import{l as e}from"./exec.js";import"./command.js";const t=3e3;async function n(n,i){try{let a=await e(n,i,{allowFailure:!0,timeoutMs:t});return a.exitCode===0?r(a.stdout):void 0}catch{return}}function r(e){return e.split(`
2
2
  `).map(e=>e.trim()).find(Boolean)}export{n,r,t};
@@ -1 +1 @@
1
- import{u as e}from"./exec.js";import"./command.js";import{n as t}from"./version.js";import n from"node:path";import r from"node:fs";import{fileURLToPath as i}from"node:url";const a=`agent-device`,o=`--agent-device-run-update-check`;function s(e){if(!l(e))return;let t=Date.now(),r=n.join(e.stateDir,`update-check.json`),i=f(r);u(i,e.currentVersion)&&(process.stderr.write(`Update available: ${a} ${e.currentVersion} -> ${i.latestVersion}. Run \`npm install -g ${a}@latest\` to upgrade the CLI.\n`),p(r,{...i,prompted:!0})),d(i,t)&&h(r,e.currentVersion)}async function c(e){let n=Date.now(),r=f(e.cachePath);try{let i=await g()??void 0;if(!i||t(i,e.currentVersion)<=0){p(e.cachePath,{checkedAt:new Date(n).toISOString()});return}p(e.cachePath,{checkedAt:new Date(n).toISOString(),latestVersion:i,prompted:r.latestVersion===i&&r.prompted===!0})}catch{p(e.cachePath,{...r,checkedAt:new Date(n).toISOString()})}}function l(e){return!e.command||e.command===`help`||e.command===`test`||e.flags.help||e.flags.version||e.flags.json||process.env.CI?.trim()||process.env.NODE_ENV===`test`||process.env.AGENT_DEVICE_NO_UPDATE_NOTIFIER?.trim()?!1:!!process.stderr.isTTY}function u(e,n){return!e.latestVersion||t(e.latestVersion,n)<=0?!1:e.prompted!==!0}function d(e,t){let n=_(e.checkedAt);return n===void 0||t-n>=12096e5}function f(e){try{let t=JSON.parse(r.readFileSync(e,`utf8`));return{checkedAt:typeof t.checkedAt==`string`?t.checkedAt:void 0,latestVersion:typeof t.latestVersion==`string`?t.latestVersion:void 0,prompted:t.prompted===!0}}catch{return{}}}function p(e,t){try{r.mkdirSync(n.dirname(e),{recursive:!0}),r.writeFileSync(e,`${JSON.stringify(t,null,2)}\n`,`utf8`)}catch{}}function m(){let e=i(import.meta.url),t=n.extname(e)||`.js`,a=[n.join(n.dirname(e),`update-check-entry${t}`),n.join(n.dirname(e),`internal`,`update-check-entry${t}`)].find(e=>r.existsSync(e));if(!a)throw Error(`Update check entrypoint not found. Rebuild the package to include the update-check worker entry.`);return a}function h(t,n){let r=m(),i=r.endsWith(`.ts`)?[`--experimental-strip-types`]:[];e(process.execPath,[...i,r,o,t,n])}async function g(){let e=await fetch(`https://registry.npmjs.org/${a}/latest`,{signal:AbortSignal.timeout(3500),headers:{accept:`application/json`}});if(!e.ok)return;let t=await e.json();return typeof t.version==`string`&&t.version.trim().length>0?t.version.trim():void 0}function _(e){if(!e)return;let t=Date.parse(e);return Number.isNaN(t)?void 0:t}function v(e){if(e[0]!==o)return null;let t=e[1]?.trim(),n=e[2]?.trim();return!t||!n?null:{cachePath:t,currentVersion:n}}export{v as n,c as r,s as t};
1
+ import{d as e}from"./exec.js";import"./command.js";import{n as t}from"./version.js";import n from"node:path";import r from"node:fs";import{fileURLToPath as i}from"node:url";const a=`agent-device`,o=`--agent-device-run-update-check`;function s(e){if(!l(e))return;let t=Date.now(),r=n.join(e.stateDir,`update-check.json`),i=f(r);u(i,e.currentVersion)&&(process.stderr.write(`Update available: ${a} ${e.currentVersion} -> ${i.latestVersion}. Run \`npm install -g ${a}@latest\` to upgrade the CLI.\n`),p(r,{...i,prompted:!0})),d(i,t)&&h(r,e.currentVersion)}async function c(e){let n=Date.now(),r=f(e.cachePath);try{let i=await g()??void 0;if(!i||t(i,e.currentVersion)<=0){p(e.cachePath,{checkedAt:new Date(n).toISOString()});return}p(e.cachePath,{checkedAt:new Date(n).toISOString(),latestVersion:i,prompted:r.latestVersion===i&&r.prompted===!0})}catch{p(e.cachePath,{...r,checkedAt:new Date(n).toISOString()})}}function l(e){return!e.command||e.command===`help`||e.command===`test`||e.flags.help||e.flags.version||e.flags.json||process.env.CI?.trim()||process.env.NODE_ENV===`test`||process.env.AGENT_DEVICE_NO_UPDATE_NOTIFIER?.trim()?!1:!!process.stderr.isTTY}function u(e,n){return!e.latestVersion||t(e.latestVersion,n)<=0?!1:e.prompted!==!0}function d(e,t){let n=_(e.checkedAt);return n===void 0||t-n>=12096e5}function f(e){try{let t=JSON.parse(r.readFileSync(e,`utf8`));return{checkedAt:typeof t.checkedAt==`string`?t.checkedAt:void 0,latestVersion:typeof t.latestVersion==`string`?t.latestVersion:void 0,prompted:t.prompted===!0}}catch{return{}}}function p(e,t){try{r.mkdirSync(n.dirname(e),{recursive:!0}),r.writeFileSync(e,`${JSON.stringify(t,null,2)}\n`,`utf8`)}catch{}}function m(){let e=i(import.meta.url),t=n.extname(e)||`.js`,a=[n.join(n.dirname(e),`update-check-entry${t}`),n.join(n.dirname(e),`internal`,`update-check-entry${t}`)].find(e=>r.existsSync(e));if(!a)throw Error(`Update check entrypoint not found. Rebuild the package to include the update-check worker entry.`);return a}function h(t,n){let r=m(),i=r.endsWith(`.ts`)?[`--experimental-strip-types`]:[];e(process.execPath,[...i,r,o,t,n])}async function g(){let e=await fetch(`https://registry.npmjs.org/${a}/latest`,{signal:AbortSignal.timeout(3500),headers:{accept:`application/json`}});if(!e.ok)return;let t=await e.json();return typeof t.version==`string`&&t.version.trim().length>0?t.version.trim():void 0}function _(e){if(!e)return;let t=Date.parse(e);return Number.isNaN(t)?void 0:t}function v(e){if(e[0]!==o)return null;let t=e[1]?.trim(),n=e[2]?.trim();return!t||!n?null:{cachePath:t,currentVersion:n}}export{v as n,c as r,s as t};
package/dist/src/video.js CHANGED
@@ -1,4 +1,4 @@
1
- import{N as e}from"./sdk-contracts.js";import{sr as t}from"./sdk-batch.js";import{C as n}from"./owner-identity.js";import{c as r}from"./exec.js";import{t as i}from"./timeouts.js";import{n as a,t as o}from"./file.js";import"./command.js";import"./process.js";import"./retry.js";import s from"node:path";import c from"node:fs";import{createHash as l}from"node:crypto";import u from"node:os";import{fileURLToPath as d}from"node:url";const f=`apple/runner/AgentDeviceRunner/RecordingScripts`;function p(e,t,n,r){let i=`${f}/${e}`,a=`dist/${i}`;return[s.resolve(t,e),s.resolve(n,i),s.resolve(t,`../${i}`),s.resolve(t,`../../${i}`),s.resolve(t,`../../../${i}`),s.resolve(n,a),s.resolve(r,i)]}function m(t,n,r=s.dirname(d(import.meta.url)),i=process.cwd()){let a=p(t,r,n,i);for(let e of a)if(c.existsSync(e))return e;throw new e(`COMMAND_FAILED`,`Missing recording helper script: ${t}`,{hint:`Ensure ${f} is present in this checkout or bundled under dist/${f} in the package.`,scriptName:t,searchedPaths:a})}function h(e=process.env){let t=v(),n=s.join(t,`home`),r=s.join(t,`module-cache`);return c.mkdirSync(n,{recursive:!0}),c.mkdirSync(r,{recursive:!0}),{...e,HOME:n,CLANG_MODULE_CACHE_PATH:r}}async function g(e){let t=[e.sourcePath,...e.extraSourcePaths??[]],n=t.map(e=>({sourcePath:e,stat:c.statSync(e),source:c.readFileSync(e)})),r=S(e.cacheName??s.basename(e.sourcePath,s.extname(e.sourcePath))),i=C([`2`,process.platform,process.arch,...n.flatMap(({sourcePath:e,stat:t,source:n})=>[s.resolve(e),t.size,n])]),a=s.join(v(),`bin`,`${r}-${i}`);return await y({sourcePaths:t,executablePath:a,timeoutMs:e.timeoutMs}),a}async function _(e){let t=S(e.cacheName),n=C([`2`,process.platform,process.arch,e.source]),r=s.join(v(),`sources`,`${t}-${n}.swift`),i=s.join(v(),`bin`,`${t}-${n}`);return await y({sourcePaths:[r],executablePath:i,sourceText:e.source,timeoutMs:e.timeoutMs}),i}function v(){let e=process.env.AGENT_DEVICE_SWIFT_CACHE_DIR?.trim();return e?s.resolve(e):s.join(u.tmpdir(),`agent-device-swift-cache`)}async function y(e){if(x(e.executablePath))return;let t=s.dirname(e.executablePath);c.mkdirSync(t,{recursive:!0});let n=e.timeoutMs??12e4;await a({acquire:()=>b(`${e.executablePath}.lock`,n),task:async()=>{if(x(e.executablePath))return;let i=c.mkdtempSync(s.join(t,`.${s.basename(e.executablePath)}.${process.pid}.`)),a=s.join(i,s.basename(e.executablePath));try{let[t]=e.sourcePaths;e.sourceText!==void 0&&t&&!c.existsSync(t)&&(c.mkdirSync(s.dirname(t),{recursive:!0}),c.writeFileSync(t,e.sourceText)),await r(`xcrun`,[`swiftc`,...e.sourcePaths,`-o`,a],{timeoutMs:n,env:h()}),c.renameSync(a,e.executablePath)}finally{c.rmSync(i,{recursive:!0,force:!0})}}})}async function b(t,r){try{return await o({lockDirPath:t,owner:{pid:process.pid,startTime:n(process.pid),acquiredAtMs:Date.now()},timeoutMs:r,pollMs:25,ownerGraceMs:r,description:`Swift cache lock: ${t} (${r}ms)`})}catch(n){throw n instanceof e&&n.message.startsWith(`Timed out waiting for Swift cache lock:`)?new e(`COMMAND_FAILED`,n.message,{...n.details,lockDir:t,timeoutMs:r,hint:`Another agent-device process may still be compiling this Swift helper. Retry shortly; if no agent-device process is active, remove "${t}" and retry.`}):n}}function x(e){try{return c.accessSync(e,c.constants.X_OK),c.statSync(e).isFile()}catch{return!1}}function S(e){return t(e.replaceAll(/[^A-Za-z0-9._-]/g,`-`))||`swift-helper`}function C(e){let t=l(`sha256`);for(let n of e)t.update(Buffer.isBuffer(n)?n:String(n)),t.update(`\0`);return t.digest(`hex`).slice(0,16)}const w={block:161,blockGroup:160,cluster:524531317,codecId:134,documentType:17026,ebml:440786851,segment:408125543,simpleBlock:163,trackEntry:174,trackNumber:215,tracks:374648427,trackType:131};function T(e){let t=E(e);if(!t)return!1;let{bytes:n,fileSize:r}=t,i=L(n,0,n.length,r);if(!i||i.id!==w.ebml||!i.complete||i.unknownSize||!D(n,i))return!1;let a=L(n,i.nextOffset,n.length,r);return!a||a.id!==w.segment||!V(a,r)?!1:O(n,a,r)}function E(e){try{let t=c.openSync(e,`r`);try{let e=c.fstatSync(t).size;if(e<=0)return;let n=Buffer.alloc(Math.min(e,1048576));return c.readSync(t,n,0,n.length,0)===n.length?{bytes:n,fileSize:e}:void 0}finally{c.closeSync(t)}}catch{return}}function D(e,t){let n=I(e,t)?.find(e=>e.id===w.documentType);return n!==void 0&&e.toString(`ascii`,n.dataStart,n.dataEnd)===`webm`}function O(e,t,n){let r=new Set,i=new Set;for(let a=t.dataStart;a<t.dataEnd;){let o=L(e,a,t.dataEnd,n);if(!o||!V(o,n))return!1;if(o.id===w.tracks&&k(e,o,r),o.id===w.cluster&&j(e,o,n,i),H(r,i))return!0;if(!o.complete||o.unknownSize)return!1;a=o.nextOffset}return!1}function k(e,t,n){let r=I(e,t);if(r){for(let t of r)if(t.id===w.trackEntry){let r=A(e,t);r!==void 0&&n.add(r)}}}function A(e,t){let n=I(e,t),r=F(e,n,w.trackNumber),i=F(e,n,w.trackType),a=n?.find(e=>e.id===w.codecId),o=a?e.toString(`ascii`,a.dataStart,a.dataEnd):void 0;return i===1&&o?.startsWith(`V_`)?r:void 0}function j(e,t,n,r){for(let i=t.dataStart;i<t.dataEnd;){let a=L(e,i,t.dataEnd,n);if(!a||!V(a,n)||(a.id===w.simpleBlock&&N(e,a,r),a.id===w.blockGroup&&M(e,a,r),!a.complete||a.unknownSize))return;i=a.nextOffset}}function M(e,t,n){let r=I(e,t)?.find(e=>e.id===w.block);r&&N(e,r,n)}function N(e,t,n){if(!t.complete||t.unknownSize)return;let r=z(e,t.dataStart);!r||r.unknown||t.dataEnd-t.dataStart<r.length+4||n.add(r.value)}function P(e,t){let n=t.dataEnd-t.dataStart;if(n<1||n>6)return;let r=0;for(let n=t.dataStart;n<t.dataEnd;n+=1)r=r*256+e[n];return Number.isSafeInteger(r)?r:void 0}function F(e,t,n){let r=t?.find(e=>e.id===n);return r?P(e,r):void 0}function I(e,t){if(!t.complete||t.unknownSize)return;let n=[];for(let r=t.dataStart;r<t.dataEnd;){let i=L(e,r,t.dataEnd,e.length);if(!i||!i.complete||i.unknownSize)return;n.push(i),r=i.nextOffset}return n}function L(e,t,n,r){let i=R(e,t);if(!i)return;let a=z(e,t+i.length);if(!a)return;let o=t+i.length+a.length;if(o>n)return;let s=a.unknown?r:o+a.value;if(!(!Number.isSafeInteger(s)||s<o))return{id:i.value,dataStart:o,dataEnd:Math.min(s,n),nextOffset:s,complete:s<=n,unknownSize:a.unknown}}function R(e,t){let n=B(e,t,4);if(!n)return;let r=0;for(let i=0;i<n;i+=1)r=r*256+e[t+i];return{length:n,value:r}}function z(e,t){let n=B(e,t,8);if(!n)return;let r=e[t],i=128>>n-1;if((r&i-1)==i-1&&e.subarray(t+1,t+n).every(e=>e===255))return{length:n,value:0,unknown:!0};let a=r&i-1;for(let r=1;r<n;r+=1)a=a*256+e[t+r];return Number.isSafeInteger(a)?{length:n,value:a,unknown:!1}:void 0}function B(e,t,n){let r=e[t];if(r===void 0||r===0)return;let i=128,a=1;for(;(r&i)===0;)i>>=1,a+=1;return a<=n&&t+a<=e.length?a:void 0}function V(e,t){return e.unknownSize||e.nextOffset<=t}function H(e,t){for(let n of e)if(t.has(n))return!0;return!1}let U;async function W(e,t={}){let n=t.pollMs??150,r=t.attempts??12,a,o=0;for(let t=0;t<r;t+=1){let t=0;try{t=c.statSync(e).size}catch{t=0}if(t>0&&t===a){if(o+=1,o>=2)return}else o=0;a=t,await i(n)}}async function G(e){let t=await Z(e);if(!t)return!1;if(t===`webm`)return!0;try{let t=await K(),n=await r(t,[e],{allowFailure:!0,timeoutMs:1e4,env:h()});return n.exitCode===0||Y(n.stderr,n.stdout)}catch(e){if(q(e))return!0;throw e}}async function K(){U??=_({source:`import Foundation
1
+ import{N as e}from"./sdk-contracts.js";import{sr as t}from"./sdk-batch.js";import{C as n}from"./owner-identity.js";import{l as r}from"./exec.js";import{t as i}from"./timeouts.js";import{n as a,t as o}from"./file.js";import"./command.js";import"./process.js";import"./retry.js";import s from"node:path";import c from"node:fs";import{createHash as l}from"node:crypto";import u from"node:os";import{fileURLToPath as d}from"node:url";const f=`apple/runner/AgentDeviceRunner/RecordingScripts`;function p(e,t,n,r){let i=`${f}/${e}`,a=`dist/${i}`;return[s.resolve(t,e),s.resolve(n,i),s.resolve(t,`../${i}`),s.resolve(t,`../../${i}`),s.resolve(t,`../../../${i}`),s.resolve(n,a),s.resolve(r,i)]}function m(t,n,r=s.dirname(d(import.meta.url)),i=process.cwd()){let a=p(t,r,n,i);for(let e of a)if(c.existsSync(e))return e;throw new e(`COMMAND_FAILED`,`Missing recording helper script: ${t}`,{hint:`Ensure ${f} is present in this checkout or bundled under dist/${f} in the package.`,scriptName:t,searchedPaths:a})}function h(e=process.env){let t=v(),n=s.join(t,`home`),r=s.join(t,`module-cache`);return c.mkdirSync(n,{recursive:!0}),c.mkdirSync(r,{recursive:!0}),{...e,HOME:n,CLANG_MODULE_CACHE_PATH:r}}async function g(e){let t=[e.sourcePath,...e.extraSourcePaths??[]],n=t.map(e=>({sourcePath:e,stat:c.statSync(e),source:c.readFileSync(e)})),r=S(e.cacheName??s.basename(e.sourcePath,s.extname(e.sourcePath))),i=C([`2`,process.platform,process.arch,...n.flatMap(({sourcePath:e,stat:t,source:n})=>[s.resolve(e),t.size,n])]),a=s.join(v(),`bin`,`${r}-${i}`);return await y({sourcePaths:t,executablePath:a,timeoutMs:e.timeoutMs}),a}async function _(e){let t=S(e.cacheName),n=C([`2`,process.platform,process.arch,e.source]),r=s.join(v(),`sources`,`${t}-${n}.swift`),i=s.join(v(),`bin`,`${t}-${n}`);return await y({sourcePaths:[r],executablePath:i,sourceText:e.source,timeoutMs:e.timeoutMs}),i}function v(){let e=process.env.AGENT_DEVICE_SWIFT_CACHE_DIR?.trim();return e?s.resolve(e):s.join(u.tmpdir(),`agent-device-swift-cache`)}async function y(e){if(x(e.executablePath))return;let t=s.dirname(e.executablePath);c.mkdirSync(t,{recursive:!0});let n=e.timeoutMs??12e4;await a({acquire:()=>b(`${e.executablePath}.lock`,n),task:async()=>{if(x(e.executablePath))return;let i=c.mkdtempSync(s.join(t,`.${s.basename(e.executablePath)}.${process.pid}.`)),a=s.join(i,s.basename(e.executablePath));try{let[t]=e.sourcePaths;e.sourceText!==void 0&&t&&!c.existsSync(t)&&(c.mkdirSync(s.dirname(t),{recursive:!0}),c.writeFileSync(t,e.sourceText)),await r(`xcrun`,[`swiftc`,...e.sourcePaths,`-o`,a],{timeoutMs:n,env:h()}),c.renameSync(a,e.executablePath)}finally{c.rmSync(i,{recursive:!0,force:!0})}}})}async function b(t,r){try{return await o({lockDirPath:t,owner:{pid:process.pid,startTime:n(process.pid),acquiredAtMs:Date.now()},timeoutMs:r,pollMs:25,ownerGraceMs:r,description:`Swift cache lock: ${t} (${r}ms)`})}catch(n){throw n instanceof e&&n.message.startsWith(`Timed out waiting for Swift cache lock:`)?new e(`COMMAND_FAILED`,n.message,{...n.details,lockDir:t,timeoutMs:r,hint:`Another agent-device process may still be compiling this Swift helper. Retry shortly; if no agent-device process is active, remove "${t}" and retry.`}):n}}function x(e){try{return c.accessSync(e,c.constants.X_OK),c.statSync(e).isFile()}catch{return!1}}function S(e){return t(e.replaceAll(/[^A-Za-z0-9._-]/g,`-`))||`swift-helper`}function C(e){let t=l(`sha256`);for(let n of e)t.update(Buffer.isBuffer(n)?n:String(n)),t.update(`\0`);return t.digest(`hex`).slice(0,16)}const w={block:161,blockGroup:160,cluster:524531317,codecId:134,documentType:17026,ebml:440786851,segment:408125543,simpleBlock:163,trackEntry:174,trackNumber:215,tracks:374648427,trackType:131};function T(e){let t=E(e);if(!t)return!1;let{bytes:n,fileSize:r}=t,i=L(n,0,n.length,r);if(!i||i.id!==w.ebml||!i.complete||i.unknownSize||!D(n,i))return!1;let a=L(n,i.nextOffset,n.length,r);return!a||a.id!==w.segment||!V(a,r)?!1:O(n,a,r)}function E(e){try{let t=c.openSync(e,`r`);try{let e=c.fstatSync(t).size;if(e<=0)return;let n=Buffer.alloc(Math.min(e,1048576));return c.readSync(t,n,0,n.length,0)===n.length?{bytes:n,fileSize:e}:void 0}finally{c.closeSync(t)}}catch{return}}function D(e,t){let n=I(e,t)?.find(e=>e.id===w.documentType);return n!==void 0&&e.toString(`ascii`,n.dataStart,n.dataEnd)===`webm`}function O(e,t,n){let r=new Set,i=new Set;for(let a=t.dataStart;a<t.dataEnd;){let o=L(e,a,t.dataEnd,n);if(!o||!V(o,n))return!1;if(o.id===w.tracks&&k(e,o,r),o.id===w.cluster&&j(e,o,n,i),H(r,i))return!0;if(!o.complete||o.unknownSize)return!1;a=o.nextOffset}return!1}function k(e,t,n){let r=I(e,t);if(r){for(let t of r)if(t.id===w.trackEntry){let r=A(e,t);r!==void 0&&n.add(r)}}}function A(e,t){let n=I(e,t),r=F(e,n,w.trackNumber),i=F(e,n,w.trackType),a=n?.find(e=>e.id===w.codecId),o=a?e.toString(`ascii`,a.dataStart,a.dataEnd):void 0;return i===1&&o?.startsWith(`V_`)?r:void 0}function j(e,t,n,r){for(let i=t.dataStart;i<t.dataEnd;){let a=L(e,i,t.dataEnd,n);if(!a||!V(a,n)||(a.id===w.simpleBlock&&N(e,a,r),a.id===w.blockGroup&&M(e,a,r),!a.complete||a.unknownSize))return;i=a.nextOffset}}function M(e,t,n){let r=I(e,t)?.find(e=>e.id===w.block);r&&N(e,r,n)}function N(e,t,n){if(!t.complete||t.unknownSize)return;let r=z(e,t.dataStart);!r||r.unknown||t.dataEnd-t.dataStart<r.length+4||n.add(r.value)}function P(e,t){let n=t.dataEnd-t.dataStart;if(n<1||n>6)return;let r=0;for(let n=t.dataStart;n<t.dataEnd;n+=1)r=r*256+e[n];return Number.isSafeInteger(r)?r:void 0}function F(e,t,n){let r=t?.find(e=>e.id===n);return r?P(e,r):void 0}function I(e,t){if(!t.complete||t.unknownSize)return;let n=[];for(let r=t.dataStart;r<t.dataEnd;){let i=L(e,r,t.dataEnd,e.length);if(!i||!i.complete||i.unknownSize)return;n.push(i),r=i.nextOffset}return n}function L(e,t,n,r){let i=R(e,t);if(!i)return;let a=z(e,t+i.length);if(!a)return;let o=t+i.length+a.length;if(o>n)return;let s=a.unknown?r:o+a.value;if(!(!Number.isSafeInteger(s)||s<o))return{id:i.value,dataStart:o,dataEnd:Math.min(s,n),nextOffset:s,complete:s<=n,unknownSize:a.unknown}}function R(e,t){let n=B(e,t,4);if(!n)return;let r=0;for(let i=0;i<n;i+=1)r=r*256+e[t+i];return{length:n,value:r}}function z(e,t){let n=B(e,t,8);if(!n)return;let r=e[t],i=128>>n-1;if((r&i-1)==i-1&&e.subarray(t+1,t+n).every(e=>e===255))return{length:n,value:0,unknown:!0};let a=r&i-1;for(let r=1;r<n;r+=1)a=a*256+e[t+r];return Number.isSafeInteger(a)?{length:n,value:a,unknown:!1}:void 0}function B(e,t,n){let r=e[t];if(r===void 0||r===0)return;let i=128,a=1;for(;(r&i)===0;)i>>=1,a+=1;return a<=n&&t+a<=e.length?a:void 0}function V(e,t){return e.unknownSize||e.nextOffset<=t}function H(e,t){for(let n of e)if(t.has(n))return!0;return!1}let U;async function W(e,t={}){let n=t.pollMs??150,r=t.attempts??12,a,o=0;for(let t=0;t<r;t+=1){let t=0;try{t=c.statSync(e).size}catch{t=0}if(t>0&&t===a){if(o+=1,o>=2)return}else o=0;a=t,await i(n)}}async function G(e){let t=await Z(e);if(!t)return!1;if(t===`webm`)return!0;try{let t=await K(),n=await r(t,[e],{allowFailure:!0,timeoutMs:1e4,env:h()});return n.exitCode===0||Y(n.stderr,n.stdout)}catch(e){if(q(e))return!0;throw e}}async function K(){U??=_({source:`import Foundation
2
2
  import AVFoundation
3
3
 
4
4
  let url = URL(fileURLWithPath: CommandLine.arguments[1])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-device",
3
- "version": "0.21.19",
3
+ "version": "0.21.20",
4
4
  "description": "Mobile app automation and verification for AI coding agents. CLI, MCP server, and typed Node.js API for iOS, Android, HarmonyOS, TV, web, macOS, and Linux.",
5
5
  "mcpName": "io.github.callstack/agent-device",
6
6
  "license": "MIT",
package/server.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "url": "https://github.com/callstack/agent-device",
8
8
  "source": "github"
9
9
  },
10
- "version": "0.21.19",
10
+ "version": "0.21.20",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "agent-device",
15
- "version": "0.21.19",
15
+ "version": "0.21.20",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },
@@ -1 +0,0 @@
1
- 69c852c47ebd70daa25bf2260d379fb67e740e429441c2cf204960937f5ff548 agent-device-android-ime-helper-0.21.19.apk
@@ -1 +0,0 @@
1
- e807254a5ba4b2d408bd5b309a4a9968aa0106f96b2631575f3a6901ea3f968d agent-device-android-snapshot-helper-0.21.19.apk