@flowriki/agent 0.1.0-beta.22 → 0.1.0-beta.23

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.
@@ -1 +1 @@
1
- "use strict";(()=>{function U(e,t,i){function l(n){let u=e.__flAccName;if(u){let a=u(n);return a||t(n.placeholder)||t(n.title)||""}return y(n)}function y(n){let u=n.getAttribute&&n.getAttribute("aria-labelledby");if(u){let m=u.split(/\s+/).map(b=>document.getElementById(b)).filter(Boolean).map(b=>t(b.textContent)).filter(Boolean).join(" ");if(m)return m}let a=t(n.getAttribute&&n.getAttribute("aria-label"));if(a)return a;if(n.id){let m=document.querySelector('label[for="'+CSS.escape(n.id)+'"]');if(m&&t(m.textContent))return t(m.textContent)}let o=n.closest&&n.closest("label");if(o&&t(o.textContent))return t(o.textContent);let s=n.tagName.toLowerCase(),p=(n.type||"").toLowerCase();return(["button","a","summary"].includes(s)||n.getAttribute&&n.getAttribute("role")==="button")&&t(n.textContent)?t(n.textContent):s==="input"&&["submit","button","reset"].includes(p)&&n.value?t(n.value):t(n.placeholder)||t(n.title)||""}let E="input,select,textarea,button,meter,output,progress,[contenteditable]";function v(n){let u=n.parentElement;if(!u||!n.matches?.(E))return"";for(let a of Array.from(u.querySelectorAll("label"))){let o=a.getAttribute("for");if(o&&document.getElementById(o))continue;let s=t(a.textContent);if(s)return s}return""}let x=new WeakMap,_=crypto.randomUUID(),j=0;function L(n){let u=n.getRootNode(),a=h=>u.querySelectorAll(h).length===1,o=[],s=n.getAttribute?.("data-testid");s&&a(`[data-testid=${JSON.stringify(s)}]`)&&o.push({strategy:"testId",value:s});let p=t(n.placeholder);p&&a(`[placeholder=${JSON.stringify(n.placeholder)}]`)&&o.push({strategy:"placeholder",value:p});let m=t(n.getAttribute?.("alt"));m&&a(`[alt=${JSON.stringify(n.getAttribute("alt"))}]`)&&o.push({strategy:"altText",value:m});let b=n.getAttribute?.("title");return b&&a(`[title=${JSON.stringify(b)}]`)&&o.push({strategy:"title",value:t(b)}),n.id&&!/:r|[a-f0-9]{12}|\d{6}/i.test(n.id)&&a(`#${CSS.escape(n.id)}`)&&o.push({strategy:"css",value:`#${CSS.escape(n.id)}`}),o.slice(0,4)}function C(n){let u=x.get(n);u||(u=`${_}:${++j}`,x.set(n,u));let a=L(n),o={__targetId:u,...a.length?{candidates:a}:{}},s=n.getRootNode(),p=l(n);if(p)return{...o,name:p};let m=v(n);if(m)return{...o,name:m,nameFrom:"adjacent-label"};let b=t(Array.from(n.childNodes||[]).filter(N=>N.nodeType===3).map(N=>N.textContent).join(" "));if(b&&b.length<=80)return{...o,name:b,nameFrom:"text"};let h=a[0];return h?{...o,name:"",locator:h.strategy==="placeholder"||h.strategy==="altText"?{strategy:"css",value:`[${h.strategy==="altText"?"alt":"placeholder"}=${JSON.stringify(h.value)}]`}:h}:{...o,name:""}}function k(n){let u=n.getAttribute&&n.getAttribute("role");if(u)return u;let a=n.tagName.toLowerCase(),o=(n.type||"").toLowerCase();return a==="button"?"button":a==="a"&&n.href?"link":a==="select"?n.multiple||n.size>1?"listbox":"combobox":a==="textarea"?"textbox":a==="input"?["submit","button","reset","file"].includes(o)?"button":o==="checkbox"||o==="radio"?o:o==="number"?"spinbutton":o==="search"?"searchbox":o==="range"?"slider":"textbox":n.isContentEditable?"textbox":H[a]??""}let H={li:"listitem",ul:"list",ol:"list",tr:"row",td:"cell",th:"columnheader",table:"table",nav:"navigation",main:"main",header:"banner",footer:"contentinfo",aside:"complementary",form:"form",dialog:"dialog",details:"group",fieldset:"group",img:"img",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading"};function I(n){let u=n,a=null;for(let o=0;u&&o<6&&!(u===document.body||u===document.documentElement);o++){let s="";try{s=getComputedStyle(u).cursor}catch{break}if(s==="pointer")a=u;else if(a)break;u=u.parentElement}return a}let T="tr, [role=row], li, [role=listitem], [role=article], [role=gridcell]";function $(n){try{let u=n.cloneNode(!0);for(let a of Array.from(u.querySelectorAll(i+", input, select, textarea")))a.remove();for(let a of Array.from(u.querySelectorAll("td, th, li, p, div, span, tr")))a.append(" ");return t(u.textContent).slice(0,120)}catch{return""}}function V(n,u,a){if(!a)return!1;let o;try{o=Array.from(document.querySelectorAll(i+", input, select, textarea"))}catch{return!1}if(o.length>400)return!0;let s=0;for(let p of o)if(p!==n&&k(p)===u&&C(p).name===a&&++s>0)return!0;return!1}function A(n,u,a){if(!V(n,u,a))return null;let o=n.closest&&n.closest(T);if(!o)return null;let s=$(o);if(!s)return null;let p=o.getAttribute&&o.getAttribute("role"),m=o.tagName.toLowerCase();return{scope:s,scopeRole:p||(m==="tr"?"row":m==="li"?"listitem":m)}}function r(n,u,a){let o=A(n,u,a);return o||{scope:f(n)}}function f(n){let u=n.closest&&n.closest("form, fieldset, section, [role=group], [role=region], [role=dialog], [role=alertdialog], dialog");return u?l(u):""}function c(n){if(n.id)return"#"+CSS.escape(n.id);let u=[],a=n;for(;a&&a.nodeType===1&&a!==document.body;){let o=Array.from(a.parentNode?a.parentNode.children:[]).filter(s=>s.tagName===a.tagName);u.unshift(o.length>1?`${a.tagName.toLowerCase()}:nth-of-type(${o.indexOf(a)+1})`:a.tagName.toLowerCase()),a=a.parentElement}return"body > "+u.join(" > ")}return{accName:l,identify:C,roleOf:k,pointerTarget:I,scoping:r,cssPath:c}}var ge=Object.prototype.toString;function Q(e){return typeof e=="function"||ge.call(e)==="[object Function]"}function ye(e){var t=Number(e);return isNaN(t)?0:t===0||!isFinite(t)?t:(t>0?1:-1)*Math.floor(Math.abs(t))}var he=Math.pow(2,53)-1;function ve(e){var t=ye(e);return Math.min(Math.max(t,0),he)}function w(e,t){var i=Array,l=Object(e);if(e==null)throw new TypeError("Array.from requires an array-like object - not null or undefined");if(typeof t<"u"&&!Q(t))throw new TypeError("Array.from: when provided, the second argument must be a function");for(var y=ve(l.length),E=Q(i)?Object(new i(y)):new Array(y),v=0,x;v<y;)x=l[v],t?E[v]=t(x,v):E[v]=x,v+=1;return E.length=y,E}function O(e){"@babel/helpers - typeof";return O=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(e)}function we(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function X(e,t){for(var i=0;i<t.length;i++){var l=t[i];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,Y(l.key),l)}}function Se(e,t,i){return t&&X(e.prototype,t),i&&X(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ee(e,t,i){return t=Y(t),t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Y(e){var t=xe(e,"string");return O(t)=="symbol"?t:t+""}function xe(e,t){if(O(e)!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var l=i.call(e,t||"default");if(O(l)!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ae=(function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];we(this,e),Ee(this,"items",void 0),this.items=t}return Se(e,[{key:"add",value:function(i){return this.has(i)===!1&&this.items.push(i),this}},{key:"clear",value:function(){this.items=[]}},{key:"delete",value:function(i){var l=this.items.length;return this.items=this.items.filter(function(y){return y!==i}),l!==this.items.length}},{key:"forEach",value:function(i){var l=this;this.items.forEach(function(y){i(y,y,l)})}},{key:"has",value:function(i){return this.items.indexOf(i)!==-1}},{key:"size",get:function(){return this.items.length}}])})(),Z=typeof Set>"u"?Set:Ae;function g(e){var t;return(t=e.localName)!==null&&t!==void 0?t:e.tagName.toLowerCase()}var Te={article:"article",aside:"complementary",button:"button",datalist:"listbox",dd:"definition",details:"group",dialog:"dialog",dt:"term",fieldset:"group",figure:"figure",form:"form",footer:"contentinfo",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading",header:"banner",hr:"separator",html:"document",legend:"legend",li:"listitem",math:"math",main:"main",menu:"list",nav:"navigation",ol:"list",optgroup:"group",option:"option",output:"status",progress:"progressbar",section:"region",summary:"button",table:"table",tbody:"rowgroup",textarea:"textbox",tfoot:"rowgroup",td:"cell",th:"columnheader",thead:"rowgroup",tr:"row",ul:"list"},Le={caption:new Set(["aria-label","aria-labelledby"]),code:new Set(["aria-label","aria-labelledby"]),deletion:new Set(["aria-label","aria-labelledby"]),emphasis:new Set(["aria-label","aria-labelledby"]),generic:new Set(["aria-label","aria-labelledby","aria-roledescription"]),insertion:new Set(["aria-label","aria-labelledby"]),none:new Set(["aria-label","aria-labelledby"]),paragraph:new Set(["aria-label","aria-labelledby"]),presentation:new Set(["aria-label","aria-labelledby"]),strong:new Set(["aria-label","aria-labelledby"]),subscript:new Set(["aria-label","aria-labelledby"]),superscript:new Set(["aria-label","aria-labelledby"])};function Ne(e,t){return["aria-atomic","aria-busy","aria-controls","aria-current","aria-description","aria-describedby","aria-details","aria-dropeffect","aria-flowto","aria-grabbed","aria-hidden","aria-keyshortcuts","aria-label","aria-labelledby","aria-live","aria-owns","aria-relevant","aria-roledescription"].some(function(i){var l;return e.hasAttribute(i)&&!((l=Le[t])!==null&&l!==void 0&&l.has(i))})}function ee(e,t){return Ne(e,t)}function D(e){var t=Ie(e);if(t===null||R.indexOf(t)!==-1){var i=Ce(e);if(R.indexOf(t||"")===-1||ee(e,i||""))return i}return t}function Ce(e){var t=Te[g(e)];if(t!==void 0)return t;switch(g(e)){case"a":case"area":case"link":if(e.hasAttribute("href"))return"link";break;case"img":return e.getAttribute("alt")===""&&!ee(e,"img")?"presentation":"img";case"input":{var i=e,l=i.type;switch(l){case"button":case"image":case"reset":case"submit":return"button";case"checkbox":case"radio":return l;case"range":return"slider";case"email":case"tel":case"text":case"url":return e.hasAttribute("list")?"combobox":"textbox";case"search":return e.hasAttribute("list")?"combobox":"searchbox";case"number":return"spinbutton";default:return null}}case"select":return e.hasAttribute("multiple")||e.size>1?"listbox":"combobox"}return null}function Ie(e){var t=e.getAttribute("role");if(t!==null){var i=t.trim().split(" ")[0];if(i.length>0)return i}return null}var R=["presentation","none"];function d(e){return e!==null&&e.nodeType===e.ELEMENT_NODE}function B(e){return d(e)&&g(e)==="caption"}function M(e){return d(e)&&g(e)==="input"}function te(e){return d(e)&&g(e)==="optgroup"}function re(e){return d(e)&&g(e)==="select"}function ne(e){return d(e)&&g(e)==="table"}function ie(e){return d(e)&&g(e)==="textarea"}function ae(e){var t=e.ownerDocument===null?e:e.ownerDocument,i=t.defaultView;if(i===null)throw new TypeError("no window available");return i}function oe(e){return d(e)&&g(e)==="fieldset"}function ue(e){return d(e)&&g(e)==="legend"}function le(e){return d(e)&&g(e)==="slot"}function Oe(e){return d(e)&&e.ownerSVGElement!==void 0}function se(e){return d(e)&&g(e)==="svg"}function fe(e){return Oe(e)&&g(e)==="title"}function P(e,t){if(d(e)&&e.hasAttribute(t)){var i=e.getAttribute(t).split(" "),l=e.getRootNode?e.getRootNode():e.ownerDocument;return i.map(function(y){return l.getElementById(y)}).filter(function(y){return y!==null})}return[]}function S(e,t){return d(e)?t.indexOf(D(e))!==-1:!1}function Re(e){return e.trim().replace(/\s\s+/g," ")}function Me(e,t){if(!d(e))return!1;if(e.hasAttribute("hidden")||e.getAttribute("aria-hidden")==="true")return!0;var i=t(e);return i.getPropertyValue("display")==="none"||i.getPropertyValue("visibility")==="hidden"}function Pe(e){return S(e,["button","combobox","listbox","textbox"])||pe(e,"range")}function pe(e,t){if(!d(e))return!1;if(t==="range")return S(e,["meter","progressbar","scrollbar","slider","spinbutton"]);throw new TypeError("No knowledge about abstract role '".concat(t,"'. This is likely a bug :("))}function ce(e,t){var i=w(e.querySelectorAll(t));return P(e,"aria-owns").forEach(function(l){i.push.apply(i,w(l.querySelectorAll(t)))}),i}function _e(e){return re(e)?e.selectedOptions||ce(e,"[selected]"):ce(e,'[aria-selected="true"]')}function je(e){return S(e,R)}function ke(e){return B(e)}function He(e){return S(e,["button","cell","checkbox","columnheader","gridcell","heading","label","legend","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowheader","switch","tab","tooltip","treeitem"])}function De(e){return!1}function $e(e){return M(e)||ie(e)?e.value:e.textContent||""}function de(e){var t=e.getPropertyValue("content");return/^["'].*["']$/.test(t)?t.slice(1,-1):""}function me(e){var t=g(e);return t==="button"||t==="input"&&e.getAttribute("type")!=="hidden"||t==="meter"||t==="output"||t==="progress"||t==="select"||t==="textarea"}function be(e){if(me(e))return e;var t=null;return e.childNodes.forEach(function(i){if(t===null&&d(i)){var l=be(i);l!==null&&(t=l)}}),t}function Ve(e){if(e.control!==void 0)return e.control;var t=e.getAttribute("for");return t!==null?e.ownerDocument.getElementById(t):be(e)}function qe(e){var t=e.labels;if(t===null)return t;if(t!==void 0)return w(t);if(!me(e))return null;var i=e.ownerDocument;return w(i.querySelectorAll("label")).filter(function(l){return Ve(l)===e})}function Ge(e){var t=e.assignedNodes();return t.length===0?w(e.childNodes):t}function J(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=new Z,l=typeof Map>"u"?void 0:new Map,y=ae(e),E=t.compute,v=E===void 0?"name":E,x=t.computedStyleSupportsPseudoElements,_=x===void 0?t.getComputedStyle!==void 0:x,j=t.getComputedStyle,L=j===void 0?y.getComputedStyle.bind(y):j,C=t.hidden,k=C===void 0?!1:C,H=function(f,c){if(c!==void 0)throw new Error("use uncachedGetComputedStyle directly for pseudo elements");if(l===void 0)return L(f);var n=l.get(f);if(n)return n;var u=L(f,c);return l.set(f,u),u};function I(r,f){var c="";if(d(r)&&_){var n=L(r,"::before"),u=de(n);c="".concat(u," ").concat(c)}var a=le(r)?Ge(r):w(r.childNodes).concat(P(r,"aria-owns"));if(a.forEach(function(p){var m=A(p,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1,recursion:!0}),b=d(p)?H(p).getPropertyValue("display"):"inline",h=b!=="inline"?" ":"";c+="".concat(h).concat(m).concat(h)}),d(r)&&_){var o=L(r,"::after"),s=de(o);c="".concat(c," ").concat(s)}return c.trim()}function T(r,f){var c=r.getAttributeNode(f);return c!==null&&!i.has(c)&&c.value.trim()!==""?(i.add(c),c.value):null}function $(r){return d(r)?T(r,"title"):null}function V(r){if(!d(r))return null;if(oe(r)){i.add(r);for(var f=w(r.childNodes),c=0;c<f.length;c+=1){var n=f[c];if(ue(n))return A(n,{isEmbeddedInLabel:!1,isReferenced:!1,recursion:!1})}}else if(ne(r)){i.add(r);for(var u=w(r.childNodes),a=0;a<u.length;a+=1){var o=u[a];if(B(o))return A(o,{isEmbeddedInLabel:!1,isReferenced:!1,recursion:!1})}}else if(se(r)){i.add(r);for(var s=w(r.childNodes),p=0;p<s.length;p+=1){var m=s[p];if(fe(m))return m.textContent}return null}else if(g(r)==="img"||g(r)==="area"){var b=T(r,"alt");if(b!==null)return b}else if(te(r)){var h=T(r,"label");if(h!==null)return h}if(M(r)&&(r.type==="button"||r.type==="submit"||r.type==="reset")){var N=T(r,"value");if(N!==null)return N;if(r.type==="submit")return"Submit";if(r.type==="reset")return"Reset"}var q=qe(r);if(q!==null&&q.length!==0)return i.add(r),w(q).map(function(G){return A(G,{isEmbeddedInLabel:!0,isReferenced:!1,recursion:!0})}).filter(function(G){return G.length>0}).join(" ");if(M(r)&&r.type==="image"){var z=T(r,"alt");if(z!==null)return z;var F=T(r,"title");return F!==null?F:"Submit Query"}if(S(r,["button"])){var K=I(r,{isEmbeddedInLabel:!1,isReferenced:!1});if(K!=="")return K}return null}function A(r,f){if(i.has(r))return"";if(!k&&Me(r,H)&&!f.isReferenced)return i.add(r),"";var c=d(r)?r.getAttributeNode("aria-labelledby"):null,n=c!==null&&!i.has(c)?P(r,"aria-labelledby"):[];if(v==="name"&&!f.isReferenced&&n.length>0)return i.add(c),n.map(function(b){return A(b,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!0,recursion:!1})}).join(" ");var u=f.recursion&&Pe(r)&&v==="name";if(!u){var a=(d(r)&&r.getAttribute("aria-label")||"").trim();if(a!==""&&v==="name")return i.add(r),a;if(!je(r)){var o=V(r);if(o!==null)return i.add(r),o}}if(S(r,["menu"]))return i.add(r),"";if(u||f.isEmbeddedInLabel||f.isReferenced){if(S(r,["combobox","listbox"])){i.add(r);var s=_e(r);return s.length===0?M(r)?r.value:"":w(s).map(function(b){return A(b,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1,recursion:!0})}).join(" ")}if(pe(r,"range"))return i.add(r),r.hasAttribute("aria-valuetext")?r.getAttribute("aria-valuetext"):r.hasAttribute("aria-valuenow")?r.getAttribute("aria-valuenow"):r.getAttribute("value")||"";if(S(r,["textbox"]))return i.add(r),$e(r)}if(He(r)||d(r)&&f.isReferenced||ke(r)||De(r)){var p=I(r,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1});if(p!=="")return i.add(r),p}if(r.nodeType===r.TEXT_NODE)return i.add(r),r.textContent||"";if(f.recursion)return i.add(r),I(r,{isEmbeddedInLabel:f.isEmbeddedInLabel,isReferenced:!1});var m=$(r);return m!==null?(i.add(r),m):(i.add(r),"")}return Re(A(e,{isEmbeddedInLabel:!1,isReferenced:v==="description",recursion:!1}))}function Be(e){return S(e,["caption","code","deletion","emphasis","generic","insertion","none","paragraph","presentation","strong","subscript","superscript"])}function W(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Be(e)?"":J(e,t)}window.__flAccName=e=>{try{return W(e).replace(/\s+/g," ").trim()}catch{return""}};window.__flCreateTargetIdentity=U;})();
1
+ "use strict";(()=>{function U(e,t,i){function u(n){let o=e.__flAccName;if(o){let l=o(n);return l||t(n.placeholder)||t(n.title)||""}return g(n)}function g(n){let o=n.getAttribute&&n.getAttribute("aria-labelledby");if(o){let b=o.split(/\s+/).map(y=>document.getElementById(y)).filter(Boolean).map(y=>t(y.textContent)).filter(Boolean).join(" ");if(b)return b}let l=t(n.getAttribute&&n.getAttribute("aria-label"));if(l)return l;if(n.id){let b=document.querySelector('label[for="'+CSS.escape(n.id)+'"]');if(b&&t(b.textContent))return t(b.textContent)}let a=n.closest&&n.closest("label");if(a&&t(a.textContent))return t(a.textContent);let s=n.tagName.toLowerCase(),m=(n.type||"").toLowerCase();return(["button","a","summary"].includes(s)||n.getAttribute&&n.getAttribute("role")==="button")&&t(n.textContent)?t(n.textContent):s==="input"&&["submit","button","reset"].includes(m)&&n.value?t(n.value):t(n.placeholder)||t(n.title)||""}let T="input,select,textarea,button,meter,output,progress,[contenteditable]";function h(n){let o=n.parentElement;if(!o||!n.matches?.(T))return"";for(let l of Array.from(o.querySelectorAll("label"))){let a=l.getAttribute("for");if(a&&document.getElementById(a))continue;let s=t(l.textContent);if(s)return s}return""}let L=new WeakMap,H=crypto.randomUUID(),D=0;function R(n){let o=n.getRootNode(),l=E=>o.querySelectorAll(E).length===1,a=[],s=n.getAttribute?.("data-testid");s&&l(`[data-testid=${JSON.stringify(s)}]`)&&a.push({strategy:"testId",value:s});let m=t(n.placeholder);m&&l(`[placeholder=${JSON.stringify(n.placeholder)}]`)&&a.push({strategy:"placeholder",value:m});let b=t(n.getAttribute?.("alt"));b&&l(`[alt=${JSON.stringify(n.getAttribute("alt"))}]`)&&a.push({strategy:"altText",value:b});let y=n.getAttribute?.("title");return y&&l(`[title=${JSON.stringify(y)}]`)&&a.push({strategy:"title",value:t(y)}),n.id&&!/:r|[a-f0-9]{12}|\d{6}/i.test(n.id)&&l(`#${CSS.escape(n.id)}`)&&a.push({strategy:"css",value:`#${CSS.escape(n.id)}`}),a.slice(0,4)}function O(n){let o=L.get(n);o||(o=`${H}:${++D}`,L.set(n,o));let l=R(n),a={__targetId:o,...l.length?{candidates:l}:{}},s=n.getRootNode(),m=u(n);if(m)return{...a,name:m};let b=h(n);if(b)return{...a,name:b,nameFrom:"adjacent-label"};let y=t(Array.from(n.childNodes||[]).filter(I=>I.nodeType===3).map(I=>I.textContent).join(" "));if(y&&y.length<=80)return{...a,name:y,nameFrom:"text"};let E=l[0];return E?{...a,name:"",locator:E.strategy==="placeholder"||E.strategy==="altText"?{strategy:"css",value:`[${E.strategy==="altText"?"alt":"placeholder"}=${JSON.stringify(E.value)}]`}:E}:{...a,name:""}}function $(n){let o=n.getAttribute&&n.getAttribute("role");if(o)return o;let l=n.tagName.toLowerCase(),a=(n.type||"").toLowerCase();return l==="button"?"button":l==="a"&&n.href?"link":l==="select"?n.multiple||n.size>1?"listbox":"combobox":l==="textarea"?"textbox":l==="input"?["submit","button","reset","file"].includes(a)?"button":a==="checkbox"||a==="radio"?a:a==="number"?"spinbutton":a==="search"?"searchbox":a==="range"?"slider":"textbox":n.isContentEditable?"textbox":V[l]??""}let V={li:"listitem",ul:"list",ol:"list",tr:"row",td:"cell",th:"columnheader",table:"table",nav:"navigation",main:"main",header:"banner",footer:"contentinfo",aside:"complementary",form:"form",dialog:"dialog",details:"group",fieldset:"group",img:"img",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading"};function M(n){let o=n,l=null;for(let a=0;o&&a<6&&!(o===document.body||o===document.documentElement);a++){let s="";try{s=getComputedStyle(o).cursor}catch{break}if(s==="pointer")l=o;else if(l)break;o=o.parentElement}return l}let C="tr, [role=row], li, [role=listitem], [role=article], [role=gridcell]";function B(n){try{let o=n.cloneNode(!0);for(let l of Array.from(o.querySelectorAll(i+", input, select, textarea")))l.remove();for(let l of Array.from(o.querySelectorAll("td, th, li, p, div, span, tr")))l.append(" ");return t(o.textContent).slice(0,120)}catch{return""}}function q(n,o,l){if(!l)return!1;let a;try{a=Array.from(document.querySelectorAll(i+", input, select, textarea"))}catch{return!1}if(a.length>400)return!0;let s=0;for(let m of a)if(m!==n&&$(m)===o&&O(m).name===l&&++s>0)return!0;return!1}function N(n,o,l){if(!q(n,o,l))return null;let a=n.closest&&n.closest(C);if(!a)return null;let s=B(a);if(!s)return null;let m=a.getAttribute&&a.getAttribute("role"),b=a.tagName.toLowerCase();return{scope:s,scopeRole:m||(b==="tr"?"row":b==="li"?"listitem":b)}}function r(n){if(!n.closest)return null;let o=n.closest("nav, main, aside, header, footer, [role=navigation], [role=main], [role=complementary], [role=banner], [role=contentinfo], [role=search]");if(!o)return null;let l=o.getAttribute&&o.getAttribute("role");if(l)return{scope:u(o),scopeRole:l};let a=o.tagName.toLowerCase();return a==="nav"?{scope:u(o),scopeRole:"navigation"}:a==="main"?{scope:u(o),scopeRole:"main"}:a==="aside"?{scope:u(o),scopeRole:"complementary"}:o.closest("article, aside, main, nav, section")!==o&&o.closest("article, aside, main, nav, section")!==null?null:a==="header"?{scope:u(o),scopeRole:"banner"}:a==="footer"?{scope:u(o),scopeRole:"contentinfo"}:null}let c=new WeakMap;function f(n,o){n&&o&&Object.keys(o).length&&c.set(n,o)}function w(n,o,l){let a=c.get(n);if(a&&(a.scopeRole||a.nth!==void 0||a.warning))return{scope:a.scope??"",...a.scopeRole?{scopeRole:a.scopeRole}:{},...a.nth===void 0?{}:{nth:a.nth},...a.warning?{warning:a.warning}:{}};let s=N(n,o,l);return s||{scope:S(n)}}function S(n){let o=n.closest&&n.closest("form, fieldset, section, [role=group], [role=region], [role=dialog], [role=alertdialog], dialog");return o?u(o):""}function A(n){if(n.id)return"#"+CSS.escape(n.id);let o=[],l=n;for(;l&&l.nodeType===1&&l!==document.body;){let a=Array.from(l.parentNode?l.parentNode.children:[]).filter(s=>s.tagName===l.tagName);o.unshift(a.length>1?`${l.tagName.toLowerCase()}:nth-of-type(${a.indexOf(l)+1})`:l.tagName.toLowerCase()),l=l.parentElement}return"body > "+o.join(" > ")}return{accName:u,identify:O,roleOf:$,pointerTarget:M,scoping:w,cssPath:A,isAmbiguous:q,landmarkScope:r,remember:f}}var ge=Object.prototype.toString;function Q(e){return typeof e=="function"||ge.call(e)==="[object Function]"}function ye(e){var t=Number(e);return isNaN(t)?0:t===0||!isFinite(t)?t:(t>0?1:-1)*Math.floor(Math.abs(t))}var he=Math.pow(2,53)-1;function ve(e){var t=ye(e);return Math.min(Math.max(t,0),he)}function v(e,t){var i=Array,u=Object(e);if(e==null)throw new TypeError("Array.from requires an array-like object - not null or undefined");if(typeof t<"u"&&!Q(t))throw new TypeError("Array.from: when provided, the second argument must be a function");for(var g=ve(u.length),T=Q(i)?Object(new i(g)):new Array(g),h=0,L;h<g;)L=u[h],t?T[h]=t(L,h):T[h]=L,h+=1;return T.length=g,T}function P(e){"@babel/helpers - typeof";return P=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(e)}function we(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function X(e,t){for(var i=0;i<t.length;i++){var u=t[i];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(e,Y(u.key),u)}}function Se(e,t,i){return t&&X(e.prototype,t),i&&X(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ee(e,t,i){return t=Y(t),t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Y(e){var t=xe(e,"string");return P(t)=="symbol"?t:t+""}function xe(e,t){if(P(e)!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var u=i.call(e,t||"default");if(P(u)!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ae=(function(){function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];we(this,e),Ee(this,"items",void 0),this.items=t}return Se(e,[{key:"add",value:function(i){return this.has(i)===!1&&this.items.push(i),this}},{key:"clear",value:function(){this.items=[]}},{key:"delete",value:function(i){var u=this.items.length;return this.items=this.items.filter(function(g){return g!==i}),u!==this.items.length}},{key:"forEach",value:function(i){var u=this;this.items.forEach(function(g){i(g,g,u)})}},{key:"has",value:function(i){return this.items.indexOf(i)!==-1}},{key:"size",get:function(){return this.items.length}}])})(),Z=typeof Set>"u"?Set:Ae;function p(e){var t;return(t=e.localName)!==null&&t!==void 0?t:e.tagName.toLowerCase()}var Te={article:"article",aside:"complementary",button:"button",datalist:"listbox",dd:"definition",details:"group",dialog:"dialog",dt:"term",fieldset:"group",figure:"figure",form:"form",footer:"contentinfo",h1:"heading",h2:"heading",h3:"heading",h4:"heading",h5:"heading",h6:"heading",header:"banner",hr:"separator",html:"document",legend:"legend",li:"listitem",math:"math",main:"main",menu:"list",nav:"navigation",ol:"list",optgroup:"group",option:"option",output:"status",progress:"progressbar",section:"region",summary:"button",table:"table",tbody:"rowgroup",textarea:"textbox",tfoot:"rowgroup",td:"cell",th:"columnheader",thead:"rowgroup",tr:"row",ul:"list"},Le={caption:new Set(["aria-label","aria-labelledby"]),code:new Set(["aria-label","aria-labelledby"]),deletion:new Set(["aria-label","aria-labelledby"]),emphasis:new Set(["aria-label","aria-labelledby"]),generic:new Set(["aria-label","aria-labelledby","aria-roledescription"]),insertion:new Set(["aria-label","aria-labelledby"]),none:new Set(["aria-label","aria-labelledby"]),paragraph:new Set(["aria-label","aria-labelledby"]),presentation:new Set(["aria-label","aria-labelledby"]),strong:new Set(["aria-label","aria-labelledby"]),subscript:new Set(["aria-label","aria-labelledby"]),superscript:new Set(["aria-label","aria-labelledby"])};function Ne(e,t){return["aria-atomic","aria-busy","aria-controls","aria-current","aria-description","aria-describedby","aria-details","aria-dropeffect","aria-flowto","aria-grabbed","aria-hidden","aria-keyshortcuts","aria-label","aria-labelledby","aria-live","aria-owns","aria-relevant","aria-roledescription"].some(function(i){var u;return e.hasAttribute(i)&&!((u=Le[t])!==null&&u!==void 0&&u.has(i))})}function ee(e,t){return Ne(e,t)}function G(e){var t=Re(e);if(t===null||_.indexOf(t)!==-1){var i=Ce(e);if(_.indexOf(t||"")===-1||ee(e,i||""))return i}return t}function Ce(e){var t=Te[p(e)];if(t!==void 0)return t;switch(p(e)){case"a":case"area":case"link":if(e.hasAttribute("href"))return"link";break;case"img":return e.getAttribute("alt")===""&&!ee(e,"img")?"presentation":"img";case"input":{var i=e,u=i.type;switch(u){case"button":case"image":case"reset":case"submit":return"button";case"checkbox":case"radio":return u;case"range":return"slider";case"email":case"tel":case"text":case"url":return e.hasAttribute("list")?"combobox":"textbox";case"search":return e.hasAttribute("list")?"combobox":"searchbox";case"number":return"spinbutton";default:return null}}case"select":return e.hasAttribute("multiple")||e.size>1?"listbox":"combobox"}return null}function Re(e){var t=e.getAttribute("role");if(t!==null){var i=t.trim().split(" ")[0];if(i.length>0)return i}return null}var _=["presentation","none"];function d(e){return e!==null&&e.nodeType===e.ELEMENT_NODE}function W(e){return d(e)&&p(e)==="caption"}function j(e){return d(e)&&p(e)==="input"}function te(e){return d(e)&&p(e)==="optgroup"}function re(e){return d(e)&&p(e)==="select"}function ne(e){return d(e)&&p(e)==="table"}function ie(e){return d(e)&&p(e)==="textarea"}function ae(e){var t=e.ownerDocument===null?e:e.ownerDocument,i=t.defaultView;if(i===null)throw new TypeError("no window available");return i}function oe(e){return d(e)&&p(e)==="fieldset"}function le(e){return d(e)&&p(e)==="legend"}function ue(e){return d(e)&&p(e)==="slot"}function Ie(e){return d(e)&&e.ownerSVGElement!==void 0}function se(e){return d(e)&&p(e)==="svg"}function ce(e){return Ie(e)&&p(e)==="title"}function k(e,t){if(d(e)&&e.hasAttribute(t)){var i=e.getAttribute(t).split(" "),u=e.getRootNode?e.getRootNode():e.ownerDocument;return i.map(function(g){return u.getElementById(g)}).filter(function(g){return g!==null})}return[]}function x(e,t){return d(e)?t.indexOf(G(e))!==-1:!1}function Oe(e){return e.trim().replace(/\s\s+/g," ")}function Me(e,t){if(!d(e))return!1;if(e.hasAttribute("hidden")||e.getAttribute("aria-hidden")==="true")return!0;var i=t(e);return i.getPropertyValue("display")==="none"||i.getPropertyValue("visibility")==="hidden"}function Pe(e){return x(e,["button","combobox","listbox","textbox"])||pe(e,"range")}function pe(e,t){if(!d(e))return!1;if(t==="range")return x(e,["meter","progressbar","scrollbar","slider","spinbutton"]);throw new TypeError("No knowledge about abstract role '".concat(t,"'. This is likely a bug :("))}function fe(e,t){var i=v(e.querySelectorAll(t));return k(e,"aria-owns").forEach(function(u){i.push.apply(i,v(u.querySelectorAll(t)))}),i}function _e(e){return re(e)?e.selectedOptions||fe(e,"[selected]"):fe(e,'[aria-selected="true"]')}function je(e){return x(e,_)}function ke(e){return W(e)}function He(e){return x(e,["button","cell","checkbox","columnheader","gridcell","heading","label","legend","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowheader","switch","tab","tooltip","treeitem"])}function De(e){return!1}function $e(e){return j(e)||ie(e)?e.value:e.textContent||""}function de(e){var t=e.getPropertyValue("content");return/^["'].*["']$/.test(t)?t.slice(1,-1):""}function me(e){var t=p(e);return t==="button"||t==="input"&&e.getAttribute("type")!=="hidden"||t==="meter"||t==="output"||t==="progress"||t==="select"||t==="textarea"}function be(e){if(me(e))return e;var t=null;return e.childNodes.forEach(function(i){if(t===null&&d(i)){var u=be(i);u!==null&&(t=u)}}),t}function Ve(e){if(e.control!==void 0)return e.control;var t=e.getAttribute("for");return t!==null?e.ownerDocument.getElementById(t):be(e)}function qe(e){var t=e.labels;if(t===null)return t;if(t!==void 0)return v(t);if(!me(e))return null;var i=e.ownerDocument;return v(i.querySelectorAll("label")).filter(function(u){return Ve(u)===e})}function Ge(e){var t=e.assignedNodes();return t.length===0?v(e.childNodes):t}function z(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=new Z,u=typeof Map>"u"?void 0:new Map,g=ae(e),T=t.compute,h=T===void 0?"name":T,L=t.computedStyleSupportsPseudoElements,H=L===void 0?t.getComputedStyle!==void 0:L,D=t.getComputedStyle,R=D===void 0?g.getComputedStyle.bind(g):D,O=t.hidden,$=O===void 0?!1:O,V=function(c,f){if(f!==void 0)throw new Error("use uncachedGetComputedStyle directly for pseudo elements");if(u===void 0)return R(c);var w=u.get(c);if(w)return w;var S=R(c,f);return u.set(c,S),S};function M(r,c){var f="";if(d(r)&&H){var w=R(r,"::before"),S=de(w);f="".concat(S," ").concat(f)}var A=ue(r)?Ge(r):v(r.childNodes).concat(k(r,"aria-owns"));if(A.forEach(function(l){var a=N(l,{isEmbeddedInLabel:c.isEmbeddedInLabel,isReferenced:!1,recursion:!0}),s=d(l)?V(l).getPropertyValue("display"):"inline",m=s!=="inline"?" ":"";f+="".concat(m).concat(a).concat(m)}),d(r)&&H){var n=R(r,"::after"),o=de(n);f="".concat(f," ").concat(o)}return f.trim()}function C(r,c){var f=r.getAttributeNode(c);return f!==null&&!i.has(f)&&f.value.trim()!==""?(i.add(f),f.value):null}function B(r){return d(r)?C(r,"title"):null}function q(r){if(!d(r))return null;if(oe(r)){i.add(r);for(var c=v(r.childNodes),f=0;f<c.length;f+=1){var w=c[f];if(le(w))return N(w,{isEmbeddedInLabel:!1,isReferenced:!1,recursion:!1})}}else if(ne(r)){i.add(r);for(var S=v(r.childNodes),A=0;A<S.length;A+=1){var n=S[A];if(W(n))return N(n,{isEmbeddedInLabel:!1,isReferenced:!1,recursion:!1})}}else if(se(r)){i.add(r);for(var o=v(r.childNodes),l=0;l<o.length;l+=1){var a=o[l];if(ce(a))return a.textContent}return null}else if(p(r)==="img"||p(r)==="area"){var s=C(r,"alt");if(s!==null)return s}else if(te(r)){var m=C(r,"label");if(m!==null)return m}if(j(r)&&(r.type==="button"||r.type==="submit"||r.type==="reset")){var b=C(r,"value");if(b!==null)return b;if(r.type==="submit")return"Submit";if(r.type==="reset")return"Reset"}var y=qe(r);if(y!==null&&y.length!==0)return i.add(r),v(y).map(function(J){return N(J,{isEmbeddedInLabel:!0,isReferenced:!1,recursion:!0})}).filter(function(J){return J.length>0}).join(" ");if(j(r)&&r.type==="image"){var E=C(r,"alt");if(E!==null)return E;var I=C(r,"title");return I!==null?I:"Submit Query"}if(x(r,["button"])){var K=M(r,{isEmbeddedInLabel:!1,isReferenced:!1});if(K!=="")return K}return null}function N(r,c){if(i.has(r))return"";if(!$&&Me(r,V)&&!c.isReferenced)return i.add(r),"";var f=d(r)?r.getAttributeNode("aria-labelledby"):null,w=f!==null&&!i.has(f)?k(r,"aria-labelledby"):[];if(h==="name"&&!c.isReferenced&&w.length>0)return i.add(f),w.map(function(s){return N(s,{isEmbeddedInLabel:c.isEmbeddedInLabel,isReferenced:!0,recursion:!1})}).join(" ");var S=c.recursion&&Pe(r)&&h==="name";if(!S){var A=(d(r)&&r.getAttribute("aria-label")||"").trim();if(A!==""&&h==="name")return i.add(r),A;if(!je(r)){var n=q(r);if(n!==null)return i.add(r),n}}if(x(r,["menu"]))return i.add(r),"";if(S||c.isEmbeddedInLabel||c.isReferenced){if(x(r,["combobox","listbox"])){i.add(r);var o=_e(r);return o.length===0?j(r)?r.value:"":v(o).map(function(s){return N(s,{isEmbeddedInLabel:c.isEmbeddedInLabel,isReferenced:!1,recursion:!0})}).join(" ")}if(pe(r,"range"))return i.add(r),r.hasAttribute("aria-valuetext")?r.getAttribute("aria-valuetext"):r.hasAttribute("aria-valuenow")?r.getAttribute("aria-valuenow"):r.getAttribute("value")||"";if(x(r,["textbox"]))return i.add(r),$e(r)}if(He(r)||d(r)&&c.isReferenced||ke(r)||De(r)){var l=M(r,{isEmbeddedInLabel:c.isEmbeddedInLabel,isReferenced:!1});if(l!=="")return i.add(r),l}if(r.nodeType===r.TEXT_NODE)return i.add(r),r.textContent||"";if(c.recursion)return i.add(r),M(r,{isEmbeddedInLabel:c.isEmbeddedInLabel,isReferenced:!1});var a=B(r);return a!==null?(i.add(r),a):(i.add(r),"")}return Oe(N(e,{isEmbeddedInLabel:!1,isReferenced:h==="description",recursion:!1}))}function Be(e){return x(e,["caption","code","deletion","emphasis","generic","insertion","none","paragraph","presentation","strong","subscript","superscript"])}function F(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Be(e)?"":z(e,t)}window.__flAccName=e=>{try{return F(e).replace(/\s+/g," ").trim()}catch{return""}};window.__flCreateTargetIdentity=U;})();
@@ -6,7 +6,7 @@ import os from "os";
6
6
  import path from "path";
7
7
  import { createRequire } from "module";
8
8
  import { spawnSync } from "child_process";
9
- var AGENT_VERSION = "0.1.0-beta.22";
9
+ var AGENT_VERSION = "0.1.0-beta.23";
10
10
  async function prepareBrowsers() {
11
11
  if (browsersReady()) {
12
12
  return { ok: true, already: true, message: "chromium is already installed" };
@@ -1561,7 +1561,7 @@ function describePlan(step, p) {
1561
1561
  if (p.method === "goForward") return "page.goForward()";
1562
1562
  let root = "page";
1563
1563
  for (const frame of step.frame ?? []) root += `.frameLocator(${quote(frameSelector(frame))})`;
1564
- if (!p.overridden && step.scope) root = scopeExpression(root, step.scope, step.scopeRole);
1564
+ if (!p.overridden && (step.scope || step.scopeRole)) root = scopeExpression(root, step.scope ?? "", step.scopeRole);
1565
1565
  let base = p.viaAdjacentLabel ? `${root}.getByText(${quote(p.arg)}, { exact: true }).locator('xpath=..').getByRole(${quote(step.role || "textbox")})` : p.method === "getByRole" ? `${root}.getByRole(${quote(p.arg)}, { name: ${quote(p.name ?? "")}, exact: true })` : `${root}.${p.method}(${quote(p.arg)}${p.exact !== void 0 ? `, { exact: ${p.exact} }` : ""})`;
1566
1566
  if (p.inputRole) base = `${root}.getByRole(${quote(p.inputRole)}, { name: ${quote(p.arg)}, exact: true }).or(${base}.and(${root}.locator(${quote(inputSelector(p.inputRole))})))`;
1567
1567
  if (p.visible) base += ".filter({ visible: true })";
@@ -1580,7 +1580,9 @@ function inputSelector(role) {
1580
1580
  }
1581
1581
  var SCOPE_ROLES = ["form", "group", "region", "dialog", "alertdialog"];
1582
1582
  function scopeExpression(root, name, role) {
1583
- const parts = (role ? [role] : SCOPE_ROLES).map((r) => `${root}.getByRole(${quote(r)}, { name: ${quote(name)}, exact: ${!role} })`);
1583
+ const parts = (role ? [role] : SCOPE_ROLES).map(
1584
+ (r) => name ? `${root}.getByRole(${quote(r)}, { name: ${quote(name)}, exact: ${!role} })` : `${root}.getByRole(${quote(r)})`
1585
+ );
1584
1586
  return parts.reduce((a, b2) => `${a}.or(${b2})`);
1585
1587
  }
1586
1588
  var CHECKS = [
@@ -1650,6 +1652,37 @@ function describeAssertion(a, subject) {
1650
1652
  const label = check.label.replace("attribute", `attribute${attr}`);
1651
1653
  return who ? `\u201C${who}\u201D ${label}${expects}` : `${label}${expects}`;
1652
1654
  }
1655
+ var NAME_FROM_CONTENT = /* @__PURE__ */ new Set([
1656
+ "button",
1657
+ "link",
1658
+ "heading",
1659
+ "cell",
1660
+ "columnheader",
1661
+ "rowheader",
1662
+ "menuitem",
1663
+ "menuitemcheckbox",
1664
+ "menuitemradio",
1665
+ "option",
1666
+ "tab",
1667
+ "treeitem",
1668
+ "gridcell",
1669
+ "switch",
1670
+ "checkbox",
1671
+ "radio"
1672
+ ]);
1673
+ function identifiedByOwnWords(target) {
1674
+ if (!target || target.locator || !target.name) return false;
1675
+ return target.nameFrom === "text" || NAME_FROM_CONTENT.has(target.role ?? "");
1676
+ }
1677
+ function textIndependent(candidates) {
1678
+ if (!candidates?.length) return void 0;
1679
+ const order = ["testId", "css", "id", "title", "altText"];
1680
+ for (const strategy of order) {
1681
+ const found = candidates.find((each) => each.strategy === strategy && each.value.trim());
1682
+ if (found) return found;
1683
+ }
1684
+ return void 0;
1685
+ }
1653
1686
  var STEP_PRESENTATION = {
1654
1687
  fill: { label: "Fill", tone: "accent" },
1655
1688
  select: { label: "Select", tone: "accent" },
@@ -1777,7 +1810,7 @@ function installRecorder() {
1777
1810
  if (!visible(el)) return false;
1778
1811
  return getComputedStyle(el).opacity !== "0";
1779
1812
  };
1780
- const { accName, identify, roleOf, pointerTarget, scoping, cssPath } = w.__flCreateTargetIdentity(w, clean, CLICKABLE);
1813
+ const { accName, identify, roleOf, pointerTarget, scoping, cssPath, isAmbiguous, landmarkScope, remember } = w.__flCreateTargetIdentity(w, clean, CLICKABLE);
1781
1814
  function isOurs(el) {
1782
1815
  return Boolean(el?.closest?.("[data-flowriki],[data-flowriki-debug]"));
1783
1816
  }
@@ -1815,10 +1848,14 @@ function installRecorder() {
1815
1848
  w.__flMuted = Boolean(on);
1816
1849
  };
1817
1850
  const inFlight = /* @__PURE__ */ new Set();
1818
- const send = (a) => {
1851
+ const tickets = /* @__PURE__ */ new WeakMap();
1852
+ let nextTicket = 0;
1853
+ const send = (a, el) => {
1819
1854
  if (w.__flMuted) return;
1820
1855
  if (a.type && !["back", "forward", "scroll"].includes(a.type) && !a.name && !a.locator) a.warning = "This target has no stable accessible name or test ID. Choose a locator before running.";
1821
1856
  if (FRAME_CHAIN.length && a && a.__sig === void 0) a.frame = FRAME_CHAIN;
1857
+ const ticket = el ? tickets.get(el) : void 0;
1858
+ if (ticket !== void 0) a.__toldApart = ticket;
1822
1859
  if (w.__flRecord) {
1823
1860
  const pending = Promise.resolve(w.__flRecord(a));
1824
1861
  inFlight.add(pending);
@@ -1867,6 +1904,32 @@ function installRecorder() {
1867
1904
  }, true);
1868
1905
  document.addEventListener("pointerdown", flushScroll, true);
1869
1906
  document.addEventListener("keydown", flushScroll, true);
1907
+ const asked = /* @__PURE__ */ new WeakSet();
1908
+ const tellApart2 = (hit) => {
1909
+ if (w.__flMuted || !hit || !w.__flTellApart) return;
1910
+ const el = (hit.closest ? hit.closest(CLICKABLE) : null) ?? pointerTarget(hit) ?? hit;
1911
+ if (!el || asked.has(el)) return;
1912
+ const role = roleOf(el);
1913
+ const { name } = identify(el);
1914
+ if (!name || !isAmbiguous(el, role, name)) return;
1915
+ asked.add(el);
1916
+ w.__flTellingApart = el;
1917
+ const ticket = ++nextTicket;
1918
+ tickets.set(el, ticket);
1919
+ void Promise.resolve(
1920
+ w.__flTellApart({
1921
+ ticket,
1922
+ target: { role, ...identify(el), ...scoping(el, role, name) },
1923
+ suggested: landmarkScope(el),
1924
+ marker: "__flTellingApart"
1925
+ })
1926
+ ).then((told) => {
1927
+ if (told) remember(el, told);
1928
+ }).catch(() => {
1929
+ });
1930
+ };
1931
+ document.addEventListener("pointerdown", (e) => tellApart2(actualTarget(e)), true);
1932
+ document.addEventListener("focusin", (e) => tellApart2(actualTarget(e)), true);
1870
1933
  const sendSignature = () => {
1871
1934
  if (!inTopFrame) return;
1872
1935
  try {
@@ -2078,17 +2141,6 @@ function installRecorder() {
2078
2141
  const above = r.top > 26;
2079
2142
  pickLabel.style.transform = `translate(${Math.max(4, r.left)}px, ${above ? r.top - 24 : r.bottom + 4}px)`;
2080
2143
  }
2081
- function stableId(el) {
2082
- const id = el.id;
2083
- if (!id || /:r|[a-f0-9]{12}|\d{6}/i.test(id)) return null;
2084
- const root = el.getRootNode();
2085
- const sel = `#${CSS.escape(id)}`;
2086
- try {
2087
- return root.querySelectorAll(sel).length === 1 ? sel : null;
2088
- } catch {
2089
- return null;
2090
- }
2091
- }
2092
2144
  function pickTargetAt(e) {
2093
2145
  const hit = actualTarget(e);
2094
2146
  if (!hit || !hit.closest) return null;
@@ -2121,15 +2173,16 @@ function installRecorder() {
2121
2173
  ...identity,
2122
2174
  ...scoping(el, role, identity.name),
2123
2175
  // An element named by its own TEXT is a circular identity for an
2124
- // assertion about that text: change the text and the element cannot
2125
- // be found, so the check reports "missing" instead of "wrong". A
2126
- // stable id resolves it — and only then, so nothing else trades the
2127
- // accessible name for a selector.
2128
- ...identity.nameFrom === "text" && !identity.locator && stableId(el) ? { locator: { strategy: "css", value: stableId(el) } } : {},
2176
+ // assertion about that text. The driver settles it — see
2177
+ // `preferIndependentIdentity` — because only there is there one list
2178
+ // of everything that identifies this element. The version here knew
2179
+ // about `id` and nothing else, so a heading carrying the `data-testid`
2180
+ // somebody had added for exactly this purpose was recorded by its
2181
+ // words anyway.
2129
2182
  ...FRAME_CHAIN.length ? { frame: FRAME_CHAIN } : {}
2130
2183
  },
2131
2184
  readings: read
2132
- });
2185
+ }, el);
2133
2186
  }
2134
2187
  function onPickKey(e) {
2135
2188
  if (e.key !== "Escape") return;
@@ -2180,7 +2233,7 @@ function installRecorder() {
2180
2233
  ...identify(el),
2181
2234
  ...scoping(el, role, identify(el).name),
2182
2235
  legacySelector: cssPath(el)
2183
- });
2236
+ }, el);
2184
2237
  }
2185
2238
  document.addEventListener(
2186
2239
  "click",
@@ -2236,7 +2289,7 @@ function installRecorder() {
2236
2289
  // app's own handler runs and before any navigation starts. This is
2237
2290
  // the only moment the true "before" state is observable.
2238
2291
  __before: w.__flSignature()
2239
- });
2292
+ }, el);
2240
2293
  setTimeout(sendSignature, 350);
2241
2294
  },
2242
2295
  true
@@ -2259,7 +2312,7 @@ function installRecorder() {
2259
2312
  to: describe(to),
2260
2313
  legacySelector: cssPath(from),
2261
2314
  __before: w.__flSignature()
2262
- });
2315
+ }, from);
2263
2316
  setTimeout(sendSignature, 350);
2264
2317
  }
2265
2318
  document.addEventListener(
@@ -2382,7 +2435,7 @@ function installRecorder() {
2382
2435
  // Same reasoning as the click listener: the capture phase is the only
2383
2436
  // moment the pre-submit state is still observable.
2384
2437
  __before: w.__flSignature()
2385
- });
2438
+ }, el);
2386
2439
  setTimeout(sendSignature, 350);
2387
2440
  },
2388
2441
  true
@@ -2423,7 +2476,7 @@ function installRecorder() {
2423
2476
  legacySelector: cssPath(el),
2424
2477
  value: picked.join(", "),
2425
2478
  values: picked
2426
- });
2479
+ }, el);
2427
2480
  return;
2428
2481
  }
2429
2482
  const values = tag === "select" ? Array.from(el.selectedOptions).map((o) => o.value) : void 0;
@@ -2441,7 +2494,7 @@ function installRecorder() {
2441
2494
  value,
2442
2495
  ...values ? { values } : {},
2443
2496
  secret: looksSecret(el, type, identity.name)
2444
- });
2497
+ }, el);
2445
2498
  };
2446
2499
  document.addEventListener("input", onEdit, true);
2447
2500
  document.addEventListener("change", onEdit, true);
@@ -2487,6 +2540,8 @@ function installDebugPanel() {
2487
2540
  if (r.interactive) {
2488
2541
  first.push("visible", "enabled");
2489
2542
  if (r.text) first.push("text");
2543
+ } else if (r.text && r.namedByOwnWords) {
2544
+ first.push("visible");
2490
2545
  } else if (r.text) {
2491
2546
  first.push("text-contains", "text");
2492
2547
  }
@@ -3820,9 +3875,12 @@ async function locateAll(page, step, opts = {}) {
3820
3875
  }
3821
3876
  async function fromPlan(page, step, plan, opts = {}) {
3822
3877
  let root = rootFor(page, step);
3823
- if (step.scope && !plan.overridden) {
3878
+ if ((step.scope || step.scopeRole) && !plan.overridden) {
3824
3879
  const roles = step.scopeRole ? [step.scopeRole] : [...SCOPE_ROLES];
3825
- const containers = roles.map((role) => root.getByRole(role, { name: step.scope, exact: !step.scopeRole, includeHidden: opts.includeHidden }));
3880
+ const containers = roles.map((role) => root.getByRole(role, {
3881
+ ...step.scope ? { name: step.scope, exact: !step.scopeRole } : {},
3882
+ includeHidden: opts.includeHidden
3883
+ }));
3826
3884
  root = containers.reduce((a, b2) => a.or(b2));
3827
3885
  }
3828
3886
  if (plan.viaAdjacentLabel) return root.getByText(plan.arg, { exact: true }).locator("xpath=..").getByRole(step.role || "textbox", { includeHidden: opts.includeHidden });
@@ -4013,7 +4071,14 @@ async function checkAssertion(page, kind, value, timeoutMs = 3e3, assertion) {
4013
4071
  const target = assertion?.target && kind !== "count" ? await locate(page, asStep(assertion.target), { includeHidden: aboutAbsence }) : void 0;
4014
4072
  if (kind === "fields_visible") {
4015
4073
  for (const name of Array.isArray(value) ? value : [value]) {
4016
- await page.getByLabel(name, { exact: true }).or(page.getByRole("textbox", { name, exact: true })).waitFor({ state: "visible", timeout: remaining() });
4074
+ const field = page.getByLabel(name, { exact: true }).or(page.getByRole("textbox", { name, exact: true })).filter({ visible: true });
4075
+ let seen = 0;
4076
+ do {
4077
+ seen = await field.count().catch(() => 0);
4078
+ if (seen > 0) break;
4079
+ await new Promise((r) => setTimeout(r, 50));
4080
+ } while (Date.now() < deadline);
4081
+ if (seen === 0) throw new Error(`no visible field named "${name}"`);
4017
4082
  }
4018
4083
  return `fields visible: ${Array.isArray(value) ? value.join(", ") : value}`;
4019
4084
  }
@@ -5007,6 +5072,50 @@ async function describePick(page, payload) {
5007
5072
  } catch {
5008
5073
  }
5009
5074
  }
5075
+ function preferIndependentIdentity(target) {
5076
+ if (!identifiedByOwnWords(target)) return;
5077
+ const independent = textIndependent(target["candidates"]);
5078
+ if (independent) target["locator"] = independent;
5079
+ }
5080
+ async function tellApart(page, target, suggested, marker) {
5081
+ const asStep = (over = {}) => ({
5082
+ id: "pick",
5083
+ type: "click",
5084
+ value: "",
5085
+ secret: false,
5086
+ legacySelector: "",
5087
+ proposals: [],
5088
+ scope: "",
5089
+ ...target,
5090
+ ...over
5091
+ });
5092
+ const matches = async (over) => {
5093
+ try {
5094
+ return await (await locateAll(page, asStep(over))).count();
5095
+ } catch {
5096
+ return -1;
5097
+ }
5098
+ };
5099
+ const bare = await matches();
5100
+ if (bare <= 1) return {};
5101
+ if (suggested?.scopeRole) {
5102
+ const scoped = { scope: suggested.scope ?? "", scopeRole: suggested.scopeRole };
5103
+ if (await matches(scoped) === 1) return scoped;
5104
+ }
5105
+ const all = await (await locateAll(page, asStep())).elementHandles();
5106
+ try {
5107
+ for (const [index, handle] of all.entries()) {
5108
+ const isIt = await handle.evaluate((el, key) => el === window[key], marker).catch(() => false);
5109
+ if (isIt) return { nth: index };
5110
+ }
5111
+ } finally {
5112
+ await Promise.all(all.map((h) => h.dispose().catch(() => {
5113
+ })));
5114
+ }
5115
+ return {
5116
+ warning: `${bare} elements on this page are called "${String(target["name"] ?? "")}" and nothing here tells them apart \u2014 give it a test ID, or choose a locator before running.`
5117
+ };
5118
+ }
5010
5119
  var OUTCOME_WINDOW_MS = 2500;
5011
5120
  var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
5012
5121
  var COMMITS = /* @__PURE__ */ new Set([
@@ -5188,6 +5297,11 @@ async function startRecordingSession(opts) {
5188
5297
  ...payload.nameFrom ? { nameFrom: payload.nameFrom } : {},
5189
5298
  scope: payload.scope ?? "",
5190
5299
  ...payload.scopeRole ? { scopeRole: payload.scopeRole } : {},
5300
+ // WHICH OF SEVERAL IDENTICAL ONES, when nothing else separates them.
5301
+ // Worked out by the driver while the page still showed both — see
5302
+ // `tellApart` — and dropped here until now, so the answer was computed
5303
+ // and then quietly thrown away.
5304
+ ...typeof payload.nth === "number" ? { nth: payload.nth } : {},
5191
5305
  ...payload.frame?.length ? { frame: payload.frame } : {},
5192
5306
  ...payload.to ? { to: payload.to } : {},
5193
5307
  ...payload.locator ? { locator: payload.locator } : {},
@@ -5231,6 +5345,18 @@ async function startRecordingSession(opts) {
5231
5345
  }
5232
5346
  const before = payload.__before ?? signature;
5233
5347
  delete payload.__before;
5348
+ const ticket = payload.__toldApart;
5349
+ delete payload.__toldApart;
5350
+ if (typeof ticket === "number" && answers.has(ticket)) {
5351
+ const told = await answers.get(ticket);
5352
+ answers.delete(ticket);
5353
+ if (told?.scopeRole) {
5354
+ payload.scope = told.scope ?? "";
5355
+ payload.scopeRole = told.scopeRole;
5356
+ }
5357
+ if (told?.nth !== void 0) payload.nth = told.nth;
5358
+ if (told?.warning && !payload.warning) payload.warning = told.warning;
5359
+ }
5234
5360
  const chain = src?.frame ? frameChains.get(src.frame) : void 0;
5235
5361
  if (chain?.length) payload.frame = chain;
5236
5362
  if (payload.type === "press" && payload.value === "Enter") {
@@ -5259,10 +5385,22 @@ async function startRecordingSession(opts) {
5259
5385
  const chain = src?.frame ? frameChains.get(src.frame) : void 0;
5260
5386
  if (chain?.length) payload.target.frame = chain;
5261
5387
  if (src.page) payload.target.pageId = pageIds.get(src.page) ?? "main";
5388
+ preferIndependentIdentity(payload.target);
5262
5389
  await describePick(src.page ?? page, payload);
5390
+ if (payload.readings) payload.readings.namedByOwnWords = identifiedByOwnWords(payload.target);
5263
5391
  void session.setPicking(false);
5264
5392
  void toPanel({ picked: payload });
5265
5393
  });
5394
+ const answers = /* @__PURE__ */ new Map();
5395
+ await context.exposeBinding("__flTellApart", async (src, payload) => {
5396
+ if (paused || stopped || !payload?.target) return {};
5397
+ const work = tellApart(src.page ?? page, payload.target, payload.suggested, String(payload.marker ?? "__flTellingApart")).catch(() => ({}));
5398
+ if (typeof payload.ticket === "number") {
5399
+ answers.set(payload.ticket, work);
5400
+ void work.finally(() => setTimeout(() => answers.delete(payload.ticket), 1e4).unref?.());
5401
+ }
5402
+ return await work;
5403
+ });
5266
5404
  await context.exposeBinding("__flStop", () => {
5267
5405
  onStopRequested?.(true);
5268
5406
  });
@@ -5411,8 +5549,8 @@ async function startRecordingSession(opts) {
5411
5549
  legacySelector: "",
5412
5550
  proposals: [parsed]
5413
5551
  };
5414
- if ((parsed.kind === "text" || parsed.kind === "class" || parsed.kind === "attribute") && parsed.target?.nameFrom === "text" && !parsed.target.locator) {
5415
- step.warning = "This element is identified by its own text, so a change to that text reads as a missing element rather than a failed check. Give it a test ID or a locator to tell the two apart.";
5552
+ if ((parsed.kind === "text" || parsed.kind === "class" || parsed.kind === "attribute") && identifiedByOwnWords(parsed.target)) {
5553
+ step.warning = "Nothing identifies this element except the text being checked, so a change to that text reads as a missing element rather than a failed check. Give it a test ID, or choose a locator.";
5416
5554
  }
5417
5555
  RecordedStepSchema.parse(step);
5418
5556
  if (pendingScrollPos) {
@@ -5703,6 +5841,7 @@ async function startDebugSession(opts) {
5703
5841
  return;
5704
5842
  }
5705
5843
  if (!payload?.target) return;
5844
+ preferIndependentIdentity(payload.target);
5706
5845
  await describePick(src.page ?? page, payload);
5707
5846
  void session.setPicking(false);
5708
5847
  void toPanel({ picked: payload });
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  resolveCheckouts,
9
9
  start,
10
10
  status
11
- } from "./chunk-O3S4QSN4.js";
11
+ } from "./chunk-5J5D7IIT.js";
12
12
 
13
13
  // src/cli.ts
14
14
  import { parseArgs } from "util";
package/dist/engine.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  resolveCheckouts,
10
10
  start,
11
11
  status
12
- } from "./chunk-O3S4QSN4.js";
12
+ } from "./chunk-5J5D7IIT.js";
13
13
  export {
14
14
  AGENT_VERSION,
15
15
  browsersReady,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowriki/agent",
3
- "version": "0.1.0-beta.22",
3
+ "version": "0.1.0-beta.23",
4
4
  "description": "Run Flowriki UI tests on your own computer. Connects this machine to your Flowriki account.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",