agent-device 0.17.1 → 0.17.2

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 (81) hide show
  1. package/README.md +1 -1
  2. package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.17.1.apk → agent-device-android-multitouch-helper-0.17.2.apk} +0 -0
  3. package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.17.2.apk.sha256 +1 -0
  4. package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.17.1.manifest.json → agent-device-android-multitouch-helper-0.17.2.manifest.json} +4 -4
  5. package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.17.1.apk → agent-device-android-snapshot-helper-0.17.2.apk} +0 -0
  6. package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.17.2.apk.sha256 +1 -0
  7. package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.17.1.manifest.json → agent-device-android-snapshot-helper-0.17.2.manifest.json} +6 -6
  8. package/dist/src/123.js +1 -0
  9. package/dist/src/1352.js +1 -1
  10. package/dist/src/1534.js +1 -0
  11. package/dist/src/1620.js +1 -0
  12. package/dist/src/1644.js +2 -0
  13. package/dist/src/2284.js +1 -0
  14. package/dist/src/2403.js +3 -0
  15. package/dist/src/2415.js +28 -29
  16. package/dist/src/2474.js +1 -0
  17. package/dist/src/2672.js +1 -0
  18. package/dist/src/3393.js +1 -0
  19. package/dist/src/4778.js +1 -1
  20. package/dist/src/5898.js +1 -0
  21. package/dist/src/7556.js +1 -1
  22. package/dist/src/7847.js +1 -1
  23. package/dist/src/8173.js +27 -0
  24. package/dist/src/8407.js +1 -0
  25. package/dist/src/8699.js +1 -1
  26. package/dist/src/8806.js +3 -3
  27. package/dist/src/9010.js +1 -0
  28. package/dist/src/9238.js +3 -3
  29. package/dist/src/9471.js +1 -1
  30. package/dist/src/9542.js +3 -3
  31. package/dist/src/9616.js +1 -0
  32. package/dist/src/9673.js +1 -0
  33. package/dist/src/9974.js +1 -0
  34. package/dist/src/android-adb.d.ts +12 -6
  35. package/dist/src/android-adb.js +1 -1
  36. package/dist/src/android-snapshot-helper.d.ts +15 -7
  37. package/dist/src/android.js +1 -1
  38. package/dist/src/apple.js +1 -1
  39. package/dist/src/apps.js +1 -1
  40. package/dist/src/args.js +1 -1
  41. package/dist/src/batch.d.ts +16 -4
  42. package/dist/src/cli.js +18 -42
  43. package/dist/src/command-surface.js +1 -1
  44. package/dist/src/contracts.d.ts +28 -4
  45. package/dist/src/contracts.js +1 -1
  46. package/dist/src/find.js +1 -1
  47. package/dist/src/finders.d.ts +3 -1
  48. package/dist/src/generic.js +5 -5
  49. package/dist/src/index.d.ts +141 -73
  50. package/dist/src/index.js +1 -1
  51. package/dist/src/input-actions.js +1 -1
  52. package/dist/src/interaction.js +1 -1
  53. package/dist/src/internal/png-worker.d.ts +26 -0
  54. package/dist/src/internal/png-worker.js +1 -0
  55. package/dist/src/metro.d.ts +3 -1
  56. package/dist/src/react-native.js +1 -1
  57. package/dist/src/remote-config.d.ts +33 -7
  58. package/dist/src/selector-runtime.js +1 -1
  59. package/dist/src/selectors.d.ts +3 -3
  60. package/dist/src/selectors.js +1 -1
  61. package/dist/src/server.js +2 -2
  62. package/dist/src/session.js +10 -11
  63. package/dist/src/snapshot.js +1 -1
  64. package/package.json +6 -3
  65. package/server.json +2 -2
  66. package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.17.1.apk.sha256 +0 -1
  67. package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.17.1.apk.sha256 +0 -1
  68. package/dist/src/1998.js +0 -1
  69. package/dist/src/2805.js +0 -1
  70. package/dist/src/4057.js +0 -1
  71. package/dist/src/5792.js +0 -1
  72. package/dist/src/6085.js +0 -1
  73. package/dist/src/6232.js +0 -1
  74. package/dist/src/8020.js +0 -1
  75. package/dist/src/8502.js +0 -1
  76. package/dist/src/940.js +0 -1
  77. package/dist/src/9404.js +0 -1
  78. package/dist/src/9533.js +0 -1
  79. package/dist/src/command-metadata.js +0 -1
  80. /package/dist/src/{1393.js → 3675.js} +0 -0
  81. /package/dist/src/{5310.js → 695.js} +0 -0
@@ -0,0 +1,3 @@
1
+ import e from"node:fs";import{parseAllDocuments as t,stringify as n}from"yaml";import{AppError as r}from"./9152.js";import{readScreenshotScriptFlag as i}from"./695.js";import{formatScriptStringLiteral as o,parseReplayOpenFlags as s,formatPortableActionLine as l,parseReplaySeriesFlags as a,parseReplayRuntimeFlags as u,isClickLikeCommand as f}from"./123.js";import{MAESTRO_COMPAT_TRACKER_URL as p,MAESTRO_NEW_ISSUE_URL as c}from"./1352.js";let h=/^[A-Z_][A-Z0-9_]*$/,d=/(\\\$\{)|\$\{([A-Za-z_][A-Za-z0-9_.]*)(?::-((?:[^}\\]|\\.)*))?\}/g,m="AD_VAR_";function g(e){return e.startsWith("AD_")}function A(e){return new r("INVALID_ARGS",`The AD_* namespace is reserved for built-in variables. Rename ${e} to avoid the AD_ prefix.`)}function y(e){let t={};if(e.builtins)for(let[n,r]of Object.entries(e.builtins))t[n]=r;for(let n of[e.fileEnv,e.shellEnv,e.cliEnv])if(n)for(let[e,r]of Object.entries(n)){if(g(e))throw A(e);t[e]=r}return{values:t}}function v(e,t){Object.assign(e.values,t)}function w(e){let t={};for(let[n,r]of Object.entries(e)){if("string"!=typeof r||!n.startsWith(m))continue;let e=n.slice(m.length);0!==e.length&&h.test(e)&&(g(e)||(t[e]=r))}return t}function b(e){let t={};for(let n of e){let e=n.indexOf("=");if(e<=0)throw new r("INVALID_ARGS",`Invalid -e entry "${n}": expected KEY=VALUE.`);let i=n.slice(0,e);if(!h.test(i))throw new r("INVALID_ARGS",`Invalid -e key "${i}": keys must be uppercase letters, digits, and underscores (e.g. APP_ID).`);if(g(i))throw A(i);t[i]=n.slice(e+1)}return t}function I(e){return Array.isArray(e)?e.filter(e=>"string"==typeof e):[]}function $(e){if(e&&"object"==typeof e&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))"string"==typeof r&&(t[n]=r);return t}return process.env}function _(e,t,n){return e.replace(d,(e,i,o,s)=>{if(i)return"${";if(!o)return e;if(Object.prototype.hasOwnProperty.call(t.values,o))return String(t.values[o]);if(void 0!==s)return s.replace(/\\(.)/g,"$1");throw new r("INVALID_ARGS",`Unresolved variable \${${o}} at ${n.file}:${n.line}.`)})}function S(e,t,n){return{...e,positionals:(e.positionals??[]).map(e=>_(e,t,n)),flags:N(e.flags,t,n)??{},runtime:N(e.runtime,t,n),replayControl:function(e,t,n){if(!e)return e;if(e.kind==="maestroRunFlowWhen"){return{...e,selector:_(e.selector,t,n)}}return e}(e.replayControl,t,n)}}function N(e,t,n){return e?function e(t,n,r){return"string"==typeof t?_(t,n,r):Array.isArray(t)?t.map(t=>e(t,n,r)):t&&"object"==typeof t?Object.fromEntries(Object.entries(t).map(([t,i])=>[t,e(i,n,r)])):t}(e,t,n):e}let R=new Set(["ios","android","macos","linux"]),D=new Set(["mobile","tv","desktop"]);function M(e){let t=[],n=[],o=e.split(/\r?\n/),l=!1;for(let[e,p]of o.entries()){let o=p.trim();if(0===o.length||o.startsWith("#"))continue;if(x(o)){if(l)throw new r("INVALID_ARGS",`env directives must precede all actions (line ${e+1}).`);continue}let c=function(e){let t=e.trim();if(0===t.length||t.startsWith("#"))return null;let[n,...o]=function(e){let t=[],n=0;for(;n<e.length&&!((n=function(e,t){let n=t;for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n}(e,n))>=e.length);){let i='"'===e[n]?function(e,t){let n=!1,i=t+1;for(;i<e.length;i+=1){let t=e.charAt(i);if('"'===t&&!n)break;if(n){n=!1;continue}n="\\"===t}if(i>=e.length)throw new r("INVALID_ARGS",`Invalid replay script line: ${e}`);return{value:JSON.parse(e.slice(t,i+1)),nextCursor:i+1}}(e,n):function(e,t){let n=t;for(;n<e.length&&!/\s/.test(e.charAt(n));)n+=1;return{value:e.slice(t,n),nextCursor:n}}(e,n);t.push(i.value),n=i.nextCursor}return t}(t);if(void 0===n||"context"===n)return null;let l={ts:Date.now(),command:n,positionals:[],flags:{}};if("snapshot"===n){l.positionals=[];for(let e=0;e<o.length;e+=1){let t=o[e];if("-i"===t){l.flags.snapshotInteractiveOnly=!0;continue}if("-c"===t){l.flags.snapshotCompact=!0;continue}if("--raw"===t){l.flags.snapshotRaw=!0;continue}if("--force-full"===t){l.flags.snapshotForceFull=!0;continue}if(("-d"===t||"--depth"===t)&&e+1<o.length){let t=Number(o[e+1]);Number.isFinite(t)&&t>=0&&(l.flags.snapshotDepth=Math.floor(t)),e+=1;continue}if(("-s"===t||"--scope"===t)&&e+1<o.length){l.flags.snapshotScope=o[e+1],e+=1;continue}if("--backend"===t&&e+1<o.length){e+=1;continue}}return l}if("open"===n){let e=s(o);return l.positionals=e.positionals,Object.assign(l.flags,e.flags),l.runtime=e.runtime,l}if("runtime"===n){let e=u(o);return l.positionals=e.positionals,Object.assign(l.flags,e.flags),l}if(f(n)){let e=a(n,o);Object.assign(l.flags,e.flags);let t=e.positionals[0];if(void 0===t)return l;if(t.startsWith("@"))return l.positionals=[t],e.positionals[1]&&(l.result={refLabel:e.positionals[1]}),l;let r=e.positionals[0],i=e.positionals[1];return j(r)&&j(i)&&e.positionals.length>=2?l.positionals=[r,i]:l.positionals=[e.positionals.join(" ")],l}if("fill"===n){let e=a(n,o);if(Object.assign(l.flags,e.flags),!(e.positionals.length>=2))return l.positionals=e.positionals,l;let[t,r,...i]=e.positionals;return t.startsWith("@")?(i.length>0?(l.positionals=[t,i.join(" ")],l.result={refLabel:r}):l.positionals=[t,r],l):(l.positionals=[t,[r,...i].join(" ")],l)}if("get"===n){let e=o[0],t=o[1];return void 0===e||void 0===t?l.positionals=o:t.startsWith("@")?(l.positionals=[e,t],o[2]&&(l.result={refLabel:o[2]})):l.positionals=[e,o.slice(1).join(" ")],l}if("swipe"===n||"type"===n){let e=a(n,o);return Object.assign(l.flags,e.flags),l.positionals=e.positionals,l}if("record"===n){let e=[];for(let t=0;t<o.length;t+=1){let n=o[t];if("--hide-touches"===n){l.flags.hideTouches=!0;continue}if("--fps"===n&&t+1<o.length){let e=Number(o[t+1]);Number.isFinite(e)&&(l.flags.fps=Math.floor(e)),t+=1;continue}if("--quality"===n&&t+1<o.length){let e=Number(o[t+1]);Number.isFinite(e)&&(l.flags.quality=Math.floor(e)),t+=1;continue}e.push(n)}return l.positionals=e,l}if("screenshot"===n){let e=[];for(let t=0;t<o.length;t+=1){let n=o[t],r=i({args:o,index:t,flags:l.flags});if(r.handled){t=r.nextIndex;continue}e.push(n)}return l.positionals=e,l}return l.positionals=o,l}(p);c&&(t.push(c),n.push(e+1),l=!0)}return{actions:t,actionLines:n}}function O(e){let t=e.split(/\r?\n/),n={};for(let[e,i]of t.entries()){let t=i.trim();if(0===t.length||t.startsWith("#"))continue;if(x(t)){!function(e,t,n){let{key:i,value:o}=function(e,t){let n=e.slice(3).replace(/^[\s]+/,""),i=n.indexOf("=");if(i<=0)throw new r("INVALID_ARGS",`Invalid env directive on line ${t}: expected "env KEY=VALUE".`);let o=n.slice(0,i);if(!h.test(o))throw new r("INVALID_ARGS",`Invalid env key "${o}" on line ${t}: keys must be uppercase letters, digits, and underscores (e.g. APP_ID).`);if(o.startsWith("AD_"))throw new r("INVALID_ARGS",`Invalid env key "${o}" on line ${t}: the AD_* namespace is reserved for built-in variables. Rename ${o} to avoid the AD_ prefix.`);return{key:o,value:function(e,t){if(0===e.length)return"";if(e.startsWith('"'))try{let t=JSON.parse(e);if("string"!=typeof t)throw Error("not a string literal");return t}catch{throw new r("INVALID_ARGS",`Invalid quoted env value on line ${t}.`)}return e}(n.slice(i+1),t)}}(t,n),s=e.env??{};if(Object.prototype.hasOwnProperty.call(s,i))throw new r("INVALID_ARGS",`Duplicate env directive "${i}" on line ${n}.`);s[i]=o,e.env=s}(n,t,e+1);continue}if(!t.startsWith("context "))break;let o=t.match(/(?:^|\s)platform=([^\s]+)/);if(o){let e=o[1];e&&R.has(e)&&L(n,"platform",e)}let s=t.match(/(?:^|\s)target=([^\s]+)/);if(s){let e=s[1];e&&D.has(e)&&L(n,"target",e)}let l=t.match(/(?:^|\s)timeout=(\d+)/);if(l){let e=Number(l[1]);Number.isFinite(e)&&e>=1&&L(n,"timeoutMs",Math.floor(e))}let a=t.match(/(?:^|\s)retries=(\d+)/);if(a){let e=Number(a[1]);Number.isFinite(e)&&e>=0&&L(n,"retries",Math.floor(e))}}return n}function x(e){return"env"===e||e.startsWith("env ")||e.startsWith("env ")}function L(e,t,n){let i=e[t];if(void 0!==i)throw new r("INVALID_ARGS",i===n?`Duplicate replay test metadata "${t}" in context header.`:`Conflicting replay test metadata "${t}" in context header: ${String(i)} vs ${String(n)}.`);e[t]=n}function j(e){return!!e&&!Number.isNaN(Number(e))}function V(t,n,r){let i=[];if(r){let e=r.device.kind?` kind=${r.device.kind}`:"",t=r.device.target?` target=${r.device.target}`:"";i.push(`context platform=${r.device.platform}${t} device=${o(r.device.name)}${e} theme=unknown`)}for(let e of n)i.push(l(e,{runtimeIncludeAllPositionals:!0}));let s=`${i.join("\n")}
2
+ `,a=`${t}.tmp-${process.pid}-${Date.now()}`;e.writeFileSync(a,s),e.renameSync(a,t)}function E(e){let n=t(e);for(let e of n)if(e.errors.length>0){let t=e.errors[0]?.message??"Invalid Maestro YAML flow.";throw new r("INVALID_ARGS",`Invalid Maestro YAML flow: ${t}`)}return n.map(e=>e.toJSON()).filter(e=>null!==e)}function k(e){return`${e.map(e=>n(e).trimEnd()).join("\n---\n")}
3
+ `}function C(e,t=[],n){return{ts:Date.now(),command:e,positionals:t,flags:n??{}}}function G(e,t,n){let r=new Set(n),i=Object.keys(e).filter(e=>!r.has(e));if(i.length>0)throw H(`Maestro ${t} field "${i[0]}" is not supported yet.`)}function P(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function W(e){return e.map((e,t)=>{if("string"==typeof e||P(e))return e;throw new r("INVALID_ARGS",`Unsupported Maestro command at index ${t+1}: expected a scalar or one-key map.`)})}function K(e){if(e){let t;return"android"===(t=e.trim().toLowerCase())?"android":"ios"===t?"ios":void 0}}function F(e,t){if(null==e)return{};if(!P(e))throw new r("INVALID_ARGS",`${t} expects a map.`);let n={};for(let[t,r]of Object.entries(e))("string"==typeof r||"number"==typeof r||"boolean"==typeof r)&&(n[t]=String(r));return n}function U(e,t){return P(e)&&"number"==typeof e.timeout&&Number.isFinite(e.timeout)?Math.max(0,Math.floor(e.timeout)):t}function q(e,t){if(e.appId)return e.appId;throw new r("INVALID_ARGS",`${t} requires appId in the Maestro flow config.`)}function z(e,t){if("string"==typeof t)return t;throw new r("INVALID_ARGS",`${e} expects a string value.`)}function Y(e,t){return e.replace(/\$\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(e,n)=>Object.prototype.hasOwnProperty.call(t.env,n)?String(t.env[n]):e)}function Z(e){throw H(`Maestro command "${e}" is not supported yet.`)}function H(e){throw new r("INVALID_ARGS",`${e} See supported/unsupported Maestro compatibility at ${p}. If this syntax matters for your flows, comment there or open a focused issue at ${c}.`)}function J(e,t){return`${e},${t}`}function T(e){let t=e.match(/^(\d+),(\d+)$/);if(!t)throw H('Only absolute Maestro point selectors like "100,200" are supported.');return{x:Number(t[1]),y:Number(t[2])}}function B(e){let t=e.match(/^\s*(\d+)\s*,\s*(\d+)\s*$/);if(t)return{kind:"absolute",x:Number(t[1]),y:Number(t[2])};let n=e.match(/^\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*$/);if(n)return{kind:"percent",x:Number(n[1]),y:Number(n[2])};throw H('Only Maestro swipe coordinates like "100,200" or "50%,75%" are supported.')}export{G as assertOnlyKeys,y as buildReplayVarScope,w as collectReplayShellEnv,J as formatMaestroPoint,P as isPlainRecord,v as mergeReplayVarScopeValues,W as normalizeCommandList,K as normalizePlatform,T as parseAbsolutePoint,B as parseMaestroPoint,E as parseMaestroYamlDocuments,b as parseReplayCliEnvEntries,M as parseReplayScriptDetailed,F as readEnvMap,I as readReplayCliEnvEntries,O as readReplayScriptMetadata,$ as readReplayShellEnvSource,U as readTimeoutMs,q as requireAppId,z as requireStringValue,Y as resolveMaestroString,S as resolveReplayAction,k as stringifyMaestroYamlDocuments,C as support_action,Z as unsupportedCommand,H as unsupportedMaestroSyntax,V as writeReplayScript};