agent-device 0.21.1 → 0.21.3

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 (196) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.1.apk → agent-device-android-ime-helper-0.21.3.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.3.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.1.manifest.json → agent-device-android-ime-helper-0.21.3.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.3.apk +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.3.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.1.manifest.json → agent-device-android-snapshot-helper-0.21.3.manifest.json} +7 -7
  7. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerScrollViewportPolicy.swift +413 -0
  8. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +34 -0
  9. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +56 -31
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +1 -13
  11. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +4 -0
  12. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +9 -1
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +1 -0
  14. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +0 -4
  15. package/dist/src/absence-observation-errors.js +1 -0
  16. package/dist/src/adapter.js +1 -1
  17. package/dist/src/agent-browser-lifecycle.js +1 -1
  18. package/dist/src/agent-browser-process-record.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/ai-sdk.d.ts +1 -1
  22. package/dist/src/ai-sdk.js +1 -1
  23. package/dist/src/alert-runtime.js +1 -1
  24. package/dist/src/android-input-ownership.js +1 -1
  25. package/dist/src/app-helpers.js +1 -1
  26. package/dist/src/app-inventory-contract.js +1 -1
  27. package/dist/src/app-inventory.js +1 -1
  28. package/dist/src/app-launch.js +1 -1
  29. package/dist/src/app-log-runtime2.js +2 -2
  30. package/dist/src/auth-session.js +1 -1
  31. package/dist/src/auth.js +1 -1
  32. package/dist/src/back-mode.js +1 -0
  33. package/dist/src/browser-launch.js +1 -0
  34. package/dist/src/catalog.js +1 -1
  35. package/dist/src/cli-config.js +1 -1
  36. package/dist/src/cli-help.js +12 -12
  37. package/dist/src/cli-runner.js +1 -1
  38. package/dist/src/cli.js +3 -3
  39. package/dist/src/client-metro-companion.js +1 -1
  40. package/dist/src/client-metro.js +1 -1
  41. package/dist/src/client-types.d.ts +3 -2
  42. package/dist/src/code-signature-cache.js +1 -1
  43. package/dist/src/code-signature.js +1 -1
  44. package/dist/src/command-metadata.js +1 -1
  45. package/dist/src/command-schema.js +3 -3
  46. package/dist/src/command-tools.js +2 -2
  47. package/dist/src/config.js +1 -1
  48. package/dist/src/connection-runtime.js +1 -1
  49. package/dist/src/connection.js +1 -1
  50. package/dist/src/contracts.d.ts +1 -1
  51. package/dist/src/daemon-client-lifecycle.js +1 -1
  52. package/dist/src/daemon-process.js +1 -1
  53. package/dist/src/daemon-registration.js +1 -1
  54. package/dist/src/daemon-resolution.js +1 -0
  55. package/dist/src/daemon-shutdown-report.js +1 -1
  56. package/dist/src/daemon.js +1 -1
  57. package/dist/src/device-boot.js +1 -0
  58. package/dist/src/device-claim-inspection.js +1 -1
  59. package/dist/src/device-claim-rule.js +1 -1
  60. package/dist/src/device-input-state.d.ts +1 -1
  61. package/dist/src/device-session.js +1 -1
  62. package/dist/src/durable-resource.js +1 -1
  63. package/dist/src/engine-eval-script.js +1 -0
  64. package/dist/src/file.js +1 -1
  65. package/dist/src/find.js +1 -1
  66. package/dist/src/finders.js +1 -1
  67. package/dist/src/format.js +1 -0
  68. package/dist/src/generic-settle.js +1 -1
  69. package/dist/src/gesture-plan.js +1 -1
  70. package/dist/src/gesture-runtime.js +1 -1
  71. package/dist/src/harmonyos.js +1 -1
  72. package/dist/src/helper.js +1 -1
  73. package/dist/src/human-control-contract.js +1 -1
  74. package/dist/src/human-control.js +1 -1
  75. package/dist/src/index.d.ts +1 -1
  76. package/dist/src/input-actions.js +1 -1
  77. package/dist/src/interaction-positionals.js +1 -1
  78. package/dist/src/interaction-ref-policy.js +1 -1
  79. package/dist/src/interaction.js +1 -1
  80. package/dist/src/interaction2.js +1 -1
  81. package/dist/src/interactor.js +5 -5
  82. package/dist/src/interactors.js +1 -1
  83. package/dist/src/internal/bin.js +1 -1
  84. package/dist/src/internal/daemon.js +2 -2
  85. package/dist/src/internal/png-worker.d.ts +3 -0
  86. package/dist/src/internal/png-worker.js +1 -1
  87. package/dist/src/ios-snapshot-acquisition.js +1 -1
  88. package/dist/src/ios-snapshot-planning.js +1 -1
  89. package/dist/src/ios-snapshot-runtime.js +1 -1
  90. package/dist/src/lease-scope.js +1 -1
  91. package/dist/src/lease.js +1 -1
  92. package/dist/src/limrun.d.ts +1 -1
  93. package/dist/src/local-interactor-operation-set.js +1 -1
  94. package/dist/src/mechanics.js +16 -16
  95. package/dist/src/mobile-snapshot-semantics.js +1 -1
  96. package/dist/src/mp4-atoms.js +1 -0
  97. package/dist/src/owner-identity.js +3 -3
  98. package/dist/src/parameterized-recorded-fill.js +1 -1
  99. package/dist/src/perf-facade.js +1 -1
  100. package/dist/src/perf-runtime-plan.js +1 -1
  101. package/dist/src/physical-device-control.js +1 -1
  102. package/dist/src/platform-request-scope.js +1 -1
  103. package/dist/src/platform-runtime-app-log-process.js +1 -1
  104. package/dist/src/platform-runtime-host.js +1 -1
  105. package/dist/src/platform-runtime-managed-owner.js +1 -1
  106. package/dist/src/platform-runtime-operation-host.js +2 -2
  107. package/dist/src/platform-runtime-screen-recording-android-host.js +1 -1
  108. package/dist/src/platform-runtime-screen-recording-apple-runner-host.js +1 -1
  109. package/dist/src/platform-runtime-screen-recording-apple-runner-transport.js +1 -1
  110. package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
  111. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  112. package/dist/src/platform-runtime-screen-recording-harmony-host.js +1 -1
  113. package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
  114. package/dist/src/platform-runtime.js +1 -1
  115. package/dist/src/platform-runtime2.js +1 -1
  116. package/dist/src/png-crop-bytes.js +1 -0
  117. package/dist/src/png-worker-contract.js +1 -1
  118. package/dist/src/png.js +1 -0
  119. package/dist/src/process.js +1 -1
  120. package/dist/src/provider-webdriver.js +1 -1
  121. package/dist/src/quality-warnings.js +1 -0
  122. package/dist/src/react-native.js +1 -1
  123. package/dist/src/record-runtime.js +1 -1
  124. package/dist/src/register-builtins.js +1 -1
  125. package/dist/src/registry.js +36 -37
  126. package/dist/src/replay.js +1 -1
  127. package/dist/src/request-admission.js +1 -1
  128. package/dist/src/request-cancellation.js +1 -1
  129. package/dist/src/request-providers.js +1 -1
  130. package/dist/src/request-runtime-binding.js +1 -1
  131. package/dist/src/runner-cache-metadata.js +2 -2
  132. package/dist/src/runner-client.js +1 -1
  133. package/dist/src/runner-disposal.js +1 -1
  134. package/dist/src/runner-presentation.js +1 -1
  135. package/dist/src/runtime.js +3 -3
  136. package/dist/src/runtime10.js +1 -0
  137. package/dist/src/runtime2.js +4 -4
  138. package/dist/src/runtime4.js +5 -5
  139. package/dist/src/runtime6.js +1 -1
  140. package/dist/src/runtime7.js +1 -1
  141. package/dist/src/runtime8.js +1 -1
  142. package/dist/src/runtime9.js +1 -1
  143. package/dist/src/screen-recording-live-handle.js +1 -1
  144. package/dist/src/screen-recording-resource-recovery.js +1 -1
  145. package/dist/src/screen-recording-runtime.js +1 -1
  146. package/dist/src/screenshot-runtime.js +1 -1
  147. package/dist/src/screenshot3.js +2 -2
  148. package/dist/src/script.js +1 -1
  149. package/dist/src/scroll-gesture.js +1 -1
  150. package/dist/src/sdk-batch.js +2 -2
  151. package/dist/src/sdk-contracts.d.ts +26 -26
  152. package/dist/src/sdk-finders.d.ts +1 -1
  153. package/dist/src/sdk-finders.js +1 -1
  154. package/dist/src/sdk-remote-config.d.ts +2 -1
  155. package/dist/src/sdk-remote-config.js +1 -1
  156. package/dist/src/sdk-selectors.d.ts +12 -4
  157. package/dist/src/sdk-selectors.js +1 -1
  158. package/dist/src/selection.js +0 -0
  159. package/dist/src/selector-runtime.js +1 -1
  160. package/dist/src/selectors.js +1 -1
  161. package/dist/src/semantic-index.js +1 -1
  162. package/dist/src/server.js +1 -1
  163. package/dist/src/session-routing.js +1 -1
  164. package/dist/src/session-snapshot.js +1 -1
  165. package/dist/src/session-store.js +2 -2
  166. package/dist/src/session-target-evidence.js +1 -1
  167. package/dist/src/session2.js +5 -5
  168. package/dist/src/simulator-boot.js +3 -0
  169. package/dist/src/simulator.js +1 -1
  170. package/dist/src/snapshot-runtime-binding.js +1 -1
  171. package/dist/src/snapshot-runtime.js +1 -1
  172. package/dist/src/snapshot-state.js +1 -1
  173. package/dist/src/snapshot4.js +1 -1
  174. package/dist/src/src.js +1 -1
  175. package/dist/src/src3.js +1 -1
  176. package/dist/src/src4.js +1 -1
  177. package/dist/src/src7.js +1 -1
  178. package/dist/src/src8.js +2 -2
  179. package/dist/src/telemetry.js +1 -1
  180. package/dist/src/touch-reference-frame.js +1 -1
  181. package/dist/src/tree.js +1 -1
  182. package/dist/src/type-text-runtime.js +1 -1
  183. package/dist/src/vars.js +2 -0
  184. package/dist/src/version.js +1 -1
  185. package/dist/src/video.js +2 -2
  186. package/dist/src/viewport.js +1 -0
  187. package/dist/src/webdriver-ios-snapshot.js +1 -1
  188. package/package.json +2 -1
  189. package/server.json +2 -2
  190. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.1.apk.sha256 +0 -1
  191. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.1.apk +0 -0
  192. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.1.apk.sha256 +0 -1
  193. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-trim.swift +0 -93
  194. package/dist/src/config2.js +0 -1
  195. package/dist/src/provider-device-runtime.js +0 -1
  196. package/dist/src/snapshot-quality-verdict.js +0 -1
@@ -1 +1 @@
1
- import{p as e}from"./scroll-gesture.js";const t=new WeakMap;function n(e){if(!e)return;let n=t.get(e);if(n)return n;let r=i(e.nodes??[]);if(r)return t.set(e,r),r}function r(e){return n({nodes:e,createdAt:0})}const i=e;export{r as n,n as t};
1
+ import{h as e}from"./scroll-gesture.js";const t=new WeakMap;function n(e){if(!e)return;let n=t.get(e);if(n)return n;let r=i(e.nodes??[]);if(r)return t.set(e,r),r}function r(e){return n({nodes:e,createdAt:0})}const i=e;export{r as n,n as t};
package/dist/src/tree.js CHANGED
@@ -1 +1 @@
1
- import{jr as e}from"./sdk-batch.js";function t(e){let t=new Map;for(let n of e){if(typeof n.parentIndex!=`number`)continue;let e=t.get(n.parentIndex)??[];e.push(n),t.set(n.parentIndex,e)}return t}const n=new WeakMap;function r(e,t){if(!e[t])return[];let n=o(e)[t]??t+1;return e.slice(t+1,n)}function i(e,t,n){let r=o(e)[t]??t+1;for(let i=t+1;i<r;i+=1){let t=e[i];if(t&&n(t))return t}}function a(e,t,n){let r=o(e)[t]??t+1;for(let i=t+1;i<r;i+=1){let t=e[i];t&&n(t)}}function o(e){let t=n.get(e);if(t)return t;let r=Array(e.length),i=[];for(let[t,n]of e.entries()){let e=n?.depth??0;for(;i.length>0&&e<=i.at(-1).depth;){let e=i.pop();r[e.position]=t}i.push({depth:e,position:t})}for(let t of i)r[t.position]=e.length;return n.set(e,r),r}function s(e,t){let n=[],r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);)i.add(r.index),n.push(r),r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0;return n}function c(e,t,n){for(let r of s(e,t))if(n(r))return r;return null}function l(e,t,n={}){return(n.includeSelf===!0&&p(e.type)?e:null)??c(e,t,e=>p(e.type))}function u(t,n){let r=e(t.type??``),i=t.label?.trim();return!!(f(t)||r===`other`&&!i&&!t.value||(r===`other`||r===`statictext`)&&i&&n.includes(i)||r===`image`)}function d(t){let n=e(t.type??``);return n===`button`||n===`link`||n===`switch`||n===`searchfield`||n===`textfield`}function f(t){return e(t.type??``)===`button`&&t.label?.trim()===`chevron`&&t.enabled===!1}function p(t){let n=e(t??``);return n===`collectionview`||n===`table`||n===`scrollview`||n===`scrollarea`}function m(t,n){let r=t.label?.trim();if(!r||r!==n)return!1;let i=e(t.type??``);return i===`other`||i===`statictext`||i===`link`}function h(e,t,n){e.set(t.index,{..._(e,t),...n})}function g(e,t,n){let r=_(e,t);e.set(t.index,{...r,...n(r)})}function _(e,t){return{...t,...e.get(t.index)}}function v(t){let n;for(let r of t){let t=e(r.type??``);(t===`application`||t===`window`)&&b(r.rect,n)&&(n=r.rect)}return n}function y(e,t,n=.8){let r=x(e),i=x(t);return r>0&&i>0&&r/i>=n}function b(e,t){return!!(e&&(!t||x(e)>x(t)))}function x(e){return e?e.width*e.height:0}function S(e,t,n){let r=new Map(n.map(e=>[e.index,e])),i=new Map;for(let[t,n]of e.entries())i.set(n.index,t);return e.map((e,n)=>{let a=typeof e.parentIndex==`number`?i.get(e.parentIndex):void 0;return a===void 0&&typeof e.parentIndex==`number`&&(a=C(e.parentIndex,t,r,i)),{...e,index:n,parentIndex:a}})}function C(e,t,n,r){let i=e,a=new Set;for(;typeof i==`number`&&!a.has(i);){if(a.add(i),!t.has(i))return r.get(i);i=n.get(i)?.parentIndex}}export{c as a,f as c,p as d,d as f,g,u as h,v as i,y as l,S as m,r as n,l as o,h as p,i as r,a as s,t,m as u};
1
+ import{Mr as e}from"./sdk-batch.js";function t(e){let t=new Map;for(let n of e){if(typeof n.parentIndex!=`number`)continue;let e=t.get(n.parentIndex)??[];e.push(n),t.set(n.parentIndex,e)}return t}const n=new WeakMap;function r(e,t){if(!e[t])return[];let n=o(e)[t]??t+1;return e.slice(t+1,n)}function i(e,t,n){let r=o(e)[t]??t+1;for(let i=t+1;i<r;i+=1){let t=e[i];if(t&&n(t))return t}}function a(e,t,n){let r=o(e)[t]??t+1;for(let i=t+1;i<r;i+=1){let t=e[i];t&&n(t)}}function o(e){let t=n.get(e);if(t)return t;let r=Array(e.length),i=[];for(let[t,n]of e.entries()){let e=n?.depth??0;for(;i.length>0&&e<=i.at(-1).depth;){let e=i.pop();r[e.position]=t}i.push({depth:e,position:t})}for(let t of i)r[t.position]=e.length;return n.set(e,r),r}function s(e,t){let n=[],r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);)i.add(r.index),n.push(r),r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0;return n}function c(e,t,n){for(let r of s(e,t))if(n(r))return r;return null}function l(e,t,n={}){return(n.includeSelf===!0&&p(e.type)?e:null)??c(e,t,e=>p(e.type))}function u(t,n){let r=e(t.type??``),i=t.label?.trim();return!!(f(t)||r===`other`&&!i&&!t.value||(r===`other`||r===`statictext`)&&i&&n.includes(i)||r===`image`)}function d(t){let n=e(t.type??``);return n===`button`||n===`link`||n===`switch`||n===`searchfield`||n===`textfield`}function f(t){return e(t.type??``)===`button`&&t.label?.trim()===`chevron`&&t.enabled===!1}function p(t){let n=e(t??``);return n===`collectionview`||n===`table`||n===`scrollview`||n===`scrollarea`}function m(t,n){let r=t.label?.trim();if(!r||r!==n)return!1;let i=e(t.type??``);return i===`other`||i===`statictext`||i===`link`}function h(e,t,n){e.set(t.index,{..._(e,t),...n})}function g(e,t,n){let r=_(e,t);e.set(t.index,{...r,...n(r)})}function _(e,t){return{...t,...e.get(t.index)}}function v(t){let n;for(let r of t){let t=e(r.type??``);(t===`application`||t===`window`)&&b(r.rect,n)&&(n=r.rect)}return n}function y(e,t,n=.8){let r=x(e),i=x(t);return r>0&&i>0&&r/i>=n}function b(e,t){return!!(e&&(!t||x(e)>x(t)))}function x(e){return e?e.width*e.height:0}function S(e,t,n){let r=new Map(n.map(e=>[e.index,e])),i=new Map;for(let[t,n]of e.entries())i.set(n.index,t);return e.map((e,n)=>{let a=typeof e.parentIndex==`number`?i.get(e.parentIndex):void 0;return a===void 0&&typeof e.parentIndex==`number`&&(a=C(e.parentIndex,t,r,i)),{...e,index:n,parentIndex:a}})}function C(e,t,n,r){let i=e,a=new Set;for(;typeof i==`number`&&!a.has(i);){if(a.add(i),!t.has(i))return r.get(i);i=n.get(i)?.parentIndex}}export{c as a,f as c,p as d,d as f,g,u as h,v as i,y as l,S as m,r as n,l as o,h as p,i as r,a as s,t,m as u};
@@ -1 +1 @@
1
- import{C as e}from"./sdk-contracts.js";import{Vt as t}from"./sdk-batch.js";import{b as n}from"./runtime.js";import{n as r}from"./success-text.js";import{h as i,p as a}from"./session-snapshot.js";function o(e){let t=e?.trim().split(/\s+/,1)[0];if(!t||!t.startsWith(`@`)||t.length<3)return null;let n=t.slice(1);return/^[A-Za-z_-]*\d[\w-]*$/i.test(n)||/^(?:ref|node|element|el)[\w-]*$/i.test(n)?t:null}async function s(e){let n=await i({command:`type`,device:e.device,use:t,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(n.type===`response`)return{ok:!1,response:n.response};let r=n.runtime;return{ok:!0,typeText:async(e,t)=>await c(r,e,t)}}async function c(t,i,a){let s=o(i[0]);if(s)throw new e(`INVALID_ARGS`,`type does not accept a target ref like "${s}"`,{hint:`Use fill ${s} "text" to target that field, or press ${s} then type "text" to append.`});let c=i.join(` `);if(!c)throw new e(`INVALID_ARGS`,`type requires text`);let u=n(a.delayMs??0,`delay-ms`,0,1e4),d=(await t.operations.typeText(l(c,u,a)))?.textEntryRoute;return{...d===void 0?{}:{textEntryRoute:d},text:c,delayMs:u,...r(`Typed ${Array.from(c).length} chars`)}}function l(e,t,n){return{text:e,delayMs:t,...n.appBundleId===void 0?{}:{options:{appBundleId:n.appBundleId}},execution:a(n)}}export{s as n,c as t};
1
+ import{C as e}from"./sdk-contracts.js";import{Ht as t}from"./sdk-batch.js";import{k as n}from"./runtime.js";import{n as r}from"./success-text.js";import{g as i,m as a}from"./session-snapshot.js";function o(e){let t=e?.trim().split(/\s+/,1)[0];if(!t||!t.startsWith(`@`)||t.length<3)return null;let n=t.slice(1);return/^[A-Za-z_-]*\d[\w-]*$/i.test(n)||/^(?:ref|node|element|el)[\w-]*$/i.test(n)?t:null}async function s(e){let n=await i({command:`type`,device:e.device,use:t,inspectFacts:e.inspectFacts,bindDevice:e.bindDevice});if(n.type===`response`)return{ok:!1,response:n.response};let r=n.runtime;return{ok:!0,typeText:async(e,t)=>await c(r,e,t)}}async function c(t,i,a){let s=o(i[0]);if(s)throw new e(`INVALID_ARGS`,`type does not accept a target ref like "${s}"`,{hint:`Use fill ${s} "text" to target that field, or press ${s} then type "text" to append.`});let c=i.join(` `);if(!c)throw new e(`INVALID_ARGS`,`type requires text`);let u=n(a.delayMs??0,`delay-ms`,0,1e4),d=(await t.operations.typeText(l(c,u,a)))?.textEntryRoute;return{...d===void 0?{}:{textEntryRoute:d},text:c,delayMs:u,...r(`Typed ${Array.from(c).length} chars`)}}function l(e,t,n){return{text:e,delayMs:t,...n.appBundleId===void 0?{}:{options:{appBundleId:n.appBundleId}},execution:a(n)}}export{s as n,c as t};
@@ -0,0 +1,2 @@
1
+ import{C as e}from"./sdk-contracts.js";import{t}from"./script.js";function n(e){return e.startsWith(`AD_`)}function r(t){return new e(`INVALID_ARGS`,`The AD_* namespace is reserved for built-in variables. Rename ${t} to avoid the AD_ prefix.`)}function i(e){let t={};if(e.builtins)for(let[n,r]of Object.entries(e.builtins))t[n]=r;let i=[e.fileEnv,e.shellEnv,e.cliEnv];for(let e of i)if(e)for(let[i,a]of Object.entries(e)){if(n(i))throw r(i);t[i]=a}return{values:t,expandedBuiltinNames:new Set}}function a(e){let r={};for(let[i,a]of Object.entries(e)){if(typeof a!=`string`||!i.startsWith(`AD_VAR_`))continue;let e=i.slice(7);e.length!==0&&t.test(e)&&(n(e)||(r[e]=a))}return r}function o(i){let a={};for(let o of i){let i=o.indexOf(`=`);if(i<=0)throw new e(`INVALID_ARGS`,`Invalid -e entry "${o}": expected KEY=VALUE.`);let s=o.slice(0,i);if(!t.test(s))throw new e(`INVALID_ARGS`,`Invalid -e key "${s}": keys must be uppercase letters, digits, and underscores (e.g. APP_ID).`);if(n(s))throw r(s);a[s]=o.slice(i+1)}return a}function s(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function c(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}return process.env}function l(e){return e>=`A`&&e<=`Z`||e>=`a`&&e<=`z`||e===`_`}function u(e){return l(e)||e>=`0`&&e<=`9`||e===`.`}function d(e){return e===`
2
+ `||e===`\r`||e===`\u2028`||e===`\u2029`}function f(e,t){let n=t+2;if(n>=e.length||!l(e[n]))return null;for(n+=1;n<e.length&&u(e[n]);)n+=1;let r=e.slice(t+2,n);if(e[n]===`}`)return{key:r,fallback:void 0,end:n+1};if(e[n]!==`:`||e[n+1]!==`-`)return null;n+=2;let i=``;for(;n<e.length;){let t=e[n];if(t===`}`)return{key:r,fallback:i,end:n+1};if(t===`\\`){let t=e[n+1];if(t===void 0)return{abortEnd:e.length};if(d(t))return{abortEnd:n+2};i+=t,n+=2;continue}i+=t,n+=1}return{abortEnd:e.length}}function p(t,r,i){let a=``,o=0;for(;o<t.length;){let s=t[o];if(s===`\\`&&t.startsWith("${",o+1)){a+="${",o+=3;continue}if(s===`$`&&t[o+1]===`{`){let s=f(t,o);if(s!==null&&`abortEnd`in s){a+=t.slice(o,s.abortEnd),o=s.abortEnd;continue}if(s!==null){let{key:t,fallback:c}=s;if(Object.prototype.hasOwnProperty.call(r.values,t))n(t)&&(r.expandedBuiltinNames??=new Set).add(t),a+=String(r.values[t]);else if(c!==void 0)a+=c;else throw new e(`INVALID_ARGS`,`Unresolved variable \${${t}} at ${i.file}:${i.line}.`);o=s.end;continue}}a+=s,o+=1}return a}function m(e,t,n){return{...e,positionals:(e.positionals??[]).map(e=>p(e,t,n)),flags:h(e.flags,t,n)??{},runtime:h(e.runtime,t,n)}}function h(e,t,n){return e&&g(e,t,n)}function g(e,t,n){return typeof e==`string`?p(e,t,n):Array.isArray(e)?e.map(e=>g(e,t,n)):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,r])=>[e,g(r,t,n)])):e}function _(e){return Object.entries(e.values).filter(([t,r])=>r.length>0&&(!n(t)||e.expandedBuiltinNames?.has(t))).map(([e,t])=>({name:e,value:t})).sort((e,t)=>t.value.length-e.value.length)}export{s as a,o as i,_ as n,c as o,a as r,m as s,i as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime.js";import{t}from"./ttl-memo.js";import n from"node:path";import r from"node:fs";import{fileURLToPath as i}from"node:url";function a(e){let t=e,i=null;for(let e=0;e<8;e+=1){let e=n.join(t,`package.json`);if(r.existsSync(e)){i??=t;try{if(JSON.parse(r.readFileSync(e,`utf8`)).name===`agent-device`)return t}catch{}}t=n.dirname(t)}return i??e}const o=t(),s=t();function c(e=l()){let t=o.get(e);if(t!==void 0)return t;let i;try{i=JSON.parse(r.readFileSync(n.join(e,`package.json`),`utf8`))}catch{return`0.0.0`}let a=typeof i.version==`string`?i.version:`0.0.0`;return o.set(e,a),a}function l(){let e=s.get(`self`);if(e!==void 0)return e;let t=a(n.dirname(i(import.meta.url)));return s.set(`self`,t),t}var u=e({findProjectRoot:()=>l,readVersion:()=>c});export{l as n,c as r,u as t};
1
+ import{r as e}from"./rolldown-runtime.js";import{t}from"./ttl-memo.js";import n from"node:path";import r from"node:fs";import{fileURLToPath as i}from"node:url";function a(e){let t=e,i=null;for(let e=0;e<8;e+=1){let e=n.join(t,`package.json`);if(r.existsSync(e)){i??=t;try{if(JSON.parse(r.readFileSync(e,`utf8`)).name===`agent-device`)return t}catch{}}t=n.dirname(t)}return i??e}const o=`src/daemon.ts`;function s(e){return r.existsSync(n.join(e,`package.json`))&&r.existsSync(n.join(e,`src/daemon.ts`))}const c=t(),l=t();function u(e=d()){let t=c.get(e);if(t!==void 0)return t;let i;try{i=JSON.parse(r.readFileSync(n.join(e,`package.json`),`utf8`))}catch{return`0.0.0`}let a=typeof i.version==`string`?i.version:`0.0.0`;return c.set(e,a),a}function d(){let e=l.get(`self`);if(e!==void 0)return e;let t=a(n.dirname(i(import.meta.url)));return l.set(`self`,t),t}var f=e({DAEMON_SOURCE_ENTRY:()=>o,findProjectRoot:()=>d,isSourceCheckoutProjectRoot:()=>s,readVersion:()=>u});export{s as a,o as i,d as n,u as r,f as t};
package/dist/src/video.js CHANGED
@@ -1,4 +1,4 @@
1
- import{C as e}from"./sdk-contracts.js";import{tr as t}from"./sdk-batch.js";import{b as n}from"./owner-identity.js";import{c as r}from"./exec.js";import{t as i}from"./timeouts.js";import{t as a}from"./file.js";import"./command.js";import"./retry.js";import"./process.js";import o from"node:path";import s from"node:fs";import{createHash as c}from"node:crypto";import l from"node:os";function u(e=process.env){let t=p(),n=o.join(t,`home`),r=o.join(t,`module-cache`);return s.mkdirSync(n,{recursive:!0}),s.mkdirSync(r,{recursive:!0}),{...e,HOME:n,CLANG_MODULE_CACHE_PATH:r}}async function d(e){let t=[e.sourcePath,...e.extraSourcePaths??[]],n=t.map(e=>({sourcePath:e,stat:s.statSync(e),source:s.readFileSync(e)})),r=_(e.cacheName??o.basename(e.sourcePath,o.extname(e.sourcePath))),i=v([`2`,process.platform,process.arch,...n.flatMap(({sourcePath:e,stat:t,source:n})=>[o.resolve(e),t.size,n])]),a=o.join(p(),`bin`,`${r}-${i}`);return await m({sourcePaths:t,executablePath:a,timeoutMs:e.timeoutMs}),a}async function f(e){let t=_(e.cacheName),n=v([`2`,process.platform,process.arch,e.source]),r=o.join(p(),`sources`,`${t}-${n}.swift`),i=o.join(p(),`bin`,`${t}-${n}`);return await m({sourcePaths:[r],executablePath:i,sourceText:e.source,timeoutMs:e.timeoutMs}),i}function p(){let e=process.env.AGENT_DEVICE_SWIFT_CACHE_DIR?.trim();return e?o.resolve(e):o.join(l.tmpdir(),`agent-device-swift-cache`)}async function m(e){if(g(e.executablePath))return;let t=o.dirname(e.executablePath);s.mkdirSync(t,{recursive:!0});let n=await h(`${e.executablePath}.lock`,e.executablePath,e.timeoutMs??12e4);if(!n)return;let i=s.mkdtempSync(o.join(t,`.${o.basename(e.executablePath)}.${process.pid}.`)),a=o.join(i,o.basename(e.executablePath));try{if(g(e.executablePath))return;let[t]=e.sourcePaths;e.sourceText!==void 0&&t&&!s.existsSync(t)&&(s.mkdirSync(o.dirname(t),{recursive:!0}),s.writeFileSync(t,e.sourceText)),await r(`xcrun`,[`swiftc`,...e.sourcePaths,`-o`,a],{timeoutMs:e.timeoutMs??12e4,env:u()}),s.renameSync(a,e.executablePath)}finally{s.rmSync(i,{recursive:!0,force:!0}),await n()}}async function h(t,r,i){if(g(r))return null;try{return await a({lockDirPath:t,owner:{pid:process.pid,startTime:n(process.pid),acquiredAtMs:Date.now()},timeoutMs:i,pollMs:25,ownerGraceMs:i,description:`Swift cache lock: ${t} (${i}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:i,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 g(e){try{return s.accessSync(e,s.constants.X_OK),s.statSync(e).isFile()}catch{return!1}}function _(e){return t(e.replaceAll(/[^A-Za-z0-9._-]/g,`-`))||`swift-helper`}function v(e){let t=c(`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 y={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 b(e){let t=x(e);if(!t)return!1;let{bytes:n,fileSize:r}=t,i=M(n,0,n.length,r);if(!i||i.id!==y.ebml||!i.complete||i.unknownSize||!S(n,i))return!1;let a=M(n,i.nextOffset,n.length,r);return!a||a.id!==y.segment||!I(a,r)?!1:C(n,a,r)}function x(e){try{let t=s.openSync(e,`r`);try{let e=s.fstatSync(t).size;if(e<=0)return;let n=Buffer.alloc(Math.min(e,1048576));return s.readSync(t,n,0,n.length,0)===n.length?{bytes:n,fileSize:e}:void 0}finally{s.closeSync(t)}}catch{return}}function S(e,t){let n=j(e,t)?.find(e=>e.id===y.documentType);return n!==void 0&&e.toString(`ascii`,n.dataStart,n.dataEnd)===`webm`}function C(e,t,n){let r=new Set,i=new Set;for(let a=t.dataStart;a<t.dataEnd;){let o=M(e,a,t.dataEnd,n);if(!o||!I(o,n))return!1;if(o.id===y.tracks&&w(e,o,r),o.id===y.cluster&&E(e,o,n,i),L(r,i))return!0;if(!o.complete||o.unknownSize)return!1;a=o.nextOffset}return!1}function w(e,t,n){let r=j(e,t);if(r){for(let t of r)if(t.id===y.trackEntry){let r=T(e,t);r!==void 0&&n.add(r)}}}function T(e,t){let n=j(e,t),r=A(e,n,y.trackNumber),i=A(e,n,y.trackType),a=n?.find(e=>e.id===y.codecId),o=a?e.toString(`ascii`,a.dataStart,a.dataEnd):void 0;return i===1&&o?.startsWith(`V_`)?r:void 0}function E(e,t,n,r){for(let i=t.dataStart;i<t.dataEnd;){let a=M(e,i,t.dataEnd,n);if(!a||!I(a,n)||(a.id===y.simpleBlock&&O(e,a,r),a.id===y.blockGroup&&D(e,a,r),!a.complete||a.unknownSize))return;i=a.nextOffset}}function D(e,t,n){let r=j(e,t)?.find(e=>e.id===y.block);r&&O(e,r,n)}function O(e,t,n){if(!t.complete||t.unknownSize)return;let r=P(e,t.dataStart);!r||r.unknown||t.dataEnd-t.dataStart<r.length+4||n.add(r.value)}function k(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 A(e,t,n){let r=t?.find(e=>e.id===n);return r?k(e,r):void 0}function j(e,t){if(!t.complete||t.unknownSize)return;let n=[];for(let r=t.dataStart;r<t.dataEnd;){let i=M(e,r,t.dataEnd,e.length);if(!i||!i.complete||i.unknownSize)return;n.push(i),r=i.nextOffset}return n}function M(e,t,n,r){let i=N(e,t);if(!i)return;let a=P(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 N(e,t){let n=F(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 P(e,t){let n=F(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 F(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 I(e,t){return e.unknownSize||e.nextOffset<=t}function L(e,t){for(let n of e)if(t.has(n))return!0;return!1}let R;async function z(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=s.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 B(e){let t=G(e);if(!t)return!1;if(t===`webm`)return!0;try{let t=await V(),n=await r(t,[e],{allowFailure:!0,timeoutMs:1e4,env:u()});return n.exitCode===0||W(n.stderr,n.stdout)}catch(e){if(H(e))return!0;throw e}}async function V(){R??=f({source:`import Foundation
1
+ import{C as e}from"./sdk-contracts.js";import{nr as t}from"./sdk-batch.js";import{x as n}from"./owner-identity.js";import{c as r}from"./exec.js";import{t as i}from"./timeouts.js";import{t as a}from"./file.js";import"./command.js";import"./retry.js";import"./process.js";import o from"node:path";import s from"node:fs";import{createHash as c}from"node:crypto";import l from"node:os";function u(e=process.env){let t=p(),n=o.join(t,`home`),r=o.join(t,`module-cache`);return s.mkdirSync(n,{recursive:!0}),s.mkdirSync(r,{recursive:!0}),{...e,HOME:n,CLANG_MODULE_CACHE_PATH:r}}async function d(e){let t=[e.sourcePath,...e.extraSourcePaths??[]],n=t.map(e=>({sourcePath:e,stat:s.statSync(e),source:s.readFileSync(e)})),r=_(e.cacheName??o.basename(e.sourcePath,o.extname(e.sourcePath))),i=v([`2`,process.platform,process.arch,...n.flatMap(({sourcePath:e,stat:t,source:n})=>[o.resolve(e),t.size,n])]),a=o.join(p(),`bin`,`${r}-${i}`);return await m({sourcePaths:t,executablePath:a,timeoutMs:e.timeoutMs}),a}async function f(e){let t=_(e.cacheName),n=v([`2`,process.platform,process.arch,e.source]),r=o.join(p(),`sources`,`${t}-${n}.swift`),i=o.join(p(),`bin`,`${t}-${n}`);return await m({sourcePaths:[r],executablePath:i,sourceText:e.source,timeoutMs:e.timeoutMs}),i}function p(){let e=process.env.AGENT_DEVICE_SWIFT_CACHE_DIR?.trim();return e?o.resolve(e):o.join(l.tmpdir(),`agent-device-swift-cache`)}async function m(e){if(g(e.executablePath))return;let t=o.dirname(e.executablePath);s.mkdirSync(t,{recursive:!0});let n=await h(`${e.executablePath}.lock`,e.executablePath,e.timeoutMs??12e4);if(!n)return;let i=s.mkdtempSync(o.join(t,`.${o.basename(e.executablePath)}.${process.pid}.`)),a=o.join(i,o.basename(e.executablePath));try{if(g(e.executablePath))return;let[t]=e.sourcePaths;e.sourceText!==void 0&&t&&!s.existsSync(t)&&(s.mkdirSync(o.dirname(t),{recursive:!0}),s.writeFileSync(t,e.sourceText)),await r(`xcrun`,[`swiftc`,...e.sourcePaths,`-o`,a],{timeoutMs:e.timeoutMs??12e4,env:u()}),s.renameSync(a,e.executablePath)}finally{s.rmSync(i,{recursive:!0,force:!0}),await n()}}async function h(t,r,i){if(g(r))return null;try{return await a({lockDirPath:t,owner:{pid:process.pid,startTime:n(process.pid),acquiredAtMs:Date.now()},timeoutMs:i,pollMs:25,ownerGraceMs:i,description:`Swift cache lock: ${t} (${i}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:i,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 g(e){try{return s.accessSync(e,s.constants.X_OK),s.statSync(e).isFile()}catch{return!1}}function _(e){return t(e.replaceAll(/[^A-Za-z0-9._-]/g,`-`))||`swift-helper`}function v(e){let t=c(`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 y={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 b(e){let t=x(e);if(!t)return!1;let{bytes:n,fileSize:r}=t,i=M(n,0,n.length,r);if(!i||i.id!==y.ebml||!i.complete||i.unknownSize||!S(n,i))return!1;let a=M(n,i.nextOffset,n.length,r);return!a||a.id!==y.segment||!I(a,r)?!1:C(n,a,r)}function x(e){try{let t=s.openSync(e,`r`);try{let e=s.fstatSync(t).size;if(e<=0)return;let n=Buffer.alloc(Math.min(e,1048576));return s.readSync(t,n,0,n.length,0)===n.length?{bytes:n,fileSize:e}:void 0}finally{s.closeSync(t)}}catch{return}}function S(e,t){let n=j(e,t)?.find(e=>e.id===y.documentType);return n!==void 0&&e.toString(`ascii`,n.dataStart,n.dataEnd)===`webm`}function C(e,t,n){let r=new Set,i=new Set;for(let a=t.dataStart;a<t.dataEnd;){let o=M(e,a,t.dataEnd,n);if(!o||!I(o,n))return!1;if(o.id===y.tracks&&w(e,o,r),o.id===y.cluster&&E(e,o,n,i),L(r,i))return!0;if(!o.complete||o.unknownSize)return!1;a=o.nextOffset}return!1}function w(e,t,n){let r=j(e,t);if(r){for(let t of r)if(t.id===y.trackEntry){let r=T(e,t);r!==void 0&&n.add(r)}}}function T(e,t){let n=j(e,t),r=A(e,n,y.trackNumber),i=A(e,n,y.trackType),a=n?.find(e=>e.id===y.codecId),o=a?e.toString(`ascii`,a.dataStart,a.dataEnd):void 0;return i===1&&o?.startsWith(`V_`)?r:void 0}function E(e,t,n,r){for(let i=t.dataStart;i<t.dataEnd;){let a=M(e,i,t.dataEnd,n);if(!a||!I(a,n)||(a.id===y.simpleBlock&&O(e,a,r),a.id===y.blockGroup&&D(e,a,r),!a.complete||a.unknownSize))return;i=a.nextOffset}}function D(e,t,n){let r=j(e,t)?.find(e=>e.id===y.block);r&&O(e,r,n)}function O(e,t,n){if(!t.complete||t.unknownSize)return;let r=P(e,t.dataStart);!r||r.unknown||t.dataEnd-t.dataStart<r.length+4||n.add(r.value)}function k(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 A(e,t,n){let r=t?.find(e=>e.id===n);return r?k(e,r):void 0}function j(e,t){if(!t.complete||t.unknownSize)return;let n=[];for(let r=t.dataStart;r<t.dataEnd;){let i=M(e,r,t.dataEnd,e.length);if(!i||!i.complete||i.unknownSize)return;n.push(i),r=i.nextOffset}return n}function M(e,t,n,r){let i=N(e,t);if(!i)return;let a=P(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 N(e,t){let n=F(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 P(e,t){let n=F(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 F(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 I(e,t){return e.unknownSize||e.nextOffset<=t}function L(e,t){for(let n of e)if(t.has(n))return!0;return!1}let R;async function z(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=s.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 B(e){let t=await G(e);if(!t)return!1;if(t===`webm`)return!0;try{let t=await V(),n=await r(t,[e],{allowFailure:!0,timeoutMs:1e4,env:u()});return n.exitCode===0||W(n.stderr,n.stdout)}catch(e){if(H(e))return!0;throw e}}async function V(){R??=f({source:`import Foundation
2
2
  import AVFoundation
3
3
 
4
4
  let url = URL(fileURLWithPath: CommandLine.arguments[1])
@@ -20,4 +20,4 @@ Task {
20
20
  }
21
21
 
22
22
  semaphore.wait()
23
- exit(exitCode)`,cacheName:`video-validator`,timeoutMs:3e4});try{return await R}catch(e){throw R=void 0,e}}function H(t){return t instanceof e?t.code===`TOOL_MISSING`||W(String(t.details?.stderr??``),String(t.details?.stdout??``)):!1}async function U(e,t={}){let n=t.pollMs??150,r=t.attempts??12;for(let t=0;t<r;t+=1){if(await B(e))return;await i(n)}}function W(e,t){let n=`${e}\n${t}`;return/\b(no such module ['"]AVFoundation['"]|unable to find utility ["']swiftc?["']|xcrun: error: unable to find utility ["']swiftc?["'])\b/i.test(n)}function G(e){try{let t=s.statSync(e);if(!t.isFile()||t.size<=0)return}catch{return}if(e.toLowerCase().endsWith(`.webm`))return b(e)?`webm`:void 0;let t=K(e);return t.includes(`ftyp`)&&t.includes(`moov`)?`mp4`:void 0}function K(e){try{let t=s.openSync(e,`r`);try{let e=s.fstatSync(t).size,n=0,r=[];for(;n+8<=e&&r.length<16;){let e=Buffer.alloc(8);if(s.readSync(t,e,0,8,n)<8)break;let i=e.readUInt32BE(0),a=e.toString(`latin1`,4,8);if(r.push(a),i===1){let e=Buffer.alloc(8);if(s.readSync(t,e,0,8,n+8)<8)break;i=Number(e.readBigUInt64BE(0))}if(!Number.isFinite(i)||i<=0)break;n+=i}return r}finally{s.closeSync(t)}}catch{return[]}}export{d as a,u as i,U as n,z as r,B as t};
23
+ exit(exitCode)`,cacheName:`video-validator`,timeoutMs:3e4});try{return await R}catch(e){throw R=void 0,e}}function H(t){return t instanceof e?t.code===`TOOL_MISSING`||W(String(t.details?.stderr??``),String(t.details?.stdout??``)):!1}async function U(e,t={}){let n=t.pollMs??150,r=t.attempts??12;for(let t=0;t<r;t+=1){if(await B(e))return;await i(n)}}function W(e,t){let n=`${e}\n${t}`;return/\b(no such module ['"]AVFoundation['"]|unable to find utility ["']swiftc?["']|xcrun: error: unable to find utility ["']swiftc?["'])\b/i.test(n)}async function G(e){try{let t=s.statSync(e);if(!t.isFile()||t.size<=0)return}catch{return}return e.toLowerCase().endsWith(`.webm`)?b(e)?`webm`:void 0:await K(e)?`mp4`:void 0}async function K(e){let{findMp4Atom:t}=await import(`./mp4-atoms.js`).then(e=>e.n);return t(e,[`ftyp`])!==void 0&&t(e,[`moov`])!==void 0}export{d as a,u as i,U as n,z as r,B as t};
@@ -0,0 +1 @@
1
+ import{C as e}from"./sdk-contracts.js";function t(t,n){let r=t===void 0?NaN:Number(t);if(!Number.isInteger(r)||r<1)throw new e(`INVALID_ARGS`,`viewport ${n} must be a positive integer`);return r}function n(n){if(n.length!==2)throw new e(`INVALID_ARGS`,`viewport requires exactly two arguments: <width> <height>`);return{width:t(n[0],`width`),height:t(n[1],`height`)}}export{n as t};
@@ -1 +1 @@
1
- import{t as e}from"./webdriver-source.js";import{r as t,t as n}from"./ios-snapshot-acquisition.js";async function r(e,t){return i(await e.source(),t)}function i(r,i){let a=e(r),o=t(a.roots)??{kind:`missing`,reason:`not-provided`};return n({producer:`appium-source`,nodes:a.nodes,viewport:o,lineage:i?{targetId:i}:{}})}export{r as captureWebDriverIosSnapshot};
1
+ import{t as e}from"./webdriver-source.js";import{r as t,t as n}from"./ios-snapshot-acquisition.js";function r(r,i){let a=e(r),o=t(a.roots)??{kind:`missing`,reason:`not-provided`};return n({producer:`appium-source`,nodes:a.nodes,viewport:o,lineage:i?{targetId:i}:{}})}export{r as acquireWebDriverIosSnapshot};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-device",
3
- "version": "0.21.1",
3
+ "version": "0.21.3",
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",
@@ -124,6 +124,7 @@
124
124
  "bench:ios-snapshot": "node --experimental-strip-types scripts/ios-snapshot-benchmark/run.ts",
125
125
  "bench:ios-snapshot:deep-button": "node --experimental-strip-types scripts/ios-snapshot-benchmark/deep-button.ts",
126
126
  "bench:ios-snapshot:evidence": "node --experimental-strip-types scripts/ios-snapshot-benchmark/evidence.ts",
127
+ "bench:png-crop": "node --experimental-strip-types scripts/png-crop-benchmark/run.ts",
127
128
  "bench:ios-ax-bridge:targeted": "node --experimental-strip-types scripts/ios-ax-bridge-spike/targeted-run.ts",
128
129
  "mutation:run": "node --experimental-strip-types scripts/mutation/run.ts",
129
130
  "mutation:check": "node --experimental-strip-types scripts/mutation/run.ts --no-run",
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.1",
10
+ "version": "0.21.3",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "agent-device",
15
- "version": "0.21.1",
15
+ "version": "0.21.3",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },
@@ -1 +0,0 @@
1
- 65454a4663596adfc7fccd9a30e42f02b5ecde17eb1514fa115ef3036171b995 agent-device-android-ime-helper-0.21.1.apk
@@ -1 +0,0 @@
1
- 6ee75909ac499eca439d3663717d8fc1928ada3fec71bf2ae85fb567967a3793 agent-device-android-snapshot-helper-0.21.1.apk
@@ -1,93 +0,0 @@
1
- import AVFoundation
2
- import Foundation
3
-
4
-
5
-
6
- @main
7
- enum RecordingTrim {
8
- static func main() {
9
- do {
10
- try run()
11
- } catch {
12
- fputs("recording-trim: \(error)\n", stderr)
13
- exit(1)
14
- }
15
- }
16
- }
17
-
18
- func run() throws {
19
- let arguments = Array(CommandLine.arguments.dropFirst())
20
- let parsedArgs = try parseArguments(arguments)
21
- let inputURL = URL(fileURLWithPath: parsedArgs.inputPath)
22
- let outputURL = URL(fileURLWithPath: parsedArgs.outputPath)
23
-
24
- try removeStaleOutput(outputURL)
25
-
26
- let asset = AVURLAsset(url: inputURL)
27
- let videoTrack = try sourceVideoTrack(of: asset)
28
- let trimStart = CMTime(seconds: parsedArgs.trimStartMs / 1000.0, preferredTimescale: 600)
29
- guard CMTimeCompare(trimStart, asset.duration) < 0 else {
30
- throw RecordingScriptError.invalidTrimRange
31
- }
32
-
33
- let trimmedDuration = CMTimeSubtract(asset.duration, trimStart)
34
- guard CMTimeCompare(trimmedDuration, .zero) > 0 else {
35
- throw RecordingScriptError.invalidTrimRange
36
- }
37
-
38
- let composition = try makeRecordingComposition(
39
- asset: asset,
40
- videoTrack: videoTrack,
41
- timeRange: CMTimeRange(start: trimStart, duration: trimmedDuration)
42
- )
43
- composition.tracks(withMediaType: .video).first?.preferredTransform = videoTrack.preferredTransform
44
-
45
-
46
-
47
- let presetName = AVAssetExportSession.exportPresets(compatibleWith: composition)
48
- .contains(AVAssetExportPresetPassthrough)
49
- ? AVAssetExportPresetPassthrough
50
- : AVAssetExportPresetHighestQuality
51
- let exporter = try makeRecordingExporter(composition, presetName: presetName, outputURL: outputURL)
52
- try runRecordingExport(
53
- exporter,
54
- timeoutMessage: "Trim export timed out.",
55
- failureMessage: "Trim export failed."
56
- )
57
- }
58
-
59
- func parseArguments(_ arguments: [String]) throws -> (inputPath: String, outputPath: String, trimStartMs: Double) {
60
- var inputPath: String?
61
- var outputPath: String?
62
- var trimStartMs: Double?
63
- var index = 0
64
-
65
- while index < arguments.count {
66
- let argument = arguments[index]
67
- let nextIndex = index + 1
68
- switch argument {
69
- case "--input":
70
- inputPath = try recordingOptionValue(arguments, nextIndex, "--input")
71
- index += 2
72
- case "--output":
73
- outputPath = try recordingOptionValue(arguments, nextIndex, "--output")
74
- index += 2
75
- case "--trim-start-ms":
76
- let rawValue = try recordingOptionValue(arguments, nextIndex, "--trim-start-ms")
77
- guard let parsed = Double(rawValue), parsed >= 0 else {
78
- throw RecordingScriptError.invalidArgs("--trim-start-ms must be a non-negative number")
79
- }
80
- trimStartMs = parsed
81
- index += 2
82
- default:
83
- throw RecordingScriptError.invalidArgs("Unknown argument: \(argument)")
84
- }
85
- }
86
-
87
- guard let inputPath, let outputPath, let trimStartMs else {
88
- throw RecordingScriptError.invalidArgs(
89
- "Usage: recording-trim.swift --input <video> --output <video> --trim-start-ms <ms>"
90
- )
91
- }
92
- return (inputPath, outputPath, trimStartMs)
93
- }
@@ -1 +0,0 @@
1
- const e=18e4,t=6e4,n=6e4,r=2e4,i=12e4,a=1e4,o=15e3,s=2e4,c=15e3,l=2e4,u=1e3,d=5e3;export{l as a,u as c,s as d,o as f,i,d as l,e as n,t as o,r,a as s,n as t,c as u};
@@ -1 +0,0 @@
1
- import{C as e}from"./sdk-contracts.js";import{AsyncLocalStorage as t}from"node:async_hooks";let n=[];const r=new t;async function i(e,t){return await r.run([...e],t)}function a(e,t){for(let n of s()){if(!n.ownsDevice(e))continue;let r=n.getInteractor(e,t);if(r)return r}}function o(e){return s().some(t=>t.ownsDevice(e))}function s(){return r.getStore()??n}function c(e,t={}){y(e);let n=e.map(e=>e.provider);return{providerRuntimes:Object.freeze([...e]),providerRuntimeIds:n,providerRuntimeRequiredIds:m([...n,...t.providerRuntimeRequiredIds??[]]),leaseLifecycleProvider:h(e),recoverableProviderIds:e.filter(e=>e.recoverExpiredLease!==void 0).map(e=>e.provider),recoverExpiredLease:p(e),cloudArtifactProvider:g(e),providerAppCatalog:_(e),deviceInventorySource:v(e),appleRunnerProvider:u(e),appleRunnerScreenRecordingTransport:l(e),providerDeviceRuntimeScope:async t=>await i(e,t)}}function l(e){if(e.some(f))return t=>{for(let n of e){if(!f(n)||!n.ownsDevice(t.device))continue;let e=n.getAppleRunnerScreenRecordingTransport(t.device);if(e)return e}}}function u(e){if(e.some(d))return t=>{for(let n of e){if(!d(n)||!n.ownsDevice(t.device))continue;let e=n.getAppleRunnerProvider(t.device);if(e)return e}}}function d(e){return`getAppleRunnerProvider`in e&&typeof e.getAppleRunnerProvider==`function`}function f(e){return`getAppleRunnerScreenRecordingTransport`in e&&typeof e.getAppleRunnerScreenRecordingTransport==`function`}function p(t){if(t.some(e=>e.recoverExpiredLease!==void 0))return async n=>{let r=t.find(e=>S(e,n.leaseProvider));if(!r?.recoverExpiredLease)throw new e(`UNSUPPORTED_OPERATION`,`Provider ${n.leaseProvider??`unknown`} cannot recover an expired lease.`,{provider:n.leaseProvider,leaseId:n.leaseId});await r.recoverExpiredLease(n)}}function m(e){return[...new Set(e)]}function h(e){if(e.length!==0)return{allocate:async(t,n)=>await x(e,`allocate`,t,n),heartbeat:async(t,n)=>await x(e,`heartbeat`,t,n),release:async(t,n)=>await x(e,`release`,t,n)}}function g(e){if(e.length!==0)return{listCloudArtifacts:async t=>await b(e,t)}}function _(t){let n=t.filter(e=>e.appCatalog!==void 0);if(n.length!==0)return{supports:e=>n.some(t=>S(t,e)),list:async(t,r)=>{let i=n.find(e=>S(e,t.provider));if(!i?.appCatalog)throw new e(`UNSUPPORTED_OPERATION`,`Provider ${t.provider} does not expose an app catalog.`,{provider:t.provider});return await i.appCatalog(t,r)}}}function v(e){if(e.length!==0)return{discover:async(t,n)=>{n.throwIfAborted();for(let r of e){if(!S(r,t.leaseProvider))continue;let e=await r.deviceInventoryProvider(t,n);if(n.throwIfAborted(),e!=null)return{kind:`inventory`,devices:e}}return{kind:`declined`}}}}function y(e){let t=new Set;for(let n of e){if(t.has(n.provider))throw TypeError(`Duplicate provider device runtime: ${n.provider}`);t.add(n.provider)}}async function b(e,t){for(let n of e){if(!S(n,t.provider))continue;let e=await n.cloudArtifacts?.listCloudArtifacts?.(t);if(e)return e}}async function x(e,t,n,r){for(let i of e){if(!S(i,n.leaseProvider))continue;let e=i.leaseLifecycle[t],a=e?await e(n,r):void 0;if(a)return a}}function S(e,t){return e.provider===t}export{a as n,o as r,c as t};
@@ -1 +0,0 @@
1
- import{C as e,R as t}from"./sdk-contracts.js";import{i as n}from"./capture.js";import{n as r}from"./snapshot-quality-backend-capabilities.js";import{r as i}from"./diagnostics.js";import"./diagnostics2.js";import{a,i as o,n as s,r as c,t as l}from"./png-worker-contract.js";import u from"node:path";import d,{promises as f}from"node:fs";import{fileURLToPath as p}from"node:url";import{Worker as m}from"node:worker_threads";function h(e,t){try{let n=p(e),r=u.extname(n)||`.js`;return[u.join(u.dirname(n),`${t}${r}`),u.join(u.dirname(n),`internal`,`${t}${r}`)].find(e=>d.existsSync(e))??null}catch{return null}}var g=class extends Error{};let _=null,v=!1,y=!1,b=0;const x=new Map;function S(e){v=!0,!y&&(y=!0,i({level:`warn`,phase:`png_worker_unavailable`,data:{reason:e}}),process.emitWarning(`PNG worker unavailable, falling back to in-process PNG processing: ${e}`))}function C(n){let r=x.get(n.id);r&&(x.delete(n.id),E(),n.ok?r.resolve(n.result):r.reject(new e(t(n.error.code),n.error.message,n.error.details)))}function w(e,t){_===e&&(S(t.message),_=null,e.terminate().catch(()=>{}),T(new g(`PNG worker failed: ${t.message}`)))}function T(e){let t=[...x.values()];x.clear();for(let n of t)n.reject(e)}function E(){_&&(x.size>0?_.ref():_.unref())}function D(){if(v)return null;if(_)return _;let e=h(import.meta.url,`png-worker`);if(!e)return S(`worker entry module not found next to the current module`),null;try{let t=new m(e,{execArgv:e.endsWith(`.ts`)?[`--experimental-strip-types`]:[]});return t.on(`message`,C),t.on(`error`,e=>{w(t,e)}),t.on(`exit`,e=>{w(t,Error(`PNG worker exited with code ${e}`))}),t.unref(),_=t,t}catch(e){return S(`failed to spawn worker: ${e instanceof Error?e.message:String(e)}`),null}}function O(e){let t=D();if(!t)return Promise.reject(new g(`PNG worker is unavailable`));b+=1;let n=b;return new Promise((r,i)=>{x.set(n,{resolve:r,reject:i}),E();try{t.postMessage({...e,id:n})}catch(e){x.delete(n),E(),i(new g(`failed to post job to PNG worker: ${e instanceof Error?e.message:String(e)}`))}})}async function k(e,t){try{return await O(e)}catch(e){if(e instanceof g)return t();throw e}}function A(){D()}async function j(){let e=_;_=null,T(new g(`PNG worker terminated`)),e&&await e.terminate()}async function M(e,t){let n=await k({kind:`decode`,png:e,label:t},()=>{let n=o(e,t);return{kind:`decode`,width:n.width,height:n.height,data:n.data}}),r=new a.PNG({width:n.width,height:n.height});return r.data=l(n.data),r}async function N(e){let t=await k({kind:`encode`,width:e.width,height:e.height,data:e.data},()=>({kind:`encode`,png:a.PNG.sync.write(e)}));return l(t.png)}async function P(e,t,n){let{kind:r,...i}=await k({kind:`rgb-difference`,firstPng:e,secondPng:t,label:n},()=>({kind:`rgb-difference`,...s(o(e,n),o(t,n))}));return i}async function F(e){let{kind:t,...n}=await k({kind:`diff-pixels`,...e},()=>({kind:`diff-pixels`,...c(e)}));return{...n,diffData:l(n.diffData)}}async function I(t,r){let{min:i,max:a}=n;if(!Number.isFinite(r)||r<i||r>a)throw new e(`INVALID_ARGS`,`Screenshot scale must be between ${i} and ${a}`);if(r===1)return;let o=await M(await f.readFile(t),`screenshot`),s=Math.max(1,Math.round(o.width*r)),c=Math.max(1,Math.round(o.height*r));await f.writeFile(t,await N(R(o,s,c)))}async function L(t,n,r){if(!Number.isInteger(n)||n<1||!Number.isInteger(r)||r<1)throw new e(`INVALID_ARGS`,`Screenshot resize dimensions must be positive integers`);let i=await M(await f.readFile(t),`screenshot`);(i.width!==n||i.height!==r)&&await f.writeFile(t,await N(R(i,n,r)))}function R(e,t,n){let r=new a.PNG({width:t,height:n});for(let i=0;i<n;i+=1){let a=i*e.height/n,o=(i+1)*e.height/n;for(let n=0;n<t;n+=1){let s=n*e.width/t,c=(n+1)*e.width/t,l=0,u=0,d=0,f=0,p=0;for(let t=Math.floor(a);t<Math.ceil(o);t+=1){let n=Math.min(t+1,o)-Math.max(t,a);for(let r=Math.floor(s);r<Math.ceil(c);r+=1){let i=n*(Math.min(r+1,c)-Math.max(r,s)),a=(t*e.width+r)*4;l+=(e.data[a]??0)*i,u+=(e.data[a+1]??0)*i,d+=(e.data[a+2]??0)*i,f+=(e.data[a+3]??0)*i,p+=i}}let m=(i*r.width+n)*4;r.data[m]=Math.round(l/p),r.data[m+1]=Math.round(u/p),r.data[m+2]=Math.round(d/p),r.data[m+3]=Math.round(f/p)}}return r}const z=new Set([`healthy`,`recovered`,`sparse`]),B=new Set(Object.keys(r)),V=new Set([`ax-rejected`,`sparse-tree`,`budget`,`no-nodes`,`capture-failed`,`presentation-failed`,`deferred`,`requested-backend`]);function H(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.state!=`string`||!z.has(t.state)||typeof t.backend!=`string`||!B.has(t.backend))return;let n=U(t.timing);return{state:t.state,backend:t.backend,reason:typeof t.reason==`string`?t.reason:void 0,reasonCode:typeof t.reasonCode==`string`&&V.has(t.reasonCode)?t.reasonCode:void 0,customActions:W(t.customActions),effectiveDepth:typeof t.effectiveDepth==`number`?t.effectiveDepth:void 0,collapsedLeafIndexes:Array.isArray(t.collapsedLeafIndexes)?t.collapsedLeafIndexes.filter(e=>typeof e==`number`):void 0,...n?{timing:n}:{}}}function U(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.acquisitionMs==`number`&&typeof t.presentationMs==`number`)return{acquisitionMs:t.acquisitionMs,presentationMs:t.presentationMs}}function W(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.read==`number`&&typeof t.candidates==`number`)return{read:t.read,candidates:t.candidates,truncated:typeof t.truncated==`number`?t.truncated:0,blocked:t.blocked===!0}}function G(e){return e?.state===`sparse`}function K(e){return e?.backend===`private-ax`?`private-ax`:void 0}export{I as a,M as c,j as d,L as i,N as l,K as n,P as o,H as r,F as s,G as t,A as u};