agent-device 0.20.0 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +3 -2
  2. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.0.apk → agent-device-android-ime-helper-0.20.1.apk} +0 -0
  3. package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.1.apk.sha256 +1 -0
  4. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.0.manifest.json → agent-device-android-ime-helper-0.20.1.manifest.json} +4 -4
  5. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.0.apk → agent-device-android-snapshot-helper-0.20.1.apk} +0 -0
  6. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.1.apk.sha256 +1 -0
  7. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.0.manifest.json → agent-device-android-snapshot-helper-0.20.1.manifest.json} +6 -6
  8. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +54 -6
  9. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +1 -1
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +15 -4
  11. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +8 -3
  12. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +4 -2
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +1 -1
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +2 -1
  15. package/dist/src/agent-device-client.js +2 -2
  16. package/dist/src/android-input-method-overlays.js +1 -1
  17. package/dist/src/android-system-chrome.js +1 -1
  18. package/dist/src/android.js +1 -1
  19. package/dist/src/app-log-request-scope.js +1 -1
  20. package/dist/src/app-resolution.js +1 -1
  21. package/dist/src/apple-multitouch-support.js +1 -1
  22. package/dist/src/apps.js +5 -5
  23. package/dist/src/boot-diagnostics.js +2 -2
  24. package/dist/src/cli-config.js +1 -1
  25. package/dist/src/cli-help.js +76 -19
  26. package/dist/src/cli-runner.js +1 -1
  27. package/dist/src/cli.js +14 -14
  28. package/dist/src/command-metadata.js +1 -1
  29. package/dist/src/command-schema.js +1 -1
  30. package/dist/src/compatibility-policy.js +1 -0
  31. package/dist/src/context.js +1 -1
  32. package/dist/src/contracts.d.ts +2 -2
  33. package/dist/src/debug-symbols.js +1 -1
  34. package/dist/src/devices2.js +1 -1
  35. package/dist/src/devices4.js +1 -0
  36. package/dist/src/find.js +1 -1
  37. package/dist/src/finders.js +1 -1
  38. package/dist/src/generic.js +1 -1
  39. package/dist/src/index.d.ts +144 -9
  40. package/dist/src/input-actions.js +2 -2
  41. package/dist/src/interaction-snapshot.js +1 -1
  42. package/dist/src/interaction.d.ts +2 -2
  43. package/dist/src/interaction.js +1 -1
  44. package/dist/src/interactor.js +2 -2
  45. package/dist/src/interactor2.js +1 -0
  46. package/dist/src/internal/bin.js +1 -1
  47. package/dist/src/internal/daemon.js +20 -20
  48. package/dist/src/lease-context.js +1 -1
  49. package/dist/src/lease.js +1 -1
  50. package/dist/src/linux.js +1 -1
  51. package/dist/src/method-scope.js +1 -0
  52. package/dist/src/metro-types.d.ts +52 -0
  53. package/dist/src/metro.d.ts +2 -2
  54. package/dist/src/react-native.js +1 -1
  55. package/dist/src/recording-export-quality.js +15 -0
  56. package/dist/src/register-builtins.js +1 -1
  57. package/dist/src/registry.js +24 -24
  58. package/dist/src/remote-config.d.ts +1 -1
  59. package/dist/src/reporting.js +4 -4
  60. package/dist/src/runner-client.js +1 -1
  61. package/dist/src/runner-disposal.js +2 -2
  62. package/dist/src/runner-lease.js +1 -1
  63. package/dist/src/runner-provider.js +1 -1
  64. package/dist/src/runtime.js +3 -3
  65. package/dist/src/runtime2.js +1 -1
  66. package/dist/src/sdk-android-adb.d.ts +2 -24
  67. package/dist/src/sdk-android-adb.js +4 -4
  68. package/dist/src/sdk-batch-runner.js +3 -2
  69. package/dist/src/sdk-contracts.d.ts +4 -90
  70. package/dist/src/sdk-device.js +1 -1
  71. package/dist/src/sdk-finders.d.ts +3 -2
  72. package/dist/src/sdk-finders.js +1 -1
  73. package/dist/src/sdk-remote-config.d.ts +18 -103
  74. package/dist/src/sdk-selectors.js +1 -1
  75. package/dist/src/selector-runtime.js +1 -1
  76. package/dist/src/selector-vocabulary.js +1 -1
  77. package/dist/src/selectors.d.ts +1 -1
  78. package/dist/src/selectors.js +1 -1
  79. package/dist/src/server.js +2 -2
  80. package/dist/src/session-target-evidence.js +1 -1
  81. package/dist/src/session.js +8 -8
  82. package/dist/src/simctl.js +1 -0
  83. package/dist/src/simulator.js +1 -1
  84. package/dist/src/snapshot-diagnostics.js +4 -4
  85. package/dist/src/snapshot-quality.js +1 -1
  86. package/dist/src/snapshot2.js +1 -1
  87. package/dist/src/tool-provider3.js +1 -0
  88. package/dist/src/unsupported-interactor.js +1 -0
  89. package/dist/src/web.js +1 -1
  90. package/package.json +8 -6
  91. package/server.json +2 -2
  92. package/skills/agent-device/SKILL.md +5 -3
  93. package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.0.apk.sha256 +0 -1
  94. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.0.apk.sha256 +0 -1
  95. package/dist/src/config.js +0 -1
  96. package/dist/src/daemon-shutdown-report.js +0 -1
  97. package/dist/src/sdk-batch.js +0 -2
  98. package/dist/src/tv-remote.js +0 -15
@@ -1,2 +1,3 @@
1
- import{_ as e,a as t,i as n,v as r}from"./sdk-contracts.js";import{a as i,i as a,n as o,t as s}from"./sdk-batch.js";function c(t,n,r,i){let a=r(t[n]);if(a===void 0)throw new e(`COMMAND_FAILED`,i,{response:t});return a}function l(e,t,n){return n(e[t])}function u(e,t,n){let r=e[t];return r===null?null:n(r)}function d(e,t){return c(e,t,x,`Daemon response is missing "${t}".`)}function f(e,t){return l(e,t,x)}function p(e,t){return u(e,t,x)}function m(e,t){return c(e,t,S,`Daemon response is missing numeric "${t}".`)}function h(e,t){return c(e,t,C,`Daemon response has invalid "${t}".`)}function g(e,t){return c(e,t,w,`Daemon response has invalid "${t}".`)}function _(e,t){return l(e,t,T)??`mobile`}function v(e){if(!D(e))return;let t=b(e,`x`),n=b(e,`y`),r=b(e,`width`),i=b(e,`height`);if(!(t===void 0||n===void 0||r===void 0||i===void 0))return{x:t,y:n,width:r,height:i}}function y(e){if(!D(e))return;let t=b(e,`x`),n=b(e,`y`);if(!(t===void 0||n===void 0))return{x:t,y:n}}function b(e,t){let n=e[t];return typeof n==`number`?n:void 0}function x(e){return typeof e==`string`&&e.length>0?e:void 0}function S(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function C(e){return e===`apple`?`ios`:e===`ios`||e===`macos`||e===`android`||e===`linux`||e===`web`?e:void 0}function w(e){return e===`simulator`||e===`emulator`||e===`device`?e:void 0}function T(e){return e===`tv`||e===`mobile`||e===`desktop`?e:void 0}function E(t){if(!D(t))throw new e(`COMMAND_FAILED`,`Daemon returned an unexpected response shape.`,{value:t});return t}function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function O(e){return D(e)?e:void 0}function k(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function A(e){return e.split(`
2
- `).map(e=>e.trim()).filter(e=>e.length>0)}function j(e){return Number.isInteger(e)&&e>=1&&e<=1e3}function M(t,n){if(t>n)throw new e(`INVALID_ARGS`,`batch has ${t} steps; max allowed is ${n}.`)}function N(t,n){if(!D(t))throw new e(`INVALID_ARGS`,`Invalid batch step ${n}.`);return t}function P(t,n){let r=t.input;if(!D(r))throw new e(`INVALID_ARGS`,`Batch step ${n} input must be an object.`);return r}function F(t,r){if(t!==void 0)try{return n.parse(t)}catch(t){throw new e(`INVALID_ARGS`,`Batch step ${r} runtime is invalid: ${t instanceof Error?t.message:String(t)}`)}}const I=new Set(s);async function L(e,t,n){let i=W(e.flags),a=i?.batchOnError??`stop`;if(a!==`stop`)return G(`INVALID_ARGS`,`Unsupported batch on-error mode: ${a}.`);let o=i?.batchMaxSteps??100;if(!j(o))return G(`INVALID_ARGS`,`Invalid batch max-steps: ${String(i?.batchMaxSteps)}`);try{let r=R(i?.batchSteps,o),a=Date.now(),s=[];for(let[i,a]of r.entries()){let o=await U(e,t,a,n,i+1,i===r.length-1);if(!o.ok)return{ok:!1,error:{code:o.error.code,message:`Batch failed at step ${o.step} (${a.command}): ${o.error.message}`,hint:o.error.hint,diagnosticId:o.error.diagnosticId,logPath:o.error.logPath,details:{...o.error.details??{},step:o.step,command:a.command,positionals:a.positionals,executed:i,total:r.length,partialResults:s}}};s.push(o.result)}return{ok:!0,data:{total:r.length,executed:r.length,totalDurationMs:Date.now()-a,results:s}}}catch(e){let t=r(e);return G(t.code,t.message,t.details)}}function R(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty batchSteps array.`);M(t.length,n);let r=[];for(let n=0;n<t.length;n+=1){let o=t[n];if(!D(o))throw new e(`INVALID_ARGS`,`Invalid batch step at index ${n}.`);let s=Object.keys(o).filter(e=>!I.has(e));if(s.length>0){let t=s.map(e=>`"${e}"`).join(`, `);throw new e(`INVALID_ARGS`,`Batch step ${n+1} has unknown field(s): ${t}. Allowed fields: command, positionals, input, flags, runtime.`)}let c=i(o.command);if(!c)throw new e(`INVALID_ARGS`,`Batch step ${n+1} requires command.`);if(a(c,n+1),o.positionals!==void 0&&!Array.isArray(o.positionals))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must be an array.`);let l=o.positionals??[];if(l.some(e=>typeof e!=`string`))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must contain only strings.`);if(o.flags!==void 0&&!D(o.flags))throw new e(`INVALID_ARGS`,`Batch step ${n+1} flags must be an object.`);if(o.input!==void 0&&!D(o.input))throw new e(`INVALID_ARGS`,`Batch step ${n+1} input must be an object.`);r.push({command:c,positionals:l,input:o.input,flags:o.flags??{},runtime:F(o.runtime,n+1)})}return r}function z(e,t){let{batchSteps:n,batchOnError:r,batchMaxSteps:i,...a}=t??{};return B(W(e),a)}function B(e,t){let n=W(e)??{},r=t;for(let e of o)r[e]===void 0&&n[e]!==void 0&&(r[e]=n[e]);return t}function V(e,n){return t(e)?n?e:`digest`:e}function H(e,t){let n=e?.responseLevel,r=V(n,t);return r===n?e:{...e,responseLevel:r}}async function U(e,t,n,r,i,a){let o=Date.now(),s=z(e.flags,n.flags);s.session===void 0&&(s.session=t);let c=await r({token:e.token,session:t,command:n.command,positionals:n.positionals,input:n.input,flags:s,runtime:n.runtime===void 0?e.runtime:n.runtime,meta:H(e.meta,a)}),l=Date.now()-o;return c.ok?{ok:!0,step:i,result:{step:i,command:n.command,ok:!0,data:c.data??{},durationMs:l}}:{ok:!1,step:i,error:c.error}}function W(e){return e}function G(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}export{m as _,F as a,A as b,O as c,y as d,v as f,g,f as h,j as i,E as l,p as m,L as n,P as o,_ as p,M as r,N as s,B as t,D as u,h as v,k as x,d as y};
1
+ import{_ as e,a as t,i as n,v as r}from"./sdk-contracts.js";const i=new Set([`id`,`role`,`text`,`label`,`value`,`appname`,`windowtitle`]),a=new Set([`visible`,`hidden`,`editable`,`selected`,`focused`,`enabled`,`hittable`]),o=new Set([...i,...a]),s=[...o],c=new Set(`button.imagebutton.link.cell.statictext.checkedtextview.textfield.textbox.edittext.textarea.switch.slider.image.imageview.webview.framelayout.linearlayout.relativelayout.constraintlayout.viewgroup.view.listview.recyclerview.collectionview.list.searchfield.segmentedcontrol.group.window.checkbox.radio.menuitem.toolbar.scrollarea.scrollview.nestedscrollview.table.application.navigationbar.tabbar.tab.alert.dialog.header`.split(`.`));function ee(e){return c.has(e.trim().toLowerCase())}const te=new Map([[`"`,`"`],[`'`,`'`],[`\\`,`\\`],[`/`,`/`],[`b`,`\b`],[`f`,`\f`],[`n`,`
2
+ `],[`r`,`\r`],[`t`,` `]]);function ne(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=oe(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>ie(e))}}function l(e){try{return ne(e)}catch{return null}}function u(e){let t=e.trim();if(!t)return!1;if(t===`||`)return!0;let n=t.indexOf(`=`);if(n!==-1){let e=t.slice(0,n).trim().toLowerCase();return o.has(e)}return o.has(t.toLowerCase())}function re(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||o.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=p(i).trim();return a?{key:r,value:a}:null}function d(e,t={}){if(e.length===0)return null;let n=t.preferTrailingValue??!1,r=0,i=[];for(;r<e.length;){let t=e[r];if(t===void 0||!u(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&l(n)&&i.push(r)}if(i.length===0)return null;let a=i.at(-1);if(a===void 0)return null;let o=a;if(n)for(let t=i.length-1;t>=0;--t){let n=i[t];if(n!==void 0&&n<e.length){o=n;break}}let s=e.slice(0,o).join(` `).trim();return s?{selectorExpression:s,rest:e.slice(o)}:null}function ie(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=se(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(ae)}}function ae(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Empty selector term`);let r=n.indexOf(`=`);if(r===-1){let r=n.toLowerCase();if(!a.has(r))throw new e(`INVALID_ARGS`,`Invalid selector term "${t}", expected key=value`);return{key:r,value:!0}}let i=n.slice(0,r).trim().toLowerCase(),s=n.slice(r+1).trim();if(!o.has(i))throw new e(`INVALID_ARGS`,`Unknown selector key: ${i}`);if(!s)throw new e(`INVALID_ARGS`,`Missing selector value for key: ${i}`);if(a.has(i)){let t=ue(s);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${s}`);return{key:i,value:t}}return{key:i,value:p(s)}}function oe(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!m(t,a)){i=f(i,o),r+=o;continue}if(!i&&o===`|`&&t[a+1]===`|`){let i=r.trim();if(!i)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);n.push(i),r=``,a+=1;continue}r+=o}let a=r.trim();if(!a)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);return n.push(a),n}function se(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!m(t,e)){i=f(i,a),r+=a;continue}if(!i&&/\s/.test(a)){r.trim()&&n.push(r.trim()),r=``;continue}r+=a}if(i)throw new e(`INVALID_ARGS`,`Unclosed quote in selector: ${t}`);return r.trim()&&n.push(r.trim()),n}function f(e,t){return e?e===t?null:e:t}function p(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?ce(t.slice(1,-1)):t}function ce(e){let t=``,n=0;for(;n<e.length;){let r=e.charAt(n);if(r!==`\\`){t+=r,n+=1;continue}let i=e.charAt(n+1);if(!i){t+=r,n+=1;continue}let a=le(i);if(a!==null){t+=a,n+=2;continue}if(i===`u`){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+=r,n+=1}return t}function le(e){return te.get(e)??null}function ue(e){let t=p(e).toLowerCase();return t===`true`?!0:t===`false`?!1:null}function m(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}const de=[`any`,`text`,`label`,`value`,`role`,`id`],fe=[`text`,`label`,`value`,`role`,`id`];function pe(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`}function me(e,t,n,r={}){let i=g(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=he(n,t,i);if(!(e<=0)){if(e>a){a=e,o.length=0,o.push(n);continue}e===a&&o.push(n)}}return{matches:o,score:a}}function he(e,t,n){switch(t){case`role`:return ge(e.type,n);case`label`:return h(e.label,n);case`value`:return h(e.value,n);case`id`:return h(e.identifier,n);default:return Math.max(h(e.label,n),h(e.value,n),h(e.identifier,n))}}function h(e,t){let n=g(e??``);return n?n===t?2:+!!n.includes(t):0}function ge(e,t){let n=_e(e??``);return n?n===t?2:+!!n.includes(t):0}function g(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function _e(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replace(/XCUIElementType/gi,``).toLowerCase(),t):``}const ve=`find requires a value`;function ye(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=_([...e]);return n.query?t?.findFirst&&t?.findLast?{ok:!1,code:`INVALID_ARGS`,message:`find accepts only one of --first or --last`}:{ok:!0,parsed:n}:{ok:!1,code:`INVALID_ARGS`,message:ve}}function _(t){let n=`any`,r=0;fe.includes(t[0])&&(n=t[0],r=1);let i=t[r]??``,a=t.slice(r+1);if(a.length===0)return{locator:n,query:i,action:`click`};let o=a[0]?.toLowerCase();if(o===`get`){let t=a[1]?.toLowerCase();if(t===`text`)return{locator:n,query:i,action:`get_text`};if(t===`attrs`)return{locator:n,query:i,action:`get_attrs`};throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}if(o===`wait`){let e=xe(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`exists`)return{locator:n,query:i,action:`exists`};if(o===`click`)return{locator:n,query:i,action:`click`};if(o===`focus`)return{locator:n,query:i,action:`focus`};if(o===`fill`){let e=a.slice(1).join(` `);return{locator:n,query:i,action:`fill`,value:e}}if(o===`type`){let e=a.slice(1).join(` `);return{locator:n,query:i,action:`type`,value:e}}throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`)}function be(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:l(t)}function xe(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function v(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function y(e){let t=e[0];if(t===void 0)return null;let n=v(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=v(e[e.length-1]);if(t===`text`)return{kind:`text`,text:(r===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:r};if(t===`stable`){let t=e.slice(1),n=t.length>1?v(t[1]):null;return{kind:`stable`,quietMs:t.length>0?v(t[0]):null,timeoutMs:n}}if(t.startsWith(`@`))return{kind:`ref`,rawRef:t,timeoutMs:r};let i=d(r===null?e.slice():e.slice(0,-1));return i&&i.rest.length===0&&l(i.selectorExpression)?{kind:`selector`,selectorExpression:i.selectorExpression,timeoutMs:r}:{kind:`text`,text:(r===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:r}}function Se(e){let t=y(e);return t?t.kind===`sleep`?t.durationMs:t.timeoutMs:null}const b=24e4,x={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},Ce={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`};function S(e){if(e!==void 0)return Ce[e]}const C={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},w={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},T=()=>!0,we=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,E=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),D=new Set([`status`,`get`]),Te=e=>k(e,D,`status`),O=new Set([`get`,`wait`]),Ee=e=>k(e,O,`get`),De=e=>A(e,D,`status`),Oe=e=>A(e,O,`get`),ke=e=>{try{return pe(_(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}};function k(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function A(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const j={simulator:!0,device:!0},M={emulator:!0,device:!0,unknown:!0},N={emulator:!0},P={device:!0},F={},I={apple:j,android:M,linux:P},L={...I,vega:N},Ae={apple:j,android:M,linux:F},R={apple:j,android:M,linux:F},z={recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:j,android:M,linux:P},timeoutPolicy:x,batchable:!0},B={...x,onTimeout:`preserve-daemon`},V={...x,envelopeMs:18e4},H={...x,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},je={fields:{count:{defaultValue:1,omitDefault:!0},intervalMs:{defaultValue:0,omitDefault:!0},holdMs:{defaultValue:0,omitDefault:!0},jitterPx:{defaultValue:0,omitDefault:!0},doubleTap:{defaultValue:!1,omitDefault:!0}}},Me={fields:{delayMs:{defaultValue:0}}};function U(e){return S(e)===void 0?B:H}function W(e){let t=S(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const Ne=[{name:`lease_allocate`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...C},timeoutPolicy:x,batchable:!1},{name:`lease_heartbeat`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...C},timeoutPolicy:x,batchable:!1},{name:`lease_release`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...C},timeoutPolicy:x,batchable:!1},{name:`artifacts`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...C},timeoutPolicy:x,batchable:!1},{name:`session_list`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...w},timeoutPolicy:x,batchable:!1},{name:`session_save_script`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:x,batchable:!1},{name:`devices`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...w},timeoutPolicy:x,batchable:!0},{name:`capabilities`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...w},timeoutPolicy:x,batchable:!0},{name:`doctor`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:T,...w},timeoutPolicy:x,batchable:!0},{name:`apps`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0},capability:Ae,timeoutPolicy:x,batchable:!0},{name:`boot`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`shutdown`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},capability:{apple:{simulator:!0},android:{emulator:!0},linux:F},timeoutPolicy:x,batchable:!0},{name:`appstate`,catalog:{group:`public`,key:`appState`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},timeoutPolicy:x,batchable:!0},{name:`perf`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`logs`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`events`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...w},timeoutPolicy:x,batchable:!1},{name:`network`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`audio`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:j,android:{emulator:!0},linux:F},timeoutPolicy:x,batchable:!0},{name:`replay`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:E},timeoutPolicy:{...x,budget:{source:`flag`}},batchable:!1},{name:`test`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:E},timeoutPolicy:{...x,envelopeMs:`unbounded`},batchable:!0},{name:`runtime`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:x,batchable:!1},{name:`clipboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`},dispatch:{},capability:{apple:j,android:M,linux:P},timeoutPolicy:x,batchable:!0},{name:`keyboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:De,daemon:{route:`session`,refFrameEffect:Te,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`install`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},capability:R,timeoutPolicy:V,batchable:!0},{name:`reinstall`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},capability:R,timeoutPolicy:V,batchable:!0},{name:`install_source`,catalog:{group:`internal`,key:`installSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},timeoutPolicy:V,batchable:!1},{name:`release_materialized_paths`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...w},timeoutPolicy:x,batchable:!1},{name:`push`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:{simulator:!0},android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`trigger-app-event`,catalog:{group:`public`,key:`triggerAppEvent`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`open`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:T},dispatch:{},capability:L,timeoutPolicy:x,batchable:!0},{name:`prepare`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:{budget:{source:`flag`},envelopeMs:b,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1},{name:`batch`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:x,batchable:!1},{name:`close`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0},dispatch:{},capability:L,timeoutPolicy:x,batchable:!0},{name:`snapshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},dispatch:{},capability:I,timeoutPolicy:{...B,budget:{source:`flag`}},batchable:!0},{name:`diff`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:I,timeoutPolicy:x,batchable:!0},{name:`wait`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:I,timeoutPolicy:{...B,budget:{source:`positional-parser`,parser:Se}},batchable:!0},{name:`alert`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:Oe,daemon:{route:`snapshot`,refFrameEffect:Ee},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`settings`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`snapshot`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`react-native`,catalog:{group:`public`,key:`reactNative`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`record`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:we},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`trace`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:x,batchable:!0},{name:`find`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:ke,daemon:{route:`find`,refFrameEffect:`may-invalidate`},capability:I,timeoutPolicy:B,batchable:!0},{name:`click`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:j,android:M,linux:P},timeoutPolicy:U(`click`),postActionObservation:W(`click`),responseDataTransform:je,batchable:!0},{name:`fill`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:j,android:M,linux:P},timeoutPolicy:U(`fill`),postActionObservation:W(`fill`),responseDataTransform:Me,batchable:!0},{name:`longpress`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`,key:`longPress`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:j,android:M,linux:P},timeoutPolicy:{...H,envelopeMs:21e4},postActionObservation:W(`longpress`),batchable:!0},{name:`press`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:j,android:M,linux:P},timeoutPolicy:U(`press`),postActionObservation:W(`press`),responseDataTransform:je,batchable:!0},{name:`type`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:I,timeoutPolicy:U(`type`),batchable:!0},{name:`get`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:I,timeoutPolicy:U(`get`),batchable:!0},{name:`read`,catalog:{group:`dispatch-alias`},recordsSessionAction:!1,dispatch:{},timeoutPolicy:x,batchable:!1},{name:`is`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:I,timeoutPolicy:U(`is`),batchable:!0},{name:`back`,catalog:{group:`public`},...z,capability:{...z.capability,vega:N}},{name:`gesture`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:I,timeoutPolicy:x,batchable:!0},{name:`home`,catalog:{group:`public`},...z,capability:{...z.capability,vega:N}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:j,android:M,vega:N,linux:F},timeoutPolicy:x,batchable:!0},{name:`orientation`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`scroll`,catalog:{group:`public`},...z},{name:`swipe`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:j,android:M,linux:P},timeoutPolicy:x,batchable:!0},{name:`focus`,catalog:{group:`public`},...z},{name:`screenshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},dispatch:{},capability:I,timeoutPolicy:x,batchable:!0},{name:`viewport`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!1},{name:`app-switcher`,catalog:{group:`public`,key:`appSwitcher`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:j,android:M,linux:F},timeoutPolicy:x,batchable:!0},{name:`install-from-source`,catalog:{group:`public`,key:`installFromSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,capability:R,timeoutPolicy:x,batchable:!0},{name:`debug`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1},{name:`daemon`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1},{name:`device`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1},{name:`metro`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1},{name:`session`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1},{name:`cdp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1},{name:`auth`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1},{name:`connect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1},{name:`connection`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1},{name:`disconnect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1},{name:`mcp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1},{name:`proxy`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1},{name:`react-devtools`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1},{name:`web`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:x,batchable:!1,mcpExposed:!1}],Pe=new Set([`public`,`local-cli`]),G=new Set(Ne.filter(e=>Pe.has(Be(e))).map(e=>e.name)),K=Ne.map(e=>({...e,mcpExposed:Re(e)}));function Fe(e){return K.filter(t=>Be(t)===e).map(e=>[Ve(e),e.name])}function Ie(){return K.filter(e=>ze(e)).map(e=>e.name).sort()}const q=new Map(K.map(e=>[e.name,e]));function Le(e){return G.has(e)}function Re(e){return e.mcpExposed??G.has(e.name)}function ze(e){return e.mcpExposed&&Le(e.name)}function Be(e){return e.catalog.group}function Ve(e){return e.catalog.key??e.name}const He=new Map(K.map(e=>[e.name,e.timeoutPolicy])),Ue=new Map(Array.from(q.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function We(e){if(e!==void 0)return q.get(e)?.postActionObservation}function Ge(e){return We(e)!==void 0}function Ke(e){return We(e)===`settle-and-verify`}function qe(e){return e===void 0?x:He.get(e)??x}function Je(e){if(e!==void 0)return Ue.get(e)}function Ye(e){return e===void 0?!1:q.get(e)?.recordsSessionAction??!1}function Xe(e){return q.get(e)?.targetIdentityVerification}function Ze(e){let t=q.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Qe(){return[...new Set(Array.from(Ue.values()).flatMap(e=>Object.keys(e.fields)))].sort()}function J(t,n,r,i){let a=r(t[n]);if(a===void 0)throw new e(`COMMAND_FAILED`,i,{response:t});return a}function $e(e,t,n){return n(e[t])}function et(e,t,n){let r=e[t];return r===null?null:n(r)}function tt(e,t){return J(e,t,X,`Daemon response is missing "${t}".`)}function nt(e,t){return $e(e,t,X)}function rt(e,t){return et(e,t,X)}function it(e,t){return J(e,t,ut,`Daemon response is missing numeric "${t}".`)}function at(e,t){return J(e,t,dt,`Daemon response has invalid "${t}".`)}function ot(e,t){return J(e,t,ft,`Daemon response has invalid "${t}".`)}function st(e,t){return $e(e,t,pt)??`mobile`}function ct(e){if(!Z(e))return;let t=Y(e,`x`),n=Y(e,`y`),r=Y(e,`width`),i=Y(e,`height`);if(!(t===void 0||n===void 0||r===void 0||i===void 0))return{x:t,y:n,width:r,height:i}}function lt(e){if(!Z(e))return;let t=Y(e,`x`),n=Y(e,`y`);if(!(t===void 0||n===void 0))return{x:t,y:n}}function Y(e,t){let n=e[t];return typeof n==`number`?n:void 0}function X(e){return typeof e==`string`&&e.length>0?e:void 0}function ut(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function dt(e){return e===`apple`?`ios`:e===`ios`||e===`macos`||e===`android`||e===`vega`||e===`linux`||e===`web`?e:void 0}function ft(e){return e===`simulator`||e===`emulator`||e===`device`?e:void 0}function pt(e){return e===`tv`||e===`mobile`||e===`desktop`?e:void 0}function mt(t){if(!Z(t))throw new e(`COMMAND_FAILED`,`Daemon returned an unexpected response shape.`,{value:t});return t}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ht(e){return Z(e)?e:void 0}function gt(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function _t(e){return e.split(`
3
+ `).map(e=>e.trim()).filter(e=>e.length>0)}function vt(e){return Number.isInteger(e)&&e>=1&&e<=1e3}function yt(t,n){if(t>n)throw new e(`INVALID_ARGS`,`batch has ${t} steps; max allowed is ${n}.`)}function bt(t,n){if(!Z(t))throw new e(`INVALID_ARGS`,`Invalid batch step ${n}.`);return t}function xt(t,n){let r=t.input;if(!Z(r))throw new e(`INVALID_ARGS`,`Batch step ${n} input must be an object.`);return r}function St(t,r){if(t!==void 0)try{return n.parse(t)}catch(t){throw new e(`INVALID_ARGS`,`Batch step ${r} runtime is invalid: ${t instanceof Error?t.message:String(t)}`)}}function Ct(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function wt(e){let t={};for(let n of e)n.capability&&(t[n.name]=n.capability);return t}function Tt(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Et=Tt(K),Dt=new Set([`batch`,`replay`]),Ot=[`command`,`positionals`,`input`,`flags`,`runtime`],kt=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],At=new Set(Et);function jt(e){return At.has(e)}function Mt(e){return typeof e==`string`?e.trim().toLowerCase():``}function Nt(t,n){let r=Mt(t);if(jt(r))return r;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`)}function Pt(t,n){if(Dt.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}const Ft=new Set(Ot);async function It(e,t,n){let i=Q(e.flags),a=i?.batchOnError??`stop`;if(a!==`stop`)return $(`INVALID_ARGS`,`Unsupported batch on-error mode: ${a}.`);let o=i?.batchMaxSteps??100;if(!vt(o))return $(`INVALID_ARGS`,`Invalid batch max-steps: ${String(i?.batchMaxSteps)}`);try{let r=Lt(i?.batchSteps,o),a=Date.now(),s=[];for(let[i,a]of r.entries()){let o=await Ht(e,t,a,n,i+1,i===r.length-1);if(!o.ok)return{ok:!1,error:{code:o.error.code,message:`Batch failed at step ${o.step} (${a.command}): ${o.error.message}`,hint:o.error.hint,diagnosticId:o.error.diagnosticId,logPath:o.error.logPath,details:{...o.error.details??{},step:o.step,command:a.command,positionals:a.positionals,executed:i,total:r.length,partialResults:s}}};s.push(o.result)}return{ok:!0,data:{total:r.length,executed:r.length,totalDurationMs:Date.now()-a,results:s}}}catch(e){let t=r(e);return $(t.code,t.message,t.details)}}function Lt(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty batchSteps array.`);yt(t.length,n);let r=[];for(let n=0;n<t.length;n+=1){let i=t[n];if(!Z(i))throw new e(`INVALID_ARGS`,`Invalid batch step at index ${n}.`);let a=Object.keys(i).filter(e=>!Ft.has(e));if(a.length>0){let t=a.map(e=>`"${e}"`).join(`, `);throw new e(`INVALID_ARGS`,`Batch step ${n+1} has unknown field(s): ${t}. Allowed fields: command, positionals, input, flags, runtime.`)}let o=Mt(i.command);if(!o)throw new e(`INVALID_ARGS`,`Batch step ${n+1} requires command.`);if(Pt(o,n+1),i.positionals!==void 0&&!Array.isArray(i.positionals))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must be an array.`);let s=i.positionals??[];if(s.some(e=>typeof e!=`string`))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must contain only strings.`);if(i.flags!==void 0&&!Z(i.flags))throw new e(`INVALID_ARGS`,`Batch step ${n+1} flags must be an object.`);if(i.input!==void 0&&!Z(i.input))throw new e(`INVALID_ARGS`,`Batch step ${n+1} input must be an object.`);r.push({command:o,positionals:s,input:i.input,flags:i.flags??{},runtime:St(i.runtime,n+1)})}return r}function Rt(e,t){let{batchSteps:n,batchOnError:r,batchMaxSteps:i,...a}=t??{};return zt(Q(e),a)}function zt(e,t){let n=Q(e)??{},r=t;for(let e of kt)r[e]===void 0&&n[e]!==void 0&&(r[e]=n[e]);return t}function Bt(e,n){return t(e)?n?e:`digest`:e}function Vt(e,t){let n=e?.responseLevel,r=Bt(n,t);return r===n?e:{...e,responseLevel:r}}async function Ht(e,t,n,r,i,a){let o=Date.now(),s=Rt(e.flags,n.flags);s.session===void 0&&(s.session=t);let c=await r({token:e.token,session:t,command:n.command,positionals:n.positionals,input:n.input,flags:s,runtime:n.runtime===void 0?e.runtime:n.runtime,meta:Vt(e.meta,a)}),ee=Date.now()-o;return c.ok?{ok:!0,step:i,result:{step:i,command:n.command,ok:!0,data:c.data??{},durationMs:ee}}:{ok:!1,step:i,error:c.error}}function Q(e){return e}function $(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}export{d as $,Fe as A,de as B,tt as C,Ge as D,K as E,qe as F,g as G,ye as H,Xe as I,s as J,_ as K,b as L,Ze as M,Ye as N,Ke as O,Je as P,ne as Q,y as R,at as S,gt as T,me as U,ve as V,pe as W,ee as X,re as Y,u as Z,st as _,wt as a,ot as b,vt as c,bt as d,l as et,ht as f,ct as g,lt as h,Nt as i,Ie as j,Qe as k,St as l,Z as m,It as n,Ct as o,mt as p,be as q,Et as r,yt as s,zt as t,xt as u,rt as v,_t as w,it as x,nt as y,v as z};
@@ -1,11 +1,11 @@
1
1
  //#region src/kernel/device.d.ts
2
2
  declare const APPLE_OS_VALUES: readonly ['ios', 'ipados', 'tvos', 'watchos', 'visionos', 'macos'];
3
3
  type AppleOS = (typeof APPLE_OS_VALUES)[number];
4
- declare const PLATFORMS: readonly ['apple', 'android', 'linux', 'web'];
4
+ declare const PLATFORMS: readonly ['apple', 'android', 'vega', 'linux', 'web'];
5
5
  type Platform = (typeof PLATFORMS)[number];
6
- declare const PUBLIC_PLATFORMS: readonly ['ios', 'macos', 'android', 'linux', 'web'];
6
+ declare const PUBLIC_PLATFORMS: readonly ['ios', 'macos', 'android', 'vega', 'linux', 'web'];
7
7
  type PublicPlatform = (typeof PUBLIC_PLATFORMS)[number];
8
- declare const PLATFORM_SELECTORS: readonly ["apple", "android", "linux", "web", "ios", "macos"];
8
+ declare const PLATFORM_SELECTORS: readonly ["apple", "android", "vega", "linux", "web", "ios", "macos"];
9
9
  type PlatformSelector = (typeof PLATFORM_SELECTORS)[number];
10
10
  declare const DEVICE_KINDS: readonly ['simulator', 'emulator', 'device'];
11
11
  type DeviceKind = (typeof DEVICE_KINDS)[number];
@@ -173,55 +173,6 @@ declare function normalizeError(err: unknown, context?: {
173
173
  }): NormalizedError;
174
174
  declare function defaultHintForCode(code: string): string | undefined;
175
175
  //#endregion
176
- //#region src/contracts/debug-symbols.d.ts
177
- type DebugSymbolsOptions = {
178
- action?: 'symbols';
179
- artifact: string;
180
- dsym?: string;
181
- searchPath?: string;
182
- out?: string;
183
- cwd?: string;
184
- };
185
- type DebugSymbolsImage = {
186
- name: string;
187
- uuid: string;
188
- arch?: string;
189
- dsymPath: string;
190
- binaryPath: string;
191
- };
192
- type DebugSymbolsCrashFrame = {
193
- index: number;
194
- image: string;
195
- address: string;
196
- symbol?: string;
197
- };
198
- type DebugSymbolsCrashSummary = {
199
- format: 'ips' | 'text';
200
- appName?: string;
201
- bundleId?: string;
202
- version?: string;
203
- incident?: string;
204
- timestamp?: string;
205
- exceptionType?: string;
206
- exceptionCodes?: string;
207
- terminationReason?: string;
208
- crashedThread?: number;
209
- topFrames: DebugSymbolsCrashFrame[];
210
- findings: string[];
211
- };
212
- type DebugSymbolsResult = {
213
- kind: 'debugSymbols';
214
- platform: 'apple';
215
- artifactPath: string;
216
- outPath: string;
217
- crash: DebugSymbolsCrashSummary;
218
- matchedImages: DebugSymbolsImage[];
219
- symbolicatedFrames: number;
220
- skippedImages: number;
221
- warnings?: string[];
222
- message: string;
223
- };
224
- //#endregion
225
176
  //#region src/kernel/contracts.d.ts
226
177
  type SessionRuntimeHints = {
227
178
  platform?: 'ios' | 'android';
@@ -345,43 +296,6 @@ type DaemonResponse = {
345
296
  ok: false;
346
297
  error: DaemonError;
347
298
  };
348
- type LeaseAllocatePayload = {
349
- token?: string;
350
- session?: string;
351
- tenantId?: string;
352
- tenant?: string;
353
- runId?: string;
354
- ttlMs?: number;
355
- backend?: LeaseBackend;
356
- leaseProvider?: string;
357
- deviceKey?: string;
358
- clientId?: string;
359
- };
360
- type LeaseHeartbeatPayload = {
361
- token?: string;
362
- session?: string;
363
- tenantId?: string;
364
- tenant?: string;
365
- runId?: string;
366
- leaseId?: string;
367
- ttlMs?: number;
368
- backend?: LeaseBackend;
369
- leaseProvider?: string;
370
- deviceKey?: string;
371
- clientId?: string;
372
- };
373
- type LeaseReleasePayload = {
374
- token?: string;
375
- session?: string;
376
- tenantId?: string;
377
- tenant?: string;
378
- runId?: string;
379
- leaseId?: string;
380
- backend?: LeaseBackend;
381
- leaseProvider?: string;
382
- deviceKey?: string;
383
- clientId?: string;
384
- };
385
299
  type JsonRpcId = string | number | null;
386
300
  type JsonRpcRequestEnvelope<TParams = unknown> = {
387
301
  jsonrpc?: string;
@@ -390,4 +304,4 @@ type JsonRpcRequestEnvelope<TParams = unknown> = {
390
304
  params?: TParams;
391
305
  };
392
306
  //#endregion
393
- export { Point as A, DeviceKind as B, DebugSymbolsResult as C, isAgentDeviceError as D, defaultHintForCode as E, SnapshotState as F, Platform as H, SnapshotUnchanged as I, SnapshotVisibility as L, ScreenshotOverlayRef as M, SnapshotNode as N, normalizeAgentDeviceError as O, SnapshotQualityVerdict as P, centerOfRect as R, DebugSymbolsOptions as S, NormalizedError as T, PlatformSelector as U, DeviceTarget as V, PublicPlatform as W, NetworkIncludeMode as _, DaemonLockPolicy as a, SessionIsolationMode as b, DaemonResponseData as c, JsonRpcId as d, JsonRpcRequestEnvelope as f, LeaseReleasePayload as g, LeaseHeartbeatPayload as h, DaemonInstallSource as i, Rect as j, normalizeError as k, DaemonServerMode as l, LeaseBackend as m, DaemonArtifactType as n, DaemonRequest as o, LeaseAllocatePayload as p, DaemonError as r, DaemonResponse as s, DaemonArtifact as t, DaemonTransportPreference as u, ResponseCost as v, AppError as w, SessionRuntimeHints as x, ResponseLevel as y, AppleOS as z };
307
+ export { SnapshotState as A, normalizeAgentDeviceError as C, ScreenshotOverlayRef as D, Rect as E, DeviceKind as F, DeviceTarget as I, Platform as L, SnapshotVisibility as M, centerOfRect as N, SnapshotNode as O, AppleOS as P, PlatformSelector as R, isAgentDeviceError as S, Point as T, SessionIsolationMode as _, DaemonLockPolicy as a, NormalizedError as b, DaemonResponseData as c, JsonRpcId as d, JsonRpcRequestEnvelope as f, ResponseLevel as g, ResponseCost as h, DaemonInstallSource as i, SnapshotUnchanged as j, SnapshotQualityVerdict as k, DaemonServerMode as l, NetworkIncludeMode as m, DaemonArtifactType as n, DaemonRequest as o, LeaseBackend as p, DaemonError as r, DaemonResponse as s, DaemonArtifact as t, DaemonTransportPreference as u, SessionRuntimeHints as v, normalizeError as w, defaultHintForCode as x, AppError as y, PublicPlatform as z };
@@ -1 +1 @@
1
- import{_ as e}from"./sdk-contracts.js";const t=[`ios`,`ipados`,`tvos`,`watchos`,`visionos`,`macos`],n=[`apple`,`android`,`linux`,`web`],r=[`ios`,`macos`,`android`,`linux`,`web`],i=[...n,`ios`,`macos`],a=[`mobile`,`tv`,`desktop`];function o(e){return e===`apple`||e===`ios`||e===`macos`}function s(e){return e.appleOs===`macos`||e.platform===`macos`}function c(e){return o(e.platform)&&!s(e)}function l(e){return e.platform===`android`||o(e.platform)&&!s(e)}function u(e){return o(e.platform)?s(e)?`macos`:`ios`:e.platform}function d(e){return e===`macos`?{platform:`apple`,appleOs:`macos`}:e===`ios`?{platform:`apple`}:{platform:e}}function f(e){return o(e.platform)&&e.target===`tv`}function p(e){return e.appleOs?e.appleOs:e.platform===`macos`?`macos`:f(e)?`tvos`:`ios`}function m(e){return r.includes(e)}function h(e){return t.includes(e)}function g(e,t){return t?t===`apple`?o(e.platform):t===`ios`?o(e.platform)&&!s(e):t===`macos`?o(e.platform)&&s(e):e.platform===t:!0}function _(e,t){return t?v(t):e===`macos`||e===`desktop`?`macOS`:e===`tv`?`tvOS`:`iOS`}function v(e){switch(e){case`tvos`:return`tvOS`;case`macos`:return`macOS`;case`visionos`:return`visionOS`;default:return`iOS`}}function y(e){let{simulatorSetPath:t,platform:n,target:r}=e;if(t&&!(n===`macos`||r===`desktop`))return t}function b(e){return e.map((e,t)=>({device:e,index:t})).sort((e,t)=>O(e,t)).map(({device:e})=>e)}function x(e){return!e||e===`apple`||e===`ios`}async function S(t,n,r={}){let i=t.filter(e=>w(e,n));if(n.udid){let t=i.find(e=>e.id===n.udid&&o(e.platform));if(!t)throw new e(`DEVICE_NOT_FOUND`,`No Apple device with UDID ${n.udid}`);return t}if(n.serial){let t=i.find(e=>e.id===n.serial&&e.platform===`android`);if(!t)throw new e(`DEVICE_NOT_FOUND`,`No Android device with serial ${n.serial}`);return t}if(r.allowStoppedAndroidAvdPlaceholders!==!0&&(i=i.filter(e=>!C(e))),n.deviceName){let t=D(n.deviceName),r=i.find(e=>D(e.name)===t);if(!r)throw new e(`DEVICE_NOT_FOUND`,`No device named ${n.deviceName}`);return r}j(i)&&(i=b(i));let a=i[0];if(a!==void 0&&i.length===1)return a;i.length===0&&E(n,r);let s=i.filter(e=>e.kind!==`device`),c=s.length>0?s:i,l=c.filter(e=>e.booted),u=l[0];if(u&&l.length===1&&!j(c))return u;let d=j(c)?c[0]:l[0]??c[0];return d||E(n,r),d}function C(e){return e.platform===`android`&&e.kind===`emulator`&&e.booted===!1&&!/^emulator-\d+$/.test(e.id)}function w(e,t,n={}){return g(e,t.platform)&&(!t.target||(e.target??`mobile`)===t.target)&&(!n.includeExplicitSelectors||T(e,t))}function T(e,t){return!(t.udid&&!(e.id===t.udid&&o(e.platform))||t.serial&&!(e.id===t.serial&&e.platform===`android`)||t.deviceName&&D(e.name)!==D(t.deviceName))}function E(t,n){let r=n.simulatorSetPath;throw r&&x(t.platform)?new e(`DEVICE_NOT_FOUND`,`No devices found in the scoped simulator set`,{simulatorSetPath:r,hint:`The simulator set at "${r}" appears to be empty. Create a compatible simulator first with xcrun simctl --set "${r}" create, or remove the scoped simulator set.`,selector:t}):new e(`DEVICE_NOT_FOUND`,`No devices found`,{selector:t})}function D(e){return e.toLowerCase().replace(/_/g,` `).replace(/\s+/g,` `).trim()}function O(e,t){return k(e.device)-k(t.device)||Number(t.device.booted===!0)-Number(e.device.booted===!0)||e.device.name.localeCompare(t.device.name)||e.index-t.index}function k(e){return e.kind===`simulator`?A(e,0,1,2,3):e.kind===`device`&&o(e.platform)&&!s(e)?A(e,10,11,12,13):14}function A(e,t,n,r,i){return{mobile:M(e.name)?n:t,tv:r,desktop:i}[e.target??`mobile`]}function j(e){return e.length>0&&e.every(e=>o(e.platform))}function M(e){return/\bipad\b/i.test(e)}export{S as _,h as a,s as c,f as d,w as f,y as g,_ as h,d as i,l,u as m,i as n,o,g as p,r,c as s,a as t,m as u,p as v,b as y};
1
+ import{_ as e}from"./sdk-contracts.js";const t=[`ios`,`ipados`,`tvos`,`watchos`,`visionos`,`macos`],n=[`apple`,`android`,`vega`,`linux`,`web`],r=[`ios`,`macos`,`android`,`vega`,`linux`,`web`],i=[...n,`ios`,`macos`],a=[`mobile`,`tv`,`desktop`];function o(e){return e===`apple`||e===`ios`||e===`macos`}function s(e){return e.appleOs===`macos`||e.platform===`macos`}function c(e){return o(e.platform)&&!s(e)}function l(e){return e.platform===`android`||o(e.platform)&&!s(e)}function u(e){return o(e.platform)?s(e)?`macos`:`ios`:e.platform}function d(e){return e===`macos`?{platform:`apple`,appleOs:`macos`}:e===`ios`?{platform:`apple`}:{platform:e}}function f(e){return o(e.platform)&&e.target===`tv`}function p(e){return e.appleOs?e.appleOs:e.platform===`macos`?`macos`:f(e)?`tvos`:`ios`}function m(e){return r.includes(e)}function h(e){return t.includes(e)}function g(e,t){return t?t===`apple`?o(e.platform):t===`ios`?o(e.platform)&&!s(e):t===`macos`?o(e.platform)&&s(e):e.platform===t:!0}function _(e,t){return t?v(t):e===`macos`||e===`desktop`?`macOS`:e===`tv`?`tvOS`:`iOS`}function v(e){switch(e){case`tvos`:return`tvOS`;case`macos`:return`macOS`;case`visionos`:return`visionOS`;default:return`iOS`}}function y(e){let{simulatorSetPath:t,platform:n,target:r}=e;if(t&&!(n===`macos`||r===`desktop`))return t}function b(e){return e.map((e,t)=>({device:e,index:t})).sort((e,t)=>A(e,t)).map(({device:e})=>e)}function x(e){return!e||e===`apple`||e===`ios`}async function S(t,n,r={}){let i=t.filter(e=>w(e,n));if(n.udid){let t=i.find(e=>e.id===n.udid&&o(e.platform));if(!t)throw new e(`DEVICE_NOT_FOUND`,`No Apple device with UDID ${n.udid}`);return t}if(n.serial){let t=i.find(e=>e.id===n.serial&&E(e.platform));if(!t)throw new e(`DEVICE_NOT_FOUND`,D(n));return t}if(r.allowStoppedAndroidAvdPlaceholders!==!0&&(i=i.filter(e=>!C(e))),n.deviceName){let t=k(n.deviceName),r=i.find(e=>k(e.name)===t);if(!r)throw new e(`DEVICE_NOT_FOUND`,`No device named ${n.deviceName}`);return r}N(i)&&(i=b(i));let a=i[0];if(a!==void 0&&i.length===1)return a;i.length===0&&O(n,r);let s=i.filter(e=>e.kind!==`device`),c=s.length>0?s:i,l=c.filter(e=>e.booted),u=l[0];if(u&&l.length===1&&!N(c))return u;let d=N(c)?c[0]:l[0]??c[0];return d||O(n,r),d}function C(e){return e.platform===`android`&&e.kind===`emulator`&&e.booted===!1&&!/^emulator-\d+$/.test(e.id)}function w(e,t,n={}){return g(e,t.platform)&&(!t.target||(e.target??`mobile`)===t.target)&&(!n.includeExplicitSelectors||T(e,t))}function T(e,t){return!(t.udid&&!(e.id===t.udid&&o(e.platform))||t.serial&&!(e.id===t.serial&&E(e.platform))||t.deviceName&&k(e.name)!==k(t.deviceName))}function E(e){return e===`android`||e===`vega`}function D(e){return e.platform===`android`?`No Android device with serial ${e.serial}`:e.platform===`vega`?`No Vega VVD with serial ${e.serial}`:`No Android device or Vega VVD with serial ${e.serial}`}function O(t,n){let r=n.simulatorSetPath;throw r&&x(t.platform)?new e(`DEVICE_NOT_FOUND`,`No devices found in the scoped simulator set`,{simulatorSetPath:r,hint:`The simulator set at "${r}" appears to be empty. Create a compatible simulator first with xcrun simctl --set "${r}" create, or remove the scoped simulator set.`,selector:t}):new e(`DEVICE_NOT_FOUND`,`No devices found`,{selector:t})}function k(e){return e.toLowerCase().replace(/_/g,` `).replace(/\s+/g,` `).trim()}function A(e,t){return j(e.device)-j(t.device)||Number(t.device.booted===!0)-Number(e.device.booted===!0)||e.device.name.localeCompare(t.device.name)||e.index-t.index}function j(e){return e.kind===`simulator`?M(e,0,1,2,3):e.kind===`device`&&o(e.platform)&&!s(e)?M(e,10,11,12,13):14}function M(e,t,n,r,i){return{mobile:P(e.name)?n:t,tv:r,desktop:i}[e.target??`mobile`]}function N(e){return e.length>0&&e.every(e=>o(e.platform))}function P(e){return/\bipad\b/i.test(e)}export{y as _,h as a,b,s as c,E as d,f,_ as g,u as h,d as i,l,g as m,i as n,o,w as p,r,c as s,a as t,m as u,S as v,p as y};
@@ -1,4 +1,4 @@
1
- import { N as SnapshotNode } from "./sdk-contracts.js";
1
+ import { O as SnapshotNode } from "./sdk-contracts.js";
2
2
  //#region src/selectors/parse.d.ts
3
3
  type SelectorKey = 'id' | 'role' | 'text' | 'label' | 'value' | 'appname' | 'windowtitle' | 'visible' | 'hidden' | 'editable' | 'selected' | 'focused' | 'enabled' | 'hittable';
4
4
  type SelectorTerm = {
@@ -40,13 +40,14 @@ type FindAction = {
40
40
  kind: 'wait';
41
41
  timeoutMs?: number;
42
42
  };
43
- declare function parseFindArgs(args: string[]): {
43
+ type ParsedFindArgs = {
44
44
  locator: FindLocator;
45
45
  query: string;
46
46
  action: FindAction['kind'];
47
47
  value?: string;
48
48
  timeoutMs?: number;
49
49
  };
50
+ declare function parseFindArgs(args: string[]): ParsedFindArgs;
50
51
  //#endregion
51
52
  //#region src/finders.d.ts
52
53
  type FindMatchOptions = {
@@ -1 +1 @@
1
- import{C as e}from"./sdk-batch.js";function t(t,n,r,i){return e(t,n,r,typeof i==`boolean`?{requireRect:i}:i)}export{t};
1
+ import{U as e}from"./sdk-batch-runner.js";function t(t,n,r,i){return e(t,n,r,typeof i==`boolean`?{requireRect:i}:i)}export{t};
@@ -1,95 +1,20 @@
1
- import { U as PlatformSelector, V as DeviceTarget, b as SessionIsolationMode, l as DaemonServerMode, m as LeaseBackend, u as DaemonTransportPreference, x as SessionRuntimeHints } from "./sdk-contracts.js";
2
- //#region src/client/client-companion-tunnel-contract.d.ts
3
- type CompanionTunnelScope = {
4
- tenantId: string;
5
- runId: string;
6
- leaseId: string;
7
- };
8
- type MetroBridgeScope = CompanionTunnelScope;
9
- //#endregion
10
- //#region src/metro/metro-types.d.ts
11
- /** Re-export of {@link SessionRuntimeHints} under the Metro-specific alias used by public API consumers. */
12
- type MetroRuntimeHints = SessionRuntimeHints;
13
- type MetroBridgeResult = {
14
- enabled: boolean;
15
- baseUrl: string;
16
- statusUrl: string;
17
- bundleUrl: string;
18
- iosRuntime: MetroRuntimeHints;
19
- androidRuntime: MetroRuntimeHints;
20
- upstream: {
21
- bundleUrl: string;
22
- host: string;
23
- port: number;
24
- statusUrl: string;
25
- };
26
- probe: {
27
- reachable: boolean;
28
- statusCode: number;
29
- latencyMs: number;
30
- detail: string;
31
- };
32
- };
33
- type MetroBridgeRuntimePayload = {
34
- metro_host?: string;
35
- metro_port?: number;
36
- metro_bundle_url?: string;
37
- launch_url?: string;
38
- };
39
- type MetroBridgeDescriptor = {
40
- enabled: boolean;
41
- base_url: string;
42
- status_url?: string;
43
- bundle_url?: string;
44
- ios_runtime: MetroBridgeRuntimePayload;
45
- android_runtime: MetroBridgeRuntimePayload;
46
- upstream: {
47
- bundle_url?: string;
48
- host?: string;
49
- port?: number;
50
- status_url?: string;
51
- };
52
- probe: {
53
- reachable: boolean;
54
- status_code: number;
55
- latency_ms: number;
56
- detail: string;
57
- };
58
- };
59
- //#endregion
60
- //#region src/metro/client-metro.d.ts
1
+ import { I as DeviceTarget, R as PlatformSelector, _ as SessionIsolationMode, l as DaemonServerMode, p as LeaseBackend, u as DaemonTransportPreference } from "./sdk-contracts.js";
2
+ //#region src/contracts/metro.d.ts
61
3
  type MetroPrepareKind = 'auto' | 'react-native' | 'expo' | 'repack';
62
- type ResolvedMetroKind = Exclude<MetroPrepareKind, 'auto'>;
63
- type PrepareMetroRuntimeResult = {
64
- projectRoot: string;
65
- kind: ResolvedMetroKind;
66
- dependenciesInstalled: boolean;
67
- packageManager: string | null;
68
- started: boolean;
69
- reused: boolean;
70
- pid: number;
71
- logPath: string;
72
- statusUrl: string;
73
- runtimeFilePath: string | null;
74
- iosRuntime: MetroRuntimeHints;
75
- androidRuntime: MetroRuntimeHints;
76
- bridge: MetroBridgeResult | null;
77
- };
78
- /**
79
- * `transport` says which channel delivered the reload: `http` for the classic GET /reload route,
80
- * `message-socket` for the /message websocket broadcast used when the server has no HTTP reload
81
- * route (Expo). `status`/`body` always describe the HTTP probe; on the websocket path `reloadUrl`
82
- * is the ws(s) message-socket URL.
83
- */
84
- type ReloadMetroResult = {
85
- reloaded: true;
86
- reloadUrl: string;
87
- status: number;
88
- body: string;
89
- transport: 'http' | 'message-socket';
90
- };
91
4
  //#endregion
92
- //#region src/remote/remote-config-schema.d.ts
5
+ //#region src/contracts/remote-config-fields.d.ts
6
+ type CloudProviderProfileFields = {
7
+ providerApp?: string;
8
+ providerOsVersion?: string;
9
+ providerProject?: string;
10
+ providerBuild?: string;
11
+ providerSessionName?: string;
12
+ awsProjectArn?: string;
13
+ awsDeviceArn?: string;
14
+ awsAppArn?: string;
15
+ awsRegion?: string;
16
+ awsInteractionMode?: 'INTERACTIVE' | 'NO_VIDEO' | 'VIDEO_ONLY';
17
+ };
93
18
  type RemoteConfigMetroOptions = {
94
19
  metroProjectRoot?: string;
95
20
  metroKind?: MetroPrepareKind;
@@ -106,6 +31,8 @@ type RemoteConfigMetroOptions = {
106
31
  metroNoInstallDeps?: boolean;
107
32
  launchUrl?: string;
108
33
  };
34
+ //#endregion
35
+ //#region src/remote/remote-config-schema.d.ts
109
36
  type RemoteConnectionProfileFields = {
110
37
  stateDir?: string;
111
38
  daemonBaseUrl?: string;
@@ -121,18 +48,6 @@ type RemoteConnectionProfileFields = {
121
48
  deviceKey?: string;
122
49
  clientId?: string;
123
50
  };
124
- type CloudProviderProfileFields = {
125
- providerApp?: string;
126
- providerOsVersion?: string;
127
- providerProject?: string;
128
- providerBuild?: string;
129
- providerSessionName?: string;
130
- awsProjectArn?: string;
131
- awsDeviceArn?: string;
132
- awsAppArn?: string;
133
- awsRegion?: string;
134
- awsInteractionMode?: 'INTERACTIVE' | 'NO_VIDEO' | 'VIDEO_ONLY';
135
- };
136
51
  type RemoteConfigProfile = RemoteConfigMetroOptions & CloudProviderProfileFields & RemoteConnectionProfileFields & {
137
52
  platform?: PlatformSelector;
138
53
  target?: DeviceTarget;
@@ -144,4 +59,4 @@ type RemoteConfigProfile = RemoteConfigMetroOptions & CloudProviderProfileFields
144
59
  session?: string;
145
60
  };
146
61
  //#endregion
147
- export { PrepareMetroRuntimeResult as a, MetroBridgeScope as c, MetroPrepareKind as i, RemoteConfigProfile as n, ReloadMetroResult as o, RemoteConnectionProfileFields as r, MetroBridgeDescriptor as s, CloudProviderProfileFields as t };
62
+ export { MetroPrepareKind as i, RemoteConnectionProfileFields as n, CloudProviderProfileFields as r, RemoteConfigProfile as t };
@@ -1 +1 @@
1
- import{_ as e,u as t}from"./sdk-contracts.js";import{N as n,P as r,T as i}from"./sdk-batch.js";const a=/^#\s*agent-device:target-v(\d+)(?:\s+(.*))?$/,o=4096;function s(e){return e.normalize(`NFC`)}function c(e){if(e===void 0)return;let t=s(e);return t.length>0?t:void 0}function l(e){return s(e)}function u(e){if(e===void 0)return;let t=s(e).trim().replace(/\s+/g,` `);return t.length>0?t:void 0}function d(e){return Buffer.byteLength(e,`utf8`)}function f(e,t){if(d(e)<=t)return e;let n=e.length;for(;n>0&&d(e.slice(0,n))>t;)--n;if(n>0){let t=e.charCodeAt(n-1);t>=55296&&t<=56319&&--n}return e.slice(0,n)}function p(e){let t={};return e.id!==void 0&&(t.id=e.id),t.role=e.role,e.label!==void 0&&(t.label=e.label),t.ancestry=e.ancestry.map(m),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=ee(e.scrollRegion)),e.rect&&(t.rect=te(e.rect)),t.verification=e.verification,t}function m(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function ee(e){let t={role:e.role};return e.id!==void 0&&(t.id=e.id),e.label!==void 0&&(t.label=e.label),t}function te(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function ne(e){return JSON.stringify(p(e))}function re(e){return`# agent-device:target-v1 ${ne(e)}`}function ie(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=a.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:ae((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function ae(t){if(d(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${o}-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`target-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`target-v1 annotation must be a JSON object.`);let r=n,i=h(r.role,`role`),a=g(r.id,`id`),s=_(r.label,`label`),c=oe(r.ancestry),l=y(r.sibling,`sibling`,0),u=y(r.viewportOrder,`viewportOrder`,0),f=ce(r.scrollRegion),p=le(r.rect),m=ue(r.verification);return{...a===void 0?{}:{id:a},role:i,...s===void 0?{}:{label:s},ancestry:c,sibling:l,viewportOrder:u,...f?{scrollRegion:f}:{},...p?{rect:p}:{},verification:m}}function h(t,n){if(t===void 0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" is required.`);if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);return v(l(t),n)}function g(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=c(t);return r===void 0?void 0:v(r,n)}function _(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=u(t);return r===void 0?void 0:v(r,n)}function v(t,n){if(d(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function oe(t){if(t===void 0)return[];if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry" must be an array.`);if(t.length>8)throw new e(`INVALID_ARGS`,`target-v1 "ancestry" exceeds the 8-entry cap.`);return t.map((e,t)=>se(e,t))}function se(t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry[${n}]" must be an object.`);let r=t,i=h(r.role,`ancestry[${n}].role`),a=_(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function y(t,n,r){if(t===void 0)return r;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a non-negative integer.`);return t}function ce(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "scrollRegion" must be an object.`);let n=t,r=h(n.role,`scrollRegion.role`),i=g(n.id,`id`),a=_(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function le(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "rect" must be an object.`);let n=t;return{x:b(n.x,`rect.x`),y:b(n.y,`rect.y`),width:b(n.width,`rect.width`),height:b(n.height,`rect.height`)}}function b(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a finite number.`);return t}function ue(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function de(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function fe(e,t){if(e.length<t.length)return!1;for(let[n,r]of t.entries()){let t=e[n];if(!t||t.role!==r.role||r.label!==void 0&&t.label!==r.label)return!1}return!0}function pe(e){return e.matchedRefs.length===0?{path:2,outcome:`unverifiable`,reason:`selector-miss`}:e.identitySetRefs.length===0?{path:3,outcome:`unverifiable`,reason:`identity-set-empty`}:e.identitySetRefs.length===1?e.identitySetRefs[0]===e.winnerRef?{path:4,outcome:`verified`}:{path:5,outcome:`unverifiable`,reason:`unique-but-wrong`}:e.siblingMatchRefs.length===1?e.siblingMatchRefs[0]===e.winnerRef?{path:6,outcome:`verified`}:{path:6,outcome:`unverifiable`,reason:`signal-isolated-wrong`}:e.regionMemberRefs!==void 0&&e.regionMemberRefs.length>0&&e.viewportCandidateRef!==void 0?e.viewportCandidateRef===e.winnerRef?{path:6,outcome:`verified`}:{path:6,outcome:`unverifiable`,reason:`signal-isolated-wrong`}:{path:6,outcome:`unverifiable`,reason:`no-signal-isolation`}}function me(e){let t=new Map;for(let[n,r]of e.entries())t.set(r.index,n);let n=[],r=[];for(let[i,a]of e.entries()){let e=Math.max(0,a.depth??0);for(;r.length>0&&e<=r[r.length-1].depth;)r.pop();let o=i,s=typeof a.parentIndex==`number`?t.get(a.parentIndex):void 0,c=typeof s==`number`&&s<o?s:r[r.length-1]?.index;n.push({...a,index:o,depth:e,parentIndex:c}),r.push({depth:e,index:o})}return n}function x(e){return new Map(e.map(e=>[e.index,e]))}function S(e){return e.label?.trim()||e.value?.trim()||e.identifier?.trim()||``}function he(e){let t=e.trim().toLowerCase();return t?/^(vertical|horizontal)\s+scroll\s+bar(?:,?\s*\d+\s+pages?)?$/.test(t):!1}function ge(e,t){if(!(e?.trim().toLowerCase()??``).includes(`vertical scroll bar`))return null;let n=_e(t);return n===null?null:n<=1?{above:!1,below:!0}:n>=99?{above:!0,below:!1}:{above:!0,below:!0}}function _e(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}function C(e){let t=w(e.label),n=w(e.value),r=w(e.identifier),i=Se(r)?r:``;return E(e.type??``)?n||t||i:t||n||i}function ve(e,t){if(t===`text-view`||t===`text-field`||t===`search`)return!0;let n=T(e.type??``),r=`${e.role??``} ${e.subrole??``}`.toLowerCase();return n.includes(`textview`)||n.includes(`textarea`)||n.includes(`textfield`)||n.includes(`securetextfield`)||n.includes(`searchfield`)||n.includes(`edittext`)||r.includes(`text area`)||r.includes(`text field`)}function ye(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=48?t:`${t.slice(0,45)}...`}function be(e,t){let n=C(e),r=ve(e,t);return{text:n,isLargeSurface:r,shouldSummarize:r&&xe(n)}}function xe(e){return e?e.length>80||/[\r\n]/.test(e):!1}function w(e){return typeof e==`string`?e.trim():``}function T(e){let t=e.trim().replace(/XCUIElementType/gi,``).replace(/^AX/,``).toLowerCase(),n=Math.max(t.lastIndexOf(`.`),t.lastIndexOf(`/`));return n!==-1&&(t=t.slice(n+1)),t}function E(e){let t=T(e);return t.includes(`textfield`)||t.includes(`securetextfield`)||t.includes(`searchfield`)||t.includes(`edittext`)||t.includes(`textview`)||t.includes(`textarea`)}function Se(e){return e?!/^[\w.]+:id\/[\w.-]+$/i.test(e)&&!/^_?NS:\d+$/i.test(e):!1}function D(e,n){let r=t(n),i=e.filter(e=>we(e.rect)),a=i.filter(e=>{let t=(e.type??``).toLowerCase();return t.includes(`application`)||t.includes(`window`)});return k(a.map(e=>e.rect).filter(e=>O(e,r.x,r.y)))||k(a.map(e=>e.rect))||k(i.map(e=>e.rect).filter(e=>O(e,r.x,r.y)))||null}function Ce(e,t){return A(e.x,e.x+e.width,t.x,t.x+t.width)&&A(e.y,e.y+e.height,t.y,t.y+t.height)}function we(e){return e?Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height):!1}function O(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function k(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 A(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function j(e){let t=`${e??``}`.toLowerCase();return t.includes(`scroll`)||t.includes(`recyclerview`)||t.includes(`listview`)||t.includes(`gridview`)||t.includes(`collectionview`)||t===`table`}function M(e){return j(e.type)?!0:`${e.role??``} ${e.subrole??``}`.toLowerCase().includes(`scroll`)}function Te(e){if(e.length===0)return{nodes:e,hiddenCount:0,summaryLines:[]};let{byIndex:t,visibleNodeIndexes:n,offscreenNodes:r,hintedContainers:i}=N(e),a=n.size===0?e:e.filter(e=>n.has(e.index));return{nodes:a.map(e=>Ae(e,i.directionsByContainer)),hiddenCount:n.size===0?0:e.length-a.length,summaryLines:je(r.filter(e=>!i.coveredNodeIndexes.has(e.index)&&Ne(e)),e,t)}}function Ee(e){if(e.length===0)return new Map;let{hintedContainers:t}=N(e);return ke(t.directionsByContainer)}function N(e){let t=x(e),n=new Set,r=[];for(let i of e){if(P(i,e,t)){Fe(i,n,t);continue}r.push(i)}return{byIndex:t,visibleNodeIndexes:n,offscreenNodes:r,hintedContainers:Oe(e,r,n,t)}}function P(e,t,n=x(t)){if(!e.rect)return!0;let r=I(e,t,n);return r?Ce(e.rect,r):!0}function F(e,t,n=x(t)){if(!e.rect)return!0;if(!P(e,t,n))return!1;let r=D(t,e.rect);return De(e.rect,r)}function De(e,t){return!t||t.width<=0||t.height<=0?!0:O(t,e.x+e.width/2,e.y+e.height/2)}function I(e,t,n=x(t)){return Re(e,n)||D(t,e.rect??{x:0,y:0,width:0,height:0})}function Oe(e,t,n,r){let i=new Map,a=new Map,o=new Set;for(let e of t){if(!e.rect)continue;let t=R(e,n,r);if(!t?.rect)continue;let s=L(e.rect,t.rect);if(!s)continue;let c=i.get(t.index)??new Set;c.add(s),i.set(t.index,c);let l=a.get(t.index)??new Set;l.add(s),a.set(t.index,l),o.add(e.index)}return Ie(e,n,r,i,a),{directionsByContainer:i,coveredNodeIndexes:o}}function ke(e){let t=new Map;for(let[n,r]of e){let e={};r.has(`above`)&&(e.hiddenContentAbove=!0),r.has(`below`)&&(e.hiddenContentBelow=!0),(e.hiddenContentAbove||e.hiddenContentBelow)&&t.set(n,e)}return t}function Ae(e,t){let n=t.get(e.index);if(!n||n.size===0)return e;let r=e.hiddenContentAbove===!0||n.has(`above`)?!0:void 0,i=e.hiddenContentBelow===!0||n.has(`below`)?!0:void 0;return{...e,hiddenContentAbove:r,hiddenContentBelow:i}}function je(e,t,n){let r=new Map;for(let i of e){let e=Me(i,t,n);if(!e)continue;let a=r.get(e)??[];a.push(i),r.set(e,a)}return[`above`,`below`].flatMap(e=>{let t=r.get(e);if(!t||t.length===0)return[];let n=Pe(t).slice(0,3).map(e=>`"${e}"`),i=t.length===1?`interactive item`:`interactive items`,a=n.length>0?`: ${n.join(`, `)}`:``;return[`[off-screen ${e}] ${t.length} ${i}${a}`]})}function Me(e,t,n){if(!e.rect)return null;let r=I(e,t,n);return r?L(e.rect,r):null}function L(e,t){return e.y+e.height<=t.y?`above`:e.y>=t.y+t.height?`below`:null}function Ne(e){if(e.hittable===!0)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`)||!!S(e)}function Pe(e){let t=new Set,n=[];for(let r of e){let e=S(r);!e||t.has(e)||(t.add(e),n.push(e))}return n}function Fe(e,t,n){let r=e,i=new Set;for(;r&&!i.has(r.index);)i.add(r.index),t.add(r.index),r=typeof r.parentIndex==`number`?n.get(r.parentIndex):void 0}function R(e,t,n){return ze(e,n,e=>t.has(e.index))}function Ie(e,t,n,r,i){for(let a of e){let e=Le(a);if(!e||e.size===0)continue;let o=R(a,t,n);if(!o)continue;let s=r.get(o.index)??new Set,c=i.get(o.index);for(let t of e)c&&c.size>0&&!c.has(t)||s.add(t);r.set(o.index,s)}}function Le(e){let t=ge(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}function Re(e,t){return ze(e,t,e=>!!e.rect)?.rect??null}function ze(e,t,n){let r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(i.add(r.index),n(r)&&M(r))return r;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return null}function z(e){return!!(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0)}function Be(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function Ve(e){return e.width*e.height}function He(e,t){let n=t.toLowerCase();return e.find(e=>{let t=(e.label??``).toLowerCase(),r=(e.value??``).toLowerCase(),i=(e.identifier??``).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)})??null}function Ue(e,t){let n=[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).find(e=>e&&e.length>0);return n&&B(n)?n:We(e,t)??(n&&B(n)?n:void 0)}function B(e){let t=e.trim();return!(!t||/^(true|false)$/i.test(t)||/^\d+$/.test(t))}function We(e,t){if(!e.rect)return;let n=e.rect.y+e.rect.height/2,r=null;for(let e of t){if(!e.rect)continue;let t=[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).find(e=>e&&e.length>0);if(!t||!B(t))continue;let i=e.rect.y+e.rect.height/2,a=Math.abs(i-n);(!r||a<r.distance)&&(r={label:t,distance:a})}return r?.label}function Ge(e){let t=[],n=[];for(let r of e){let e=r.depth??0;for(;t.length>0&&e<=t[t.length-1];)t.pop();let i=T(r.type??``),a=[r.label,r.value,r.identifier].map(e=>typeof e==`string`?e.trim():``).find(e=>e&&e.length>0),o=a?B(a):!1;if((i===`group`||i===`ioscontentgroup`)&&!o){t.push(e);continue}let s=Math.max(0,e-t.length);n.push({...r,depth:s})}return n}function Ke(e,t){let n=T(e);return n?t===`android`?n.includes(`edittext`)||n.includes(`autocompletetextview`):n.includes(`textfield`)||n.includes(`securetextfield`)||n.includes(`searchfield`)||n.includes(`textview`)||n.includes(`textarea`)||n===`search`:!0}function qe(e,t){return t.hittable?t:Ye(e,t,e=>e.hittable===!0)}function V(e){return new Map(e.map(e=>[e.index,e]))}function H(e,t,n,r){let i=t,a=new Set;for(;typeof i.parentIndex==`number`&&!a.has(i.index);){if(a.add(i.index),i=n.get(i.parentIndex)??e[i.parentIndex],!i)return null;let t=r(i);if(t!==null)return t}return null}function Je(e,t,n,r){return!!H(e,t,r,e=>e===n||e.index===n.index?e:null)}function Ye(e,t,n){return H(e,t,V(e),e=>n(e)?e:null)}function U(e){return[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).filter(e=>e.length>0)[0]??``}function Xe(e){return C(e)}function W(e){return e.hittable===!0?!0:e.rect?e.rect.width>0&&e.rect.height>0:!1}function G(e,t){return Ke(e.type??``,t)&&e.enabled!==!1}function K(e){return[`visible`,`hidden`,`exists`,`editable`,`selected`,`focused`,`text`].includes(e)}const Ze=`is requires predicate: visible|hidden|exists|editable|selected|focused|text`,Qe=`Use "is <predicate> <selector>" or "is <selector> <predicate>". visible|hidden|editable|selected|focused double as selector keys: a bare predicate token after the selector is read as the predicate, so write key=true (e.g. visible=true) inside the selector to use it as a filter instead.`;function $e(e){if(K((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(K(n)&&r(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function et(e){let{predicate:t,node:n,nodes:r,expectedText:i,platform:a}=e,o=U(n),s=G(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?W(n):tt(n,r,a),d=!1;switch(t){case`visible`:d=u;break;case`hidden`:d=!u;break;case`editable`:d=s;break;case`selected`:d=c;break;case`focused`:d=l;break;case`text`:d=o===(i??``);break}let f=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:f}}function tt(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(z(e.rect))return nt(e,t);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=rt(e,t,n);return r?z(r.rect)?nt(r,t):n!==`android`&&r.hittable===!0:!1}function nt(e,t){return P(e,t)}function rt(e,t,n){return H(t,e,V(t),e=>it(e,n)?e:null)}function it(e,t){if(t===`android`&&e.visibleToUser===!1)return!1;let n=T(e.type??``);return n.includes(`application`)||n.includes(`window`)||n.includes(`scrollview`)||n.includes(`tableview`)||n.includes(`collectionview`)||n===`table`||n===`list`||n===`listview`?!1:t===`android`?e.hittable===!0&&z(e.rect):e.hittable===!0||z(e.rect)}function at(e){let t=$e(e),r=t[0]??``;return{predicate:r,split:n(t.slice(1),{preferTrailingValue:r===`text`})}}function q(e,t,n){return t.terms.every(t=>ot(e,t,n))}function ot(e,t,n){switch(t.key){case`id`:return J(e.identifier,String(t.value));case`role`:return J(T(e.type??``),String(t.value));case`label`:return J(e.label,String(t.value));case`value`:return J(e.value,String(t.value));case`text`:return J(U(e),String(t.value));case`appname`:return J(e.appName,String(t.value));case`windowtitle`:return J(e.windowTitle,String(t.value));case`visible`:return W(e)===!!t.value;case`hidden`:return!W(e)==!!t.value;case`editable`:return G(e,n)===!!t.value;case`selected`:return e.selected===!0==!!t.value;case`focused`:return e.focused===!0==!!t.value;case`enabled`:return e.enabled!==!1==!!t.value;case`hittable`:return e.hittable===!0==!!t.value;default:return!1}}function J(e,t){return i(e??``)===i(t)}function st(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[];for(let[o,s]of t.selectors.entries()){let t=pt(e,s,n.platform,r);if(a.push({selector:s.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{node:t.disambiguated,selector:s,selectorIndex:o,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}return{node:t.firstNode,selector:s,selectorIndex:o,matches:t.count,diagnostics:a}}}return null}function ct(e,t,n){let r=n.requireRect??!1;for(let[i,a]of t.selectors.entries()){let t=e.filter(e=>r&&!e.rect?!1:q(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function lt(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=gt(e,o,n.platform,r);if(i.push({selector:o.raw,matches:t}),t>0)return{selectorIndex:a,selector:o,matches:t,diagnostics:i}}return null}const ut=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function dt(e){return e.some(e=>e.matches>1)?`Add more terms to disambiguate (e.g. role=button text="Sign in"), use an @ref from snapshot -i, or use find <text> --first/--last.`:`Selector text/label values match exactly (quote multi-word values: text="Sign in"). Run snapshot -i to see current elements and refs, or use find <text> for contains matching.`}function ft(e,t,n){if(t.length===0)return`Selector did not match: ${e.raw}`;let r=t.map(e=>`${e.selector} -> ${e.matches}`).join(`, `);return n.unique??!0?`Selector did not resolve uniquely (${r})`:`Selector did not match (${r})`}function pt(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c,l=t=>(c??=x(e),F(t,e,c));for(let c of e)r&&!c.rect||q(c,t,n)&&(i+=1,a??=c,o.push(c),mt(s,c,l));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:ht(o,s.best,l),candidates:o}}function mt(e,t,n){if(!e.best){e.best=t;return}e.bestVisible||=n(e.best);let r=n(t);if(r!==e.bestVisible){r&&(e.best=t,e.bestVisible=!0,e.tie=!1);return}let i=_t(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function ht(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||Y(i,r,n).result>0)&&(r=i);return r?Y(t,r,n).criterion:null}function Y(e,t,n){let r=n(e);return r===n(t)?_t(e,t):{result:r?1:-1,criterion:`visible`}}function gt(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||q(a,t,n)&&(i+=1);return i}function _t(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=vt(e),a=vt(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function vt(e){return e.rect?e.rect.width*e.rect.height:1/0}function X(e){let t=l(T(e.type??``)),n=c(e.identifier),r=u(e.label);return{...n===void 0?{}:{id:f(n,256)},role:f(t,256),...r===void 0?{}:{label:f(r,256)}}}function yt(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function bt(e,t){let n=0;for(let r of e)X(r).id===t&&(n+=1);return n}function xt(e,t){if(e.id===void 0||bt(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function Z(e,t){let n=0;for(let r of e)if(r.parentIndex===t.parentIndex){if(r.index===t.index)return n;n+=1}return 0}function St(e,t){return{documentOrder:e.index,sibling:Z(t,e)}}function Ct(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}const wt=`replay_target_guard_mismatch`;function Tt(e,t,n={}){let r=[],i=T(e.type??``),a=Et(e,n.nodes),o=$(e.label),s=$(e.value),c=$(U(e)),l=n.action===`fill`;a&&r.push(`id=${Q(a)}`),i&&o&&r.push(l?`role=${Q(i)} label=${Q(o)} editable=true`:`role=${Q(i)} label=${Q(o)}`),o&&r.push(l?`label=${Q(o)} editable=true`:`label=${Q(o)}`),s&&r.push(l?`value=${Q(s)} editable=true`:`value=${Q(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${Q(c)} editable=true`:`text=${Q(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${Q(i)} editable=true`);let u=Dt(r);return u.length===0&&i&&u.push(l?`role=${Q(i)} editable=true`:`role=${Q(i)}`),u.length===0&&W(e)&&u.push(`visible=true`),u}function Et(e,t){let n=$(e.identifier);if(!n||!t)return n;let r=X(e).id;return r===void 0?n:bt(t,r)>1?null:n}function Dt(e){return Array.from(new Set(e))}function Q(e){return JSON.stringify(e)}function $(e){return e&&e.trim()||null}export{w as $,He as A,P as B,G as C,U as D,Xe as E,z as F,O as G,I as H,Ve as I,ye as J,k as K,Be as L,Ke as M,Ge as N,Ye as O,Ue as P,E as Q,Te as R,$e as S,V as T,M as U,F as V,j as W,C as X,be as Y,T as Z,at as _,yt as a,o as at,et as b,Z as c,fe as ct,lt as d,ne as dt,ge as et,ft as f,d as ft,q as g,dt as h,xt as i,me as it,Je as j,qe as k,Ct as l,de as lt,st as m,$ as n,x as nt,X as o,pe as ot,ct as p,D as q,wt as r,S as rt,St as s,re as st,Tt as t,he as tt,ut as u,ie as ut,Ze as v,W as w,K as x,Qe as y,Ee as z};
1
+ import{_ as e,u as t}from"./sdk-contracts.js";import{$ as n,G as r,et as i}from"./sdk-batch-runner.js";const a=/^#\s*agent-device:target-v(\d+)(?:\s+(.*))?$/,o=4096;function s(e){return e.normalize(`NFC`)}function c(e){if(e===void 0)return;let t=s(e);return t.length>0?t:void 0}function l(e){return s(e)}function u(e){if(e===void 0)return;let t=s(e).trim().replace(/\s+/g,` `);return t.length>0?t:void 0}function d(e){return Buffer.byteLength(e,`utf8`)}function f(e,t){if(d(e)<=t)return e;let n=e.length;for(;n>0&&d(e.slice(0,n))>t;)--n;if(n>0){let t=e.charCodeAt(n-1);t>=55296&&t<=56319&&--n}return e.slice(0,n)}function p(e){let t={};return e.id!==void 0&&(t.id=e.id),t.role=e.role,e.label!==void 0&&(t.label=e.label),t.ancestry=e.ancestry.map(ee),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=te(e.scrollRegion)),e.rect&&(t.rect=ne(e.rect)),t.verification=e.verification,t}function ee(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function te(e){let t={role:e.role};return e.id!==void 0&&(t.id=e.id),e.label!==void 0&&(t.label=e.label),t}function ne(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function m(e){return JSON.stringify(p(e))}function re(e){return`# agent-device:target-v1 ${m(e)}`}function ie(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=a.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:ae((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function ae(t){if(d(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${o}-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`target-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`target-v1 annotation must be a JSON object.`);let r=n,i=h(r.role,`role`),a=g(r.id,`id`),s=_(r.label,`label`),c=oe(r.ancestry),l=ce(r.sibling,`sibling`,0),u=ce(r.viewportOrder,`viewportOrder`,0),f=le(r.scrollRegion),p=ue(r.rect),ee=de(r.verification);return{...a===void 0?{}:{id:a},role:i,...s===void 0?{}:{label:s},ancestry:c,sibling:l,viewportOrder:u,...f?{scrollRegion:f}:{},...p?{rect:p}:{},verification:ee}}function h(t,n){if(t===void 0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" is required.`);if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);return v(l(t),n)}function g(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=c(t);return r===void 0?void 0:v(r,n)}function _(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=u(t);return r===void 0?void 0:v(r,n)}function v(t,n){if(d(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function oe(t){if(t===void 0)return[];if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry" must be an array.`);if(t.length>8)throw new e(`INVALID_ARGS`,`target-v1 "ancestry" exceeds the 8-entry cap.`);return t.map((e,t)=>se(e,t))}function se(t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry[${n}]" must be an object.`);let r=t,i=h(r.role,`ancestry[${n}].role`),a=_(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function ce(t,n,r){if(t===void 0)return r;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a non-negative integer.`);return t}function le(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "scrollRegion" must be an object.`);let n=t,r=h(n.role,`scrollRegion.role`),i=g(n.id,`id`),a=_(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function ue(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "rect" must be an object.`);let n=t;return{x:y(n.x,`rect.x`),y:y(n.y,`rect.y`),width:y(n.width,`rect.width`),height:y(n.height,`rect.height`)}}function y(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a finite number.`);return t}function de(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function fe(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function pe(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function me(e,t){if(e.length<t.length)return!1;for(let[n,r]of t.entries()){let t=e[n];if(!t||t.role!==r.role||r.label!==void 0&&t.label!==r.label)return!1}return!0}function he(e){return e.matchedRefs.length===0?{path:2,outcome:`unverifiable`,reason:`selector-miss`}:e.identitySetRefs.length===0?{path:3,outcome:`unverifiable`,reason:`identity-set-empty`}:e.identitySetRefs.length===1?e.identitySetRefs[0]===e.winnerRef?{path:4,outcome:`verified`}:{path:5,outcome:`unverifiable`,reason:`unique-but-wrong`}:e.siblingMatchRefs.length===1?e.siblingMatchRefs[0]===e.winnerRef?{path:6,outcome:`verified`}:{path:6,outcome:`unverifiable`,reason:`signal-isolated-wrong`}:e.regionMemberRefs!==void 0&&e.regionMemberRefs.length>0&&e.viewportCandidateRef!==void 0?e.viewportCandidateRef===e.winnerRef?{path:6,outcome:`verified`}:{path:6,outcome:`unverifiable`,reason:`signal-isolated-wrong`}:{path:6,outcome:`unverifiable`,reason:`no-signal-isolation`}}function ge(e){let t=new Map;for(let[n,r]of e.entries())t.set(r.index,n);let n=[],r=[];for(let[i,a]of e.entries()){let e=Math.max(0,a.depth??0);for(;r.length>0&&e<=r[r.length-1].depth;)r.pop();let o=i,s=typeof a.parentIndex==`number`?t.get(a.parentIndex):void 0,c=typeof s==`number`&&s<o?s:r[r.length-1]?.index;n.push({...a,index:o,depth:e,parentIndex:c}),r.push({depth:e,index:o})}return n}function b(e){return new Map(e.map(e=>[e.index,e]))}function x(e){return e.label?.trim()||e.value?.trim()||e.identifier?.trim()||``}function _e(e){let t=e.trim().toLowerCase();return t?/^(vertical|horizontal)\s+scroll\s+bar(?:,?\s*\d+\s+pages?)?$/.test(t):!1}function ve(e,t){if(!(e?.trim().toLowerCase()??``).includes(`vertical scroll bar`))return null;let n=ye(t);return n===null?null:n<=1?{above:!1,below:!0}:n>=99?{above:!0,below:!1}:{above:!0,below:!0}}function ye(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}function S(e){let t=C(e.label),n=C(e.value),r=C(e.identifier),i=Te(r)?r:``;return we(e.type??``)?n||t||i:t||n||i}function be(e,t){if(t===`text-view`||t===`text-field`||t===`search`)return!0;let n=w(e.type??``),r=`${e.role??``} ${e.subrole??``}`.toLowerCase();return n.includes(`textview`)||n.includes(`textarea`)||n.includes(`textfield`)||n.includes(`securetextfield`)||n.includes(`searchfield`)||n.includes(`edittext`)||r.includes(`text area`)||r.includes(`text field`)}function xe(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=48?t:`${t.slice(0,45)}...`}function Se(e,t){let n=S(e),r=be(e,t);return{text:n,isLargeSurface:r,shouldSummarize:r&&Ce(n)}}function Ce(e){return e?e.length>80||/[\r\n]/.test(e):!1}function C(e){return typeof e==`string`?e.trim():``}function w(e){let t=e.trim().replace(/XCUIElementType/gi,``).replace(/^AX/,``).toLowerCase(),n=Math.max(t.lastIndexOf(`.`),t.lastIndexOf(`/`));return n!==-1&&(t=t.slice(n+1)),t}function we(e){let t=w(e);return t.includes(`textfield`)||t.includes(`securetextfield`)||t.includes(`searchfield`)||t.includes(`edittext`)||t.includes(`textview`)||t.includes(`textarea`)}function Te(e){return e?!/^[\w.]+:id\/[\w.-]+$/i.test(e)&&!/^_?NS:\d+$/i.test(e):!1}function T(e,n){let r=t(n),i=e.filter(e=>Ee(e.rect)),a=i.filter(e=>{let t=(e.type??``).toLowerCase();return t.includes(`application`)||t.includes(`window`)});return O(a.map(e=>e.rect).filter(e=>D(e,r.x,r.y)))||O(a.map(e=>e.rect))||O(i.map(e=>e.rect).filter(e=>D(e,r.x,r.y)))||null}function E(e,t){return k(e.x,e.x+e.width,t.x,t.x+t.width)&&k(e.y,e.y+e.height,t.y,t.y+t.height)}function Ee(e){return e?Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height):!1}function D(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function O(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 k(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function A(e){let t=`${e??``}`.toLowerCase();return t.includes(`scroll`)||t.includes(`recyclerview`)||t.includes(`listview`)||t.includes(`gridview`)||t.includes(`collectionview`)||t===`table`}function j(e){return A(e.type)?!0:`${e.role??``} ${e.subrole??``}`.toLowerCase().includes(`scroll`)}function De(e){if(e.length===0)return{nodes:e,hiddenCount:0,summaryLines:[]};let{byIndex:t,visibleNodeIndexes:n,offscreenNodes:r,hintedContainers:i}=M(e),a=n.size===0?e:e.filter(e=>n.has(e.index));return{nodes:a.map(e=>Me(e,i.directionsByContainer)),hiddenCount:n.size===0?0:e.length-a.length,summaryLines:Ne(r.filter(e=>!i.coveredNodeIndexes.has(e.index)&&Ie(e)),e,t)}}function Oe(e){if(e.length===0)return new Map;let{hintedContainers:t}=M(e);return je(t.directionsByContainer)}function M(e){let t=b(e),n=new Set,r=[];for(let i of e){if(N(i,e,t)){Re(i,n,t);continue}r.push(i)}return{byIndex:t,visibleNodeIndexes:n,offscreenNodes:r,hintedContainers:Ae(e,r,n,t)}}function N(e,t,n=b(t)){if(!e.rect)return!0;let r=I(e,t,n);return r?E(e.rect,r):!0}function P(e,t,n=b(t)){if(!e.rect)return!0;if(!N(e,t,n))return!1;let r=T(t,e.rect);return F(e.rect,r)}function F(e,t){return!t||t.width<=0||t.height<=0?!0:D(t,e.x+e.width/2,e.y+e.height/2)}function I(e,t,n=b(t)){return He(e,n)||T(t,e.rect??{x:0,y:0,width:0,height:0})}function ke(e,t,n=b(t)){if(!e.rect)return null;let r=I(e,t,n);if(r&&!E(e.rect,r)){let t=L(e.rect,r);if(t)return t}let i=T(t,e.rect);if(i&&!F(e.rect,i)){let t=L(e.rect,i);if(t)return t}return null}function L(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=[{direction:`down`,amount:r-(t.y+t.height)},{direction:`up`,amount:t.y-r},{direction:`right`,amount:n-(t.x+t.width)},{direction:`left`,amount:t.x-n}],a=null;for(let e of i)e.amount>0&&(!a||e.amount>a.amount)&&(a=e);return a?.direction??null}function Ae(e,t,n,r){let i=new Map,a=new Map,o=new Set;for(let e of t){if(!e.rect)continue;let t=ze(e,n,r);if(!t?.rect)continue;let s=Fe(e.rect,t.rect);if(!s)continue;let c=i.get(t.index)??new Set;c.add(s),i.set(t.index,c);let l=a.get(t.index)??new Set;l.add(s),a.set(t.index,l),o.add(e.index)}return Be(e,n,r,i,a),{directionsByContainer:i,coveredNodeIndexes:o}}function je(e){let t=new Map;for(let[n,r]of e){let e={};r.has(`above`)&&(e.hiddenContentAbove=!0),r.has(`below`)&&(e.hiddenContentBelow=!0),(e.hiddenContentAbove||e.hiddenContentBelow)&&t.set(n,e)}return t}function Me(e,t){let n=t.get(e.index);if(!n||n.size===0)return e;let r=e.hiddenContentAbove===!0||n.has(`above`)?!0:void 0,i=e.hiddenContentBelow===!0||n.has(`below`)?!0:void 0;return{...e,hiddenContentAbove:r,hiddenContentBelow:i}}function Ne(e,t,n){let r=new Map;for(let i of e){let e=Pe(i,t,n);if(!e)continue;let a=r.get(e)??[];a.push(i),r.set(e,a)}return[`above`,`below`].flatMap(e=>{let t=r.get(e);if(!t||t.length===0)return[];let n=Le(t).slice(0,3).map(e=>`"${e}"`),i=t.length===1?`interactive item`:`interactive items`,a=n.length>0?`: ${n.join(`, `)}`:``;return[`[off-screen ${e}] ${t.length} ${i}${a}`]})}function Pe(e,t,n){if(!e.rect)return null;let r=I(e,t,n);return r?Fe(e.rect,r):null}function Fe(e,t){return e.y+e.height<=t.y?`above`:e.y>=t.y+t.height?`below`:null}function Ie(e){if(e.hittable===!0)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`)||!!x(e)}function Le(e){let t=new Set,n=[];for(let r of e){let e=x(r);!e||t.has(e)||(t.add(e),n.push(e))}return n}function Re(e,t,n){let r=e,i=new Set;for(;r&&!i.has(r.index);)i.add(r.index),t.add(r.index),r=typeof r.parentIndex==`number`?n.get(r.parentIndex):void 0}function ze(e,t,n){return Ue(e,n,e=>t.has(e.index))}function Be(e,t,n,r,i){for(let a of e){let e=Ve(a);if(!e||e.size===0)continue;let o=ze(a,t,n);if(!o)continue;let s=r.get(o.index)??new Set,c=i.get(o.index);for(let t of e)c&&c.size>0&&!c.has(t)||s.add(t);r.set(o.index,s)}}function Ve(e){let t=ve(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}function He(e,t){return Ue(e,t,e=>!!e.rect)?.rect??null}function Ue(e,t,n){let r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(i.add(r.index),n(r)&&j(r))return r;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return null}function R(e,t){return{ok:!1,code:`INVALID_ARGS`,message:e,...t?{hint:t}:{}}}function z(e){return!!(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0)}function We(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function Ge(e){return e.width*e.height}function Ke(e,t){let n=t.toLowerCase();return e.find(e=>{let t=(e.label??``).toLowerCase(),r=(e.value??``).toLowerCase(),i=(e.identifier??``).toLowerCase();return t.includes(n)||r.includes(n)||i.includes(n)})??null}function qe(e,t){let n=[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).find(e=>e&&e.length>0);return n&&B(n)?n:Je(e,t)??(n&&B(n)?n:void 0)}function B(e){let t=e.trim();return!(!t||/^(true|false)$/i.test(t)||/^\d+$/.test(t))}function Je(e,t){if(!e.rect)return;let n=e.rect.y+e.rect.height/2,r=null;for(let e of t){if(!e.rect)continue;let t=[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).find(e=>e&&e.length>0);if(!t||!B(t))continue;let i=e.rect.y+e.rect.height/2,a=Math.abs(i-n);(!r||a<r.distance)&&(r={label:t,distance:a})}return r?.label}function Ye(e){let t=[],n=[];for(let r of e){let e=r.depth??0;for(;t.length>0&&e<=t[t.length-1];)t.pop();let i=w(r.type??``),a=[r.label,r.value,r.identifier].map(e=>typeof e==`string`?e.trim():``).find(e=>e&&e.length>0),o=a?B(a):!1;if((i===`group`||i===`ioscontentgroup`)&&!o){t.push(e);continue}let s=Math.max(0,e-t.length);n.push({...r,depth:s})}return n}function V(e,t){let n=w(e);return n?t===`android`?n.includes(`edittext`)||n.includes(`autocompletetextview`):n.includes(`textfield`)||n.includes(`securetextfield`)||n.includes(`searchfield`)||n.includes(`textview`)||n.includes(`textarea`)||n===`search`:!0}function Xe(e,t){return t.hittable?t:W(e,t,e=>e.hittable===!0)}function H(e){return new Map(e.map(e=>[e.index,e]))}function U(e,t,n,r){let i=t,a=new Set;for(;typeof i.parentIndex==`number`&&!a.has(i.index);){if(a.add(i.index),i=n.get(i.parentIndex)??e[i.parentIndex],!i)return null;let t=r(i);if(t!==null)return t}return null}function Ze(e,t,n,r){return!!U(e,t,r,e=>e===n||e.index===n.index?e:null)}function W(e,t,n){return U(e,t,H(e),e=>n(e)?e:null)}function G(e){return[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).filter(e=>e.length>0)[0]??``}function Qe(e){return S(e)}function K(e){return e.hittable===!0?!0:e.rect?e.rect.width>0&&e.rect.height>0:!1}function q(e,t){return V(e.type??``,t)&&e.enabled!==!1}function J(e){return[`visible`,`hidden`,`exists`,`editable`,`selected`,`focused`,`text`].includes(e)}function $e(e){let t=e.toLowerCase();return J(t)?{ok:!0,predicate:t}:R(`is requires predicate: visible|hidden|exists|editable|selected|focused|text`,et)}const et=`Use "is <predicate> <selector>" or "is <selector> <predicate>". visible|hidden|editable|selected|focused double as selector keys: a bare predicate token after the selector is read as the predicate, so write key=true (e.g. visible=true) inside the selector to use it as a filter instead.`;function tt(e){if(J((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(J(n)&&i(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function nt(e){let{predicate:t,node:n,nodes:r,expectedText:i,platform:a}=e,o=G(n),s=q(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?K(n):rt(n,r,a),d=!1;switch(t){case`visible`:d=u;break;case`hidden`:d=!u;break;case`editable`:d=s;break;case`selected`:d=c;break;case`focused`:d=l;break;case`text`:d=o===(i??``);break}let f=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:f}}function rt(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(z(e.rect))return it(e,t);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=at(e,t,n);return r?z(r.rect)?it(r,t):n!==`android`&&r.hittable===!0:!1}function it(e,t){return N(e,t)}function at(e,t,n){return U(t,e,H(t),e=>ot(e,n)?e:null)}function ot(e,t){if(t===`android`&&e.visibleToUser===!1)return!1;let n=w(e.type??``);return n.includes(`application`)||n.includes(`window`)||n.includes(`scrollview`)||n.includes(`tableview`)||n.includes(`collectionview`)||n===`table`||n===`list`||n===`listview`?!1:t===`android`?e.hittable===!0&&z(e.rect):e.hittable===!0||z(e.rect)}function st(e){let t=tt(e),r=t[0]??``;return{predicate:r,split:n(t.slice(1),{preferTrailingValue:r===`text`})}}const ct=`is requires a selector expression`,lt=`is text requires expected text value`;function ut(e){let{predicate:t,split:n}=st([...e]),r=$e(t);if(!r.ok)return r;if(!n)return R(ct);let i=n.rest.join(` `).trim();return r.predicate===`text`&&!i?R(lt):r.predicate!==`text`&&n.rest.length>0?R(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:i}}function dt(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:R(`get only supports text or attrs`)}function ft(e){let t=e[0];if(t?.startsWith(`@`)){let n=e.slice(1).join(` `).trim();return{ok:!0,ref:t,...n?{label:n}:{}}}let n=e.join(` `).trim();return n?{ok:!0,selector:n}:R(`get requires @ref or selector expression`)}function pt(e){return e?{ok:!0,text:e}:R(`wait requires text`)}function Y(e,t,n){return t.terms.every(t=>mt(e,t,n))}function mt(e,t,n){switch(t.key){case`id`:return X(e.identifier,String(t.value));case`role`:return X(w(e.type??``),String(t.value));case`label`:return X(e.label,String(t.value));case`value`:return X(e.value,String(t.value));case`text`:return X(G(e),String(t.value));case`appname`:return X(e.appName,String(t.value));case`windowtitle`:return X(e.windowTitle,String(t.value));case`visible`:return K(e)===!!t.value;case`hidden`:return!K(e)==!!t.value;case`editable`:return q(e,n)===!!t.value;case`selected`:return e.selected===!0==!!t.value;case`focused`:return e.focused===!0==!!t.value;case`enabled`:return e.enabled!==!1==!!t.value;case`hittable`:return e.hittable===!0==!!t.value;default:return!1}}function X(e,t){return r(e??``)===r(t)}function ht(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[];for(let[o,s]of t.selectors.entries()){let t=xt(e,s,n.platform,r);if(a.push({selector:s.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{node:t.disambiguated,selector:s,selectorIndex:o,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}return{node:t.firstNode,selector:s,selectorIndex:o,matches:t.count,diagnostics:a}}}return null}function gt(e,t,n){let r=n.requireRect??!1;for(let[i,a]of t.selectors.entries()){let t=e.filter(e=>r&&!e.rect?!1:Y(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function _t(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=Tt(e,o,n.platform,r);if(i.push({selector:o.raw,matches:t}),t>0)return{selectorIndex:a,selector:o,matches:t,diagnostics:i}}return null}const vt=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function yt(e){return e.some(e=>e.matches>1)?`Add more terms to disambiguate (e.g. role=button text="Sign in"), use an @ref from snapshot -i, or use find <text> --first/--last.`:`Selector text/label values match exactly (quote multi-word values: text="Sign in"). Run snapshot -i to see current elements and refs, or use find <text> for contains matching.`}function bt(e,t,n){if(t.length===0)return`Selector did not match: ${e.raw}`;let r=t.map(e=>`${e.selector} -> ${e.matches}`).join(`, `);return n.unique??!0?`Selector did not resolve uniquely (${r})`:`Selector did not match (${r})`}function xt(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c,l=t=>(c??=b(e),P(t,e,c));for(let c of e)r&&!c.rect||Y(c,t,n)&&(i+=1,a??=c,o.push(c),St(s,c,l));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:Ct(o,s.best,l),candidates:o}}function St(e,t,n){if(!e.best){e.best=t;return}e.bestVisible||=n(e.best);let r=n(t);if(r!==e.bestVisible){r&&(e.best=t,e.bestVisible=!0,e.tie=!1);return}let i=Et(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function Ct(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||wt(i,r,n).result>0)&&(r=i);return r?wt(t,r,n).criterion:null}function wt(e,t,n){let r=n(e);return r===n(t)?Et(e,t):{result:r?1:-1,criterion:`visible`}}function Tt(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||Y(a,t,n)&&(i+=1);return i}function Et(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=Dt(e),a=Dt(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function Dt(e){return e.rect?e.rect.width*e.rect.height:1/0}function Z(e){let t=l(w(e.type??``)),n=c(e.identifier),r=u(e.label);return{...n===void 0?{}:{id:f(n,256)},role:f(t,256),...r===void 0?{}:{label:f(r,256)}}}function Ot(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function kt(e,t){let n=0;for(let r of e)Z(r).id===t&&(n+=1);return n}function At(e,t){if(e.id===void 0||kt(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function jt(e,t){let n=0;for(let r of e)if(r.parentIndex===t.parentIndex){if(r.index===t.index)return n;n+=1}return 0}function Mt(e,t){return{documentOrder:e.index,sibling:jt(t,e)}}function Nt(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}const Pt=`replay_target_guard_mismatch`,Ft=`wait_landmark_identity_mismatch`;function It(e,t,n={}){let r=[],i=w(e.type??``),a=Lt(e,n.nodes),o=$(e.label),s=$(e.value),c=$(G(e)),l=n.action===`fill`;a&&r.push(`id=${Q(a)}`),i&&o&&r.push(l?`role=${Q(i)} label=${Q(o)} editable=true`:`role=${Q(i)} label=${Q(o)}`),o&&r.push(l?`label=${Q(o)} editable=true`:`label=${Q(o)}`),s&&r.push(l?`value=${Q(s)} editable=true`:`value=${Q(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${Q(c)} editable=true`:`text=${Q(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${Q(i)} editable=true`);let u=Rt(r);return u.length===0&&i&&u.push(l?`role=${Q(i)} editable=true`:`role=${Q(i)}`),u.length===0&&K(e)&&u.push(`visible=true`),u}function Lt(e,t){let n=$(e.identifier);if(!n||!t)return n;let r=Z(e).id;return r===void 0?n:kt(t,r)>1?null:n}function Rt(e){return Array.from(new Set(e))}function Q(e){return JSON.stringify(e)}function $(e){return e&&e.trim()||null}export{T as $,H as A,z as B,pt as C,tt as D,nt as E,Ke as F,Oe as G,We as H,Ze as I,I as J,N as K,V as L,G as M,W as N,q as O,Xe as P,O as Q,Ye as R,ut as S,$e as T,De as U,Ge as V,ke as W,A as X,j as Y,D as Z,Y as _,ie as _t,At as a,C as at,ft as b,Mt as c,b as ct,vt as d,o as dt,xe as et,_t as f,fe as ft,yt as g,pe as gt,ht as h,me as ht,Ft as i,we as it,Qe as j,K as k,jt as l,x as lt,gt as m,re as mt,$ as n,S as nt,Ot as o,ve as ot,bt as p,he as pt,P as q,Pt as r,w as rt,Z as s,_e as st,It as t,Se as tt,Nt as u,ge as ut,lt as v,m as vt,st as w,dt as x,ct as y,d as yt,qe as z};