agent-device 0.17.2 → 0.17.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.
- package/README.md +2 -2
- package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.17.2.apk → agent-device-android-multitouch-helper-0.17.3.apk} +0 -0
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.17.3.apk.sha256 +1 -0
- package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.17.2.manifest.json → agent-device-android-multitouch-helper-0.17.3.manifest.json} +4 -4
- package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.17.2.apk → agent-device-android-snapshot-helper-0.17.3.apk} +0 -0
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.17.3.apk.sha256 +1 -0
- package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.17.2.manifest.json → agent-device-android-snapshot-helper-0.17.3.manifest.json} +6 -6
- package/dist/src/123.js +1 -1
- package/dist/src/1231.js +1 -1
- package/dist/src/1352.js +1 -1
- package/dist/src/221.js +2 -2
- package/dist/src/2403.js +3 -3
- package/dist/src/2415.js +36 -29
- package/dist/src/5611.js +1 -0
- package/dist/src/5827.js +1 -0
- package/dist/src/6088.js +1 -0
- package/dist/src/6133.js +1 -0
- package/dist/src/7847.js +1 -1
- package/dist/src/9471.js +1 -1
- package/dist/src/9542.js +6 -3
- package/dist/src/9616.js +2 -1
- package/dist/src/9818.js +1 -1
- package/dist/src/android-snapshot-helper.d.ts +0 -1
- package/dist/src/android.js +5 -5
- package/dist/src/apple.js +1 -1
- package/dist/src/apps.js +10 -10
- package/dist/src/args.js +53 -14
- package/dist/src/batch.js +1 -1
- package/dist/src/cli-output.js +29 -0
- package/dist/src/cli.js +15 -16
- package/dist/src/command-surface.js +1 -1
- package/dist/src/contracts.d.ts +52 -0
- package/dist/src/contracts.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/generic.js +5 -5
- package/dist/src/index.d.ts +111 -8
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-trace-recording.js +3 -3
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.d.ts +14 -0
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +2 -2
- package/dist/src/session.js +8 -10
- package/dist/src/snapshot.js +2 -2
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +1 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +14 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +297 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +328 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +121 -172
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +153 -5
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +171 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +0 -10
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +64 -18
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +200 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +406 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +82 -169
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +425 -0
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +77 -6
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +10 -1
- package/ios-runner/README.md +5 -5
- package/ios-runner/RUNNER_PROTOCOL.md +0 -1
- package/package.json +3 -3
- package/server.json +2 -2
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.17.2.apk.sha256 +0 -1
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.17.2.apk.sha256 +0 -1
- package/dist/src/1534.js +0 -1
- package/dist/src/1620.js +0 -1
- package/dist/src/1644.js +0 -2
- package/dist/src/2284.js +0 -1
- package/dist/src/2474.js +0 -1
- package/dist/src/2672.js +0 -1
- package/dist/src/3393.js +0 -1
- package/dist/src/5898.js +0 -1
- package/dist/src/695.js +0 -1
- package/dist/src/7455.js +0 -1
- package/dist/src/8173.js +0 -27
- package/dist/src/8407.js +0 -1
- package/dist/src/8699.js +0 -1
- package/dist/src/9673.js +0 -1
- package/dist/src/9974.js +0 -1
package/dist/src/1620.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AppError as e}from"./9152.js";import{defineStringEnum as t}from"./5898.js";import{centerOfRect as n,findNodeByRef as r,normalizeRef as i}from"./1644.js";import{intersectArea as o,isScrollableNodeLike as a}from"./4778.js";import{buildTextPreview as l,trimText as c,findNearestHittableAncestor as s,buildSelectorChainForNode as u,resolveSelectorChain as d,findNodeByLabel as f,resolveRefLabel as p,describeTextSurface as h,formatSelectorFailure as w,normalizeType as m}from"./7847.js";import{successText as b}from"./1534.js";import{parseSelectorChain as g}from"./8407.js";let x=["up","down","left","right"],v=["left","right","left-edge","right-edge"],y=["one-way","ping-pong"],S=t(v,{message:"gesture swipe requires left, right, left-edge, or right-edge"}),I=t(x,{message:e=>`Unknown direction: ${e}`});function N(t){let n=t.direction,r="up"===n||"down"===n?t.referenceHeight:t.referenceWidth,i=function(t){if(void 0===t)return .6;if(!Number.isFinite(t)||t<=0)throw new e("INVALID_ARGS","scroll amount must be a positive number");return t}(t.amount),o=void 0!==t.pixels?function(t){if(!Number.isFinite(t)||t<=0)throw new e("INVALID_ARGS","scroll pixels must be a positive integer");return Math.max(1,Math.round(t))}(t.pixels):Math.round(r*i),a=Math.max(1,Math.round(.05*r)),l=Math.max(1,Math.min(o,Math.max(1,r-2*a))),c=Math.round(l/2),s=Math.round(t.referenceWidth/2),u=Math.round(t.referenceHeight/2),d=(e,r,i,o)=>({direction:n,x1:e,y1:r,x2:i,y2:o,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight,amount:t.amount,pixels:l});switch(n){case"up":return d(s,u-c,s,u+c);case"down":return d(s,u+c,s,u-c);case"left":return d(s-c,u,s+c,u);case"right":return d(s+c,u,s-c,u)}}function k(e){return{...N({...e,direction:function(e){switch(e){case"up":return"down";case"down":return"up";case"left":return"right";case"right":return"left"}}(e.direction)}),direction:e.direction}}function M(e,t,n={}){let r=n.marginPx??8,[i,o,a]="left"===e?[85,15,50]:"right"===e?[15,85,50]:"left-edge"===e?[99,15,50]:[1,85,50],l=_(t,i,a,{marginPx:r}),c=_(t,o,a,{marginPx:r});return{preset:e,x1:l.x,y1:l.y,x2:c.x,y2:c.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function A(e){return S.parse(e)}function $(e){let t=function(e){let t=e.filter(e=>(function(e){if(!e)return!1;let t=e.toLowerCase();return t.includes("application")||t.includes("window")})(e.type)&&P(e.rect)).map(e=>e.rect).sort((e,t)=>(t?.width??0)*(t?.height??0)-(e?.width??0)*(e?.height??0))[0];if(t)return t;let n=e.map(e=>e.rect).filter(P);if(0===n.length)return;let r=Math.max(...n.map(e=>e.x+e.width)),i=Math.max(...n.map(e=>e.y+e.height));if(!(r<=0)&&!(i<=0))return{x:0,y:0,width:r,height:i}}(e);if(t)return{referenceWidth:t.width,referenceHeight:t.height}}function _(e,t,n,r={}){let i={x:Math.round(e.referenceWidth*t/100),y:Math.round(e.referenceHeight*n/100)};return void 0===r.marginPx?i:R(i,e,r.marginPx)}function R(e,t,n){return{x:O(e.x,n,t.referenceWidth),y:O(e.y,n,t.referenceHeight)}}function C(e){return I.parse(e)}function P(e){return!!e&&e.width>0&&e.height>0}function O(e,t,n){let r=Math.max(t,n-t);return E(e,t,r)}function E(e,t,n){return Math.min(Math.round(n),Math.max(Math.round(t),Math.round(e)))}let T=["primary","secondary","middle"];function L(e){return e?.clickButton??"primary"}function D(t){return"primary"===t.button?null:"click"!==t.commandLabel?new e("INVALID_ARGS","--button is supported only for click"):"macos"!==t.platform&&"linux"!==t.platform?new e("UNSUPPORTED_OPERATION",`click --button ${t.button} is supported only on macOS and Linux`):"macos"===t.platform&&"middle"===t.button?new e("UNSUPPORTED_OPERATION","click --button middle is not supported by the macOS runner yet"):"number"==typeof t.count||"number"==typeof t.intervalMs||"number"==typeof t.holdMs||"number"==typeof t.jitterPx||!0===t.doubleTap?new e("INVALID_ARGS",`click --button ${t.button} does not support repeat or gesture modifier flags`):null}function U(e){return"primary"===e?{}:{button:e}}function F(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function H(e){let t=null,n=-1;for(let r of e){let e=r.width*r.height;e>n&&(t=r,n=e)}return t}function q(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function G(e){let t=e.trim().toLowerCase();return!!t&&/^(vertical|horizontal)\s+scroll\s+bar(?:,?\s*\d+\s+pages?)?$/.test(t)}function B(e,t){if(!(e?.trim().toLowerCase()??"").includes("vertical scroll bar"))return null;let n=function(e){if(!e)return null;let t=/^(\d{1,3})%$/.exec(e.trim());if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?Math.max(0,Math.min(100,n)):null}(t);return null===n?null:n<=1?{above:!1,below:!0}:n>=99?{above:!0,below:!1}:{above:!0,below:!0}}function V(e){let t=new Map;for(let[n,r]of e.entries())t.set(r.index,n);let n=[],r=[];for(let[i,o]of e.entries()){let e=Math.max(0,o.depth??0);for(;r.length>0&&e<=r[r.length-1].depth;)r.pop();let a="number"==typeof o.parentIndex?t.get(o.parentIndex):void 0,l="number"==typeof a&&a<i?a:r[r.length-1]?.index;n.push({...o,index:i,depth:e,parentIndex:l}),r.push({depth:e,index:i})}return n}function K(e){return new Map(e.map(e=>[e.index,e]))}function W(e){return e.label?.trim()||e.value?.trim()||e.identifier?.trim()||""}function z(e){if(0===e.length)return{nodes:e,hiddenCount:0,summaryLines:[]};let{byIndex:t,visibleNodeIndexes:n,offscreenNodes:r,hintedContainers:i}=X(e),o=0===n.size?e:e.filter(e=>n.has(e.index));return{nodes:o.map(e=>(function(e,t){let n=t.get(e.index);if(!n||0===n.size)return e;let r=!!(!0===e.hiddenContentAbove||n.has("above"))||void 0,i=!!(!0===e.hiddenContentBelow||n.has("below"))||void 0;return{...e,hiddenContentAbove:r,hiddenContentBelow:i}})(e,i.directionsByContainer)),hiddenCount:0===n.size?0:e.length-o.length,summaryLines:function(e,t,n){let r=new Map;for(let i of e){let e=function(e,t,n){if(!e.rect)return null;let r=Q(e,t,n);return r?Y(e.rect,r):null}(i,t,n);if(!e)continue;let o=r.get(e)??[];o.push(i),r.set(e,o)}return["above","below"].flatMap(e=>{let t=r.get(e);if(!t||0===t.length)return[];let n=(function(e){let t=new Set,n=[];for(let r of e){let e=W(r);!e||t.has(e)||(t.add(e),n.push(e))}return n})(t).slice(0,3).map(e=>`"${e}"`),i=1===t.length?"interactive item":"interactive items",o=n.length>0?`: ${n.join(", ")}`:"";return[`[off-screen ${e}] ${t.length} ${i}${o}`]})}(r.filter(e=>!i.coveredNodeIndexes.has(e.index)&&function(e){if(!0===e.hittable)return!0;let t=(e.type??"").toLowerCase();return t.includes("button")||t.includes("link")||t.includes("textfield")||t.includes("edittext")||t.includes("searchfield")||t.includes("checkbox")||t.includes("radio")||t.includes("switch")||t.includes("menuitem")||!!W(e)}(e)),e,t)}}function j(e){if(0===e.length)return new Map;let{hintedContainers:t}=X(e);var n=t.directionsByContainer;let r=new Map;for(let[e,t]of n){let n={};t.has("above")&&(n.hiddenContentAbove=!0),t.has("below")&&(n.hiddenContentBelow=!0),(n.hiddenContentAbove||n.hiddenContentBelow)&&r.set(e,n)}return r}function X(e){let t=K(e),n=new Set,r=[];for(let i of e){if(J(i,e,t)){!function(e,t,n){let r=e,i=new Set;for(;r&&!i.has(r.index);)i.add(r.index),t.add(r.index),r="number"==typeof r.parentIndex?n.get(r.parentIndex):void 0}(i,n,t);continue}r.push(i)}let i=function(e,t,n,r){let i=new Map,o=new Map,a=new Set;for(let e of t){if(!e.rect)continue;let t=Z(e,n,r);if(!t?.rect)continue;let l=Y(e.rect,t.rect);if(!l)continue;let c=i.get(t.index)??new Set;c.add(l),i.set(t.index,c);let s=o.get(t.index)??new Set;s.add(l),o.set(t.index,s),a.add(e.index)}return function(e,t,n,r,i){for(let o of e){let e=function(e){let t=B(e.label,e.value);if(!t)return null;let n=new Set;return t.above&&n.add("above"),t.below&&n.add("below"),n.size>0?n:null}(o);if(!e||0===e.size)continue;let a=Z(o,t,n);if(!a)continue;let l=r.get(a.index)??new Set,c=i.get(a.index);for(let t of e)(!c||!(c.size>0)||c.has(t))&&l.add(t);r.set(a.index,l)}}(e,n,r,i,o),{directionsByContainer:i,coveredNodeIndexes:a}}(e,r,n,t);return{byIndex:t,visibleNodeIndexes:n,offscreenNodes:r,hintedContainers:i}}function J(e,t,n=K(t)){var r;if(!e.rect)return!0;let i=Q(e,t,n);return!i||(r=e.rect,q(r.x,r.x+r.width,i.x,i.x+i.width)&&q(r.y,r.y+r.height,i.y,i.y+i.height))}function Q(e,t,r=K(t)){var i,o;let a=(i=e,o=r,ee(i,o,e=>!!e.rect)?.rect??null);return a||function(e,t){let r=n(t),i=e.filter(e=>{var t;return!!(t=e.rect)&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.width)&&Number.isFinite(t.height)}),o=i.filter(e=>{let t=(e.type??"").toLowerCase();return t.includes("application")||t.includes("window")}),a=H(o.map(e=>e.rect).filter(e=>F(e,r.x,r.y)));if(a)return a;let l=H(o.map(e=>e.rect));if(l)return l;let c=H(i.map(e=>e.rect).filter(e=>F(e,r.x,r.y)));return c||null}(t,e.rect??{x:0,y:0,width:0,height:0})}function Y(e,t){return e.y+e.height<=t.y?"above":e.y>=t.y+t.height?"below":null}function Z(e,t,n){return ee(e,n,e=>t.has(e.index))}function ee(e,t,n){let r="number"==typeof e.parentIndex?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(i.add(r.index),n(r)&&a(r))return r;r="number"==typeof r.parentIndex?t.get(r.parentIndex):void 0}return null}async function et(t){let{edge:n,target:r={},scope:i,captureNodes:o}=t;try{let e=await o(i),t=function(e,t,n={}){var r,i,o;let l,c=(e??[]).map((e,t)=>({...e,ref:"ref"in e&&e.ref?e.ref:`e${t+1}`}));if(0===c.length)return{canScroll:!1,emptySnapshot:!0,signature:""};let s=j(c),u=function(e,t,n,r){let i=new Map(e.map(e=>[e.index,e])),o=e.filter(e=>a(e)&&es(e.rect));if(0===o.length)return null;let l=function(e,t){if(void 0===e)return null;let n=t.get(e);for(;n;){if(a(n)&&es(n.rect))return n;n=void 0===n.parentIndex?void 0:t.get(n.parentIndex)}return null}(r.nodeIndex,i);if(l)return l;let c=r.point;if(c){let e=o.filter(e=>{var t,n;return e.rect&&(t=e.rect,(n=c).x>=t.x&&n.x<=t.x+t.width&&n.y>=t.y&&n.y<=t.y+t.height)}).sort(ea);if(e.length>0)return e.find(e=>ei(e,t.get(e.index),n))??e[0]??null}let s=o.filter(e=>ei(e,t.get(e.index),n)).sort(el);return s.length>0?s[0]??null:o.filter(t=>J(t,e)).sort(el)[0]??o.sort(el)[0]??null}(c,s,t,n),d=(u?(r=c,i=u.index,l=new Map(r.map(e=>[e.index,e])),r.filter(e=>e.index===i||function(e,t,n){let r=void 0===e.parentIndex?void 0:n.get(e.parentIndex);for(;r;){if(r.index===t)return!0;r=void 0===r.parentIndex?void 0:n.get(r.parentIndex)}return!1}(e,i,l))):c).map(e=>{let t=e.rect?["x","y","width","height"].map(t=>{var n;return n=e.rect?.[t],"number"==typeof n&&Number.isFinite(n)?n.toFixed(1):""}).join(","):"";return[String(e.index??""),String(e.parentIndex??""),String(e.type??""),String(e.label??""),String(e.value??""),t].join("|")}).join("\n");return u?{canScroll:ei(u,s.get(u.index),t),emptySnapshot:!1,signature:d,scope:[(o=u).identifier,o.label,o.value].map(e=>"string"==typeof e?e.trim():"").find(eo)}:{canScroll:!1,emptySnapshot:!1,signature:d}}(e,n,r);if(i&&t.emptySnapshot)return await et({edge:n,target:r,captureNodes:o});return t}catch(t){var l,c,s;throw l=n,c=i,s=t,c?new e("COMMAND_FAILED",`Failed to verify scroll ${l} state for scoped container`,{scope:c,hint:`scroll ${l} could not verify the scoped scroll container. Run snapshot -i -c for the current screen and retry with a visible scroll target.`},s):new e("COMMAND_FAILED",`Failed to verify scroll ${l} state`,{hint:`scroll ${l} needs a snapshot showing hidden content ${"bottom"===l?"below":"above"} before it will move.`},s)}}async function en(t){let n,{edge:r,captureState:i,scroll:o}=t,a=await i();a.scope&&(a=await i(a.scope));let l=0;for(;a.canScroll;){if(l>=40)throw new e("COMMAND_FAILED",`scroll ${r} reached the safety limit before the snapshot showed the edge`,{hint:"The scoped scroll container still reports hidden content. Use a smaller manual scroll + snapshot loop to inspect the current state."});n=await o(),l+=1,a=await i(a.scope)}return{passes:l,result:n}}function er(e,t,n,r,i){return t&&0===n?`Already at ${t}; no hidden content ${"bottom"===t?"below":"above"} detected`:t?`Scrolled to ${t} with ${n} ${e} passes`:void 0!==i?`Scrolled ${e} by ${i}px`:void 0!==r?`Scrolled ${e} by ${r}`:`Scrolled ${e}`}function ei(e,t,n){return"bottom"===n?!0===e.hiddenContentBelow||t?.hiddenContentBelow===!0:!0===e.hiddenContentAbove||t?.hiddenContentAbove===!0}function eo(e){return e.length>0&&e.length<=80&&!/^(true|false)$/i.test(e)&&!/^\d+$/.test(e)&&!/^\d+%$/.test(e)}function ea(e,t){return ec(e.rect)-ec(t.rect)}function el(e,t){return ec(t.rect)-ec(e.rect)}function ec(e){return e?e.width*e.height:0}function es(e){return!!(e&&e.width>0&&e.height>0)}function eu(t,n,r,i){if(!Number.isFinite(t)||!Number.isInteger(t)||t<r||t>i)throw new e("INVALID_ARGS",`${n} must be an integer between ${r} and ${i}`);return t}let ed=["x","y","width","height"];function ef(e){let t=ep(e);if(!t)return null;let r=n(t);return Number.isFinite(r.x)&&Number.isFinite(r.y)?r:null}function ep(e){if(!e)return null;let t=Number(e.x),n=Number(e.y),r=Number(e.width),i=Number(e.height);return Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)&&!(r<0)&&!(i<0)?{x:t,y:n,width:r,height:i}:null}function eh(e,t){return!!e&&!!t&&ed.every(n=>.5>=Math.abs(e[n]-t[n]))}function ew(e){return{x:em(e.x,e.width),y:em(e.y,e.height)}}function em(e,t){if(t<=1)return Math.floor(e);let n=Math.ceil(e);return Math.round(Math.min(Math.floor(e+t-1),Math.max(n,e+t/2)))}let eb=["tabbar","toolbar","navigationbar","bottomnavigation","bottomnavigationview","sheet","dialog","alert","popover","menu"],eg=["button","link","menuitem","tabitem","textfield","searchfield","edittext","checkbox","radio","switch","cell"];function ex(e){if(e.length<2)return e;let t=[...e],r={nodes:t,byIndex:new Map(t.map(e=>[e.index,e]))},i=!1;for(let[e,o]of t.entries()){if(!function(e){return!!eN(e.rect)&&(!!(!0===e.hittable||ey(e,eg))||!!(e.label?.trim()||e.value?.trim()||e.identifier?.trim()))}(o)||!function e(t,r,i){let o=eN(i.rect);if(!o)return null;let a=n(o);for(let n=r+1;n<t.nodes.length;n+=1){let r=t.nodes[n];if(r&&function(t,n,r,i,o){if(!t.nodes[n])return!1;let a=function(t,n,r,i){var o,a,l,c;let s=t.nodes[n];if(!s||!(!(!eN((o=s).rect)||function(e){let t=eS(e);return t.includes("application")||t.includes("window")}(o))&&ey(o,eb))||eI(a=r,l=s,c=t.byIndex)||eI(l,a,c))return null;let u=eN(s.rect);return!u||eh(i,u)||e(t,n,s)?null:u}(t,n,r,i);return!!(a&&F(a,o.x,o.y))}(t,n,i,o,a))return r}return null}(r,e,o))continue;i=!0;let a={...o,hittable:!1,interactionBlocked:"covered",presentationHints:Array.from(new Set([...o.presentationHints??[],"covered"]))};t[e]=a,r.byIndex.set(a.index,a)}return i?t:e}function ev(e){return void 0!==e.interactionBlocked}function ey(e,t){let n=eS(e);return t.some(e=>n.includes(e))}function eS(e){return[e.type,e.role,e.subrole].map(e=>m(e??"")).join(" ")}function eI(e,t,n){let r="number"==typeof t.parentIndex?n.get(t.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(r.index===e.index)return!0;i.add(r.index),r="number"==typeof r.parentIndex?n.get(r.parentIndex):void 0}return!1}function eN(e){let t=ep(e);return t&&t.width>0&&t.height>0?t:null}let ek={application:"application",navigationbar:"navigation-bar",tabbar:"tab-bar",button:"button",imagebutton:"button",link:"link",cell:"cell",statictext:"text",checkedtextview:"text",textfield:"text-field",edittext:"text-field",textarea:"text-view",switch:"switch",slider:"slider",image:"image",imageview:"image",webview:"webview",framelayout:"group",linearlayout:"group",relativelayout:"group",constraintlayout:"group",viewgroup:"group",view:"group",listview:"list",recyclerview:"list",collectionview:"collection",searchfield:"search",segmentedcontrol:"segmented-control",group:"group",window:"window",checkbox:"checkbox",radio:"radio",menuitem:"menu-item",toolbar:"toolbar",scrollarea:"scroll-area",scrollview:"scroll-area",nestedscrollview:"scroll-area",table:"table"};function eM(e,t={}){let n=[],r=[];for(let i of e){let e=i.depth??0,o=i.label?.trim()||i.value?.trim()||i.identifier?.trim()||"",a=e_(i.type??"Element");if("group"===a&&!o)continue;for(;n.length>0&&e<=n[n.length-1];)n.pop();let l=n.length;n.push(e),r.push({node:i,depth:l,type:a,text:eA(i,l,!1,a,t)})}return r}function eA(e,t,n,r,i={}){var o,a,s,u,d,f,p,w;let m,b=r??e_(e.type??"Element"),g=h(e,b),x=(o=e,a=b,s=i,u=g,s.summarizeTextSurfaces&&u.shouldSummarize&&function(e,t,n){let r=c(e.label);if(r&&r!==n)return r;let i=c(e.identifier);if(i&&!eC(i)&&i!==n)return i;switch(t){case"text":case"text-view":return"Text view";case"text-field":return"Text field";case"search":return"Search field";default:return""}}(o,a,u.text)||e$(o,a)),v=" ".repeat(t),y=e.ref?`@${e.ref}`:"",S=(d=e,f=b,p=i,w=g,m=[],!1===d.enabled&&m.push("disabled"),m.push(...d.presentationHints??[]),p.summarizeTextSurfaces&&(!0===d.selected&&m.push("selected"),!0===d.focused&&m.push("focused"),eR(f)&&m.push("editable"),function(e,t){if("scroll-area"===t)return!0;let n=(e.type??"").toLowerCase(),r=`${e.role??""} ${e.subrole??""}`.toLowerCase();return n.includes("scroll")||r.includes("scroll")}(d,f)&&m.push("scrollable"),w.shouldSummarize&&(m.push(`preview:"${l(w.text).replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`),m.push("truncated"))),eP(m)).map(e=>` [${e}]`).join(""),I=x?` "${x}"`:"";return n?`${v}${y} [${b}]${S}`.trimEnd():`${v}${y} [${b}]${I}${S}`.trimEnd()}function e$(e,t){var n,r;let i=e.label?.trim();if(i&&(n=t,r=i,("scroll-area"===n||"list"===n||"collection"===n||"table"===n)&&G(r)))return"";let o=e.value?.trim();if(eR(t)){if(o)return o;if(i)return i}else if(i)return i;if(o)return o;let a=e.identifier?.trim();return!a||eC(a)&&("group"===t||"image"===t||"list"===t||"collection"===t)?"":a}function e_(e){var t;let n=e.replace(/XCUIElementType/gi,"").toLowerCase(),r=e.includes(".")&&(e.startsWith("android.")||e.startsWith("androidx.")||e.startsWith("com."));return(n.includes(".")&&(n=n.replace(/^android\.widget\./,"").replace(/^android\.view\./,"").replace(/^android\.webkit\./,"").replace(/^androidx\./,"").replace(/^com\.google\.android\./,"").replace(/^com\.android\./,""),r&&n.includes(".")&&(n=n.slice(n.lastIndexOf(".")+1))),"textview"===n)?r?"text":"text-view":(t=n,(Object.prototype.hasOwnProperty.call(ek,t)?ek[t]:void 0)||n||"element")}function eR(e){return"text-field"===e||"text-view"===e||"search"===e}function eC(e){return/^[\w.]+:id\/[\w.-]+$/i.test(e)}function eP(e){return[...new Set(e)]}function eO(e){return"text"===e||"label"===e||"any"===e}function eE(e,t){return{session:t.session,requestId:t.requestId,signal:t.signal??e.signal,metadata:t.metadata}}function eT(e){return e.clock?.now()??Date.now()}async function eL(e,t){e.clock?await e.clock.sleep(t):await new Promise(e=>setTimeout(e,t))}function eD(e){return e&&"object"==typeof e?e:void 0}let eU=["button","link","menuitem","tabitem","textfield","searchfield","securetextfield","checkbox","radio","switch","cell"];function eF(e,t){return eH(e,t).node}function eH(e,t){var r;if(ev(t))return{node:t,reason:"covered"};let i=function(e,t){let n=ep(t.rect);if(!n)return null;let r=t,i=new Set;for(;!i.has(r.ref);){i.add(r.ref);let t=e.filter(e=>{if(e.parentIndex!==r.index||!e.hittable||ev(e))return!1;let t=ep(e.rect);return!!t&&eh(t,n)});if(1!==t.length)break;r=t[0]}return r===t?null:r}(e,t);if(i?.rect&&ef(i.rect))return{node:i,reason:"same-rect-descendant"};if([(r=t).type,r.role,r.subrole].map(e=>m(e??"")).some(eq)&&t.rect&&ef(t.rect))return{node:t,reason:"semantic-target"};let a=s(e,t);return a?.rect&&!ev(a)&&ef(a.rect)?!function(e,t,r){var i,a;let l,c,s,u=ep(e.rect),d=ep(t.rect);if(!u||!d)return!1;let f=function(e,t){let r=n(t),i=e.filter(e=>{let t=(e.type??"").toLowerCase();return t.includes("application")||t.includes("window")}).map(e=>ep(e.rect)).filter(e=>null!==e);if(0===i.length)return null;let o=i.filter(e=>F(e,r.x,r.y));return H(o.length>0?o:i)}(r,u);return!!f&&(l=o(i=d,a=f),c=i.width*i.height,s=a.width*a.height,!(l<=0)&&!(c<=0)&&!(s<=0)&&!!(l/s>=.9)&&!!(l/c>=.8))&&!eh(u,d)}(t,a,e)?{node:a,reason:"hittable-ancestor"}:{node:t,reason:"overly-broad-ancestor"}:{node:t,reason:"original"}}function eq(e){return"tab"===e||eU.some(t=>e.includes(t))}async function eG(e,t,n){var r;return(await eJ(e,t,n.action),"point"===t.target.kind)?{kind:"point",point:{x:(r=t.target).x,y:r.y}}:"ref"===t.target.kind?await eB(e,t,t.target,n):await eV(e,t,t.target,n)}async function eB(t,n,r,o){let a=await eY(t,n,r),l=a.resolved,c=o.promoteToHittableAncestor?eW(a.snapshot.nodes,l.node,{action:o.action,label:`Ref ${r.ref}`}):l.node;return ez(c,`Ref ${r.ref}`,o.action),function(t,n,r,o){let a=t.rect?Q(t,n):null;if(!(!t.rect||!a||J(t,n)))throw new e("COMMAND_FAILED",`Ref ${r} is off-screen and not safe to ${o}`,{reason:"offscreen_ref",ref:i(r),rect:t.rect,viewport:a,hint:`Use scroll with the direction from the off-screen summary, take a fresh snapshot, then retry ${o} with the new ref or a selector.`})}(c,a.snapshot.nodes,r.ref,o.action),{kind:"ref",point:e0(c,`Ref ${r.ref} not found or has invalid bounds`),target:{kind:"ref",ref:`@${l.ref}`},node:c,selectorChain:u(c,t.backend.platform,{action:"fill"===o.action?"fill":"click"}),refLabel:p(c,a.snapshot.nodes)}}async function eV(t,n,r,i){let o=g(r.selector),a=await eX(t,n,i.requireInteractive),l=d(eK(a.snapshot.nodes),o,{platform:t.backend.platform,requireRect:!0,requireUnique:!0,disambiguateAmbiguous:!0});if(l&&l.node.rect||!i.requireInteractive||(l=d(eK((a=await eX(t,n,!1)).snapshot.nodes),o,{platform:t.backend.platform,requireRect:!0,requireUnique:!0,disambiguateAmbiguous:!0})),!l||!l.node.rect){let n=d(a.snapshot.nodes,o,{platform:t.backend.platform,requireRect:!0,requireUnique:!1});if(n?.node&&ev(n.node))throw ej({label:`Selector ${n.selector.raw}`,node:n.node,action:i.action,selector:n.selector.raw});throw new e("COMMAND_FAILED",w(o,l?.diagnostics??[],{unique:!0}))}let c=i.promoteToHittableAncestor?eW(a.snapshot.nodes,l.node,{action:i.action,label:`Selector ${l.selector.raw}`}):l.node;return ez(c,`Selector ${l.selector.raw}`,i.action),{kind:"selector",point:e0(c,`Selector ${l.selector.raw} resolved to invalid bounds`),target:{kind:"selector",selector:l.selector.raw},node:c,selectorChain:u(c,t.backend.platform,{action:"fill"===i.action?"fill":"click"}),refLabel:p(c,a.snapshot.nodes)}}function eK(e){return e.filter(e=>!ev(e))}function eW(e,t,n){let r=eH(e,t);if("covered"===r.reason)throw ej({label:n.label,node:t,action:n.action});return r.node}function ez(e,t,n){if(ev(e))throw ej({label:t,node:e,action:n})}function ej(t){return new e("COMMAND_FAILED",`${t.label} is covered by another visible element and cannot ${function(e){switch(e){case"fill":return"be filled";case"focus":return"be focused";case"longPress":return"be long-pressed";default:return"be tapped"}}(t.action)} safely`,{hint:"Use a different visible target, scroll it clear of the overlay, or inspect with snapshot/screenshot before retrying.",...t.selector?{selector:t.selector}:{},ref:`@${t.node.ref}`,interactionBlocked:t.node.interactionBlocked})}async function eX(t,n,r){if(!t.backend.captureSnapshot)throw new e("UNSUPPORTED_OPERATION","snapshot is not supported by this backend");let i=n.session??"default",o=await t.sessions.get(i);if(!o)throw new e("SESSION_NOT_FOUND","No active session. Run open first.");let a=await t.backend.captureSnapshot(eE(t,n),{interactiveOnly:r,compact:r}),l=a.snapshot??{nodes:a.nodes??[],truncated:a.truncated,backend:a.backend,createdAt:eT(t)};return await t.sessions.set({...o,snapshot:l}),{snapshot:l}}async function eJ(t,n,r){if("macos"!==t.backend.platform)return;let i=await eQ(t,n);if(("desktop"===i||"menubar"===i)&&("menubar"!==i||"click"!==r&&"press"!==r))throw new e("UNSUPPORTED_OPERATION",`${r} is not supported on macOS ${i} sessions yet. Open an app session to act, or use the ${i} surface to inspect.`)}async function eQ(e,t){let n=await e.sessions.get(t.session??"default");return n?.metadata?.surface}async function eY(t,n,r){let i=n.session??"default",o=await t.sessions.get(i);if(!o)throw new e("SESSION_NOT_FOUND","No active session. Run open first.");if(!o.snapshot)throw new e("INVALID_ARGS","No snapshot in session. Run snapshot first.");let a=r.fallbackLabel??"",l=eZ(o.snapshot.nodes,r.ref,{fallbackLabel:a});if(l)return{snapshot:o.snapshot,resolved:l};let c=await eX(t,n,!0),s=eZ(c.snapshot.nodes,r.ref,{fallbackLabel:a});if(!s)throw new e("COMMAND_FAILED",`Ref ${r.ref} not found or has no bounds`);return{...c,resolved:s}}function eZ(t,n,o){let a=i(n);if(!a)throw new e("INVALID_ARGS",`Invalid ref: ${n}`);let l=r(t,a);if(e1(l))return{ref:a,node:l};let c=o.fallbackLabel.length>0?f(t,o.fallbackLabel):null;return e1(c)?{ref:a,node:c}:null}function e0(t,n){let r=ef(t.rect);if(!r)throw new e("COMMAND_FAILED",n);return r}function e1(e){return!!e&&null!==ef(e.rect)}let e5=["up","down","left","right","top","bottom"],e2=async(t,n)=>{let r=await eG(t,n,{action:"focus",requireInteractive:!0,promoteToHittableAncestor:!1});if(!t.backend.focus)throw new e("UNSUPPORTED_OPERATION","focus is not supported by this backend");let i=eD(await t.backend.focus(eE(t,n),r.point));return{...r,...i?{backendResult:i}:{},...b(`Focused (${r.point.x}, ${r.point.y})`)}},e8=async(t,n)=>{let r=await eG(t,n,{action:"longPress",requireInteractive:!0,promoteToHittableAncestor:!0});if(!t.backend.longPress)throw new e("UNSUPPORTED_OPERATION","longPress is not supported by this backend");let i=void 0===n.durationMs?void 0:eu(n.durationMs,"durationMs",0,12e4),o=eD(await t.backend.longPress(eE(t,n),r.point,{durationMs:i}));return{...r,...void 0!==i?{durationMs:i}:{},...o?{backendResult:o}:{},...b(`Long pressed (${r.point.x}, ${r.point.y})`)}},e4=async(t,n)=>{var r,i,o,a;let l;if(!t.backend.scroll)throw new e("UNSUPPORTED_OPERATION","scroll is not supported by this backend");let c="bottom"===(r=n.direction)?{direction:"down",edge:"bottom"}:"top"===r?{direction:"up",edge:"top"}:{direction:tn(r,"scroll direction")},s=(i=n.amount,o="scroll amount",void 0===i?void 0:ti(i,o)),u=function(t,n){if(void 0!==t){if(!Number.isFinite(t)||!Number.isInteger(t)||t<=0)throw new e("INVALID_ARGS",`${n} must be a positive integer`);return t}}(n.pixels,"scroll pixels");if(void 0!==s&&void 0!==u)throw new e("INVALID_ARGS","scroll accepts either amount or pixels, not both");let d=await e3(t,n),f="viewport"===d.kind?{kind:"viewport"}:{kind:"point",point:d.point},p=t.backend.scroll,h=async()=>await p(eE(t,n),f,{direction:c.direction,...void 0!==s?{amount:s}:{},...void 0!==u?{pixels:u}:{}}),w=0;if(c.edge){let e=c.edge,r="viewport"===(a=d).kind?{}:{point:a.point,nodeIndex:"node"in a?a.node.index:void 0},i=await en({edge:e,captureState:async i=>await tt(t,n,e,r,i),scroll:h});l=i.result,w=i.passes}else l=await h(),w=1;let m=eD(l);return{...d,direction:c.direction,...c.edge?{edge:c.edge,passes:w}:{},...void 0!==s?{amount:s}:{},...void 0!==u?{pixels:u}:{},...m?{backendResult:m}:{},...b(er(c.direction,c.edge,w,s,u))}},e9=async(t,n)=>{if(!t.backend.swipe)throw new e("UNSUPPORTED_OPERATION","swipe is not supported by this backend");if(n.preset)return await e7(t,n,t.backend.swipe);let r=await te(t,n),i=function(e,t){if(t.to)return{point:tr(t.to,"to")};let n=tn(t.direction,"swipe direction"),r=ti(t.distance??200,"swipe distance");switch(n){case"up":return{point:{x:e.x,y:e.y-r},direction:n,distance:r};case"down":return{point:{x:e.x,y:e.y+r},direction:n,distance:r};case"left":return{point:{x:e.x-r,y:e.y},direction:n,distance:r};case"right":return{point:{x:e.x+r,y:e.y},direction:n,distance:r}}}(r.point,n),o=void 0===n.durationMs?void 0:eu(n.durationMs,"durationMs",16,1e4),a=eD(await t.backend.swipe(eE(t,n),r.point,i.point,{durationMs:o}));return{kind:"swipe",from:r.point,to:i.point,...i.direction?{direction:i.direction}:{},...void 0!==i.distance?{distance:i.distance}:{},...void 0!==o?{durationMs:o}:{},...r.target?{fromTarget:r.target}:{},...a?{backendResult:a}:{},...b("Swiped")}};async function e7(t,n,r){let i;if(n.from||n.to||n.direction||void 0!==n.distance)throw new e("INVALID_ARGS","gesture swipe preset cannot be combined with from, to, direction, or distance");let o=A(n.preset);await eJ(t,n,"swipe");let a=M(o,{referenceWidth:(i=to((await eX(t,n,!1)).snapshot.nodes)).width,referenceHeight:i.height},{platform:t.backend.platform}),l=void 0===n.durationMs?void 0:eu(n.durationMs,"durationMs",16,1e4),c={x:a.x1,y:a.y1},s={x:a.x2,y:a.y2},u=eD(await r(eE(t,n),c,s,{durationMs:l}));return{kind:"swipe",from:c,to:s,preset:o,...void 0!==l?{durationMs:l}:{},fromTarget:{kind:"viewport"},...u?{backendResult:u}:{},...b(`Swiped ${o}`)}}let e6=async(t,n)=>{if(!t.backend.pinch)throw new e("UNSUPPORTED_OPERATION","pinch is not supported by this backend");await eJ(t,n,"pinch");let r=ti(n.scale,"pinch scale"),i=n.center?await eG(t,{...n,target:n.center},{action:"pinch",requireInteractive:!1,promoteToHittableAncestor:!1}):void 0,o=eD(await t.backend.pinch(eE(t,n),{scale:r,...i?{center:i.point}:{}}));return{kind:"pinch",scale:r,...i?{center:i.point,centerTarget:i}:{},...o?{backendResult:o}:{},...b(`Pinched to scale ${r}`)}};async function e3(e,t){let n=t.target??{kind:"viewport"};return"viewport"===n.kind?(await eJ(e,t,"scroll"),{kind:"viewport"}):await eG(e,{...t,target:n},{action:"scroll",requireInteractive:!1,promoteToHittableAncestor:!1})}async function te(t,r){if(r.from){var i;if("x"in(i=r.from)&&"y"in i)return await eJ(t,r,"swipe"),{point:tr(r.from,"from")};let e=await eG(t,{...r,target:r.from},{action:"swipe",requireInteractive:!1,promoteToHittableAncestor:!1});return{point:e.point,target:e}}if(!r.direction)throw new e("INVALID_ARGS","swipe requires from+to or a direction");return await eJ(t,r,"swipe"),{point:n(to((await eX(t,r,!1)).snapshot.nodes)),target:{kind:"viewport"}}}async function tt(t,n,r,i,o){if(!t.backend.captureSnapshot)throw new e("UNSUPPORTED_OPERATION",`scroll ${r} requires snapshot support to verify hidden content before scrolling`);let{captureSnapshot:a}=t.backend;return await et({edge:r,target:i,scope:o,captureNodes:async e=>{let r=await a(eE(t,n),{compact:!0,scope:e});return r.snapshot?.nodes??r.nodes??[]}})}function tn(t,n){switch(t){case"up":case"down":case"left":case"right":return t;default:throw new e("INVALID_ARGS",`${n} must be up, down, left, or right`)}}function tr(t,n){let r=Number(t.x),i=Number(t.y);if(!Number.isFinite(r)||!Number.isFinite(i))throw new e("INVALID_ARGS",`${n} point requires finite x and y`);return{x:r,y:i}}function ti(t,n){if(!Number.isFinite(t)||t<=0)throw new e("INVALID_ARGS",`${n} must be a positive number`);return t}function to(t){let n=t.filter(e=>J(e,t)).map(e=>e.rect).filter(ta),r=n.length>0?n:t.map(e=>e.rect).filter(ta);if(0===r.length)throw new e("COMMAND_FAILED","Cannot infer viewport for directional swipe");let i=Math.min(...r.map(e=>e.x)),o=Math.min(...r.map(e=>e.y));return{x:i,y:o,width:Math.max(...r.map(e=>e.x+e.width))-i,height:Math.max(...r.map(e=>e.y+e.height))-o}}function ta(e){return!!(e&&e.width>0&&e.height>0)}export{T as CLICK_BUTTONS,x as SCROLL_DIRECTIONS,e5 as SCROLL_INPUT_DIRECTIONS,y as SWIPE_PATTERNS,v as SWIPE_PRESETS,ex as annotateCoveredSnapshotNodes,eh as areRectsApproximatelyEqual,z as buildMobileSnapshotPresentation,N as buildScrollGesturePlan,eM as buildSnapshotDisplayLines,k as buildSwipeGesturePlan,M as buildSwipePresetGesturePlan,U as buttonTag,et as captureScrollEdgeState,R as clampGesturePoint,E as clampToRange,j as deriveMobileSnapshotHiddenContentHints,e$ as displayLabel,W as displayNodeLabel,e2 as focusCommand,e_ as formatRole,er as formatScrollEdgeMessage,eA as formatSnapshotLine,D as getClickButtonValidationError,$ as inferGestureReferenceFrame,B as inferVerticalScrollIndicatorDirections,J as isNodeVisibleInEffectiveViewport,ev as isSnapshotNodeInteractionBlocked,G as isSystemScrollIndicatorLabel,e8 as longPressCommand,V as normalizeSnapshotTree,eT as now,C as parseScrollDirection,A as parseSwipePreset,e6 as pinchCommand,_ as pointFromPercent,ew as pointInsideRect,eu as requireIntInRange,eF as resolveActionableTouchNode,eH as resolveActionableTouchResolution,L as resolveClickButton,eG as resolveInteractionTarget,ef as resolveRectCenter,en as runScrollEdgePasses,e4 as scrollCommand,eO as shouldScopeFind,eL as sleep,e9 as swipeCommand,eE as toBackendContext,eD as toBackendResult};
|
package/dist/src/1644.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{AppError as e}from"./9152.js";let t=["ios","macos","android","linux","apple"],r=["mobile","tv","desktop"];function i(e){return e}function o(e){return"apple"===e||"ios"===e||"macos"===e}function n(e,t){return!t||("apple"===t?o(e):e===t)}function a(e){return"macos"===e||"desktop"===e?"macOS":"tv"===e?"tvOS":"iOS"}function l(e){let{simulatorSetPath:t,platform:r,target:i}=e;if(t&&"macos"!==r&&"desktop"!==i)return t}async function s(t,r,i={}){let a=t,l=e=>e.toLowerCase().replace(/_/g," ").replace(/\s+/g," ").trim();if(r.platform&&(a=a.filter(e=>n(e.platform,r.platform))),r.target&&(a=a.filter(e=>(e.target??"mobile")===r.target)),r.udid){let t=a.find(e=>e.id===r.udid&&o(e.platform));if(!t)throw new e("DEVICE_NOT_FOUND",`No Apple device with UDID ${r.udid}`);return t}if(r.serial){let t=a.find(e=>e.id===r.serial&&"android"===e.platform);if(!t)throw new e("DEVICE_NOT_FOUND",`No Android device with serial ${r.serial}`);return t}if(r.deviceName){let t=l(r.deviceName),i=a.find(e=>l(e.name)===t);if(!i)throw new e("DEVICE_NOT_FOUND",`No device named ${r.deviceName}`);return i}let c=a[0];if(void 0!==c&&1===a.length)return c;if(0===a.length){var p;let t=i.simulatorSetPath;if(t&&(!(p=r.platform)||"apple"===p||"ios"===p))throw new e("DEVICE_NOT_FOUND","No devices found in the scoped simulator set",{simulatorSetPath:t,hint:`The simulator set at "${t}" appears to be empty. Create a simulator first:
|
|
2
|
-
xcrun simctl --set "${t}" create "iPhone 16" com.apple.CoreSimulator.SimDeviceType.iPhone-16 com.apple.CoreSimulator.SimRuntime.iOS-18-0`,selector:r});throw new e("DEVICE_NOT_FOUND","No devices found",{selector:r})}let f=a.filter(e=>"device"!==e.kind);f.length>0&&(a=f);let u=a.filter(e=>e.booted),m=u[0];if(void 0!==m&&1===u.length)return m;let d=u[0]??a[0];if(void 0===d)throw new e("DEVICE_NOT_FOUND","No devices found",{selector:r});return d}function c(e){return e.map((e,t)=>({...e,ref:`e${t+1}`}))}function p(e){let t=e.trim();return t.startsWith("@")?t.slice(1)||null:t.startsWith("e")?t:null}function f(e,t){return e.find(e=>e.ref===t)??null}function u(e){return JSON.stringify({interactiveOnly:e?.interactiveOnly===!0,compact:e?.compact===!0,depth:"number"==typeof e?.depth?e.depth:null,scope:e?.scope?.trim()||null,raw:e?.raw===!0})}function m(e){if(e)return{compact:e.snapshotCompact,depth:e.snapshotDepth,interactiveOnly:e.snapshotInteractiveOnly,raw:e.snapshotRaw,scope:e.snapshotScope}}function d(e){return{x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)}}export{r as DEVICE_TARGETS,t as PLATFORM_SELECTORS,c as attachRefs,u as buildSnapshotPresentationKey,d as centerOfRect,f as findNodeByRef,o as isApplePlatform,n as matchesPlatformSelector,i as normalizePlatformSelector,p as normalizeRef,a as resolveApplePlatformName,l as resolveAppleSimulatorSetPathForSelector,s as resolveDevice,m as snapshotPresentationOptionsFromFlags};
|
package/dist/src/2284.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{splitSelectorFromArgs as e,tryParseSelectorChain as t}from"./8407.js";function i(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function n(n){let r=n[0];if(void 0===r)return null;let l=i(r);if(null!==l)return{kind:"sleep",durationMs:l};let s=i(n[n.length-1]);if("text"===r)return{kind:"text",text:(null!==s?n.slice(1,-1).join(" "):n.slice(1).join(" ")).trim(),timeoutMs:s};if(r.startsWith("@"))return{kind:"ref",rawRef:r,timeoutMs:s};let o=e(null!==s?n.slice(0,-1):n.slice());return o&&0===o.rest.length&&t(o.selectorExpression)?{kind:"selector",selectorExpression:o.selectorExpression,timeoutMs:s}:{kind:"text",text:(null!==s?n.slice(0,-1).join(" "):n.join(" ")).trim(),timeoutMs:s}}export{i as parseTimeout,n as parseWaitPositionals};
|
package/dist/src/2474.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{defineStringEnum as e}from"./5898.js";let t={devices:"List available devices.",boot:"Boot or prepare a selected device without using CLI positional arguments.",shutdown:"Shutdown a selected simulator or emulator.",apps:"List installed apps.",session:"List active sessions or print daemon state directory.",open:"Open an app, deep link, URL, or platform surface.",prepare:"Prepare platform helper infrastructure.",close:"Close an app or end the active session.",install:"Install an app binary.",reinstall:"Reinstall an app binary.","install-from-source":"Install an app from a structured source.",push:"Deliver a push payload.","trigger-app-event":"Trigger an app-defined event.",snapshot:"Capture an accessibility snapshot.",screenshot:"Capture a screenshot.",diff:"Diff accessibility snapshots.",wait:"Wait for duration, text, ref, or selector.",alert:"Inspect or handle platform alerts.",appstate:"Show foreground app or activity.",back:"Navigate back.",home:"Go to the home screen.",rotate:"Rotate device orientation.","app-switcher":"Open the app switcher.",keyboard:"Inspect or dismiss the keyboard.",clipboard:"Read or write clipboard text.","react-native":"Run supported React Native app automation helpers.",replay:"Replay a recorded session.",test:"Run one or more replay scripts.",perf:"Show session performance metrics and frame health.",logs:"Manage session app logs.",network:"Show recent HTTP traffic.",record:"Start or stop screen recording.",trace:"Start or stop trace capture.",settings:"Change OS settings and app permissions.",metro:"Prepare Metro runtime or reload React Native apps.",click:"Click or tap a semantic UI target by ref, selector, or point.",press:"Press a semantic UI target by ref, selector, or point.",fill:"Fill text into a semantic UI target by ref, selector, or point.",longpress:"Long press by ref, selector, or point.",swipe:"Swipe between two points.",focus:"Focus input at coordinates.",type:"Type text in the focused field.",scroll:"Scroll in a direction or to an edge.",get:"Get element text or attributes.",is:"Assert UI state.",find:"Find an element and optionally act on it.",gesture:"Run a structured gesture.",batch:"Run multiple structured command steps in one daemon request."};function r(e){let r=t[e];if(!r)throw Error(`Missing command description for ${e}`);return r}function a(){return Object.entries(t).map(([e,t])=>({name:e,description:t}))}let s=["app","frontmost-app","desktop","menubar"],o=e(s,{normalize:e=>e.trim().toLowerCase(),message:e=>`Invalid surface: ${e}. Use ${s.join("|")}.`});function n(e){return o.parse(e)}export{s as SESSION_SURFACES,a as listCommandDescriptionMetadata,n as parseSessionSurface,r as requireCommandDescription};
|
package/dist/src/2672.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{withSuccessText as e,successText as a}from"./1534.js";import{defineStringEnum as t}from"./5898.js";function i(e){let a=e.appId??e.bundleId??e.packageName;return{session:e.session,appId:a,appBundleId:e.bundleId,package:e.packageName}}function n(e,a,t){return{deviceId:a,deviceName:t,..."android"===e?{serial:a}:"ios"===e?{udid:a}:{}}}function r(e,a={}){let t=a.includeAndroidSerial??!0;return{platform:e.platform,target:e.target,device:e.name,id:e.id,..."ios"===e.platform?{device_udid:e.ios?.udid??e.id,ios_simulator_device_set:e.ios?.simulatorSetPath??null}:{},..."android"===e.platform&&t?{serial:e.android?.serial??e.id}:{}}}function s(e){return{name:e.name,...e.sessionStateDir?{sessionStateDir:e.sessionStateDir}:{},...e.runnerLogPath?{runnerLogPath:e.runnerLogPath}:{},...r(e.device,{includeAndroidSerial:!1}),createdAt:e.createdAt}}function d(e){return{platform:e.platform,id:e.id,name:e.name,kind:e.kind,target:e.target,..."boolean"==typeof e.booted?{booted:e.booted}:{}}}function p(e){return e.bundleId??e.package??e.app}function o(a){return e({app:a.app,appPath:a.appPath,platform:a.platform,...a.appId?{appId:a.appId}:{},...a.bundleId?{bundleId:a.bundleId}:{},...a.package?{package:a.package}:{}},`Installed: ${p(a)}`)}function l(e){return e.appName??e.bundleId??e.packageName??e.launchTarget}function u(a){return e({launchTarget:a.launchTarget,...a.appName?{appName:a.appName}:{},...a.appId?{appId:a.appId}:{},...a.bundleId?{bundleId:a.bundleId}:{},...a.packageName?{package:a.packageName}:{},...a.installablePath?{installablePath:a.installablePath}:{},...a.archivePath?{archivePath:a.archivePath}:{},...a.materializationId?{materializationId:a.materializationId}:{},...a.materializationExpiresAt?{materializationExpiresAt:a.materializationExpiresAt}:{}},`Installed: ${l(a)}`)}function c(a){let t=a.appName??a.appBundleId??a.session;return e({session:a.session,...a.sessionStateDir?{sessionStateDir:a.sessionStateDir}:{},...a.runnerLogPath?{runnerLogPath:a.runnerLogPath}:{},...a.requestLogPath?{requestLogPath:a.requestLogPath}:{},...a.appName?{appName:a.appName}:{},...a.appBundleId?{appBundleId:a.appBundleId}:{},...a.startup?{startup:a.startup}:{},...a.runtime?{runtime:a.runtime}:{},...a.device?r(a.device):{}},t?`Opened: ${t}`:"Opened")}function m(e){return{session:e.session,...e.shutdown?{shutdown:e.shutdown}:{},...a(e.session?`Closed: ${e.session}`:"Closed")}}function I(e){return{nodes:e.nodes,truncated:e.truncated,...e.appName?{appName:e.appName}:{},...e.appBundleId?{appBundleId:e.appBundleId}:{},...e.visibility?{visibility:e.visibility}:{},...e.androidSnapshot?{androidSnapshot:e.androidSnapshot}:{},...e.warnings&&e.warnings.length>0?{warnings:e.warnings}:{},...e.unchanged?{unchanged:e.unchanged}:{}}}let g=["path","start","stop","doctor","mark","clear"],h=["metrics","frames"],f=["sample"],S=t(h),P=t(f),_="perf area must be metrics or frames",b="perf action must be sample",A=S.is,N=P.is;export{g as LOG_ACTION_VALUES,b as PERF_ACTION_ERROR_MESSAGE,f as PERF_ACTION_VALUES,_ as PERF_AREA_ERROR_MESSAGE,h as PERF_AREA_VALUES,i as buildAppIdentifiers,n as buildDeviceIdentifiers,N as isPerfAction,A as isPerfArea,p as resolveDeployResultTarget,l as resolveInstallFromSourceResultTarget,m as serializeCloseResult,o as serializeDeployResult,d as serializeDevice,u as serializeInstallFromSourceResult,c as serializeOpenResult,s as serializeSessionListEntry,I as serializeSnapshotResult};
|
package/dist/src/3393.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{splitSelectorFromArgs as e}from"./8407.js";function t(t){if(t[0]?.startsWith("@")){let e=i(t.slice(1));return{ref:t[0],...void 0===e?{}:{label:e}}}let r=e(t);return r?{selector:r.selectorExpression}:{x:Number(t[0]),y:Number(t[1])}}function r(t){let r=t[0];if(r?.startsWith("@")){let e=t.length>=3?t.slice(2).join(" "):t.slice(1).join(" ");return{kind:"ref",target:{ref:r,label:t.length>=3?i(t.slice(1,2)):void 0},text:e}}let n=e(t,{preferTrailingValue:!0});return n?{kind:"selector",target:{selector:n.selectorExpression},text:n.rest.join(" ")}:{kind:"point",target:{x:Number(t[0]),y:Number(t[1])},text:t.slice(2).join(" ")}}function i(e){return e.join(" ").trim()||void 0}export{r as readFillTargetFromPositionals,t as readInteractionTargetFromPositionals};
|
package/dist/src/5898.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AppError as e}from"./9152.js";let t={alert:"alert",appState:"appstate",appSwitcher:"app-switcher",apps:"apps",back:"back",batch:"batch",boot:"boot",click:"click",close:"close",clipboard:"clipboard",devices:"devices",diff:"diff",fill:"fill",find:"find",focus:"focus",gesture:"gesture",get:"get",home:"home",install:"install",installFromSource:"install-from-source",is:"is",keyboard:"keyboard",logs:"logs",longPress:"longpress",network:"network",open:"open",perf:"perf",prepare:"prepare",press:"press",push:"push",record:"record",reactNative:"react-native",reinstall:"reinstall",replay:"replay",rotate:"rotate",scroll:"scroll",screenshot:"screenshot",settings:"settings",shutdown:"shutdown",snapshot:"snapshot",swipe:"swipe",test:"test",trace:"trace",triggerAppEvent:"trigger-app-event",type:"type",wait:"wait"},s={installSource:"install_source",leaseAllocate:"lease_allocate",leaseHeartbeat:"lease_heartbeat",leaseRelease:"lease_release",releaseMaterializedPaths:"release_materialized_paths",runtime:"runtime",sessionList:"session_list"},r={auth:"auth",connect:"connect",connection:"connection",disconnect:"disconnect",mcp:"mcp",metro:"metro",reactDevtools:"react-devtools",session:"session"},o=["pan","fling","swipe","pinch","rotate","transform"],a=`gesture requires one of: ${o.join(", ")}`,n=[t.devices,t.boot,t.shutdown,t.apps,t.open,t.close,t.install,t.reinstall,t.installFromSource,t.push,t.triggerAppEvent,t.snapshot,t.screenshot,t.diff,t.wait,t.alert,t.settings,t.click,t.press,t.longPress,t.swipe,t.focus,t.type,t.fill,t.scroll,t.get,t.gesture,t.is,t.find,t.perf,t.logs,t.network,t.record,t.trace,t.test,t.appState,t.back,t.home,t.rotate,t.appSwitcher,t.keyboard,t.clipboard,t.reactNative],i=c(r.auth,r.connect,r.connection,r.disconnect,r.mcp,r.reactDevtools,t.prepare);function c(...e){return new Set(e)}function l(){return[...Object.values(t),...Object.values(r)].sort()}function p(e){return Object.values(t).includes(e)||e===r.metro||e===r.session}function u(){return l().filter(e=>!i.has(e))}function d(e,t){return e.includes(t)}function m(t,s,r={}){let o=void 0===s?void 0:r.normalize?.(s)??s;if(void 0!==o&&d(t,o))return o;throw new e("INVALID_ARGS",("function"==typeof r.message?r.message(s):r.message)??`Invalid value: ${s}. Use ${t.join("|")}.`)}function f(e,t={}){return{values:e,is:t=>d(e,t),parse:s=>m(e,s,t)}}c(r.auth,r.connect,r.connection,r.disconnect,r.mcp,r.metro,r.reactDevtools,r.session,t.appState,t.prepare,t.batch,t.devices,t.gesture,t.replay,t.test,t.trace);export{n as BATCH_COMMAND_NAMES,o as GESTURE_KINDS,a as GESTURE_SUBCOMMAND_ERROR,s as INTERNAL_COMMANDS,t as PUBLIC_COMMANDS,f as defineStringEnum,p as isClientBackedCliCommandName,d as isStringMember,l as listCliCommandNames,u as listMcpExposedCommandNames,m as parseStringMember};
|
package/dist/src/695.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AppError as e}from"./9152.js";let s=["out","overlayRefs","screenshotFullscreen","screenshotMaxSize","screenshotNoStabilize"],n=["screenshotFullscreen","screenshotMaxSize","screenshotNoStabilize"],t=[{key:"screenshotFullscreen",names:["--fullscreen"],type:"boolean",usageLabel:"--fullscreen",usageDescription:"Screenshot: capture the full screen instead of the app window"},{key:"screenshotMaxSize",names:["--max-size"],type:"int",min:1,usageLabel:"--max-size <px>",usageDescription:"Screenshot: downscale so the longest edge is at most <px>"},{key:"screenshotNoStabilize",names:["--no-stabilize"],type:"boolean",usageLabel:"--no-stabilize",usageDescription:"Screenshot: skip Android demo-mode/status-bar stabilization and settle delay for low-latency capture loops"}];function r(e){return l({overlayRefs:e?.overlayRefs,fullscreen:e?.screenshotFullscreen,maxSize:e?.screenshotMaxSize,stabilize:!e?.screenshotNoStabilize&&void 0})}function o(e={}){return l({overlayRefs:e.overlayRefs,screenshotFullscreen:e.screenshotFullscreen??e.fullscreen,screenshotMaxSize:e.screenshotMaxSize??e.maxSize,screenshotNoStabilize:e.screenshotNoStabilize??(!1===e.stabilize||void 0)})}function i(e,s){s?.screenshotFullscreen&&e.push("--fullscreen"),"number"==typeof s?.screenshotMaxSize&&e.push("--max-size",String(s.screenshotMaxSize)),s?.screenshotNoStabilize&&e.push("--no-stabilize")}function a(s){let{args:n,flags:t,index:r}=s,o=n[r];if("--fullscreen"===o)return t.screenshotFullscreen=!0,{handled:!0,nextIndex:r};if("--no-stabilize"===o)return t.screenshotNoStabilize=!0,{handled:!0,nextIndex:r};if("--max-size"===o){let s=n[r+1],o=void 0===s?NaN:Number(s);if(!Number.isInteger(o)||o<1)throw new e("INVALID_ARGS","screenshot --max-size requires a positive integer");return t.screenshotMaxSize=o,{handled:!0,nextIndex:r+1}}return{handled:!1}}function l(e){return Object.fromEntries(Object.entries(e).filter(e=>void 0!==e[1]))}export{n as SCREENSHOT_ACTION_FLAG_KEYS,s as SCREENSHOT_COMMAND_FLAG_KEYS,t as SCREENSHOT_SPECIFIC_FLAG_DEFINITIONS,i as appendScreenshotScriptFlags,a as readScreenshotScriptFlag,o as screenshotFlagsFromOptions,r as screenshotOptionsFromFlags};
|
package/dist/src/7455.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AppError as e}from"./9152.js";function n(n,r,t,i){let o=t(n[r]);if(void 0===o)throw new e("COMMAND_FAILED",i,{response:n});return o}function r(e,r){return n(e,r,c,`Daemon response is missing "${r}".`)}function t(e,n){return c(e[n])}function i(e,n){var r;let t;return r=c,null===(t=e[n])?null:r(t)}function o(e,r){return n(e,r,m,`Daemon response is missing numeric "${r}".`)}function u(e,r){return n(e,r,p,`Daemon response has invalid "${r}".`)}function d(e,r){return n(e,r,v,`Daemon response has invalid "${r}".`)}function f(e,n){return function(e){return"tv"===e||"mobile"===e||"desktop"===e?e:void 0}(e[n])??"mobile"}function s(e,n){let r=e[n];if(!g(r))return;let t=a(r,"x"),i=a(r,"y"),o=a(r,"width"),u=a(r,"height");if(void 0!==t&&void 0!==i&&void 0!==o&&void 0!==u)return{x:t,y:i,width:o,height:u}}function l(e,n){let r=e[n];if(!g(r))return;let t=a(r,"x"),i=a(r,"y");if(void 0!==t&&void 0!==i)return{x:t,y:i}}function a(e,n){let r=e[n];return"number"==typeof r?r:void 0}function c(e){return"string"==typeof e&&e.length>0?e:void 0}function m(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function p(e){return"ios"===e||"macos"===e||"android"===e||"linux"===e?e:void 0}function v(e){return"simulator"===e||"emulator"===e||"device"===e?e:void 0}function D(n){if(!g(n))throw new e("COMMAND_FAILED","Daemon returned an unexpected response shape.",{value:n});return n}function g(e){return"object"==typeof e&&null!==e}function h(e){let n={};for(let[r,t]of Object.entries(e))void 0!==t&&(n[r]=t);return n}function b(e){return e.split("\n").map(e=>e.trim()).filter(e=>e.length>0)}export{D as asRecord,g as isRecord,f as readDeviceTarget,i as readNullableString,t as readOptionalString,l as readPoint,s as readRect,d as readRequiredDeviceKind,o as readRequiredNumber,u as readRequiredPlatform,r as readRequiredString,b as splitNonEmptyTrimmedLines,h as stripUndefined};
|
package/dist/src/8173.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import e from"node:path";import{styleText as t}from"node:util";import{buildMobileSnapshotPresentation as n,CLICK_BUTTONS as r,SCROLL_DIRECTIONS as i,formatSnapshotLine as o,SCROLL_INPUT_DIRECTIONS as a,SWIPE_PRESETS as s,displayNodeLabel as u,SWIPE_PATTERNS as l,buildSnapshotDisplayLines as d}from"./1620.js";import{normalizeError as p,AppError as c}from"./9152.js";import{PERF_AREA_VALUES as f,serializeOpenResult as h,serializeSessionListEntry as m,serializeDeployResult as g,serializeSnapshotResult as $,LOG_ACTION_VALUES as y,serializeCloseResult as x,PERF_ACTION_VALUES as v,serializeInstallFromSourceResult as b,serializeDevice as w}from"./2672.js";import{DEVICE_ROTATIONS as M,readCommandMessage as C}from"./1534.js";import{listMcpExposedCommandNames as S,BATCH_COMMAND_NAMES as k,GESTURE_KINDS as P}from"./5898.js";import{readInputRecord as A,selectorSnapshotFields as I,elementTargetField as N,stringSchema as j,stringArrayField as _,jsonSchemaField as O,booleanSchema as B,integerSchema as F,integerField as R,customField as T,assertAllowedKeys as D,booleanField as L,enumField as H,requiredEnum as K,looseObjectField as E,readPoint as U,requiredField as z,pointField as W,readFieldInput as J,stringField as q,interactionTargetField as G,fieldsInputSchema as V,requiredNumber as X,readCommonInput as Y,repeatedFields as Q,looseObjectSchema as Z,numberField as ee,optionalInteger as et}from"./9974.js";import{NETWORK_INCLUDE_MODES as en}from"./9616.js";import{requireCommandDescription as er,SESSION_SURFACES as ei}from"./2474.js";import{FIND_LOCATORS as eo}from"./7556.js";function ea(e){return e.width>0&&e.height>0}function es(e,t){return!!e&&!!t&&e.x>=t.x-2&&e.y>=t.y-2&&e.x+e.width<=t.x+t.width+2&&e.y+e.height<=t.y+t.height+2}function eu(e){return"number"!=typeof e.parentIndex}function el(e){let t=(e.type??"").toLowerCase(),n=(e.identifier??"").trim().toLowerCase();return t.includes("edittext")||t.includes("textfield")||"composer"===n}function ed(e){let t=(e.type??"").toLowerCase();return t.includes("scroll")||t.includes("list")||t.includes("recyclerview")}function ep(e){var t;let n=u(e);if(!n||n!==e.identifier?.trim()||(t=n,!/^[\w.]+:id\/[\w.-]+$/i.test(t)))return n;let r=(e.type??"").toLowerCase();return r.includes("view")||r.includes("layout")||r.includes("image")||r.includes("list")||r.includes("recyclerview")||r.includes("collection")?"":n}function ec(e){let t=e.trim().replace(/\s+/g," ").toLowerCase();return!t||/^(true|false|\d+)$/.test(t)?null:t}function ef(e,t){let n=[],r=[t];for(;r.length>0;){let t=r.pop();for(let i of e)i.parentIndex===t&&(n.push(i),r.push(i.index))}return n}function eh(e,t,n){let r=[t];for(;r.length>0;){let t=r.pop();if(!n.has(t))for(let i of(n.add(t),e))i.parentIndex!==t||n.has(i.index)||r.push(i.index)}}let em=["button","switch","checkbox","radio"],eg=["button","image","textview","view"];function e$(e){if(!0===e.hittable||el(e))return!1;let t=(e.type??"").toLowerCase();return t.includes("text")||t.includes("image")||t.includes("icon")}function ey(e){if(!e.rect||!ea(e.rect)||eu(e)||el(e))return!1;let t=(e.type??"").toLowerCase();return"text"===t||eb(t,eg)}function ex(e,t){let n=ev(e);return ev(t)>n?t:e}function ev(e){let t=(e.type??"").toLowerCase(),n=0;return eb(t,em)?n+=100:t.includes("image")?n+=30:t.includes("textview")||"text"===t?n+=20:t.includes("view")&&(n+=10),!0===e.hittable&&(n+=20),!1!==e.enabled&&(n+=5),n}function eb(e,t){return t.some(t=>e.includes(t))}function ew(e){process.stdout.write(`${JSON.stringify(e,null,2)}
|
|
2
|
-
`)}function eM(e,t={}){let n=e instanceof c?p(e):e;process.stderr.write(`Error (${n.code}): ${n.message}
|
|
3
|
-
`),n.hint&&process.stderr.write(`Hint: ${n.hint}
|
|
4
|
-
`),n.diagnosticId&&process.stderr.write(`Diagnostic ID: ${n.diagnosticId}
|
|
5
|
-
`),n.logPath&&process.stderr.write(`Diagnostics Log: ${n.logPath}
|
|
6
|
-
`),t.showDetails&&n.details&&process.stderr.write(`${JSON.stringify(n.details,null,2)}
|
|
7
|
-
`)}function eC(e){return e&&e.summaryLines.length>0?`
|
|
8
|
-
${e.summaryLines.join("\n")}`:""}function eS(e){var n;let r=!0===e.baselineInitialized,i=e.summary??{},o=e_(i.additions),a=e_(i.removals),s=e_(i.unchanged),u=eO(),l=eF(e),d=l.length>0?`${l.join("\n")}
|
|
9
|
-
`:"";if(r)return`${d}Baseline initialized (${s} lines).
|
|
10
|
-
`;let p=(function(e){if(0===e.length)return e;let t=e.map((e,t)=>({index:t,kind:e.kind})).filter(e=>"added"===e.kind||"removed"===e.kind).map(e=>e.index);if(0===t.length)return e;let n=Array(e.length).fill(!1);for(let r of t){let t=Math.max(0,r-1),i=Math.min(e.length-1,r+1);for(let e=t;e<=i;e+=1)n[e]=!0}return e.filter((e,t)=>n[t])})(Array.isArray(e.lines)?e.lines:[]).map(e=>{let n="string"==typeof e.text?e.text:"";if("added"===e.kind){let e=n.startsWith(" ")?`+${n}`:`+ ${n}`;return u?t("green",e):e}if("removed"===e.kind){let e=n.startsWith(" ")?`-${n}`:`- ${n}`;return u?t("red",e):e}return u?t("dim",n):n}),c=p.length>0?`${p.join("\n")}
|
|
11
|
-
`:"";if(!u)return`${d}${c}${o} additions, ${a} removals, ${s} unchanged
|
|
12
|
-
`;let f=`${(n=String(o),t("green",n))} additions, ${t("red",String(a))} removals, ${t("dim",String(s))} unchanged`;return`${d}${c}${f}
|
|
13
|
-
`}function ek(e){var n,r,i,o;let a,s,u,l,d=eO(),p=!0===e.match,c=e.dimensionMismatch,f=[];return f.push(...function(e,n){if(!0===e.match){let e=n?function(e,n){return t(n,e)}("✓","green"):"✓";return[`${e} Screenshots match.`]}let r=e.dimensionMismatch,i=n?function(e,n){return t(n,e)}("✗","red"):"✗";if(r){let e=r.expected,t=r.actual;return[`${i} Screenshots have different dimensions: expected ${e?.width}x${e?.height}, got ${t?.width}x${t?.height}`]}let o=e_(e.differentPixels),a=e_(e.mismatchPercentage),s=0===a&&o>0?"<0.01":String(a),u=`${s}% pixels differ`;return[`${i} ${n?function(e,n){return t(n,e)}(u,"red"):u}`]}(e,d)),f.push(...function(e,n,r){if(n)return[];let i=[];if(e.diffPath){let n=ej(e.diffPath),o=r?function(e,n){return t(n,e)}("Diff image:","dim"):"Diff image:",a=r?function(e,n){return t(n,e)}(n,"green"):n;i.push(` ${o} ${a}`)}if(e.currentOverlayPath){let n=ej(e.currentOverlayPath),o=r?function(e,n){return t(n,e)}("Current overlay:","dim"):"Current overlay:",a=r?function(e,n){return t(n,e)}(n,"green"):n,s=e_(e.currentOverlayRefCount),u=s>0?` (${s} refs)`:"";i.push(` ${o} ${a}${u}`)}return i}(e,p,d)),p||c||(f.push(...(n=e,r=d,a=e_(n.differentPixels),s=e_(n.totalPixels),u=r?function(e,n){return t(n,e)}(String(a),"red"):String(a),[` ${u} different / ${s} total pixels`])),f.push(...(i=e,o=d,0===(l=function(e){let t=[];for(let n of(e.ocr?.movementClusters??[]).slice(0,2))t.push(`text movement cluster: ${function(e){let t=e.slice(0,4).map(e=>JSON.stringify(e)),n=e.length>t.length?` +${e.length-t.length} more`:"";return`${t.join(", ")}${n}`}(n.texts)} dx=${eN(n.xRange)}px dy=${eN(n.yRange)}px`);let n=(e.nonTextDeltas??[]).filter(e=>["icon","toggle","chevron"].includes(e.likelyKind)).slice(0,3);n.length>0&&t.push(`non-text controls: ${n.map(eI).join("; ")}`);let r=(e.nonTextDeltas??[]).filter(e=>"separator"===e.likelyKind).slice(0,2);return r.length>0&&t.push(`non-text boundaries: ${r.map(eI).join("; ")}`),t.slice(0,6)}(i)).length?[]:[` ${eB("Hints:",o)}`,...l.map(e=>` - ${e}`)])),f.push(...function(e,t){let n=Array.isArray(e.regions)?e.regions:[];if(0===n.length)return[];let r=[` ${eB("Changed regions:",t)}`];for(let e of n.slice(0,5))r.push(...function(e){let t=0===e.shareOfDiffPercentage&&e.differentPixels>0?"<0.01":String(e.shareOfDiffPercentage),n=e.rect,r=[` ${e.index}. ${e.location} x=${n.x} y=${n.y} ${n.width}x${n.height}, ${t}% of diff, change=${e.dominantChange}`],i=function(e){let t=[e.size?`size=${e.size}`:null,e.shape?`shape=${e.shape}`:null,"number"==typeof e.densityPercentage?`density=${e.densityPercentage}%`:null,e.averageBaselineColorHex&&e.averageCurrentColorHex?`avgColor=${e.averageBaselineColorHex}->${e.averageCurrentColorHex}`:null,"number"==typeof e.baselineLuminance&&"number"==typeof e.currentLuminance?`luminance=${e.baselineLuminance}->${e.currentLuminance}`:null].filter(e=>null!==e);return t.length>0?t.join(" "):null}(e);i&&r.push(` ${i}`);let o=e.currentOverlayMatches?.[0];if(o){let e=o.label?` "${o.label}"`:"";r.push(` overlaps @${o.ref}${e}, ${o.regionCoveragePercentage}% of region`)}return r}(e));return r}(e,d)),f.push(...function(e,t){let n=e.ocr?.matches??[];if(0===n.length)return[];let r=n.slice(0,8),i=[` ${eB(`OCR text deltas (${e.ocr?.provider}; baselineBlocks=${e.ocr?.baselineBlocks} currentBlocks=${e.ocr?.currentBlocks}; showing ${r.length}/${n.length}; px):`,t)}`,` ${eB("item | text | movePx | sizeDeltaPx | bboxBaseline | bboxCurrent | confidence | issueHint",t)}`];for(let[e,t]of r.entries()){let n=t.delta;i.push(` ${e+1} | ${JSON.stringify(t.text)} | ${eA(n.x)},${eA(n.y)} | ${eA(n.width)},${eA(n.height)} | ${eP(t.baselineRect)} | ${eP(t.currentRect)} | ${t.confidence} | ${t.possibleTextMetricMismatch?"ocr-bbox-size-change":"-"}`)}return i}(e,d)),f.push(...function(e,t){let n=e.nonTextDeltas??[];if(0===n.length)return[];let r=n.slice(0,8),i=[` ${eB(`Non-text visual deltas (showing ${r.length}/${n.length}; px):`,t)}`,` ${eB("item | region | slot | kind | bboxCurrent | nearestText",t)}`];for(let e of r)i.push(` ${e.index} | ${e.regionIndex?`r${e.regionIndex}`:"-"} | ${e.slot} | ${e.likelyKind} | ${eP(e.rect)} | ${e.nearestText?JSON.stringify(e.nearestText):"-"}`);return i}(e,d))),`${f.join("\n")}
|
|
14
|
-
`}function eP(e){return`x=${e.x},y=${e.y},w=${e.width},h=${e.height}`}function eA(e){return e>0?`+${e}`:String(e)}function eI(e){let t=e.nearestText?` near ${JSON.stringify(e.nearestText)}`:"",n=e.regionIndex?` r${e.regionIndex}`:"";return`${e.likelyKind}${t}${n}`}function eN(e){return e.min===e.max?eA(e.min):`${eA(e.min)}..${eA(e.max)}`}function ej(t){let n=process.cwd(),r=e.relative(n,t);return""!==r&&(r.startsWith("..")||e.isAbsolute(r))?t:""===r?".":`.${e.sep}${r}`}function e_(e){return"number"==typeof e&&Number.isFinite(e)?e:0}function eO(){let e=process.env.FORCE_COLOR;return"string"==typeof e?"0"!==e:"string"!=typeof process.env.NO_COLOR&&!!process.stdout.isTTY}function eB(e,n){return n?t("dim",e):e}function eF(e){let t=e.warnings;return Array.isArray(t)?t.filter(e=>"string"==typeof e&&e.length>0):[]}function eR(e,t){var n;let r="scroll-area"===(n=e.type)||"list"===n||"collection"===n||"table"===n?n:null;if(!r)return[];let i=[];if(e.node.hiddenContentAbove&&"below"!==t&&i.push(`[content above ${r} hidden]`),e.node.hiddenContentBelow&&"above"!==t&&i.push(`[content below ${r} hidden]`),0===i.length)return[];let o=" ".repeat(e.depth+1);return i.map(e=>`${o}${e}`)}function eT(e){return eL(g(e))}function eD(e){let t=e.ref??"",n=e.x,r=e.y;return t&&"number"==typeof n&&"number"==typeof r?{data:e,text:`Tapped @${t} (${n}, ${r})`}:eL(e)}function eL(e){return{data:e,text:C(e)}}function eH(e){let t=e.kind?` ${e.kind}`:"",n=e.target?` target=${e.target}`:"",r="boolean"==typeof e.booted?` booted=${e.booted}`:"";return`${e.name} (${e.platform}${t}${n})${r}`}function eK(e,t,n){"string"==typeof n&&e.push(` ${t}: ${n}`)}function eE(e,t){return t.map(t=>void 0!==e[t]&&null!==e[t]?`${t}=${e[t]}`:"").filter(Boolean).join(" ")||void 0}function eU(e){if(!Array.isArray(e))return;let t=e.filter(e=>"string"==typeof e&&e.length>0);return t.length>0?t.join("\n"):void 0}function ez(e){return e.filter(e=>!!e).join("\n")||void 0}function eW(e,t){return e?`Performance: ${e}`:`Frame health: unavailable - ${t}`}function eJ(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:void 0}function eq(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function eG(e){return`${Number.isInteger(e)?e:e.toFixed(1)}%`}function eV(e){let t=Math.max(0,Math.round(e));if(t<1e3)return`${t}ms`;let n=Math.round(t/1e3);if(n<60)return`${n}s`;let r=Math.floor(n/60),i=n%60;return i>0?`${r}m ${i}s`:`${r}m`}function eX(e){return({result:t})=>e(t)}let eY=eX(function(e){return eL(e)}),eQ={boot:eX(function(e){let t=e.platform??"unknown",n=e.device??e.id??"unknown";return{data:e,text:`Boot ready: ${n} (${t})`}}),shutdown:eX(function(e){let t=e.platform??"unknown",n=e.device??e.id??"unknown",r=e.shutdown,i=!!r&&"object"==typeof r&&"success"in r&&!0===r.success;return{data:e,text:`${i?"Shutdown":"Shutdown failed"}: ${n} (${t})`}}),click:eX(eD),press:eX(eD),batch:eX(function(e){let t="number"==typeof e.total?e.total:0,n="number"==typeof e.executed?e.executed:0,r="number"==typeof e.totalDurationMs?e.totalDurationMs:void 0,i=[`Batch completed: ${n}/${t} steps${void 0!==r?` in ${r}ms`:""}`];for(let t of Array.isArray(e.results)?e.results:[]){let e=function(e){let t=eJ(e);if(!t)return;let n="number"==typeof t.step?t.step:void 0,r="string"==typeof t.command?t.command:"step",i=!1!==t.ok,o=function(e,t,n){var r;return t?C(eJ(e.data))??n:(r=eJ(e.error),("string"==typeof r?.message&&r.message.length>0?r.message:null)??n)}(t,i,r),a=void 0!==n?`${n}. `:"- ",s="number"==typeof t.durationMs?t.durationMs:void 0,u=void 0!==s?` (${s}ms)`:"";return`${a}${i?"OK":"FAILED"} ${o}${u}`}(t);e&&i.push(e)}return{data:e,text:i.join("\n")}}),devices:eX(function(e){return{data:{devices:e.map(w)},text:e.map(eH).join("\n")}}),apps:({input:e,result:t})=>{var n;return{data:{apps:(n={result:t,appsFilter:e.appsFilter}).result},stderr:"all"===n.appsFilter?"Showing all apps, including system apps.\n":"Showing user-installed apps. Use --all to include system apps.\n",text:n.result.length>0?n.result.join("\n"):"all"===n.appsFilter?"No apps found.":"No user-installed apps found."}},session:eX(function(e){let t={sessions:e.sessions.map(m)};return{data:t,text:JSON.stringify(t,null,2)}}),open:eX(function(e){let t=h(e),n=[C(t)].filter(e=>!!e);return"string"==typeof t.sessionStateDir&&n.push(`Session state: ${t.sessionStateDir}`),{data:t,text:n.join("\n")||null}}),close:eX(function(e){return eL(x(e))}),install:eX(eT),reinstall:eX(eT),"install-from-source":eX(function(e){return eL(b(e))}),snapshot:({input:e,result:t})=>{var r;let i;return{data:i=$((r={result:t,raw:e.raw,interactiveOnly:e.interactiveOnly,scope:e.scope,depth:e.depth}).result),jsonData:function(e){let{unchanged:t,...n}=e;return n}(i),text:function(e,t={}){var r,i,a,s;let l,p,c,f,h,m=e.nodes,g=Array.isArray(m)?m:[],$="string"==typeof e.backend?e.backend:void 0,y=function(e,t,n){let r;if(n.raw||!((r=e.androidSnapshot)&&"object"==typeof r&&"android-helper"===r.backend))return{nodes:t,filteredCount:0};let i=function(e){var t,n;if(0===e.length)return e;let r=new Set,i=new Map,o=new Map(e.map(e=>[e.index,e]));(function(e,t){for(let n of e)!n.rect||ea(n.rect)||eu(n)||eh(e,n.index,t)})(e,r),function(e,t,n,r){for(let i of e){if(n.has(i.index)||i.rect||eu(i))continue;let o=function(e,t,n){let r=e;for(;"number"==typeof r.parentIndex;){let e=t.get(r.parentIndex);if(!e)break;if(n(e))return e;r=e}return null}(i,t,ed);o&&function(e,t,n){if(!n)return;let r=e.get(t.index)??t;e.set(t.index,{...r,hiddenContentAbove:!0===r.hiddenContentAbove||"above"===n||void 0,hiddenContentBelow:!0===r.hiddenContentBelow||"below"===n||void 0})}(r,o,function(e,t){let n=t.filter(t=>t.parentIndex===e.parentIndex&&t.rect&&ea(t.rect)).map(e=>e.index);return 0===n.length?null:e.index<Math.min(...n)?"above":e.index>Math.max(...n)?"below":null}(i,e)),eh(e,i.index,n)}}(e,o,r,i);for(let n of e){if(r.has(n.index)||!(!0===(t=n).hittable&&!el(t)&&t.rect&&ea(t.rect)&&0===ep(t).trim().length))continue;let o=function(e,t,n){let r=[],i=[],o=new Set;for(let a of e){if(n.has(a.index)||!e$(a)||!es(a.rect,t.rect))continue;let e=ep(a).trim().replace(/\s+/g," "),s=ec(e);i.push(a.index),!e||!s||o.has(s)||(o.add(s),r.push(e))}return{label:r.join(", "),removableIndexes:i}}(ef(e,n.index),n,r);if(o.label)for(let t of(i.set(n.index,{...n,...i.get(n.index),label:o.label}),o.removableIndexes))eh(e,t,r)}for(let t of e){if(r.has(t.index)||!(!0===(n=t).hittable&&!el(n)&&n.rect&&ea(n.rect)&&ec(ep(n))))continue;let i=ec(ep(t));if(!i)continue;let o=ef(e,t.index).filter(e=>!r.has(e.index)&&function(e,t,n){if(!ey(t)||!es(t.rect,e.rect))return!1;let r=ec(ep(t));return!!(r&&n!==r&&n.includes(r))}(t,e,i));for(let t of o.filter(e$))eh(e,t.index,r);let a=o.filter(e=>!e$(e)),s=new Set(a.map(e=>ec(ep(e))).filter(e=>!!e));if(!(a.length<2)&&!(s.size<2))for(let t of a)eh(e,t.index,r)}let a=new Map;for(let t of e){if(r.has(t.index)||!ey(t))continue;let n=ec(ep(t));if(!n)continue;let o=a.get(n);if(o&&function(e,t,n){var r,i,o,a;return!n.has(e.index)&&(r=e.rect,i=t.rect,!r||!i||Math.abs(r.y+r.height/2-(i.y+i.height/2))<=Math.max(r.height,i.height,1))&&(o=e,a=t,(o.parentIndex===a.parentIndex?3>=Math.abs(o.index-a.index):o.parentIndex!==a.index&&a.parentIndex!==o.index&&1>=Math.abs((o.depth??0)-(a.depth??0))&&2>=Math.abs(o.index-a.index))||function(e,t){let n=e.parentIndex===t.index?t:t.parentIndex===e.index?e:null,r=n?.index===e.index?t:n?.index===t.index?e:null;return!!n&&!!r&&ex(n,r).index===n.index}(e,t))}(o,t,r)){let s=function(e,t,n,r,i){var o,a,s;let u=ex(t,n),l=u.index===t.index?n:t,d=(l.type??"").toLowerCase().includes("image")?"has image":null,p=i.get(u.index)??u,c=i.get(l.index)?.presentationHints??l.presentationHints;return i.set(u.index,{...p,presentationHints:(o=p.presentationHints,a=c,s=d,[...new Set([...Array.isArray(o)?o:[],...Array.isArray(a)?a:[],...s?[s]:[]])])}),eh(e,l.index,r),i.get(u.index)??u}(e,o,t,r,i);a.set(n,s);continue}a.set(n,t)}return e.filter(e=>!r.has(e.index)).map(e=>i.get(e.index)??e)}(t);return{nodes:i,filteredCount:t.length-i.length}}(e,g,t),x=(l="string"==typeof(r=e).appName?r.appName:void 0,p="string"==typeof r.appBundleId?r.appBundleId:void 0,c=[],l&&c.push(`Page: ${l}`),p&&c.push(`App: ${p}`),c.length>0?`${c.join("\n")}
|
|
15
|
-
`:""),v=function(e,t,n,r={nodes:t,filteredCount:0}){let i=eF(e),o=function(e,t){if(!0===t.scoped||!0===t.depthLimited||e.length>3)return null;let n=1===e.length?"node":"nodes";return`Hint: sparse accessibility snapshot returned ${e.length} ${n}; snapshot state is invalid or unavailable for this screen. Use plain screenshot, not screenshot --overlay-refs, as visual truth. If screenshot shows the Home Screen or another app, run open for this app again first. Then navigate away with coordinates if needed and retry snapshot -i on the next screen.`}(t,n);o&&i.push(o),!n.raw&&r.filteredCount>0&&i.push(`Collapsed ${r.filteredCount} Android helper node${1===r.filteredCount?"":"s"} from the agent-facing text snapshot; use --raw or --json for the full hierarchy.`);let a=r.filteredCount>0?r.nodes:t;return!n.raw&&function(e){if(e.length<20)return!1;let t=new Map;for(let n of e){let e=(n.type??"").toLowerCase(),r=function(e){var t;let n=e.trim().replace(/\s+/g," ").toLowerCase();return!n||(t=n,/\S+@\S+\.\S+/.test(t))?null:n}(u(n));if(!r)continue;let i=`${e}|${r}`,o=t.get(i)??[];o.push(n),t.set(i,o)}let n=0;for(let e of t.values())!(e.length<=1)&&function(e){for(let r=0;r<e.length;r+=1)for(let i=r+1;i<e.length;i+=1){var t,n;if(t=e[r]?.rect,n=e[i]?.rect,!t||!n||!(t.x+t.width<=n.x+.5||n.x+n.width<=t.x+.5||t.y+t.height<=n.y+.5||n.y+n.height<=t.y+.5))return!0}return!1}(e)&&(n+=e.length);return n>=8}(a)&&i.push("Warning: possible repeated nav subtree detected."),i}(e,g,t,y),b=v.length>0?`${v.join("\n")}
|
|
16
|
-
`:"",w=t.raw?null:(f=e.unchanged)&&"object"==typeof f?"number"!=typeof f.ageMs||"number"!=typeof f.nodeCount?null:{ageMs:f.ageMs,nodeCount:f.nodeCount,interactiveOnly:!0===f.interactiveOnly||void 0,scope:"string"==typeof f.scope?f.scope:void 0}:null;if(w){let e;return`${x}${b}${e=function(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(Math.round(e/100)/10).toFixed(1)}s`;let t=e/6e4;return t<60?`${(Math.round(10*t)/10).toFixed(1)}m`:`${(Math.round(t/60*10)/10).toFixed(1)}h`}((i=w).ageMs),i.scope?`Scoped snapshot unchanged for scope "${i.scope}" since previous read ${e} ago.
|
|
17
|
-
Previous refs in this scope remain valid. Use find/get/is for a targeted query, or --force-full to re-emit.`:i.interactiveOnly?`Interactive snapshot unchanged since previous read ${e} ago.
|
|
18
|
-
${i.nodeCount} visible nodes are unchanged. Previous @e refs are still valid. Use find/get/is for a targeted query, or --force-full to re-emit.`:`Snapshot unchanged since previous read ${e} ago.
|
|
19
|
-
Refs from the previous snapshot are still valid. Use --force-full to re-emit the tree, or use find/get/is for a targeted query.`}
|
|
20
|
-
`}let M=t.raw||"macos-helper"===$?null:n(y.nodes),C=!!e.truncated,S=M?.nodes??g,k=t.raw||"macos-helper"===$?null:function(e,t,n,r,i=0){let o,a=(o=e.visibility)&&"object"==typeof o&&"boolean"==typeof o.partial&&"number"==typeof o.visibleNodeCount&&"number"==typeof o.totalNodeCount&&Array.isArray(o.reasons)?{partial:o.partial,visibleNodeCount:o.visibleNodeCount,totalNodeCount:o.totalNodeCount,reasons:o.reasons.filter(e=>"string"==typeof e)}:null;if(0===i&&a)return a;let s=(t?.hiddenCount??0)+i,u=!!t&&t.nodes.some(e=>e.hiddenContentAbove||e.hiddenContentBelow);return s>0?{partial:!0,visibleNodeCount:n,totalNodeCount:Math.max(r,a?.totalNodeCount??r),reasons:[...new Set([...a?.reasons??[],"offscreen-nodes"])]}:a||(u?{partial:!0,visibleNodeCount:n,totalNodeCount:n,reasons:[]}:null)}(e,M,S.length,g.length,y.filteredCount),P=(a=g.length,s=k,h=C?" (truncated)":"",s?.partial?s.totalNodeCount>s.visibleNodeCount?`Snapshot: ${s.visibleNodeCount} visible nodes (${s.totalNodeCount} total)${h}`:`Snapshot: ${s.visibleNodeCount} visible nodes${h}`:`Snapshot: ${a} nodes${h}`);return 0===g.length?`${x}${P}
|
|
21
|
-
${b}`:t.raw?`${x}${P}
|
|
22
|
-
${b}${g.map(e=>JSON.stringify(e)).join("\n")}
|
|
23
|
-
`:t.flatten?`${x}${P}
|
|
24
|
-
${b}${d(S,{summarizeTextSurfaces:!0}).flatMap(e=>[o(e.node,0,!1,e.type,{summarizeTextSurfaces:!0}),...eR({...e,depth:0})]).join("\n")}${eC(M)}
|
|
25
|
-
`:`${x}${P}
|
|
26
|
-
${b}${(function(e){let t=[],n=[],r=new Map(e.map(e=>[e.node.index,e.node])),i=e=>{for(var i,o,a;n.length>0&&(!e||(i=e,o=n[n.length-1],a=r,!function(e,t,n){let r=e;for(;"number"==typeof r.parentIndex;){if(r.parentIndex===t.index)return!0;let e=n.get(r.parentIndex);if(!e)break;r=e}return!1}(i.node,o.node,a)&&i.depth<=o.depth));)t.push(...eR(n.pop(),"below"))};for(let r of e)i(r),t.push(r.text),t.push(...eR(r,"above")),r.node.hiddenContentBelow&&n.push(r);return i(),t})(d(S,{summarizeTextSurfaces:!0})).join("\n")}${eC(M)}
|
|
27
|
-
`}(i,{raw:r.raw,flatten:r.interactiveOnly,scoped:"string"==typeof r.scope&&r.scope.trim().length>0,depthLimited:"number"==typeof r.depth})}},wait:eY,alert:eY,appstate:eX(function(e){return{data:e,text:function(e){if("ios"===e.platform){let t=[`Foreground app: ${e.appName??e.appBundleId??"unknown"}`];return e.appBundleId&&t.push(`Bundle: ${e.appBundleId}`),e.source&&t.push(`Source: ${e.source}`),t.join("\n")}if("android"===e.platform){let t=[`Foreground app: ${e.package??"unknown"}`];return e.activity&&t.push(`Activity: ${e.activity}`),t.join("\n")}return null}(e)}}),back:eY,home:eY,rotate:eY,"app-switcher":eY,keyboard:eX(function(e){if("android"===e.platform&&"status"===e.action){var t;let n=[`Keyboard visible: ${!0===e.visible?"yes":"no"}`,`Input type: ${e.type??e.inputType??"unknown"}`,`Input owner: ${e.inputOwner??"unknown"}`];return e.inputMethodPackage&&n.push(`Input method: ${e.inputMethodPackage}`),e.focusedPackage&&n.push(`Focused package: ${e.focusedPackage}`),e.focusedResourceId&&n.push(`Focused resource: ${e.focusedResourceId}`),n.push(`Next action: ${(t=e.visible,"ime"===e.inputOwner?"Focused input appears to be owned by the keyboard/IME; dismiss or change the IME before retrying text entry.":!0===t?"Keyboard is visible and focused input appears app-owned; fill/type can proceed.":"Keyboard is hidden; focus an app field before type, or use fill with a concrete target.")}`),{data:e,text:n.join("\n")}}return eL(e)}),clipboard:eX(function(e){return"read"===e.action?{data:e,text:e.text}:eL(e)}),get:({input:e,result:t})=>{var n;let r;return r=(n={result:t,format:e.format}).result,"text"===n.format?{data:r,text:"string"==typeof r.text?r.text:""}:"attrs"===n.format?{data:r,text:JSON.stringify(r.node??{},null,2)}:eL(r)},is:eX(function(e){return{data:e,text:`Passed: is ${e.predicate??"assertion"}`}}),find:eX(function(e){return"string"==typeof e.text?{data:e,text:e.text}:"boolean"==typeof e.found?{data:e,text:`Found: ${e.found}`}:e.node?{data:e,text:JSON.stringify(e.node,null,2)}:eL(e)}),perf:eX(function(e){return{data:e,text:function(e){var t,n,r;let i,o=eJ(e.metrics),a=eJ(o?.fps),s=(t=o,(i=[function(e){if(e?.available!==!0)return;let t=eq(e.usagePercent);return void 0!==t?`CPU ${eG(t)}`:void 0}(eJ(t?.cpu)),function(e){let t;if(e?.available!==!0)return;let n=eq(e.residentMemoryKb)??eq(e.totalPssKb)??eq(e.totalRssKb);return void 0!==n?`memory ${t=n/1024,`${t>=10?Math.round(t):t.toFixed(1)}MB`}`:void 0}(eJ(t?.memory))].filter(e=>!!e)).length>0?i.join(", "):void 0);if(!a)return eW(s,"missing frame metric");if(!1===a.available){return eW(s,"string"==typeof(n=a).reason&&n.reason.length>0?n.reason:"not available")}let u=function(e){let t=eq(e.droppedFramePercent),n=eq(e.droppedFrameCount);if(void 0!==t&&void 0!==n){var r,i,o;return[`dropped ${eG(t)}`,(r=n,void 0!==(i=eq(e.totalFrameCount))?`(${Math.round(r)}/${Math.round(i)} frames)`:`(${Math.round(r)} dropped frames)`),void 0!==(o=eq(e.sampleWindowMs))?`window ${eV(o)}`:""].filter(Boolean).join(" ")}}(a);if(!u)return eW(s,"missing dropped-frame summary");let l=[`Frame health: ${u}`],d=(Array.isArray(r=a.worstWindows)?r.filter(e=>!!e&&"object"==typeof e&&!Array.isArray(e)):[]).flatMap(e=>{let t=function(e){let t=eq(e.startOffsetMs),n=eq(e.endOffsetMs),r=eq(e.missedDeadlineFrameCount);if(void 0===t||void 0===n||void 0===r)return;let i=eq(e.worstFrameMs),o=void 0===i?"":`, worst ${eV(i)}`;return`- +${eV(t)}-+${eV(n)}: ${Math.round(r)} missed-deadline frames${o}`}(e);return t?[t]:[]});return d.length>0&&l.push("Worst windows:",...d),l.join("\n")}(e)}}),prepare:eY,logs:eX(function(e){var t;return{data:e,text:"string"==typeof e.path?e.path:"",stderr:ez([eE(e,["active","state","backend","sizeBytes"]),(t=e,["started","stopped","marked","cleared","restarted","removedRotatedFiles"].map(e=>{var n,r;return n=e,!0===(r=t[e])?`${n}=true`:"number"==typeof r?`${n}=${r}`:""}).filter(Boolean).join(" ")||void 0),"string"==typeof e.hint?e.hint:void 0,eU(e.notes)])}}),network:eX(function(e){let t=[],n="string"==typeof e.path?e.path:"";n&&t.push(n);let r=Array.isArray(e.entries)?e.entries:[];if(0===r.length)t.push("No recent HTTP(s) entries found.");else for(let e of r)t.push(...function(e){let t=eJ(e)??{},n="string"==typeof t.method?t.method:"HTTP",r="string"==typeof t.url?t.url:"<unknown-url>",i="number"==typeof t.status?` status=${t.status}`:"",o="string"==typeof t.timestamp?`${t.timestamp} `:"",a="number"==typeof t.durationMs?` durationMs=${t.durationMs}`:"",s=[`${o}${n} ${r}${i}${a}`];return eK(s,"headers",t.headers),eK(s,"request",t.requestBody),eK(s,"response",t.responseBody),s}(e));return{data:e,text:t.join("\n"),stderr:ez([eE(e,["active","state","backend","include","scannedLines","matchedLines"]),eU(e.notes)])}}),record:eX(function(e){let t,n="string"==typeof e.outPath?e.outPath:"",r=Array.isArray(t=e.chunks)?t.flatMap(e=>e&&"object"==typeof e?"number"!=typeof e.index||"string"!=typeof e.path?[]:[{index:e.index,path:e.path}]:[]):[];if(r.length<=1){var i,o;let t;return{data:e,text:(i=e,t=[],(o=n)&&t.push(o),"string"==typeof i.sessionStateDir&&t.push(`Session state: ${i.sessionStateDir}`),"string"==typeof i.warning&&t.push(`Warning: ${i.warning}`),"string"==typeof i.overlayWarning&&t.push(`Overlay warning: ${i.overlayWarning}`),t.join("\n"))}}let a=["Recording chunks:"];for(let e of r)a.push(` ${e.index}: ${e.path}`);return"string"==typeof e.telemetryPath&&a.push(`Telemetry: ${e.telemetryPath}`),"string"==typeof e.warning&&a.push(`Warning: ${e.warning}`),"string"==typeof e.overlayWarning&&a.push(`Overlay warning: ${e.overlayWarning}`),{data:e,text:a.join("\n")}}),metro:({input:e,result:t})=>{var n;return{data:(n={result:t,action:e.action}).result,text:"reload"===n.action?`Reloaded React Native apps via ${n.result.reloadUrl}`:JSON.stringify(n.result,null,2)}}};function eZ(e){return eQ[e.name]?.({input:e.input??{},result:e.result})}function e0(e,t){return{...e,run:t,invoke:async(n,r)=>await t(n,e.readInput(r))}}function e1(e=k){var t;let n={steps:z(T({type:"array",description:"Structured batch steps. Each step uses a command name and the same input object as that command tool.",items:{type:"object",properties:{command:{type:"string",enum:t=e,description:"Command name to run with structured input."},input:{type:"object",additionalProperties:!0,description:"Structured command input for the nested command. Use the matching MCP tool schema for this object."},runtime:{type:"object",additionalProperties:!0,description:"Optional per-step runtime payload."}},required:["command","input"],additionalProperties:!1}},(e,n)=>(function(e,t){if(!Array.isArray(e))throw Error("Expected steps to be an array.");return e.map((e,n)=>{var r,i,o;let a;return r=e,i=n+1,o=t,D(a=function(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw Error(`Invalid batch step ${t}.`);return e}(r,i),["command","input","runtime"],`Batch step ${i}`),{command:K(a,"command",o),input:function(e,t){let n=e.input;if(!n||"object"!=typeof n||Array.isArray(n))throw Error(`Batch step ${t} input must be an object.`);return n}(a,i),...function(e,t){let n=e.runtime;if(void 0!==n&&(!n||"object"!=typeof n||Array.isArray(n)))throw Error(`Batch step ${t} runtime must be an object.`);return void 0===n?{}:{runtime:n}}(a,i)}})})(e[n],t))),onError:H(["stop"],"Batch failure policy."),maxSteps:R("Maximum number of steps accepted for this batch.",{min:1,max:1e3}),out:q("Optional output path for command artifacts.")};return{name:"batch",description:"Run multiple structured command steps in one daemon request.",inputSchema:V(n),readInput:e=>(function(e,t){let n=J(e,t),r=n.maxSteps??100;if(!Number.isInteger(r)||r<1||r>1e3)throw Error(`Invalid batch maxSteps: ${String(n.maxSteps)}`);if(n.steps.length>r)throw Error(`batch has ${n.steps.length} steps; max allowed is ${r}.`);return{...n}})(e,n)}}function e2(e,t,n){return{name:e,description:t,inputSchema:V(n),readInput:e=>J(e,n)}}let e6=["duration","text","ref","selector"],e5=["start","stop"],e3=[e4("devices",{}),e4("boot",{headless:L("Boot without showing simulator UI when supported.")}),e4("shutdown",{}),e4("prepare",{action:z(H(["ios-runner"])),timeoutMs:R("Maximum wall-clock time for the prepare command.")}),e4("apps",{appsFilter:H(["user-installed","all"])}),e4("session",{action:H(["list"])}),e4("open",{app:q("App name, bundle id, package, or URL."),url:q("Optional URL passed with an app shell."),surface:H(ei),activity:q("Android activity name."),launchConsole:q("Launch console mode."),launchArgs:_("Launch arguments forwarded verbatim to the platform launch command."),relaunch:L("Force relaunch."),saveScript:O({oneOf:[B(),j()]}),noDeviceHub:L("Skip Xcode Device Hub and use the standalone Simulator app when surfacing Apple simulators."),noRecord:L("Do not record this action.")}),e4("close",{app:q("Optional app to close."),shutdown:L("Shutdown the session/device where supported."),saveScript:O({oneOf:[B(),j()]})}),e4("install",{app:z(q()),appPath:z(q("Path to app binary."))}),e4("reinstall",{app:z(q()),appPath:z(q("Path to app binary."))}),e4("install-from-source",{source:z(O(Z("Install source object."))),retainPaths:L(),retentionMs:R()}),e4("push",{app:z(q()),payload:z(O({oneOf:[j(),Z()]}))}),e4("trigger-app-event",{event:z(q()),payload:E()}),e4("snapshot",{interactiveOnly:L(),compact:L(),depth:R(),scope:q(),raw:L(),forceFull:L(),timeoutMs:R("Maximum wall-clock time for the snapshot command.")}),e4("screenshot",{path:q("Output path."),overlayRefs:L(),fullscreen:L(),maxSize:R(),stabilize:L(),surface:H(ei)}),e4("diff",{kind:z(O({type:"string",const:"snapshot"})),out:q(),interactiveOnly:L(),compact:L(),depth:R(),scope:q(),raw:L()}),e4("wait",{kind:H(e6),durationMs:R(),text:q(),ref:q(),selector:q(),timeoutMs:R(),depth:R(),scope:q(),raw:L()}),e4("alert",{action:H(["get","accept","dismiss","wait"]),timeoutMs:R()}),e4("appstate",{}),e4("back",{mode:H(["in-app","system"])}),e4("home",{}),e4("rotate",{orientation:z(H(M))}),e4("app-switcher",{}),e4("keyboard",{action:H(["status","dismiss"])}),e4("clipboard",{action:z(H(["read","write"])),text:q()}),e4("react-native",{action:z(H(["dismiss-overlay"]))}),e4("replay",{path:z(q()),update:L(),backend:q(),maestro:L(),env:_()}),e4("test",{paths:z(_()),update:L(),backend:q(),maestro:L(),env:_(),failFast:L(),timeoutMs:R(),retries:R(),recordVideo:L(),artifactsDir:q(),reportJunit:q(),shardAll:R(),shardSplit:R()}),e4("perf",{area:H(f),action:H(v)}),e4("logs",{action:H(y),message:q(),restart:L()}),e4("network",{action:H(["dump","log"]),limit:R(),include:H(en)}),e4("record",{action:z(H(e5)),path:q(),fps:R(),quality:O(F()),hideTouches:L()}),e4("trace",{action:z(H(e5)),path:q()}),e4("settings",{setting:z(q()),state:z(q()),app:q(),latitude:ee(),longitude:ee(),permission:q(),mode:H(["full","limited"])}),e4("metro",{action:z(H(["prepare","reload"])),projectRoot:q(),kind:O(j()),publicBaseUrl:q(),proxyBaseUrl:q(),bearerToken:q(),bridgeScope:O({type:"object",additionalProperties:!0}),launchUrl:q(),port:R(),listenHost:q(),statusHost:q(),startupTimeoutMs:R(),probeTimeoutMs:R(),reuseExisting:L(),installDependenciesIfNeeded:L(),runtimeFilePath:q(),logPath:q(),metroHost:q(),metroPort:R(),bundleUrl:q(),timeoutMs:R()})];function e4(e,t){return e2(e,er(e),t)}let e8={target:z(G()),button:H(r,"Pointer button for platforms that support mouse buttons."),...I(),...Q()},e9={target:z(G()),...I(),...Q()},e7={target:z(G()),text:z(q("Text to enter into the target.")),delayMs:R("Delay between typed characters.",{min:0}),...I()},te={target:z(G()),durationMs:R("Long press duration in milliseconds.",{min:0}),...I()},tt={from:z(W("Swipe start point.")),to:z(W("Swipe end point.")),durationMs:R("Swipe duration in milliseconds.",{min:0}),count:R("Number of swipe repetitions.",{min:1}),pauseMs:R("Pause between repeated swipes.",{min:0}),pattern:H(l)},tn={x:z(ee("X coordinate.")),y:z(ee("Y coordinate."))},tr={text:z(q("Text to type.")),delayMs:R("Delay between typed characters.",{min:0})},ti={direction:z(H(a)),amount:ee("Platform scroll amount."),pixels:R("Pixel scroll amount.",{min:0})},to={format:z(H(["text","attrs"])),target:z(N()),...I()},ta={predicate:z(H(["visible","hidden","exists","editable","selected","text"])),selector:z(q()),value:q(),...I()},ts={locator:H(eo),query:z(q()),action:H(["click","focus","exists","getText","getAttrs","wait","fill","type"]),value:q(),timeoutMs:R(),first:L(),last:L(),depth:R(),raw:L()},tu={kind:z(H(P,"Gesture variant.")),direction:H(i,"Fling direction."),preset:H(s,"Swipe preset."),origin:W("Gesture origin point."),delta:W("Movement delta for pan or transform gestures."),distance:R("Fling distance.",{min:0}),scale:ee("Pinch or transform scale."),degrees:ee("Rotation in degrees."),velocity:R("Rotate gesture velocity.",{min:0}),durationMs:R("Gesture duration in milliseconds.",{min:0})},tl=[{name:"click",description:er("click"),inputSchema:V(e8),readInput:e=>J(e,e8)},{name:"press",description:er("press"),inputSchema:V(e9),readInput:e=>J(e,e9)},{name:"fill",description:er("fill"),inputSchema:V(e7),readInput:e=>J(e,e7)},td("longpress",te),td("swipe",tt),td("focus",tn),td("type",tr),td("scroll",ti),td("get",to),td("is",ta),td("find",ts),{name:"gesture",description:er("gesture"),inputSchema:V(tu),readInput:function(e){let t=A(e),n=Y(t),r=K(t,"kind",P);return"pan"===r?{...n,kind:r,origin:U(t,"origin"),delta:U(t,"delta"),durationMs:et(t,"durationMs",{min:0})}:"fling"===r?{...n,kind:r,direction:K(t,"direction",i),origin:U(t,"origin"),distance:et(t,"distance",{min:0}),durationMs:et(t,"durationMs",{min:0})}:"swipe"===r?{...n,kind:r,preset:K(t,"preset",s),durationMs:et(t,"durationMs",{min:0})}:"pinch"===r?{...n,kind:r,scale:X(t,"scale"),origin:tp(t,"origin")}:"rotate"===r?{...n,kind:r,degrees:X(t,"degrees"),origin:tp(t,"origin"),velocity:et(t,"velocity",{min:0})}:{...n,kind:r,origin:U(t,"origin"),delta:U(t,"delta"),scale:X(t,"scale"),degrees:X(t,"degrees"),durationMs:et(t,"durationMs",{min:0})}}}];function td(e,t){return e2(e,er(e),t)}function tp(e,t){return void 0===e[t]?void 0:U(e,t)}let tc=new Map([...tl,...e3,e1(k)].map(e=>[e.name,e]));function tf(){return S().map(e=>{var t;if(!th(e))throw Error(`Missing command metadata for MCP-exposed command: ${e}`);return t=e,tc.get(t)})}function th(e){return tc.has(e)}export{e6 as WAIT_KIND_VALUES,e3 as clientCommandMetadata,e1 as createBatchCommandMetadata,e0 as defineExecutableCommand,eZ as formatCliOutput,ek as formatScreenshotDiffText,eS as formatSnapshotDiffText,tl as interactionCommandMetadata,th as isCommandName,tf as listMcpCommandMetadata,eM as printHumanError,ew as printJson};
|
package/dist/src/8407.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AppError as e}from"./9152.js";let t=new Set(["id","role","text","label","value","appname","windowtitle"]),n=new Set(["visible","hidden","editable","selected","enabled","hittable"]),r=new Set([...t,...n]),l=new Map([['"','"'],["'","'"],["\\","\\"],["/","/"],["b","\b"],["f","\f"],["n","\n"],["r","\r"],["t"," "]]);function i(t){let n=t.trim();if(!n)throw new e("INVALID_ARGS","Selector expression cannot be empty");let r=function(t){let n=[],r="",l=null;for(let i=0;i<t.length;i+=1){let o=t[i];if(('"'===o||"'"===o)&&!h(t,i)){l=a(l,o),r+=o;continue}if(!l&&"|"===o&&"|"===t[i+1]){let l=r.trim();if(!l)throw new e("INVALID_ARGS",`Invalid selector fallback expression: ${t}`);n.push(l),r="",i+=1;continue}r+=o}let i=r.trim();if(!i)throw new e("INVALID_ARGS",`Invalid selector fallback expression: ${t}`);return n.push(i),n}(n);if(0===r.length)throw new e("INVALID_ARGS","Selector expression cannot be empty");return{raw:n,selectors:r.map(t=>(function(t){let n=t.trim();if(!n)throw new e("INVALID_ARGS","Selector segment cannot be empty");let r=function(t){let n=[],r="",l=null;for(let e=0;e<t.length;e+=1){let i=t.charAt(e);if(('"'===i||"'"===i)&&!h(t,e)){l=a(l,i),r+=i;continue}if(!l&&/\s/.test(i)){r.trim()&&n.push(r.trim()),r="";continue}r+=i}if(l)throw new e("INVALID_ARGS",`Unclosed quote in selector: ${t}`);return r.trim()&&n.push(r.trim()),n}(n);if(0===r.length)throw new e("INVALID_ARGS",`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(f)}})(t))}}function o(e){try{return i(e)}catch{return null}}function u(e){let t=e.trim();if(!t)return!1;if("||"===t)return!0;let n=t.indexOf("=");if(-1!==n){let e=t.slice(0,n).trim().toLowerCase();return r.has(e)}return r.has(t.toLowerCase())}function s(e,t={}){if(0===e.length)return null;let n=t.preferTrailingValue??!1,r=0,l=[];for(;r<e.length;){let t=e[r];if(void 0===t||!u(t))break;r+=1;let n=e.slice(0,r).join(" ").trim();n&&o(n)&&l.push(r)}if(0===l.length)return null;let i=l.at(-1);if(void 0===i)return null;let f=i;if(n)for(let t=l.length-1;t>=0;t-=1){let n=l[t];if(void 0!==n&&n<e.length){f=n;break}}let a=e.slice(0,f).join(" ").trim();return a?{selectorExpression:a,rest:e.slice(f)}:null}function f(t){let l=t.trim();if(!l)throw new e("INVALID_ARGS","Empty selector term");let i=l.indexOf("=");if(-1===i){let r=l.toLowerCase();if(!n.has(r))throw new e("INVALID_ARGS",`Invalid selector term "${t}", expected key=value`);return{key:r,value:!0}}let o=l.slice(0,i).trim().toLowerCase(),u=l.slice(i+1).trim();if(!r.has(o))throw new e("INVALID_ARGS",`Unknown selector key: ${o}`);if(!u)throw new e("INVALID_ARGS",`Missing selector value for key: ${o}`);if(n.has(o)){let t,n="true"===(t=c(u).toLowerCase())||"false"!==t&&null;if(null===n)throw new e("INVALID_ARGS",`Invalid boolean value for ${o}: ${u}`);return{key:o,value:n}}return{key:o,value:c(u)}}function a(e,t){return e?e===t?null:e:t}function c(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?function(e){let t="",n=0;for(;n<e.length;){var r;let i=e.charAt(n);if("\\"!==i){t+=i,n+=1;continue}let o=e.charAt(n+1);if(!o){t+=i,n+=1;continue}let u=(r=o,l.get(r)??null);if(null!==u){t+=u,n+=2;continue}if("u"===o){let r=e.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(Number.parseInt(r,16)),n+=6;continue}}t+=i,n+=1}return t}(t.slice(1,-1)):t}function h(e,t){let n=0;for(let r=t-1;r>=0&&"\\"===e[r];r-=1)n+=1;return n%2==1}export{u as isSelectorToken,i as parseSelectorChain,s as splitSelectorFromArgs,o as tryParseSelectorChain};
|
package/dist/src/8699.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{screenshotFlagsFromOptions as e,screenshotOptionsFromFlags as t}from"./695.js";import{AppError as r}from"./9152.js";import{readRequiredString as i,readRequiredPlatform as n,readRequiredDeviceKind as o,readNullableString as a,readDeviceTarget as s,readRect as u,asRecord as l,stripUndefined as c,isRecord as d,readRequiredNumber as p,readPoint as f,readOptionalString as m}from"./7455.js";import{buildAppIdentifiers as h,isPerfAction as g,PERF_AREA_ERROR_MESSAGE as v,LOG_ACTION_VALUES as w,PERF_ACTION_ERROR_MESSAGE as y,buildDeviceIdentifiers as S,isPerfArea as A}from"./2672.js";import{splitSelectorFromArgs as b,tryParseSelectorChain as I}from"./8407.js";import{compactRecord as _}from"./9974.js";import{INTERNAL_COMMANDS as N,parseStringMember as M,PUBLIC_COMMANDS as x,BATCH_COMMAND_NAMES as R}from"./5898.js";import{readLocationCoordinate as D}from"./9673.js";import{parseWaitPositionals as k}from"./2284.js";import{readInteractionTargetFromPositionals as L,readFillTargetFromPositionals as V}from"./3393.js";import{NETWORK_INCLUDE_MODES as G}from"./9616.js";import{parseDeviceRotation as q}from"./1534.js";import{assertResolvedAppsFilter as C}from"./3675.js";function P(e,t){let r=m(e,"bundleId"),o=m(e,"package");return{app:i(e,"app"),appPath:i(e,"appPath"),platform:n(e,"platform"),appId:r??o,bundleId:r,package:o,identifiers:h({session:t,bundleId:r,packageName:o})}}function E(e,t){let i=m(e,"bundleId"),n=m(e,"packageName"),o=i??n??m(e,"appId"),a=m(e,"launchTarget")??n??i??o;if(!a)throw new r("COMMAND_FAILED",'Daemon response is missing "launchTarget".',{response:e});return{appName:m(e,"appName"),appId:o,bundleId:i,packageName:n,launchTarget:a,installablePath:m(e,"installablePath"),archivePath:m(e,"archivePath"),materializationId:m(e,"materializationId"),materializationExpiresAt:m(e,"materializationExpiresAt"),identifiers:h({session:t,bundleId:i,packageName:n,appId:o})}}function U(e){return{released:!0===e.released,materializationId:i(e,"materializationId"),identifiers:{}}}function $(e){let{record:t,platform:r,id:i,name:n,target:a}=K(e,"name");return{platform:r,target:a,kind:o(t,"kind"),id:i,name:n,booted:"boolean"==typeof t.booted?t.booted:void 0,identifiers:S(r,i,n),...j(r,i)}}function F(e){let{record:t,platform:r,id:n,name:o,target:s}=K(e,"name"),u=i(t,"device"),l={session:o,...S(r,n,u)};return{name:o,createdAt:p(t,"createdAt"),sessionStateDir:m(t,"sessionStateDir"),runnerLogPath:m(t,"runnerLogPath"),device:{platform:r,target:s,id:n,name:u,identifiers:l,...j(r,n,a(t,"ios_simulator_device_set"))},identifiers:l}}function K(e,t){let r=l(e);return{record:r,platform:n(r,"platform"),id:i(r,"id"),name:i(r,t),target:s(r,"target")}}function j(e,t,r){return{ios:"ios"===e?{udid:t,...void 0!==r?{simulatorSetPath:r}:{}}:void 0,android:"android"===e?{serial:t}:void 0}}function O(e){if(!d(e))return;let t=e.platform,r=m(e,"metroHost"),i="number"==typeof e.metroPort?e.metroPort:void 0;return{platform:"ios"===t||"android"===t?t:void 0,metroHost:r,metroPort:i,bundleUrl:m(e,"bundleUrl"),launchUrl:m(e,"launchUrl")}}function T(e){let t=e.platform,r=m(e,"id"),i=m(e,"device");if("ios"!==t&&"macos"!==t&&"android"!==t&&"linux"!==t||!r||!i)return;let n=s(e,"target"),o=S(t,r,i);return{platform:t,target:n,id:r,name:i,identifiers:o,ios:"ios"===t?{udid:m(e,"device_udid")??r,simulatorSetPath:a(e,"ios_simulator_device_set")}:void 0,android:"android"===t?{serial:m(e,"serial")??r}:void 0}}function z(e){if(d(e)&&"number"==typeof e.durationMs&&"string"==typeof e.measuredAt&&"string"==typeof e.method)return{durationMs:e.durationMs,measuredAt:e.measuredAt,method:e.method,appTarget:m(e,"appTarget"),appBundleId:m(e,"appBundleId")}}function H(e){return Array.isArray(e)?e:[]}function B(e){let t=e.overlayRefs;if(!Array.isArray(t))return;let r=[];for(let e of t){if(!d(e))continue;let t=m(e,"ref"),i=u(e,"rect"),n=u(e,"overlayRect"),o=f(e,"center");t&&i&&n&&o&&r.push({ref:t,label:m(e,"label"),rect:i,overlayRect:n,center:o})}return r}function J(t){return c({stateDir:t.stateDir,daemonBaseUrl:t.daemonBaseUrl,daemonAuthToken:t.daemonAuthToken,daemonTransport:t.daemonTransport,daemonServerMode:t.daemonServerMode,tenant:t.tenant,sessionIsolation:t.sessionIsolation,runId:t.runId,leaseId:t.leaseId,leaseBackend:t.leaseBackend,platform:t.platform,target:t.target,device:t.device,udid:t.udid,serial:t.serial,iosSimulatorDeviceSet:t.iosSimulatorDeviceSet,androidDeviceAllowlist:t.androidDeviceAllowlist,surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,shutdown:t.shutdown,saveScript:t.saveScript,noDeviceHub:t.noDeviceHub,noRecord:t.noRecord,backMode:t.backMode,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,launchUrl:t.launchUrl,snapshotInteractiveOnly:t.interactiveOnly,snapshotCompact:t.compact,snapshotDepth:t.depth,snapshotScope:t.scope,snapshotRaw:t.raw,snapshotForceFull:t.forceFull,...e(t),appsFilter:t.appsFilter,out:t.out,count:t.count,fps:t.fps,quality:t.quality,hideTouches:t.hideTouches,intervalMs:t.intervalMs,delayMs:t.delayMs,holdMs:t.holdMs,jitterPx:t.jitterPx,pixels:t.pixels,doubleTap:t.doubleTap,clickButton:t.clickButton,pauseMs:t.pauseMs,pattern:t.pattern,headless:t.headless,restart:t.restart,replayUpdate:t.replayUpdate,replayBackend:t.replayBackend,replayEnv:t.replayEnv,replayShellEnv:t.replayShellEnv,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,recordVideo:t.recordVideo,artifactsDir:t.artifactsDir,reportJunit:t.reportJunit,shardAll:t.shardAll,shardSplit:t.shardSplit,findFirst:t.findFirst,findLast:t.findLast,networkInclude:t.networkInclude,batchOnError:t.batchOnError,batchMaxSteps:t.batchMaxSteps,batchSteps:t.batchSteps,verbose:t.debug})}function W(e){return c({requestId:e.requestId,cwd:e.cwd,sessionExplicit:void 0!==e.session,debug:e.debug,lockPolicy:e.lockPolicy,lockPlatform:e.lockPlatform,tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId,leaseBackend:e.leaseBackend,leaseTtlMs:e.leaseTtlMs,sessionIsolation:e.sessionIsolation,installSource:e.installSource,retainMaterializedPaths:e.retainMaterializedPaths,materializedPathRetentionMs:e.materializedPathRetentionMs,materializationId:e.materializationId})}function Q(e){return e??"default"}function X(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new r("INVALID_ARGS",`${t} installSource must be an object.`);if("github-actions-artifact"!==ee(e.type,`${t} installSource.type`))throw new r("INVALID_ARGS",`${t} installSource.type must be "github-actions-artifact".`);let{owner:i,repo:n}=Z(ee(e.repo,`${t} installSource.repo`),`${t} installSource.repo`);return Y(i,n,e.artifact,`${t} installSource.artifact`)}function Y(e,t,i,n){var o;return"number"==typeof i||"string"==typeof(o=i)&&/^\d+$/.test(o.trim())?{kind:"github-actions-artifact",owner:e,repo:t,artifactId:function(e,t){let i="number"==typeof e?e:"string"==typeof e?Number(e):NaN;if(!Number.isInteger(i))throw new r("INVALID_ARGS",`${t} must be an integer.`);return i}(i,n)}:{kind:"github-actions-artifact",owner:e,repo:t,artifactName:ee(i,n)}}function Z(e,t){let i=e.indexOf("/");if(i<=0||i===e.length-1||-1!==e.indexOf("/",i+1))throw new r("INVALID_ARGS",`${t} must use owner/repo.`);let n={owner:e.slice(0,i).trim(),repo:e.slice(i+1).trim()};if(!n.owner||!n.repo)throw new r("INVALID_ARGS",`${t} must use owner/repo.`);return n}function ee(e,t){let i="string"==typeof e&&e.trim().length>0?e.trim():void 0;if(!i)throw new r("INVALID_ARGS",`${t} must be a non-empty string.`);return i}function et(e,t){return r=>er(e,t?t(r):[],r)}function er(e,t,r){return{command:e,positionals:t,options:function(e){var t;let r="mobile"===(t=e.deviceTarget??e.target)||"tv"===t||"desktop"===t?t:void 0;if(void 0===r&&void 0===e.target)return e;let{target:i,...n}=e;return void 0===r?n:{...n,target:r}}(r)}}function ei(e){return _({session:e.session,platform:e.platform,deviceTarget:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist})}function en(e){return{platform:e.platform,target:e.target,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist}}function eo(e){return _({depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw})}function ea(e){return{depth:e.snapshotDepth,scope:e.snapshotScope,raw:e.snapshotRaw}}function es(e){return _({count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap})}function eu(e){return"ref"in e&&void 0!==e.ref?_({kind:"ref",ref:e.ref,label:e.label}):"selector"in e&&void 0!==e.selector?{kind:"selector",selector:e.selector}:{kind:"point",x:e.x,y:e.y}}function el(e){let t=ec(e);if("string"==typeof t.ref)return[t.ref,...ep(t.label)];if("string"==typeof t.selector)return[t.selector];if("point"===t.kind||void 0!==t.x||void 0!==t.y)return[String(ed(t.x,"x")),String(ed(t.y,"y"))];throw new r("INVALID_ARGS","interaction requires @ref, selector, or point target")}function ec(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new r("INVALID_ARGS","Expected target object.");let t=e.target;return t&&"object"==typeof t&&!Array.isArray(t)?t:e}function ed(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new r("INVALID_ARGS",`point target requires numeric ${t}.`);return e}function ep(e){return"string"==typeof e&&e.length>0?[e]:[]}function ef(...e){return new Set(e)}function em(e,t){return void 0!==e&&t.has(e)}function eh(e){return void 0!==e&&""!==e.trim()&&Number.isFinite(Number(e))}function eg(e){return void 0===e?void 0:Number(e)}function ev(e){return void 0===e?[]:[e]}function ew(e){return void 0===e?[]:[String(e)]}function ey(e,t){if(void 0===e||""===e)throw new r("INVALID_ARGS",t);return e}function eS(e,t){if("string"!=typeof e||0===e.length)throw new r("INVALID_ARGS",t);return e}let eA={devices:(e,t)=>ei(t),apps:(e,t)=>({...ei(t),appsFilter:C(t.appsFilter)}),session:(e,t)=>({...ei(t),action:function(e){let t=e??"list";if("list"===t||"state-dir"===t)return t;throw new r("INVALID_ARGS","session only supports list or state-dir")}(e[0])}),boot:(e,t)=>({...ei(t),headless:t.headless}),shutdown:(e,t)=>ei(t),prepare:(e,t)=>({...ei(t),action:ey(e[0],"prepare requires subcommand"),timeoutMs:t.timeoutMs}),open:(e,t)=>({...ei(t),app:e[0],url:e[1],surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,saveScript:t.saveScript,noDeviceHub:t.noDeviceHub,noRecord:t.noRecord}),close:(e,t)=>({...ei(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript}),install:eI,reinstall:eI,"install-from-source":(e,t)=>({...ei(t),source:function(e,t){let i=e[0]?.trim();if(e.length>1)throw new r("INVALID_ARGS","install-from-source accepts either one <url> positional or --github-actions-artifact");let n=t.githubActionsArtifact?function(e,t="--github-actions-artifact"){let i=e.indexOf(":");if(i<=0||i===e.length-1)throw new r("INVALID_ARGS",`${t} must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232`);let{owner:n,repo:o}=Z(e.slice(0,i),t);return Y(n,o,e.slice(i+1),`${t} artifact`)}(t.githubActionsArtifact):void 0,o=t.installSource;if(1!=+!!i+ +!!n+ +!!o)throw new r("INVALID_ARGS","install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource");if(!i&&t.header&&t.header.length>0)throw new r("INVALID_ARGS","install-from-source --header is only supported for URL sources");return n||o||{kind:"url",url:i,headers:function(e){if(!e||0===e.length)return;let t={};for(let i of e){let e=i.indexOf(":");if(e<=0)throw new r("INVALID_ARGS",`Invalid --header value "${i}". Expected "name:value".`);let n=i.slice(0,e).trim(),o=i.slice(e+1).trim();if(!n)throw new r("INVALID_ARGS",`Invalid --header value "${i}". Header name cannot be empty.`);t[n]=o}return t}(t.header)}}(e,t),retainPaths:t.retainPaths,retentionMs:t.retentionMs}),push:(e,t)=>({...ei(t),app:ey(e[0],"push requires bundleOrPackage"),payload:ey(e[1],"push requires payloadOrJson")}),"trigger-app-event":(e,t)=>({...ei(t),event:ey(e[0],"trigger-app-event requires event"),payload:e[1]?function(e,t){try{let t=JSON.parse(e);if(t&&"object"==typeof t&&!Array.isArray(t))return t}catch{}throw new r("INVALID_ARGS",`${t} must be a JSON object`)}(e[1],"trigger-app-event payload"):void 0})},eb={devices:et(x.devices),boot:et(x.boot),shutdown:et(x.shutdown),prepare:et(x.prepare,e=>[eS(e.action,"prepare requires subcommand")]),apps:et(x.apps),open:et(x.open,function(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}),close:et(x.close,e=>ev(e.app)),install:et(x.install,e=>e_(e.app,e.appPath)),reinstall:et(x.reinstall,e=>e_(e.app,e.appPath)),"install-from-source":e=>er(N.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),push:et(x.push,e=>{var t;return[(t=e).app,"string"==typeof t.payload?t.payload:JSON.stringify(t.payload)]}),"trigger-app-event":et(x.triggerAppEvent,e=>{var t;return[(t=e).event,...t.payload?[JSON.stringify(t.payload)]:[]]})};function eI(e,t,r="install"){return{...ei(t),app:ey(e[0],`${r} requires app`),appPath:ey(e[1],`${r} requires path`)}}function e_(e,t){return[eS(e,"missing first positional"),eS(t,"missing second positional")]}let eN={snapshot:(e,t)=>({...ei(t),interactiveOnly:t.snapshotInteractiveOnly,compact:t.snapshotCompact,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw,forceFull:t.snapshotForceFull,timeoutMs:t.timeoutMs}),screenshot:(e,r)=>({...ei(r),path:e[0]??r.out,...t(r)}),diff:(e,t)=>{if("snapshot"!==e[0])throw new r("INVALID_ARGS","Only diff snapshot is available through this parser.");return{...ei(t),kind:"snapshot",out:t.out,interactiveOnly:t.snapshotInteractiveOnly,compact:t.snapshotCompact,depth:t.snapshotDepth,scope:t.snapshotScope,raw:t.snapshotRaw}},wait:(e,t)=>(function(e,t){let i=k(e);if(!i)throw new r("INVALID_ARGS","wait requires <ms>, text <text>, @ref, or <selector> [timeoutMs].");let n={...en(t),...ea(t)};if("sleep"===i.kind)return{...n,durationMs:i.durationMs};if("text"===i.kind){if(!i.text)throw new r("INVALID_ARGS","wait requires text.");return{...n,text:i.text,...ex(i.timeoutMs)}}return"ref"===i.kind?{...n,ref:i.rawRef,...ex(i.timeoutMs)}:{...n,selector:i.selectorExpression,...ex(i.timeoutMs)}})(e,t),alert:(e,t)=>({...ei(t),...function(e){if(e.length>2)throw new r("INVALID_ARGS","alert accepts at most action and timeout arguments.");return _({action:function(e){let t=e?.toLowerCase();if(void 0===t||"get"===t||"accept"===t||"dismiss"===t||"wait"===t)return t;throw new r("INVALID_ARGS","alert action must be get, accept, dismiss, or wait.")}(e[0]),timeoutMs:function(e,t){if(void 0===e)return;let i=Number(e);if(Number.isFinite(i))return i;throw new r("INVALID_ARGS",`${t} must be a finite number.`)}(e[1],"alert timeout")})}(e)}),settings:(e,t)=>(function(e,t){let i=en(t),n=e[0],o=e[1];if(em(n,eR)&&em(o,eD))return{...i,setting:n,state:o};if("location"===n&&"set"===o)return{...i,setting:n,state:o,latitude:D(e[2],"latitude"),longitude:D(e[3],"longitude")};if("appearance"===n&&em(o,ek)||em(n,eL)&&em(o,eV)||"fingerprint"===n&&em(o,eG))return{...i,setting:n,state:o};if("permission"===n&&em(o,eq))return{...i,setting:n,state:o,permission:function(e){if(em(e,eC))return e;throw new r("INVALID_ARGS","settings permission requires a permission target.")}(e[2]),mode:function(e){if(void 0===e||"full"===e||"limited"===e)return e;throw new r("INVALID_ARGS","settings permission mode must be full or limited.")}(e[3])};if("clear-app-state"===n){let t="clear"===o?e[2]:o;return{...i,setting:n,state:"clear",app:t}}throw new r("INVALID_ARGS","Invalid settings arguments.")})(e,t)},eM={snapshot:et(x.snapshot),screenshot:t=>er(x.screenshot,ev(t.path),{...t,...e(t)}),diff:et(x.diff,e=>[eS(e.kind,"diff requires kind")]),wait:et(x.wait,e=>(function(e){if(1!==[void 0!==e.durationMs?"durationMs":void 0,void 0!==e.text?"text":void 0,void 0!==e.ref?"ref":void 0,void 0!==e.selector?"selector":void 0].filter(Boolean).length)throw new r("INVALID_ARGS","wait command requires exactly one of durationMs, text, ref, or selector.");if(void 0!==e.durationMs)return[String(e.durationMs)];let t=ew(e.timeoutMs);if(void 0!==e.text)return["text",e.text,...t];if(void 0!==e.ref)return[e.ref,...t];let i=e.selector;if(!I(i))throw new r("INVALID_ARGS",`Invalid wait selector: ${i}`);return[i,...t]})(e)),alert:et(x.alert,e=>{var t;return[(t=e).action??"get",...ew(t.timeoutMs)]}),settings:et(x.settings,e=>{var t;return"clear-app-state"===(t=e).setting?[t.setting,...ev(t.app)]:"location"===t.setting&&"set"===t.state?[t.setting,t.state,String(t.latitude),String(t.longitude)]:"permission"===t.setting?[t.setting,t.state,t.permission,...ev(t.mode)]:[t.setting,t.state]})};function ex(e){return null===e?{}:{timeoutMs:e}}let eR=ef("wifi","airplane","location","animations"),eD=ef("on","off"),ek=ef("light","dark","toggle"),eL=ef("faceid","touchid"),eV=ef("match","nonmatch","enroll","unenroll"),eG=ef("match","nonmatch"),eq=ef("grant","deny","reset"),eC=ef("camera","microphone","photos","contacts","contacts-limited","notifications","calendar","location","location-always","media-library","motion","reminders","siri","accessibility","screen-recording","input-monitoring"),eP={gesture:function(e,t){let i=e[0],n=e.slice(1),o=ei(t);switch(i){case"pan":return{...o,kind:i,origin:{x:Number(n[0]),y:Number(n[1])},delta:{x:Number(n[2]),y:Number(n[3])},durationMs:eg(n[4])};case"fling":return{...o,kind:i,direction:n[0],origin:{x:Number(n[1]),y:Number(n[2])},distance:eg(n[3]),durationMs:eg(n[4])};case"swipe":return{...o,kind:i,preset:n[0],durationMs:eg(n[1])};case"pinch":return{...o,kind:i,scale:Number(n[0]),origin:void 0===n[1]||void 0===n[2]?void 0:{x:Number(n[1]),y:Number(n[2])}};case"rotate":return{...o,kind:i,degrees:Number(n[0]),origin:void 0===n[1]||void 0===n[2]?void 0:{x:Number(n[1]),y:Number(n[2])},velocity:eg(n[3])};case"transform":return{...o,kind:i,origin:{x:Number(n[0]),y:Number(n[1])},delta:{x:Number(n[2]),y:Number(n[3])},scale:Number(n[4]),degrees:Number(n[5]),durationMs:eg(n[6])};default:throw new r("INVALID_ARGS","gesture requires pan, fling, swipe, pinch, rotate, or transform")}}},eE={gesture:et(x.gesture,function(e){switch(e.kind){case"pan":return["pan",String(e.origin?.x),String(e.origin?.y),String(e.delta?.x),String(e.delta?.y),...ew(e.durationMs)];case"fling":return["fling",eS(e.direction,"gesture fling requires direction"),String(e.origin?.x),String(e.origin?.y),...ew(e.distance),...ew(e.durationMs)];case"swipe":return eU(e);case"pinch":return["pinch",String(e.scale),...ew(e.origin?.x),...ew(e.origin?.y)];case"rotate":return["rotate",String(e.degrees),...ew(e.origin?.x),...ew(e.origin?.y),...ew(e.velocity)];case"transform":return["transform",String(e.origin?.x),String(e.origin?.y),String(e.delta?.x),String(e.delta?.y),String(e.scale),String(e.degrees),...ew(e.durationMs)];default:throw new r("INVALID_ARGS","gesture requires pan, fling, swipe, pinch, rotate, or transform")}}),"gesture-pan":et(x.gesture,function(e){return["pan",String(e.x),String(e.y),String(e.dx),String(e.dy),...ew(e.durationMs)]}),"gesture-fling":et(x.gesture,e=>{var t;let r;return r=void 0!==(t=e).durationMs?t.distance??180:t.distance,["fling",t.direction,String(t.x),String(t.y),...ew(r),...ew(t.durationMs)]}),"gesture-swipe":et(x.gesture,eU),"gesture-pinch":et(x.gesture,function(e){return["pinch",String(e.scale),...ew(e.x),...ew(e.y)]}),"gesture-rotate":et(x.gesture,e=>(function(e){var t=e;if(void 0===t.x&&void 0!==t.y||void 0!==t.x&&void 0===t.y)throw new r("INVALID_ARGS","gesture rotate center requires both x and y");let i=void 0===e.x||void 0===e.y?[]:[String(e.x),String(e.y)];return["rotate",String(e.degrees),...i,...ew(e.velocity)]})(e)),"gesture-transform":et(x.gesture,function(e){return["transform",String(e.x),String(e.y),String(e.dx),String(e.dy),String(e.scale),String(e.degrees),...ew(e.durationMs)]})};function eU(e){return["swipe",eS(e.preset,"gesture swipe requires preset"),...ew(e.durationMs)]}let e$={click:(e,t)=>({...ei(t),...eo(t),...es(t),target:eu(L(e)),button:t.clickButton}),press:(e,t)=>({...ei(t),...eo(t),...es(t),target:eu(L(e))}),longpress:(e,t)=>{let r,i={...L((r=function(e){if(eh(e[0])&&eh(e[1]))return{target:e.slice(0,2),...void 0!==e[2]?{durationMs:Number(e[2])}:{}};let t=e.at(-1);return e.length>1&&eh(t)?{target:e.slice(0,-1),durationMs:Number(t)}:{target:e}}(e)).target),...void 0!==r.durationMs?{durationMs:r.durationMs}:{}};return{...ei(t),...eo(t),target:eu(i),durationMs:i.durationMs}},swipe:(e,t)=>({...ei(t),from:{x:Number(e[0]),y:Number(e[1])},to:{x:Number(e[2]),y:Number(e[3])},durationMs:eg(e[4]),count:t.count,pauseMs:t.pauseMs,pattern:t.pattern}),focus:(e,t)=>({...ei(t),x:Number(e[0]),y:Number(e[1])}),type:(e,t)=>({...ei(t),text:e.join(" "),delayMs:t.delayMs}),fill:(e,t)=>{let r=V(e);return{...ei(t),...eo(t),target:eu(r.target),text:r.text,delayMs:t.delayMs}},scroll:(e,t)=>({...ei(t),direction:function(e){if("up"===e||"down"===e||"left"===e||"right"===e||"top"===e||"bottom"===e)return e;throw new r("INVALID_ARGS",`Unknown direction: ${String(e)}`)}(e[0]),amount:eg(e[1]),pixels:t.pixels}),get:(e,t)=>({...ei(t),...eo(t),format:function(e){if("text"===e||"attrs"===e)return e;throw new r("INVALID_ARGS","get only supports text or attrs")}(e[0]),target:eu(function(e){if(e[0]?.startsWith("@"))return{ref:e[0],label:e.slice(1).join(" ").trim()||void 0};let t=e.join(" ").trim();if(!t)throw new r("INVALID_ARGS","get requires @ref or selector expression");return{selector:t}}(e.slice(1)))})},eF={click:e=>er(x.click,el(e),{...e,clickButton:e.button}),press:et(x.press,e=>el(e)),longpress:et(x.longPress,e=>{var t;return[...el(t=e),...ew(t.durationMs)]}),swipe:et(x.swipe,function(e){return[String(e.from?.x),String(e.from?.y),String(e.to?.x),String(e.to?.y),...ew(e.durationMs)]}),focus:et(x.focus,e=>[String(e.x),String(e.y)]),type:et(x.type,e=>[e.text]),fill:et(x.fill,e=>{var t;return[...el(t=e),t.text]}),scroll:et(x.scroll,e=>[eS(e.direction,"scroll requires direction"),...ew(e.amount)]),get:et(x.get,e=>[eS(e.format,"get requires format"),...function(e){let t=ec(e);if("string"==typeof t.ref)return[t.ref,...ep(t.label)];if("string"==typeof t.selector)return[t.selector];throw new r("INVALID_ARGS","element command requires @ref or selector target")}(e)])},eK={perf:(e,t)=>({...ei(t),...function(e){if(void 0!==e[0]&&void 0===e[1]){let t=ez(e[0],{allowUndefined:!0});if(t)return{action:t}}return{area:function(e){if(void 0===e)return;let t=e.toLowerCase();if(A(t))return t;throw new r("INVALID_ARGS",v)}(e[0]),action:ez(e[1])}}(e)}),logs:(e,t)=>({...ei(t),action:function(e){if(void 0!==e)return M(w,e,{message:"logs requires path, start, stop, doctor, mark, or clear"})}(e[0]),message:e.slice(1).join(" ")||void 0,restart:t.restart}),network:(e,t)=>({...ei(t),action:function(e){if(void 0!==e){if("dump"===e||"log"===e)return e;throw new r("INVALID_ARGS","network requires dump or log")}}(e[0]),limit:eg(e[1]),include:t.networkInclude??function(e){if(void 0!==e)return M(G,e,{message:"network include mode must be summary, headers, body, or all"})}(e[2])}),record:(e,t)=>({...ei(t),action:eT(e[0],"record"),path:e[1],fps:t.fps,quality:t.quality,hideTouches:t.hideTouches}),trace:(e,t)=>({...ei(t),action:eT(e[0],"trace"),path:e[1]})},ej={perf:et(x.perf,e=>{var t;return[...ev((t=e).area??(t.action?"metrics":void 0)),...ev(t.action)]}),logs:et(x.logs,e=>{var t;return[(t=e).action??"path",...ev(t.message)]}),network:e=>{var t;return er(x.network,[...(t=e).action?[t.action]:[],...ew(t.limit)],{...e,networkInclude:e.include})},record:et(x.record,e=>eO(e)),trace:et(x.trace,e=>eO(e))};function eO(e){return[e.action,...ev(e.path)]}function eT(e,t){if("start"===e||"stop"===e)return e;throw new r("INVALID_ARGS",`${t} requires start|stop`)}function ez(e,t={}){if(void 0===e)return;let i=e.toLowerCase();if(g(i))return i;if(!t.allowUndefined)throw new r("INVALID_ARGS",y)}let eH={replay:(e,t)=>({...ei(t),path:ey(e[0],"replay requires path"),update:t.replayUpdate,backend:t.replayMaestro?"maestro":void 0,env:t.replayEnv}),test:(e,t)=>({...ei(t),paths:e,update:t.replayUpdate,backend:t.replayMaestro?"maestro":void 0,env:t.replayEnv,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,recordVideo:t.recordVideo,artifactsDir:t.artifactsDir,reportJunit:t.reportJunit,shardAll:t.shardAll,shardSplit:t.shardSplit})};function eB(e){return e.backend??(!0===e.maestro?"maestro":void 0)}function eJ(e){let t={};for(let[r,i]of Object.entries(e))"string"==typeof i&&r.startsWith("AD_VAR_")&&(t[r]=i);return t}let eW={find:(e,t)=>(function(e,t){var i;let n={...{depth:(i=t).snapshotDepth,raw:i.snapshotRaw},...en(t),first:t.findFirst,last:t.findLast},o=function(e){if("text"===e||"label"===e||"value"===e||"role"===e||"id"===e)return e}(e[0]),a=void 0!==o,s=a?e[1]:e[0],u=a?2:1,l=e[u];if(void 0===l)return{...n,locator:o,query:eX(s)};if("get"===l){let t=e[u+1];if("text"===t)return{...n,locator:o,query:eX(s),action:"getText"};if("attrs"===t)return{...n,locator:o,query:eX(s),action:"getAttrs"};throw new r("INVALID_ARGS","find get only supports text or attrs")}if("wait"===l)return{...n,locator:o,query:eX(s),action:"wait",timeoutMs:eg(e[u+1])};if("fill"===l||"type"===l)return{...n,locator:o,query:eX(s),action:l,value:e.slice(u+1).join(" ")};if("click"===l||"focus"===l||"exists"===l)return{...n,locator:o,query:eX(s),action:l};throw new r("INVALID_ARGS",`Unsupported find action: ${l}`)})(e,t),is:(e,t)=>(function(e,t){let i={...ea(t),...en(t)},n=e[0],o=function(e,t={}){let i=b(e,t);if(!i)throw new r("INVALID_ARGS","is requires a selector expression");return i}(e.slice(1),{preferTrailingValue:"text"===n});if("text"===n)return{...i,predicate:n,selector:o.selectorExpression,value:o.rest.join(" ")};if("visible"===n||"hidden"===n||"exists"===n||"editable"===n||"selected"===n)return{...i,predicate:n,selector:o.selectorExpression};throw new r("INVALID_ARGS","is requires predicate: visible|hidden|exists|editable|selected|text")})(e,t)},eQ={is:et(x.is,e=>{var t;return[(t=e).predicate,t.selector,..."text"===t.predicate?[t.value]:[]]}),find:e=>er(x.find,function(e){let t=e.locator&&"any"!==e.locator?[e.locator,e.query]:[e.query];switch(e.action){case void 0:case"click":case"focus":case"exists":return e.action?[...t,e.action]:t;case"getText":return[...t,"get","text"];case"getAttrs":return[...t,"get","attrs"];case"wait":return[...t,"wait",...ew(e.timeoutMs)];case"fill":case"type":return[...t,e.action,e.value]}}(e),{...e,findFirst:e.first,findLast:e.last})};function eX(e){if(void 0===e||""===e)throw new r("INVALID_ARGS","find requires query");return e}let eY={appstate:(e,t)=>ei(t),home:(e,t)=>ei(t),"app-switcher":(e,t)=>ei(t),back:(e,t)=>({...ei(t),mode:t.backMode}),rotate:(e,t)=>({...ei(t),orientation:q(e[0])}),keyboard:(e,t)=>({...ei(t),...function(e){if(e.length>1)throw new r("INVALID_ARGS","keyboard accepts at most one action argument.");return _({action:function(e){let t=e?.toLowerCase();if("get"===t)return"status";if(void 0===t||"status"===t||"dismiss"===t||"enter"===t||"return"===t)return t;throw new r("INVALID_ARGS","keyboard action must be status, get, dismiss, enter, or return.")}(e[0])})}(e)}),clipboard:(e,t)=>({...ei(t),...function(e){let t=e[0]?.toLowerCase();if("read"!==t&&"write"!==t)throw new r("INVALID_ARGS","clipboard requires a subcommand: read or write.");if("read"===t){if(1!==e.length)throw new r("INVALID_ARGS","clipboard read does not accept additional arguments.");return{action:t}}if(e.length<2)throw new r("INVALID_ARGS","clipboard write requires text.");return{action:t,text:e.slice(1).join(" ")}}(e)}),"react-native":(e,t)=>({...ei(t),action:function(e){if("dismiss-overlay"===e)return e;throw new r("INVALID_ARGS","react-native supports only: dismiss-overlay")}(e[0])})},eZ={appstate:et(x.appState),back:e=>{var t;return er(x.back,[],{...e,backMode:"in-app"===(t=e.mode)||"system"===t?t:void 0})},home:et(x.home),rotate:et(x.rotate,e=>[eS(e.orientation,"rotate requires orientation")]),"app-switcher":et(x.appSwitcher),keyboard:et(x.keyboard,e=>ev(e.action)),clipboard:et(x.clipboard,e=>{var t;return"read"===(t=e).action?["read"]:["write",t.text]}),"react-native":et(x.reactNative,e=>[eS(e.action,"react-native requires action")])},e0={...eb,...eM,...eF,...eE,...eQ,...ej,replay:e=>er(x.replay,[eS(e.path,"replay requires path")],{...e,replayUpdate:e.update,replayBackend:eB(e),replayEnv:e.env,replayShellEnv:eJ(process.env)}),test:e=>er(x.test,e.paths??[],{...e,replayUpdate:e.update,replayBackend:eB(e),replayEnv:e.env,replayShellEnv:eJ(process.env)}),...eZ,batch:e=>er(x.batch,[],{...e,batchSteps:function(e){if(!Array.isArray(e)||0===e.length)throw new r("INVALID_ARGS","batch requires a non-empty steps array.");return e.map((e,t)=>{var i;let n,o,a,s,u,l;return a=function(e,t){let i="string"==typeof e.command?e.command.trim().toLowerCase():"";if(e2.has(i))return i;throw new r("INVALID_ARGS",`Batch step ${t} command is not available through command batch: ${String(e.command)}`)}(o=function(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new r("INVALID_ARGS",`Invalid batch step ${t}.`);return e}(e,i=t+1),i),s=function(e,t){let i=e.input;if(!i||"object"!=typeof i||Array.isArray(i))throw new r("INVALID_ARGS",`Batch step ${t} input must be an object.`);return i}(o,i),u=function(e,t){let i=e.runtime;if(void 0!==i&&(!i||"object"!=typeof i||Array.isArray(i)))throw new r("INVALID_ARGS",`Batch step ${t} runtime must be an object.`);return i}(o,i),{...l={command:(n=e3(a,s)).command,positionals:n.positionals,flags:J(n.options),runtime:n.options.runtime},runtime:u??l.runtime}})}(e.steps),batchOnError:e.onError,batchMaxSteps:e.maxSteps})},e1=R,e2=new Set(e1);function e3(e,t){return e0[e](t)}export{eA as appCliReaders,e1 as batchCommandNames,J as buildFlags,W as buildMeta,eN as captureCliReaders,ei as commonInputFromFlags,eP as gestureCliReaders,e$ as interactionCliReaders,P as normalizeDeployResult,$ as normalizeDevice,E as normalizeInstallFromSourceResult,U as normalizeMaterializationReleaseResult,T as normalizeOpenDevice,O as normalizeRuntimeHints,F as normalizeSession,z as normalizeStartupSample,eK as observabilityCliReaders,X as parseInstallSourceConfig,e3 as prepareDaemonCommandRequest,B as readScreenshotOverlayRefs,H as readSnapshotNodes,eH as replayCliReaders,Q as resolveSessionName,eW as selectorCliReaders,eY as systemCliReaders};
|
package/dist/src/9673.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./3675.js";import{AppError as t}from"./9152.js";function e(e,i){if(void 0===e||""===e.trim())throw new t("INVALID_ARGS",`settings location set requires ${i}`);return o(Number(e),i)}function i(t){return{latitude:o(t?.latitude,"latitude"),longitude:o(t?.longitude,"longitude")}}function o(e,i){let o="latitude"===i?-90:-180,r="latitude"===i?90:180;if("number"!=typeof e||!Number.isFinite(e)||e<o||e>r)throw new t("INVALID_ARGS",`${i} must be a number from ${o} to ${r}`);return e}export{e as readLocationCoordinate,i as requireLocationCoordinates};
|
package/dist/src/9974.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{PLATFORM_SELECTORS as e,DEVICE_TARGETS as t}from"./1644.js";import"./2672.js";let r=["ref","selector","point"];function i(e){return{type:"string",...e?{description:e}:{}}}function n(e){return{type:"integer",...e?{description:e}:{}}}function o(e){return{type:"boolean",...e?{description:e}:{}}}function s(e){return{type:"object",additionalProperties:!0,...e?{description:e}:{}}}function a(e){return{...e,required:!0}}function d(e){return K(i(e),k)}function c(e){return K({type:"number",...e?{description:e}:{}},$)}function l(e,t={}){var r,i;return K((r=e,i=t,{...n(r),...void 0===i.min?{}:{minimum:i.min},...void 0===i.max?{}:{maximum:i.max}}),(e,r)=>F(e,r,t))}function u(e){return K(o(e),D)}function p(e,t){return K({type:"string",enum:e,...t?{description:t}:{}},(t,r)=>P(t,r,e))}function f(e){return K(s(e),H)}function m(e){return K({type:"array",items:{type:"string"},...e?{description:e}:{}},L)}function b(e){return K(e,(e,t)=>e[t])}function g(e,t){return K(e,t)}function y(){return K({oneOf:[...z(),{type:"object",properties:{kind:{type:"string",const:"point"},x:{type:"number"},y:{type:"number"}},required:["kind","x","y"],additionalProperties:!1}],description:"UI target. This is separate from deviceTarget, which selects the device form."},(e,t)=>void 0===e[t]?void 0:function(e,t){let i=W(e,t),n=U(i,"kind",r);switch(n){case"ref":return{kind:n,ref:T(i,"ref"),label:k(i,"label")};case"selector":return{kind:n,selector:T(i,"selector")};case"point":return{kind:n,x:O(i,"x"),y:O(i,"y")}}}(e,t))}function h(){return K({oneOf:z(),description:"UI element target by snapshot ref or selector expression."},(e,t)=>{let r,i;return void 0===e[t]?void 0:"ref"===(i=U(r=W(e,t),"kind",["ref","selector"]))?{kind:i,ref:T(r,"ref"),label:k(r,"label")}:{kind:i,selector:T(r,"selector")}})}function v(e){return K({type:"object",description:e,properties:{x:{type:"number"},y:{type:"number"}},required:["x","y"],additionalProperties:!1},(e,t)=>void 0===e[t]?void 0:I(e,t))}function w(){return{depth:l("Snapshot traversal depth.",{min:0}),scope:d("Snapshot scope selector used before resolution."),raw:u("Use raw snapshot data during selector resolution.")}}function E(){return{count:l("Number of press/click repetitions.",{min:1}),intervalMs:l("Delay between repeated press/click actions.",{min:0}),holdMs:l("Hold duration for each action.",{min:0}),jitterPx:l("Randomization radius in pixels.",{min:0}),doubleTap:u("Request a double-tap action.")}}function x(r){return function(r,i=[]){return{type:"object",properties:{session:{type:"string",description:"Agent-device session name."},platform:{type:"string",enum:e,description:"Platform selector used to resolve a device."},deviceTarget:{type:"string",enum:t,description:"Device target form. Maps to the CLI --target flag."},target:{type:"string",enum:t,description:"Alias for deviceTarget on commands without a UI target field. Interaction commands reserve target for the UI element."},device:{type:"string",description:"Device name selector."},udid:{type:"string",description:"iOS device UDID selector."},serial:{type:"string",description:"Android serial selector."},iosSimulatorDeviceSet:{type:"string",description:"iOS simulator device-set path used for device resolution."},androidDeviceAllowlist:{type:"string",description:"Android serial allowlist used for device resolution."},daemonBaseUrl:{type:"string",description:"Remote daemon base URL."},daemonAuthToken:{type:"string",description:"Remote daemon auth token."},tenant:{type:"string",description:"Remote tenant identifier."},runId:{type:"string",description:"Lease run identifier."},leaseId:{type:"string",description:"Existing lease identifier."},cwd:{type:"string",description:"Working directory for command execution."},debug:{type:"boolean",description:"Enable debug diagnostics."},...r},...i.length>0?{required:i}:{},additionalProperties:!1}}(Object.fromEntries(Object.entries(r).map(([e,t])=>[e,t.schema])),Object.entries(r).flatMap(([e,t])=>t.required?[e]:[]))}function j(e,t){let r=A(e),i=Object.fromEntries(Object.entries(t).flatMap(([e,t])=>{let i=t.read(r,e);if(t.required&&void 0===i)throw Error(`Expected ${e} to be set.`);return void 0===i?[]:[[e,i]]})),n=S(r,{readTargetAlias:!Object.hasOwn(t,"target")});return B({...n,...q(n),...i})}function A(e){if(null==e)return{};if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Expected object arguments.");return e}function S(r,i={}){return{session:k(r,"session"),platform:P(r,"platform",e),deviceTarget:function(e,r){let i=P(e,"deviceTarget",t);if(!1===r.readTargetAlias||void 0===e.target)return i;let n=P(e,"target",t);if(void 0!==i&&n!==i)throw Error("Expected target alias to match deviceTarget when both are set.");return i??n}(r,i),device:k(r,"device"),udid:k(r,"udid"),serial:k(r,"serial"),iosSimulatorDeviceSet:k(r,"iosSimulatorDeviceSet"),androidDeviceAllowlist:k(r,"androidDeviceAllowlist"),daemonBaseUrl:k(r,"daemonBaseUrl"),daemonAuthToken:k(r,"daemonAuthToken"),tenant:k(r,"tenant"),runId:k(r,"runId"),leaseId:k(r,"leaseId"),cwd:k(r,"cwd"),debug:D(r,"debug")}}function I(e,t){let r=W(e,t);return{x:O(r,"x"),y:O(r,"y")}}function T(e,t){let r=e[t];if("string"!=typeof r||0===r.length)throw Error(`Expected ${t} to be a non-empty string.`);return r}function k(e,t){let r=e[t];if(void 0!==r){if("string"!=typeof r||0===r.length)throw Error(`Expected ${t} to be a non-empty string.`);return r}}function O(e,t){let r=e[t];if("number"!=typeof r||!Number.isFinite(r))throw Error(`Expected ${t} to be a finite number.`);return r}function $(e,t){let r=e[t];if(void 0!==r){if("number"!=typeof r||!Number.isFinite(r))throw Error(`Expected ${t} to be a finite number.`);return r}}function F(e,t,r={}){let i=e[t];if(void 0!==i){if(!Number.isInteger(i))throw Error(`Expected ${t} to be an integer.`);if(void 0!==r.min&&i<r.min)throw Error(`Expected ${t} to be at least ${r.min}.`);if(void 0!==r.max&&i>r.max)throw Error(`Expected ${t} to be at most ${r.max}.`);return i}}function D(e,t){let r=e[t];if(void 0!==r){if("boolean"!=typeof r)throw Error(`Expected ${t} to be a boolean.`);return r}}function U(e,t,r){let i=e[t];if("string"!=typeof i||!r.includes(i))throw Error(`Expected ${t} to be one of: ${r.join(", ")}.`);return i}function P(e,t,r){let i=e[t];if(void 0!==i){if("string"!=typeof i||!r.includes(i))throw Error(`Expected ${t} to be one of: ${r.join(", ")}.`);return i}}function q(e){return B({session:e.session,platform:e.platform,target:e.deviceTarget,device:e.device,udid:e.udid,serial:e.serial,iosSimulatorDeviceSet:e.iosSimulatorDeviceSet,androidDeviceAllowlist:e.androidDeviceAllowlist,daemonBaseUrl:e.daemonBaseUrl,daemonAuthToken:e.daemonAuthToken,tenant:e.tenant,runId:e.runId,leaseId:e.leaseId,cwd:e.cwd,debug:e.debug})}function M(e){switch(e.kind){case"ref":return{ref:e.ref,label:e.label};case"selector":return{selector:e.selector};case"point":return{x:e.x,y:e.y}}}function R(e){switch(e.kind){case"ref":return{ref:e.ref,label:e.label};case"selector":return{selector:e.selector}}}function _(e){return{count:e.count,intervalMs:e.intervalMs,holdMs:e.holdMs,jitterPx:e.jitterPx,doubleTap:e.doubleTap}}function C(e){return{depth:e.depth,scope:e.scope,raw:e.raw}}function N(e,t,r){let i=new Set(t),n=Object.keys(e).filter(e=>!i.has(e));if(n.length>0)throw Error(`${r} has unknown field(s): ${n.join(", ")}.`)}function B(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}function K(e,t){return{schema:e,required:!1,read:t}}function H(e,t){let r=e[t];if(void 0!==r){if(!r||"object"!=typeof r||Array.isArray(r))throw Error(`Expected ${t} to be an object.`);return r}}function L(e,t){let r=e[t];if(void 0!==r){if(!Array.isArray(r)||r.some(e=>"string"!=typeof e))throw Error(`Expected ${t} to be an array of strings.`);return r}}function z(){return[{type:"object",properties:{kind:{type:"string",const:"ref"},ref:{type:"string",description:"Snapshot element ref such as @e12."},label:{type:"string",description:"Optional human label for the ref."}},required:["kind","ref"],additionalProperties:!1},{type:"object",properties:{kind:{type:"string",const:"selector"},selector:{type:"string",description:"Agent-device selector expression."}},required:["kind","selector"],additionalProperties:!1}]}function W(e,t){let r=e[t];if(!r||"object"!=typeof r||Array.isArray(r))throw Error(`Expected ${t} to be an object.`);return r}export{N as assertAllowedKeys,u as booleanField,o as booleanSchema,q as commonToClientOptions,B as compactRecord,g as customField,h as elementTargetField,p as enumField,x as fieldsInputSchema,l as integerField,n as integerSchema,y as interactionTargetField,b as jsonSchemaField,f as looseObjectField,s as looseObjectSchema,c as numberField,P as optionalEnum,F as optionalInteger,v as pointField,S as readCommonInput,j as readFieldInput,A as readInputRecord,I as readPoint,E as repeatedFields,U as requiredEnum,a as requiredField,O as requiredNumber,w as selectorSnapshotFields,m as stringArrayField,d as stringField,i as stringSchema,R as toClientElementTarget,M as toClientInteractionTarget,_ as toRepeatedOptions,C as toSelectorSnapshotOptions};
|