@browserbasehq/orca 3.2.1-preview.1 → 3.2.1-preview.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/lib/inference.js +1 -1
  2. package/dist/cjs/lib/inference.js.map +1 -1
  3. package/dist/cjs/lib/v3/dom/build/a11yScripts.generated.js +11 -11
  4. package/dist/cjs/lib/v3/dom/build/a11yScripts.generated.js.map +1 -1
  5. package/dist/cjs/lib/v3/dom/build/locatorScripts.generated.js +47 -47
  6. package/dist/cjs/lib/v3/dom/build/locatorScripts.generated.js.map +1 -1
  7. package/dist/cjs/lib/v3/dom/build/reRenderScriptContent.js +1 -1
  8. package/dist/cjs/lib/v3/dom/build/reRenderScriptContent.js.map +1 -1
  9. package/dist/cjs/lib/v3/dom/build/screenshotScripts.generated.js +1 -1
  10. package/dist/cjs/lib/v3/dom/build/screenshotScripts.generated.js.map +1 -1
  11. package/dist/cjs/lib/v3/dom/build/scriptV3Content.js +1 -1
  12. package/dist/cjs/lib/v3/dom/build/scriptV3Content.js.map +1 -1
  13. package/dist/cjs/lib/v3/llm/aisdk.js +0 -5
  14. package/dist/cjs/lib/v3/llm/aisdk.js.map +1 -1
  15. package/dist/cjs/tests/unit/aisdk-clients.test.js +0 -4
  16. package/dist/cjs/tests/unit/aisdk-clients.test.js.map +1 -1
  17. package/dist/esm/lib/inference.js +1 -1
  18. package/dist/esm/lib/inference.js.map +1 -1
  19. package/dist/esm/lib/v3/dom/build/a11yScripts.generated.js +11 -11
  20. package/dist/esm/lib/v3/dom/build/a11yScripts.generated.js.map +1 -1
  21. package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js +47 -47
  22. package/dist/esm/lib/v3/dom/build/locatorScripts.generated.js.map +1 -1
  23. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.js +1 -1
  24. package/dist/esm/lib/v3/dom/build/reRenderScriptContent.js.map +1 -1
  25. package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.js +1 -1
  26. package/dist/esm/lib/v3/dom/build/screenshotScripts.generated.js.map +1 -1
  27. package/dist/esm/lib/v3/dom/build/scriptV3Content.js +1 -1
  28. package/dist/esm/lib/v3/dom/build/scriptV3Content.js.map +1 -1
  29. package/dist/esm/lib/v3/llm/aisdk.js +0 -5
  30. package/dist/esm/lib/v3/llm/aisdk.js.map +1 -1
  31. package/dist/esm/tests/unit/aisdk-clients.test.js +0 -4
  32. package/dist/esm/tests/unit/aisdk-clients.test.js.map +1 -1
  33. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"locatorScripts.generated.js","sourceRoot":"","sources":["../../../../../../lib/v3/dom/build/locatorScripts.generated.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,sBAAsB,GAAG,0rtBAA0rtB,CAAC;AACpttB,QAAA,oBAAoB,GAAG;IAClC,kCAAkC,EAAE,8tBAA8tB;IAClwB,uBAAuB,EAAE,ktBAAktB;IAC3uB,wBAAwB,EAAE,sgBAAsgB;IAChiB,kBAAkB,EAAE,ugDAAugD;IAC3hD,4BAA4B,EAAE,+CAA+C;IAC7E,kBAAkB,EAAE,yRAAyR;IAC7S,wBAAwB,EAAE,8IAA8I;IACxK,kBAAkB,EAAE,mlDAAmlD;IACvmD,cAAc,EAAE,0EAA0E;IAC1F,kBAAkB,EAAE,8PAA8P;IAClR,kBAAkB,EAAE,mZAAmZ;IACva,yBAAyB,EAAE,imBAAimB;IAC5nB,sBAAsB,EAAE,0EAA0E;IAClG,sBAAsB,EAAE,mKAAmK;IAC3L,uBAAuB,EAAE,qNAAqN;IAC9O,wBAAwB,EAAE,4EAA4E;IACtG,oBAAoB,EAAE,sGAAsG;IAC5H,0BAA0B,EAAE,8uBAA8uB;IAC1wB,qBAAqB,EAAE,o5CAAo5C;IAC36C,uBAAuB,EAAE,8DAA8D;IACvF,wBAAwB,EAAE,45BAA45B;IACt7B,sBAAsB,EAAE,snBAAsnB;IAC9oB,iBAAiB,EAAE,+lCAA+lC;CAC1mC,CAAC;AACE,QAAA,uBAAuB,GAAG;IACrC,kCAAkC,EAAE,uEAAuE;IAC3G,uBAAuB,EAAE,4DAA4D;IACrF,wBAAwB,EAAE,6DAA6D;IACvF,kBAAkB,EAAE,uDAAuD;IAC3E,4BAA4B,EAAE,iEAAiE;IAC/F,kBAAkB,EAAE,uDAAuD;IAC3E,wBAAwB,EAAE,6DAA6D;IACvF,kBAAkB,EAAE,uDAAuD;IAC3E,cAAc,EAAE,mDAAmD;IACnE,kBAAkB,EAAE,uDAAuD;IAC3E,kBAAkB,EAAE,uDAAuD;IAC3E,yBAAyB,EAAE,8DAA8D;IACzF,sBAAsB,EAAE,2DAA2D;IACnF,sBAAsB,EAAE,2DAA2D;IACnF,uBAAuB,EAAE,4DAA4D;IACrF,wBAAwB,EAAE,6DAA6D;IACvF,oBAAoB,EAAE,yDAAyD;IAC/E,0BAA0B,EAAE,+DAA+D;IAC3F,qBAAqB,EAAE,0DAA0D;IACjF,uBAAuB,EAAE,4DAA4D;IACrF,wBAAwB,EAAE,6DAA6D;IACvF,sBAAsB,EAAE,2DAA2D;IACnF,iBAAiB,EAAE,sDAAsD;CACjE,CAAC","sourcesContent":["/*\n * AUTO-GENERATED FILE. DO NOT EDIT.\n * Update sources in lib/v3/dom/locatorScripts and run genLocatorScripts.ts.\n */\nexport const locatorScriptBootstrap = \"if (!globalThis.__stagehandLocatorScripts) { var __stagehandLocatorScriptsFactory=(()=>{var M=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var Z=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},j=(e,t,n,o)=>{if(t&&typeof t==\\\"object\\\"||typeof t==\\\"function\\\")for(let r of U(t))!Q.call(e,r)&&r!==n&&M(e,r,{get:()=>t[r],enumerable:!(o=K(t,r))||o.enumerable});return e};var J=e=>j(M({},\\\"__esModule\\\",{value:!0}),e);var Oe={};Z(Oe,{assignFilePayloadsToInputElement:()=>te,countCssMatchesPierce:()=>Me,countCssMatchesPrimary:()=>Ce,countTextMatches:()=>Le,countXPathMatchesMainWorld:()=>Pe,dispatchDomClick:()=>ne,ensureFileInputElement:()=>ee,fillElementValue:()=>se,focusElement:()=>le,isElementChecked:()=>ce,isElementVisible:()=>ae,prepareElementForTyping:()=>v,readElementInnerHTML:()=>me,readElementInnerText:()=>fe,readElementInputValue:()=>ue,readElementTextContent:()=>de,resolveCssSelector:()=>ve,resolveCssSelectorPierce:()=>Te,resolveTextSelector:()=>Re,resolveXPathMainWorld:()=>Ne,scrollElementToPercent:()=>oe,selectElementOptions:()=>ie,waitForSelector:()=>_e});function ee(){try{return(this.tagName?.toLowerCase()??\\\"\\\")!==\\\"input\\\"?!1:String(this.type??\\\"\\\").toLowerCase()===\\\"file\\\"}catch{return!1}}function te(e){try{let t=this;if(!t||t.tagName?.toLowerCase()!==\\\"input\\\"||(t.type??\\\"\\\").toLowerCase()!==\\\"file\\\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(e)?e:[];for(let r of o){if(!r)continue;let l=r.name||\\\"upload.bin\\\",s=r.mimeType||\\\"application/octet-stream\\\",i=typeof r.lastModified==\\\"number\\\"?r.lastModified:Date.now(),a=window.atob(r.base64??\\\"\\\"),d=new Uint8Array(a.length);for(let p=0;p<a.length;p+=1)d[p]=a.charCodeAt(p);let f=new Blob([d],{type:s}),c=new File([f],l,{type:s,lastModified:i});n.items.add(c)}return t.files=n.files,t.dispatchEvent(new Event(\\\"input\\\",{bubbles:!0})),t.dispatchEvent(new Event(\\\"change\\\",{bubbles:!0})),!0}catch{return!1}}function ne(e){let t=e??{};try{let n=new MouseEvent(\\\"click\\\",{bubbles:!!t.bubbles,cancelable:!!t.cancelable,composed:!!t.composed,detail:typeof t.detail==\\\"number\\\"?t.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}function oe(e){let t=n=>{if(typeof n==\\\"number\\\"&&Number.isFinite(n))return n;let o=String(n??\\\"\\\").trim();if(!o)return 0;let r=parseFloat(o.replace(\\\"%\\\",\\\"\\\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(t(e),100)),o=this,r=o.tagName?.toLowerCase()??\\\"\\\";if(r===\\\"html\\\"||r===\\\"body\\\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\\\"smooth\\\"}),!0}let s=o.scrollHeight??0,i=o.clientHeight??0,d=Math.max(0,s-i)*(n/100);return o.scrollTo({top:d,left:o.scrollLeft??0,behavior:\\\"smooth\\\"}),!0}catch{return!1}}var H=new Set([\\\"color\\\",\\\"date\\\",\\\"datetime-local\\\",\\\"month\\\",\\\"range\\\",\\\"time\\\",\\\"week\\\"]),re=new Set([\\\"\\\",\\\"email\\\",\\\"number\\\",\\\"password\\\",\\\"search\\\",\\\"tel\\\",\\\"text\\\",\\\"url\\\"]);function v(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument||document,n=t.defaultView||window;try{typeof e.focus==\\\"function\\\"&&e.focus()}catch{}if(e instanceof n.HTMLInputElement||e instanceof n.HTMLTextAreaElement){try{if(typeof e.select==\\\"function\\\")return e.select(),!0}catch{}try{let o=(e.value??\\\"\\\").length;if(typeof e.setSelectionRange==\\\"function\\\")return e.setSelectionRange(0,o),!0}catch{}return!0}if(e.isContentEditable){let o=t.getSelection?.(),r=t.createRange?.();if(o&&r)try{r.selectNodeContents(e),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}function se(e){let t=this;if(!t.isConnected)return{status:\\\"error\\\",reason:\\\"notconnected\\\"};let o=(t.ownerDocument||document).defaultView||window,r=e??\\\"\\\";try{let l=s=>{let i;if(typeof o.InputEvent==\\\"function\\\")try{i=new o.InputEvent(\\\"input\\\",{bubbles:!0,composed:!0,data:s,inputType:\\\"insertText\\\"})}catch{i=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0})}else i=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0});t.dispatchEvent(i);let a=new o.Event(\\\"change\\\",{bubbles:!0});t.dispatchEvent(a)};if(t instanceof o.HTMLInputElement){let s=(t.type||\\\"\\\").toLowerCase();if(!re.has(s)&&!H.has(s))return{status:\\\"error\\\",reason:`unsupported-input-type:${s}`};let i=e;if(s===\\\"number\\\"){let a=e.trim();if(a!==\\\"\\\"&&Number.isNaN(Number(a)))return{status:\\\"error\\\",reason:\\\"invalid-number-value\\\"};i=a}if(r=i,H.has(s)){let a=e.trim();r=a,v.call(t);let d=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(d,\\\"value\\\")?.set;return typeof c==\\\"function\\\"?c.call(t,a):t.value=a,t._valueTracker?.setValue?.(a),t.value!==a?{status:\\\"error\\\",reason:\\\"malformed-value\\\"}:(l(a),{status:\\\"done\\\"})}return v.call(t),{status:\\\"needsinput\\\",value:i}}return t instanceof o.HTMLTextAreaElement?(v.call(t),r=e,{status:\\\"needsinput\\\",value:e}):t instanceof o.HTMLSelectElement?{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}:t.isContentEditable?(v.call(t),r=e,{status:\\\"needsinput\\\",value:e}):{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}}catch(l){let s=\\\"exception\\\";if(l&&typeof l==\\\"object\\\"){let i=l.message;typeof i==\\\"string\\\"&&i.trim().length>0&&(s=`exception:${i}`)}return{status:\\\"needsinput\\\",value:r,reason:s}}}function le(){try{typeof this.focus==\\\"function\\\"&&this.focus()}catch{}}function ie(e){try{if(!(this instanceof HTMLSelectElement))return[];let t=Array.isArray(e)?e:[e],n=new Set(t.map(s=>String(s??\\\"\\\").trim())),o=s=>{let i=(s.label||s.textContent||\\\"\\\").trim(),a=String(s.value??\\\"\\\").trim();return n.has(i)||n.has(a)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let i of Array.from(this.options))!s&&o(i)?(i.selected=!0,this.value=i.value,s=!0):i.selected=!1}let r=new Event(\\\"input\\\",{bubbles:!0}),l=new Event(\\\"change\\\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}function ae(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument?.defaultView?.getComputedStyle(e)??window.getComputedStyle(e);if(!t||t.display===\\\"none\\\"||t.visibility===\\\"hidden\\\")return!1;let n=parseFloat(t.opacity??\\\"1\\\");if(!Number.isFinite(n)||n===0)return!1;let o=e.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||e.getClientRects().length===0)}catch{return!1}}function ce(){try{let e=this;if((e.tagName||\\\"\\\").toLowerCase()===\\\"input\\\"){let o=e.type?.toLowerCase()??\\\"\\\";if(o===\\\"checkbox\\\"||o===\\\"radio\\\")return!!e.checked}let n=e.getAttribute?.(\\\"aria-checked\\\");return n!=null?n===\\\"true\\\":!1}catch{return!1}}function ue(){try{let e=this,t=(e.tagName||\\\"\\\").toLowerCase();return t===\\\"input\\\"||t===\\\"textarea\\\"||t===\\\"select\\\"?String(e.value??\\\"\\\"):e.isContentEditable?String(e.textContent??\\\"\\\"):\\\"\\\"}catch{return\\\"\\\"}}function de(){try{return String(this.textContent??\\\"\\\")}catch{return\\\"\\\"}}function me(){try{return String(this.innerHTML??\\\"\\\")}catch{return\\\"\\\"}}function fe(){try{let e=this,t=e.innerText;if(typeof t==\\\"string\\\"&&t.length>0)return t;let n=e.textContent;return typeof n==\\\"string\\\"?n:\\\"\\\"}catch{return\\\"\\\"}}function O(e){let t=String(e||\\\"\\\").trim().replace(/^xpath=/i,\\\"\\\");if(!t)return[];let n=[],o=0;for(;o<t.length;){let r=\\\"child\\\";t.startsWith(\\\"//\\\",o)?(r=\\\"desc\\\",o+=2):t[o]===\\\"/\\\"&&(r=\\\"child\\\",o+=1);let l=o,s=0,i=null;for(;o<t.length;){let c=t[o];if(i)c===i&&(i=null);else if(c===\\\"'\\\"||c==='\\\"')i=c;else if(c===\\\"[\\\")s++;else if(c===\\\"]\\\")s--;else if(c===\\\"/\\\"&&s===0)break;o+=1}let a=t.slice(l,o).trim();if(!a)continue;let{tag:d,predicates:f}=pe(a);n.push({axis:r,tag:d,predicates:f})}return n}function he(e){let t=[],n=0;for(;n<e.length;){if(e[n]!==\\\"[\\\"){n++;continue}n++;let o=n,r=null;for(;n<e.length;){let l=e[n];if(r)l===r&&(r=null);else if(l===\\\"'\\\"||l==='\\\"')r=l;else if(l===\\\"]\\\")break;n++}t.push(e.slice(o,n).trim()),n++}return t}function pe(e){let t=e.indexOf(\\\"[\\\");if(t===-1)return{tag:e===\\\"\\\"?\\\"*\\\":e.toLowerCase(),predicates:[]};let n=e.slice(0,t).trim(),o=n===\\\"\\\"?\\\"*\\\":n.toLowerCase(),r=e.slice(t),l=[];for(let s of he(r)){let i=T(s);i&&l.push(i)}return{tag:o,predicates:l}}function T(e){let t=e.trim();if(!t)return null;let n=A(t,\\\"or\\\");if(n.length>1){let l=n.map(s=>T(s)).filter(Boolean);return l.length!==n.length?null:{type:\\\"or\\\",predicates:l}}let o=A(t,\\\"and\\\");if(o.length>1){let l=o.map(s=>T(s)).filter(Boolean);return l.length!==o.length?null:{type:\\\"and\\\",predicates:l}}let r=we(t,\\\"not\\\");if(r!=null){let l=T(r);return l?{type:\\\"not\\\",predicate:l}:null}return ge(t)}function ge(e){let t=/^(?:'([^']*)'|\\\"([^\\\"]*)\\\")$/,n=\\\"[a-zA-Z_][\\\\\\\\w.-]*\\\",o=`(?:'([^']*)'|\\\"([^\\\"]*)\\\")`;if(/^\\\\d+$/.test(e))return{type:\\\"index\\\",index:Math.max(1,Number(e))};let r=e.match(new RegExp(`^normalize-space\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*\\\\\\\\)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(r)return{type:\\\"attrEquals\\\",name:r[1],value:r[2]??r[3]??\\\"\\\",normalize:!0};let l=e.match(new RegExp(`^normalize-space\\\\\\\\(\\\\\\\\s*(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*\\\\\\\\)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(l)return{type:\\\"textEquals\\\",value:l[1]??l[2]??\\\"\\\",normalize:!0};let s=e.match(new RegExp(`^@(${n})\\\\\\\\s*=\\\\\\\\s*${o}$`));if(s)return{type:\\\"attrEquals\\\",name:s[1],value:s[2]??s[3]??\\\"\\\"};let i=e.match(new RegExp(`^@(${n})$`));if(i)return{type:\\\"attrExists\\\",name:i[1]};let a=e.match(new RegExp(`^contains\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));if(a)return{type:\\\"attrContains\\\",name:a[1],value:a[2]??a[3]??\\\"\\\"};let d=e.match(new RegExp(`^starts-with\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));if(d)return{type:\\\"attrStartsWith\\\",name:d[1],value:d[2]??d[3]??\\\"\\\"};let f=e.match(new RegExp(`^(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(f)return{type:\\\"textEquals\\\",value:f[1]??f[2]??\\\"\\\"};let c=e.match(new RegExp(`^contains\\\\\\\\(\\\\\\\\s*(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));return c?{type:\\\"textContains\\\",value:c[1]??c[2]??\\\"\\\"}:(t.test(e),null)}function A(e,t){let n=[],o=0,r=0,l=null,s=0;for(;s<e.length;){let i=e[s];if(l){i===l&&(l=null),s+=1;continue}if(i===\\\"'\\\"||i==='\\\"'){l=i,s+=1;continue}if(i===\\\"(\\\"){r+=1,s+=1;continue}if(i===\\\")\\\"){r=Math.max(0,r-1),s+=1;continue}if(r===0&&Ee(e,s,t)){n.push(e.slice(o,s).trim()),s+=t.length,o=s;continue}s+=1}return n.push(e.slice(o).trim()),n.filter(i=>i.length>0)}function Ee(e,t,n){if(!e.startsWith(n,t))return!1;let o=t>0?e[t-1]:\\\" \\\";if(o===\\\"@\\\")return!1;let r=t+n.length<e.length?e[t+n.length]:\\\" \\\";return W(o)&&W(r)}function W(e){return!/[a-zA-Z0-9_.-]/.test(e)}function we(e,t){let n=`${t}(`;if(!e.startsWith(n)||!e.endsWith(\\\")\\\"))return null;let o=e.slice(n.length,-1);return ye(o)?o:null}function ye(e){let t=0,n=null;for(let o=0;o<e.length;o+=1){let r=e[o];if(n){r===n&&(n=null);continue}if(r===\\\"'\\\"||r==='\\\"'){n=r;continue}if(r===\\\"(\\\"?t+=1:r===\\\")\\\"&&(t-=1),t<0)return!1}return t===0}var be=e=>e.replace(/\\\\s+/g,\\\" \\\").trim();function _(e){return String(e.textContent??\\\"\\\")}function S(e,t){return t?be(e):e}function R(e,t){switch(t.type){case\\\"and\\\":return t.predicates.every(n=>R(e,n));case\\\"or\\\":return t.predicates.some(n=>R(e,n));case\\\"not\\\":return!R(e,t.predicate);case\\\"attrExists\\\":return e.getAttribute(t.name)!==null;case\\\"attrEquals\\\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize)===S(t.value,t.normalize)}case\\\"attrContains\\\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize).includes(S(t.value,t.normalize))}case\\\"attrStartsWith\\\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize).startsWith(S(t.value,t.normalize))}case\\\"textEquals\\\":return S(_(e),t.normalize)===S(t.value,t.normalize);case\\\"textContains\\\":return S(_(e),t.normalize).includes(S(t.value,t.normalize));case\\\"index\\\":return!0;default:return!0}}function q(e,t){let n=e;for(let o of t){if(!n.length)return[];if(o.type===\\\"index\\\"){let r=o.index-1;n=r>=0&&r<n.length?[n[r]]:[];continue}n=n.filter(r=>R(r,o))}return n}var P=e=>{let t=String(e??\\\"\\\").trim();return t?t.replace(/^xpath=/i,\\\"\\\").trim():\\\"\\\"};function I(e,t){return k(e,0,t)}function k(e,t,n){if(!Number.isFinite(t)||t<0)return null;let o=P(e);if(!o)return null;let r=Math.floor(t),l=n?.pierceShadow!==!1,s=l?z():null;if(!l)return X(o,r).value;if(!s?.hasShadow){let a=X(o,r);return a.error?N(o,s?.getClosedRoot)[r]??null:a.value}return N(o,s.getClosedRoot)[r]??null}function $(e,t){let n=P(e);if(!n)return 0;let o=t?.pierceShadow!==!1,r=o?z():null;if(!o)return F(n).count;if(!r?.hasShadow){let l=F(n);return l.error?N(n,r?.getClosedRoot).length:l.count}return N(n,r.getClosedRoot).length}function N(e,t){let n=P(e);if(!n)return[];let o=O(n);if(!o.length)return[];let r=t??null,l=[document];for(let s of o){let i=[],a=new Set;for(let d of l){if(!d)continue;let f=s.axis===\\\"child\\\"?L(d,r):Se(d,r);if(!f.length)continue;let c=f.filter(g=>xe(g,s)),p=q(c,s.predicates);for(let g of p)a.has(g)||(a.add(g),i.push(g))}if(!i.length)return[];l=i}return l}function xe(e,t){return t.tag===\\\"*\\\"?!0:e.localName===t.tag}function z(){let e=window.__stagehandV3__,t=e&&typeof e.getClosedRoot==\\\"function\\\"?o=>{try{return e.getClosedRoot(o)??null}catch{return null}}:null,n=!1;try{if(e&&typeof e.stats==\\\"function\\\"){let o=e.stats();n=(o?.open??0)>0||(o?.closed??0)>0}}catch{}if(!n)try{let o=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;o.nextNode();)if(o.currentNode.shadowRoot){n=!0;break}}catch{}return{getClosedRoot:t,hasShadow:n}}function L(e,t){let n=[];if(!e)return n;if(e instanceof Document)return e.documentElement&&n.push(e.documentElement),n;if(e instanceof ShadowRoot||e instanceof DocumentFragment)return n.push(...Array.from(e.children??[])),n;if(e instanceof Element){n.push(...Array.from(e.children??[]));let o=e.shadowRoot;if(o&&n.push(...Array.from(o.children??[])),t){let r=t(e);r&&n.push(...Array.from(r.children??[]))}return n}return n}function Se(e,t){let n=[],o=new Set,r=[...L(e,t)].reverse();for(;r.length;){let l=r.pop();if(!l||o.has(l))continue;o.add(l),n.push(l);let s=L(l,t);for(let i=s.length-1;i>=0;i-=1)r.push(s[i])}return n}function X(e,t){try{return{value:document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(t),error:!1}}catch{return{value:null,error:!0}}}function F(e){try{return{count:document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength,error:!1}}catch{return{count:0,error:!0}}}var C=e=>{let t=Number(e??0);return!Number.isFinite(t)||t<0?0:Math.floor(t)},V=(e,t)=>{if(!e)return[];let n=new WeakSet,o=new Set,r=[],l=[document],s=i=>{if(!(!i||n.has(i)||r.length>=t)){n.add(i);try{let a=i.querySelectorAll(e);for(let d of a)if(!o.has(d)&&(o.add(d),r.push(d),r.length>=t))return}catch{}try{let d=(i instanceof Document?i:i.host?.ownerDocument??document).createTreeWalker(i,NodeFilter.SHOW_ELEMENT),f;for(;f=d.nextNode();){if(!(f instanceof Element))continue;let c=f.shadowRoot;c&&l.push(c)}}catch{}}};for(;l.length&&r.length<t;){let i=l.shift();i&&s(i)}return r};function ve(e,t){let n=String(e??\\\"\\\").trim();if(!n)return null;let o=C(t);return V(n,o+1)[o]??null}function Te(e,t){let n=String(e??\\\"\\\").trim();if(!n)return null;let o=C(t),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\\\"function\\\")return V(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,i=new Set,a=[],d=[document],f=c=>{if(!(!c||s.has(c)||a.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!i.has(g)&&(i.add(g),a.push(g),a.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&d.push(x);let y=l(w);y&&d.push(y)}}catch{}}};for(;d.length&&a.length<o+1;){let c=d.shift();c&&f(c)}return a[o]??null}function Re(e,t){let n=String(e??\\\"\\\");if(!n)return null;let o=n.toLowerCase(),r=C(t),l=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),s=u=>{if(!u)return!1;let h=u.tagName?.toUpperCase()??\\\"\\\";return l.has(h)},i=u=>{try{if(s(u))return\\\"\\\";let h=u.innerText;if(typeof h==\\\"string\\\"&&h.trim())return h.trim()}catch{}try{let h=u.textContent;if(typeof h==\\\"string\\\")return h.trim()}catch{}return\\\"\\\"},a=u=>{let h=i(u);return!!h&&h.toLowerCase().includes(o)},d=window.__stagehandV3__,f=d&&typeof d.getClosedRoot==\\\"function\\\"?u=>{try{return d.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&a(u)&&g.push({element:u,tag:u.tagName??\\\"\\\",id:u.id??\\\"\\\",className:u.className??\\\"\\\",text:i(u)});let h=x(u);if(!h)continue;let E;for(;E=h.nextNode();){if(!(E instanceof Element))continue;a(E)&&g.push({element:E,tag:E.tagName??\\\"\\\",id:E.id??\\\"\\\",className:E.className??\\\"\\\",text:i(E)});let b=E.shadowRoot;b&&w(b);let D=f(E);D&&w(D)}}let y=[];for(let u of g){let h=u.element,E=!1;for(let b of g)if(u!==b)try{if(h.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}function Ne(e,t){let n=C(t);return k(e,n,{pierceShadow:!0})}function Ce(e){let t=String(e??\\\"\\\").trim();if(!t)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\\\"function\\\"&&(l+=s.querySelectorAll(t).length)}catch{}try{let i=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();)a instanceof Element&&a.shadowRoot&&(l+=o(a.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(t).length}catch{return 0}}}function Me(e){let t=String(e??\\\"\\\").trim();if(!t)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\\\"function\\\")try{return document.querySelectorAll(t).length}catch{return 0}let o=new WeakSet,r=[],l=a=>{!a||o.has(a)||(o.add(a),r.push(a))};l(document);let s=0,i=a=>{let d=a.shadowRoot;d&&l(d);try{let f=n.getClosedRoot(a);f&&l(f)}catch{}};for(;r.length;){let a=r.shift();if(a){try{let d=a;typeof d.querySelectorAll==\\\"function\\\"&&(s+=d.querySelectorAll(t).length)}catch{}try{let f=(a instanceof Document?a:a instanceof ShadowRoot?a.host?.ownerDocument??document:a.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&i(c)}catch{}}}return s}function Le(e){let t=String(e??\\\"\\\");if(!t)return{count:0,sample:[],error:null};let n=t.toLowerCase(),o=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),r=m=>{if(!m)return!1;let u=m.tagName?.toUpperCase()??\\\"\\\";return o.has(u)},l=m=>{try{if(r(m))return\\\"\\\";let u=m.innerText;if(typeof u==\\\"string\\\"&&u.trim())return u.trim()}catch{}try{let u=m.textContent;if(typeof u==\\\"string\\\")return u.trim()}catch{}return\\\"\\\"},s=m=>{let u=l(m);return!!u&&u.toLowerCase().includes(n)},i=window.__stagehandV3__,a=i&&typeof i.getClosedRoot==\\\"function\\\"?m=>{try{return i.getClosedRoot(m)??null}catch{return null}}:m=>null,d=new WeakSet,f=[],c=m=>{!m||d.has(m)||(d.add(m),f.push(m))},p=m=>{try{return(m instanceof Document?m:m?.ownerDocument??document).createTreeWalker(m,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let m=f.shift();if(!m)continue;m instanceof Element&&s(m)&&g.push({element:m,tag:m.tagName??\\\"\\\",id:m.id??\\\"\\\",className:m.className??\\\"\\\",text:l(m)});let u=p(m);if(!u)continue;let h;for(;h=u.nextNode();){if(!(h instanceof Element))continue;s(h)&&g.push({element:h,tag:h.tagName??\\\"\\\",id:h.id??\\\"\\\",className:h.className??\\\"\\\",text:l(h)});let E=h.shadowRoot;E&&c(E);let b=a(h);b&&c(b)}}let w=[];for(let m of g){let u=m.element,h=!1;for(let E of g)if(m!==E)try{if(u.contains(E.element)){h=!0;break}}catch{}h||w.push(m)}let x=w.length,y=w.slice(0,5).map(m=>({tag:m.tag,id:m.id,class:m.className,text:m.text}));return{count:x,sample:y,error:null}}function Pe(e){return $(e,{pierceShadow:!0})}var ke=e=>e.startsWith(\\\"xpath=\\\")||e.startsWith(\\\"/\\\"),De=e=>{try{let t=window.__stagehandV3__;if(t&&typeof t.getClosedRoot==\\\"function\\\")return t.getClosedRoot(e)??null}catch{}return null},Y=e=>e.shadowRoot?e.shadowRoot:De(e),He=(e,t,n)=>{try{let l=e.querySelector(t);if(l)return l}catch{}if(!n)return null;let o=new WeakSet,r=[e];for(;r.length>0;){let l=r.shift();if(!(!l||o.has(l))){o.add(l);try{let s=l.querySelector(t);if(s)return s}catch{}try{let i=(l instanceof Document?l:l.host?.ownerDocument??document).createTreeWalker(l,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();){if(!(a instanceof Element))continue;let d=Y(a);d&&!o.has(d)&&r.push(d)}}catch{}}}return null},Ae=(e,t)=>I(e,{pierceShadow:t}),B=(e,t)=>ke(e)?Ae(e,t):He(document,e,t),G=(e,t)=>{if(t===\\\"detached\\\")return e===null;if(t===\\\"attached\\\")return e!==null;if(e===null)return!1;if(t===\\\"hidden\\\")try{let n=window.getComputedStyle(e),o=e.getBoundingClientRect();return n.display===\\\"none\\\"||n.visibility===\\\"hidden\\\"||n.opacity===\\\"0\\\"||o.width===0||o.height===0}catch{return!1}try{let n=window.getComputedStyle(e),o=e.getBoundingClientRect();return n.display!==\\\"none\\\"&&n.visibility!==\\\"hidden\\\"&&n.opacity!==\\\"0\\\"&&o.width>0&&o.height>0}catch{return!1}},We=(e,t)=>{let n=new WeakSet,o=l=>{let s=Y(l);if(s&&!n.has(s)){n.add(s);let i=new MutationObserver(e);i.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\\\"style\\\",\\\"class\\\",\\\"hidden\\\",\\\"disabled\\\"]}),t.push(i);for(let a of Array.from(s.children))o(a)}for(let i of Array.from(l.children))o(i)},r=document.documentElement||document.body;r&&o(r)};function _e(e,t,n,o){let r=String(e??\\\"\\\").trim(),l=String(t??\\\"visible\\\")||\\\"visible\\\",s=typeof n==\\\"number\\\"&&n>0?n:3e4,i=o!==!1;return new Promise((a,d)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=B(r,i);if(G(w,l)){p=!0,a(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null)},m=()=>{if(p)return;let E=B(r,i);G(E,l)&&(p=!0,g(),y(),a(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null,m(),h()},document.addEventListener(\\\"DOMContentLoaded\\\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s);return}let h=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(m);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\\\"style\\\",\\\"class\\\",\\\"hidden\\\",\\\"disabled\\\"]}),x.push(b),i&&We(m,x)};h(),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s)})}return J(Oe);})();\\n globalThis.__stagehandLocatorScripts = __stagehandLocatorScriptsFactory;\\n}\";\nexport const locatorScriptSources = {\n \"assignFilePayloadsToInputElement\": \"function ce(e){try{let t=this;if(!t||t.tagName?.toLowerCase()!==\\\"input\\\"||(t.type??\\\"\\\").toLowerCase()!==\\\"file\\\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(e)?e:[];for(let r of o){if(!r)continue;let l=r.name||\\\"upload.bin\\\",s=r.mimeType||\\\"application/octet-stream\\\",i=typeof r.lastModified==\\\"number\\\"?r.lastModified:Date.now(),a=window.atob(r.base64??\\\"\\\"),d=new Uint8Array(a.length);for(let p=0;p<a.length;p+=1)d[p]=a.charCodeAt(p);let f=new Blob([d],{type:s}),c=new File([f],l,{type:s,lastModified:i});n.items.add(c)}return t.files=n.files,t.dispatchEvent(new Event(\\\"input\\\",{bubbles:!0})),t.dispatchEvent(new Event(\\\"change\\\",{bubbles:!0})),!0}catch{return!1}}\",\n \"countCssMatchesPierce\": \"function He(e){let t=String(e??\\\"\\\").trim();if(!t)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\\\"function\\\")try{return document.querySelectorAll(t).length}catch{return 0}let o=new WeakSet,r=[],l=a=>{!a||o.has(a)||(o.add(a),r.push(a))};l(document);let s=0,i=a=>{let d=a.shadowRoot;d&&l(d);try{let f=n.getClosedRoot(a);f&&l(f)}catch{}};for(;r.length;){let a=r.shift();if(a){try{let d=a;typeof d.querySelectorAll==\\\"function\\\"&&(s+=d.querySelectorAll(t).length)}catch{}try{let f=(a instanceof Document?a:a instanceof ShadowRoot?a.host?.ownerDocument??document:a.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&i(c)}catch{}}}return s}\",\n \"countCssMatchesPrimary\": \"function De(e){let t=String(e??\\\"\\\").trim();if(!t)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\\\"function\\\"&&(l+=s.querySelectorAll(t).length)}catch{}try{let i=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();)a instanceof Element&&a.shadowRoot&&(l+=o(a.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(t).length}catch{return 0}}}\",\n \"countTextMatches\": \"function Ae(e){let t=String(e??\\\"\\\");if(!t)return{count:0,sample:[],error:null};let n=t.toLowerCase(),o=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),r=m=>{if(!m)return!1;let u=m.tagName?.toUpperCase()??\\\"\\\";return o.has(u)},l=m=>{try{if(r(m))return\\\"\\\";let u=m.innerText;if(typeof u==\\\"string\\\"&&u.trim())return u.trim()}catch{}try{let u=m.textContent;if(typeof u==\\\"string\\\")return u.trim()}catch{}return\\\"\\\"},s=m=>{let u=l(m);return!!u&&u.toLowerCase().includes(n)},i=window.__stagehandV3__,a=i&&typeof i.getClosedRoot==\\\"function\\\"?m=>{try{return i.getClosedRoot(m)??null}catch{return null}}:m=>null,d=new WeakSet,f=[],c=m=>{!m||d.has(m)||(d.add(m),f.push(m))},p=m=>{try{return(m instanceof Document?m:m?.ownerDocument??document).createTreeWalker(m,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let m=f.shift();if(!m)continue;m instanceof Element&&s(m)&&g.push({element:m,tag:m.tagName??\\\"\\\",id:m.id??\\\"\\\",className:m.className??\\\"\\\",text:l(m)});let u=p(m);if(!u)continue;let h;for(;h=u.nextNode();){if(!(h instanceof Element))continue;s(h)&&g.push({element:h,tag:h.tagName??\\\"\\\",id:h.id??\\\"\\\",className:h.className??\\\"\\\",text:l(h)});let E=h.shadowRoot;E&&c(E);let b=a(h);b&&c(b)}}let w=[];for(let m of g){let u=m.element,h=!1;for(let E of g)if(m!==E)try{if(u.contains(E.element)){h=!0;break}}catch{}h||w.push(m)}let x=w.length,y=w.slice(0,5).map(m=>({tag:m.tag,id:m.id,class:m.className,text:m.text}));return{count:x,sample:y,error:null}}\",\n \"countXPathMatchesMainWorld\": \"function We(e){return I(e,{pierceShadow:!0})}\",\n \"dispatchDomClick\": \"function ue(e){let t=e??{};try{let n=new MouseEvent(\\\"click\\\",{bubbles:!!t.bubbles,cancelable:!!t.cancelable,composed:!!t.composed,detail:typeof t.detail==\\\"number\\\"?t.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}\",\n \"ensureFileInputElement\": \"function ae(){try{return(this.tagName?.toLowerCase()??\\\"\\\")!==\\\"input\\\"?!1:String(this.type??\\\"\\\").toLowerCase()===\\\"file\\\"}catch{return!1}}\",\n \"fillElementValue\": \"function me(e){let t=this;if(!t.isConnected)return{status:\\\"error\\\",reason:\\\"notconnected\\\"};let o=(t.ownerDocument||document).defaultView||window,r=e??\\\"\\\";try{let l=s=>{let i;if(typeof o.InputEvent==\\\"function\\\")try{i=new o.InputEvent(\\\"input\\\",{bubbles:!0,composed:!0,data:s,inputType:\\\"insertText\\\"})}catch{i=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0})}else i=new o.Event(\\\"input\\\",{bubbles:!0,composed:!0});t.dispatchEvent(i);let a=new o.Event(\\\"change\\\",{bubbles:!0});t.dispatchEvent(a)};if(t instanceof o.HTMLInputElement){let s=(t.type||\\\"\\\").toLowerCase();if(!Y.has(s)&&!D.has(s))return{status:\\\"error\\\",reason:`unsupported-input-type:${s}`};let i=e;if(s===\\\"number\\\"){let a=e.trim();if(a!==\\\"\\\"&&Number.isNaN(Number(a)))return{status:\\\"error\\\",reason:\\\"invalid-number-value\\\"};i=a}if(r=i,D.has(s)){let a=e.trim();r=a,v.call(t);let d=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(d,\\\"value\\\")?.set;return typeof c==\\\"function\\\"?c.call(t,a):t.value=a,t._valueTracker?.setValue?.(a),t.value!==a?{status:\\\"error\\\",reason:\\\"malformed-value\\\"}:(l(a),{status:\\\"done\\\"})}return v.call(t),{status:\\\"needsinput\\\",value:i}}return t instanceof o.HTMLTextAreaElement?(v.call(t),r=e,{status:\\\"needsinput\\\",value:e}):t instanceof o.HTMLSelectElement?{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}:t.isContentEditable?(v.call(t),r=e,{status:\\\"needsinput\\\",value:e}):{status:\\\"error\\\",reason:\\\"unsupported-element\\\"}}catch(l){let s=\\\"exception\\\";if(l&&typeof l==\\\"object\\\"){let i=l.message;typeof i==\\\"string\\\"&&i.trim().length>0&&(s=`exception:${i}`)}return{status:\\\"needsinput\\\",value:r,reason:s}}}\",\n \"focusElement\": \"function fe(){try{typeof this.focus==\\\"function\\\"&&this.focus()}catch{}}\",\n \"isElementChecked\": \"function ge(){try{let e=this;if((e.tagName||\\\"\\\").toLowerCase()===\\\"input\\\"){let o=e.type?.toLowerCase()??\\\"\\\";if(o===\\\"checkbox\\\"||o===\\\"radio\\\")return!!e.checked}let n=e.getAttribute?.(\\\"aria-checked\\\");return n!=null?n===\\\"true\\\":!1}catch{return!1}}\",\n \"isElementVisible\": \"function pe(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument?.defaultView?.getComputedStyle(e)??window.getComputedStyle(e);if(!t||t.display===\\\"none\\\"||t.visibility===\\\"hidden\\\")return!1;let n=parseFloat(t.opacity??\\\"1\\\");if(!Number.isFinite(n)||n===0)return!1;let o=e.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||e.getClientRects().length===0)}catch{return!1}}\",\n \"prepareElementForTyping\": \"function v(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument||document,n=t.defaultView||window;try{typeof e.focus==\\\"function\\\"&&e.focus()}catch{}if(e instanceof n.HTMLInputElement||e instanceof n.HTMLTextAreaElement){try{if(typeof e.select==\\\"function\\\")return e.select(),!0}catch{}try{let o=(e.value??\\\"\\\").length;if(typeof e.setSelectionRange==\\\"function\\\")return e.setSelectionRange(0,o),!0}catch{}return!0}if(e.isContentEditable){let o=t.getSelection?.(),r=t.createRange?.();if(o&&r)try{r.selectNodeContents(e),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}\",\n \"readElementInnerHTML\": \"function ye(){try{return String(this.innerHTML??\\\"\\\")}catch{return\\\"\\\"}}\",\n \"readElementInnerText\": \"function be(){try{let e=this,t=e.innerText;if(typeof t==\\\"string\\\"&&t.length>0)return t;let n=e.textContent;return typeof n==\\\"string\\\"?n:\\\"\\\"}catch{return\\\"\\\"}}\",\n \"readElementInputValue\": \"function Ee(){try{let e=this,t=(e.tagName||\\\"\\\").toLowerCase();return t===\\\"input\\\"||t===\\\"textarea\\\"||t===\\\"select\\\"?String(e.value??\\\"\\\"):e.isContentEditable?String(e.textContent??\\\"\\\"):\\\"\\\"}catch{return\\\"\\\"}}\",\n \"readElementTextContent\": \"function we(){try{return String(this.textContent??\\\"\\\")}catch{return\\\"\\\"}}\",\n \"resolveCssSelector\": \"function Ne(e,t){let n=String(e??\\\"\\\").trim();if(!n)return null;let o=C(t);return z(n,o+1)[o]??null}\",\n \"resolveCssSelectorPierce\": \"function Ce(e,t){let n=String(e??\\\"\\\").trim();if(!n)return null;let o=C(t),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\\\"function\\\")return z(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,i=new Set,a=[],d=[document],f=c=>{if(!(!c||s.has(c)||a.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!i.has(g)&&(i.add(g),a.push(g),a.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&d.push(x);let y=l(w);y&&d.push(y)}}catch{}}};for(;d.length&&a.length<o+1;){let c=d.shift();c&&f(c)}return a[o]??null}\",\n \"resolveTextSelector\": \"function Me(e,t){let n=String(e??\\\"\\\");if(!n)return null;let o=n.toLowerCase(),r=C(t),l=new Set([\\\"SCRIPT\\\",\\\"STYLE\\\",\\\"TEMPLATE\\\",\\\"NOSCRIPT\\\",\\\"HEAD\\\",\\\"TITLE\\\",\\\"LINK\\\",\\\"META\\\",\\\"HTML\\\",\\\"BODY\\\"]),s=u=>{if(!u)return!1;let h=u.tagName?.toUpperCase()??\\\"\\\";return l.has(h)},i=u=>{try{if(s(u))return\\\"\\\";let h=u.innerText;if(typeof h==\\\"string\\\"&&h.trim())return h.trim()}catch{}try{let h=u.textContent;if(typeof h==\\\"string\\\")return h.trim()}catch{}return\\\"\\\"},a=u=>{let h=i(u);return!!h&&h.toLowerCase().includes(o)},d=window.__stagehandV3__,f=d&&typeof d.getClosedRoot==\\\"function\\\"?u=>{try{return d.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&a(u)&&g.push({element:u,tag:u.tagName??\\\"\\\",id:u.id??\\\"\\\",className:u.className??\\\"\\\",text:i(u)});let h=x(u);if(!h)continue;let E;for(;E=h.nextNode();){if(!(E instanceof Element))continue;a(E)&&g.push({element:E,tag:E.tagName??\\\"\\\",id:E.id??\\\"\\\",className:E.className??\\\"\\\",text:i(E)});let b=E.shadowRoot;b&&w(b);let k=f(E);k&&w(k)}}let y=[];for(let u of g){let h=u.element,E=!1;for(let b of g)if(u!==b)try{if(h.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}\",\n \"resolveXPathMainWorld\": \"function Le(e,t){let n=C(t);return P(e,n,{pierceShadow:!0})}\",\n \"scrollElementToPercent\": \"function de(e){let t=n=>{if(typeof n==\\\"number\\\"&&Number.isFinite(n))return n;let o=String(n??\\\"\\\").trim();if(!o)return 0;let r=parseFloat(o.replace(\\\"%\\\",\\\"\\\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(t(e),100)),o=this,r=o.tagName?.toLowerCase()??\\\"\\\";if(r===\\\"html\\\"||r===\\\"body\\\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\\\"smooth\\\"}),!0}let s=o.scrollHeight??0,i=o.clientHeight??0,d=Math.max(0,s-i)*(n/100);return o.scrollTo({top:d,left:o.scrollLeft??0,behavior:\\\"smooth\\\"}),!0}catch{return!1}}\",\n \"selectElementOptions\": \"function he(e){try{if(!(this instanceof HTMLSelectElement))return[];let t=Array.isArray(e)?e:[e],n=new Set(t.map(s=>String(s??\\\"\\\").trim())),o=s=>{let i=(s.label||s.textContent||\\\"\\\").trim(),a=String(s.value??\\\"\\\").trim();return n.has(i)||n.has(a)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let i of Array.from(this.options))!s&&o(i)?(i.selected=!0,this.value=i.value,s=!0):i.selected=!1}let r=new Event(\\\"input\\\",{bubbles:!0}),l=new Event(\\\"change\\\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}\",\n \"waitForSelector\": \"function qe(e,t,n,o){let r=String(e??\\\"\\\").trim(),l=String(t??\\\"visible\\\")||\\\"visible\\\",s=typeof n==\\\"number\\\"&&n>0?n:3e4,i=o!==!1;return new Promise((a,d)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=V(r,i);if(B(w,l)){p=!0,a(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null)},m=()=>{if(p)return;let E=V(r,i);B(E,l)&&(p=!0,g(),y(),a(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\\\"DOMContentLoaded\\\",c),c=null,m(),h()},document.addEventListener(\\\"DOMContentLoaded\\\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s);return}let h=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(m);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\\\"style\\\",\\\"class\\\",\\\"hidden\\\",\\\"disabled\\\"]}),x.push(b),i&&ie(m,x)};h(),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \\\"${r}\\\" to be ${l}`)))},s)})}\"\n} as const;\nexport const locatorScriptGlobalRefs = {\n \"assignFilePayloadsToInputElement\": \"globalThis.__stagehandLocatorScripts.assignFilePayloadsToInputElement\",\n \"countCssMatchesPierce\": \"globalThis.__stagehandLocatorScripts.countCssMatchesPierce\",\n \"countCssMatchesPrimary\": \"globalThis.__stagehandLocatorScripts.countCssMatchesPrimary\",\n \"countTextMatches\": \"globalThis.__stagehandLocatorScripts.countTextMatches\",\n \"countXPathMatchesMainWorld\": \"globalThis.__stagehandLocatorScripts.countXPathMatchesMainWorld\",\n \"dispatchDomClick\": \"globalThis.__stagehandLocatorScripts.dispatchDomClick\",\n \"ensureFileInputElement\": \"globalThis.__stagehandLocatorScripts.ensureFileInputElement\",\n \"fillElementValue\": \"globalThis.__stagehandLocatorScripts.fillElementValue\",\n \"focusElement\": \"globalThis.__stagehandLocatorScripts.focusElement\",\n \"isElementChecked\": \"globalThis.__stagehandLocatorScripts.isElementChecked\",\n \"isElementVisible\": \"globalThis.__stagehandLocatorScripts.isElementVisible\",\n \"prepareElementForTyping\": \"globalThis.__stagehandLocatorScripts.prepareElementForTyping\",\n \"readElementInnerHTML\": \"globalThis.__stagehandLocatorScripts.readElementInnerHTML\",\n \"readElementInnerText\": \"globalThis.__stagehandLocatorScripts.readElementInnerText\",\n \"readElementInputValue\": \"globalThis.__stagehandLocatorScripts.readElementInputValue\",\n \"readElementTextContent\": \"globalThis.__stagehandLocatorScripts.readElementTextContent\",\n \"resolveCssSelector\": \"globalThis.__stagehandLocatorScripts.resolveCssSelector\",\n \"resolveCssSelectorPierce\": \"globalThis.__stagehandLocatorScripts.resolveCssSelectorPierce\",\n \"resolveTextSelector\": \"globalThis.__stagehandLocatorScripts.resolveTextSelector\",\n \"resolveXPathMainWorld\": \"globalThis.__stagehandLocatorScripts.resolveXPathMainWorld\",\n \"scrollElementToPercent\": \"globalThis.__stagehandLocatorScripts.scrollElementToPercent\",\n \"selectElementOptions\": \"globalThis.__stagehandLocatorScripts.selectElementOptions\",\n \"waitForSelector\": \"globalThis.__stagehandLocatorScripts.waitForSelector\"\n} as const;\nexport type LocatorScriptName = keyof typeof locatorScriptSources;\n"]}
1
+ {"version":3,"file":"locatorScripts.generated.js","sourceRoot":"","sources":["../../../../../../lib/v3/dom/build/locatorScripts.generated.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,sBAAsB,GACjC,krsBAAkrsB,CAAC;AACxqsB,QAAA,oBAAoB,GAAG;IAClC,gCAAgC,EAC9B,4sBAA4sB;IAC9sB,qBAAqB,EACnB,4sBAA4sB;IAC9sB,sBAAsB,EACpB,kgBAAkgB;IACpgB,gBAAgB,EACd,y9CAAy9C;IAC39C,0BAA0B,EAAE,+CAA+C;IAC3E,gBAAgB,EACd,qRAAqR;IACvR,sBAAsB,EACpB,sIAAsI;IACxI,gBAAgB,EACd,qhDAAqhD;IACvhD,YAAY,EACV,wEAAwE;IAC1E,gBAAgB,EACd,gPAAgP;IAClP,gBAAgB,EACd,6YAA6Y;IAC/Y,uBAAuB,EACrB,ylBAAylB;IAC3lB,oBAAoB,EAClB,sEAAsE;IACxE,oBAAoB,EAClB,2JAA2J;IAC7J,qBAAqB,EACnB,qMAAqM;IACvM,sBAAsB,EACpB,wEAAwE;IAC1E,kBAAkB,EAChB,oGAAoG;IACtG,wBAAwB,EACtB,0uBAA0uB;IAC5uB,mBAAmB,EACjB,s2CAAs2C;IACx2C,qBAAqB,EACnB,8DAA8D;IAChE,sBAAsB,EACpB,04BAA04B;IAC54B,oBAAoB,EAClB,4mBAA4mB;IAC9mB,eAAe,EACb,qkCAAqkC;CAC/jC,CAAC;AACE,QAAA,uBAAuB,GAAG;IACrC,gCAAgC,EAC9B,uEAAuE;IACzE,qBAAqB,EACnB,4DAA4D;IAC9D,sBAAsB,EACpB,6DAA6D;IAC/D,gBAAgB,EAAE,uDAAuD;IACzE,0BAA0B,EACxB,iEAAiE;IACnE,gBAAgB,EAAE,uDAAuD;IACzE,sBAAsB,EACpB,6DAA6D;IAC/D,gBAAgB,EAAE,uDAAuD;IACzE,YAAY,EAAE,mDAAmD;IACjE,gBAAgB,EAAE,uDAAuD;IACzE,gBAAgB,EAAE,uDAAuD;IACzE,uBAAuB,EACrB,8DAA8D;IAChE,oBAAoB,EAClB,2DAA2D;IAC7D,oBAAoB,EAClB,2DAA2D;IAC7D,qBAAqB,EACnB,4DAA4D;IAC9D,sBAAsB,EACpB,6DAA6D;IAC/D,kBAAkB,EAAE,yDAAyD;IAC7E,wBAAwB,EACtB,+DAA+D;IACjE,mBAAmB,EACjB,0DAA0D;IAC5D,qBAAqB,EACnB,4DAA4D;IAC9D,sBAAsB,EACpB,6DAA6D;IAC/D,oBAAoB,EAClB,2DAA2D;IAC7D,eAAe,EAAE,sDAAsD;CAC/D,CAAC","sourcesContent":["/*\n * AUTO-GENERATED FILE. DO NOT EDIT.\n * Update sources in lib/v3/dom/locatorScripts and run genLocatorScripts.ts.\n */\nexport const locatorScriptBootstrap =\n 'if (!globalThis.__stagehandLocatorScripts) { var __stagehandLocatorScriptsFactory=(()=>{var M=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var Z=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},j=(e,t,n,o)=>{if(t&&typeof t==\"object\"||typeof t==\"function\")for(let r of U(t))!Q.call(e,r)&&r!==n&&M(e,r,{get:()=>t[r],enumerable:!(o=K(t,r))||o.enumerable});return e};var J=e=>j(M({},\"__esModule\",{value:!0}),e);var Oe={};Z(Oe,{assignFilePayloadsToInputElement:()=>te,countCssMatchesPierce:()=>Me,countCssMatchesPrimary:()=>Ce,countTextMatches:()=>Le,countXPathMatchesMainWorld:()=>Pe,dispatchDomClick:()=>ne,ensureFileInputElement:()=>ee,fillElementValue:()=>se,focusElement:()=>le,isElementChecked:()=>ce,isElementVisible:()=>ae,prepareElementForTyping:()=>v,readElementInnerHTML:()=>me,readElementInnerText:()=>fe,readElementInputValue:()=>ue,readElementTextContent:()=>de,resolveCssSelector:()=>ve,resolveCssSelectorPierce:()=>Te,resolveTextSelector:()=>Re,resolveXPathMainWorld:()=>Ne,scrollElementToPercent:()=>oe,selectElementOptions:()=>ie,waitForSelector:()=>_e});function ee(){try{return(this.tagName?.toLowerCase()??\"\")!==\"input\"?!1:String(this.type??\"\").toLowerCase()===\"file\"}catch{return!1}}function te(e){try{let t=this;if(!t||t.tagName?.toLowerCase()!==\"input\"||(t.type??\"\").toLowerCase()!==\"file\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(e)?e:[];for(let r of o){if(!r)continue;let l=r.name||\"upload.bin\",s=r.mimeType||\"application/octet-stream\",i=typeof r.lastModified==\"number\"?r.lastModified:Date.now(),a=window.atob(r.base64??\"\"),d=new Uint8Array(a.length);for(let p=0;p<a.length;p+=1)d[p]=a.charCodeAt(p);let f=new Blob([d],{type:s}),c=new File([f],l,{type:s,lastModified:i});n.items.add(c)}return t.files=n.files,t.dispatchEvent(new Event(\"input\",{bubbles:!0})),t.dispatchEvent(new Event(\"change\",{bubbles:!0})),!0}catch{return!1}}function ne(e){let t=e??{};try{let n=new MouseEvent(\"click\",{bubbles:!!t.bubbles,cancelable:!!t.cancelable,composed:!!t.composed,detail:typeof t.detail==\"number\"?t.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}function oe(e){let t=n=>{if(typeof n==\"number\"&&Number.isFinite(n))return n;let o=String(n??\"\").trim();if(!o)return 0;let r=parseFloat(o.replace(\"%\",\"\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(t(e),100)),o=this,r=o.tagName?.toLowerCase()??\"\";if(r===\"html\"||r===\"body\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\"smooth\"}),!0}let s=o.scrollHeight??0,i=o.clientHeight??0,d=Math.max(0,s-i)*(n/100);return o.scrollTo({top:d,left:o.scrollLeft??0,behavior:\"smooth\"}),!0}catch{return!1}}var H=new Set([\"color\",\"date\",\"datetime-local\",\"month\",\"range\",\"time\",\"week\"]),re=new Set([\"\",\"email\",\"number\",\"password\",\"search\",\"tel\",\"text\",\"url\"]);function v(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument||document,n=t.defaultView||window;try{typeof e.focus==\"function\"&&e.focus()}catch{}if(e instanceof n.HTMLInputElement||e instanceof n.HTMLTextAreaElement){try{if(typeof e.select==\"function\")return e.select(),!0}catch{}try{let o=(e.value??\"\").length;if(typeof e.setSelectionRange==\"function\")return e.setSelectionRange(0,o),!0}catch{}return!0}if(e.isContentEditable){let o=t.getSelection?.(),r=t.createRange?.();if(o&&r)try{r.selectNodeContents(e),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}function se(e){let t=this;if(!t.isConnected)return{status:\"error\",reason:\"notconnected\"};let o=(t.ownerDocument||document).defaultView||window,r=e??\"\";try{let l=s=>{let i;if(typeof o.InputEvent==\"function\")try{i=new o.InputEvent(\"input\",{bubbles:!0,composed:!0,data:s,inputType:\"insertText\"})}catch{i=new o.Event(\"input\",{bubbles:!0,composed:!0})}else i=new o.Event(\"input\",{bubbles:!0,composed:!0});t.dispatchEvent(i);let a=new o.Event(\"change\",{bubbles:!0});t.dispatchEvent(a)};if(t instanceof o.HTMLInputElement){let s=(t.type||\"\").toLowerCase();if(!re.has(s)&&!H.has(s))return{status:\"error\",reason:`unsupported-input-type:${s}`};let i=e;if(s===\"number\"){let a=e.trim();if(a!==\"\"&&Number.isNaN(Number(a)))return{status:\"error\",reason:\"invalid-number-value\"};i=a}if(r=i,H.has(s)){let a=e.trim();r=a,v.call(t);let d=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(d,\"value\")?.set;return typeof c==\"function\"?c.call(t,a):t.value=a,t._valueTracker?.setValue?.(a),t.value!==a?{status:\"error\",reason:\"malformed-value\"}:(l(a),{status:\"done\"})}return v.call(t),{status:\"needsinput\",value:i}}return t instanceof o.HTMLTextAreaElement?(v.call(t),r=e,{status:\"needsinput\",value:e}):t instanceof o.HTMLSelectElement?{status:\"error\",reason:\"unsupported-element\"}:t.isContentEditable?(v.call(t),r=e,{status:\"needsinput\",value:e}):{status:\"error\",reason:\"unsupported-element\"}}catch(l){let s=\"exception\";if(l&&typeof l==\"object\"){let i=l.message;typeof i==\"string\"&&i.trim().length>0&&(s=`exception:${i}`)}return{status:\"needsinput\",value:r,reason:s}}}function le(){try{typeof this.focus==\"function\"&&this.focus()}catch{}}function ie(e){try{if(!(this instanceof HTMLSelectElement))return[];let t=Array.isArray(e)?e:[e],n=new Set(t.map(s=>String(s??\"\").trim())),o=s=>{let i=(s.label||s.textContent||\"\").trim(),a=String(s.value??\"\").trim();return n.has(i)||n.has(a)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let i of Array.from(this.options))!s&&o(i)?(i.selected=!0,this.value=i.value,s=!0):i.selected=!1}let r=new Event(\"input\",{bubbles:!0}),l=new Event(\"change\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}function ae(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument?.defaultView?.getComputedStyle(e)??window.getComputedStyle(e);if(!t||t.display===\"none\"||t.visibility===\"hidden\")return!1;let n=parseFloat(t.opacity??\"1\");if(!Number.isFinite(n)||n===0)return!1;let o=e.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||e.getClientRects().length===0)}catch{return!1}}function ce(){try{let e=this;if((e.tagName||\"\").toLowerCase()===\"input\"){let o=e.type?.toLowerCase()??\"\";if(o===\"checkbox\"||o===\"radio\")return!!e.checked}let n=e.getAttribute?.(\"aria-checked\");return n!=null?n===\"true\":!1}catch{return!1}}function ue(){try{let e=this,t=(e.tagName||\"\").toLowerCase();return t===\"input\"||t===\"textarea\"||t===\"select\"?String(e.value??\"\"):e.isContentEditable?String(e.textContent??\"\"):\"\"}catch{return\"\"}}function de(){try{return String(this.textContent??\"\")}catch{return\"\"}}function me(){try{return String(this.innerHTML??\"\")}catch{return\"\"}}function fe(){try{let e=this,t=e.innerText;if(typeof t==\"string\"&&t.length>0)return t;let n=e.textContent;return typeof n==\"string\"?n:\"\"}catch{return\"\"}}function O(e){let t=String(e||\"\").trim().replace(/^xpath=/i,\"\");if(!t)return[];let n=[],o=0;for(;o<t.length;){let r=\"child\";t.startsWith(\"//\",o)?(r=\"desc\",o+=2):t[o]===\"/\"&&(r=\"child\",o+=1);let l=o,s=0,i=null;for(;o<t.length;){let c=t[o];if(i)c===i&&(i=null);else if(c===\"\\'\"||c===\\'\"\\')i=c;else if(c===\"[\")s++;else if(c===\"]\")s--;else if(c===\"/\"&&s===0)break;o+=1}let a=t.slice(l,o).trim();if(!a)continue;let{tag:d,predicates:f}=pe(a);n.push({axis:r,tag:d,predicates:f})}return n}function he(e){let t=[],n=0;for(;n<e.length;){if(e[n]!==\"[\"){n++;continue}n++;let o=n,r=null;for(;n<e.length;){let l=e[n];if(r)l===r&&(r=null);else if(l===\"\\'\"||l===\\'\"\\')r=l;else if(l===\"]\")break;n++}t.push(e.slice(o,n).trim()),n++}return t}function pe(e){let t=e.indexOf(\"[\");if(t===-1)return{tag:e===\"\"?\"*\":e.toLowerCase(),predicates:[]};let n=e.slice(0,t).trim(),o=n===\"\"?\"*\":n.toLowerCase(),r=e.slice(t),l=[];for(let s of he(r)){let i=T(s);i&&l.push(i)}return{tag:o,predicates:l}}function T(e){let t=e.trim();if(!t)return null;let n=A(t,\"or\");if(n.length>1){let l=n.map(s=>T(s)).filter(Boolean);return l.length!==n.length?null:{type:\"or\",predicates:l}}let o=A(t,\"and\");if(o.length>1){let l=o.map(s=>T(s)).filter(Boolean);return l.length!==o.length?null:{type:\"and\",predicates:l}}let r=we(t,\"not\");if(r!=null){let l=T(r);return l?{type:\"not\",predicate:l}:null}return ge(t)}function ge(e){let t=/^(?:\\'([^\\']*)\\'|\"([^\"]*)\")$/,n=\"[a-zA-Z_][\\\\\\\\w.-]*\",o=`(?:\\'([^\\']*)\\'|\"([^\"]*)\")`;if(/^\\\\d+$/.test(e))return{type:\"index\",index:Math.max(1,Number(e))};let r=e.match(new RegExp(`^normalize-space\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*\\\\\\\\)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(r)return{type:\"attrEquals\",name:r[1],value:r[2]??r[3]??\"\",normalize:!0};let l=e.match(new RegExp(`^normalize-space\\\\\\\\(\\\\\\\\s*(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*\\\\\\\\)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(l)return{type:\"textEquals\",value:l[1]??l[2]??\"\",normalize:!0};let s=e.match(new RegExp(`^@(${n})\\\\\\\\s*=\\\\\\\\s*${o}$`));if(s)return{type:\"attrEquals\",name:s[1],value:s[2]??s[3]??\"\"};let i=e.match(new RegExp(`^@(${n})$`));if(i)return{type:\"attrExists\",name:i[1]};let a=e.match(new RegExp(`^contains\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));if(a)return{type:\"attrContains\",name:a[1],value:a[2]??a[3]??\"\"};let d=e.match(new RegExp(`^starts-with\\\\\\\\(\\\\\\\\s*@(${n})\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));if(d)return{type:\"attrStartsWith\",name:d[1],value:d[2]??d[3]??\"\"};let f=e.match(new RegExp(`^(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*=\\\\\\\\s*${o}$`));if(f)return{type:\"textEquals\",value:f[1]??f[2]??\"\"};let c=e.match(new RegExp(`^contains\\\\\\\\(\\\\\\\\s*(?:text\\\\\\\\(\\\\\\\\)|\\\\\\\\.)\\\\\\\\s*,\\\\\\\\s*${o}\\\\\\\\s*\\\\\\\\)$`));return c?{type:\"textContains\",value:c[1]??c[2]??\"\"}:(t.test(e),null)}function A(e,t){let n=[],o=0,r=0,l=null,s=0;for(;s<e.length;){let i=e[s];if(l){i===l&&(l=null),s+=1;continue}if(i===\"\\'\"||i===\\'\"\\'){l=i,s+=1;continue}if(i===\"(\"){r+=1,s+=1;continue}if(i===\")\"){r=Math.max(0,r-1),s+=1;continue}if(r===0&&Ee(e,s,t)){n.push(e.slice(o,s).trim()),s+=t.length,o=s;continue}s+=1}return n.push(e.slice(o).trim()),n.filter(i=>i.length>0)}function Ee(e,t,n){if(!e.startsWith(n,t))return!1;let o=t>0?e[t-1]:\" \";if(o===\"@\")return!1;let r=t+n.length<e.length?e[t+n.length]:\" \";return W(o)&&W(r)}function W(e){return!/[a-zA-Z0-9_.-]/.test(e)}function we(e,t){let n=`${t}(`;if(!e.startsWith(n)||!e.endsWith(\")\"))return null;let o=e.slice(n.length,-1);return ye(o)?o:null}function ye(e){let t=0,n=null;for(let o=0;o<e.length;o+=1){let r=e[o];if(n){r===n&&(n=null);continue}if(r===\"\\'\"||r===\\'\"\\'){n=r;continue}if(r===\"(\"?t+=1:r===\")\"&&(t-=1),t<0)return!1}return t===0}var be=e=>e.replace(/\\\\s+/g,\" \").trim();function _(e){return String(e.textContent??\"\")}function S(e,t){return t?be(e):e}function R(e,t){switch(t.type){case\"and\":return t.predicates.every(n=>R(e,n));case\"or\":return t.predicates.some(n=>R(e,n));case\"not\":return!R(e,t.predicate);case\"attrExists\":return e.getAttribute(t.name)!==null;case\"attrEquals\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize)===S(t.value,t.normalize)}case\"attrContains\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize).includes(S(t.value,t.normalize))}case\"attrStartsWith\":{let n=e.getAttribute(t.name);return n===null?!1:S(n,t.normalize).startsWith(S(t.value,t.normalize))}case\"textEquals\":return S(_(e),t.normalize)===S(t.value,t.normalize);case\"textContains\":return S(_(e),t.normalize).includes(S(t.value,t.normalize));case\"index\":return!0;default:return!0}}function q(e,t){let n=e;for(let o of t){if(!n.length)return[];if(o.type===\"index\"){let r=o.index-1;n=r>=0&&r<n.length?[n[r]]:[];continue}n=n.filter(r=>R(r,o))}return n}var P=e=>{let t=String(e??\"\").trim();return t?t.replace(/^xpath=/i,\"\").trim():\"\"};function I(e,t){return k(e,0,t)}function k(e,t,n){if(!Number.isFinite(t)||t<0)return null;let o=P(e);if(!o)return null;let r=Math.floor(t),l=n?.pierceShadow!==!1,s=l?z():null;if(!l)return X(o,r).value;if(!s?.hasShadow){let a=X(o,r);return a.error?N(o,s?.getClosedRoot)[r]??null:a.value}return N(o,s.getClosedRoot)[r]??null}function $(e,t){let n=P(e);if(!n)return 0;let o=t?.pierceShadow!==!1,r=o?z():null;if(!o)return F(n).count;if(!r?.hasShadow){let l=F(n);return l.error?N(n,r?.getClosedRoot).length:l.count}return N(n,r.getClosedRoot).length}function N(e,t){let n=P(e);if(!n)return[];let o=O(n);if(!o.length)return[];let r=t??null,l=[document];for(let s of o){let i=[],a=new Set;for(let d of l){if(!d)continue;let f=s.axis===\"child\"?L(d,r):Se(d,r);if(!f.length)continue;let c=f.filter(g=>xe(g,s)),p=q(c,s.predicates);for(let g of p)a.has(g)||(a.add(g),i.push(g))}if(!i.length)return[];l=i}return l}function xe(e,t){return t.tag===\"*\"?!0:e.localName===t.tag}function z(){let e=window.__stagehandV3__,t=e&&typeof e.getClosedRoot==\"function\"?o=>{try{return e.getClosedRoot(o)??null}catch{return null}}:null,n=!1;try{if(e&&typeof e.stats==\"function\"){let o=e.stats();n=(o?.open??0)>0||(o?.closed??0)>0}}catch{}if(!n)try{let o=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;o.nextNode();)if(o.currentNode.shadowRoot){n=!0;break}}catch{}return{getClosedRoot:t,hasShadow:n}}function L(e,t){let n=[];if(!e)return n;if(e instanceof Document)return e.documentElement&&n.push(e.documentElement),n;if(e instanceof ShadowRoot||e instanceof DocumentFragment)return n.push(...Array.from(e.children??[])),n;if(e instanceof Element){n.push(...Array.from(e.children??[]));let o=e.shadowRoot;if(o&&n.push(...Array.from(o.children??[])),t){let r=t(e);r&&n.push(...Array.from(r.children??[]))}return n}return n}function Se(e,t){let n=[],o=new Set,r=[...L(e,t)].reverse();for(;r.length;){let l=r.pop();if(!l||o.has(l))continue;o.add(l),n.push(l);let s=L(l,t);for(let i=s.length-1;i>=0;i-=1)r.push(s[i])}return n}function X(e,t){try{return{value:document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(t),error:!1}}catch{return{value:null,error:!0}}}function F(e){try{return{count:document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotLength,error:!1}}catch{return{count:0,error:!0}}}var C=e=>{let t=Number(e??0);return!Number.isFinite(t)||t<0?0:Math.floor(t)},V=(e,t)=>{if(!e)return[];let n=new WeakSet,o=new Set,r=[],l=[document],s=i=>{if(!(!i||n.has(i)||r.length>=t)){n.add(i);try{let a=i.querySelectorAll(e);for(let d of a)if(!o.has(d)&&(o.add(d),r.push(d),r.length>=t))return}catch{}try{let d=(i instanceof Document?i:i.host?.ownerDocument??document).createTreeWalker(i,NodeFilter.SHOW_ELEMENT),f;for(;f=d.nextNode();){if(!(f instanceof Element))continue;let c=f.shadowRoot;c&&l.push(c)}}catch{}}};for(;l.length&&r.length<t;){let i=l.shift();i&&s(i)}return r};function ve(e,t){let n=String(e??\"\").trim();if(!n)return null;let o=C(t);return V(n,o+1)[o]??null}function Te(e,t){let n=String(e??\"\").trim();if(!n)return null;let o=C(t),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\"function\")return V(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,i=new Set,a=[],d=[document],f=c=>{if(!(!c||s.has(c)||a.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!i.has(g)&&(i.add(g),a.push(g),a.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&d.push(x);let y=l(w);y&&d.push(y)}}catch{}}};for(;d.length&&a.length<o+1;){let c=d.shift();c&&f(c)}return a[o]??null}function Re(e,t){let n=String(e??\"\");if(!n)return null;let o=n.toLowerCase(),r=C(t),l=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),s=u=>{if(!u)return!1;let h=u.tagName?.toUpperCase()??\"\";return l.has(h)},i=u=>{try{if(s(u))return\"\";let h=u.innerText;if(typeof h==\"string\"&&h.trim())return h.trim()}catch{}try{let h=u.textContent;if(typeof h==\"string\")return h.trim()}catch{}return\"\"},a=u=>{let h=i(u);return!!h&&h.toLowerCase().includes(o)},d=window.__stagehandV3__,f=d&&typeof d.getClosedRoot==\"function\"?u=>{try{return d.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&a(u)&&g.push({element:u,tag:u.tagName??\"\",id:u.id??\"\",className:u.className??\"\",text:i(u)});let h=x(u);if(!h)continue;let E;for(;E=h.nextNode();){if(!(E instanceof Element))continue;a(E)&&g.push({element:E,tag:E.tagName??\"\",id:E.id??\"\",className:E.className??\"\",text:i(E)});let b=E.shadowRoot;b&&w(b);let D=f(E);D&&w(D)}}let y=[];for(let u of g){let h=u.element,E=!1;for(let b of g)if(u!==b)try{if(h.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}function Ne(e,t){let n=C(t);return k(e,n,{pierceShadow:!0})}function Ce(e){let t=String(e??\"\").trim();if(!t)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\"function\"&&(l+=s.querySelectorAll(t).length)}catch{}try{let i=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();)a instanceof Element&&a.shadowRoot&&(l+=o(a.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(t).length}catch{return 0}}}function Me(e){let t=String(e??\"\").trim();if(!t)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\"function\")try{return document.querySelectorAll(t).length}catch{return 0}let o=new WeakSet,r=[],l=a=>{!a||o.has(a)||(o.add(a),r.push(a))};l(document);let s=0,i=a=>{let d=a.shadowRoot;d&&l(d);try{let f=n.getClosedRoot(a);f&&l(f)}catch{}};for(;r.length;){let a=r.shift();if(a){try{let d=a;typeof d.querySelectorAll==\"function\"&&(s+=d.querySelectorAll(t).length)}catch{}try{let f=(a instanceof Document?a:a instanceof ShadowRoot?a.host?.ownerDocument??document:a.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&i(c)}catch{}}}return s}function Le(e){let t=String(e??\"\");if(!t)return{count:0,sample:[],error:null};let n=t.toLowerCase(),o=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),r=m=>{if(!m)return!1;let u=m.tagName?.toUpperCase()??\"\";return o.has(u)},l=m=>{try{if(r(m))return\"\";let u=m.innerText;if(typeof u==\"string\"&&u.trim())return u.trim()}catch{}try{let u=m.textContent;if(typeof u==\"string\")return u.trim()}catch{}return\"\"},s=m=>{let u=l(m);return!!u&&u.toLowerCase().includes(n)},i=window.__stagehandV3__,a=i&&typeof i.getClosedRoot==\"function\"?m=>{try{return i.getClosedRoot(m)??null}catch{return null}}:m=>null,d=new WeakSet,f=[],c=m=>{!m||d.has(m)||(d.add(m),f.push(m))},p=m=>{try{return(m instanceof Document?m:m?.ownerDocument??document).createTreeWalker(m,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let m=f.shift();if(!m)continue;m instanceof Element&&s(m)&&g.push({element:m,tag:m.tagName??\"\",id:m.id??\"\",className:m.className??\"\",text:l(m)});let u=p(m);if(!u)continue;let h;for(;h=u.nextNode();){if(!(h instanceof Element))continue;s(h)&&g.push({element:h,tag:h.tagName??\"\",id:h.id??\"\",className:h.className??\"\",text:l(h)});let E=h.shadowRoot;E&&c(E);let b=a(h);b&&c(b)}}let w=[];for(let m of g){let u=m.element,h=!1;for(let E of g)if(m!==E)try{if(u.contains(E.element)){h=!0;break}}catch{}h||w.push(m)}let x=w.length,y=w.slice(0,5).map(m=>({tag:m.tag,id:m.id,class:m.className,text:m.text}));return{count:x,sample:y,error:null}}function Pe(e){return $(e,{pierceShadow:!0})}var ke=e=>e.startsWith(\"xpath=\")||e.startsWith(\"/\"),De=e=>{try{let t=window.__stagehandV3__;if(t&&typeof t.getClosedRoot==\"function\")return t.getClosedRoot(e)??null}catch{}return null},Y=e=>e.shadowRoot?e.shadowRoot:De(e),He=(e,t,n)=>{try{let l=e.querySelector(t);if(l)return l}catch{}if(!n)return null;let o=new WeakSet,r=[e];for(;r.length>0;){let l=r.shift();if(!(!l||o.has(l))){o.add(l);try{let s=l.querySelector(t);if(s)return s}catch{}try{let i=(l instanceof Document?l:l.host?.ownerDocument??document).createTreeWalker(l,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();){if(!(a instanceof Element))continue;let d=Y(a);d&&!o.has(d)&&r.push(d)}}catch{}}}return null},Ae=(e,t)=>I(e,{pierceShadow:t}),B=(e,t)=>ke(e)?Ae(e,t):He(document,e,t),G=(e,t)=>{if(t===\"detached\")return e===null;if(t===\"attached\")return e!==null;if(e===null)return!1;if(t===\"hidden\")try{let n=window.getComputedStyle(e),o=e.getBoundingClientRect();return n.display===\"none\"||n.visibility===\"hidden\"||n.opacity===\"0\"||o.width===0||o.height===0}catch{return!1}try{let n=window.getComputedStyle(e),o=e.getBoundingClientRect();return n.display!==\"none\"&&n.visibility!==\"hidden\"&&n.opacity!==\"0\"&&o.width>0&&o.height>0}catch{return!1}},We=(e,t)=>{let n=new WeakSet,o=l=>{let s=Y(l);if(s&&!n.has(s)){n.add(s);let i=new MutationObserver(e);i.observe(s,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),t.push(i);for(let a of Array.from(s.children))o(a)}for(let i of Array.from(l.children))o(i)},r=document.documentElement||document.body;r&&o(r)};function _e(e,t,n,o){let r=String(e??\"\").trim(),l=String(t??\"visible\")||\"visible\",s=typeof n==\"number\"&&n>0?n:3e4,i=o!==!1;return new Promise((a,d)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=B(r,i);if(G(w,l)){p=!0,a(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\"DOMContentLoaded\",c),c=null)},m=()=>{if(p)return;let E=B(r,i);G(E,l)&&(p=!0,g(),y(),a(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\"DOMContentLoaded\",c),c=null,m(),h()},document.addEventListener(\"DOMContentLoaded\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s);return}let h=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(m);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),x.push(b),i&&We(m,x)};h(),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s)})}return J(Oe);})();\\n globalThis.__stagehandLocatorScripts = __stagehandLocatorScriptsFactory;\\n}';\nexport const locatorScriptSources = {\n assignFilePayloadsToInputElement:\n 'function ce(e){try{let t=this;if(!t||t.tagName?.toLowerCase()!==\"input\"||(t.type??\"\").toLowerCase()!==\"file\")return!1;let n=(()=>{try{return new DataTransfer}catch{return null}})();if(!n)return!1;let o=Array.isArray(e)?e:[];for(let r of o){if(!r)continue;let l=r.name||\"upload.bin\",s=r.mimeType||\"application/octet-stream\",i=typeof r.lastModified==\"number\"?r.lastModified:Date.now(),a=window.atob(r.base64??\"\"),d=new Uint8Array(a.length);for(let p=0;p<a.length;p+=1)d[p]=a.charCodeAt(p);let f=new Blob([d],{type:s}),c=new File([f],l,{type:s,lastModified:i});n.items.add(c)}return t.files=n.files,t.dispatchEvent(new Event(\"input\",{bubbles:!0})),t.dispatchEvent(new Event(\"change\",{bubbles:!0})),!0}catch{return!1}}',\n countCssMatchesPierce:\n 'function He(e){let t=String(e??\"\").trim();if(!t)return 0;let n=window.__stagehandV3__;if(!n||typeof n.getClosedRoot!=\"function\")try{return document.querySelectorAll(t).length}catch{return 0}let o=new WeakSet,r=[],l=a=>{!a||o.has(a)||(o.add(a),r.push(a))};l(document);let s=0,i=a=>{let d=a.shadowRoot;d&&l(d);try{let f=n.getClosedRoot(a);f&&l(f)}catch{}};for(;r.length;){let a=r.shift();if(a){try{let d=a;typeof d.querySelectorAll==\"function\"&&(s+=d.querySelectorAll(t).length)}catch{}try{let f=(a instanceof Document?a:a instanceof ShadowRoot?a.host?.ownerDocument??document:a.ownerDocument??document).createTreeWalker(a,NodeFilter.SHOW_ELEMENT),c;for(;c=f.nextNode();)c instanceof Element&&i(c)}catch{}}}return s}',\n countCssMatchesPrimary:\n 'function De(e){let t=String(e??\"\").trim();if(!t)return 0;let n=new WeakSet,o=r=>{if(!r||n.has(r))return 0;n.add(r);let l=0;try{let s=r;typeof s.querySelectorAll==\"function\"&&(l+=s.querySelectorAll(t).length)}catch{}try{let i=(r instanceof Document?r:r?.ownerDocument??document).createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a;for(;a=i.nextNode();)a instanceof Element&&a.shadowRoot&&(l+=o(a.shadowRoot))}catch{}return l};try{return o(document)}catch{try{return document.querySelectorAll(t).length}catch{return 0}}}',\n countTextMatches:\n 'function Ae(e){let t=String(e??\"\");if(!t)return{count:0,sample:[],error:null};let n=t.toLowerCase(),o=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),r=m=>{if(!m)return!1;let u=m.tagName?.toUpperCase()??\"\";return o.has(u)},l=m=>{try{if(r(m))return\"\";let u=m.innerText;if(typeof u==\"string\"&&u.trim())return u.trim()}catch{}try{let u=m.textContent;if(typeof u==\"string\")return u.trim()}catch{}return\"\"},s=m=>{let u=l(m);return!!u&&u.toLowerCase().includes(n)},i=window.__stagehandV3__,a=i&&typeof i.getClosedRoot==\"function\"?m=>{try{return i.getClosedRoot(m)??null}catch{return null}}:m=>null,d=new WeakSet,f=[],c=m=>{!m||d.has(m)||(d.add(m),f.push(m))},p=m=>{try{return(m instanceof Document?m:m?.ownerDocument??document).createTreeWalker(m,NodeFilter.SHOW_ELEMENT)}catch{return null}},g=[];for(c(document);f.length;){let m=f.shift();if(!m)continue;m instanceof Element&&s(m)&&g.push({element:m,tag:m.tagName??\"\",id:m.id??\"\",className:m.className??\"\",text:l(m)});let u=p(m);if(!u)continue;let h;for(;h=u.nextNode();){if(!(h instanceof Element))continue;s(h)&&g.push({element:h,tag:h.tagName??\"\",id:h.id??\"\",className:h.className??\"\",text:l(h)});let E=h.shadowRoot;E&&c(E);let b=a(h);b&&c(b)}}let w=[];for(let m of g){let u=m.element,h=!1;for(let E of g)if(m!==E)try{if(u.contains(E.element)){h=!0;break}}catch{}h||w.push(m)}let x=w.length,y=w.slice(0,5).map(m=>({tag:m.tag,id:m.id,class:m.className,text:m.text}));return{count:x,sample:y,error:null}}',\n countXPathMatchesMainWorld: \"function We(e){return I(e,{pierceShadow:!0})}\",\n dispatchDomClick:\n 'function ue(e){let t=e??{};try{let n=new MouseEvent(\"click\",{bubbles:!!t.bubbles,cancelable:!!t.cancelable,composed:!!t.composed,detail:typeof t.detail==\"number\"?t.detail:1,view:this?.ownerDocument?.defaultView??window});this.dispatchEvent(n)}catch{try{this.click()}catch{}}}',\n ensureFileInputElement:\n 'function ae(){try{return(this.tagName?.toLowerCase()??\"\")!==\"input\"?!1:String(this.type??\"\").toLowerCase()===\"file\"}catch{return!1}}',\n fillElementValue:\n 'function me(e){let t=this;if(!t.isConnected)return{status:\"error\",reason:\"notconnected\"};let o=(t.ownerDocument||document).defaultView||window,r=e??\"\";try{let l=s=>{let i;if(typeof o.InputEvent==\"function\")try{i=new o.InputEvent(\"input\",{bubbles:!0,composed:!0,data:s,inputType:\"insertText\"})}catch{i=new o.Event(\"input\",{bubbles:!0,composed:!0})}else i=new o.Event(\"input\",{bubbles:!0,composed:!0});t.dispatchEvent(i);let a=new o.Event(\"change\",{bubbles:!0});t.dispatchEvent(a)};if(t instanceof o.HTMLInputElement){let s=(t.type||\"\").toLowerCase();if(!Y.has(s)&&!D.has(s))return{status:\"error\",reason:`unsupported-input-type:${s}`};let i=e;if(s===\"number\"){let a=e.trim();if(a!==\"\"&&Number.isNaN(Number(a)))return{status:\"error\",reason:\"invalid-number-value\"};i=a}if(r=i,D.has(s)){let a=e.trim();r=a,v.call(t);let d=o.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(d,\"value\")?.set;return typeof c==\"function\"?c.call(t,a):t.value=a,t._valueTracker?.setValue?.(a),t.value!==a?{status:\"error\",reason:\"malformed-value\"}:(l(a),{status:\"done\"})}return v.call(t),{status:\"needsinput\",value:i}}return t instanceof o.HTMLTextAreaElement?(v.call(t),r=e,{status:\"needsinput\",value:e}):t instanceof o.HTMLSelectElement?{status:\"error\",reason:\"unsupported-element\"}:t.isContentEditable?(v.call(t),r=e,{status:\"needsinput\",value:e}):{status:\"error\",reason:\"unsupported-element\"}}catch(l){let s=\"exception\";if(l&&typeof l==\"object\"){let i=l.message;typeof i==\"string\"&&i.trim().length>0&&(s=`exception:${i}`)}return{status:\"needsinput\",value:r,reason:s}}}',\n focusElement:\n 'function fe(){try{typeof this.focus==\"function\"&&this.focus()}catch{}}',\n isElementChecked:\n 'function ge(){try{let e=this;if((e.tagName||\"\").toLowerCase()===\"input\"){let o=e.type?.toLowerCase()??\"\";if(o===\"checkbox\"||o===\"radio\")return!!e.checked}let n=e.getAttribute?.(\"aria-checked\");return n!=null?n===\"true\":!1}catch{return!1}}',\n isElementVisible:\n 'function pe(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument?.defaultView?.getComputedStyle(e)??window.getComputedStyle(e);if(!t||t.display===\"none\"||t.visibility===\"hidden\")return!1;let n=parseFloat(t.opacity??\"1\");if(!Number.isFinite(n)||n===0)return!1;let o=e.getBoundingClientRect();return!(!o||Math.max(o.width,o.height)===0||e.getClientRects().length===0)}catch{return!1}}',\n prepareElementForTyping:\n 'function v(){try{let e=this;if(!e.isConnected)return!1;let t=e.ownerDocument||document,n=t.defaultView||window;try{typeof e.focus==\"function\"&&e.focus()}catch{}if(e instanceof n.HTMLInputElement||e instanceof n.HTMLTextAreaElement){try{if(typeof e.select==\"function\")return e.select(),!0}catch{}try{let o=(e.value??\"\").length;if(typeof e.setSelectionRange==\"function\")return e.setSelectionRange(0,o),!0}catch{}return!0}if(e.isContentEditable){let o=t.getSelection?.(),r=t.createRange?.();if(o&&r)try{r.selectNodeContents(e),o.removeAllRanges(),o.addRange(r)}catch{}return!0}return!1}catch{return!1}}',\n readElementInnerHTML:\n 'function ye(){try{return String(this.innerHTML??\"\")}catch{return\"\"}}',\n readElementInnerText:\n 'function be(){try{let e=this,t=e.innerText;if(typeof t==\"string\"&&t.length>0)return t;let n=e.textContent;return typeof n==\"string\"?n:\"\"}catch{return\"\"}}',\n readElementInputValue:\n 'function Ee(){try{let e=this,t=(e.tagName||\"\").toLowerCase();return t===\"input\"||t===\"textarea\"||t===\"select\"?String(e.value??\"\"):e.isContentEditable?String(e.textContent??\"\"):\"\"}catch{return\"\"}}',\n readElementTextContent:\n 'function we(){try{return String(this.textContent??\"\")}catch{return\"\"}}',\n resolveCssSelector:\n 'function Ne(e,t){let n=String(e??\"\").trim();if(!n)return null;let o=C(t);return z(n,o+1)[o]??null}',\n resolveCssSelectorPierce:\n 'function Ce(e,t){let n=String(e??\"\").trim();if(!n)return null;let o=C(t),r=window.__stagehandV3__;if(!r||typeof r.getClosedRoot!=\"function\")return z(n,o+1)[o]??null;let l=c=>{try{return r.getClosedRoot(c)??null}catch{return null}},s=new WeakSet,i=new Set,a=[],d=[document],f=c=>{if(!(!c||s.has(c)||a.length>=o+1)){s.add(c);try{let p=c.querySelectorAll(n);for(let g of p)if(!i.has(g)&&(i.add(g),a.push(g),a.length>=o+1))return}catch{}try{let g=(c instanceof Document?c:c.host?.ownerDocument??document).createTreeWalker(c,NodeFilter.SHOW_ELEMENT),w;for(;w=g.nextNode();){if(!(w instanceof Element))continue;let x=w.shadowRoot;x&&d.push(x);let y=l(w);y&&d.push(y)}}catch{}}};for(;d.length&&a.length<o+1;){let c=d.shift();c&&f(c)}return a[o]??null}',\n resolveTextSelector:\n 'function Me(e,t){let n=String(e??\"\");if(!n)return null;let o=n.toLowerCase(),r=C(t),l=new Set([\"SCRIPT\",\"STYLE\",\"TEMPLATE\",\"NOSCRIPT\",\"HEAD\",\"TITLE\",\"LINK\",\"META\",\"HTML\",\"BODY\"]),s=u=>{if(!u)return!1;let h=u.tagName?.toUpperCase()??\"\";return l.has(h)},i=u=>{try{if(s(u))return\"\";let h=u.innerText;if(typeof h==\"string\"&&h.trim())return h.trim()}catch{}try{let h=u.textContent;if(typeof h==\"string\")return h.trim()}catch{}return\"\"},a=u=>{let h=i(u);return!!h&&h.toLowerCase().includes(o)},d=window.__stagehandV3__,f=d&&typeof d.getClosedRoot==\"function\"?u=>{try{return d.getClosedRoot(u)??null}catch{return null}}:u=>null,c=new WeakSet,p=[],g=[],w=u=>{!u||c.has(u)||(c.add(u),p.push(u))},x=u=>{try{return(u instanceof Document?u:u?.ownerDocument??document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT)}catch{return null}};for(w(document);p.length;){let u=p.shift();if(!u)continue;u instanceof Element&&a(u)&&g.push({element:u,tag:u.tagName??\"\",id:u.id??\"\",className:u.className??\"\",text:i(u)});let h=x(u);if(!h)continue;let E;for(;E=h.nextNode();){if(!(E instanceof Element))continue;a(E)&&g.push({element:E,tag:E.tagName??\"\",id:E.id??\"\",className:E.className??\"\",text:i(E)});let b=E.shadowRoot;b&&w(b);let k=f(E);k&&w(k)}}let y=[];for(let u of g){let h=u.element,E=!1;for(let b of g)if(u!==b)try{if(h.contains(b.element)){E=!0;break}}catch{}E||y.push(u)}return y[r]?.element??null}',\n resolveXPathMainWorld:\n \"function Le(e,t){let n=C(t);return P(e,n,{pierceShadow:!0})}\",\n scrollElementToPercent:\n 'function de(e){let t=n=>{if(typeof n==\"number\"&&Number.isFinite(n))return n;let o=String(n??\"\").trim();if(!o)return 0;let r=parseFloat(o.replace(\"%\",\"\"));return Number.isNaN(r)||!Number.isFinite(r)?0:r};try{let n=Math.max(0,Math.min(t(e),100)),o=this,r=o.tagName?.toLowerCase()??\"\";if(r===\"html\"||r===\"body\"){let c=(o.ownerDocument?.scrollingElement||o.ownerDocument?.documentElement||o.ownerDocument?.body||document.scrollingElement||document.documentElement||document.body)?.scrollHeight??document.body.scrollHeight??0,p=o.ownerDocument?.defaultView?.innerHeight??window.innerHeight,w=Math.max(0,c-p)*(n/100);return o.ownerDocument?.defaultView?.scrollTo({top:w,left:o.ownerDocument?.defaultView?.scrollX??window.scrollX??0,behavior:\"smooth\"}),!0}let s=o.scrollHeight??0,i=o.clientHeight??0,d=Math.max(0,s-i)*(n/100);return o.scrollTo({top:d,left:o.scrollLeft??0,behavior:\"smooth\"}),!0}catch{return!1}}',\n selectElementOptions:\n 'function he(e){try{if(!(this instanceof HTMLSelectElement))return[];let t=Array.isArray(e)?e:[e],n=new Set(t.map(s=>String(s??\"\").trim())),o=s=>{let i=(s.label||s.textContent||\"\").trim(),a=String(s.value??\"\").trim();return n.has(i)||n.has(a)};if(this.multiple)for(let s of Array.from(this.options))s.selected=o(s);else{let s=!1;for(let i of Array.from(this.options))!s&&o(i)?(i.selected=!0,this.value=i.value,s=!0):i.selected=!1}let r=new Event(\"input\",{bubbles:!0}),l=new Event(\"change\",{bubbles:!0});return this.dispatchEvent(r),this.dispatchEvent(l),Array.from(this.selectedOptions).map(s=>s.value)}catch{return[]}}',\n waitForSelector:\n 'function qe(e,t,n,o){let r=String(e??\"\").trim(),l=String(t??\"visible\")||\"visible\",s=typeof n==\"number\"&&n>0?n:3e4,i=o!==!1;return new Promise((a,d)=>{let f=null,c=null,p=!1,g=()=>{f!==null&&(clearTimeout(f),f=null)},w=V(r,i);if(B(w,l)){p=!0,a(!0);return}let x=[],y=()=>{for(let E of x)E.disconnect();c&&(document.removeEventListener(\"DOMContentLoaded\",c),c=null)},m=()=>{if(p)return;let E=V(r,i);B(E,l)&&(p=!0,g(),y(),a(!0))};if(!(document.body||document.documentElement)){c=()=>{document.removeEventListener(\"DOMContentLoaded\",c),c=null,m(),h()},document.addEventListener(\"DOMContentLoaded\",c),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s);return}let h=()=>{let E=document.body||document.documentElement;if(!E)return;let b=new MutationObserver(m);b.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"disabled\"]}),x.push(b),i&&ie(m,x)};h(),f=setTimeout(()=>{p||(p=!0,g(),y(),d(new Error(`waitForSelector: Timeout ${s}ms exceeded waiting for \"${r}\" to be ${l}`)))},s)})}',\n} as const;\nexport const locatorScriptGlobalRefs = {\n assignFilePayloadsToInputElement:\n \"globalThis.__stagehandLocatorScripts.assignFilePayloadsToInputElement\",\n countCssMatchesPierce:\n \"globalThis.__stagehandLocatorScripts.countCssMatchesPierce\",\n countCssMatchesPrimary:\n \"globalThis.__stagehandLocatorScripts.countCssMatchesPrimary\",\n countTextMatches: \"globalThis.__stagehandLocatorScripts.countTextMatches\",\n countXPathMatchesMainWorld:\n \"globalThis.__stagehandLocatorScripts.countXPathMatchesMainWorld\",\n dispatchDomClick: \"globalThis.__stagehandLocatorScripts.dispatchDomClick\",\n ensureFileInputElement:\n \"globalThis.__stagehandLocatorScripts.ensureFileInputElement\",\n fillElementValue: \"globalThis.__stagehandLocatorScripts.fillElementValue\",\n focusElement: \"globalThis.__stagehandLocatorScripts.focusElement\",\n isElementChecked: \"globalThis.__stagehandLocatorScripts.isElementChecked\",\n isElementVisible: \"globalThis.__stagehandLocatorScripts.isElementVisible\",\n prepareElementForTyping:\n \"globalThis.__stagehandLocatorScripts.prepareElementForTyping\",\n readElementInnerHTML:\n \"globalThis.__stagehandLocatorScripts.readElementInnerHTML\",\n readElementInnerText:\n \"globalThis.__stagehandLocatorScripts.readElementInnerText\",\n readElementInputValue:\n \"globalThis.__stagehandLocatorScripts.readElementInputValue\",\n readElementTextContent:\n \"globalThis.__stagehandLocatorScripts.readElementTextContent\",\n resolveCssSelector: \"globalThis.__stagehandLocatorScripts.resolveCssSelector\",\n resolveCssSelectorPierce:\n \"globalThis.__stagehandLocatorScripts.resolveCssSelectorPierce\",\n resolveTextSelector:\n \"globalThis.__stagehandLocatorScripts.resolveTextSelector\",\n resolveXPathMainWorld:\n \"globalThis.__stagehandLocatorScripts.resolveXPathMainWorld\",\n scrollElementToPercent:\n \"globalThis.__stagehandLocatorScripts.scrollElementToPercent\",\n selectElementOptions:\n \"globalThis.__stagehandLocatorScripts.selectElementOptions\",\n waitForSelector: \"globalThis.__stagehandLocatorScripts.waitForSelector\",\n} as const;\nexport type LocatorScriptName = keyof typeof locatorScriptSources;\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reRenderScriptContent = void 0;
4
- exports.reRenderScriptContent = "(()=>{function s(){try{let o=window.__stagehandV3__;if(!o||typeof o.getClosedRoot!=\"function\")return;let t=[],r=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;r.nextNode();){let e=r.currentNode,n=e.tagName?.toLowerCase()??\"\";if(!n.includes(\"-\")||typeof customElements?.get!=\"function\"||!customElements.get(n))continue;let c=!!e.shadowRoot,i=!!o.getClosedRoot(e);c||i||t.push(e)}for(let e of t)try{let n=e.cloneNode(!0);e.replaceWith(n)}catch{}o.stats&&t.length&&console.info(\"[v3-piercer] rerender\",{count:t.length})}catch(o){console.info(\"[v3-piercer] rerender error\",{message:String(o??\"\")})}}s();})();\n";
4
+ exports.reRenderScriptContent = '(()=>{function s(){try{let o=window.__stagehandV3__;if(!o||typeof o.getClosedRoot!="function")return;let t=[],r=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;r.nextNode();){let e=r.currentNode,n=e.tagName?.toLowerCase()??"";if(!n.includes("-")||typeof customElements?.get!="function"||!customElements.get(n))continue;let c=!!e.shadowRoot,i=!!o.getClosedRoot(e);c||i||t.push(e)}for(let e of t)try{let n=e.cloneNode(!0);e.replaceWith(n)}catch{}o.stats&&t.length&&console.info("[v3-piercer] rerender",{count:t.length})}catch(o){console.info("[v3-piercer] rerender error",{message:String(o??"")})}}s();})();\n';
5
5
  //# sourceMappingURL=reRenderScriptContent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reRenderScriptContent.js","sourceRoot":"","sources":["../../../../../../lib/v3/dom/build/reRenderScriptContent.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,goBAAgoB,CAAC","sourcesContent":["export const reRenderScriptContent = \"(()=>{function s(){try{let o=window.__stagehandV3__;if(!o||typeof o.getClosedRoot!=\\\"function\\\")return;let t=[],r=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;r.nextNode();){let e=r.currentNode,n=e.tagName?.toLowerCase()??\\\"\\\";if(!n.includes(\\\"-\\\")||typeof customElements?.get!=\\\"function\\\"||!customElements.get(n))continue;let c=!!e.shadowRoot,i=!!o.getClosedRoot(e);c||i||t.push(e)}for(let e of t)try{let n=e.cloneNode(!0);e.replaceWith(n)}catch{}o.stats&&t.length&&console.info(\\\"[v3-piercer] rerender\\\",{count:t.length})}catch(o){console.info(\\\"[v3-piercer] rerender error\\\",{message:String(o??\\\"\\\")})}}s();})();\\n\";"]}
1
+ {"version":3,"file":"reRenderScriptContent.js","sourceRoot":"","sources":["../../../../../../lib/v3/dom/build/reRenderScriptContent.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAChC,knBAAknB,CAAC","sourcesContent":["export const reRenderScriptContent =\n '(()=>{function s(){try{let o=window.__stagehandV3__;if(!o||typeof o.getClosedRoot!=\"function\")return;let t=[],r=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;r.nextNode();){let e=r.currentNode,n=e.tagName?.toLowerCase()??\"\";if(!n.includes(\"-\")||typeof customElements?.get!=\"function\"||!customElements.get(n))continue;let c=!!e.shadowRoot,i=!!o.getClosedRoot(e);c||i||t.push(e)}for(let e of t)try{let n=e.cloneNode(!0);e.replaceWith(n)}catch{}o.stats&&t.length&&console.info(\"[v3-piercer] rerender\",{count:t.length})}catch(o){console.info(\"[v3-piercer] rerender error\",{message:String(o??\"\")})}}s();})();\\n';\n"]}
@@ -6,6 +6,6 @@ exports.screenshotScriptSources = void 0;
6
6
  * Update sources in lib/v3/dom/screenshotScripts and run genScreenshotScripts.ts.
7
7
  */
8
8
  exports.screenshotScriptSources = {
9
- "resolveMaskRect": "function h(r){function u(t,e){try{return t&&typeof t.closest==\"function\"?t.closest(e):null}catch{return null}}function s(t,e){try{return!!t&&typeof t.matches==\"function\"&&t.matches(e)}catch{return!1}}function c(t){let e=u(t,\"dialog[open]\");if(e)return e;let l=u(t,\"[popover]\");return l&&s(l,\":popover-open\")?l:null}if(!this||typeof this.getBoundingClientRect!=\"function\")return null;let n=this.getBoundingClientRect();if(!n)return null;let i=window.getComputedStyle(this);if(!i||i.visibility===\"hidden\"||i.display===\"none\"||n.width<=0||n.height<=0)return null;let o=c(this);if(o){let t=o.getBoundingClientRect();if(!t)return null;let e=null;if(r)try{let l=o.getAttribute(\"data-stagehand-mask-root\");l&&l.startsWith(r)?e=l:(e=r+\"_root_\"+Math.random().toString(36).slice(2),o.setAttribute(\"data-stagehand-mask-root\",e))}catch{e=null}return{x:n.left-t.left-(o.clientLeft||0)+(o.scrollLeft||0),y:n.top-t.top-(o.clientTop||0)+(o.scrollTop||0),width:n.width,height:n.height,rootToken:e}}return{x:n.left+window.scrollX,y:n.top+window.scrollY,width:n.width,height:n.height,rootToken:null}}"
9
+ resolveMaskRect: 'function h(r){function u(t,e){try{return t&&typeof t.closest=="function"?t.closest(e):null}catch{return null}}function s(t,e){try{return!!t&&typeof t.matches=="function"&&t.matches(e)}catch{return!1}}function c(t){let e=u(t,"dialog[open]");if(e)return e;let l=u(t,"[popover]");return l&&s(l,":popover-open")?l:null}if(!this||typeof this.getBoundingClientRect!="function")return null;let n=this.getBoundingClientRect();if(!n)return null;let i=window.getComputedStyle(this);if(!i||i.visibility==="hidden"||i.display==="none"||n.width<=0||n.height<=0)return null;let o=c(this);if(o){let t=o.getBoundingClientRect();if(!t)return null;let e=null;if(r)try{let l=o.getAttribute("data-stagehand-mask-root");l&&l.startsWith(r)?e=l:(e=r+"_root_"+Math.random().toString(36).slice(2),o.setAttribute("data-stagehand-mask-root",e))}catch{e=null}return{x:n.left-t.left-(o.clientLeft||0)+(o.scrollLeft||0),y:n.top-t.top-(o.clientTop||0)+(o.scrollTop||0),width:n.width,height:n.height,rootToken:e}}return{x:n.left+window.scrollX,y:n.top+window.scrollY,width:n.width,height:n.height,rootToken:null}}',
10
10
  };
11
11
  //# sourceMappingURL=screenshotScripts.generated.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"screenshotScripts.generated.js","sourceRoot":"","sources":["../../../../../../lib/v3/dom/build/screenshotScripts.generated.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,uBAAuB,GAAG;IACrC,iBAAiB,EAAE,ilCAAilC;CAC5lC,CAAC","sourcesContent":["/*\n * AUTO-GENERATED FILE. DO NOT EDIT.\n * Update sources in lib/v3/dom/screenshotScripts and run genScreenshotScripts.ts.\n */\nexport const screenshotScriptSources = {\n \"resolveMaskRect\": \"function h(r){function u(t,e){try{return t&&typeof t.closest==\\\"function\\\"?t.closest(e):null}catch{return null}}function s(t,e){try{return!!t&&typeof t.matches==\\\"function\\\"&&t.matches(e)}catch{return!1}}function c(t){let e=u(t,\\\"dialog[open]\\\");if(e)return e;let l=u(t,\\\"[popover]\\\");return l&&s(l,\\\":popover-open\\\")?l:null}if(!this||typeof this.getBoundingClientRect!=\\\"function\\\")return null;let n=this.getBoundingClientRect();if(!n)return null;let i=window.getComputedStyle(this);if(!i||i.visibility===\\\"hidden\\\"||i.display===\\\"none\\\"||n.width<=0||n.height<=0)return null;let o=c(this);if(o){let t=o.getBoundingClientRect();if(!t)return null;let e=null;if(r)try{let l=o.getAttribute(\\\"data-stagehand-mask-root\\\");l&&l.startsWith(r)?e=l:(e=r+\\\"_root_\\\"+Math.random().toString(36).slice(2),o.setAttribute(\\\"data-stagehand-mask-root\\\",e))}catch{e=null}return{x:n.left-t.left-(o.clientLeft||0)+(o.scrollLeft||0),y:n.top-t.top-(o.clientTop||0)+(o.scrollTop||0),width:n.width,height:n.height,rootToken:e}}return{x:n.left+window.scrollX,y:n.top+window.scrollY,width:n.width,height:n.height,rootToken:null}}\"\n} as const;\nexport type ScreenshotScriptName = keyof typeof screenshotScriptSources;\n"]}
1
+ {"version":3,"file":"screenshotScripts.generated.js","sourceRoot":"","sources":["../../../../../../lib/v3/dom/build/screenshotScripts.generated.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,uBAAuB,GAAG;IACrC,eAAe,EACb,2jCAA2jC;CACrjC,CAAC","sourcesContent":["/*\n * AUTO-GENERATED FILE. DO NOT EDIT.\n * Update sources in lib/v3/dom/screenshotScripts and run genScreenshotScripts.ts.\n */\nexport const screenshotScriptSources = {\n resolveMaskRect:\n 'function h(r){function u(t,e){try{return t&&typeof t.closest==\"function\"?t.closest(e):null}catch{return null}}function s(t,e){try{return!!t&&typeof t.matches==\"function\"&&t.matches(e)}catch{return!1}}function c(t){let e=u(t,\"dialog[open]\");if(e)return e;let l=u(t,\"[popover]\");return l&&s(l,\":popover-open\")?l:null}if(!this||typeof this.getBoundingClientRect!=\"function\")return null;let n=this.getBoundingClientRect();if(!n)return null;let i=window.getComputedStyle(this);if(!i||i.visibility===\"hidden\"||i.display===\"none\"||n.width<=0||n.height<=0)return null;let o=c(this);if(o){let t=o.getBoundingClientRect();if(!t)return null;let e=null;if(r)try{let l=o.getAttribute(\"data-stagehand-mask-root\");l&&l.startsWith(r)?e=l:(e=r+\"_root_\"+Math.random().toString(36).slice(2),o.setAttribute(\"data-stagehand-mask-root\",e))}catch{e=null}return{x:n.left-t.left-(o.clientLeft||0)+(o.scrollLeft||0),y:n.top-t.top-(o.clientTop||0)+(o.scrollTop||0),width:n.width,height:n.height,rootToken:e}}return{x:n.left+window.scrollX,y:n.top+window.scrollY,width:n.width,height:n.height,rootToken:null}}',\n} as const;\nexport type ScreenshotScriptName = keyof typeof screenshotScriptSources;\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.v3ScriptContent = void 0;
4
- exports.v3ScriptContent = "(()=>{function s(c={}){let r=e=>{let{hostToRoot:o}=e;window.__stagehandV3__={getClosedRoot:a=>o.get(a),stats:()=>({installed:!0,url:location.href,isTop:window.top===window,open:e.openCount,closed:e.closedCount})}},n=Element.prototype.attachShadow;if(n.__v3Patched&&n.__v3State){n.__v3State.debug=!0,r(n.__v3State);return}let t={hostToRoot:new WeakMap,openCount:0,closedCount:0,debug:!0},l=n,d=function(e){let o=e?.mode??\"open\",a=l.call(this,e);try{t.hostToRoot.set(this,a),o===\"closed\"?t.closedCount++:t.openCount++,t.debug&&console.info(\"[v3-piercer] attachShadow\",{tag:this.tagName?.toLowerCase()??\"\",mode:o,url:location.href})}catch{}return a};if(d.__v3Patched=!0,d.__v3State=t,Object.defineProperty(Element.prototype,\"attachShadow\",{configurable:!0,writable:!0,value:d}),c.tagExisting)try{let e=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){let o=e.currentNode;o.shadowRoot&&(t.hostToRoot.set(o,o.shadowRoot),t.openCount++)}}catch{}window.__stagehandV3Injected=!0,r(t),t.debug&&console.info(\"[v3-piercer] installed\",{url:location.href,isTop:window.top===window,readyState:document.readyState})}s({debug:!0,tagExisting:!1});})();\n";
4
+ exports.v3ScriptContent = '(()=>{function s(c={}){let r=e=>{let{hostToRoot:o}=e;window.__stagehandV3__={getClosedRoot:a=>o.get(a),stats:()=>({installed:!0,url:location.href,isTop:window.top===window,open:e.openCount,closed:e.closedCount})}},n=Element.prototype.attachShadow;if(n.__v3Patched&&n.__v3State){n.__v3State.debug=!0,r(n.__v3State);return}let t={hostToRoot:new WeakMap,openCount:0,closedCount:0,debug:!0},l=n,d=function(e){let o=e?.mode??"open",a=l.call(this,e);try{t.hostToRoot.set(this,a),o==="closed"?t.closedCount++:t.openCount++,t.debug&&console.info("[v3-piercer] attachShadow",{tag:this.tagName?.toLowerCase()??"",mode:o,url:location.href})}catch{}return a};if(d.__v3Patched=!0,d.__v3State=t,Object.defineProperty(Element.prototype,"attachShadow",{configurable:!0,writable:!0,value:d}),c.tagExisting)try{let e=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){let o=e.currentNode;o.shadowRoot&&(t.hostToRoot.set(o,o.shadowRoot),t.openCount++)}}catch{}window.__stagehandV3Injected=!0,r(t),t.debug&&console.info("[v3-piercer] installed",{url:location.href,isTop:window.top===window,readyState:document.readyState})}s({debug:!0,tagExisting:!1});})();\n';
5
5
  //# sourceMappingURL=scriptV3Content.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scriptV3Content.js","sourceRoot":"","sources":["../../../../../../lib/v3/dom/build/scriptV3Content.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,8pCAA8pC,CAAC","sourcesContent":["export const v3ScriptContent = \"(()=>{function s(c={}){let r=e=>{let{hostToRoot:o}=e;window.__stagehandV3__={getClosedRoot:a=>o.get(a),stats:()=>({installed:!0,url:location.href,isTop:window.top===window,open:e.openCount,closed:e.closedCount})}},n=Element.prototype.attachShadow;if(n.__v3Patched&&n.__v3State){n.__v3State.debug=!0,r(n.__v3State);return}let t={hostToRoot:new WeakMap,openCount:0,closedCount:0,debug:!0},l=n,d=function(e){let o=e?.mode??\\\"open\\\",a=l.call(this,e);try{t.hostToRoot.set(this,a),o===\\\"closed\\\"?t.closedCount++:t.openCount++,t.debug&&console.info(\\\"[v3-piercer] attachShadow\\\",{tag:this.tagName?.toLowerCase()??\\\"\\\",mode:o,url:location.href})}catch{}return a};if(d.__v3Patched=!0,d.__v3State=t,Object.defineProperty(Element.prototype,\\\"attachShadow\\\",{configurable:!0,writable:!0,value:d}),c.tagExisting)try{let e=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){let o=e.currentNode;o.shadowRoot&&(t.hostToRoot.set(o,o.shadowRoot),t.openCount++)}}catch{}window.__stagehandV3Injected=!0,r(t),t.debug&&console.info(\\\"[v3-piercer] installed\\\",{url:location.href,isTop:window.top===window,readyState:document.readyState})}s({debug:!0,tagExisting:!1});})();\\n\";"]}
1
+ {"version":3,"file":"scriptV3Content.js","sourceRoot":"","sources":["../../../../../../lib/v3/dom/build/scriptV3Content.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAC1B,kpCAAkpC,CAAC","sourcesContent":["export const v3ScriptContent =\n '(()=>{function s(c={}){let r=e=>{let{hostToRoot:o}=e;window.__stagehandV3__={getClosedRoot:a=>o.get(a),stats:()=>({installed:!0,url:location.href,isTop:window.top===window,open:e.openCount,closed:e.closedCount})}},n=Element.prototype.attachShadow;if(n.__v3Patched&&n.__v3State){n.__v3State.debug=!0,r(n.__v3State);return}let t={hostToRoot:new WeakMap,openCount:0,closedCount:0,debug:!0},l=n,d=function(e){let o=e?.mode??\"open\",a=l.call(this,e);try{t.hostToRoot.set(this,a),o===\"closed\"?t.closedCount++:t.openCount++,t.debug&&console.info(\"[v3-piercer] attachShadow\",{tag:this.tagName?.toLowerCase()??\"\",mode:o,url:location.href})}catch{}return a};if(d.__v3Patched=!0,d.__v3State=t,Object.defineProperty(Element.prototype,\"attachShadow\",{configurable:!0,writable:!0,value:d}),c.tagExisting)try{let e=document.createTreeWalker(document,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();){let o=e.currentNode;o.shadowRoot&&(t.hostToRoot.set(o,o.shadowRoot),t.openCount++)}}catch{}window.__stagehandV3Injected=!0,r(t),t.debug&&console.info(\"[v3-piercer] installed\",{url:location.href,isTop:window.top===window,readyState:document.readyState})}s({debug:!0,tagExisting:!1});})();\\n';\n"]}
@@ -146,11 +146,6 @@ class AISdkClient extends LLMClient_js_1.LLMClient {
146
146
  structuredOutputs: true,
147
147
  };
148
148
  break;
149
- case "anthropic":
150
- providerOptions.anthropic = {
151
- structuredOutputMode: "auto",
152
- };
153
- break;
154
149
  case "groq":
155
150
  providerOptions.groq = {
156
151
  structuredOutputs: true,
@@ -1 +1 @@
1
- {"version":3,"file":"aisdk.js","sourceRoot":"","sources":["../../../../../lib/v3/llm/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ACG,CAAC;QAEP,oCAAoC;QACpC,0BAAU,CAAC,cAAc,CAAC;YACxB,SAAS,EAAE,YAAY;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YACzB,MAAM,EACJ,YAAY,CAAC,IAAI;gBACjB,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC;oBAC9B,CAAC,CAAC,IAAI,oBAAoB,CAAC,MAAM,cAAc;oBAC/C,CAAC,CAAC,EAAE,CAAC;YACT,WAAW,EAAE,YAAY,CAAC,KAAK,CAAC,WAAW;YAC3C,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,YAAY;SAC9C,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,UAAU;YACnB,KAAK,EAAE,CAAC;YACR,SAAS,EAAE;gBACT,QAAQ,EAAE;oBACR,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;wBACpB,IAAI,EAAE,YAAY,CAAC,IAAI;wBACvB,KAAK,EAAE,YAAY,CAAC,KAAK;wBACzB,YAAY,EAAE,YAAY,CAAC,YAAY;wBACvC,iEAAiE;qBAClE,CAAC;oBACF,IAAI,EAAE,QAAQ;iBACf;gBACD,SAAS,EAAE;oBACT,KAAK,EAAE,OAAO,CAAC,SAAS;oBACxB,IAAI,EAAE,QAAQ;iBACf;aACF;SACF,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAlbD,kCAkbC","sourcesContent":["import {\n CoreAssistantMessage,\n ModelMessage,\n CoreSystemMessage,\n CoreUserMessage,\n generateObject,\n generateText,\n ImagePart,\n NoObjectGeneratedError,\n TextPart,\n ToolSet,\n Tool,\n} from \"ai\";\nimport type { LanguageModelV2 } from \"@ai-sdk/provider\";\nimport { ChatCompletion } from \"openai/resources\";\nimport { v7 as uuidv7 } from \"uuid\";\nimport { LogLine } from \"../types/public/logs.js\";\nimport { AvailableModel, ClientOptions } from \"../types/public/model.js\";\nimport { CreateChatCompletionOptions, LLMClient } from \"./LLMClient.js\";\nimport {\n FlowLogger,\n extractLlmPromptSummary,\n} from \"../flowlogger/FlowLogger.js\";\nimport { toJsonSchema } from \"../zodCompat.js\";\n\ntype ProviderOptionValue = string | number | boolean | null;\ntype ProviderOptionMap = Record<string, ProviderOptionValue>;\n\nfunction inferProviderName(modelId: string): string | undefined {\n const [providerName] = modelId.split(\"/\");\n return providerName || undefined;\n}\n\nexport class AISdkClient extends LLMClient {\n public type = \"aisdk\" as const;\n private model: LanguageModelV2;\n private logger?: (message: LogLine) => void;\n\n constructor({\n model,\n logger,\n clientOptions,\n }: {\n model: LanguageModelV2;\n logger?: (message: LogLine) => void;\n clientOptions?: ClientOptions;\n }) {\n super(model.modelId as AvailableModel);\n this.model = model;\n this.logger = logger;\n if (clientOptions) {\n this.clientOptions = clientOptions;\n }\n }\n\n public getLanguageModel(): LanguageModelV2 {\n return this.model;\n }\n\n async createChatCompletion<T = ChatCompletion>({\n options,\n }: CreateChatCompletionOptions): Promise<T> {\n this.logger?.({\n category: \"aisdk\",\n message: \"creating chat completion\",\n level: 2,\n auxiliary: {\n options: {\n value: JSON.stringify({\n ...options,\n image: undefined,\n messages: options.messages.map((msg) => ({\n ...msg,\n content: Array.isArray(msg.content)\n ? msg.content.map((c) =>\n \"image_url\" in c\n ? { ...c, image_url: { url: \"[IMAGE_REDACTED]\" } }\n : c,\n )\n : msg.content,\n })),\n }),\n type: \"object\",\n },\n modelName: {\n value: this.model.modelId,\n type: \"string\",\n },\n },\n });\n\n const formattedMessages: ModelMessage[] = options.messages.map(\n (message) => {\n if (Array.isArray(message.content)) {\n if (message.role === \"system\") {\n const systemMessage: CoreSystemMessage = {\n role: \"system\",\n content: message.content\n .map((c) => (\"text\" in c ? c.text : \"\"))\n .join(\"\\n\"),\n };\n return systemMessage;\n }\n\n const contentParts = message.content.map((content) => {\n if (\"image_url\" in content) {\n const imageContent: ImagePart = {\n type: \"image\",\n image: content.image_url.url,\n };\n return imageContent;\n } else {\n const textContent: TextPart = {\n type: \"text\",\n text: content.text,\n };\n return textContent;\n }\n });\n\n if (message.role === \"user\") {\n const userMessage: CoreUserMessage = {\n role: \"user\",\n content: contentParts,\n };\n return userMessage;\n } else {\n const textOnlyParts = contentParts.map((part) => ({\n type: \"text\" as const,\n text: part.type === \"image\" ? \"[Image]\" : part.text,\n }));\n const assistantMessage: CoreAssistantMessage = {\n role: \"assistant\",\n content: textOnlyParts,\n };\n return assistantMessage;\n }\n }\n\n return {\n role: message.role,\n content: message.content,\n };\n },\n );\n\n let objectResponse: Awaited<ReturnType<typeof generateObject>>;\n const isGPT5 = this.model.modelId.includes(\"gpt-5\");\n const isCodex = this.model.modelId.includes(\"codex\");\n const isOpus47 =\n this.model.modelId === \"anthropic/claude-opus-4-7\" ||\n this.model.modelId === \"claude-opus-4-7\";\n // Kimi models only support temperature=1\n const isKimi = this.model.modelId.includes(\"kimi\");\n const temperature = isKimi ? 1 : isOpus47 ? undefined : options.temperature;\n\n // Resolve reasoning effort: user-configured > default \"none\" for GPT-5.x sub-models\n const isGPT5SubModel = this.model.modelId.includes(\"gpt-5.\") && !isCodex;\n const userReasoningEffort = this.clientOptions?.reasoningEffort;\n const resolvedReasoningEffort =\n userReasoningEffort ?? (isGPT5SubModel ? \"none\" : undefined);\n const providerName = inferProviderName(this.model.modelId);\n\n // Models that lack native structured-output support need a prompt-based\n // JSON fallback instead of response_format: { type: \"json_schema\" }.\n const PROMPT_JSON_FALLBACK_PATTERNS = [\"deepseek\", \"kimi\", \"glm\"];\n const needsPromptJsonFallback = PROMPT_JSON_FALLBACK_PATTERNS.some((p) =>\n this.model.modelId.includes(p),\n );\n\n const providerOptions: Record<string, ProviderOptionMap> = {};\n switch (providerName) {\n case \"openai\":\n providerOptions.openai = {\n strictJsonSchema: true,\n ...(isGPT5 ? { textVerbosity: isCodex ? \"medium\" : \"low\" } : {}),\n ...(resolvedReasoningEffort\n ? { reasoningEffort: resolvedReasoningEffort }\n : {}),\n };\n break;\n case \"azure\":\n providerOptions.azure = {\n strictJsonSchema: true,\n };\n break;\n case \"google\":\n providerOptions.google = {\n structuredOutputs: true,\n };\n break;\n case \"vertex\":\n providerOptions.vertex = {\n structuredOutputs: true,\n };\n break;\n case \"anthropic\":\n providerOptions.anthropic = {\n structuredOutputMode: \"auto\",\n };\n break;\n case \"groq\":\n providerOptions.groq = {\n structuredOutputs: true,\n };\n break;\n case \"cerebras\":\n providerOptions.cerebras = {\n strictJsonSchema: true,\n };\n break;\n case \"mistral\":\n providerOptions.mistral = {\n structuredOutputs: true,\n strictJsonSchema: true,\n };\n break;\n }\n\n if (options.response_model) {\n // Log LLM request for generateObject (extract)\n const llmRequestId = uuidv7();\n const promptSummary = extractLlmPromptSummary(options.messages, {\n hasSchema: true,\n });\n FlowLogger.logLlmRequest({\n requestId: llmRequestId,\n model: this.model.modelId,\n prompt: promptSummary,\n });\n\n // For models that don't support native structured outputs, add a prompt instruction\n if (needsPromptJsonFallback) {\n const parsedSchema = JSON.stringify(\n toJsonSchema(options.response_model.schema),\n );\n\n formattedMessages.push({\n role: \"user\",\n content: `Respond in this zod schema format:\\n${parsedSchema}\\n\nYou must respond in JSON format. respond WITH JSON. Do not include any other text, formatting or markdown in your output. Do not include \\`\\`\\` or \\`\\`\\`json in your response. Only the JSON object itself.`,\n });\n }\n\n try {\n objectResponse = await generateObject({\n model: this.model,\n messages: formattedMessages,\n schema: options.response_model.schema,\n temperature,\n ...(Object.keys(providerOptions).length > 0\n ? { providerOptions }\n : {}),\n });\n } catch (err) {\n // Log error response to maintain request/response pairing\n FlowLogger.logLlmResponse({\n requestId: llmRequestId,\n model: this.model.modelId,\n output: `[error: ${err instanceof Error ? err.message : \"unknown\"}]`,\n });\n\n if (NoObjectGeneratedError.isInstance(err)) {\n this.logger?.({\n category: \"AISDK error\",\n message: err.message,\n level: 0,\n auxiliary: {\n cause: {\n value: JSON.stringify(err.cause ?? {}),\n type: \"object\",\n },\n text: {\n value: err.text ?? \"\",\n type: \"string\",\n },\n response: {\n value: JSON.stringify(err.response ?? {}),\n type: \"object\",\n },\n usage: {\n value: JSON.stringify(err.usage ?? {}),\n type: \"object\",\n },\n finishReason: {\n value: err.finishReason ?? \"unknown\",\n type: \"string\",\n },\n requestId: {\n value: options.requestId,\n type: \"string\",\n },\n },\n });\n\n throw err;\n }\n throw err;\n }\n\n const result = {\n data: objectResponse.object,\n usage: {\n prompt_tokens: objectResponse.usage.inputTokens ?? 0,\n completion_tokens: objectResponse.usage.outputTokens ?? 0,\n reasoning_tokens: objectResponse.usage.reasoningTokens ?? 0,\n cached_input_tokens: objectResponse.usage.cachedInputTokens ?? 0,\n total_tokens: objectResponse.usage.totalTokens ?? 0,\n },\n } as T;\n\n // Log LLM response for generateObject\n FlowLogger.logLlmResponse({\n requestId: llmRequestId,\n model: this.model.modelId,\n output: JSON.stringify(objectResponse.object),\n inputTokens: objectResponse.usage.inputTokens,\n outputTokens: objectResponse.usage.outputTokens,\n });\n\n this.logger?.({\n category: \"aisdk\",\n message: \"response\",\n level: 1,\n auxiliary: {\n response: {\n value: JSON.stringify({\n object: objectResponse.object,\n usage: objectResponse.usage,\n finishReason: objectResponse.finishReason,\n // Omit request and response properties that might contain images\n }),\n type: \"object\",\n },\n requestId: {\n value: options.requestId,\n type: \"string\",\n },\n },\n });\n\n return result;\n }\n\n const tools: ToolSet = {};\n if (options.tools && options.tools.length > 0) {\n for (const tool of options.tools) {\n tools[tool.name] = {\n description: tool.description,\n inputSchema: tool.parameters,\n } as Tool;\n }\n }\n\n // Log LLM request for generateText (act/observe)\n const llmRequestId = uuidv7();\n const toolCount = Object.keys(tools).length;\n const promptSummary = extractLlmPromptSummary(options.messages, {\n toolCount,\n });\n FlowLogger.logLlmRequest({\n requestId: llmRequestId,\n model: this.model.modelId,\n prompt: promptSummary,\n });\n\n let textResponse: Awaited<ReturnType<typeof generateText>>;\n try {\n textResponse = await generateText({\n model: this.model,\n messages: formattedMessages,\n tools: Object.keys(tools).length > 0 ? tools : undefined,\n toolChoice:\n Object.keys(tools).length > 0\n ? options.tool_choice === \"required\"\n ? \"required\"\n : options.tool_choice === \"none\"\n ? \"none\"\n : \"auto\"\n : undefined,\n temperature,\n });\n } catch (err) {\n // Log error response to maintain request/response pairing\n FlowLogger.logLlmResponse({\n requestId: llmRequestId,\n model: this.model.modelId,\n output: `[error: ${err instanceof Error ? err.message : \"unknown\"}]`,\n });\n throw err;\n }\n\n // Transform AI SDK response to match LLMResponse format expected by operator handler\n const transformedToolCalls = (textResponse.toolCalls || []).map(\n (toolCall) => ({\n id:\n toolCall.toolCallId ||\n `call_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,\n type: \"function\",\n function: {\n name: toolCall.toolName,\n arguments: JSON.stringify(toolCall.input),\n },\n }),\n );\n\n const result = {\n id: `chatcmpl_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,\n object: \"chat.completion\",\n created: Math.floor(Date.now() / 1000),\n model: this.model.modelId,\n choices: [\n {\n index: 0,\n message: {\n role: \"assistant\",\n content: textResponse.text || null,\n tool_calls: transformedToolCalls,\n },\n finish_reason: textResponse.finishReason || \"stop\",\n },\n ],\n usage: {\n prompt_tokens: textResponse.usage.inputTokens ?? 0,\n completion_tokens: textResponse.usage.outputTokens ?? 0,\n reasoning_tokens: textResponse.usage.reasoningTokens ?? 0,\n cached_input_tokens: textResponse.usage.cachedInputTokens ?? 0,\n total_tokens: textResponse.usage.totalTokens ?? 0,\n },\n } as T;\n\n // Log LLM response for generateText\n FlowLogger.logLlmResponse({\n requestId: llmRequestId,\n model: this.model.modelId,\n output:\n textResponse.text ||\n (transformedToolCalls.length > 0\n ? `[${transformedToolCalls.length} tool calls]`\n : \"\"),\n inputTokens: textResponse.usage.inputTokens,\n outputTokens: textResponse.usage.outputTokens,\n });\n\n this.logger?.({\n category: \"aisdk\",\n message: \"response\",\n level: 2,\n auxiliary: {\n response: {\n value: JSON.stringify({\n text: textResponse.text,\n usage: textResponse.usage,\n finishReason: textResponse.finishReason,\n // Omit request and response properties that might contain images\n }),\n type: \"object\",\n },\n requestId: {\n value: options.requestId,\n type: \"string\",\n },\n },\n });\n\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"aisdk.js","sourceRoot":"","sources":["../../../../../lib/v3/llm/aisdk.ts"],"names":[],"mappings":";;;AAAA,2BAYY;AAGZ,+BAAoC;AAGpC,iDAAwE;AACxE,+DAGqC;AACrC,kDAA+C;AAK/C,SAAS,iBAAiB,CAAC,OAAe;IACxC,MAAM,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO,YAAY,IAAI,SAAS,CAAC;AACnC,CAAC;AAED,MAAa,WAAY,SAAQ,wBAAS;IACjC,IAAI,GAAG,OAAgB,CAAC;IACvB,KAAK,CAAkB;IACvB,MAAM,CAA8B;IAE5C,YAAY,EACV,KAAK,EACL,MAAM,EACN,aAAa,GAKd;QACC,KAAK,CAAC,KAAK,CAAC,OAAyB,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACrC,CAAC;IACH,CAAC;IAEM,gBAAgB;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAqB,EAC7C,OAAO,GACqB;QAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,0BAA0B;YACnC,KAAK,EAAE,CAAC;YACR,SAAS,EAAE;gBACT,OAAO,EAAE;oBACP,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;wBACpB,GAAG,OAAO;wBACV,KAAK,EAAE,SAAS;wBAChB,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,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;gBAC9D,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC;aAClD;SACG,CAAC;QAEP,oCAAoC;QACpC,0BAAU,CAAC,cAAc,CAAC;YACxB,SAAS,EAAE,YAAY;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YACzB,MAAM,EACJ,YAAY,CAAC,IAAI;gBACjB,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC;oBAC9B,CAAC,CAAC,IAAI,oBAAoB,CAAC,MAAM,cAAc;oBAC/C,CAAC,CAAC,EAAE,CAAC;YACT,WAAW,EAAE,YAAY,CAAC,KAAK,CAAC,WAAW;YAC3C,YAAY,EAAE,YAAY,CAAC,KAAK,CAAC,YAAY;SAC9C,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,UAAU;YACnB,KAAK,EAAE,CAAC;YACR,SAAS,EAAE;gBACT,QAAQ,EAAE;oBACR,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;wBACpB,IAAI,EAAE,YAAY,CAAC,IAAI;wBACvB,KAAK,EAAE,YAAY,CAAC,KAAK;wBACzB,YAAY,EAAE,YAAY,CAAC,YAAY;wBACvC,iEAAiE;qBAClE,CAAC;oBACF,IAAI,EAAE,QAAQ;iBACf;gBACD,SAAS,EAAE;oBACT,KAAK,EAAE,OAAO,CAAC,SAAS;oBACxB,IAAI,EAAE,QAAQ;iBACf;aACF;SACF,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA7aD,kCA6aC","sourcesContent":["import {\n CoreAssistantMessage,\n ModelMessage,\n CoreSystemMessage,\n CoreUserMessage,\n generateObject,\n generateText,\n ImagePart,\n NoObjectGeneratedError,\n TextPart,\n ToolSet,\n Tool,\n} from \"ai\";\nimport type { LanguageModelV2 } from \"@ai-sdk/provider\";\nimport { ChatCompletion } from \"openai/resources\";\nimport { v7 as uuidv7 } from \"uuid\";\nimport { LogLine } from \"../types/public/logs.js\";\nimport { AvailableModel, ClientOptions } from \"../types/public/model.js\";\nimport { CreateChatCompletionOptions, LLMClient } from \"./LLMClient.js\";\nimport {\n FlowLogger,\n extractLlmPromptSummary,\n} from \"../flowlogger/FlowLogger.js\";\nimport { toJsonSchema } from \"../zodCompat.js\";\n\ntype ProviderOptionValue = string | number | boolean | null;\ntype ProviderOptionMap = Record<string, ProviderOptionValue>;\n\nfunction inferProviderName(modelId: string): string | undefined {\n const [providerName] = modelId.split(\"/\");\n return providerName || undefined;\n}\n\nexport class AISdkClient extends LLMClient {\n public type = \"aisdk\" as const;\n private model: LanguageModelV2;\n private logger?: (message: LogLine) => void;\n\n constructor({\n model,\n logger,\n clientOptions,\n }: {\n model: LanguageModelV2;\n logger?: (message: LogLine) => void;\n clientOptions?: ClientOptions;\n }) {\n super(model.modelId as AvailableModel);\n this.model = model;\n this.logger = logger;\n if (clientOptions) {\n this.clientOptions = clientOptions;\n }\n }\n\n public getLanguageModel(): LanguageModelV2 {\n return this.model;\n }\n\n async createChatCompletion<T = ChatCompletion>({\n options,\n }: CreateChatCompletionOptions): Promise<T> {\n this.logger?.({\n category: \"aisdk\",\n message: \"creating chat completion\",\n level: 2,\n auxiliary: {\n options: {\n value: JSON.stringify({\n ...options,\n image: undefined,\n messages: options.messages.map((msg) => ({\n ...msg,\n content: Array.isArray(msg.content)\n ? msg.content.map((c) =>\n \"image_url\" in c\n ? { ...c, image_url: { url: \"[IMAGE_REDACTED]\" } }\n : c,\n )\n : msg.content,\n })),\n }),\n type: \"object\",\n },\n modelName: {\n value: this.model.modelId,\n type: \"string\",\n },\n },\n });\n\n const formattedMessages: ModelMessage[] = options.messages.map(\n (message) => {\n if (Array.isArray(message.content)) {\n if (message.role === \"system\") {\n const systemMessage: CoreSystemMessage = {\n role: \"system\",\n content: message.content\n .map((c) => (\"text\" in c ? c.text : \"\"))\n .join(\"\\n\"),\n };\n return systemMessage;\n }\n\n const contentParts = message.content.map((content) => {\n if (\"image_url\" in content) {\n const imageContent: ImagePart = {\n type: \"image\",\n image: content.image_url.url,\n };\n return imageContent;\n } else {\n const textContent: TextPart = {\n type: \"text\",\n text: content.text,\n };\n return textContent;\n }\n });\n\n if (message.role === \"user\") {\n const userMessage: CoreUserMessage = {\n role: \"user\",\n content: contentParts,\n };\n return userMessage;\n } else {\n const textOnlyParts = contentParts.map((part) => ({\n type: \"text\" as const,\n text: part.type === \"image\" ? \"[Image]\" : part.text,\n }));\n const assistantMessage: CoreAssistantMessage = {\n role: \"assistant\",\n content: textOnlyParts,\n };\n return assistantMessage;\n }\n }\n\n return {\n role: message.role,\n content: message.content,\n };\n },\n );\n\n let objectResponse: Awaited<ReturnType<typeof generateObject>>;\n const isGPT5 = this.model.modelId.includes(\"gpt-5\");\n const isCodex = this.model.modelId.includes(\"codex\");\n const isOpus47 =\n this.model.modelId === \"anthropic/claude-opus-4-7\" ||\n this.model.modelId === \"claude-opus-4-7\";\n // Kimi models only support temperature=1\n const isKimi = this.model.modelId.includes(\"kimi\");\n const temperature = isKimi ? 1 : isOpus47 ? undefined : options.temperature;\n\n // Resolve reasoning effort: user-configured > default \"none\" for GPT-5.x sub-models\n const isGPT5SubModel = this.model.modelId.includes(\"gpt-5.\") && !isCodex;\n const userReasoningEffort = this.clientOptions?.reasoningEffort;\n const resolvedReasoningEffort =\n userReasoningEffort ?? (isGPT5SubModel ? \"none\" : undefined);\n const providerName = inferProviderName(this.model.modelId);\n\n // Models that lack native structured-output support need a prompt-based\n // JSON fallback instead of response_format: { type: \"json_schema\" }.\n const PROMPT_JSON_FALLBACK_PATTERNS = [\"deepseek\", \"kimi\", \"glm\"];\n const needsPromptJsonFallback = PROMPT_JSON_FALLBACK_PATTERNS.some((p) =>\n this.model.modelId.includes(p),\n );\n\n const providerOptions: Record<string, ProviderOptionMap> = {};\n switch (providerName) {\n case \"openai\":\n providerOptions.openai = {\n strictJsonSchema: true,\n ...(isGPT5 ? { textVerbosity: isCodex ? \"medium\" : \"low\" } : {}),\n ...(resolvedReasoningEffort\n ? { reasoningEffort: resolvedReasoningEffort }\n : {}),\n };\n break;\n case \"azure\":\n providerOptions.azure = {\n strictJsonSchema: true,\n };\n break;\n case \"google\":\n providerOptions.google = {\n structuredOutputs: true,\n };\n break;\n case \"vertex\":\n providerOptions.vertex = {\n structuredOutputs: true,\n };\n break;\n case \"groq\":\n providerOptions.groq = {\n structuredOutputs: true,\n };\n break;\n case \"cerebras\":\n providerOptions.cerebras = {\n strictJsonSchema: true,\n };\n break;\n case \"mistral\":\n providerOptions.mistral = {\n structuredOutputs: true,\n strictJsonSchema: true,\n };\n break;\n }\n\n if (options.response_model) {\n // Log LLM request for generateObject (extract)\n const llmRequestId = uuidv7();\n const promptSummary = extractLlmPromptSummary(options.messages, {\n hasSchema: true,\n });\n FlowLogger.logLlmRequest({\n requestId: llmRequestId,\n model: this.model.modelId,\n prompt: promptSummary,\n });\n\n // For models that don't support native structured outputs, add a prompt instruction\n if (needsPromptJsonFallback) {\n const parsedSchema = JSON.stringify(\n toJsonSchema(options.response_model.schema),\n );\n\n formattedMessages.push({\n role: \"user\",\n content: `Respond in this zod schema format:\\n${parsedSchema}\\n\nYou must respond in JSON format. respond WITH JSON. Do not include any other text, formatting or markdown in your output. Do not include \\`\\`\\` or \\`\\`\\`json in your response. Only the JSON object itself.`,\n });\n }\n\n try {\n objectResponse = await generateObject({\n model: this.model,\n messages: formattedMessages,\n schema: options.response_model.schema,\n temperature,\n ...(Object.keys(providerOptions).length > 0\n ? { providerOptions }\n : {}),\n });\n } catch (err) {\n // Log error response to maintain request/response pairing\n FlowLogger.logLlmResponse({\n requestId: llmRequestId,\n model: this.model.modelId,\n output: `[error: ${err instanceof Error ? err.message : \"unknown\"}]`,\n });\n\n if (NoObjectGeneratedError.isInstance(err)) {\n this.logger?.({\n category: \"AISDK error\",\n message: err.message,\n level: 0,\n auxiliary: {\n cause: {\n value: JSON.stringify(err.cause ?? {}),\n type: \"object\",\n },\n text: {\n value: err.text ?? \"\",\n type: \"string\",\n },\n response: {\n value: JSON.stringify(err.response ?? {}),\n type: \"object\",\n },\n usage: {\n value: JSON.stringify(err.usage ?? {}),\n type: \"object\",\n },\n finishReason: {\n value: err.finishReason ?? \"unknown\",\n type: \"string\",\n },\n requestId: {\n value: options.requestId,\n type: \"string\",\n },\n },\n });\n\n throw err;\n }\n throw err;\n }\n\n const result = {\n data: objectResponse.object,\n usage: {\n prompt_tokens: objectResponse.usage.inputTokens ?? 0,\n completion_tokens: objectResponse.usage.outputTokens ?? 0,\n reasoning_tokens: objectResponse.usage.reasoningTokens ?? 0,\n cached_input_tokens: objectResponse.usage.cachedInputTokens ?? 0,\n total_tokens: objectResponse.usage.totalTokens ?? 0,\n },\n } as T;\n\n // Log LLM response for generateObject\n FlowLogger.logLlmResponse({\n requestId: llmRequestId,\n model: this.model.modelId,\n output: JSON.stringify(objectResponse.object),\n inputTokens: objectResponse.usage.inputTokens,\n outputTokens: objectResponse.usage.outputTokens,\n });\n\n this.logger?.({\n category: \"aisdk\",\n message: \"response\",\n level: 1,\n auxiliary: {\n response: {\n value: JSON.stringify({\n object: objectResponse.object,\n usage: objectResponse.usage,\n finishReason: objectResponse.finishReason,\n // Omit request and response properties that might contain images\n }),\n type: \"object\",\n },\n requestId: {\n value: options.requestId,\n type: \"string\",\n },\n },\n });\n\n return result;\n }\n\n const tools: ToolSet = {};\n if (options.tools && options.tools.length > 0) {\n for (const tool of options.tools) {\n tools[tool.name] = {\n description: tool.description,\n inputSchema: tool.parameters,\n } as Tool;\n }\n }\n\n // Log LLM request for generateText (act/observe)\n const llmRequestId = uuidv7();\n const toolCount = Object.keys(tools).length;\n const promptSummary = extractLlmPromptSummary(options.messages, {\n toolCount,\n });\n FlowLogger.logLlmRequest({\n requestId: llmRequestId,\n model: this.model.modelId,\n prompt: promptSummary,\n });\n\n let textResponse: Awaited<ReturnType<typeof generateText>>;\n try {\n textResponse = await generateText({\n model: this.model,\n messages: formattedMessages,\n tools: Object.keys(tools).length > 0 ? tools : undefined,\n toolChoice:\n Object.keys(tools).length > 0\n ? options.tool_choice === \"required\"\n ? \"required\"\n : options.tool_choice === \"none\"\n ? \"none\"\n : \"auto\"\n : undefined,\n temperature,\n });\n } catch (err) {\n // Log error response to maintain request/response pairing\n FlowLogger.logLlmResponse({\n requestId: llmRequestId,\n model: this.model.modelId,\n output: `[error: ${err instanceof Error ? err.message : \"unknown\"}]`,\n });\n throw err;\n }\n\n // Transform AI SDK response to match LLMResponse format expected by operator handler\n const transformedToolCalls = (textResponse.toolCalls || []).map(\n (toolCall) => ({\n id:\n toolCall.toolCallId ||\n `call_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,\n type: \"function\",\n function: {\n name: toolCall.toolName,\n arguments: JSON.stringify(toolCall.input),\n },\n }),\n );\n\n const result = {\n id: `chatcmpl_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,\n object: \"chat.completion\",\n created: Math.floor(Date.now() / 1000),\n model: this.model.modelId,\n choices: [\n {\n index: 0,\n message: {\n role: \"assistant\",\n content: textResponse.text || null,\n tool_calls: transformedToolCalls,\n },\n finish_reason: textResponse.finishReason || \"stop\",\n },\n ],\n usage: {\n prompt_tokens: textResponse.usage.inputTokens ?? 0,\n completion_tokens: textResponse.usage.outputTokens ?? 0,\n reasoning_tokens: textResponse.usage.reasoningTokens ?? 0,\n cached_input_tokens: textResponse.usage.cachedInputTokens ?? 0,\n total_tokens: textResponse.usage.totalTokens ?? 0,\n },\n } as T;\n\n // Log LLM response for generateText\n FlowLogger.logLlmResponse({\n requestId: llmRequestId,\n model: this.model.modelId,\n output:\n textResponse.text ||\n (transformedToolCalls.length > 0\n ? `[${transformedToolCalls.length} tool calls]`\n : \"\"),\n inputTokens: textResponse.usage.inputTokens,\n outputTokens: textResponse.usage.outputTokens,\n });\n\n this.logger?.({\n category: \"aisdk\",\n message: \"response\",\n level: 2,\n auxiliary: {\n response: {\n value: JSON.stringify({\n text: textResponse.text,\n usage: textResponse.usage,\n finishReason: textResponse.finishReason,\n // Omit request and response properties that might contain images\n }),\n type: \"object\",\n },\n requestId: {\n value: options.requestId,\n type: \"string\",\n },\n },\n });\n\n return result;\n }\n}\n"]}
@@ -37,10 +37,6 @@ function createModel(modelId) {
37
37
  ["azure/gpt-4.1", { azure: { strictJsonSchema: true } }],
38
38
  ["google/gemini-2.5-pro", { google: { structuredOutputs: true } }],
39
39
  ["vertex/gemini-2.5-pro", { vertex: { structuredOutputs: true } }],
40
- [
41
- "anthropic/claude-sonnet-4-20250514",
42
- { anthropic: { structuredOutputMode: "auto" } },
43
- ],
44
40
  ["groq/llama-3.3-70b-versatile", { groq: { structuredOutputs: true } }],
45
41
  ["cerebras/llama-4-scout", { cerebras: { strictJsonSchema: true } }],
46
42
  [
@@ -1 +1 @@
1
- {"version":3,"file":"aisdk-clients.test.js","sourceRoot":"","sources":["../../../../tests/unit/aisdk-clients.test.ts"],"names":[],"mappings":";;AACA,2BAAoC;AACpC,6BAAwB;AACxB,mCAA8D;AAC9D,wDAAwD;AAExD,WAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,MAAM,GAAG,MAAM,WAAE,CAAC,YAAY,CAAsB,IAAI,CAAC,CAAC;IAChE,OAAO;QACL,GAAG,MAAM;QACT,cAAc,EAAE,WAAE,CAAC,EAAE,EAAE;KACxB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,WAAE,CAAC,MAAM,CAAC,mBAAc,CAAC,CAAC;AAErD,SAAS,WAAW,CAAC,OAAe;IAClC,OAAO;QACL,OAAO;QACP,oBAAoB,EAAE,IAAI;KACG,CAAC;AAClC,CAAC;AAED,IAAA,iBAAQ,EAAC,gDAAgD,EAAE,GAAG,EAAE;IAC9D,IAAA,mBAAU,EAAC,GAAG,EAAE;QACd,kBAAkB,CAAC,SAAS,EAAE,CAAC;QAC/B,kBAAkB,CAAC,iBAAiB,CAAC;YACnC,MAAM,EAAE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,CAAC","sourcesContent":["import type { LanguageModelV2 } from \"@ai-sdk/provider\";\nimport { generateObject } from \"ai\";\nimport { z } from \"zod\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { AISdkClient } from \"../../lib/v3/llm/aisdk.js\";\n\nvi.mock(\"ai\", async () => {\n const actual = await vi.importActual<typeof import(\"ai\")>(\"ai\");\n return {\n ...actual,\n generateObject: vi.fn(),\n };\n});\n\nconst mockGenerateObject = vi.mocked(generateObject);\n\nfunction createModel(modelId: string) {\n return {\n modelId,\n specificationVersion: \"v2\",\n } as unknown as LanguageModelV2;\n}\n\ndescribe(\"AISdkClient structured output provider options\", () => {\n beforeEach(() => {\n mockGenerateObject.mockReset();\n mockGenerateObject.mockResolvedValue({\n object: { ok: true },\n usage: {\n inputTokens: 1,\n outputTokens: 2,\n reasoningTokens: 0,\n cachedInputTokens: 0,\n totalTokens: 3,\n },\n } as never);\n });\n\n it.each([\n [\"openai/gpt-4.1\", { openai: { strictJsonSchema: true } }],\n [\"azure/gpt-4.1\", { azure: { strictJsonSchema: true } }],\n [\"google/gemini-2.5-pro\", { google: { structuredOutputs: true } }],\n [\"vertex/gemini-2.5-pro\", { vertex: { structuredOutputs: true } }],\n [\n \"anthropic/claude-sonnet-4-20250514\",\n { anthropic: { structuredOutputMode: \"auto\" } },\n ],\n [\"groq/llama-3.3-70b-versatile\", { groq: { structuredOutputs: true } }],\n [\"cerebras/llama-4-scout\", { cerebras: { strictJsonSchema: true } }],\n [\n \"mistral/mistral-large-latest\",\n { mistral: { structuredOutputs: true, strictJsonSchema: true } },\n ],\n ])(\n \"passes provider structured-output options for %s\",\n async (modelId, providerOptions) => {\n const client = new AISdkClient({\n model: createModel(modelId),\n logger: vi.fn(),\n });\n\n await client.createChatCompletion({\n options: {\n messages: [{ role: \"user\", content: \"hello\" }],\n response_model: {\n name: \"test\",\n schema: z.object({ ok: z.boolean() }),\n },\n },\n logger: vi.fn(),\n });\n\n expect(mockGenerateObject).toHaveBeenCalledWith(\n expect.objectContaining({\n providerOptions,\n }),\n );\n },\n );\n\n it(\"omits temperature for claude-opus-4-7 structured calls\", async () => {\n const client = new AISdkClient({\n model: createModel(\"anthropic/claude-opus-4-7\"),\n logger: vi.fn(),\n });\n\n await client.createChatCompletion({\n options: {\n messages: [{ role: \"user\", content: \"hello\" }],\n response_model: {\n name: \"test\",\n schema: z.object({ ok: z.boolean() }),\n },\n temperature: 0.1,\n },\n logger: vi.fn(),\n });\n\n expect(mockGenerateObject).toHaveBeenCalledWith(\n expect.objectContaining({\n temperature: undefined,\n }),\n );\n });\n});\n"]}
1
+ {"version":3,"file":"aisdk-clients.test.js","sourceRoot":"","sources":["../../../../tests/unit/aisdk-clients.test.ts"],"names":[],"mappings":";;AACA,2BAAoC;AACpC,6BAAwB;AACxB,mCAA8D;AAC9D,wDAAwD;AAExD,WAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,MAAM,GAAG,MAAM,WAAE,CAAC,YAAY,CAAsB,IAAI,CAAC,CAAC;IAChE,OAAO;QACL,GAAG,MAAM;QACT,cAAc,EAAE,WAAE,CAAC,EAAE,EAAE;KACxB,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,WAAE,CAAC,MAAM,CAAC,mBAAc,CAAC,CAAC;AAErD,SAAS,WAAW,CAAC,OAAe;IAClC,OAAO;QACL,OAAO;QACP,oBAAoB,EAAE,IAAI;KACG,CAAC;AAClC,CAAC;AAED,IAAA,iBAAQ,EAAC,gDAAgD,EAAE,GAAG,EAAE;IAC9D,IAAA,mBAAU,EAAC,GAAG,EAAE;QACd,kBAAkB,CAAC,SAAS,EAAE,CAAC;QAC/B,kBAAkB,CAAC,iBAAiB,CAAC;YACnC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE;YACpB,KAAK,EAAE;gBACL,WAAW,EAAE,CAAC;gBACd,YAAY,EAAE,CAAC;gBACf,eAAe,EAAE,CAAC;g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AAE,EAAE,OAAC,CAAC,OAAO,EAAE,EAAE,CAAC;iBACtC;aACF;YACD,MAAM,EAAE,WAAE,CAAC,EAAE,EAAE;SAChB,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAC,oBAAoB,CAC7C,eAAM,CAAC,gBAAgB,CAAC;YACtB,eAAe;SAChB,CAAC,CACH,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,IAAA,WAAE,EAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,MAAM,GAAG,IAAI,sBAAW,CAAC;YAC7B,KAAK,EAAE,WAAW,CAAC,2BAA2B,CAAC;YAC/C,MAAM,EAAE,WAAE,CAAC,EAAE,EAAE;SAChB,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,oBAAoB,CAAC;YAChC,OAAO,EAAE;gBACP,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;gBAC9C,cAAc,EAAE;oBACd,IAAI,EAAE,MAAM;oBACZ,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,OAAC,CAAC,OAAO,EAAE,EAAE,CAAC;iBACtC;gBACD,WAAW,EAAE,GAAG;aACjB;YACD,MAAM,EAAE,WAAE,CAAC,EAAE,EAAE;SAChB,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAC,oBAAoB,CAC7C,eAAM,CAAC,gBAAgB,CAAC;YACtB,WAAW,EAAE,SAAS;SACvB,CAAC,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import type { LanguageModelV2 } from \"@ai-sdk/provider\";\nimport { generateObject } from \"ai\";\nimport { z } from \"zod\";\nimport { beforeEach, describe, expect, it, vi } from \"vitest\";\nimport { AISdkClient } from \"../../lib/v3/llm/aisdk.js\";\n\nvi.mock(\"ai\", async () => {\n const actual = await vi.importActual<typeof import(\"ai\")>(\"ai\");\n return {\n ...actual,\n generateObject: vi.fn(),\n };\n});\n\nconst mockGenerateObject = vi.mocked(generateObject);\n\nfunction createModel(modelId: string) {\n return {\n modelId,\n specificationVersion: \"v2\",\n } as unknown as LanguageModelV2;\n}\n\ndescribe(\"AISdkClient structured output provider options\", () => {\n beforeEach(() => {\n mockGenerateObject.mockReset();\n mockGenerateObject.mockResolvedValue({\n object: { ok: true },\n usage: {\n inputTokens: 1,\n outputTokens: 2,\n reasoningTokens: 0,\n cachedInputTokens: 0,\n totalTokens: 3,\n },\n } as never);\n });\n\n it.each([\n [\"openai/gpt-4.1\", { openai: { strictJsonSchema: true } }],\n [\"azure/gpt-4.1\", { azure: { strictJsonSchema: true } }],\n [\"google/gemini-2.5-pro\", { google: { structuredOutputs: true } }],\n [\"vertex/gemini-2.5-pro\", { vertex: { structuredOutputs: true } }],\n [\"groq/llama-3.3-70b-versatile\", { groq: { structuredOutputs: true } }],\n [\"cerebras/llama-4-scout\", { cerebras: { strictJsonSchema: true } }],\n [\n \"mistral/mistral-large-latest\",\n { mistral: { structuredOutputs: true, strictJsonSchema: true } },\n ],\n ])(\n \"passes provider structured-output options for %s\",\n async (modelId, providerOptions) => {\n const client = new AISdkClient({\n model: createModel(modelId),\n logger: vi.fn(),\n });\n\n await client.createChatCompletion({\n options: {\n messages: [{ role: \"user\", content: \"hello\" }],\n response_model: {\n name: \"test\",\n schema: z.object({ ok: z.boolean() }),\n },\n },\n logger: vi.fn(),\n });\n\n expect(mockGenerateObject).toHaveBeenCalledWith(\n expect.objectContaining({\n providerOptions,\n }),\n );\n },\n );\n\n it(\"omits temperature for claude-opus-4-7 structured calls\", async () => {\n const client = new AISdkClient({\n model: createModel(\"anthropic/claude-opus-4-7\"),\n logger: vi.fn(),\n });\n\n await client.createChatCompletion({\n options: {\n messages: [{ role: \"user\", content: \"hello\" }],\n response_model: {\n name: \"test\",\n schema: z.object({ ok: z.boolean() }),\n },\n temperature: 0.1,\n },\n logger: vi.fn(),\n });\n\n expect(mockGenerateObject).toHaveBeenCalledWith(\n expect.objectContaining({\n temperature: undefined,\n }),\n );\n });\n});\n"]}
@@ -259,7 +259,7 @@ export async function act({ instruction, domElements, llmClient, userProvidedIns
259
259
  })
260
260
  .nullable()
261
261
  .describe("The element to act on. Return null if no element on the page matches the instruction — do NOT fabricate or guess an element, and never emit empty strings or placeholder values."),
262
- twoStep: z.boolean().default(false),
262
+ twoStep: z.boolean(),
263
263
  });
264
264
  const messages = [
265
265
  buildActSystemPrompt(userProvidedInstructions),