shiplightai 0.1.85 → 0.1.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/debugger-pw.cjs +13 -13
- package/dist/cjs/fixture.cjs +1 -8
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/reporter.cjs +23 -23
- package/dist/cli.js +96 -69
- package/dist/debugger-pw.js +12 -12
- package/dist/fixture.js +1 -8
- package/dist/index.js +3 -3
- package/dist/reporter.js +23 -23
- package/package.json +1 -1
package/dist/cjs/debugger-pw.cjs
CHANGED
|
@@ -4082,28 +4082,28 @@ Based on the above information, please determine if the statement is true.
|
|
|
4082
4082
|
} : null,
|
|
4083
4083
|
clientRects: clientRectsArray
|
|
4084
4084
|
};
|
|
4085
|
-
}`,returnByValue:!0});s.value&&i.push({axNode:r,...s.value})}catch(s){w.debug(`Failed to resolve element: ${s}`)}}return i}async getElementsWithEventListeners(e,t=da){let i=[];try{let{root:n}=await e.send("DOM.getDocument",{depth:0}),a=ca.join(","),{nodeIds:o}=await e.send("DOM.querySelectorAll",{nodeId:n.nodeId,selector:a});w.debug(`\u{1F50D} Checking ${Math.min(o.length,t)} elements for event listeners`);for(let r of o.slice(0,t))try{let{object:l}=await e.send("DOM.resolveNode",{nodeId:r});if(!l.objectId)continue;let{listeners:s}=await e.send("DOMDebugger.getEventListeners",{objectId:l.objectId}),c=s.filter(d=>la.has(d.type));if(c.length>0){let{node:d}=await e.send("DOM.describeNode",{nodeId:r});i.push({backendNodeId:d.backendNodeId,eventTypes:c.map(u=>u.type)})}await e.send("Runtime.releaseObject",{objectId:l.objectId})}catch{}w.debug(`\u2705 Found ${i.length} elements with interaction event listeners`)}catch(n){w.warn("Failed to get elements with event listeners:",n)}return i}async buildDomStateFromAXTree(e){let t=new Map,i=new Ae("body","/body",{},[],!0,!1,!1,!1,!0,!0,!1,null),n=0;for(let a of e){let o=a.axNode.role?.value||"",r=a.axNode.name?.value||"",l=["button","link","menuitem","tab","switch"].includes(o),s=new Ae(a.tagName,a.xpath,a.attributes,[],a.isVisible,!0,o==="scrollbar",l,a.isTopElement,a.isInViewport,!1,n,a.boundingRect?{topLeft:{x:a.boundingRect.x,y:a.boundingRect.y},topRight:{x:a.boundingRect.x+a.boundingRect.width,y:a.boundingRect.y},bottomLeft:{x:a.boundingRect.x,y:a.boundingRect.y+a.boundingRect.height},bottomRight:{x:a.boundingRect.x+a.boundingRect.width,y:a.boundingRect.y+a.boundingRect.height},center:{x:a.boundingRect.x+a.boundingRect.width/2,y:a.boundingRect.y+a.boundingRect.height/2},width:a.boundingRect.width,height:a.boundingRect.height}:null,null,null,[],i);if(r){let c=new Ct(r,!0,s);s.children.push(c)}i.children.push(s),t.set(n,s),n++}return{domState:{elementTree:i,selectorMap:t},highlightIndex:n}}async renderHighlightsForAXElements(e,t){let i=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"];await e.evaluate(({elements:n,colors:a})=>{let o="playwright-highlight-container",r=document.getElementById(o);r||(r=document.createElement("div"),r.id=o,r.style.position="fixed",r.style.pointerEvents="none",r.style.top="0",r.style.left="0",r.style.width="100%",r.style.height="100%",r.style.zIndex="2147483647",r.style.backgroundColor="transparent",document.body.appendChild(r)),n.forEach((l,s)=>{if(!l.boundingRect)return;let c=a[s%a.length],d=l.boundingRect,u=document.createElement("div");u.style.position="fixed",u.style.border=`1px solid ${c}`,u.style.backgroundColor="transparent",u.style.pointerEvents="none",u.style.boxSizing="border-box",u.style.top=`${d.y}px`,u.style.left=`${d.x}px`,u.style.width=`${d.width}px`,u.style.height=`${d.height}px`,r.appendChild(u);let p=document.createElement("div");p.style.position="fixed",p.style.background=c,p.style.color="white",p.style.padding="1px 4px",p.style.borderRadius="4px",p.style.fontSize=s>=100?"8px":"12px",p.textContent=String(s);let h=Math.max(0,d.y-16),f=Math.max(0,Math.min(d.x+d.width-20,window.innerWidth-25));p.style.top=`${h}px`,p.style.left=`${f}px`,r.appendChild(p)})},{elements:t,colors:i})}async removeHighlights(e,t=[]){let i=()=>{let n=document.getElementById("playwright-highlight-container");n&&n.remove(),window._highlightCleanupFunctions&&(window._highlightCleanupFunctions.forEach(a=>a()),window._highlightCleanupFunctions=[])};try{await e.evaluate(i),w.debug("\u2705 Highlights removed from page")}catch(n){w.warn("Failed to remove highlights:",n.message)}for(let n of e.frames()){let a=n.url();if(!(!a.startsWith("chrome-extension://")&&!this.isConfiguredIframeFallbackDomain(a,t)))try{await n.evaluate(i)}catch{}}}async getCrossOriginIframes(e){let t=await e.locator("iframe").filter({hasNot:e.locator(":visible")}).evaluateAll(l=>l.map(s=>s.src)),i=l=>{try{let s=new URL(l);return["doubleclick.net","adroll.com","googletagmanager.com"].some(c=>s.hostname.includes(c))}catch{return!1}},n=e.url(),a=new URL(n).hostname,o=e.frames(),r=[];for(let l of o){let s=l.url();try{let c=new URL(s).hostname;c&&c!==a&&!t.includes(s)&&!i(s)&&r.push(s)}catch{continue}}return r}async buildDomTree(e,t,i,n,a,o,r,l,s="all"){if(await e.evaluate("1+1")!==2)throw new Error("The page cannot evaluate javascript code properly");if(Gc(e.url()))return[new Ae("body","",{},[],!1,!1,!1,!1,!1,!1,!1,null),new Map];let c={doHighlightElements:t,focusHighlightIndex:i,viewportExpansion:n,debugMode:!1,interactiveClassNames:a,alwaysHighlightFileInput:r,sameRectIoUThreshold:l,actionIntent:s,domTreeRoot:this.domTreeRoot};w.debug(`\u{1F527} Starting JavaScript DOM analysis for ${e.url().slice(0,50)}...`);let d,u=null;if(this.useDomTreeTs&&t)try{let y={...c,phase:"boxes",grayscaleImage:null},m=await e.evaluate(({code:N,argsObj:O})=>new Function("return "+N)()(O),{code:this.jsCode,argsObj:y});w.debug(`\u{1F4E6} Phase 1: Drew ${m.elementData?.length||0} bounding boxes`);let b=await e.screenshot({type:"png",fullPage:!1});w.debug("\u{1F4F8} Captured screenshot with bounding boxes");let v=performance.now(),S=await Uo(b);u=S.pixels;let T=Math.round(performance.now()-v);w.debug(`\u{1F5BC}\uFE0F Generated grayscale image (${S.width}x${S.height}) in ${T}ms`);let M={...c,phase:"labels",grayscaleImage:u,elementData:m.elementData};d=await e.evaluate(({code:N,argsObj:O})=>new Function("return "+N)()(O),{code:this.jsCode,argsObj:M}),d.map=m.map,d.rootId=m.rootId,d.highlightCount=m.highlightCount,d.perfMetrics=m.perfMetrics,w.debug("\u2705 Phase 2: Labels placed using grayscale-based positioning")}catch(y){w.warn("Two-phase rendering failed, falling back to legacy mode:",y.message),u=null;let m={...c,grayscaleImage:null};d=await e.evaluate(({code:b,argsObj:v})=>new Function("return "+b)()(v),{code:this.jsCode,argsObj:m}),w.debug("\u2705 JavaScript DOM analysis completed (legacy mode)")}else try{d=await e.evaluate(({code:y,argsObj:m})=>new Function("return "+y)()(m),{code:this.jsCode,argsObj:c}),w.debug("\u2705 JavaScript DOM analysis completed")}catch(y){throw w.error("Error evaluating JavaScript:",y.message),y}if(!d||typeof d!="object")throw w.error("JavaScript returned invalid result:",d),new Error("JavaScript DOM analysis returned invalid result");if(!d.map||!d.rootId)throw w.error("JavaScript result missing map or rootId:",JSON.stringify(d,null,2)),new Error("JavaScript result missing required fields (map or rootId)");if(s!=="all"&&d.highlightCount===0){w.debug(`\u26A0\uFE0F No elements matched intent '${s}', falling back to 'all'`);let y={...c,actionIntent:"all"};d=await e.evaluate(({code:m,argsObj:b})=>new Function("return "+m)()(b),{code:this.jsCode,argsObj:y})}let p=Object.entries(d.map).filter(([,y])=>y.tagName==="iframe");w.debug(`\u{1F50D} [ext-iframe] Total iframe nodes in map: ${p.length}`);for(let[y,m]of p){let b=m;w.debug(`\u{1F50D} [ext-iframe] iframe node id=${y} src=${b.attributes?.src} inaccessibleFrame=${b.inaccessibleFrame}`)}let h=e.frames();w.debug(`\u{1F50D} [ext-iframe] Playwright frames count: ${h.length}`);for(let y of h)w.debug(`\u{1F50D} [ext-iframe] Playwright frame url=${y.url()}`);let f=[];for(let[y,m]of Object.entries(d.map)){let b=m;this.shouldProcessWithPlaywrightFrameFallback(b,o)&&f.push({nodeId:y,src:b.attributes.src})}if(w.debug(`\u{1F50D} [ext-iframe] Inaccessible fallback iframes found: ${f.length}`),f.length>0){w.debug(`\u{1F50C} Found ${f.length} inaccessible iframe(s) for Playwright fallback, processing`);let y=-1;for(let m of Object.values(d.map)){let b=m;b.highlightIndex!=null&&(y=Math.max(y,b.highlightIndex))}w.debug(`\u{1F50D} [ext-iframe] Main page max highlight index: ${y}`);for(let m=0;m<f.length;m++){let{nodeId:b,src:v}=f[m];w.debug(`\u{1F50D} [ext-iframe] Processing fallback iframe [${m}]: ${v}`);let S=O=>{try{let D=new URL(O);if(D.protocol==="chrome-extension:"&&D.hostname)return`chrome-extension://${D.hostname}`;let ie=D.origin;return ie==="null"?null:ie}catch{return null}},T=S(v);w.debug(`\u{1F50D} [ext-iframe] iframe src origin=${T??"null"}`);let M=null,N=e.frames().find(O=>{let D=O.url();if(D===v)return M="exact",w.debug(`\u{1F50D} [ext-iframe] Candidate frame matched by exact URL: ${D}`),!0;let ie=S(D);return w.debug(`\u{1F50D} [ext-iframe] Candidate frame compare url=${D} origin=${ie??"null"} vs srcOrigin=${T??"null"}`),T&&ie===T?(M="origin",w.debug(`\u{1F50D} [ext-iframe] Candidate frame matched by origin: ${D}`),!0):!1});if(!N){w.debug(`\u26A0\uFE0F [ext-iframe] No Playwright frame found for fallback iframe: ${v}`),w.debug(`\u26A0\uFE0F [ext-iframe] Available frame URLs: ${e.frames().map(O=>O.url()).join(", ")}`);continue}w.debug(`\u{1F50D} [ext-iframe] Found matching Playwright frame for: ${v} (frame url: ${N.url()})`);try{let O={...c,initialHighlightIndex:y+1,domTreeRoot:"body"};w.debug(`\u{1F50D} [ext-iframe] Running dom-tree in extension frame with initialHighlightIndex=${O.initialHighlightIndex}`);let D=await N.evaluate(({code:K,argsObj:z})=>new Function("return "+K)()(z),{code:this.jsCode,argsObj:O});if(w.debug(`\u{1F50D} [ext-iframe] frameEval result: map size=${Object.keys(D?.map??{}).length} rootId=${D?.rootId}`),!D?.map||!D.rootId){w.debug("\u26A0\uFE0F [ext-iframe] frameEval missing map or rootId, skipping");continue}let ie=Object.values(D.map).filter(K=>K.highlightIndex!=null);w.debug(`\u{1F50D} [ext-iframe] Interactive elements in extension frame: ${ie.length}`);for(let K of ie){let z=K;w.debug(`\u{1F50D} [ext-iframe] - <${z.tagName}> highlightIndex=${z.highlightIndex} text="${z.children?.length?"...":""}"`)}for(let K of Object.values(D.map)){let z=K;z.highlightIndex!=null&&(y=Math.max(y,z.highlightIndex))}let J=`ext_${m}_`;for(let[K,z]of Object.entries(D.map)){let ke={...z};ke.children&&(ke.children=ke.children.map(Fe=>`${J}${Fe}`)),d.map[`${J}${K}`]=ke}let ae=d.map[b];ae?(ae.children=[...ae.children||[],`${J}${D.rootId}`],w.debug(`\u{1F50D} [ext-iframe] Attached frame root to iframe node ${b}`)):w.debug(`\u26A0\uFE0F [ext-iframe] iframe node ${b} not found in map`),w.debug(`\u2705 Merged fallback iframe content from: ${v}`)}catch(O){w.warn(`Failed to process fallback iframe ${v}:`,O)}}}if(d&&d.perfMetrics){let y=d.perfMetrics.nodeMetrics?.totalNodes??0,m=0;if(d.map)for(let v of Object.values(d.map))typeof v=="object"&&v!==null&&v.isInteractive&&m++;let b=e.url().length>50?e.url().slice(0,50)+"...":e.url();w.debug(`\u{1F50E} Ran buildDOMTree.js interactive element detection on: ${b} interactive=${m}/${y}`)}w.debug("\u{1F504} Starting TypeScript DOM tree construction...");let g=await this.constructDomTree(d);return w.debug("\u2705 TypeScript DOM tree construction completed"),g}async constructDomTree(e){let t=e.map,i=e.rootId,n=new Map,a=new Map,o=new Map;for(let[l,s]of Object.entries(t)){let[c,d]=this.parseNode(s);c!==null&&(a.set(l,c),o.set(l,d),c instanceof Ae&&c.highlightIndex!==null&&n.set(c.highlightIndex,c))}for(let[l,s]of o){let c=a.get(l);if(c instanceof Ae)for(let d of s){let u=a.get(d);u&&(u.parent=c,c.children.push(u))}}let r=a.get(i);if(!r||!(r instanceof Ae))throw new Error("Failed to parse HTML to dictionary");return[r,n]}parseNode(e){if(!e)return[null,[]];if(e.type==="TEXT_NODE")return[new Ct(e.text,e.isVisible,null),[]];let t=null;e.viewport&&(t={width:e.viewport.width,height:e.viewport.height,scrollX:e.viewport.scrollX,scrollY:e.viewport.scrollY});let i=e.shadowHostXPaths??[],n=new Ae(e.tagName,e.xpath,e.attributes||{},[],e.isVisible??!1,e.isInteractive??!1,e.isScrollable??!1,e.markAsClickable??!1,e.isTopElement??!1,e.isInViewport??!1,e.shadowRoot??!1,e.highlightIndex??null,e.viewportCoordinates??null,e.pageCoordinates??null,t,i,null),a=e.children||[];return[n,a]}}});var Vo,Xo,ap,Xi=x(()=>{"use strict";Vo=require("zod"),Xo=class{async execute(e,t){await e.waitForLoadState("networkidle",{timeout:5e3}).catch(()=>{}),await e.waitForLoadState("domcontentloaded")}transpile(e){return["await page.waitForLoadState('domcontentloaded');"]}},ap=Vo.z.object({})});var Yo,Yi=x(()=>{"use strict";j();I();Yo=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.keys;if(!a||typeof a!="string")throw new Error("Missing or invalid keys for send keys on element action");let o=R(e,t),r=L(i,t.action_data?.kwargs?.timeout_ms);if(o)await o.press(a,{timeout:r}),await e.waitForTimeout(500);else throw new Error("No locator found for send keys on element action")}transpile(e){let t=Ne(e);if(!t){let a=e.action_data?.kwargs?.keys||"";return['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(a)} } },`,"});"]}let i=e.action_data?.kwargs?.keys||"",n=L();return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${n} });`]}}});var Jo,Ji=x(()=>{"use strict";Jo=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.code;if(!a)throw new Error("Missing code for js_action");let o=i.agent;if(!o)throw new Error("Agent not initialized on AgentServices \u2014 js_action requires an agent reference");await new Function("page","agent",`
|
|
4085
|
+
}`,returnByValue:!0});s.value&&i.push({axNode:r,...s.value})}catch(s){w.debug(`Failed to resolve element: ${s}`)}}return i}async getElementsWithEventListeners(e,t=da){let i=[];try{let{root:n}=await e.send("DOM.getDocument",{depth:0}),a=ca.join(","),{nodeIds:o}=await e.send("DOM.querySelectorAll",{nodeId:n.nodeId,selector:a});w.debug(`\u{1F50D} Checking ${Math.min(o.length,t)} elements for event listeners`);for(let r of o.slice(0,t))try{let{object:l}=await e.send("DOM.resolveNode",{nodeId:r});if(!l.objectId)continue;let{listeners:s}=await e.send("DOMDebugger.getEventListeners",{objectId:l.objectId}),c=s.filter(d=>la.has(d.type));if(c.length>0){let{node:d}=await e.send("DOM.describeNode",{nodeId:r});i.push({backendNodeId:d.backendNodeId,eventTypes:c.map(u=>u.type)})}await e.send("Runtime.releaseObject",{objectId:l.objectId})}catch{}w.debug(`\u2705 Found ${i.length} elements with interaction event listeners`)}catch(n){w.warn("Failed to get elements with event listeners:",n)}return i}async buildDomStateFromAXTree(e){let t=new Map,i=new Ae("body","/body",{},[],!0,!1,!1,!1,!0,!0,!1,null),n=0;for(let a of e){let o=a.axNode.role?.value||"",r=a.axNode.name?.value||"",l=["button","link","menuitem","tab","switch"].includes(o),s=new Ae(a.tagName,a.xpath,a.attributes,[],a.isVisible,!0,o==="scrollbar",l,a.isTopElement,a.isInViewport,!1,n,a.boundingRect?{topLeft:{x:a.boundingRect.x,y:a.boundingRect.y},topRight:{x:a.boundingRect.x+a.boundingRect.width,y:a.boundingRect.y},bottomLeft:{x:a.boundingRect.x,y:a.boundingRect.y+a.boundingRect.height},bottomRight:{x:a.boundingRect.x+a.boundingRect.width,y:a.boundingRect.y+a.boundingRect.height},center:{x:a.boundingRect.x+a.boundingRect.width/2,y:a.boundingRect.y+a.boundingRect.height/2},width:a.boundingRect.width,height:a.boundingRect.height}:null,null,null,[],i);if(r){let c=new Ct(r,!0,s);s.children.push(c)}i.children.push(s),t.set(n,s),n++}return{domState:{elementTree:i,selectorMap:t},highlightIndex:n}}async renderHighlightsForAXElements(e,t){let i=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"];await e.evaluate(({elements:n,colors:a})=>{let o="playwright-highlight-container",r=document.getElementById(o);r||(r=document.createElement("div"),r.id=o,r.style.position="fixed",r.style.pointerEvents="none",r.style.top="0",r.style.left="0",r.style.width="100%",r.style.height="100%",r.style.zIndex="2147483647",r.style.backgroundColor="transparent",document.body.appendChild(r)),n.forEach((l,s)=>{if(!l.boundingRect)return;let c=a[s%a.length],d=l.boundingRect,u=document.createElement("div");u.style.position="fixed",u.style.border=`1px solid ${c}`,u.style.backgroundColor="transparent",u.style.pointerEvents="none",u.style.boxSizing="border-box",u.style.top=`${d.y}px`,u.style.left=`${d.x}px`,u.style.width=`${d.width}px`,u.style.height=`${d.height}px`,r.appendChild(u);let p=document.createElement("div");p.style.position="fixed",p.style.background=c,p.style.color="white",p.style.padding="1px 4px",p.style.borderRadius="4px",p.style.fontSize=s>=100?"8px":"12px",p.textContent=String(s);let h=Math.max(0,d.y-16),f=Math.max(0,Math.min(d.x+d.width-20,window.innerWidth-25));p.style.top=`${h}px`,p.style.left=`${f}px`,r.appendChild(p)})},{elements:t,colors:i})}async removeHighlights(e,t=[]){let i=()=>{let n=document.getElementById("playwright-highlight-container");n&&n.remove(),window._highlightCleanupFunctions&&(window._highlightCleanupFunctions.forEach(a=>a()),window._highlightCleanupFunctions=[])};try{await e.evaluate(i),w.debug("\u2705 Highlights removed from page")}catch(n){w.warn("Failed to remove highlights:",n.message)}for(let n of e.frames()){let a=n.url();if(!(!a.startsWith("chrome-extension://")&&!this.isConfiguredIframeFallbackDomain(a,t)))try{await n.evaluate(i)}catch{}}}async getCrossOriginIframes(e){let t=await e.locator("iframe").filter({hasNot:e.locator(":visible")}).evaluateAll(l=>l.map(s=>s.src)),i=l=>{try{let s=new URL(l);return["doubleclick.net","adroll.com","googletagmanager.com"].some(c=>s.hostname.includes(c))}catch{return!1}},n=e.url(),a=new URL(n).hostname,o=e.frames(),r=[];for(let l of o){let s=l.url();try{let c=new URL(s).hostname;c&&c!==a&&!t.includes(s)&&!i(s)&&r.push(s)}catch{continue}}return r}async buildDomTree(e,t,i,n,a,o,r,l,s="all"){if(await e.evaluate("1+1")!==2)throw new Error("The page cannot evaluate javascript code properly");if(Gc(e.url()))return[new Ae("body","",{},[],!1,!1,!1,!1,!1,!1,!1,null),new Map];let c={doHighlightElements:t,focusHighlightIndex:i,viewportExpansion:n,debugMode:!1,interactiveClassNames:a,alwaysHighlightFileInput:r,sameRectIoUThreshold:l,actionIntent:s,domTreeRoot:this.domTreeRoot};w.debug(`\u{1F527} Starting JavaScript DOM analysis for ${e.url().slice(0,50)}...`);let d,u=null;if(this.useDomTreeTs&&t)try{let y={...c,phase:"boxes",grayscaleImage:null},m=await e.evaluate(({code:N,argsObj:O})=>new Function("return "+N)()(O),{code:this.jsCode,argsObj:y});w.debug(`\u{1F4E6} Phase 1: Drew ${m.elementData?.length||0} bounding boxes`);let b=await e.screenshot({type:"png",fullPage:!1});w.debug("\u{1F4F8} Captured screenshot with bounding boxes");let v=performance.now(),S=await Uo(b);u=S.pixels;let T=Math.round(performance.now()-v);w.debug(`\u{1F5BC}\uFE0F Generated grayscale image (${S.width}x${S.height}) in ${T}ms`);let M={...c,phase:"labels",grayscaleImage:u,elementData:m.elementData};d=await e.evaluate(({code:N,argsObj:O})=>new Function("return "+N)()(O),{code:this.jsCode,argsObj:M}),d.map=m.map,d.rootId=m.rootId,d.highlightCount=m.highlightCount,d.perfMetrics=m.perfMetrics,w.debug("\u2705 Phase 2: Labels placed using grayscale-based positioning")}catch(y){w.warn("Two-phase rendering failed, falling back to legacy mode:",y.message),u=null;let m={...c,grayscaleImage:null};d=await e.evaluate(({code:b,argsObj:v})=>new Function("return "+b)()(v),{code:this.jsCode,argsObj:m}),w.debug("\u2705 JavaScript DOM analysis completed (legacy mode)")}else try{d=await e.evaluate(({code:y,argsObj:m})=>new Function("return "+y)()(m),{code:this.jsCode,argsObj:c}),w.debug("\u2705 JavaScript DOM analysis completed")}catch(y){throw w.error("Error evaluating JavaScript:",y.message),y}if(!d||typeof d!="object")throw w.error("JavaScript returned invalid result:",d),new Error("JavaScript DOM analysis returned invalid result");if(!d.map||!d.rootId)throw w.error("JavaScript result missing map or rootId:",JSON.stringify(d,null,2)),new Error("JavaScript result missing required fields (map or rootId)");if(s!=="all"&&d.highlightCount===0){w.debug(`\u26A0\uFE0F No elements matched intent '${s}', falling back to 'all'`);let y={...c,actionIntent:"all"};d=await e.evaluate(({code:m,argsObj:b})=>new Function("return "+m)()(b),{code:this.jsCode,argsObj:y})}let p=Object.entries(d.map).filter(([,y])=>y.tagName==="iframe");w.debug(`\u{1F50D} [ext-iframe] Total iframe nodes in map: ${p.length}`);for(let[y,m]of p){let b=m;w.debug(`\u{1F50D} [ext-iframe] iframe node id=${y} src=${b.attributes?.src} inaccessibleFrame=${b.inaccessibleFrame}`)}let h=e.frames();w.debug(`\u{1F50D} [ext-iframe] Playwright frames count: ${h.length}`);for(let y of h)w.debug(`\u{1F50D} [ext-iframe] Playwright frame url=${y.url()}`);let f=[];for(let[y,m]of Object.entries(d.map)){let b=m;this.shouldProcessWithPlaywrightFrameFallback(b,o)&&f.push({nodeId:y,src:b.attributes.src})}if(w.debug(`\u{1F50D} [ext-iframe] Inaccessible fallback iframes found: ${f.length}`),f.length>0){w.debug(`\u{1F50C} Found ${f.length} inaccessible iframe(s) for Playwright fallback, processing`);let y=-1;for(let m of Object.values(d.map)){let b=m;b.highlightIndex!=null&&(y=Math.max(y,b.highlightIndex))}w.debug(`\u{1F50D} [ext-iframe] Main page max highlight index: ${y}`);for(let m=0;m<f.length;m++){let{nodeId:b,src:v}=f[m];w.debug(`\u{1F50D} [ext-iframe] Processing fallback iframe [${m}]: ${v}`);let S=O=>{try{let D=new URL(O);if(D.protocol==="chrome-extension:"&&D.hostname)return`chrome-extension://${D.hostname}`;let ie=D.origin;return ie==="null"?null:ie}catch{return null}},T=S(v);w.debug(`\u{1F50D} [ext-iframe] iframe src origin=${T??"null"}`);let M=null,N=e.frames().find(O=>{let D=O.url();if(D===v)return M="exact",w.debug(`\u{1F50D} [ext-iframe] Candidate frame matched by exact URL: ${D}`),!0;let ie=S(D);return w.debug(`\u{1F50D} [ext-iframe] Candidate frame compare url=${D} origin=${ie??"null"} vs srcOrigin=${T??"null"}`),T&&ie===T?(M="origin",w.debug(`\u{1F50D} [ext-iframe] Candidate frame matched by origin: ${D}`),!0):!1});if(!N){w.debug(`\u26A0\uFE0F [ext-iframe] No Playwright frame found for fallback iframe: ${v}`),w.debug(`\u26A0\uFE0F [ext-iframe] Available frame URLs: ${e.frames().map(O=>O.url()).join(", ")}`);continue}w.debug(`\u{1F50D} [ext-iframe] Found matching Playwright frame for: ${v} (frame url: ${N.url()})`);try{let O={...c,initialHighlightIndex:y+1,domTreeRoot:"body"};w.debug(`\u{1F50D} [ext-iframe] Running dom-tree in extension frame with initialHighlightIndex=${O.initialHighlightIndex}`);let D=await N.evaluate(({code:K,argsObj:z})=>new Function("return "+K)()(z),{code:this.jsCode,argsObj:O});if(w.debug(`\u{1F50D} [ext-iframe] frameEval result: map size=${Object.keys(D?.map??{}).length} rootId=${D?.rootId}`),!D?.map||!D.rootId){w.debug("\u26A0\uFE0F [ext-iframe] frameEval missing map or rootId, skipping");continue}let ie=Object.values(D.map).filter(K=>K.highlightIndex!=null);w.debug(`\u{1F50D} [ext-iframe] Interactive elements in extension frame: ${ie.length}`);for(let K of ie){let z=K;w.debug(`\u{1F50D} [ext-iframe] - <${z.tagName}> highlightIndex=${z.highlightIndex} text="${z.children?.length?"...":""}"`)}for(let K of Object.values(D.map)){let z=K;z.highlightIndex!=null&&(y=Math.max(y,z.highlightIndex))}let J=`ext_${m}_`;for(let[K,z]of Object.entries(D.map)){let ke={...z};ke.children&&(ke.children=ke.children.map(Fe=>`${J}${Fe}`)),d.map[`${J}${K}`]=ke}let ae=d.map[b];ae?(ae.children=[...ae.children||[],`${J}${D.rootId}`],w.debug(`\u{1F50D} [ext-iframe] Attached frame root to iframe node ${b}`)):w.debug(`\u26A0\uFE0F [ext-iframe] iframe node ${b} not found in map`),w.debug(`\u2705 Merged fallback iframe content from: ${v}`)}catch(O){w.warn(`Failed to process fallback iframe ${v}:`,O)}}}if(d&&d.perfMetrics){let y=d.perfMetrics.nodeMetrics?.totalNodes??0,m=0;if(d.map)for(let v of Object.values(d.map))typeof v=="object"&&v!==null&&v.isInteractive&&m++;let b=e.url().length>50?e.url().slice(0,50)+"...":e.url();w.debug(`\u{1F50E} Ran buildDOMTree.js interactive element detection on: ${b} interactive=${m}/${y}`)}w.debug("\u{1F504} Starting TypeScript DOM tree construction...");let g=await this.constructDomTree(d);return w.debug("\u2705 TypeScript DOM tree construction completed"),g}async constructDomTree(e){let t=e.map,i=e.rootId,n=new Map,a=new Map,o=new Map;for(let[l,s]of Object.entries(t)){let[c,d]=this.parseNode(s);c!==null&&(a.set(l,c),o.set(l,d),c instanceof Ae&&c.highlightIndex!==null&&n.set(c.highlightIndex,c))}for(let[l,s]of o){let c=a.get(l);if(c instanceof Ae)for(let d of s){let u=a.get(d);u&&(u.parent=c,c.children.push(u))}}let r=a.get(i);if(!r||!(r instanceof Ae))throw new Error("Failed to parse HTML to dictionary");return[r,n]}parseNode(e){if(!e)return[null,[]];if(e.type==="TEXT_NODE")return[new Ct(e.text,e.isVisible,null),[]];let t=null;e.viewport&&(t={width:e.viewport.width,height:e.viewport.height,scrollX:e.viewport.scrollX,scrollY:e.viewport.scrollY});let i=e.shadowHostXPaths??[],n=new Ae(e.tagName,e.xpath,e.attributes||{},[],e.isVisible??!1,e.isInteractive??!1,e.isScrollable??!1,e.markAsClickable??!1,e.isTopElement??!1,e.isInViewport??!1,e.shadowRoot??!1,e.highlightIndex??null,e.viewportCoordinates??null,e.pageCoordinates??null,t,i,null),a=e.children||[];return[n,a]}}});var Vo,Xo,op,Xi=x(()=>{"use strict";Vo=require("zod"),Xo=class{async execute(e,t){await e.waitForLoadState("networkidle",{timeout:5e3}).catch(()=>{}),await e.waitForLoadState("domcontentloaded")}transpile(e){return["await page.waitForLoadState('domcontentloaded');"]}},op=Vo.z.object({})});var Yo,Yi=x(()=>{"use strict";j();I();Yo=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.keys;if(!a||typeof a!="string")throw new Error("Missing or invalid keys for send keys on element action");let o=R(e,t),r=L(i,t.action_data?.kwargs?.timeout_ms);if(o)await o.press(a,{timeout:r}),await e.waitForTimeout(500);else throw new Error("No locator found for send keys on element action")}transpile(e){let t=Ne(e);if(!t){let a=e.action_data?.kwargs?.keys||"";return['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(a)} } },`,"});"]}let i=e.action_data?.kwargs?.keys||"",n=L();return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${n} });`]}}});var Jo,Ji=x(()=>{"use strict";Jo=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.code;if(!a)throw new Error("Missing code for js_action");let o=i.agent;if(!o)throw new Error("Agent not initialized on AgentServices \u2014 js_action requires an agent reference");await new Function("page","agent",`
|
|
4086
4086
|
return (async () => {
|
|
4087
4087
|
${a}
|
|
4088
4088
|
})();
|
|
4089
4089
|
`)(e,o)}transpile(e){let t=e.action_data?.kwargs?.code;return t?t.split(`
|
|
4090
|
-
`):["// Skipping js_action: missing code"]}}});var Kc,qo,at,Nt=x(()=>{"use strict";Se();Kc=Z(require("playwright/test"),1),qo=Z(require("playwright/test"),1),at={};Ci(at,{default:()=>qo.default});ho(at,Kc)});var ua,Zo,
|
|
4090
|
+
`):["// Skipping js_action: missing code"]}}});var Kc,qo,at,Nt=x(()=>{"use strict";Se();Kc=Z(require("playwright/test"),1),qo=Z(require("playwright/test"),1),at={};Ci(at,{default:()=>qo.default});ho(at,Kc)});var ua,Zo,fp,qi=x(()=>{"use strict";Nt();ua=require("zod"),Zo=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.code;if(!a)throw new Error("Missing code for js_code action");let o=i.agent;if(!o)throw new Error("Agent not initialized on AgentServices \u2014 js_code requires an agent reference");await new Function("page","expect","agent",`
|
|
4091
4091
|
return (async () => {
|
|
4092
4092
|
${a}
|
|
4093
4093
|
})();
|
|
4094
4094
|
`)(e,at.expect,o)}transpile(e){let t=e.action_data?.kwargs?.code;if(!t)return["// Skipping js_code: missing code"];let i=["{"],n=t.split(`
|
|
4095
|
-
`);for(let a of n)i.push(` ${a}`);return i.push("}"),i}},
|
|
4095
|
+
`);for(let a of n)i.push(` ${a}`);return i.push("}"),i}},fp=ua.z.object({code:ua.z.string().describe("JavaScript code to execute in the browser context")})});var Qo,Zi=x(()=>{"use strict";j();I();Qo=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");if(typeof n.kwargs.relative_x=="number"&&typeof n.kwargs.relative_y=="number"){let a=R(e,t);if(a){await a.waitFor({state:"attached",timeout:L(i,t.action_data?.kwargs?.timeout_ms)});let o=await a.boundingBox();if(o){let r=o.x+n.kwargs.relative_x+o.width/2,l=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.move(r,l),await e.waitForTimeout(200),await e.mouse.click(r,l,{button:"right",delay:100}),await e.waitForTimeout(200)}}else throw new Error("Element-anchored coordinates provided but no locator found")}else if(typeof n.kwargs.x=="number"&&typeof n.kwargs.y=="number")await e.mouse.move(n.kwargs.x,n.kwargs.y),await e.waitForTimeout(200),await e.mouse.click(n.kwargs.x,n.kwargs.y,{button:"right"}),await e.waitForTimeout(200);else throw new Error("Missing or invalid coordinates")}transpile(e){let t=e.action_data?.kwargs||{},i=[];return typeof t.relative_x=="number"&&typeof t.relative_y=="number"?(i.push(`action_data: { kwargs: { relative_x: ${t.relative_x}, relative_y: ${t.relative_y} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`)):typeof t.x=="number"&&typeof t.y=="number"&&i.push(`action_data: { kwargs: { x: ${t.x}, y: ${t.y} } }`),['await agent.execAction("right_click_by_coordinates", page, {',...i.map(n=>` ${n},`),"});"]}}});var er,Qi=x(()=>{"use strict";j();I();er=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");if(typeof n.kwargs.relative_x=="number"&&typeof n.kwargs.relative_y=="number"){let a=R(e,t);if(a){await a.waitFor({state:"attached",timeout:L(i,t.action_data?.kwargs?.timeout_ms)});let o=await a.boundingBox();if(o){let r=o.x+n.kwargs.relative_x+o.width/2,l=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.dblclick(r,l,{delay:50}),await e.waitForTimeout(200)}}else throw new Error("Element-anchored coordinates provided but no locator found")}else if(typeof n.kwargs.x=="number"&&typeof n.kwargs.y=="number")await e.mouse.dblclick(n.kwargs.x,n.kwargs.y),await e.waitForTimeout(200);else throw new Error("Missing or invalid coordinates")}transpile(e){let t=e.action_data?.kwargs||{},i=[];return typeof t.relative_x=="number"&&typeof t.relative_y=="number"?(i.push(`action_data: { kwargs: { relative_x: ${t.relative_x}, relative_y: ${t.relative_y} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`)):typeof t.x=="number"&&typeof t.y=="number"&&i.push(`action_data: { kwargs: { x: ${t.x}, y: ${t.y} } }`),['await agent.execAction("double_click_by_coordinates", page, {',...i.map(n=>` ${n},`),"});"]}}});var tr,en=x(()=>{"use strict";j();I();tr=class{async execute(e,t,i){let n=i.getActionSettings().drag_drop_steps??10,a=t.action_data;if(!a)throw new Error("Action data not found");let o=a.kwargs,r=[o.coord_source_x,o.coord_source_y],l=[o.coord_target_x,o.coord_target_y];if(typeof o.relative_x=="number"&&typeof o.relative_y=="number"&&typeof o.delta_x=="number"&&typeof o.delta_y=="number"){let s=R(e,t);if(!s)throw new Error("No locator found for drag_drop action with element-anchored coordinates");await s.waitFor({state:"attached",timeout:L(i,t.action_data?.kwargs?.timeout_ms)});let c=await(await s).boundingBox();if(!c)throw new Error("Could not get bounding box for drag_drop element");let d=c.x+o.relative_x+c.width/2,u=c.y+o.relative_y+c.height/2,p=d+o.delta_x,h=u+o.delta_y;await e.mouse.move(d,u),await e.mouse.down(),n>0?await e.mouse.move(p,h,{steps:n}):await e.mouse.move(p,h),await e.mouse.up()}else if(r.every(s=>typeof s=="number")&&l.every(s=>typeof s=="number")){let[s,c]=r,[d,u]=l;await e.mouse.move(s,c),await e.mouse.down(),n>0?await e.mouse.move(d,u,{steps:n}):await e.mouse.move(d,u),await e.mouse.up()}else throw new Error("Missing coordinates for drag_drop action: requires either element-anchored coordinates with delta, or full absolute coordinates");await e.waitForTimeout(500)}transpile(e){let t=e.action_data?.kwargs||{},i=[],n={};return typeof t.relative_x=="number"&&(n.relative_x=t.relative_x),typeof t.relative_y=="number"&&(n.relative_y=t.relative_y),typeof t.delta_x=="number"&&(n.delta_x=t.delta_x),typeof t.delta_y=="number"&&(n.delta_y=t.delta_y),typeof t.coord_source_x=="number"&&(n.coord_source_x=t.coord_source_x),typeof t.coord_source_y=="number"&&(n.coord_source_y=t.coord_source_y),typeof t.coord_target_x=="number"&&(n.coord_target_x=t.coord_target_x),typeof t.coord_target_y=="number"&&(n.coord_target_y=t.coord_target_y),i.push(`action_data: { kwargs: ${JSON.stringify(n)} }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("drag_drop", page, {',...i.map(a=>` ${a},`),"});"]}}});var ir,tn=x(()=>{"use strict";ir=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=this.generateFunctionCallCode(n.kwargs);if(!a)throw new Error("Missing function name for function action");let o=i.agent;if(!o)throw new Error("Agent not initialized on AgentServices \u2014 FunctionAction requires an agent reference");await new Function("page","agent",`
|
|
4096
4096
|
return (async () => {
|
|
4097
4097
|
${a}
|
|
4098
4098
|
})();
|
|
4099
|
-
`)(e,o)}transpile(e){let t=this.generateFunctionCallCode(e.action_data?.kwargs||{});return t?[t.endsWith(";")?t:`${t};`]:["// Skipping function: missing functionName"]}generateFunctionCallCode(e){let t=e.functionName;if(!t)return null;let i;if(Array.isArray(e.args))i=e.args.map(String);else if(Array.isArray(e.parameterNames)){let r=e.parameterValues||[];i=e.parameterNames.map((l,s)=>s<r.length?String(r[s]):"undefined")}else return`await ${t}()`;if(i.length===0)return`await ${t}()`;let n=["page","testContext","request","agent"],a=["undefined","null","true","false"],o=i.map(r=>n.includes(r)||a.includes(r)||/^-?\d+(\.\d+)?$/.test(r)?r:r.startsWith("$")?`agent.agentServices.readVariable('${r.substring(1)}')`:`"${r}"`);return`await ${t}(${o.join(", ")})`}}});var nn=x(()=>{"use strict";nt()});var nr,Ot=x(()=>{"use strict";nr=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.SILENT=4]="SILENT",e))(nr||{})});var ot={};Xe(ot,{evaluateStatement:()=>rn,executeAction:()=>Dt,executeStep:()=>on,generateActionStep:()=>an,runTask:()=>sn});var rt=x(()=>{"use strict";Lt();zi();Gi();Ii();et();Li();Pi();Hi();Je();Ui();Et();St();Te();bt();nn();Ue();$t();Mt();nt();It();Pt();re();tt();xe();_t();Ze();kt();Oe();qe();Y();He();U();oe();Ot();j();Se()});var ha,ar,pg,ln=x(()=>{"use strict";ha=require("zod"),ar=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.statement;if(!a)throw new Error("Missing statement for ai_step");let{runTask:o}=await Promise.resolve().then(()=>(rt(),ot)),r=await o(a,e,i);if(r.status!=="success")throw new Error(r.error||"Task execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;return i?[`await agent.run(page, ${JSON.stringify(i)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]}},pg=ha.z.object({statement:ha.z.string().describe('The complete step to execute (e.g., "fill in the login form and submit")')})});var or,cn=x(()=>{"use strict";j();I();or=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");if(typeof n.kwargs.relative_x=="number"&&typeof n.kwargs.relative_y=="number"){let a=R(e,t);if(a){await a.waitFor({state:"attached",timeout:L(i,t.action_data?.kwargs?.timeout_ms)});let o=await a.boundingBox();if(o){let r=o.x+n.kwargs.relative_x+o.width/2,l=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.move(r,l),await e.waitForTimeout(200),await e.mouse.click(r,l),await e.waitForTimeout(500)}}else throw new Error("Element-anchored coordinates provided but no locator found")}else if(typeof n.kwargs.x=="number"&&typeof n.kwargs.y=="number")await e.mouse.move(n.kwargs.x,n.kwargs.y),await e.waitForTimeout(200),await e.mouse.click(n.kwargs.x,n.kwargs.y),await e.waitForTimeout(500);else throw new Error("Missing or invalid coordinates")}transpile(e){let t=e.action_data?.kwargs||{},i=[];return typeof t.relative_x=="number"&&typeof t.relative_y=="number"?(i.push(`action_data: { kwargs: { relative_x: ${t.relative_x}, relative_y: ${t.relative_y} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`)):typeof t.x=="number"&&typeof t.y=="number"&&i.push(`action_data: { kwargs: { x: ${t.x}, y: ${t.y} } }`),['await agent.execAction("click_by_coordinates", page, {',...i.map(n=>` ${n},`),"});"]}}});var ma,rr,xg,dn=x(()=>{"use strict";ma=require("zod"),rr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.statement;if(!a)throw new Error("Missing statement for ai_action");let o=n.kwargs.use_pure_vision,{executeStep:r}=await Promise.resolve().then(()=>(rt(),ot)),l=await r(a,e,i,{usePureVision:o});if(l.status!=="success")throw new Error(l.error||"Action execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;if(!i)return["// Skipping ai_action: missing statement"];let n=JSON.stringify(i),a=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${n}, '${t||""}', ${a});`]}},xg=ma.z.object({statement:ma.z.string().describe('The action to perform (e.g., "click the submit button")')})});async function lr(e,t,i,n){let{useFileInput:a,timeout:o,mockShowOpenFilePicker:r}=n;if(r){w.info("Using mockShowOpenFilePicker approach");let l=i.map(s=>({path:s,buffer:new Uint8Array(sr.default.readFileSync(s))}));await e.evaluate(s=>{window.__pw_showOpenFilePicker_mock_files=s},l),await t.click({timeout:o}),await e.waitForTimeout(3e3),await e.evaluate(()=>{delete window.__pw_showOpenFilePicker_mock_files})}else if(a)w.info("Using direct file input approach"),await t.setInputFiles(i,{timeout:o}),await e.waitForTimeout(3e3);else{w.info("Using file chooser approach");let l=e.waitForEvent("filechooser",{timeout:o});l.catch(()=>{}),await t.click({timeout:o}),await(await l).setFiles(i),await e.waitForTimeout(3e3)}w.info(`Successfully uploaded ${i.length} file(s)`)}var sr,Rt=x(()=>{"use strict";U();sr=Z(require("fs"),1)});async function zc(e,t,i={},n){return{...await W(t,e),action_description:n||"Upload file to element",action_data:{action_name:"upload_file",kwargs:{...i}}}}function cr(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"upload_file",kwargs:t},feedback:"Element not found in DOM"}}function ur(e,t){e.register({name:"upload_file",description:'Click on target element (usually contains hints like "Upload file" or "Choose file" etc.) to trigger the file upload dialog, and choose the files to upload',schema:Vc,usesElementIndex:!0,async execute(i,n){let{element_index:a,paths:o}=i,{page:r,agentServices:l,actionDescription:s}=n;try{let c=await G(n,a);if(!c)return{success:!1,error:`File input element with index ${a} not found`,actionEntity:cr(s||`Upload file to element ${a}`,{index:a,paths:o})};let d=await zc(c,r,{paths:o},s);return await t.execute(r,d,l),{success:!0,actionEntity:d,message:`Uploaded file to element ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:cr(s||`Upload file to element ${a}`,{index:a,paths:o})}}}})}var te,dr,Vc,$g,Ft=x(()=>{"use strict";Rt();Y();j();te=require("zod");I();dr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=[];if(n.kwargs.paths?a=Array.isArray(n.kwargs.paths)?n.kwargs.paths:[n.kwargs.paths]:n.kwargs.path&&(a=Array.isArray(n.kwargs.path)?n.kwargs.path:[n.kwargs.path]),a.length===0)throw new Error("No file paths provided for upload_file action");await i.downloadTestDataFiles(a);let o=a.map(c=>i.getTestDataFilePath(c)),r=R(e,t);if(!r)throw new Error("Missing locator for upload_file action");let l=n.kwargs.use_file_input||!1,s=i.getActionSettings().mock_show_open_file_picker??!1;await lr(e,r,o,{useFileInput:l,timeout:L(i,t.action_data?.kwargs?.timeout_ms),mockShowOpenFilePicker:s})}transpile(e){let t=e.action_data?.kwargs||{},i=[],n={};return t.paths?n.paths=t.paths:t.path&&(n.path=t.path),t.use_file_input&&(n.use_file_input=!0),i.push(`action_data: { kwargs: ${JSON.stringify(n)} }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...i.map(a=>` ${a},`),"});"]}};Vc=te.z.object({element_index:te.z.number().int().describe("Index of the target element to trigger the file upload dialog"),paths:te.z.union([te.z.string(),te.z.array(te.z.string())]).describe('Path to a file, relative to the test project root (e.g. "fixtures/data.csv"), or an array of such paths.'),timeout_ms:te.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")});$g=te.z.object({element_index:te.z.number().int().describe("Index of the file input element"),paths:te.z.union([te.z.string(),te.z.array(te.z.string())]).describe('Path to a file, relative to the test project root (e.g. "fixtures/data.csv"), or an array of such paths.'),timeout_ms:te.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function mr(e,t){e.register({name:"wait",description:"Wait for a specified number of seconds before continuing.",schema:Xc,async execute(i,n){let{seconds:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s={action_description:l||`Wait ${a} seconds`,action_data:{action_name:"wait",kwargs:{seconds:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Waited ${a} seconds`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(l||`Wait ${a} seconds`)+" (failed)",action_data:{action_name:"wait",kwargs:{seconds:a}},feedback:s.message}}}}})}var pa,hr,Xc,Ht=x(()=>{"use strict";pa=require("zod"),hr=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.seconds||1;await e.waitForTimeout(n*1e3)}transpile(e){return[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]}},Xc=pa.z.object({seconds:pa.z.number().positive().describe("Number of seconds to wait")})});function gr(e,t){e.register({name:"wait_for_download_complete",description:"Wait for an in-progress download to complete.",schema:Yc,async execute(i,n){let{timeout_seconds:a=10}=i,{page:o,agentServices:r}=n;try{let l={action_description:`Wait for download to complete (timeout: ${a}s)`,action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:"Download completed"}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:"Wait for download to complete (failed)",action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:a}},feedback:l.message}}}}})}var ga,pr,Yc,Wt=x(()=>{"use strict";ga=require("zod"),pr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.timeout_seconds||10;await i.waitForDownloadComplete(e,a)}transpile(e){return['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]}},Yc=ga.z.object({timeout_seconds:ga.z.number().positive().optional().describe("Maximum time in seconds to wait for download to complete (default: 10)")})});function wr(e,t){e.register({name:"ai_wait_until",description:'Wait until a specific condition is met on the page (e.g., "page loads", "spinner disappears", "button becomes enabled"). Use this instead of wait when the goal is to wait for something to happen rather than waiting a fixed duration.',schema:Jc,async execute(i,n){let{condition:a,timeout_seconds:o=60}=i,{page:r,agentServices:l}=n;try{let s={action_description:`Wait until: ${a}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:a,timeout_seconds:o}}};return await t.execute(r,s,l),{success:!0,actionEntity:s,message:`Condition met: ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:`Wait until: ${a} (failed)`,action_data:{action_name:"ai_wait_until",kwargs:{condition:a,timeout_seconds:o}},feedback:s.message}}}}})}var un,fr,Jc,jt=x(()=>{"use strict";un=require("zod"),fr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.condition;if(!a)throw new Error("Missing condition for ai_wait_until");let o=(n.kwargs.timeout_seconds||60)*1e3,r=5e3,l=Date.now(),{evaluateStatement:s}=await Promise.resolve().then(()=>(rt(),ot));for(;Date.now()-l<o;){if((await s(a,e,i,{})).success)return;await e.waitForTimeout(r)}throw new Error(`Timeout waiting for condition: ${a}`)}transpile(e,t){let i=e.action_data?.kwargs?.condition,n=e.action_data?.kwargs?.timeout_seconds||60;return i?[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${n}, '${t}');`]:["// Skipping ai_wait_until: missing condition"]}},Jc=un.z.object({condition:un.z.string().describe('The condition to wait for (e.g., "the loading spinner disappears")'),timeout_seconds:un.z.number().positive().optional().describe("Timeout in seconds (default: 60)")})});function br(e,t){e.register({name:"save_variable",description:"Save a value to a named variable for later use in the test.",schema:qc,async execute(i,n){let{name:a,value:o}=i,{page:r,agentServices:l}=n;try{let s={action_description:`Save variable "${a}" = "${o}"`,action_data:{action_name:"save_variable",kwargs:{name:a,value:o}}};return await t.execute(r,s,l),{success:!0,actionEntity:s,message:`Saved variable "${a}"`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:`Save variable "${a}" (failed)`,action_data:{action_name:"save_variable",kwargs:{name:a,value:o}},feedback:s.message}}}}})}var hn,yr,qc,Ut=x(()=>{"use strict";hn=require("zod"),yr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.name,o=n.kwargs.value;if(!a||o===void 0)throw new Error("Missing variable name or value for save_variable");a.startsWith("$")&&(a=a.slice(1)),i.saveVariable(a,o)}transpile(e){let t=e.action_data?.kwargs?.name||"",i=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(i)} } },`,"});"]}},qc=hn.z.object({name:hn.z.string().describe("Variable name to save"),value:hn.z.string().describe("Value to save in the variable")})});async function Zc(e,t,i={}){return{action_description:t,action_data:{action_name:e,kwargs:{...i}}}}function Qc(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Scroll failed!"}}function xr(e,t){e.register({name:"scroll",description:"Scroll the page by specified number of pages (set down=True to scroll down, down=False to scroll up, num_pages=number of pages to scroll like 0.5 for half page, 1.0 for one page, etc.). ",schema:ed,async execute(i,n){let{down:a,num_pages:o}=i,{page:r,agentServices:l,actionDescription:s}=n;try{let c=s||`Scroll ${a?"down":"up"} ${o} page(s)`,d=await Zc("scroll",c,{down:a,num_pages:o});return await t.execute(r,d,l),{success:!0,actionEntity:d,message:`Scrolled ${a?"down":"up"} ${o} page(s)`}}catch(c){return{success:!1,error:c.message,actionEntity:Qc(s||`Scroll ${a?"down":"up"} ${o} page(s)`,"scroll",{down:a,num_pages:o})}}}})}var mn,Bt,ed,Gt=x(()=>{"use strict";mn=require("zod"),Bt=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.down??!0,a=i.kwargs.num_pages??1,o=n?1:-1;await e.evaluate(`window.scrollBy(0, window.innerHeight * ${a} * ${o})`)}transpile(e){let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]}};ed=mn.z.object({down:mn.z.boolean().describe("True to scroll down, False to scroll up"),num_pages:mn.z.number().nonnegative().describe("Number of pages to scroll (0.5 = half page, 1.0 = one page, etc.)")})});async function td(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function vr(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function kr(e,t){e.register({name:"scroll_on_element",description:"Scroll on a scrollable element horizontally and vertically.",schema:id,usesElementIndex:!0,async execute(i,n){let{element_index:a,delta_x:o,delta_y:r}=i,{page:l,agentServices:s}=n;try{let c=await G(n,a);if(!c)return{success:!1,error:`Element with index ${a} not found`,actionEntity:vr(`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:a,delta_x:o,delta_y:r})};let d=await td("scroll_on_element",`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,c,l,{delta_x:o,delta_y:r});return await t.execute(l,d,s),{success:!0,actionEntity:d,message:`Scrolled on element ${a} horizontally: ${o}px, vertically: ${r}px`}}catch(c){return{success:!1,error:c.message,actionEntity:vr(`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:a,delta_x:o,delta_y:r})}}}})}var st,_r,id,Kt=x(()=>{"use strict";Y();j();st=require("zod");I();_r=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.delta_x||0,o=n.kwargs.delta_y||0,r=R(e,t),l=L(i,t.action_data?.kwargs?.timeout_ms);if(r)await r.hover({timeout:l}),await e.mouse.wheel(a,o);else throw new Error("No locator found for scroll_on_element action")}transpile(e){let t=Ne(e);if(!t){let a=e.action_data?.kwargs?.delta_x||0,o=e.action_data?.kwargs?.delta_y||0;return['await agent.execAction("scroll_on_element", page, {',` action_data: { kwargs: { delta_x: ${a}, delta_y: ${o} } },`,"});"]}let i=e.action_data?.kwargs?.delta_x||0,n=e.action_data?.kwargs?.delta_y||0;return[`await ${t}.hover({ timeout: ${L()} });`,`await page.mouse.wheel(${i}, ${n});`]}};id=st.z.object({element_index:st.z.number().int().describe("Index of the scrollable element"),delta_x:st.z.number().optional().describe("The number of pixels to scroll horizontally. Positive values scroll right, negative values scroll left."),delta_y:st.z.number().optional().describe("The number of pixels to scroll vertically. Positive values scroll down, negative values scroll up."),timeout_ms:st.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Er(e,t){e.register({name:"scroll_to_text",description:"Scroll the page until specified text becomes visible.",schema:nd,async execute(i,n){let{text:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s={action_description:l||`Scroll to text "${a}"`,action_data:{action_name:"scroll_to_text",kwargs:{text:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Scrolled to text "${a}"`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(l||`Scroll to text "${a}"`)+" (failed)",action_data:{action_name:"scroll_to_text",kwargs:{text:a}},feedback:s.message}}}}})}var fa,Sr,nd,zt=x(()=>{"use strict";fa=require("zod"),Sr=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.text;if(n)await e.getByText(n,{exact:!1}).first().scrollIntoViewIfNeeded(),await e.waitForTimeout(500);else throw new Error("Missing text for scroll_to_text action")}transpile(e){let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]}},nd=fa.z.object({text:fa.z.string().describe("Text to scroll to on the page")})});async function ad(e,t,i,n){return{...await W(t,e),action_description:n||`Select option "${i}"`,action_data:{action_name:"select_dropdown_option",kwargs:{text:i}}}}function Tr(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"select_dropdown_option",kwargs:t},feedback:"Element not found in DOM"}}function $r(e,t){e.register({name:"select_dropdown_option",description:"Select an option from a dropdown/select element by value, label, or index.",schema:od,usesElementIndex:!0,async execute(i,n){let{element_index:a,option:o}=i,{page:r,agentServices:l,actionDescription:s}=n;try{let c=await G(n,a);if(!c)return{success:!1,error:`Dropdown element with index ${a} not found`,actionEntity:Tr(s||`Select option in dropdown ${a}`,{index:a,option:o})};let d=await ad(c,r,o,s);return await t.execute(r,d,l),{success:!0,actionEntity:d,message:`Selected option "${o}" in dropdown ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:Tr(`Select option in dropdown ${a}`,{index:a,option:o})}}}})}var Vt,Ar,od,Xt=x(()=>{"use strict";Y();j();Vt=require("zod");I();Ar=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.text||n.kwargs.option,o=R(e,t),r=L(i,t.action_data?.kwargs?.timeout_ms);if(o&&a)await o.selectOption(a,{timeout:r});else throw new Error("Missing locator or option label for select_dropdown_option action")}transpile(e){let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"",i=[];return i.push(`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("select_dropdown_option", page, {',...i.map(n=>` ${n},`),"});"]}};od=Vt.z.object({element_index:Vt.z.number().int().describe("Index of the dropdown/select element"),option:Vt.z.string().describe("Option value, label, or index to select"),timeout_ms:Vt.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function rd(e,t,i,n){return{...await W(i,t),action_description:e,action_data:{action_name:"set_date_for_native_date_picker",kwargs:{date:n}}}}function wa(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"set_date_for_native_date_picker",kwargs:t},feedback:"Element not found in DOM"}}function Ir(e,t){e.register({name:"set_date_for_native_date_picker",description:`Set a date in a native HTML date picker input (<input type="date">).
|
|
4099
|
+
`)(e,o)}transpile(e){let t=this.generateFunctionCallCode(e.action_data?.kwargs||{});return t?[t.endsWith(";")?t:`${t};`]:["// Skipping function: missing functionName"]}generateFunctionCallCode(e){let t=e.functionName;if(!t)return null;let i;if(Array.isArray(e.args))i=e.args.map(String);else if(Array.isArray(e.parameterNames)){let r=e.parameterValues||[];i=e.parameterNames.map((l,s)=>s<r.length?String(r[s]):"undefined")}else return`await ${t}()`;if(i.length===0)return`await ${t}()`;let n=["page","testContext","request","agent"],a=["undefined","null","true","false"],o=i.map(r=>n.includes(r)||a.includes(r)||/^-?\d+(\.\d+)?$/.test(r)?r:r.startsWith("$")?`agent.agentServices.readVariable('${r.substring(1)}')`:`"${r}"`);return`await ${t}(${o.join(", ")})`}}});var nn=x(()=>{"use strict";nt()});var nr,Ot=x(()=>{"use strict";nr=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.SILENT=4]="SILENT",e))(nr||{})});var ot={};Xe(ot,{evaluateStatement:()=>rn,executeAction:()=>Dt,executeStep:()=>on,generateActionStep:()=>an,runTask:()=>sn});var rt=x(()=>{"use strict";Lt();zi();Gi();Ii();et();Li();Pi();Hi();Je();Ui();Et();St();Te();bt();nn();Ue();$t();Mt();nt();It();Pt();re();tt();xe();_t();Ze();kt();Oe();qe();Y();He();U();oe();Ot();j();Se()});var ha,ar,gg,ln=x(()=>{"use strict";ha=require("zod"),ar=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.statement;if(!a)throw new Error("Missing statement for ai_step");let{runTask:o}=await Promise.resolve().then(()=>(rt(),ot)),r=await o(a,e,i);if(r.status!=="success")throw new Error(r.error||"Task execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;return i?[`await agent.run(page, ${JSON.stringify(i)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]}},gg=ha.z.object({statement:ha.z.string().describe('The complete step to execute (e.g., "fill in the login form and submit")')})});var or,cn=x(()=>{"use strict";j();I();or=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");if(typeof n.kwargs.relative_x=="number"&&typeof n.kwargs.relative_y=="number"){let a=R(e,t);if(a){await a.waitFor({state:"attached",timeout:L(i,t.action_data?.kwargs?.timeout_ms)});let o=await a.boundingBox();if(o){let r=o.x+n.kwargs.relative_x+o.width/2,l=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.move(r,l),await e.waitForTimeout(200),await e.mouse.click(r,l),await e.waitForTimeout(500)}}else throw new Error("Element-anchored coordinates provided but no locator found")}else if(typeof n.kwargs.x=="number"&&typeof n.kwargs.y=="number")await e.mouse.move(n.kwargs.x,n.kwargs.y),await e.waitForTimeout(200),await e.mouse.click(n.kwargs.x,n.kwargs.y),await e.waitForTimeout(500);else throw new Error("Missing or invalid coordinates")}transpile(e){let t=e.action_data?.kwargs||{},i=[];return typeof t.relative_x=="number"&&typeof t.relative_y=="number"?(i.push(`action_data: { kwargs: { relative_x: ${t.relative_x}, relative_y: ${t.relative_y} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`)):typeof t.x=="number"&&typeof t.y=="number"&&i.push(`action_data: { kwargs: { x: ${t.x}, y: ${t.y} } }`),['await agent.execAction("click_by_coordinates", page, {',...i.map(n=>` ${n},`),"});"]}}});var ma,rr,vg,dn=x(()=>{"use strict";ma=require("zod"),rr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.statement;if(!a)throw new Error("Missing statement for ai_action");let o=n.kwargs.use_pure_vision,{executeStep:r}=await Promise.resolve().then(()=>(rt(),ot)),l=await r(a,e,i,{usePureVision:o});if(l.status!=="success")throw new Error(l.error||"Action execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;if(!i)return["// Skipping ai_action: missing statement"];let n=JSON.stringify(i),a=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${n}, '${t||""}', ${a});`]}},vg=ma.z.object({statement:ma.z.string().describe('The action to perform (e.g., "click the submit button")')})});async function lr(e,t,i,n){let{useFileInput:a,timeout:o,mockShowOpenFilePicker:r}=n;if(r){w.info("Using mockShowOpenFilePicker approach");let l=i.map(s=>({path:s,buffer:new Uint8Array(sr.default.readFileSync(s))}));await e.evaluate(s=>{window.__pw_showOpenFilePicker_mock_files=s},l),await t.click({timeout:o}),await e.waitForTimeout(3e3),await e.evaluate(()=>{delete window.__pw_showOpenFilePicker_mock_files})}else if(a)w.info("Using direct file input approach"),await t.setInputFiles(i,{timeout:o}),await e.waitForTimeout(3e3);else{w.info("Using file chooser approach");let l=e.waitForEvent("filechooser",{timeout:o});l.catch(()=>{}),await t.click({timeout:o}),await(await l).setFiles(i),await e.waitForTimeout(3e3)}w.info(`Successfully uploaded ${i.length} file(s)`)}var sr,Rt=x(()=>{"use strict";U();sr=Z(require("fs"),1)});async function zc(e,t,i={},n){return{...await W(t,e),action_description:n||"Upload file to element",action_data:{action_name:"upload_file",kwargs:{...i}}}}function cr(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"upload_file",kwargs:t},feedback:"Element not found in DOM"}}function ur(e,t){e.register({name:"upload_file",description:'Click on target element (usually contains hints like "Upload file" or "Choose file" etc.) to trigger the file upload dialog, and choose the files to upload',schema:Vc,usesElementIndex:!0,async execute(i,n){let{element_index:a,paths:o}=i,{page:r,agentServices:l,actionDescription:s}=n;try{let c=await G(n,a);if(!c)return{success:!1,error:`File input element with index ${a} not found`,actionEntity:cr(s||`Upload file to element ${a}`,{index:a,paths:o})};let d=await zc(c,r,{paths:o},s);return await t.execute(r,d,l),{success:!0,actionEntity:d,message:`Uploaded file to element ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:cr(s||`Upload file to element ${a}`,{index:a,paths:o})}}}})}var te,dr,Vc,Mg,Ft=x(()=>{"use strict";Rt();Y();j();te=require("zod");I();dr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=[];if(n.kwargs.paths?a=Array.isArray(n.kwargs.paths)?n.kwargs.paths:[n.kwargs.paths]:n.kwargs.path&&(a=Array.isArray(n.kwargs.path)?n.kwargs.path:[n.kwargs.path]),a.length===0)throw new Error("No file paths provided for upload_file action");await i.downloadTestDataFiles(a);let o=a.map(c=>i.getTestDataFilePath(c)),r=R(e,t);if(!r)throw new Error("Missing locator for upload_file action");let l=n.kwargs.use_file_input||!1,s=i.getActionSettings().mock_show_open_file_picker??!1;await lr(e,r,o,{useFileInput:l,timeout:L(i,t.action_data?.kwargs?.timeout_ms),mockShowOpenFilePicker:s})}transpile(e){let t=e.action_data?.kwargs||{},i=[],n={};return t.paths?n.paths=t.paths:t.path&&(n.path=t.path),t.use_file_input&&(n.use_file_input=!0),i.push(`action_data: { kwargs: ${JSON.stringify(n)} }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...i.map(a=>` ${a},`),"});"]}};Vc=te.z.object({element_index:te.z.number().int().describe("Index of the target element to trigger the file upload dialog"),paths:te.z.union([te.z.string(),te.z.array(te.z.string())]).describe('Path to a file, relative to the test project root (e.g. "fixtures/data.csv"), or an array of such paths.'),timeout_ms:te.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")});Mg=te.z.object({element_index:te.z.number().int().describe("Index of the file input element"),paths:te.z.union([te.z.string(),te.z.array(te.z.string())]).describe('Path to a file, relative to the test project root (e.g. "fixtures/data.csv"), or an array of such paths.'),timeout_ms:te.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function mr(e,t){e.register({name:"wait",description:"Wait for a specified number of seconds before continuing.",schema:Xc,async execute(i,n){let{seconds:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s={action_description:l||`Wait ${a} seconds`,action_data:{action_name:"wait",kwargs:{seconds:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Waited ${a} seconds`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(l||`Wait ${a} seconds`)+" (failed)",action_data:{action_name:"wait",kwargs:{seconds:a}},feedback:s.message}}}}})}var pa,hr,Xc,Ht=x(()=>{"use strict";pa=require("zod"),hr=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.seconds||1;await e.waitForTimeout(n*1e3)}transpile(e){return[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]}},Xc=pa.z.object({seconds:pa.z.number().positive().describe("Number of seconds to wait")})});function gr(e,t){e.register({name:"wait_for_download_complete",description:"Wait for an in-progress download to complete.",schema:Yc,async execute(i,n){let{timeout_seconds:a=10}=i,{page:o,agentServices:r}=n;try{let l={action_description:`Wait for download to complete (timeout: ${a}s)`,action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:"Download completed"}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:"Wait for download to complete (failed)",action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:a}},feedback:l.message}}}}})}var ga,pr,Yc,Wt=x(()=>{"use strict";ga=require("zod"),pr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.timeout_seconds||10;await i.waitForDownloadComplete(e,a)}transpile(e){return['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]}},Yc=ga.z.object({timeout_seconds:ga.z.number().positive().optional().describe("Maximum time in seconds to wait for download to complete (default: 10)")})});function wr(e,t){e.register({name:"ai_wait_until",description:'Wait until a specific condition is met on the page (e.g., "page loads", "spinner disappears", "button becomes enabled"). Use this instead of wait when the goal is to wait for something to happen rather than waiting a fixed duration.',schema:Jc,async execute(i,n){let{condition:a,timeout_seconds:o=60}=i,{page:r,agentServices:l}=n;try{let s={action_description:`Wait until: ${a}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:a,timeout_seconds:o}}};return await t.execute(r,s,l),{success:!0,actionEntity:s,message:`Condition met: ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:`Wait until: ${a} (failed)`,action_data:{action_name:"ai_wait_until",kwargs:{condition:a,timeout_seconds:o}},feedback:s.message}}}}})}var un,fr,Jc,jt=x(()=>{"use strict";un=require("zod"),fr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.condition;if(!a)throw new Error("Missing condition for ai_wait_until");let o=(n.kwargs.timeout_seconds||60)*1e3,r=5e3,l=Date.now(),{evaluateStatement:s}=await Promise.resolve().then(()=>(rt(),ot));for(;Date.now()-l<o;){if((await s(a,e,i,{})).success)return;await e.waitForTimeout(r)}throw new Error(`Timeout waiting for condition: ${a}`)}transpile(e,t){let i=e.action_data?.kwargs?.condition,n=e.action_data?.kwargs?.timeout_seconds||60;return i?[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${n}, '${t}');`]:["// Skipping ai_wait_until: missing condition"]}},Jc=un.z.object({condition:un.z.string().describe('The condition to wait for (e.g., "the loading spinner disappears")'),timeout_seconds:un.z.number().positive().optional().describe("Timeout in seconds (default: 60)")})});function br(e,t){e.register({name:"save_variable",description:"Save a value to a named variable for later use in the test.",schema:qc,async execute(i,n){let{name:a,value:o}=i,{page:r,agentServices:l}=n;try{let s={action_description:`Save variable "${a}" = "${o}"`,action_data:{action_name:"save_variable",kwargs:{name:a,value:o}}};return await t.execute(r,s,l),{success:!0,actionEntity:s,message:`Saved variable "${a}"`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:`Save variable "${a}" (failed)`,action_data:{action_name:"save_variable",kwargs:{name:a,value:o}},feedback:s.message}}}}})}var hn,yr,qc,Ut=x(()=>{"use strict";hn=require("zod"),yr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.name,o=n.kwargs.value;if(!a||o===void 0)throw new Error("Missing variable name or value for save_variable");a.startsWith("$")&&(a=a.slice(1)),i.saveVariable(a,o)}transpile(e){let t=e.action_data?.kwargs?.name||"",i=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(i)} } },`,"});"]}},qc=hn.z.object({name:hn.z.string().describe("Variable name to save"),value:hn.z.string().describe("Value to save in the variable")})});async function Zc(e,t,i={}){return{action_description:t,action_data:{action_name:e,kwargs:{...i}}}}function Qc(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Scroll failed!"}}function xr(e,t){e.register({name:"scroll",description:"Scroll the page by specified number of pages (set down=True to scroll down, down=False to scroll up, num_pages=number of pages to scroll like 0.5 for half page, 1.0 for one page, etc.). ",schema:ed,async execute(i,n){let{down:a,num_pages:o}=i,{page:r,agentServices:l,actionDescription:s}=n;try{let c=s||`Scroll ${a?"down":"up"} ${o} page(s)`,d=await Zc("scroll",c,{down:a,num_pages:o});return await t.execute(r,d,l),{success:!0,actionEntity:d,message:`Scrolled ${a?"down":"up"} ${o} page(s)`}}catch(c){return{success:!1,error:c.message,actionEntity:Qc(s||`Scroll ${a?"down":"up"} ${o} page(s)`,"scroll",{down:a,num_pages:o})}}}})}var mn,Bt,ed,Gt=x(()=>{"use strict";mn=require("zod"),Bt=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.down??!0,a=i.kwargs.num_pages??1,o=n?1:-1;await e.evaluate(`window.scrollBy(0, window.innerHeight * ${a} * ${o})`)}transpile(e){let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]}};ed=mn.z.object({down:mn.z.boolean().describe("True to scroll down, False to scroll up"),num_pages:mn.z.number().nonnegative().describe("Number of pages to scroll (0.5 = half page, 1.0 = one page, etc.)")})});async function td(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function vr(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function kr(e,t){e.register({name:"scroll_on_element",description:"Scroll on a scrollable element horizontally and vertically.",schema:id,usesElementIndex:!0,async execute(i,n){let{element_index:a,delta_x:o,delta_y:r}=i,{page:l,agentServices:s}=n;try{let c=await G(n,a);if(!c)return{success:!1,error:`Element with index ${a} not found`,actionEntity:vr(`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:a,delta_x:o,delta_y:r})};let d=await td("scroll_on_element",`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,c,l,{delta_x:o,delta_y:r});return await t.execute(l,d,s),{success:!0,actionEntity:d,message:`Scrolled on element ${a} horizontally: ${o}px, vertically: ${r}px`}}catch(c){return{success:!1,error:c.message,actionEntity:vr(`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:a,delta_x:o,delta_y:r})}}}})}var st,_r,id,Kt=x(()=>{"use strict";Y();j();st=require("zod");I();_r=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.delta_x||0,o=n.kwargs.delta_y||0,r=R(e,t),l=L(i,t.action_data?.kwargs?.timeout_ms);if(r)await r.hover({timeout:l}),await e.mouse.wheel(a,o);else throw new Error("No locator found for scroll_on_element action")}transpile(e){let t=Ne(e);if(!t){let a=e.action_data?.kwargs?.delta_x||0,o=e.action_data?.kwargs?.delta_y||0;return['await agent.execAction("scroll_on_element", page, {',` action_data: { kwargs: { delta_x: ${a}, delta_y: ${o} } },`,"});"]}let i=e.action_data?.kwargs?.delta_x||0,n=e.action_data?.kwargs?.delta_y||0;return[`await ${t}.hover({ timeout: ${L()} });`,`await page.mouse.wheel(${i}, ${n});`]}};id=st.z.object({element_index:st.z.number().int().describe("Index of the scrollable element"),delta_x:st.z.number().optional().describe("The number of pixels to scroll horizontally. Positive values scroll right, negative values scroll left."),delta_y:st.z.number().optional().describe("The number of pixels to scroll vertically. Positive values scroll down, negative values scroll up."),timeout_ms:st.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Er(e,t){e.register({name:"scroll_to_text",description:"Scroll the page until specified text becomes visible.",schema:nd,async execute(i,n){let{text:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s={action_description:l||`Scroll to text "${a}"`,action_data:{action_name:"scroll_to_text",kwargs:{text:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Scrolled to text "${a}"`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(l||`Scroll to text "${a}"`)+" (failed)",action_data:{action_name:"scroll_to_text",kwargs:{text:a}},feedback:s.message}}}}})}var fa,Sr,nd,zt=x(()=>{"use strict";fa=require("zod"),Sr=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.text;if(n)await e.getByText(n,{exact:!1}).first().scrollIntoViewIfNeeded(),await e.waitForTimeout(500);else throw new Error("Missing text for scroll_to_text action")}transpile(e){let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]}},nd=fa.z.object({text:fa.z.string().describe("Text to scroll to on the page")})});async function ad(e,t,i,n){return{...await W(t,e),action_description:n||`Select option "${i}"`,action_data:{action_name:"select_dropdown_option",kwargs:{text:i}}}}function Tr(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"select_dropdown_option",kwargs:t},feedback:"Element not found in DOM"}}function $r(e,t){e.register({name:"select_dropdown_option",description:"Select an option from a dropdown/select element by value, label, or index.",schema:od,usesElementIndex:!0,async execute(i,n){let{element_index:a,option:o}=i,{page:r,agentServices:l,actionDescription:s}=n;try{let c=await G(n,a);if(!c)return{success:!1,error:`Dropdown element with index ${a} not found`,actionEntity:Tr(s||`Select option in dropdown ${a}`,{index:a,option:o})};let d=await ad(c,r,o,s);return await t.execute(r,d,l),{success:!0,actionEntity:d,message:`Selected option "${o}" in dropdown ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:Tr(`Select option in dropdown ${a}`,{index:a,option:o})}}}})}var Vt,Ar,od,Xt=x(()=>{"use strict";Y();j();Vt=require("zod");I();Ar=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.text||n.kwargs.option,o=R(e,t),r=L(i,t.action_data?.kwargs?.timeout_ms);if(o&&a)await o.selectOption(a,{timeout:r});else throw new Error("Missing locator or option label for select_dropdown_option action")}transpile(e){let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"",i=[];return i.push(`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("select_dropdown_option", page, {',...i.map(n=>` ${n},`),"});"]}};od=Vt.z.object({element_index:Vt.z.number().int().describe("Index of the dropdown/select element"),option:Vt.z.string().describe("Option value, label, or index to select"),timeout_ms:Vt.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function rd(e,t,i,n){return{...await W(i,t),action_description:e,action_data:{action_name:"set_date_for_native_date_picker",kwargs:{date:n}}}}function wa(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"set_date_for_native_date_picker",kwargs:t},feedback:"Element not found in DOM"}}function Ir(e,t){e.register({name:"set_date_for_native_date_picker",description:`Set a date in a native HTML date picker input (<input type="date">).
|
|
4100
4100
|
|
|
4101
4101
|
IMPORTANT: ONLY use this action for input elements that have type="date" attribute (native HTML date picker).
|
|
4102
4102
|
Do NOT use it for custom/non-native date pickers
|
|
4103
4103
|
|
|
4104
4104
|
The date must be in YYYY-MM-DD format (e.g., 2024-03-15).`,schema:sd,usesElementIndex:!0,async execute(i,n){let{element_index:a,date:o}=i,{page:r,agentServices:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Date picker element with index ${a} not found`,actionEntity:wa(`Set date to ${o} on element ${a}`,{index:a,date:o})};let c=s.attributes.type;if(c!=="date")return{success:!1,error:`Element ${a} is not a native date picker (type="${c}"). This action only works with <input type="date">.`,actionEntity:wa(`Set date to ${o} on element ${a}`,{index:a,date:o})};let d=await rd(`Set date to ${o} on element ${a}`,s,r,o);return await t.execute(r,d,l),{success:!0,actionEntity:d,message:`Set date to ${o} on element ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:wa(`Set date to ${o} on element ${a}`,{index:a,date:o})}}}})}var Yt,Mr,sd,Jt=x(()=>{"use strict";Y();j();Yt=require("zod");I();Mr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.date;if(!a)throw new Error("Date value is required");if(!/^\d{4}-\d{2}-\d{2}$/.test(a))throw new Error(`Invalid date format: ${a}. Expected format: YYYY-MM-DD (e.g., 2024-03-15)`);let o=i.replaceVariables(String(a)),r=R(e,t);if(r){let l=await r.getAttribute("type").catch(()=>null);if(l&&l!=="date")throw new Error(`Element is not a native date picker (type="${l}"). This action only works with <input type="date">. For custom date pickers, use AI-powered actions.`);await r.fill(o,{timeout:L(i,t.action_data?.kwargs?.timeout_ms)})}else throw new Error("No locator found for set_date_for_native_date_picker action")}transpile(e){let t=e.action_data?.kwargs?.date??"",i=[];return i.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...i.map(n=>` ${n},`),"});"]}};sd=Yt.z.object({element_index:Yt.z.number().int().describe("Index of the native date picker input element"),date:Yt.z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Date in YYYY-MM-DD format (e.g., 2024-03-15)"),timeout_ms:Yt.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Cr(e,t){e.register({name:"switch_tab",description:"Switch to a different browser tab by index (0-based).",schema:ld,async execute(i,n){let a=i.tab_index,{page:o,agentServices:r,actionDescription:l}=n;try{let s={action_description:l||`Switch to tab ${a}`,action_data:{action_name:"switch_tab",kwargs:{page_id:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Switched to tab ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(l||`Switch to tab ${a}`)+" (failed)",action_data:{action_name:"switch_tab",kwargs:{page_id:a}},feedback:s.message}}}}})}var ya,Pr,ld,qt=x(()=>{"use strict";ya=require("zod"),Pr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.page_id??n.kwargs.tab_index??0;if(typeof a=="number"){let o=e.context().pages(),r=a===-1?o.length-1:a;if(i){let l=await i.switchTab(r);await l.waitForLoadState("load",{timeout:15e3}).catch(()=>{}),await l.waitForTimeout(500)}}else throw new Error("Missing page_id for switch_tab action")}transpile(e){return['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]}},ld=ya.z.object({tab_index:ya.z.number().int().nonnegative().describe("Index of the tab to switch to (0-based). Use 0 for first tab, 1 for second, etc.")})});async function cd(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function Nr(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function Or(e,t){e.register({name:"input_text",description:"Type text into an input field. To replace existing content, use clear_input first.",schema:dd,usesElementIndex:!0,async execute(i,n){let{element_index:a,text:o}=i,{page:r,agentServices:l,actionDescription:s}=n;try{let c=await G(n,a);if(!c)return{success:!1,error:`Input element with index ${a} not found`,actionEntity:Nr(s||`Input text to element ${a}`,"input_text",{index:a,text:o})};let d=s||`Input text to element ${a}`,u=await cd("input_text",d,c,r,{text:o});return await t.execute(r,u,l),{success:!0,actionEntity:u,message:`Input text to element ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:Nr(`Input text to element ${a}`,"input_text",{index:a,text:o})}}}})}var Zt,ba,dd,Qt=x(()=>{"use strict";Y();j();Zt=require("zod");I();ba=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.text??n.kwargs.value??"",o=i.replaceVariables(String(a)),r=R(e,t),l=L(i,t.action_data?.kwargs?.timeout_ms);if(r){await r.evaluate(c=>{c.value&&(c.value="")},null,{timeout:l}),await r.click({timeout:l}),await e.waitForTimeout(200);let s=i.getActionSettings().type_delay;s!==void 0?await e.keyboard.type(o,{delay:s}):await e.keyboard.type(o)}else throw new Error("No locator found for input_text action")}transpile(e){let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"",i=[];return i.push(`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("input_text", page, {',...i.map(n=>` ${n},`),"});"]}};dd=Zt.z.object({element_index:Zt.z.number().int().describe("Index of the input element"),text:Zt.z.string().describe("Text to type into the input. To use a placeholder, write {{ placeholder_name }} using exact placeholder name. Use clear_input first if you want to replace existing content."),timeout_ms:Zt.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Dr(e,t){e.register({name:"press",description:"Press a single keyboard key or key combination. Supports combinations like `Control+A` for select all. Does NOT support sequences - call this action multiple times to press keys in sequence.",schema:ud,async execute(i,n){let{keys:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s={action_description:l||`Press keys "${a}"`,action_data:{action_name:"press",kwargs:{keys:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Pressed keys "${a}"`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(l||`Press keys "${a}"`)+" (failed)",action_data:{action_name:"press",kwargs:{keys:a}},feedback:s.message}}}}})}var xa,va,ud,ei=x(()=>{"use strict";xa=require("zod"),va=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.keys;if(!n||typeof n!="string")throw new Error("Missing or invalid keys for press action");await e.keyboard.press(n),await e.waitForTimeout(500)}transpile(e){let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]}},ud=xa.z.object({keys:xa.z.string().describe("A single key or key combination to press (e.g. Escape, Backspace, Insert, PageDown, Delete, Tab, Enter). Key combinations like `Control+o`, `Control+Shift+T`, `ControlOrMeta+a` are supported. Note: This does NOT support sequences - to press multiple keys in sequence (e.g., Control+A then Backspace), call this action multiple times.")})});function Fr(e,t){e.register({name:"reload_page",description:"Reload the current page. WARNING: This will reset any in-progress forms or multi-step flows (like login). Only use when you need to refresh stale data or clear a stuck state. Do NOT use during login, checkout, or form submission flows.",schema:hd,async execute(i,n){let{page:a,agentServices:o}=n;try{let r={action_description:"Reload page",action_data:{action_name:"reload_page",kwargs:{}}};return await t.execute(a,r,o),{success:!0,actionEntity:r,message:`Reloaded ${a.url()}`}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:"Reload page (failed)",action_data:{action_name:"reload_page",kwargs:{}},feedback:r.message}}}}})}var Lr,Rr,hd,ti=x(()=>{"use strict";j();Lr=require("zod");I();Rr=class{async execute(e,t){await e.reload({timeout:fe}),await e.waitForLoadState("load",{timeout:fe}),await e.waitForTimeout(1e3)}transpile(e){return['await agent.execAction("reload_page", page, {});']}},hd=Lr.z.object({})});async function md(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function Hr(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function Wr(e,t){e.register({name:"right_click",description:"Right-click an interactive element.",schema:pd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:Hr(`Right-click element ${a}`,"right_click",{index:a})};let c=l||`Right-click element ${a}`,d=await md("right_click",c,s,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Right-clicked element ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:Hr(`Right-click element ${a}`,"right_click",{index:a})}}}})}var pn,_a,pd,ii=x(()=>{"use strict";Y();j();pn=require("zod");I();_a=class{async execute(e,t,i){let n=R(e,t),a=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.click({button:"right",timeout:a});else throw new Error("No locator found for right_click action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("right_click", page, {});']:['await agent.execAction("right_click", page, {',...t.map(i=>` ${i},`),"});"]}};pd=pn.z.object({element_index:pn.z.number().int().describe("Index of the element to right-click"),timeout_ms:pn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Ur(e,t){e.register({name:"generate_2fa_code",description:'Generate a 2FA code from an OTP secret key. The code is saved to the "otp_code" variable. To use the otp_code, you must use `$otp_code` to access it.',schema:gd,async execute(i,n){let{otp_secret_key:a}=i,{page:o,agentServices:r}=n;try{let l={action_description:"Generate 2FA code",action_data:{action_name:"generate_2fa_code",kwargs:{otp_secret_key:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:'Generated 2FA code and saved to variable "otp_code"'}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:"Generate 2FA code (failed)",action_data:{action_name:"generate_2fa_code",kwargs:{otp_secret_key:a}},feedback:l.message}}}}})}var ka,jr,gd,ni=x(()=>{"use strict";ka=require("zod"),jr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.otp_secret_key;if(!a)throw new Error("Missing otp_secret_key for generate_2fa_code");let o=i.replaceVariables(String(a)),r=await i.generate2faCode(o);i.saveVariable("otp_code",r)}transpile(e){let t=e.action_data?.kwargs?.otp_secret_key||"";return['await agent.execAction("generate_2fa_code", page, {',` action_data: { kwargs: { otp_secret_key: ${JSON.stringify(t)} } },`,"});"]}},gd=ka.z.object({otp_secret_key:ka.z.string().describe("The OTP secret key to generate the 2FA code from")})});async function fd(e,t,i){return{...await W(t,e),action_description:i||"Get dropdown options",action_data:{action_name:"get_dropdown_options",kwargs:{}}}}function Br(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"get_dropdown_options",kwargs:t},feedback:"Element not found in DOM"}}function Kr(e,t){e.register({name:"get_dropdown_options",description:"Get all options from a native dropdown",schema:wd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Dropdown element with index ${a} not found`,actionEntity:Br(l||`Get options from dropdown ${a}`,{index:a})};let c=await fd(s,o,l);return await t.execute(o,c,r),{success:!0,actionEntity:c,message:c.feedback||"No options found"}}catch(s){return{success:!1,error:s.message,actionEntity:Br(l||`Get options from dropdown ${a}`,{index:a})}}}})}var Sa,Gr,wd,ai=x(()=>{"use strict";Y();Sa=require("zod"),Gr=class{async execute(e,t,i){if(!t.xpath)throw new Error("XPath not found in action entity");let n=[];for(let a of e.frames())try{let o=await a.evaluate(r=>{let l=document.evaluate(r,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return l?{options:Array.from(l.options).map(s=>({text:s.text,value:s.value,index:s.index})),id:l.id,name:l.name}:null},t.xpath);if(o){let r=[];for(let l of o.options){let s=JSON.stringify(l.text);r.push(`${l.index}: text=${s}`)}n.push(...r)}}catch{}if(n.length>0){let a=n.join(`
|
|
4105
4105
|
`);a+=`
|
|
4106
|
-
Use the exact text string in select_dropdown_option`,i.addNote(a)}else i.addNote("No options found in any frame for dropdown")}transpile(e){let t=[];return e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("get_dropdown_options", page, {});']:['await agent.execAction("get_dropdown_options", page, {',...t.map(i=>` ${i},`),"});"]}};wd=Sa.z.object({element_index:Sa.z.number().int().describe("Index of the dropdown/select element")})});function Xr(e,t){e.register({name:"go_back",description:"Navigate back to the previous page in browser history.",schema:yd,async execute(i,n){let{page:a,agentServices:o,actionDescription:r}=n;try{let l={action_description:r||"Go back",action_data:{action_name:"go_back",kwargs:{}}};return await t.execute(a,l,o),{success:!0,actionEntity:l,message:"Navigated back"}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(r||"Go back")+" (failed)",action_data:{action_name:"go_back",kwargs:{}},feedback:l.message}}}}})}var zr,Vr,yd,oi=x(()=>{"use strict";j();zr=require("zod");I();Vr=class{async execute(e,t){await e.goBack({timeout:fe}),await e.waitForLoadState("load",{timeout:fe}),await e.waitForTimeout(1e3)}transpile(e){return['await agent.execAction("go_back", page, {});']}},yd=zr.z.object({})});function Yr(e,t){e.register({name:"go_to_url",description:"Navigate to a specific URL. Use this to visit web pages. Set new_tab=true to open in a new tab.",schema:bd,async execute(i,n){let{url:a,new_tab:o,timeout_seconds:r}=i,{page:l,agentServices:s,actionDescription:c}=n,d={url:a,new_tab:o??!1};r!==void 0&&(d.timeout_seconds=r);let u=r?` (timeout: ${r}s)`:"";try{let p=o?`Open ${a} in new tab`:`Navigate to ${a}`,h={action_description:c||p,action_data:{action_name:"go_to_url",kwargs:d}};return await t.execute(l,h,s),{success:!0,actionEntity:h,message:(o?`Opened ${a} in new tab`:`Navigated to ${a}`)+u}}catch(p){let h=o?`Open ${a} in new tab`:`Navigate to ${a}`;return{success:!1,error:p.message,actionEntity:{action_description:(c||h)+" (failed)",action_data:{action_name:"go_to_url",kwargs:d},feedback:p.message}}}}})}var ri,Ea,bd,si=x(()=>{"use strict";j();ri=require("zod");I();Ea=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.url;if(!a)throw new Error("Missing URL for go_to_url action");let o=n.kwargs.new_tab===!0,r=i.replaceVariables(String(a));if(r.startsWith("/")){let c=e.url(),d=null;try{let u=new URL(c);u.origin&&u.origin!=="null"&&(d=u.origin)}catch{}d&&(r=d+r)}let l=n.kwargs.timeout_seconds?n.kwargs.timeout_seconds*1e3:fe,s=e;o&&(s=await e.context().newPage(),i.setPage(s)),await s.goto(r,{timeout:l})}transpile(e){let t=e.action_data?.kwargs?.url||"",i=e.action_data?.kwargs?.new_tab===!0,n=e.action_data?.kwargs?.timeout_seconds,a=[`url: ${JSON.stringify(t)}`];return i&&a.push("new_tab: true"),n&&a.push(`timeout_seconds: ${n}`),['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { ${a.join(", ")} } },`,"});"]}},bd=ri.z.object({url:ri.z.string().describe("URL to navigate to (must be a valid HTTP/HTTPS URL)"),new_tab:ri.z.boolean().optional().describe("If true, open the URL in a new tab instead of the current page. Default is false."),timeout_seconds:ri.z.number().positive().optional().describe("Navigation timeout in seconds. Default is 20 seconds.")})});async function xd(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function Jr(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function qr(e,t){e.register({name:"hover",description:"Hover over an interactive element.",schema:vd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:Jr(`Hover element ${a}`,"hover",{index:a})};let c=l||`Hover over element ${a}`,d=await xd("hover",c,s,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Hovered over element ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:Jr(`Hover element ${a}`,"hover",{index:a})}}}})}var gn,Ta,vd,li=x(()=>{"use strict";Y();j();gn=require("zod");I();Ta=class{async execute(e,t,i){let n=R(e,t),a=L(i,t.action_data?.kwargs?.timeout_ms);if(n){await n.waitFor({state:"attached",timeout:a});let o=await n.elementHandle();if(!o)throw new Error("Unable to obtain element handle for hover action");let r=await o.boundingBox();if(!r)throw new Error("Unable to determine bounding box for hover action");let l=r.x+r.width/2,s=r.y+r.height/2;await e.mouse.move(l,s)}else throw new Error("No locator found for hover action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("hover", page, {});']:['await agent.execAction("hover", page, {',...t.map(i=>` ${i},`),"});"]}};vd=gn.z.object({element_index:gn.z.number().int().describe("Index of the element to hover over"),timeout_ms:gn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Qr(e,t){e.register({name:"ai_extract",description:"Use AI to extract information from the page and save it to a variable. MCP-only tool.",schema:_d,async execute(i,n){let{element_description:a,variable_name:o}=i,{page:r,agentServices:l}=n;try{let s={action_description:`Extract ${a} to ${o}`,action_data:{action_name:"ai_extract",kwargs:{element_description:a,variable_name:o}}};return await t.execute(r,s,l),{success:!0,actionEntity:s,message:`Extracted ${a} to ${o}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:`Extract ${a} (failed)`,action_data:{action_name:"ai_extract",kwargs:{element_description:a,variable_name:o}},feedback:s.message}}}},availability:{openai:!1,mcp:!0}})}var fn,Zr,_d,ci=x(()=>{"use strict";fn=require("zod"),Zr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.element_description,o=n.kwargs.variable_name;if(!a||!o)throw new Error("Missing element_description or variable_name for ai_extract");let r=`Extract ${a} and save to ${o}`,{executeStep:l}=await Promise.resolve().then(()=>(rt(),ot)),s=await l(r,e,i);if(s.status!=="success")throw new Error(s.error||"Extraction failed")}transpile(e,t){let i=e.action_data?.kwargs?.element_description,n=e.action_data?.kwargs?.variable_name;if(!i||!n)return["// Skipping ai_extract: missing element_description or variable_name"];let a=JSON.stringify(i),o=JSON.stringify(n);return[`await agent.extract(page, ${a}, ${o}, '${t||""}');`]}},_d=fn.z.object({element_description:fn.z.string().describe('Description of the element to extract (e.g., "the price of the product")'),variable_name:fn.z.string().describe("Name of the variable to store the extracted value")})});async function kd(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function es(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function is(e,t){e.register({name:"clear_input",description:"Clear the contents of an input field, textarea, or other editable element.",schema:Sd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Input element with index ${a} not found`,actionEntity:es(l||`Clear element ${a}`,"clear_input",{index:a})};let c=l||`Clear element ${a}`,d=await kd("clear_input",c,s,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Cleared element ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:es(`Clear element ${a}`,"clear_input",{index:a})}}}})}var wn,ts,Sd,di=x(()=>{"use strict";Y();j();wn=require("zod");I();ts=class{async execute(e,t,i){let n=R(e,t),a=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.click({timeout:a}),await e.keyboard.press("ControlOrMeta+a"),await e.waitForTimeout(200),await e.keyboard.press("Backspace"),await e.waitForTimeout(200);else throw new Error("No locator found for clear_input action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("clear_input", page, {});']:['await agent.execAction("clear_input", page, {',...t.map(i=>` ${i},`),"});"]}};Sd=wn.z.object({element_index:wn.z.number().int().describe("Index of the input element to clear"),timeout_ms:wn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function Ed(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function ns(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function as(e,t){e.register({name:"click",description:"Click an interactive element.",schema:Td,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:ns(`Click element ${a}`,"click",{index:a})};let c=l||`Click element ${a}`,d=await Ed("click",c,s,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Clicked element ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:ns(`Click element ${a}`,"click",{index:a})}}}})}var yn,bn,Td,ui=x(()=>{"use strict";Y();j();yn=require("zod");I();bn=class{async execute(e,t,i){let n=R(e,t),a=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.click({timeout:a});else throw new Error("No locator found for click action")}transpile(e){let t=Ne(e);if(!t)return['await agent.execAction("click", page, {});'];let i=L();return[`await ${t}.click({ timeout: ${i} });`]}};Td=yn.z.object({element_index:yn.z.number().int().describe("Index of the element to click (0-based). Return -1 if no element found"),timeout_ms:yn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function rs(e,t){e.register({name:"close_tab",description:"Close a browser tab by index. If no index is specified, closes the current tab.",schema:Ad,async execute(i,n){let{index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s={action_description:l||`Close tab ${a}`,action_data:{action_name:"close_tab",kwargs:{page_id:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Closed tab ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(l||"Close tab")+" (failed)",action_data:{action_name:"close_tab",kwargs:{}},feedback:s.message}}}}})}var Aa,os,Ad,hi=x(()=>{"use strict";Aa=require("zod"),os=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.page_id??n.kwargs.index;if(a===void 0&&(a=e.context().pages().indexOf(e)),typeof a=="number"){if(a===0)throw new Error("Cannot close the first tab (page_id 0). Skipping close_tab action.");i&&await i.closeTab(a)}else throw new Error("Missing page_id for close_tab action")}transpile(e){let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]}},Ad=Aa.z.object({index:Aa.z.number().int().nonnegative().optional().describe("Index of the tab to close (0-based). Defaults to current tab if not specified.")})});function ls(e,t){e.register({name:"done",description:"Mark the current task as complete. Use when you have finished all requested actions.",schema:$d,async execute(i,n){let{page:a,agentServices:o}=n;try{let r={action_description:"Task completed",action_data:{action_name:"done",kwargs:{}}};return await t.execute(a,r,o),{success:!0,actionEntity:r,message:"Task marked as complete"}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:"Task completed (failed)",action_data:{action_name:"done",kwargs:{}},feedback:r.message}}}}})}var xn,ss,$d,mi=x(()=>{"use strict";xn=require("zod"),ss=class{async execute(e,t){}transpile(e){return["// Done - no action needed"]}},$d=xn.z.object({success:xn.z.boolean().describe("Whether the task was completed successfully"),summary:xn.z.string().describe("Summary of what was accomplished or why it failed")})});async function Md(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function cs(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function ds(e,t){e.register({name:"double_click",description:"Double-click an interactive element.",schema:Id,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:cs(`Double-click element ${a}`,"double_click",{index:a})};let c=l||`Double-click element ${a}`,d=await Md("double_click",c,s,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Double-clicked element ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:cs(`Double-click element ${a}`,"double_click",{index:a})}}}})}var vn,$a,Id,pi=x(()=>{"use strict";Y();j();vn=require("zod");I();$a=class{async execute(e,t,i){let n=R(e,t),a=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.dblclick({timeout:a});else throw new Error("No locator found for double_click action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("double_click", page, {});']:['await agent.execAction("double_click", page, {',...t.map(i=>` ${i},`),"});"]}};Id=vn.z.object({element_index:vn.z.number().int().describe("Index of the element to double-click"),timeout_ms:vn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function hs(e){if(!e.trim())return!1;try{return(0,us.parse)(e,{sourceType:"module",plugins:["typescript"]}),!0}catch{return!1}}var us,_n=x(()=>{"use strict";us=require("@babel/parser")});function ms(e,t){e.register({name:"verify",description:"Verify that a statement is true based on the current page state. Use this to check assertions about the page content, element visibility, or any condition.",schema:Pd,async execute(i,n){let{statement:a}=i,{page:o,agentServices:r}=n;try{let l={action_description:`${a}`,action_data:{action_name:"verify",kwargs:{statement:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Assertion verified: ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Verify: ${a} (failed)`,action_data:{action_name:"verify",kwargs:{statement:a}},feedback:l.message}}}},availability:{openai:!0,mcp:!0}})}var Ma,kn,Pd,gi=x(()=>{"use strict";Nt();_n();U();Ma=require("zod"),kn=class{async execute(e,t,i){let n=t.action_data?.kwargs,a=typeof n?.code=="string",o=a?n?.statement||t.action_description:t.action_description||n?.statement;if(a&&o){let d=Date.now();try{await this.executeJSAssertion(e,n.code,i),w.info(`[VERIFY:JS] \u2713 ${((Date.now()-d)/1e3).toFixed(1)}s: ${o}`),i.addNote(`Assertion passed: ${o}`);return}catch(u){let p=((Date.now()-d)/1e3).toFixed(1);w.info(`[VERIFY:JS\u2192AI] JS failed ${p}s (${u instanceof Error?u.message:String(u)}), falling back to AI: ${o}`)}}else if(a){let d=Date.now();await this.executeJSAssertion(e,n.code,i),w.info(`[VERIFY:JS] \u2713 ${((Date.now()-d)/1e3).toFixed(1)}s: ${o||"js-only"}`),i.addNote(`Assertion passed: ${o||"js-only"}`);return}if(!o)throw new Error("Missing statement or code for verify action");let r=Date.now();w.info(`[VERIFY:AI] Evaluating: ${o}`);let{evaluateStatement:l}=await Promise.resolve().then(()=>(rt(),ot)),s=await l(o,e,i,{useCleanScreenshotForAssertion:!0}),c=s.explanation||s.error||(s.success?`Assertion passed: ${o}`:"Assertion failed");if(i.addNote(c),!s.success)throw w.info(`[VERIFY:AI] \u2717 ${((Date.now()-r)/1e3).toFixed(1)}s: ${o}`),new Error(s.error||s.explanation||"Assertion failed");w.info(`[VERIFY:AI] \u2713 ${((Date.now()-r)/1e3).toFixed(1)}s: ${o}`)}async executeJSAssertion(e,t,i){let n=i.agent;if(!n)throw new Error("Agent not initialized on AgentServices \u2014 ai_assert requires an agent reference");try{await new Function("page","expect","agent",`
|
|
4106
|
+
Use the exact text string in select_dropdown_option`,i.addNote(a)}else i.addNote("No options found in any frame for dropdown")}transpile(e){let t=[];return e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("get_dropdown_options", page, {});']:['await agent.execAction("get_dropdown_options", page, {',...t.map(i=>` ${i},`),"});"]}};wd=Sa.z.object({element_index:Sa.z.number().int().describe("Index of the dropdown/select element")})});function Xr(e,t){e.register({name:"go_back",description:"Navigate back to the previous page in browser history.",schema:yd,async execute(i,n){let{page:a,agentServices:o,actionDescription:r}=n;try{let l={action_description:r||"Go back",action_data:{action_name:"go_back",kwargs:{}}};return await t.execute(a,l,o),{success:!0,actionEntity:l,message:"Navigated back"}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(r||"Go back")+" (failed)",action_data:{action_name:"go_back",kwargs:{}},feedback:l.message}}}}})}var zr,Vr,yd,oi=x(()=>{"use strict";j();zr=require("zod");I();Vr=class{async execute(e,t){await e.goBack({timeout:fe}),await e.waitForLoadState("load",{timeout:fe}),await e.waitForTimeout(1e3)}transpile(e){return['await agent.execAction("go_back", page, {});']}},yd=zr.z.object({})});function Yr(e,t){e.register({name:"go_to_url",description:"Navigate to a specific URL. Use this to visit web pages. Set new_tab=true to open in a new tab.",schema:bd,async execute(i,n){let{url:a,new_tab:o,timeout_seconds:r}=i,{page:l,agentServices:s,actionDescription:c}=n,d={url:a,new_tab:o??!1};r!==void 0&&(d.timeout_seconds=r);let u=r?` (timeout: ${r}s)`:"";try{let p=o?`Open ${a} in new tab`:`Navigate to ${a}`,h={action_description:c||p,action_data:{action_name:"go_to_url",kwargs:d}};return await t.execute(l,h,s),{success:!0,actionEntity:h,message:(o?`Opened ${a} in new tab`:`Navigated to ${a}`)+u}}catch(p){let h=o?`Open ${a} in new tab`:`Navigate to ${a}`;return{success:!1,error:p.message,actionEntity:{action_description:(c||h)+" (failed)",action_data:{action_name:"go_to_url",kwargs:d},feedback:p.message}}}}})}var ri,Ea,bd,si=x(()=>{"use strict";j();ri=require("zod");I();Ea=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.url;if(!a)throw new Error("Missing URL for go_to_url action");let o=n.kwargs.new_tab===!0,r=i.replaceVariables(String(a));if(r.startsWith("/")){let c=e.url(),d=null;try{let u=new URL(c);u.origin&&u.origin!=="null"&&(d=u.origin)}catch{}d&&(r=d+r)}let l=n.kwargs.timeout_seconds?n.kwargs.timeout_seconds*1e3:fe,s=e;o&&(s=await e.context().newPage(),i.setPage(s)),await s.goto(r,{timeout:l})}transpile(e){let t=e.action_data?.kwargs?.url||"",i=e.action_data?.kwargs?.new_tab===!0,n=e.action_data?.kwargs?.timeout_seconds,a=[`url: ${JSON.stringify(t)}`];return i&&a.push("new_tab: true"),n&&a.push(`timeout_seconds: ${n}`),['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { ${a.join(", ")} } },`,"});"]}},bd=ri.z.object({url:ri.z.string().describe('URL to navigate to (HTTP/HTTPS URL, or a path like "/home")'),new_tab:ri.z.boolean().optional().describe("If true, open the URL in a new tab instead of the current page. Default is false."),timeout_seconds:ri.z.number().positive().optional().describe("Navigation timeout in seconds. Default is 20 seconds.")})});async function xd(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function Jr(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function qr(e,t){e.register({name:"hover",description:"Hover over an interactive element.",schema:vd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:Jr(`Hover element ${a}`,"hover",{index:a})};let c=l||`Hover over element ${a}`,d=await xd("hover",c,s,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Hovered over element ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:Jr(`Hover element ${a}`,"hover",{index:a})}}}})}var gn,Ta,vd,li=x(()=>{"use strict";Y();j();gn=require("zod");I();Ta=class{async execute(e,t,i){let n=R(e,t),a=L(i,t.action_data?.kwargs?.timeout_ms);if(n){await n.waitFor({state:"attached",timeout:a});let o=await n.elementHandle();if(!o)throw new Error("Unable to obtain element handle for hover action");let r=await o.boundingBox();if(!r)throw new Error("Unable to determine bounding box for hover action");let l=r.x+r.width/2,s=r.y+r.height/2;await e.mouse.move(l,s)}else throw new Error("No locator found for hover action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("hover", page, {});']:['await agent.execAction("hover", page, {',...t.map(i=>` ${i},`),"});"]}};vd=gn.z.object({element_index:gn.z.number().int().describe("Index of the element to hover over"),timeout_ms:gn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Qr(e,t){e.register({name:"ai_extract",description:"Use AI to extract information from the page and save it to a variable. MCP-only tool.",schema:_d,async execute(i,n){let{element_description:a,variable_name:o}=i,{page:r,agentServices:l}=n;try{let s={action_description:`Extract ${a} to ${o}`,action_data:{action_name:"ai_extract",kwargs:{element_description:a,variable_name:o}}};return await t.execute(r,s,l),{success:!0,actionEntity:s,message:`Extracted ${a} to ${o}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:`Extract ${a} (failed)`,action_data:{action_name:"ai_extract",kwargs:{element_description:a,variable_name:o}},feedback:s.message}}}},availability:{openai:!1,mcp:!0}})}var fn,Zr,_d,ci=x(()=>{"use strict";fn=require("zod"),Zr=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.element_description,o=n.kwargs.variable_name;if(!a||!o)throw new Error("Missing element_description or variable_name for ai_extract");let r=`Extract ${a} and save to ${o}`,{executeStep:l}=await Promise.resolve().then(()=>(rt(),ot)),s=await l(r,e,i);if(s.status!=="success")throw new Error(s.error||"Extraction failed")}transpile(e,t){let i=e.action_data?.kwargs?.element_description,n=e.action_data?.kwargs?.variable_name;if(!i||!n)return["// Skipping ai_extract: missing element_description or variable_name"];let a=JSON.stringify(i),o=JSON.stringify(n);return[`await agent.extract(page, ${a}, ${o}, '${t||""}');`]}},_d=fn.z.object({element_description:fn.z.string().describe('Description of the element to extract (e.g., "the price of the product")'),variable_name:fn.z.string().describe("Name of the variable to store the extracted value")})});async function kd(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function es(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function is(e,t){e.register({name:"clear_input",description:"Clear the contents of an input field, textarea, or other editable element.",schema:Sd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Input element with index ${a} not found`,actionEntity:es(l||`Clear element ${a}`,"clear_input",{index:a})};let c=l||`Clear element ${a}`,d=await kd("clear_input",c,s,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Cleared element ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:es(`Clear element ${a}`,"clear_input",{index:a})}}}})}var wn,ts,Sd,di=x(()=>{"use strict";Y();j();wn=require("zod");I();ts=class{async execute(e,t,i){let n=R(e,t),a=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.click({timeout:a}),await e.keyboard.press("ControlOrMeta+a"),await e.waitForTimeout(200),await e.keyboard.press("Backspace"),await e.waitForTimeout(200);else throw new Error("No locator found for clear_input action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("clear_input", page, {});']:['await agent.execAction("clear_input", page, {',...t.map(i=>` ${i},`),"});"]}};Sd=wn.z.object({element_index:wn.z.number().int().describe("Index of the input element to clear"),timeout_ms:wn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function Ed(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function ns(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function as(e,t){e.register({name:"click",description:"Click an interactive element.",schema:Td,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:ns(`Click element ${a}`,"click",{index:a})};let c=l||`Click element ${a}`,d=await Ed("click",c,s,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Clicked element ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:ns(`Click element ${a}`,"click",{index:a})}}}})}var yn,bn,Td,ui=x(()=>{"use strict";Y();j();yn=require("zod");I();bn=class{async execute(e,t,i){let n=R(e,t),a=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.click({timeout:a});else throw new Error("No locator found for click action")}transpile(e){let t=Ne(e);if(!t)return['await agent.execAction("click", page, {});'];let i=L();return[`await ${t}.click({ timeout: ${i} });`]}};Td=yn.z.object({element_index:yn.z.number().int().describe("Index of the element to click (0-based). Return -1 if no element found"),timeout_ms:yn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function rs(e,t){e.register({name:"close_tab",description:"Close a browser tab by index. If no index is specified, closes the current tab.",schema:Ad,async execute(i,n){let{index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s={action_description:l||`Close tab ${a}`,action_data:{action_name:"close_tab",kwargs:{page_id:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Closed tab ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(l||"Close tab")+" (failed)",action_data:{action_name:"close_tab",kwargs:{}},feedback:s.message}}}}})}var Aa,os,Ad,hi=x(()=>{"use strict";Aa=require("zod"),os=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.page_id??n.kwargs.index;if(a===void 0&&(a=e.context().pages().indexOf(e)),typeof a=="number"){if(a===0)throw new Error("Cannot close the first tab (page_id 0). Skipping close_tab action.");i&&await i.closeTab(a)}else throw new Error("Missing page_id for close_tab action")}transpile(e){let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]}},Ad=Aa.z.object({index:Aa.z.number().int().nonnegative().optional().describe("Index of the tab to close (0-based). Defaults to current tab if not specified.")})});function ls(e,t){e.register({name:"done",description:"Mark the current task as complete. Use when you have finished all requested actions.",schema:$d,async execute(i,n){let{page:a,agentServices:o}=n;try{let r={action_description:"Task completed",action_data:{action_name:"done",kwargs:{}}};return await t.execute(a,r,o),{success:!0,actionEntity:r,message:"Task marked as complete"}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:"Task completed (failed)",action_data:{action_name:"done",kwargs:{}},feedback:r.message}}}}})}var xn,ss,$d,mi=x(()=>{"use strict";xn=require("zod"),ss=class{async execute(e,t){}transpile(e){return["// Done - no action needed"]}},$d=xn.z.object({success:xn.z.boolean().describe("Whether the task was completed successfully"),summary:xn.z.string().describe("Summary of what was accomplished or why it failed")})});async function Md(e,t,i,n,a={}){return{...await W(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function cs(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function ds(e,t){e.register({name:"double_click",description:"Double-click an interactive element.",schema:Id,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:l}=n;try{let s=await G(n,a);if(!s)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:cs(`Double-click element ${a}`,"double_click",{index:a})};let c=l||`Double-click element ${a}`,d=await Md("double_click",c,s,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Double-clicked element ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:cs(`Double-click element ${a}`,"double_click",{index:a})}}}})}var vn,$a,Id,pi=x(()=>{"use strict";Y();j();vn=require("zod");I();$a=class{async execute(e,t,i){let n=R(e,t),a=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.dblclick({timeout:a});else throw new Error("No locator found for double_click action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("double_click", page, {});']:['await agent.execAction("double_click", page, {',...t.map(i=>` ${i},`),"});"]}};Id=vn.z.object({element_index:vn.z.number().int().describe("Index of the element to double-click"),timeout_ms:vn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function hs(e){if(!e.trim())return!1;try{return(0,us.parse)(e,{sourceType:"module",plugins:["typescript"]}),!0}catch{return!1}}var us,_n=x(()=>{"use strict";us=require("@babel/parser")});function ms(e,t){e.register({name:"verify",description:"Verify that a statement is true based on the current page state. Use this to check assertions about the page content, element visibility, or any condition.",schema:Pd,async execute(i,n){let{statement:a}=i,{page:o,agentServices:r}=n;try{let l={action_description:`${a}`,action_data:{action_name:"verify",kwargs:{statement:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Assertion verified: ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Verify: ${a} (failed)`,action_data:{action_name:"verify",kwargs:{statement:a}},feedback:l.message}}}},availability:{openai:!0,mcp:!0}})}var Ma,kn,Pd,gi=x(()=>{"use strict";Nt();_n();U();Ma=require("zod"),kn=class{async execute(e,t,i){let n=t.action_data?.kwargs,a=typeof n?.code=="string",o=a?n?.statement||t.action_description:t.action_description||n?.statement;if(a&&o){let d=Date.now();try{await this.executeJSAssertion(e,n.code,i),w.info(`[VERIFY:JS] \u2713 ${((Date.now()-d)/1e3).toFixed(1)}s: ${o}`),i.addNote(`Assertion passed: ${o}`);return}catch(u){let p=((Date.now()-d)/1e3).toFixed(1);w.info(`[VERIFY:JS\u2192AI] JS failed ${p}s (${u instanceof Error?u.message:String(u)}), falling back to AI: ${o}`)}}else if(a){let d=Date.now();await this.executeJSAssertion(e,n.code,i),w.info(`[VERIFY:JS] \u2713 ${((Date.now()-d)/1e3).toFixed(1)}s: ${o||"js-only"}`),i.addNote(`Assertion passed: ${o||"js-only"}`);return}if(!o)throw new Error("Missing statement or code for verify action");let r=Date.now();w.info(`[VERIFY:AI] Evaluating: ${o}`);let{evaluateStatement:l}=await Promise.resolve().then(()=>(rt(),ot)),s=await l(o,e,i,{useCleanScreenshotForAssertion:!0}),c=s.explanation||s.error||(s.success?`Assertion passed: ${o}`:"Assertion failed");if(i.addNote(c),!s.success)throw w.info(`[VERIFY:AI] \u2717 ${((Date.now()-r)/1e3).toFixed(1)}s: ${o}`),new Error(s.error||s.explanation||"Assertion failed");w.info(`[VERIFY:AI] \u2713 ${((Date.now()-r)/1e3).toFixed(1)}s: ${o}`)}async executeJSAssertion(e,t,i){let n=i.agent;if(!n)throw new Error("Agent not initialized on AgentServices \u2014 ai_assert requires an agent reference");try{await new Function("page","expect","agent",`
|
|
4107
4107
|
return (async () => {
|
|
4108
4108
|
${t}
|
|
4109
4109
|
})();
|
|
@@ -4298,17 +4298,17 @@ ${h.join(`
|
|
|
4298
4298
|
`,n+=`- Use the EXACT placeholder name as shown above
|
|
4299
4299
|
`,n+=`- Do NOT use the actual value directly in the action
|
|
4300
4300
|
`,n+=`- The values shown are for context only to help you understand what data is available
|
|
4301
|
-
`,n+='- In action descriptions, describe what the placeholder represents in natural language (e.g., "Type the first user name" instead of "Type {{ firstUserName }}")',n}}});var wi=x(()=>{"use strict"});async function Hd(e,t){let i=new Set,n=Date.now(),a=new Set(["document","stylesheet","image","font","script","iframe"]),o=new Set(["text/html","text/css","application/javascript","image/","font/","application/json"]),r=["analytics","tracking","telemetry","beacon","metrics","doubleclick","adsystem","adserver","advertising","facebook.com/plugins","platform.twitter","linkedin.com/embed","livechat","zendesk","intercom","crisp.chat","hotjar","push-notifications","onesignal","pushwoosh","heartbeat","ping","alive","webrtc","rtmp://","wss://","cloudfront.net","fastly.net"],l=u=>{let p=u.toLowerCase();return p.startsWith("data:")||p.startsWith("blob:")?!0:r.some(h=>p.includes(h))},s=u=>{let p=u.resourceType(),h=u.url();if(!a.has(p)||l(h))return;let f=u.headers();f.purpose==="prefetch"||["video","audio"].includes(f["sec-fetch-dest"])||(i.add(u),n=Date.now())},c=async u=>{let p=u.request();if(!i.has(p))return;let h=(u.headers()["content-type"]||"").toLowerCase();if(["streaming","video","audio","webm","mp4","event-stream","websocket","protobuf"].some(g=>h.includes(g))){i.delete(p);return}if(![...o].some(g=>h.startsWith(g))){i.delete(p);return}let f=u.headers()["content-length"];if(f)try{if(parseInt(f,10)>5*1024*1024){i.delete(p);return}}catch{}i.delete(p),n=Date.now()},d=Date.now()-Fd;for(let u of await e.requests()){let p=u.resourceType(),h=u.url(),f=u.timing();a.has(p)&&!l(h)&&f.responseEnd===-1&&f.startTime>=d&&(i.add(u),n=Date.now())}w.debug(`[waitForStableNetwork] Pre-populated ${i.size} in-flight requests`),e.on("request",s),e.on("response",c);try{let u=Date.now(),p=Rd;for(;;){await new Promise(f=>setTimeout(f,100));let h=Date.now();if(i.size===0&&h-n>=p){w.debug(`[waitForStableNetwork] Network idle after ${h-u}ms`);break}if(h-u>t){w.debug(`[waitForStableNetwork] Max wait time exceeded (${t}ms), pending: ${i.size}`);break}}}finally{e.removeListener("request",s),e.removeListener("response",c)}}async function ct(e,t=Ld,i=Dd){let n=Date.now();try{await Promise.all([e.waitForLoadState("load",{timeout:t}).catch(()=>{}),Hd(e,t)])}catch(r){throw r instanceof Error?new Error(`Failed during network stabilization: ${r.message}`):new Error("An unknown error occurred during network stabilization.")}let a=Date.now()-n,o=Math.max(i-a,0);o>0&&await new Promise(r=>setTimeout(r,o))}var Dd,Ld,Rd,Fd,Le=x(()=>{"use strict";wi();U();Dd=.5*1e3,Ld=30*1e3,Rd=1*1e3,Fd=3*1e3});function Wd(e,t){return e?{prompt_tokens:e.promptTokens||e.inputTokens||0,completion_tokens:e.completionTokens||e.outputTokens||0,total_tokens:e.totalTokens||0,model:t}:null}async function ys(e,t,i={}){let n=Date.now();if(i.maxSteps!==void 0&&i.maxSteps<=0)throw new Error(`maxSteps must be >= 1, got ${i.maxSteps}`);let a=i.maxSteps??15,o=3,r=t.agentServices.getModel(),l=t.domService||new De(t.agentServices.getDomServiceOptions()),s={...t,domService:l};E.init(),E.section("Task Execution Started"),E.log(`Task: ${e}`),E.log(`Max steps: ${a}`),E.log(`Model: ${r}`);let c={currentStep:0,maxSteps:a,consecutiveFailures:0,maxFailures:o,lastFailReason:null,stepHistory:[],memory:[],lastGoal:null,lastEvaluation:null},d=[],u=$n(i.customPrompt),p=new In(u);E.log(`System prompt length: ${u.length} chars`);let h=!1,f="",g=[];try{for(i.onEvent?.({type:"start",task:e,maxSteps:a});c.currentStep<a;){if(i.abortSignal?.aborted)throw new Error("Task aborted by user");c.currentStep++;let y=Date.now();E.section(`Step ${c.currentStep}/${a}`),E.log(`URL: ${s.page.url()}`),i.onEvent?.({type:"step_start",step:c.currentStep});try{E.log("Waiting for page to stabilize..."),await ct(s.page),E.log("Page stabilized")}catch{E.log("Page stabilization timed out, continuing anyway")}let m;try{E.log("Preparing context (DOM + screenshot)...");let N=s.agentServices.getInteractiveClassNames(),O=s.agentServices.getIframeFallbackDomains();m=await fs(s.page,s.domService,N,O),E.log("Context prepared")}catch(N){if(N.message.includes("Execution context was destroyed")){E.log("Page navigating, waiting for load..."),await ct(s.page);let O=s.agentServices.getInteractiveClassNames(),D=s.agentServices.getIframeFallbackDomains();m=await fs(s.page,s.domService,O,D)}else throw E.error("Error preparing context",N),N}p.addStateMessage(e,m.currentUrl,m.domTree,m.screenshotBase64,c,{isFinalStep:c.currentStep===a-1,placeholderData:t.variables,sensitiveKeys:t.sensitiveKeys});let b=await Ud(p,r,i,m.screenshotBase64);if(b.tokenUsages&&b.tokenUsages.length>0&&d.push(...b.tokenUsages),!b.stepOutput){if(E.error("Failed to get valid LLM response"),c.consecutiveFailures++,c.consecutiveFailures>=o){f="Reached the maximum allowed consecutive failures. Most recent error: Unable to get a valid response from the language model.";break}continue}let v=b.stepOutput;zd(c.currentStep,a,v);let S=await Gd(v,s,m.domState,c.currentStep,i.onEvent,m.screenshotBase64,b.debugInfo);g.push(...S.actionEntities);let T=Kd(c.currentStep,v,S,c,y,b.debugInfo,b.tokenUsages),M=Date.now()-y;if(i.onEvent?.({type:"step_complete",step:c.currentStep,duration:M}),c.consecutiveFailures>=o){E.error(`Too many consecutive failures (${c.consecutiveFailures}), stopping`),f=`Reached the maximum allowed consecutive failures. Most recent error: ${c.lastFailReason}`;break}if(S.doneResult){h=S.doneResult.success,f=S.doneResult.summary;break}if(S.completesInstruction){h=!0,f="Instruction completed";break}}return c.currentStep>=a&&!h&&(f="Reached the maximum allowed steps."),i.onEvent?.({type:"complete",totalSteps:c.currentStep,duration:Date.now()-n}),E.log(`Build success result: summary=${f}, completed=${h}, actions=${g.length}, tokens=${d.length}`),Vd(c,g,h,f,n,d,r)}catch(y){let m=y.message;return E.error(`Task execution failed: ${m}`,y),i.onEvent?.({type:"error",error:m,recoverable:!1}),Xd(c,m,n,d,r)}}async function fs(e,t,i,n){let{domState:a,screenshotBase64:o}=await t.getClickableElementsWithScreenshot(e,{interactiveClassNames:i,playwrightFrameFallbackDomains:n}),r=a.elementTree.clickableElementsToString();return{currentUrl:e.url(),domTree:r,screenshotBase64:o,domState:a}}function jd(e){return e.map(t=>({role:t.role,content:Array.isArray(t.content)?t.content.map(i=>{if(i.type==="image"){let n=i.image,a=typeof n=="string"?n:"";return{type:"image",file:a.startsWith("data:")?a:`data:image/png;base64,${a}`}}return{type:"text",text:i.text}}):t.content}))}async function Ud(e,t,i,n){let a=i.temperature??0,{system:o,messages:r}=e.getMessages(),l=0;for(let u of r)Array.isArray(u.content)&&(l+=u.content.filter(p=>p.type==="image").length);let s=be(t,l),c={model:ye(t),system:o,messages:r,temperature:a,providerOptions:s},d=3;for(let u=0;u<d;u++)try{let p=Date.now();E.log(`Calling LLM (${t})...`);let h=await(0,ws.generateText)(c),f=Date.now()-p,g=h,y=g.usage;E.llmCall(t,f,y);let m=g.reasoningText;m&&(E.thinking(m),i.onEvent?.({type:"thinking",text:m})),e.addAssistantMessage(h.text);let b={systemPrompt:o,userPrompt:jd(r),rawLlmResponse:h.text,reasoningContent:m,screenshotWithSom:n},v=[],S=Wd(y,t);S&&v.push(S);let T=Bd(h.text);if(!T)if(u<d-1){E.log(`Attempt ${u+1}/${d}: Failed to parse response, retrying...`),e.addTextMessage("user","Your response was not valid JSON. Please respond with a properly formatted JSON object according to the expected format."),await new Promise(M=>setTimeout(M,i.retryDelay||1e3));continue}else return E.error("All parsing attempts failed"),{stepOutput:null,debugInfo:b,tokenUsages:v};return{stepOutput:T,debugInfo:b,tokenUsages:v}}catch(p){if(u<d-1){E.log(`Attempt ${u+1}/${d}: LLM call failed (${p.message}), retrying...`),await new Promise(h=>setTimeout(h,i.retryDelay||1e3));continue}else throw E.error("All LLM call attempts failed",p),p}return{stepOutput:null}}function Bd(e){let t=e.trim();t.startsWith("```json")?t=t.replace(/^```json\s*/,"").replace(/\s*```\s*$/,""):t.startsWith("```")&&(t=t.replace(/^```\s*/,"").replace(/\s*```\s*$/,""));try{let i=JSON.parse(t);if(!i.current_goal)return E.error("Missing required field: current_goal"),null;if(!i.actions||!Array.isArray(i.actions)||i.actions.length===0)return E.error("Missing required field: actions (must be non-empty array)"),null;for(let n of i.actions){if(!n.action_name)return E.error("Action missing required field: action_name"),null;if(!n.description)return E.error("Action missing required field: description"),null}return i}catch(i){return E.error(`Failed to parse LLM JSON response: ${t.substring(0,500)}`),E.error(`Parse error: ${i.message}`),null}}async function Gd(e,t,i,n,a,o,r){let l=[],s=!0,c=null;E.log(`Using pre-captured DOM state with ${i.selectorMap.size} elements for ${e.actions.length} action(s)`);let d=null,u={...t,domState:i},p=o;for(let h of e.actions){if(h.action_name==="done"){d={success:h.kwargs.success??!0,summary:h.kwargs.summary||h.kwargs.text||"Task completed"};break}let f={},g=h.kwargs?.element_index??h.kwargs?.index;if(typeof g=="number"){let m=i.selectorMap.get(g);m&&(f=await W(t.page,m))}let y={...f,action_description:h.description,action_data:{action_name:h.action_name,kwargs:h.kwargs}};try{let m=await B.execute(h.action_name,h.kwargs,u);h.action_name==="perform_accurate_operation"&&(y=m.actionEntity);let b=await u.agentServices.getCurrentPage();if(b&&(u.page=b,t.page=u.page),m?.success===!1){s=!1,E.log("Action failed, stopping execution of remaining actions in this step"),c=m.error||"Action execution failed";break}l.push(y),a?.({type:"action",action_entity:y,step:n,debugInfo:r})}catch(m){s=!1,c=m.message,E.error(`Action execution failed: ${m.message}`);break}}return{allSuccess:s,failReason:c,actionEntities:l,doneResult:d,completesInstruction:e.completes_instruction??!1}}function Kd(e,t,i,n,a,o,r){let l={stepNumber:e,thinking:t.thinking,evaluation:t.evaluation_previous_goal,memory:t.memory,goal:t.current_goal,actions:i.actionEntities,timestamp:a,duration:Date.now()-a,outcome:{success:i.allSuccess},debugInfo:o,tokenUsages:r};if(n.lastGoal=t.current_goal,t.evaluation_previous_goal&&(n.lastEvaluation=t.evaluation_previous_goal),t.memory&&t.memory.trim()){let s=t.memory.trim();n.memory.includes(s)||(n.memory.push(s),n.memory.length>10&&(n.memory=n.memory.slice(-10)))}return i.allSuccess?(n.consecutiveFailures=0,n.lastFailReason=null):(n.consecutiveFailures++,n.lastFailReason=i.failReason),n.stepHistory.push(l),l}function zd(e,t,i){if(E.log(`Step ${e}/${t}`),i.thinking&&E.log(`Thinking: ${i.thinking}`),i.evaluation_previous_goal&&E.log(`Evaluation: ${i.evaluation_previous_goal}`),i.memory&&E.log(`Memory: ${i.memory}`),E.log(`Goal: ${i.current_goal}`),i.actions.length===1){let n=i.actions[0];E.log(`Action: ${n.action_name}(${JSON.stringify(n.kwargs)}) - ${n.description}`)}else E.log(`Actions (${i.actions.length}):`),i.actions.forEach((n,a)=>{E.log(` ${a+1}. ${n.action_name}(${JSON.stringify(n.kwargs)}) - ${n.description}`)})}function Vd(e,t,i,n,a,o,r){let l=o.reduce((d,u)=>d+u.prompt_tokens,0),s=o.reduce((d,u)=>d+u.completion_tokens,0),c=o.reduce((d,u)=>d+u.total_tokens,0);return{success:!0,completed:i,summary:n,trajectory:{steps:e.currentStep,actions:t,stepRecords:e.stepHistory},metadata:{totalSteps:e.currentStep,totalDuration:Date.now()-a,model:r,successfulSteps:e.stepHistory.filter(d=>d.outcome.success).length,failedSteps:e.stepHistory.filter(d=>!d.outcome.success).length,promptTokens:l,completionTokens:s,totalTokens:c,tokenUsages:o}}}function Xd(e,t,i,n,a){let o=n.reduce((s,c)=>s+c.prompt_tokens,0),r=n.reduce((s,c)=>s+c.completion_tokens,0),l=n.reduce((s,c)=>s+c.total_tokens,0);return{success:!1,completed:!1,error:t,trajectory:{steps:e.currentStep,actions:[],stepRecords:e.stepHistory},metadata:{totalSteps:e.currentStep,totalDuration:Date.now()-i,model:a,successfulSteps:e.stepHistory.filter(s=>s.outcome.success).length,failedSteps:e.stepHistory.filter(s=>!s.outcome.success).length,promptTokens:o,completionTokens:r,totalTokens:l,tokenUsages:n}}}var ws,bs=x(()=>{"use strict";Na();Mn();Te();Ue();re();Le();xe();Y();ws=require("ai")});var xs={};Xe(xs,{TaskMessageManager:()=>In,formatFinalStepWarning:()=>ps,formatTaskContext:()=>An,getBrowserTaskJSONPrompt:()=>$n,runTaskLoop:()=>ys});var vs=x(()=>{"use strict";bs();Na();Mn();Te();nn();Ue();$t();Mt();nt();It();Pt();re();Le();wi();xe();_t();Ze();kt();Oe();qe();Y();He();U();oe();Ot();j();Se()});async function Dt(e,t){try{if(!e.action_data)return{success:!1,error:"Action entity missing action_data"};let{action_name:i,kwargs:n}=e.action_data;if(B.has(i)){let a=await B.execute(i,n,t),o=a?.success!==!1,r=a?.error||a?.message;return{success:o,error:o?void 0:r}}else{let{page:a,agentServices:o}=t;return await(await Yd()).execute(a,e,o),{success:!0,error:void 0}}}catch(i){return{success:!1,error:i.message}}}async function Yd(){if(Pn)return Pn;let e=await Promise.resolve().then(()=>(Tn(),En));return Pn=new e.default,Pn}async function an(e,t,i,n={},a){let o=a||{page:t,agentServices:i,domService:new De(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},r=i.replaceVariables(e),l=await oa(r,o,n);return l.status==="error"?{status:"error",completed:l.goalAccomplished||!1,actionEntities:[],explanation:l.reasoning,error:l.error,debugInfo:l.debugInfo}:{status:"success",completed:l.goalAccomplished||!1,actionEntities:l.actionEntity?[l.actionEntity]:[],explanation:l.reasoning,debugInfo:l.debugInfo}}async function on(e,t,i,n={},a){let o=a||{page:t,agentServices:i,domService:new De(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},r=i.replaceVariables(e),l=await oa(r,o,n);if(l.status==="error"||!l.actionEntity)return{status:"error",completed:l.goalAccomplished||!1,actionEntities:[],explanation:l.reasoning,error:l.error||"No action generated",debugInfo:l.debugInfo};let{actionEntity:s,reasoning:c,goalAccomplished:d,debugInfo:u}=l,p=await Dt(s,o);return p.success?(c&&i.addNote(c),{status:"success",completed:d||!1,actionEntities:[s],explanation:c,debugInfo:u}):{status:"error",completed:!1,actionEntities:[s],error:p.error||"Action execution failed",debugInfo:u}}async function rn(e,t,i,n={}){let a={page:t,agentServices:i,domService:new De(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},o=i.replaceVariables(e);return n.useCleanScreenshotForAssertion??(n.useCleanScreenshotForAssertion=i.isUseCleanScreenshotForAssertion()),Ho(o,a,n)}async function sn(e,t,i,n,a={}){let{runTaskLoop:o}=await Promise.resolve().then(()=>(vs(),xs)),r=n?s=>{n(s)}:void 0,l=await o(e,{page:t,agentServices:i,domService:void 0,executionHistory:a.executionHistory,variables:a.variables,sensitiveKeys:a.sensitiveKeys},{maxSteps:a.maxSteps,onEvent:r,abortSignal:a.abortSignal});return{status:l.success?"success":"error",completed:l.completed,actionEntities:l.trajectory.actions,explanation:l.summary,error:l.error,tokenUsages:l.metadata.tokenUsages}}var Pn,Lt=x(()=>{"use strict";zi();Te();Ue();Pn=null});var Ux,_,Kx,Qx,iv,Ws,Hx,js,iu,nu,Nn,Wx,jx,Da,La,au,Hs,ou,yi,ru,su,lu,ue,cu,du,Gx,tv,dt=x(()=>{"use strict";Se();Ux=require("uuid"),_=require("zod"),Kx=require("yaml"),Qx=require("uuid"),iv=require("yaml"),Ws=112,Hx=1080-Ws,js=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(js||{}),iu={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}},nu={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},Nn=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),nu[e].map(n=>iu[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},Wx={desktop:{label:"Desktop",type:"desktop",devices:Nn("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:Nn("mobile")}},jx={desktop:{label:"Desktop",type:"desktop",devices:Nn("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:Nn("mobile",!0)}},Da=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(Da||{}),La=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(La||{}),au=_.z.enum(["JS_CODE","AI_MODE"]),Hs=_.z.object({type:au,expression:_.z.string()}),ou=_.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),yi=_.z.object({uid:_.z.string(),type:ou,comment:_.z.string().optional()}),ru=_.z.object({action_data:_.z.object({action_name:_.z.string(),kwargs:_.z.record(_.z.any()).optional(),args:_.z.array(_.z.any()).optional()}),action_description:_.z.string().optional(),url:_.z.string().optional(),xpath:_.z.string().nullable().optional(),locator:_.z.string().nullable().optional(),css_selector:_.z.string().nullable().optional(),unique_selector:_.z.string().nullable().optional(),element_index:_.z.number().nullable().optional(),frame_path:_.z.array(_.z.any()).optional(),artifacts:_.z.record(_.z.any()).optional(),feedback:_.z.string().optional(),original_browser_use_action:_.z.any().optional()}).passthrough(),su=yi.extend({type:_.z.literal("DRAFT"),description:_.z.string()}),lu=yi.extend({type:_.z.literal("ACTION"),description:_.z.string(),action_entity:ru.optional(),locator:_.z.string().optional(),use_pure_vision:_.z.boolean().optional()}),ue=_.z.lazy(()=>_.z.union([su,lu,yi.extend({type:_.z.literal("STEP"),description:_.z.string().optional().default(""),statements:_.z.array(ue),reference_id:_.z.number().optional(),template_path:_.z.string().optional(),template_params:_.z.record(_.z.string()).optional()}),yi.extend({type:_.z.literal("IF_ELSE"),description:_.z.string().optional(),condition:Hs,then:_.z.array(ue),else:_.z.array(ue).optional()}),yi.extend({type:_.z.literal("WHILE_LOOP"),description:_.z.string().optional(),condition:Hs,body:_.z.array(ue),timeout_ms:_.z.number().optional()})])),cu=_.z.object({name:_.z.string(),statements:_.z.array(ue),teardown:_.z.array(ue).optional(),skip:_.z.union([_.z.boolean(),_.z.string()]).optional(),timeout:_.z.number().optional(),fail:_.z.union([_.z.boolean(),_.z.string()]).optional(),only:_.z.boolean().optional(),slow:_.z.boolean().optional()}),du=_.z.object({tests:_.z.array(cu).min(1),beforeAll:_.z.array(ue).optional(),afterAll:_.z.array(ue).optional(),beforeEach:_.z.array(ue).optional(),afterEach:_.z.array(ue).optional()}),Gx=_.z.object({comment:_.z.string().optional(),version:_.z.string().optional(),goal:_.z.string().optional(),url:_.z.string().optional(),baseURL:_.z.string().optional(),final_feedback:_.z.string().optional(),completed:_.z.boolean().optional(),success:_.z.boolean().optional(),statements:_.z.array(ue).optional(),teardown:_.z.array(ue).optional(),last_modified_at:_.z.string().optional(),testGroup:du.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"}),tv=1024*1024});var Wa=x(()=>{"use strict";re();Le()});var Xs=x(()=>{"use strict"});var Ys=x(()=>{"use strict"});var Js=x(()=>{"use strict"});var On=x(()=>{"use strict"});var qs=x(()=>{"use strict";On()});var Su,Zs=x(()=>{"use strict";Su=require("uuid")});var k,Qs,Ba,el,mt,tl,il,nl,le,al,Dn,Ga,Ka=x(()=>{"use strict";k=require("zod"),Qs=k.z.enum(["JS_CODE","AI_MODE"]),Ba=k.z.object({type:Qs,expression:k.z.string()}),el=k.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),mt=k.z.object({uid:k.z.string(),type:el,comment:k.z.string().optional()}),tl=k.z.object({action_data:k.z.object({action_name:k.z.string(),kwargs:k.z.record(k.z.any()).optional(),args:k.z.array(k.z.any()).optional()}),action_description:k.z.string().optional(),url:k.z.string().optional(),xpath:k.z.string().nullable().optional(),locator:k.z.string().nullable().optional(),css_selector:k.z.string().nullable().optional(),unique_selector:k.z.string().nullable().optional(),element_index:k.z.number().nullable().optional(),frame_path:k.z.array(k.z.any()).optional(),artifacts:k.z.record(k.z.any()).optional(),feedback:k.z.string().optional(),original_browser_use_action:k.z.any().optional()}).passthrough(),il=mt.extend({type:k.z.literal("DRAFT"),description:k.z.string()}),nl=mt.extend({type:k.z.literal("ACTION"),description:k.z.string(),action_entity:tl.optional(),locator:k.z.string().optional(),use_pure_vision:k.z.boolean().optional()}),le=k.z.lazy(()=>k.z.union([il,nl,mt.extend({type:k.z.literal("STEP"),description:k.z.string().optional().default(""),statements:k.z.array(le),reference_id:k.z.number().optional(),template_path:k.z.string().optional(),template_params:k.z.record(k.z.string()).optional()}),mt.extend({type:k.z.literal("IF_ELSE"),description:k.z.string().optional(),condition:Ba,then:k.z.array(le),else:k.z.array(le).optional()}),mt.extend({type:k.z.literal("WHILE_LOOP"),description:k.z.string().optional(),condition:Ba,body:k.z.array(le),timeout_ms:k.z.number().optional()})])),al=k.z.object({name:k.z.string(),statements:k.z.array(le),teardown:k.z.array(le).optional(),skip:k.z.union([k.z.boolean(),k.z.string()]).optional(),timeout:k.z.number().optional(),fail:k.z.union([k.z.boolean(),k.z.string()]).optional(),only:k.z.boolean().optional(),slow:k.z.boolean().optional()}),Dn=k.z.object({tests:k.z.array(al).min(1),beforeAll:k.z.array(le).optional(),afterAll:k.z.array(le).optional(),beforeEach:k.z.array(le).optional(),afterEach:k.z.array(le).optional()}),Ga=k.z.object({comment:k.z.string().optional(),version:k.z.string().optional(),goal:k.z.string().optional(),url:k.z.string().optional(),baseURL:k.z.string().optional(),final_feedback:k.z.string().optional(),completed:k.z.boolean().optional(),success:k.z.boolean().optional(),statements:k.z.array(le).optional(),teardown:k.z.array(le).optional(),last_modified_at:k.z.string().optional(),testGroup:Dn.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"})});function Ln(e,t){let i={...t?.test_case_id!==void 0?{test_case_id:t.test_case_id}:{},...t?.name?{name:t.name}:{},...t?.tags&&t.tags.length>0?{tags:t.tags}:{},...t?.skip!==void 0?{skip:t.skip}:{},...t?.fail!==void 0?{fail:t.fail}:{},...t?.only?{only:t.only}:{},...t?.slow?{slow:t.slow}:{},goal:e.goal??"",url:e.url,base_url:e.baseURL,...t?.timeout!==void 0?{timeout:t.timeout}:{},...t?.settings&&Object.keys(t.settings).length>0?{settings:t.settings}:{},...t?.use&&Object.keys(t.use).length>0?{use:t.use}:{},...t?.beforeEach&&t.beforeEach.length>0?{beforeEach:t.beforeEach}:{},...t?.afterEach&&t.afterEach.length>0?{afterEach:t.afterEach}:{},...t?.parameters&&t.parameters.length>0?{parameters:t.parameters}:{},statements:(e.statements??[]).map(me)};return e.final_feedback&&(i.final_feedback=e.final_feedback),e.teardown&&e.teardown.length>0&&(i.teardown=e.teardown.map(me)),i}function Va(e,t){if(e.testGroup)return cl(e,t);let i=Ln(e,t),n=new F.Document(i),a=n.contents?.get("tags",!0);return(0,F.isSeq)(a)&&(a.flow=!0),e.comment&&(n.commentBefore=e.comment),ol(n,e.statements??[]),e.teardown&&ol(n,e.teardown,"teardown"),n.toString(ll)}function ol(e,t,i="statements"){let n=e.contents;if(!n||!(0,F.isMap)(n))return;let a=n.get(i,!0);(0,F.isSeq)(a)&&xi(a,t)}function xi(e,t){for(let i=0;i<Math.min(e.items.length,t.length);i++){let n=t[i],a=e.items[i];if(i>0&&(a.spaceBefore=!0),n.comment&&(i===0?e.commentBefore=n.comment:a.commentBefore=n.comment),(0,F.isMap)(a)){let o=a;if(n.type==="STEP"){let r=o.get("statements",!0);(0,F.isSeq)(r)&&xi(r,n.statements)}else if(n.type==="IF_ELSE"){let r=o.get("THEN",!0);(0,F.isSeq)(r)&&xi(r,n.then);let l=o.get("ELSE",!0);(0,F.isSeq)(l)&&n.else&&xi(l,n.else)}else if(n.type==="WHILE_LOOP"){let r=o.get("DO",!0);(0,F.isSeq)(r)&&xi(r,n.body)}}}}function cl(e,t){let i=e.testGroup;if(!i)throw new Error("suiteToYaml requires a TestFlow with testGroup");let n={};t?.test_case_id!==void 0&&(n.test_case_id=t.test_case_id),t?.name&&(n.name=t.name),t?.tags&&t.tags.length>0&&(n.tags=t.tags),t?.use&&Object.keys(t.use).length>0&&(n.use=t.use),t?.settings&&Object.keys(t.settings).length>0&&(n.settings=t.settings);let a={};e.baseURL&&(a.base_url=e.baseURL),i.beforeAll&&i.beforeAll.length>0&&(a.beforeAll=i.beforeAll.map(me)),i.beforeEach&&i.beforeEach.length>0&&(a.beforeEach=i.beforeEach.map(me)),i.afterEach&&i.afterEach.length>0&&(a.afterEach=i.afterEach.map(me)),i.afterAll&&i.afterAll.length>0&&(a.afterAll=i.afterAll.map(me)),a.tests=i.tests.map(l=>{let s={name:l.name};return l.skip!==void 0&&(s.skip=l.skip),l.timeout!==void 0&&(s.timeout=l.timeout),l.fail!==void 0&&(s.fail=l.fail),l.only!==void 0&&(s.only=l.only),l.slow!==void 0&&(s.slow=l.slow),s.statements=l.statements.map(me),l.teardown&&l.teardown.length>0&&(s.teardown=l.teardown.map(me)),s}),n.suite=a;let o=new F.Document(n),r=o.contents?.get("tags",!0);return(0,F.isSeq)(r)&&(r.flow=!0),o.toString(ll)}function me(e){switch(e.type){case"DRAFT":return Eu(e);case"ACTION":return Tu(e);case"STEP":return Au(e);case"IF_ELSE":return $u(e);case"WHILE_LOOP":return Mu(e)}}function Eu(e){return{intent:e.description}}function Tu(e){let t=e.action_entity?.action_data?.action_name??e.action_entity?.action?.action_name,i=e.action_entity?.action_data?.kwargs??e.action_entity?.action?.kwargs;if(t==="verify"){let l=i?.statement;if(typeof l=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let s=i?.code;return typeof s=="string"&&s.trim()?{VERIFY:l,js:s}:{VERIFY:l}}}if(t==="go_to_url"){let l=i?.url;if(typeof l=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let s={URL:l};return i?.new_tab===!0&&(s.new_tab=!0),typeof i?.timeout_seconds=="number"&&(s.timeout_seconds=i.timeout_seconds),s}}if(t==="js_action"){let l=i?.code;if(typeof l=="string"&&l.trim()&&e.description)return{description:e.description,js:l}}if(t==="ai_wait_until"){let l=i?.condition;if(typeof l=="string"){let s={WAIT_UNTIL:l};return typeof i?.timeout_seconds=="number"&&i.timeout_seconds!==60&&(s.timeout_seconds=i.timeout_seconds),s}}if(t==="wait"){let l=i?.seconds,c={WAIT:e.description||`Wait ${l}s`};return typeof l=="number"&&(c.seconds=l),c}if(t==="js_code"){let l=i?.code;if(typeof l=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath)return{description:e.description||"Code block",js:l}}if(!e.action_entity)return{intent:e.description};let n=e.action_entity.action_data??e.action_entity.action;if(!n)return{intent:e.description};let a={intent:e.description,action:n.action_name},o=e.locator??e.action_entity.locator;o&&(a.locator=o);let r=e.action_entity.xpath;if(r&&(a.xpath=r),e.use_pure_vision&&(a.use_pure_vision=!0),n.kwargs&&Object.keys(n.kwargs).length>0)for(let[l,s]of Object.entries(n.kwargs))l!=="uid"&&(l==="statement"&&(t==="ai_action"||t==="ai_step")||(a[l]=s));return n.args&&n.args.length>0&&(a.args=n.args),a}function Au(e){if(e.template_path){let i={template:e.template_path};return e.template_params&&Object.keys(e.template_params).length>0&&(i.params=e.template_params),i}let t={STEP:e.description,statements:e.statements.map(me)};return e.reference_id!==void 0&&(t.reference_id=e.reference_id),t}function $u(e){let t={IF:dl(e.condition),THEN:e.then.map(me)};return e.else&&e.else.length>0&&(t.ELSE=e.else.map(me)),t}function Mu(e){let t={WHILE:dl(e.condition),DO:e.body.map(me)};return e.timeout_ms!==void 0&&(t.timeout_ms=e.timeout_ms),t}function dl(e){return e.type==="JS_CODE"?`js:${e.expression}`:e.expression}function Xa(e){try{let t=(0,F.parse)(e);if(!t||typeof t!="object")return{};let i={};return typeof t.test_case_id=="number"&&Number.isFinite(t.test_case_id)&&(i.test_case_id=t.test_case_id),typeof t.template_id=="number"&&Number.isFinite(t.template_id)&&(i.template_id=t.template_id),typeof t.name=="string"&&t.name.trim()&&(i.name=t.name.trim()),typeof t.timeout=="number"&&Number.isFinite(t.timeout)&&(i.timeout=t.timeout),t.settings&&typeof t.settings=="object"&&!Array.isArray(t.settings)&&(i.settings=t.settings),t.use&&typeof t.use=="object"&&!Array.isArray(t.use)&&(i.use=t.use),Array.isArray(t.tags)&&t.tags.every(n=>typeof n=="string")&&(i.tags=t.tags),(typeof t.skip=="boolean"||typeof t.skip=="string")&&(i.skip=t.skip),(typeof t.fail=="boolean"||typeof t.fail=="string")&&(i.fail=t.fail),t.only===!0&&(i.only=!0),t.slow===!0&&(i.slow=!0),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(i.beforeEach=t.beforeEach),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(i.afterEach=t.afterEach),Array.isArray(t.parameters)&&t.parameters.length>0&&(i.parameters=t.parameters),i}catch{return{}}}function za(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(za);let t=e,i=Object.keys(t);if(i.length===1){let a=i[0];if(a.startsWith("{ ")&&a.endsWith(" }")&&t[a]===null)return`{{${a.slice(2,-2)}}}`}let n={};for(let[a,o]of Object.entries(t))n[a]=za(o);return n}function $e(e){if(e.length>rl)throw new Error(`YAML input too large (${e.length} bytes, max ${rl})`);let t=za((0,F.parse)(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Iu(t);let i={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:pe(t.statements??[])};t.final_feedback&&(i.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(i.teardown=pe(t.teardown));let n=Ga.safeParse(i);if(!n.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(n.error.errors)}`);let a=n.data;return Rn(e,a),a}function Iu(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let i=t.tests;if(!Array.isArray(i)||i.length===0)throw new Error('Suite must have a non-empty "tests" array');let a={tests:i.map(l=>{if(!l.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(l.statements)||l.statements.length===0)throw new Error(`Suite test "${l.name}" must have a non-empty "statements" array`);let s={name:l.name,statements:pe(l.statements)};return Array.isArray(l.teardown)&&l.teardown.length>0&&(s.teardown=pe(l.teardown)),l.skip!==void 0&&(s.skip=l.skip),typeof l.timeout=="number"&&(s.timeout=l.timeout),l.fail!==void 0&&(s.fail=l.fail),l.only===!0&&(s.only=!0),l.slow===!0&&(s.slow=!0),s})};Array.isArray(t.beforeAll)&&t.beforeAll.length>0&&(a.beforeAll=pe(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(a.afterAll=pe(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(a.beforeEach=pe(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(a.afterEach=pe(t.afterEach));let o=Dn.safeParse(a);if(!o.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(o.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:o.data}}function pe(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(Pu)}function Pu(e){if(typeof e=="string")throw new Error(`Plain string statements are not supported. Use an object with a "desc" key instead. Example: { "desc": "${e}" }`);if(typeof e!="object"||e===null)throw new Error(`Invalid statement: expected object, got ${typeof e}`);let t=e;if("IF"in t)return Cu(t);if("WHILE"in t)return Nu(t);if("STEP"in t)return Ou(t);if("VERIFY"in t){let i=t.VERIFY,n={statement:typeof i=="string"?i:String(i)};return typeof t.js=="string"&&(n.code=t.js),{uid:(0,he.v4)(),type:"ACTION",description:String(i),action_entity:{action_description:String(i),action_data:{action_name:"verify",kwargs:n}}}}if("URL"in t){let i=t.URL,n=t.new_tab===!0?!0:void 0,a=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,o={url:typeof i=="string"?i:String(i)};return n&&(o.new_tab=!0),a!==void 0&&(o.timeout_seconds=a),{uid:(0,he.v4)(),type:"ACTION",description:`Navigate to ${i}`,action_entity:{action_description:`Navigate to ${i}`,action_data:{action_name:"go_to_url",kwargs:o}}}}if("WAIT_UNTIL"in t){let i=t.WAIT_UNTIL,n=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;return{uid:(0,he.v4)(),type:"ACTION",description:`Wait until: ${i}`,action_entity:{action_description:`Wait until: ${i}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof i=="string"?i:String(i),timeout_seconds:n}}}}}if("WAIT"in t){let i=t.WAIT,n=typeof t.seconds=="number"?t.seconds:3;return{uid:(0,he.v4)(),type:"ACTION",description:typeof i=="string"?i:`Wait ${n}s`,action_entity:{action_description:typeof i=="string"?i:`Wait ${n}s`,action_data:{action_name:"wait",kwargs:{seconds:n}}}}}if("CODE"in t){let i=t.CODE;if(i==null)throw new Error('CODE statement has no code. Use "CODE: |" followed by indented code on the next line.');let n=typeof t.description=="string"?t.description:"Code block";return{uid:(0,he.v4)(),type:"ACTION",description:n,action_entity:{action_description:n,action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("js"in t&&!("VERIFY"in t)&&!("action"in t)){if("intent"in t||"desc"in t)throw new Error("A `js:` statement uses `description:`, not `intent:`. Raw JS does not self-heal \u2014 use `description: + js:` for code, or express it as a structured action (`intent:` + `action:`/`locator:`) to keep self-healing.");let i=typeof t.description=="string"&&t.description.trim()!==""?t.description:"Code block",n=t.js;return{uid:(0,he.v4)(),type:"ACTION",description:i,action_entity:{action_description:i,action_data:{action_name:"js_code",kwargs:{code:typeof n=="string"?n:String(n)}}}}}if("call"in t&&typeof t.call=="string"){let{call:i,...n}=t;return sl({...n,action:"function",functionName:i})}if("action"in t)return sl(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:(0,he.v4)(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function ul(e){if(typeof e!="string")throw new Error(`Condition must be a string, got ${typeof e}`);return e.startsWith("js:")?{type:"JS_CODE",expression:e.slice(3)}:{type:"AI_MODE",expression:e}}function Cu(e){let t=ul(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let n={uid:(0,he.v4)(),type:"IF_ELSE",condition:t,then:pe(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(n.else=pe(e.ELSE)),n}function Nu(e){let t=ul(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let n={uid:(0,he.v4)(),type:"WHILE_LOOP",condition:t,body:pe(i)};return typeof e.timeout_ms=="number"&&(n.timeout_ms=e.timeout_ms),n}function Ou(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let i={uid:(0,he.v4)(),type:"STEP",description:t,statements:pe(e.statements)};if(typeof e.reference_id=="number"&&(i.reference_id=e.reference_id),typeof e.template_path=="string"&&(i.template_path=e.template_path),e.template_params&&typeof e.template_params=="object"&&!Array.isArray(e.template_params)){let n=e.template_params,a={};for(let[o,r]of Object.entries(n))a[o]=String(r);i.template_params=a}return i}function sl(e){let t=typeof e.action=="string"?e.action:String(e.action),i=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",n=typeof e.locator=="string"?e.locator:void 0,a=typeof e.xpath=="string"?e.xpath:void 0,o=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,r={};for(let[c,d]of Object.entries(e))Du.has(c)||(r[c]=d);t==="verify"&&typeof r.js=="string"&&(r.code=r.js,delete r.js),(t==="ai_action"||t==="ai_step")&&(r.statement===void 0&&(r.statement=i),o&&(r.use_pure_vision=!0));let l={action_description:i,action_data:{action_name:t,kwargs:Object.keys(r).length>0?r:{}}};n&&(l.locator=n),a&&(l.xpath=a);let s={uid:(0,he.v4)(),type:"ACTION",description:i,action_entity:l};return o&&(s.use_pure_vision=!0),s}function Rn(e,t){let i;try{i=(0,F.parseDocument)(e)}catch{return}let n=i.contents;if(!n||!(0,F.isMap)(n))return;if(i.commentBefore)t.comment=i.commentBefore;else{let s=n.items?.[0];s?.key&&s.key.commentBefore&&(t.comment=s.key.commentBefore)}let a=n,o=a.get("statements",!0);(0,F.isSeq)(o)&&t.statements&&pt(o,t.statements);let r=a.get("teardown",!0);(0,F.isSeq)(r)&&t.teardown&&pt(r,t.teardown)}function pt(e,t){e.commentBefore&&t.length>0&&(t[0].comment=e.commentBefore);for(let i=0;i<Math.min(e.items.length,t.length);i++){let n=e.items[i];n.commentBefore&&!(i===0&&e.commentBefore)&&(t[i].comment=n.commentBefore);let a=t[i];if(a.type==="STEP"&&(0,F.isMap)(n)){let o=n.get("statements",!0);(0,F.isSeq)(o)&&pt(o,a.statements)}else if(a.type==="IF_ELSE"&&(0,F.isMap)(n)){let o=n.get("THEN",!0);(0,F.isSeq)(o)&&pt(o,a.then);let r=n.get("ELSE",!0);(0,F.isSeq)(r)&&a.else&&pt(r,a.else)}else if(a.type==="WHILE_LOOP"&&(0,F.isMap)(n)){let o=n.get("DO",!0);(0,F.isSeq)(o)&&pt(o,a.body)}}}var F,he,ll,rl,Du,Fn=x(()=>{"use strict";Ka();F=require("yaml"),he=require("uuid");ll={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};rl=1024*1024;Du=new Set(["action","intent","desc","locator","xpath","use_pure_vision"])});var hl,ml=x(()=>{"use strict";Fn();hl=require("yaml")});var pl=x(()=>{"use strict";On();Fn()});var Ge,gl=x(()=>{"use strict";Ge=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(Ge||{})});var Hn=x(()=>{"use strict"});var fl=x(()=>{"use strict";Hn()});var wl=x(()=>{"use strict";Hn()});var yl,Hu,bl,xl,vi,Wu,ju,vl=x(()=>{"use strict";yl=112,Hu=1080-yl,bl={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}},xl={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},vi=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),xl[e].map(n=>bl[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},Wu={desktop:{label:"Desktop",type:"desktop",devices:vi("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:vi("mobile")}},ju={desktop:{label:"Desktop",type:"desktop",devices:vi("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:vi("mobile",!0)}}});var _l=x(()=>{"use strict"});var kl=x(()=>{"use strict"});var Sl=x(()=>{"use strict"});var El=x(()=>{"use strict"});var gt=x(()=>{"use strict";Xs();Ys();Js();qs();Zs();ml();pl();On();Fn();gl();Ka();fl();wl();Hn();vl();_l();kl();Sl();El()});function Ku(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function zu(e){let t=e.xpath;return typeof t=="string"&&t.trim()?!t.startsWith("xpath=")&&!t.startsWith("/")&&!t.startsWith("//")?`xpath=//${t}`:t.startsWith("xpath=")?t:`xpath=${t}`:null}function Ml(e){let t=Ku(e),i=e.locator;if(typeof i=="string"&&i.trim())return i=i.trim(),i.endsWith("first()")?`${t}.${i}`:`${t}.${i}.first()`;let n=zu(e);if(n){let a=JSON.stringify(n);return`${t}.locator(${a}).first()`}return null}function $(e,t){ne.set(e,t)}function Ke(e,t,i=[]){let n=[...i];return t.locator?n.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&n.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&n.push(`frame_path: ${JSON.stringify(t.frame_path)}`),n.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...n.map(a=>` ${a},`),"});"]}function Ya(e,t){let i=t.action_data?.kwargs||{},n=[];return typeof i.relative_x=="number"&&typeof i.relative_y=="number"?(n.push(`action_data: { kwargs: { relative_x: ${i.relative_x}, relative_y: ${i.relative_y} } }`),t.locator?n.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&n.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&n.push(`frame_path: ${JSON.stringify(t.frame_path)}`)):typeof i.x=="number"&&typeof i.y=="number"&&n.push(`action_data: { kwargs: { x: ${i.x}, y: ${i.y} } }`),[`await agent.execAction("${e}", page, {`,...n.map(a=>` ${a},`),"});"]}function Tl(e){let t=e.functionName;if(!t)return null;let i=Array.isArray(e.args)?e.args.map(String):Array.isArray(e.parameterValues)?e.parameterValues.map(String):[];if(i.length===0)return`await ${t}()`;let n=["page","testContext","request","agent"],a=["undefined","null","true","false"],o=i.map(r=>n.includes(r)||a.includes(r)||/^-?\d+(\.\d+)?$/.test(r)?r:r.startsWith("$")?`agent.agentServices.readVariable('${r.substring(1)}')`:`"${r}"`);return`await ${t}(${o.join(", ")})`}function Pl(e,t,i){let n={expandingPaths:new Set([(0,wt.resolve)(t)]),depth:0,referencedPaths:new Set,basePath:i},a={...e};Array.isArray(a.statements)&&(a.statements=Re(a.statements,t,n)),Array.isArray(a.teardown)&&(a.teardown=Re(a.teardown,t,n));for(let o of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(a[o])&&(a[o]=Re(a[o],t,n));return{doc:a,referencedTemplatePaths:Array.from(n.referencedPaths)}}function Re(e,t,i){let n=[];for(let a of e)if(Vu(a)){let o=Xu(a,t,i);n.push(o)}else n.push(Yu(a,t,i));return n}function Vu(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function Xu(e,t,i){if(i.depth>=Al)throw new Error(`Template expansion exceeded maximum depth of ${Al}. Check for deeply nested or circular template references.`);let n=(0,wt.resolve)((0,wt.dirname)(t),e.template),a=!(0,jn.existsSync)(n)&&i.basePath?(0,wt.resolve)(i.basePath,e.template):n;if(i.expandingPaths.has(a))throw new Error(`Circular template reference detected: ${a} is already being expanded. Stack: ${Array.from(i.expandingPaths).join(" \u2192 ")} \u2192 ${a}`);i.referencedPaths.add(a);let o;try{o=(0,jn.readFileSync)(a,"utf-8")}catch(f){throw new Error(`Failed to read template file: ${a} (referenced from ${t}): ${f.message}`)}let r=(0,_i.parse)(o);if(!r||typeof r!="object")throw new Error(`Invalid template file: ${a} \u2014 expected a YAML object`);let l=r.params||[],s=e.params||{};for(let f of l)if(!(f in s))throw new Error(`Template ${e.template} requires param "${f}" but it was not provided. Required params: [${l.join(", ")}]`);let c=r.statements;if(!Array.isArray(c))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(s).length>0){let g=(0,_i.stringify)(c);for(let[y,m]of Object.entries(s))g=g.split(`<<${y}>>`).join(String(m));c=(0,_i.parse)(g)}let d={expandingPaths:new Set([...i.expandingPaths,a]),depth:i.depth+1,referencedPaths:i.referencedPaths},u=Re(c,a,d),h={STEP:r.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:u};return Object.keys(s).length>0&&(h.template_params=s),h}function Yu(e,t,i){if(typeof e!="object"||e===null)return e;let n={...e};return Array.isArray(n.statements)&&(n.statements=Re(n.statements,t,i)),Array.isArray(n.THEN)&&(n.THEN=Re(n.THEN,t,i)),Array.isArray(n.ELSE)&&(n.ELSE=Re(n.ELSE,t,i)),Array.isArray(n.DO)&&(n.DO=Re(n.DO,t,i)),n}function Nl(e,t,i){let n=(0,ki.parse)(e),a=n?.name,o=n?.tags,r=n?.use;if(n&&(n.name!==void 0||n.tags!==void 0||n.use!==void 0)&&(delete n.name,delete n.tags,delete n.use),n?.suite){if(n.goal||n.statements)throw new Cl('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return qu(n,a,o,r,t,i)}return Ju(n,a,o,r,t,i)}function Ju(e,t,i,n,a,o){let r=e?.beforeEach,l=e?.afterEach,s=Ol(e?.parameters),c=e?.timeout,d=e?.skip,u=e?.fail,p=e?.only,h=e?.slow;if(e&&(delete e.beforeEach,delete e.afterEach,delete e.parameters,delete e.timeout,delete e.skip,delete e.fail,delete e.only,delete e.slow),e?.url)throw new Cl(`The "url" field is not supported in local YAML tests. Use "base_url: ${e.url}" and add "- URL: /" as the first statement instead.`);e&&!e.goal&&t&&(e.goal=t);let f=[];if(a&&e&&typeof e=="object"){let m=Pl(e,a,o);e=m.doc,f=m.referencedTemplatePaths}let g=(0,ki.stringify)(e),y=$e(g);return a&&(ft(y.statements??[],a,"main"),y.teardown&&ft(y.teardown,a,"teardown")),{testFlow:y,name:t,tags:i,use:n,beforeEach:r,afterEach:l,parameters:s,timeout:c,skip:d,fail:u,only:p,slow:h,referencedTemplatePaths:f}}function qu(e,t,i,n,a,o){let r=e.suite;if(!Array.isArray(r.tests)||r.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let l=r.beforeAll,s=r.afterAll,c=r.beforeEach,d=r.afterEach,u=[],p=r.tests.map(g=>{if(!g.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(g.statements)||g.statements.length===0)throw new Error(`Suite test "${g.name}" must have a non-empty "statements" array.`);let y={goal:g.name,statements:g.statements};g.teardown&&(y.teardown=g.teardown);let m=[],b=y;if(a&&typeof y=="object"){let M=Pl(y,a,o);b=M.doc,m=M.referencedTemplatePaths,u.push(...m)}let v=(0,ki.stringify)(b),S=$e(v),T=Ol(g.parameters);return{testFlow:S,name:g.name,tags:Array.isArray(g.tags)?g.tags:void 0,parameters:T,timeout:g.timeout,skip:g.skip,fail:g.fail,only:g.only,slow:g.slow}}),h=r.base_url,f=h?{...n,baseURL:h}:n;return{suite:{beforeAll:l,afterAll:s,beforeEach:c,afterEach:d,tests:p},name:t,tags:i,use:f,referencedTemplatePaths:u}}function Ol(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,i)=>{if(!t.name)throw new Error(`Parameter set at index ${i} must have a "name" field.`);if(!t.values||typeof t.values!="object")throw new Error(`Parameter set "${t.name}" must have a "values" object.`);return{name:t.name,values:t.values}})}function ft(e,t,i){for(let n=0;n<e.length;n++){let a=e[n],o=`${i}.${n}`,r=a.description||"";if(a.uid=Zu(t,o,r),a.type===Ge.STEP)ft(a.statements,t,o);else if(a.type===Ge.IF_ELSE){let l=a;ft(l.then,t,`${o}.then`),l.else&&ft(l.else,t,`${o}.else`)}else a.type===Ge.WHILE_LOOP&&ft(a.body,t,`${o}.body`)}}function Zu(e,t,i){let n=(0,Il.createHash)("sha256").update(`${e}:${t}:${i}`).digest("hex");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20,32)}`}var Gu,Wn,Il,ki,jn,wt,_i,$l,ne,Al,Cl,Dl=x(()=>{"use strict";gt();Gu=require("yaml");gt();Wn=Z(require("path"),1),Il=require("crypto"),ki=require("yaml");gt();jn=require("fs"),wt=require("path"),_i=require("yaml");gt();$l=5e3;ne=new Map;$("click",e=>{let t=Ml(e);if(!t)return['await agent.execAction("click", page, {});'];let i=e.action_data?.kwargs?.timeout_ms??$l;return[`await ${t}.click({ timeout: ${i} });`]});$("click_element",ne.get("click"));$("click_element_by_index",ne.get("click"));$("double_click",e=>Ke("double_click",e));$("double_click_on_element",ne.get("double_click"));$("right_click",e=>Ke("right_click",e));$("right_click_on_element",ne.get("right_click"));$("hover",e=>Ke("hover",e));$("hover_element_by_index",ne.get("hover"));$("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return Ke("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});$("fill",ne.get("input_text"));$("clear_input",e=>Ke("clear_input",e));$("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});$("send_keys",ne.get("press"));$("send_keys_on_element",e=>{let t=Ml(e),i=e.action_data?.kwargs?.keys||"";if(!t)return['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(i)} } },`,"});"];let n=e.action_data?.kwargs?.timeout_ms??$l;return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${n} });`]});$("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return Ke("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});$("scroll",e=>{let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]});$("scroll_down",ne.get("scroll"));$("scroll_up",ne.get("scroll"));$("scroll_element",ne.get("scroll"));$("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});$("scroll_on_element",e=>Ke("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));$("go_to_url",e=>{let t=e.action_data?.kwargs?.url||"";return e.action_data?.kwargs?.new_tab===!0?['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)}, new_tab: true } },`,"});"]:['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)} } },`,"});"]});$("open_tab",ne.get("go_to_url"));$("go_back",()=>['await agent.execAction("go_back", page, {});']);$("reload_page",()=>['await agent.execAction("reload_page", page, {});']);$("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);$("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);$("verify",(e,t)=>{let i=e.action_data?.kwargs,n=typeof i?.code=="string",a=n?i?.statement||e.action_description:e.action_description||i?.statement;if(n&&a){let r=i.code.split(`
|
|
4301
|
+
`,n+='- In action descriptions, describe what the placeholder represents in natural language (e.g., "Type the first user name" instead of "Type {{ firstUserName }}")',n}}});var wi=x(()=>{"use strict"});async function Hd(e,t){let i=new Set,n=Date.now(),a=new Set(["document","stylesheet","image","font","script","iframe"]),o=new Set(["text/html","text/css","application/javascript","image/","font/","application/json"]),r=["analytics","tracking","telemetry","beacon","metrics","doubleclick","adsystem","adserver","advertising","facebook.com/plugins","platform.twitter","linkedin.com/embed","livechat","zendesk","intercom","crisp.chat","hotjar","push-notifications","onesignal","pushwoosh","heartbeat","ping","alive","webrtc","rtmp://","wss://","cloudfront.net","fastly.net"],l=u=>{let p=u.toLowerCase();return p.startsWith("data:")||p.startsWith("blob:")?!0:r.some(h=>p.includes(h))},s=u=>{let p=u.resourceType(),h=u.url();if(!a.has(p)||l(h))return;let f=u.headers();f.purpose==="prefetch"||["video","audio"].includes(f["sec-fetch-dest"])||(i.add(u),n=Date.now())},c=async u=>{let p=u.request();if(!i.has(p))return;let h=(u.headers()["content-type"]||"").toLowerCase();if(["streaming","video","audio","webm","mp4","event-stream","websocket","protobuf"].some(g=>h.includes(g))){i.delete(p);return}if(![...o].some(g=>h.startsWith(g))){i.delete(p);return}let f=u.headers()["content-length"];if(f)try{if(parseInt(f,10)>5*1024*1024){i.delete(p);return}}catch{}i.delete(p),n=Date.now()},d=Date.now()-Fd;for(let u of await e.requests()){let p=u.resourceType(),h=u.url(),f=u.timing();a.has(p)&&!l(h)&&f.responseEnd===-1&&f.startTime>=d&&(i.add(u),n=Date.now())}w.debug(`[waitForStableNetwork] Pre-populated ${i.size} in-flight requests`),e.on("request",s),e.on("response",c);try{let u=Date.now(),p=Rd;for(;;){await new Promise(f=>setTimeout(f,100));let h=Date.now();if(i.size===0&&h-n>=p){w.debug(`[waitForStableNetwork] Network idle after ${h-u}ms`);break}if(h-u>t){w.debug(`[waitForStableNetwork] Max wait time exceeded (${t}ms), pending: ${i.size}`);break}}}finally{e.removeListener("request",s),e.removeListener("response",c)}}async function ct(e,t=Ld,i=Dd){let n=Date.now();try{await Promise.all([e.waitForLoadState("load",{timeout:t}).catch(()=>{}),Hd(e,t)])}catch(r){throw r instanceof Error?new Error(`Failed during network stabilization: ${r.message}`):new Error("An unknown error occurred during network stabilization.")}let a=Date.now()-n,o=Math.max(i-a,0);o>0&&await new Promise(r=>setTimeout(r,o))}var Dd,Ld,Rd,Fd,Le=x(()=>{"use strict";wi();U();Dd=.5*1e3,Ld=30*1e3,Rd=1*1e3,Fd=3*1e3});function Wd(e,t){return e?{prompt_tokens:e.promptTokens||e.inputTokens||0,completion_tokens:e.completionTokens||e.outputTokens||0,total_tokens:e.totalTokens||0,model:t}:null}async function ys(e,t,i={}){let n=Date.now();if(i.maxSteps!==void 0&&i.maxSteps<=0)throw new Error(`maxSteps must be >= 1, got ${i.maxSteps}`);let a=i.maxSteps??15,o=3,r=t.agentServices.getModel(),l=t.domService||new De(t.agentServices.getDomServiceOptions()),s={...t,domService:l};E.init(),E.section("Task Execution Started"),E.log(`Task: ${e}`),E.log(`Max steps: ${a}`),E.log(`Model: ${r}`);let c={currentStep:0,maxSteps:a,consecutiveFailures:0,maxFailures:o,lastFailReason:null,stepHistory:[],memory:[],lastGoal:null,lastEvaluation:null},d=[],u=$n(i.customPrompt),p=new In(u);E.log(`System prompt length: ${u.length} chars`);let h=!1,f="",g=[];try{for(i.onEvent?.({type:"start",task:e,maxSteps:a});c.currentStep<a;){if(i.abortSignal?.aborted)throw new Error("Task aborted by user");c.currentStep++;let y=Date.now();E.section(`Step ${c.currentStep}/${a}`),E.log(`URL: ${s.page.url()}`),i.onEvent?.({type:"step_start",step:c.currentStep});try{E.log("Waiting for page to stabilize..."),await ct(s.page),E.log("Page stabilized")}catch{E.log("Page stabilization timed out, continuing anyway")}let m;try{E.log("Preparing context (DOM + screenshot)...");let N=s.agentServices.getInteractiveClassNames(),O=s.agentServices.getIframeFallbackDomains();m=await fs(s.page,s.domService,N,O),E.log("Context prepared")}catch(N){if(N.message.includes("Execution context was destroyed")){E.log("Page navigating, waiting for load..."),await ct(s.page);let O=s.agentServices.getInteractiveClassNames(),D=s.agentServices.getIframeFallbackDomains();m=await fs(s.page,s.domService,O,D)}else throw E.error("Error preparing context",N),N}p.addStateMessage(e,m.currentUrl,m.domTree,m.screenshotBase64,c,{isFinalStep:c.currentStep===a-1,placeholderData:t.variables,sensitiveKeys:t.sensitiveKeys});let b=await Ud(p,r,i,m.screenshotBase64);if(b.tokenUsages&&b.tokenUsages.length>0&&d.push(...b.tokenUsages),!b.stepOutput){if(E.error("Failed to get valid LLM response"),c.consecutiveFailures++,c.consecutiveFailures>=o){f="Reached the maximum allowed consecutive failures. Most recent error: Unable to get a valid response from the language model.";break}continue}let v=b.stepOutput;zd(c.currentStep,a,v);let S=await Gd(v,s,m.domState,c.currentStep,i.onEvent,m.screenshotBase64,b.debugInfo);g.push(...S.actionEntities);let T=Kd(c.currentStep,v,S,c,y,b.debugInfo,b.tokenUsages),M=Date.now()-y;if(i.onEvent?.({type:"step_complete",step:c.currentStep,duration:M}),c.consecutiveFailures>=o){E.error(`Too many consecutive failures (${c.consecutiveFailures}), stopping`),f=`Reached the maximum allowed consecutive failures. Most recent error: ${c.lastFailReason}`;break}if(S.doneResult){h=S.doneResult.success,f=S.doneResult.summary;break}if(S.completesInstruction){h=!0,f="Instruction completed";break}}return c.currentStep>=a&&!h&&(f="Reached the maximum allowed steps."),i.onEvent?.({type:"complete",totalSteps:c.currentStep,duration:Date.now()-n}),E.log(`Build success result: summary=${f}, completed=${h}, actions=${g.length}, tokens=${d.length}`),Vd(c,g,h,f,n,d,r)}catch(y){let m=y.message;return E.error(`Task execution failed: ${m}`,y),i.onEvent?.({type:"error",error:m,recoverable:!1}),Xd(c,m,n,d,r)}}async function fs(e,t,i,n){let{domState:a,screenshotBase64:o}=await t.getClickableElementsWithScreenshot(e,{interactiveClassNames:i,playwrightFrameFallbackDomains:n}),r=a.elementTree.clickableElementsToString();return{currentUrl:e.url(),domTree:r,screenshotBase64:o,domState:a}}function jd(e){return e.map(t=>({role:t.role,content:Array.isArray(t.content)?t.content.map(i=>{if(i.type==="image"){let n=i.image,a=typeof n=="string"?n:"";return{type:"image",file:a.startsWith("data:")?a:`data:image/png;base64,${a}`}}return{type:"text",text:i.text}}):t.content}))}async function Ud(e,t,i,n){let a=i.temperature??0,{system:o,messages:r}=e.getMessages(),l=0;for(let u of r)Array.isArray(u.content)&&(l+=u.content.filter(p=>p.type==="image").length);let s=be(t,l),c={model:ye(t),system:o,messages:r,temperature:a,providerOptions:s},d=3;for(let u=0;u<d;u++)try{let p=Date.now();E.log(`Calling LLM (${t})...`);let h=await(0,ws.generateText)(c),f=Date.now()-p,g=h,y=g.usage;E.llmCall(t,f,y);let m=g.reasoningText;m&&(E.thinking(m),i.onEvent?.({type:"thinking",text:m})),e.addAssistantMessage(h.text);let b={systemPrompt:o,userPrompt:jd(r),rawLlmResponse:h.text,reasoningContent:m,screenshotWithSom:n},v=[],S=Wd(y,t);S&&v.push(S);let T=Bd(h.text);if(!T)if(u<d-1){E.log(`Attempt ${u+1}/${d}: Failed to parse response, retrying...`),e.addTextMessage("user","Your response was not valid JSON. Please respond with a properly formatted JSON object according to the expected format."),await new Promise(M=>setTimeout(M,i.retryDelay||1e3));continue}else return E.error("All parsing attempts failed"),{stepOutput:null,debugInfo:b,tokenUsages:v};return{stepOutput:T,debugInfo:b,tokenUsages:v}}catch(p){if(u<d-1){E.log(`Attempt ${u+1}/${d}: LLM call failed (${p.message}), retrying...`),await new Promise(h=>setTimeout(h,i.retryDelay||1e3));continue}else throw E.error("All LLM call attempts failed",p),p}return{stepOutput:null}}function Bd(e){let t=e.trim();t.startsWith("```json")?t=t.replace(/^```json\s*/,"").replace(/\s*```\s*$/,""):t.startsWith("```")&&(t=t.replace(/^```\s*/,"").replace(/\s*```\s*$/,""));try{let i=JSON.parse(t);if(!i.current_goal)return E.error("Missing required field: current_goal"),null;if(!i.actions||!Array.isArray(i.actions)||i.actions.length===0)return E.error("Missing required field: actions (must be non-empty array)"),null;for(let n of i.actions){if(!n.action_name)return E.error("Action missing required field: action_name"),null;if(!n.description)return E.error("Action missing required field: description"),null}return i}catch(i){return E.error(`Failed to parse LLM JSON response: ${t.substring(0,500)}`),E.error(`Parse error: ${i.message}`),null}}async function Gd(e,t,i,n,a,o,r){let l=[],s=!0,c=null;E.log(`Using pre-captured DOM state with ${i.selectorMap.size} elements for ${e.actions.length} action(s)`);let d=null,u={...t,domState:i},p=o;for(let h of e.actions){if(h.action_name==="done"){d={success:h.kwargs.success??!0,summary:h.kwargs.summary||h.kwargs.text||"Task completed"};break}let f={},g=h.kwargs?.element_index??h.kwargs?.index;if(typeof g=="number"){let m=i.selectorMap.get(g);m&&(f=await W(t.page,m))}let y={...f,action_description:h.description,action_data:{action_name:h.action_name,kwargs:h.kwargs}};try{let m=await B.execute(h.action_name,h.kwargs,u);h.action_name==="perform_accurate_operation"&&(y=m.actionEntity);let b=await u.agentServices.getCurrentPage();if(b&&(u.page=b,t.page=u.page),m?.success===!1){s=!1,E.log("Action failed, stopping execution of remaining actions in this step"),c=m.error||"Action execution failed";break}l.push(y),a?.({type:"action",action_entity:y,step:n,debugInfo:r})}catch(m){s=!1,c=m.message,E.error(`Action execution failed: ${m.message}`);break}}return{allSuccess:s,failReason:c,actionEntities:l,doneResult:d,completesInstruction:e.completes_instruction??!1}}function Kd(e,t,i,n,a,o,r){let l={stepNumber:e,thinking:t.thinking,evaluation:t.evaluation_previous_goal,memory:t.memory,goal:t.current_goal,actions:i.actionEntities,timestamp:a,duration:Date.now()-a,outcome:{success:i.allSuccess},debugInfo:o,tokenUsages:r};if(n.lastGoal=t.current_goal,t.evaluation_previous_goal&&(n.lastEvaluation=t.evaluation_previous_goal),t.memory&&t.memory.trim()){let s=t.memory.trim();n.memory.includes(s)||(n.memory.push(s),n.memory.length>10&&(n.memory=n.memory.slice(-10)))}return i.allSuccess?(n.consecutiveFailures=0,n.lastFailReason=null):(n.consecutiveFailures++,n.lastFailReason=i.failReason),n.stepHistory.push(l),l}function zd(e,t,i){if(E.log(`Step ${e}/${t}`),i.thinking&&E.log(`Thinking: ${i.thinking}`),i.evaluation_previous_goal&&E.log(`Evaluation: ${i.evaluation_previous_goal}`),i.memory&&E.log(`Memory: ${i.memory}`),E.log(`Goal: ${i.current_goal}`),i.actions.length===1){let n=i.actions[0];E.log(`Action: ${n.action_name}(${JSON.stringify(n.kwargs)}) - ${n.description}`)}else E.log(`Actions (${i.actions.length}):`),i.actions.forEach((n,a)=>{E.log(` ${a+1}. ${n.action_name}(${JSON.stringify(n.kwargs)}) - ${n.description}`)})}function Vd(e,t,i,n,a,o,r){let l=o.reduce((d,u)=>d+u.prompt_tokens,0),s=o.reduce((d,u)=>d+u.completion_tokens,0),c=o.reduce((d,u)=>d+u.total_tokens,0);return{success:!0,completed:i,summary:n,trajectory:{steps:e.currentStep,actions:t,stepRecords:e.stepHistory},metadata:{totalSteps:e.currentStep,totalDuration:Date.now()-a,model:r,successfulSteps:e.stepHistory.filter(d=>d.outcome.success).length,failedSteps:e.stepHistory.filter(d=>!d.outcome.success).length,promptTokens:l,completionTokens:s,totalTokens:c,tokenUsages:o}}}function Xd(e,t,i,n,a){let o=n.reduce((s,c)=>s+c.prompt_tokens,0),r=n.reduce((s,c)=>s+c.completion_tokens,0),l=n.reduce((s,c)=>s+c.total_tokens,0);return{success:!1,completed:!1,error:t,trajectory:{steps:e.currentStep,actions:[],stepRecords:e.stepHistory},metadata:{totalSteps:e.currentStep,totalDuration:Date.now()-i,model:a,successfulSteps:e.stepHistory.filter(s=>s.outcome.success).length,failedSteps:e.stepHistory.filter(s=>!s.outcome.success).length,promptTokens:o,completionTokens:r,totalTokens:l,tokenUsages:n}}}var ws,bs=x(()=>{"use strict";Na();Mn();Te();Ue();re();Le();xe();Y();ws=require("ai")});var xs={};Xe(xs,{TaskMessageManager:()=>In,formatFinalStepWarning:()=>ps,formatTaskContext:()=>An,getBrowserTaskJSONPrompt:()=>$n,runTaskLoop:()=>ys});var vs=x(()=>{"use strict";bs();Na();Mn();Te();nn();Ue();$t();Mt();nt();It();Pt();re();Le();wi();xe();_t();Ze();kt();Oe();qe();Y();He();U();oe();Ot();j();Se()});async function Dt(e,t){try{if(!e.action_data)return{success:!1,error:"Action entity missing action_data"};let{action_name:i,kwargs:n}=e.action_data;if(B.has(i)){let a=await B.execute(i,n,t),o=a?.success!==!1,r=a?.error||a?.message;return{success:o,error:o?void 0:r}}else{let{page:a,agentServices:o}=t;return await(await Yd()).execute(a,e,o),{success:!0,error:void 0}}}catch(i){return{success:!1,error:i.message}}}async function Yd(){if(Pn)return Pn;let e=await Promise.resolve().then(()=>(Tn(),En));return Pn=new e.default,Pn}async function an(e,t,i,n={},a){let o=a||{page:t,agentServices:i,domService:new De(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},r=i.replaceVariables(e),l=await oa(r,o,n);return l.status==="error"?{status:"error",completed:l.goalAccomplished||!1,actionEntities:[],explanation:l.reasoning,error:l.error,debugInfo:l.debugInfo}:{status:"success",completed:l.goalAccomplished||!1,actionEntities:l.actionEntity?[l.actionEntity]:[],explanation:l.reasoning,debugInfo:l.debugInfo}}async function on(e,t,i,n={},a){let o=a||{page:t,agentServices:i,domService:new De(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},r=i.replaceVariables(e),l=await oa(r,o,n);if(l.status==="error"||!l.actionEntity)return{status:"error",completed:l.goalAccomplished||!1,actionEntities:[],explanation:l.reasoning,error:l.error||"No action generated",debugInfo:l.debugInfo};let{actionEntity:s,reasoning:c,goalAccomplished:d,debugInfo:u}=l,p=await Dt(s,o);return p.success?(c&&i.addNote(c),{status:"success",completed:d||!1,actionEntities:[s],explanation:c,debugInfo:u}):{status:"error",completed:!1,actionEntities:[s],error:p.error||"Action execution failed",debugInfo:u}}async function rn(e,t,i,n={}){let a={page:t,agentServices:i,domService:new De(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},o=i.replaceVariables(e);return n.useCleanScreenshotForAssertion??(n.useCleanScreenshotForAssertion=i.isUseCleanScreenshotForAssertion()),Ho(o,a,n)}async function sn(e,t,i,n,a={}){let{runTaskLoop:o}=await Promise.resolve().then(()=>(vs(),xs)),r=n?s=>{n(s)}:void 0,l=await o(e,{page:t,agentServices:i,domService:void 0,executionHistory:a.executionHistory,variables:a.variables,sensitiveKeys:a.sensitiveKeys},{maxSteps:a.maxSteps,onEvent:r,abortSignal:a.abortSignal});return{status:l.success?"success":"error",completed:l.completed,actionEntities:l.trajectory.actions,explanation:l.summary,error:l.error,tokenUsages:l.metadata.tokenUsages}}var Pn,Lt=x(()=>{"use strict";zi();Te();Ue();Pn=null});var Bx,_,zx,ev,nv,Ws,Wx,js,iu,nu,Nn,jx,Ux,Da,La,au,Hs,ou,yi,ru,su,lu,ue,cu,du,Kx,iv,dt=x(()=>{"use strict";Se();Bx=require("uuid"),_=require("zod"),zx=require("yaml"),ev=require("uuid"),nv=require("yaml"),Ws=112,Wx=1080-Ws,js=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(js||{}),iu={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}},nu={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},Nn=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),nu[e].map(n=>iu[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},jx={desktop:{label:"Desktop",type:"desktop",devices:Nn("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:Nn("mobile")}},Ux={desktop:{label:"Desktop",type:"desktop",devices:Nn("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:Nn("mobile",!0)}},Da=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(Da||{}),La=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(La||{}),au=_.z.enum(["JS_CODE","AI_MODE"]),Hs=_.z.object({type:au,expression:_.z.string()}),ou=_.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),yi=_.z.object({uid:_.z.string(),type:ou,comment:_.z.string().optional()}),ru=_.z.object({action_data:_.z.object({action_name:_.z.string(),kwargs:_.z.record(_.z.any()).optional(),args:_.z.array(_.z.any()).optional()}),action_description:_.z.string().optional(),url:_.z.string().optional(),xpath:_.z.string().nullable().optional(),locator:_.z.string().nullable().optional(),css_selector:_.z.string().nullable().optional(),unique_selector:_.z.string().nullable().optional(),element_index:_.z.number().nullable().optional(),frame_path:_.z.array(_.z.any()).optional(),artifacts:_.z.record(_.z.any()).optional(),feedback:_.z.string().optional(),original_browser_use_action:_.z.any().optional()}).passthrough(),su=yi.extend({type:_.z.literal("DRAFT"),description:_.z.string()}),lu=yi.extend({type:_.z.literal("ACTION"),description:_.z.string(),action_entity:ru.optional(),locator:_.z.string().optional(),use_pure_vision:_.z.boolean().optional()}),ue=_.z.lazy(()=>_.z.union([su,lu,yi.extend({type:_.z.literal("STEP"),description:_.z.string().optional().default(""),statements:_.z.array(ue),reference_id:_.z.number().optional(),template_path:_.z.string().optional(),template_params:_.z.record(_.z.string()).optional()}),yi.extend({type:_.z.literal("IF_ELSE"),description:_.z.string().optional(),condition:Hs,then:_.z.array(ue),else:_.z.array(ue).optional()}),yi.extend({type:_.z.literal("WHILE_LOOP"),description:_.z.string().optional(),condition:Hs,body:_.z.array(ue),timeout_ms:_.z.number().optional()})])),cu=_.z.object({name:_.z.string(),statements:_.z.array(ue),teardown:_.z.array(ue).optional(),skip:_.z.union([_.z.boolean(),_.z.string()]).optional(),timeout:_.z.number().optional(),fail:_.z.union([_.z.boolean(),_.z.string()]).optional(),only:_.z.boolean().optional(),slow:_.z.boolean().optional()}),du=_.z.object({tests:_.z.array(cu).min(1),beforeAll:_.z.array(ue).optional(),afterAll:_.z.array(ue).optional(),beforeEach:_.z.array(ue).optional(),afterEach:_.z.array(ue).optional()}),Kx=_.z.object({comment:_.z.string().optional(),version:_.z.string().optional(),goal:_.z.string().optional(),url:_.z.string().optional(),baseURL:_.z.string().optional(),final_feedback:_.z.string().optional(),completed:_.z.boolean().optional(),success:_.z.boolean().optional(),statements:_.z.array(ue).optional(),teardown:_.z.array(ue).optional(),last_modified_at:_.z.string().optional(),testGroup:du.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"}),iv=1024*1024});var Wa=x(()=>{"use strict";re();Le()});var Xs=x(()=>{"use strict"});var Ys=x(()=>{"use strict"});var Js=x(()=>{"use strict"});var On=x(()=>{"use strict"});var qs=x(()=>{"use strict";On()});var Eu,Zs=x(()=>{"use strict";Eu=require("uuid")});var k,Qs,Ba,el,mt,tl,il,nl,le,al,Dn,Ga,Ka=x(()=>{"use strict";k=require("zod"),Qs=k.z.enum(["JS_CODE","AI_MODE"]),Ba=k.z.object({type:Qs,expression:k.z.string()}),el=k.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),mt=k.z.object({uid:k.z.string(),type:el,comment:k.z.string().optional()}),tl=k.z.object({action_data:k.z.object({action_name:k.z.string(),kwargs:k.z.record(k.z.any()).optional(),args:k.z.array(k.z.any()).optional()}),action_description:k.z.string().optional(),url:k.z.string().optional(),xpath:k.z.string().nullable().optional(),locator:k.z.string().nullable().optional(),css_selector:k.z.string().nullable().optional(),unique_selector:k.z.string().nullable().optional(),element_index:k.z.number().nullable().optional(),frame_path:k.z.array(k.z.any()).optional(),artifacts:k.z.record(k.z.any()).optional(),feedback:k.z.string().optional(),original_browser_use_action:k.z.any().optional()}).passthrough(),il=mt.extend({type:k.z.literal("DRAFT"),description:k.z.string()}),nl=mt.extend({type:k.z.literal("ACTION"),description:k.z.string(),action_entity:tl.optional(),locator:k.z.string().optional(),use_pure_vision:k.z.boolean().optional()}),le=k.z.lazy(()=>k.z.union([il,nl,mt.extend({type:k.z.literal("STEP"),description:k.z.string().optional().default(""),statements:k.z.array(le),reference_id:k.z.number().optional(),template_path:k.z.string().optional(),template_params:k.z.record(k.z.string()).optional()}),mt.extend({type:k.z.literal("IF_ELSE"),description:k.z.string().optional(),condition:Ba,then:k.z.array(le),else:k.z.array(le).optional()}),mt.extend({type:k.z.literal("WHILE_LOOP"),description:k.z.string().optional(),condition:Ba,body:k.z.array(le),timeout_ms:k.z.number().optional()})])),al=k.z.object({name:k.z.string(),statements:k.z.array(le),teardown:k.z.array(le).optional(),skip:k.z.union([k.z.boolean(),k.z.string()]).optional(),timeout:k.z.number().optional(),fail:k.z.union([k.z.boolean(),k.z.string()]).optional(),only:k.z.boolean().optional(),slow:k.z.boolean().optional()}),Dn=k.z.object({tests:k.z.array(al).min(1),beforeAll:k.z.array(le).optional(),afterAll:k.z.array(le).optional(),beforeEach:k.z.array(le).optional(),afterEach:k.z.array(le).optional()}),Ga=k.z.object({comment:k.z.string().optional(),version:k.z.string().optional(),goal:k.z.string().optional(),url:k.z.string().optional(),baseURL:k.z.string().optional(),final_feedback:k.z.string().optional(),completed:k.z.boolean().optional(),success:k.z.boolean().optional(),statements:k.z.array(le).optional(),teardown:k.z.array(le).optional(),last_modified_at:k.z.string().optional(),testGroup:Dn.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"})});function Ln(e,t){let i={...t?.test_case_id!==void 0?{test_case_id:t.test_case_id}:{},...t?.name?{name:t.name}:{},...t?.tags&&t.tags.length>0?{tags:t.tags}:{},...t?.skip!==void 0?{skip:t.skip}:{},...t?.fail!==void 0?{fail:t.fail}:{},...t?.only?{only:t.only}:{},...t?.slow?{slow:t.slow}:{},goal:e.goal??"",url:e.url,base_url:e.baseURL,...t?.timeout!==void 0?{timeout:t.timeout}:{},...t?.settings&&Object.keys(t.settings).length>0?{settings:t.settings}:{},...t?.use&&Object.keys(t.use).length>0?{use:t.use}:{},...t?.beforeEach&&t.beforeEach.length>0?{beforeEach:t.beforeEach}:{},...t?.afterEach&&t.afterEach.length>0?{afterEach:t.afterEach}:{},...t?.parameters&&t.parameters.length>0?{parameters:t.parameters}:{},statements:(e.statements??[]).map(me)};return e.final_feedback&&(i.final_feedback=e.final_feedback),e.teardown&&e.teardown.length>0&&(i.teardown=e.teardown.map(me)),i}function Va(e,t){if(e.testGroup)return cl(e,t);let i=Ln(e,t),n=new F.Document(i),a=n.contents?.get("tags",!0);return(0,F.isSeq)(a)&&(a.flow=!0),e.comment&&(n.commentBefore=e.comment),ol(n,e.statements??[]),e.teardown&&ol(n,e.teardown,"teardown"),n.toString(ll)}function ol(e,t,i="statements"){let n=e.contents;if(!n||!(0,F.isMap)(n))return;let a=n.get(i,!0);(0,F.isSeq)(a)&&xi(a,t)}function xi(e,t){for(let i=0;i<Math.min(e.items.length,t.length);i++){let n=t[i],a=e.items[i];if(i>0&&(a.spaceBefore=!0),n.comment&&(i===0?e.commentBefore=n.comment:a.commentBefore=n.comment),(0,F.isMap)(a)){let o=a;if(n.type==="STEP"){let r=o.get("statements",!0);(0,F.isSeq)(r)&&xi(r,n.statements)}else if(n.type==="IF_ELSE"){let r=o.get("THEN",!0);(0,F.isSeq)(r)&&xi(r,n.then);let l=o.get("ELSE",!0);(0,F.isSeq)(l)&&n.else&&xi(l,n.else)}else if(n.type==="WHILE_LOOP"){let r=o.get("DO",!0);(0,F.isSeq)(r)&&xi(r,n.body)}}}}function cl(e,t){let i=e.testGroup;if(!i)throw new Error("suiteToYaml requires a TestFlow with testGroup");let n={};t?.test_case_id!==void 0&&(n.test_case_id=t.test_case_id),t?.name&&(n.name=t.name),t?.tags&&t.tags.length>0&&(n.tags=t.tags),t?.use&&Object.keys(t.use).length>0&&(n.use=t.use),t?.settings&&Object.keys(t.settings).length>0&&(n.settings=t.settings);let a={};e.baseURL&&(a.base_url=e.baseURL),i.beforeAll&&i.beforeAll.length>0&&(a.beforeAll=i.beforeAll.map(me)),i.beforeEach&&i.beforeEach.length>0&&(a.beforeEach=i.beforeEach.map(me)),i.afterEach&&i.afterEach.length>0&&(a.afterEach=i.afterEach.map(me)),i.afterAll&&i.afterAll.length>0&&(a.afterAll=i.afterAll.map(me)),a.tests=i.tests.map(l=>{let s={name:l.name};return l.skip!==void 0&&(s.skip=l.skip),l.timeout!==void 0&&(s.timeout=l.timeout),l.fail!==void 0&&(s.fail=l.fail),l.only!==void 0&&(s.only=l.only),l.slow!==void 0&&(s.slow=l.slow),s.statements=l.statements.map(me),l.teardown&&l.teardown.length>0&&(s.teardown=l.teardown.map(me)),s}),n.suite=a;let o=new F.Document(n),r=o.contents?.get("tags",!0);return(0,F.isSeq)(r)&&(r.flow=!0),o.toString(ll)}function me(e){switch(e.type){case"DRAFT":return Tu(e);case"ACTION":return Au(e);case"STEP":return $u(e);case"IF_ELSE":return Mu(e);case"WHILE_LOOP":return Iu(e)}}function Tu(e){return{intent:e.description}}function Au(e){let t=e.action_entity?.action_data?.action_name??e.action_entity?.action?.action_name,i=e.action_entity?.action_data?.kwargs??e.action_entity?.action?.kwargs;if(t==="verify"){let l=i?.statement;if(typeof l=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let s=i?.code;return typeof s=="string"&&s.trim()?{VERIFY:l,js:s}:{VERIFY:l}}}if(t==="go_to_url"){let l=i?.url;if(typeof l=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let s={URL:l};return i?.new_tab===!0&&(s.new_tab=!0),typeof i?.timeout_seconds=="number"&&(s.timeout_seconds=i.timeout_seconds),s}}if(t==="js_action"){let l=i?.code;if(typeof l=="string"&&l.trim()&&e.description)return{description:e.description,js:l}}if(t==="ai_wait_until"){let l=i?.condition;if(typeof l=="string"){let s={WAIT_UNTIL:l};return typeof i?.timeout_seconds=="number"&&i.timeout_seconds!==60&&(s.timeout_seconds=i.timeout_seconds),s}}if(t==="wait"){let l=i?.seconds,c={WAIT:e.description||`Wait ${l}s`};return typeof l=="number"&&(c.seconds=l),c}if(t==="js_code"){let l=i?.code;if(typeof l=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath)return{description:e.description||"Code block",js:l}}if(!e.action_entity)return{intent:e.description};let n=e.action_entity.action_data??e.action_entity.action;if(!n)return{intent:e.description};let a={intent:e.description,action:n.action_name},o=e.locator??e.action_entity.locator;o&&(a.locator=o);let r=e.action_entity.xpath;if(r&&(a.xpath=r),e.use_pure_vision&&(a.use_pure_vision=!0),n.kwargs&&Object.keys(n.kwargs).length>0)for(let[l,s]of Object.entries(n.kwargs))l!=="uid"&&(l==="statement"&&(t==="ai_action"||t==="ai_step")||(a[l]=s));return n.args&&n.args.length>0&&(a.args=n.args),a}function $u(e){if(e.template_path){let i={template:e.template_path};return e.template_params&&Object.keys(e.template_params).length>0&&(i.params=e.template_params),i}let t={STEP:e.description,statements:e.statements.map(me)};return e.reference_id!==void 0&&(t.reference_id=e.reference_id),t}function Mu(e){let t={IF:dl(e.condition),THEN:e.then.map(me)};return e.else&&e.else.length>0&&(t.ELSE=e.else.map(me)),t}function Iu(e){let t={WHILE:dl(e.condition),DO:e.body.map(me)};return e.timeout_ms!==void 0&&(t.timeout_ms=e.timeout_ms),t}function dl(e){return e.type==="JS_CODE"?`js:${e.expression}`:e.expression}function Xa(e){try{let t=(0,F.parse)(e);if(!t||typeof t!="object")return{};let i={};return typeof t.test_case_id=="number"&&Number.isFinite(t.test_case_id)&&(i.test_case_id=t.test_case_id),typeof t.template_id=="number"&&Number.isFinite(t.template_id)&&(i.template_id=t.template_id),typeof t.name=="string"&&t.name.trim()&&(i.name=t.name.trim()),typeof t.timeout=="number"&&Number.isFinite(t.timeout)&&(i.timeout=t.timeout),t.settings&&typeof t.settings=="object"&&!Array.isArray(t.settings)&&(i.settings=t.settings),t.use&&typeof t.use=="object"&&!Array.isArray(t.use)&&(i.use=t.use),Array.isArray(t.tags)&&t.tags.every(n=>typeof n=="string")&&(i.tags=t.tags),(typeof t.skip=="boolean"||typeof t.skip=="string")&&(i.skip=t.skip),(typeof t.fail=="boolean"||typeof t.fail=="string")&&(i.fail=t.fail),t.only===!0&&(i.only=!0),t.slow===!0&&(i.slow=!0),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(i.beforeEach=t.beforeEach),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(i.afterEach=t.afterEach),Array.isArray(t.parameters)&&t.parameters.length>0&&(i.parameters=t.parameters),i}catch{return{}}}function za(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(za);let t=e,i=Object.keys(t);if(i.length===1){let a=i[0];if(a.startsWith("{ ")&&a.endsWith(" }")&&t[a]===null)return`{{${a.slice(2,-2)}}}`}let n={};for(let[a,o]of Object.entries(t))n[a]=za(o);return n}function $e(e){if(e.length>rl)throw new Error(`YAML input too large (${e.length} bytes, max ${rl})`);let t=za((0,F.parse)(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Pu(t);let i={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:pe(t.statements??[])};t.final_feedback&&(i.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(i.teardown=pe(t.teardown));let n=Ga.safeParse(i);if(!n.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(n.error.errors)}`);let a=n.data;return Rn(e,a),a}function Pu(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let i=t.tests;if(!Array.isArray(i)||i.length===0)throw new Error('Suite must have a non-empty "tests" array');let a={tests:i.map(l=>{if(!l.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(l.statements)||l.statements.length===0)throw new Error(`Suite test "${l.name}" must have a non-empty "statements" array`);let s={name:l.name,statements:pe(l.statements)};return Array.isArray(l.teardown)&&l.teardown.length>0&&(s.teardown=pe(l.teardown)),l.skip!==void 0&&(s.skip=l.skip),typeof l.timeout=="number"&&(s.timeout=l.timeout),l.fail!==void 0&&(s.fail=l.fail),l.only===!0&&(s.only=!0),l.slow===!0&&(s.slow=!0),s})};Array.isArray(t.beforeAll)&&t.beforeAll.length>0&&(a.beforeAll=pe(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(a.afterAll=pe(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(a.beforeEach=pe(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(a.afterEach=pe(t.afterEach));let o=Dn.safeParse(a);if(!o.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(o.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:o.data}}function pe(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(Cu)}function Cu(e){if(typeof e=="string")throw new Error(`Plain string statements are not supported. Use an object with a "desc" key instead. Example: { "desc": "${e}" }`);if(typeof e!="object"||e===null)throw new Error(`Invalid statement: expected object, got ${typeof e}`);let t=e;if("IF"in t)return Nu(t);if("WHILE"in t)return Ou(t);if("STEP"in t)return Du(t);if("VERIFY"in t){let i=t.VERIFY,n={statement:typeof i=="string"?i:String(i)};return typeof t.js=="string"&&(n.code=t.js),{uid:(0,he.v4)(),type:"ACTION",description:String(i),action_entity:{action_description:String(i),action_data:{action_name:"verify",kwargs:n}}}}if("URL"in t){let i=t.URL,n=t.new_tab===!0?!0:void 0,a=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,o={url:typeof i=="string"?i:String(i)};return n&&(o.new_tab=!0),a!==void 0&&(o.timeout_seconds=a),{uid:(0,he.v4)(),type:"ACTION",description:`Navigate to ${i}`,action_entity:{action_description:`Navigate to ${i}`,action_data:{action_name:"go_to_url",kwargs:o}}}}if("WAIT_UNTIL"in t){let i=t.WAIT_UNTIL,n=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;return{uid:(0,he.v4)(),type:"ACTION",description:`Wait until: ${i}`,action_entity:{action_description:`Wait until: ${i}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof i=="string"?i:String(i),timeout_seconds:n}}}}}if("WAIT"in t){let i=t.WAIT,n=typeof t.seconds=="number"?t.seconds:3;return{uid:(0,he.v4)(),type:"ACTION",description:typeof i=="string"?i:`Wait ${n}s`,action_entity:{action_description:typeof i=="string"?i:`Wait ${n}s`,action_data:{action_name:"wait",kwargs:{seconds:n}}}}}if("CODE"in t){let i=t.CODE;if(i==null)throw new Error('CODE statement has no code. Use "CODE: |" followed by indented code on the next line.');let n=typeof t.description=="string"?t.description:"Code block";return{uid:(0,he.v4)(),type:"ACTION",description:n,action_entity:{action_description:n,action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("js"in t&&!("VERIFY"in t)&&!("action"in t)){if("intent"in t||"desc"in t)throw new Error("A `js:` statement uses `description:`, not `intent:`. Raw JS does not self-heal \u2014 use `description: + js:` for code, or express it as a structured action (`intent:` + `action:`/`locator:`) to keep self-healing.");let i=typeof t.description=="string"&&t.description.trim()!==""?t.description:"Code block",n=t.js;return{uid:(0,he.v4)(),type:"ACTION",description:i,action_entity:{action_description:i,action_data:{action_name:"js_code",kwargs:{code:typeof n=="string"?n:String(n)}}}}}if("call"in t&&typeof t.call=="string"){let{call:i,...n}=t;return sl({...n,action:"function",functionName:i})}if("action"in t)return sl(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:(0,he.v4)(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function ul(e){if(typeof e!="string")throw new Error(`Condition must be a string, got ${typeof e}`);return e.startsWith("js:")?{type:"JS_CODE",expression:e.slice(3)}:{type:"AI_MODE",expression:e}}function Nu(e){let t=ul(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let n={uid:(0,he.v4)(),type:"IF_ELSE",condition:t,then:pe(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(n.else=pe(e.ELSE)),n}function Ou(e){let t=ul(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let n={uid:(0,he.v4)(),type:"WHILE_LOOP",condition:t,body:pe(i)};return typeof e.timeout_ms=="number"&&(n.timeout_ms=e.timeout_ms),n}function Du(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let i={uid:(0,he.v4)(),type:"STEP",description:t,statements:pe(e.statements)};if(typeof e.reference_id=="number"&&(i.reference_id=e.reference_id),typeof e.template_path=="string"&&(i.template_path=e.template_path),e.template_params&&typeof e.template_params=="object"&&!Array.isArray(e.template_params)){let n=e.template_params,a={};for(let[o,r]of Object.entries(n))a[o]=String(r);i.template_params=a}return i}function sl(e){let t=typeof e.action=="string"?e.action:String(e.action),i=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",n=typeof e.locator=="string"?e.locator:void 0,a=typeof e.xpath=="string"?e.xpath:void 0,o=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,r={};for(let[c,d]of Object.entries(e))Lu.has(c)||(r[c]=d);t==="verify"&&typeof r.js=="string"&&(r.code=r.js,delete r.js),(t==="ai_action"||t==="ai_step")&&(r.statement===void 0&&(r.statement=i),o&&(r.use_pure_vision=!0));let l={action_description:i,action_data:{action_name:t,kwargs:Object.keys(r).length>0?r:{}}};n&&(l.locator=n),a&&(l.xpath=a);let s={uid:(0,he.v4)(),type:"ACTION",description:i,action_entity:l};return o&&(s.use_pure_vision=!0),s}function Rn(e,t){let i;try{i=(0,F.parseDocument)(e)}catch{return}let n=i.contents;if(!n||!(0,F.isMap)(n))return;if(i.commentBefore)t.comment=i.commentBefore;else{let s=n.items?.[0];s?.key&&s.key.commentBefore&&(t.comment=s.key.commentBefore)}let a=n,o=a.get("statements",!0);(0,F.isSeq)(o)&&t.statements&&pt(o,t.statements);let r=a.get("teardown",!0);(0,F.isSeq)(r)&&t.teardown&&pt(r,t.teardown)}function pt(e,t){e.commentBefore&&t.length>0&&(t[0].comment=e.commentBefore);for(let i=0;i<Math.min(e.items.length,t.length);i++){let n=e.items[i];n.commentBefore&&!(i===0&&e.commentBefore)&&(t[i].comment=n.commentBefore);let a=t[i];if(a.type==="STEP"&&(0,F.isMap)(n)){let o=n.get("statements",!0);(0,F.isSeq)(o)&&pt(o,a.statements)}else if(a.type==="IF_ELSE"&&(0,F.isMap)(n)){let o=n.get("THEN",!0);(0,F.isSeq)(o)&&pt(o,a.then);let r=n.get("ELSE",!0);(0,F.isSeq)(r)&&a.else&&pt(r,a.else)}else if(a.type==="WHILE_LOOP"&&(0,F.isMap)(n)){let o=n.get("DO",!0);(0,F.isSeq)(o)&&pt(o,a.body)}}}var F,he,ll,rl,Lu,Fn=x(()=>{"use strict";Ka();F=require("yaml"),he=require("uuid");ll={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};rl=1024*1024;Lu=new Set(["action","intent","desc","locator","xpath","use_pure_vision"])});var hl,ml=x(()=>{"use strict";Fn();hl=require("yaml")});var pl=x(()=>{"use strict";On();Fn()});var Ge,gl=x(()=>{"use strict";Ge=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(Ge||{})});var Hn=x(()=>{"use strict"});var fl=x(()=>{"use strict";Hn()});var wl=x(()=>{"use strict";Hn()});var yl,Wu,bl,xl,vi,ju,Uu,vl=x(()=>{"use strict";yl=112,Wu=1080-yl,bl={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}},xl={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},vi=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),xl[e].map(n=>bl[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},ju={desktop:{label:"Desktop",type:"desktop",devices:vi("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:vi("mobile")}},Uu={desktop:{label:"Desktop",type:"desktop",devices:vi("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:vi("mobile",!0)}}});var _l=x(()=>{"use strict"});var kl=x(()=>{"use strict"});var Sl=x(()=>{"use strict"});var El=x(()=>{"use strict"});var gt=x(()=>{"use strict";Xs();Ys();Js();qs();Zs();ml();pl();On();Fn();gl();Ka();fl();wl();Hn();vl();_l();kl();Sl();El()});function zu(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function Vu(e){let t=e.xpath;return typeof t=="string"&&t.trim()?!t.startsWith("xpath=")&&!t.startsWith("/")&&!t.startsWith("//")?`xpath=//${t}`:t.startsWith("xpath=")?t:`xpath=${t}`:null}function Ml(e){let t=zu(e),i=e.locator;if(typeof i=="string"&&i.trim())return i=i.trim(),i.endsWith("first()")?`${t}.${i}`:`${t}.${i}.first()`;let n=Vu(e);if(n){let a=JSON.stringify(n);return`${t}.locator(${a}).first()`}return null}function $(e,t){ne.set(e,t)}function Ke(e,t,i=[]){let n=[...i];return t.locator?n.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&n.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&n.push(`frame_path: ${JSON.stringify(t.frame_path)}`),n.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...n.map(a=>` ${a},`),"});"]}function Ya(e,t){let i=t.action_data?.kwargs||{},n=[];return typeof i.relative_x=="number"&&typeof i.relative_y=="number"?(n.push(`action_data: { kwargs: { relative_x: ${i.relative_x}, relative_y: ${i.relative_y} } }`),t.locator?n.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&n.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&n.push(`frame_path: ${JSON.stringify(t.frame_path)}`)):typeof i.x=="number"&&typeof i.y=="number"&&n.push(`action_data: { kwargs: { x: ${i.x}, y: ${i.y} } }`),[`await agent.execAction("${e}", page, {`,...n.map(a=>` ${a},`),"});"]}function Tl(e){let t=e.functionName;if(!t)return null;let i=Array.isArray(e.args)?e.args.map(String):Array.isArray(e.parameterValues)?e.parameterValues.map(String):[];if(i.length===0)return`await ${t}()`;let n=["page","testContext","request","agent"],a=["undefined","null","true","false"],o=i.map(r=>n.includes(r)||a.includes(r)||/^-?\d+(\.\d+)?$/.test(r)?r:r.startsWith("$")?`agent.agentServices.readVariable('${r.substring(1)}')`:`"${r}"`);return`await ${t}(${o.join(", ")})`}function Pl(e,t,i){let n={expandingPaths:new Set([(0,wt.resolve)(t)]),depth:0,referencedPaths:new Set,basePath:i},a={...e};Array.isArray(a.statements)&&(a.statements=Re(a.statements,t,n)),Array.isArray(a.teardown)&&(a.teardown=Re(a.teardown,t,n));for(let o of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(a[o])&&(a[o]=Re(a[o],t,n));return{doc:a,referencedTemplatePaths:Array.from(n.referencedPaths)}}function Re(e,t,i){let n=[];for(let a of e)if(Xu(a)){let o=Yu(a,t,i);n.push(o)}else n.push(Ju(a,t,i));return n}function Xu(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function Yu(e,t,i){if(i.depth>=Al)throw new Error(`Template expansion exceeded maximum depth of ${Al}. Check for deeply nested or circular template references.`);let n=(0,wt.resolve)((0,wt.dirname)(t),e.template),a=!(0,jn.existsSync)(n)&&i.basePath?(0,wt.resolve)(i.basePath,e.template):n;if(i.expandingPaths.has(a))throw new Error(`Circular template reference detected: ${a} is already being expanded. Stack: ${Array.from(i.expandingPaths).join(" \u2192 ")} \u2192 ${a}`);i.referencedPaths.add(a);let o;try{o=(0,jn.readFileSync)(a,"utf-8")}catch(f){throw new Error(`Failed to read template file: ${a} (referenced from ${t}): ${f.message}`)}let r=(0,_i.parse)(o);if(!r||typeof r!="object")throw new Error(`Invalid template file: ${a} \u2014 expected a YAML object`);let l=r.params||[],s=e.params||{};for(let f of l)if(!(f in s))throw new Error(`Template ${e.template} requires param "${f}" but it was not provided. Required params: [${l.join(", ")}]`);let c=r.statements;if(!Array.isArray(c))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(s).length>0){let g=(0,_i.stringify)(c);for(let[y,m]of Object.entries(s))g=g.split(`<<${y}>>`).join(String(m));c=(0,_i.parse)(g)}let d={expandingPaths:new Set([...i.expandingPaths,a]),depth:i.depth+1,referencedPaths:i.referencedPaths},u=Re(c,a,d),h={STEP:r.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:u};return Object.keys(s).length>0&&(h.template_params=s),h}function Ju(e,t,i){if(typeof e!="object"||e===null)return e;let n={...e};return Array.isArray(n.statements)&&(n.statements=Re(n.statements,t,i)),Array.isArray(n.THEN)&&(n.THEN=Re(n.THEN,t,i)),Array.isArray(n.ELSE)&&(n.ELSE=Re(n.ELSE,t,i)),Array.isArray(n.DO)&&(n.DO=Re(n.DO,t,i)),n}function Nl(e,t,i){let n=(0,ki.parse)(e),a=n?.name,o=n?.tags,r=n?.use;if(n&&(n.name!==void 0||n.tags!==void 0||n.use!==void 0)&&(delete n.name,delete n.tags,delete n.use),n?.suite){if(n.goal||n.statements)throw new Cl('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return Zu(n,a,o,r,t,i)}return qu(n,a,o,r,t,i)}function qu(e,t,i,n,a,o){let r=e?.beforeEach,l=e?.afterEach,s=Ol(e?.parameters),c=e?.timeout,d=e?.skip,u=e?.fail,p=e?.only,h=e?.slow;if(e&&(delete e.beforeEach,delete e.afterEach,delete e.parameters,delete e.timeout,delete e.skip,delete e.fail,delete e.only,delete e.slow),e?.url)throw new Cl(`The "url" field is not supported in local YAML tests. Use "base_url: ${e.url}" and add "- URL: /" as the first statement instead.`);e&&!e.goal&&t&&(e.goal=t);let f=[];if(a&&e&&typeof e=="object"){let m=Pl(e,a,o);e=m.doc,f=m.referencedTemplatePaths}let g=(0,ki.stringify)(e),y=$e(g);return a&&(ft(y.statements??[],a,"main"),y.teardown&&ft(y.teardown,a,"teardown")),{testFlow:y,name:t,tags:i,use:n,beforeEach:r,afterEach:l,parameters:s,timeout:c,skip:d,fail:u,only:p,slow:h,referencedTemplatePaths:f}}function Zu(e,t,i,n,a,o){let r=e.suite;if(!Array.isArray(r.tests)||r.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let l=r.beforeAll,s=r.afterAll,c=r.beforeEach,d=r.afterEach,u=[],p=r.tests.map(g=>{if(!g.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(g.statements)||g.statements.length===0)throw new Error(`Suite test "${g.name}" must have a non-empty "statements" array.`);let y={goal:g.name,statements:g.statements};g.teardown&&(y.teardown=g.teardown);let m=[],b=y;if(a&&typeof y=="object"){let M=Pl(y,a,o);b=M.doc,m=M.referencedTemplatePaths,u.push(...m)}let v=(0,ki.stringify)(b),S=$e(v),T=Ol(g.parameters);return{testFlow:S,name:g.name,tags:Array.isArray(g.tags)?g.tags:void 0,parameters:T,timeout:g.timeout,skip:g.skip,fail:g.fail,only:g.only,slow:g.slow}}),h=r.base_url,f=h?{...n,baseURL:h}:n;return{suite:{beforeAll:l,afterAll:s,beforeEach:c,afterEach:d,tests:p},name:t,tags:i,use:f,referencedTemplatePaths:u}}function Ol(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,i)=>{if(!t.name)throw new Error(`Parameter set at index ${i} must have a "name" field.`);if(!t.values||typeof t.values!="object")throw new Error(`Parameter set "${t.name}" must have a "values" object.`);return{name:t.name,values:t.values}})}function ft(e,t,i){for(let n=0;n<e.length;n++){let a=e[n],o=`${i}.${n}`,r=a.description||"";if(a.uid=Qu(t,o,r),a.type===Ge.STEP)ft(a.statements,t,o);else if(a.type===Ge.IF_ELSE){let l=a;ft(l.then,t,`${o}.then`),l.else&&ft(l.else,t,`${o}.else`)}else a.type===Ge.WHILE_LOOP&&ft(a.body,t,`${o}.body`)}}function Qu(e,t,i){let n=(0,Il.createHash)("sha256").update(`${e}:${t}:${i}`).digest("hex");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20,32)}`}var Ku,Wn,Il,ki,jn,wt,_i,$l,ne,Al,Cl,Dl=x(()=>{"use strict";gt();Ku=require("yaml");gt();Wn=Z(require("path"),1),Il=require("crypto"),ki=require("yaml");gt();jn=require("fs"),wt=require("path"),_i=require("yaml");gt();$l=5e3;ne=new Map;$("click",e=>{let t=Ml(e);if(!t)return['await agent.execAction("click", page, {});'];let i=e.action_data?.kwargs?.timeout_ms??$l;return[`await ${t}.click({ timeout: ${i} });`]});$("click_element",ne.get("click"));$("click_element_by_index",ne.get("click"));$("double_click",e=>Ke("double_click",e));$("double_click_on_element",ne.get("double_click"));$("right_click",e=>Ke("right_click",e));$("right_click_on_element",ne.get("right_click"));$("hover",e=>Ke("hover",e));$("hover_element_by_index",ne.get("hover"));$("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return Ke("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});$("fill",ne.get("input_text"));$("clear_input",e=>Ke("clear_input",e));$("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});$("send_keys",ne.get("press"));$("send_keys_on_element",e=>{let t=Ml(e),i=e.action_data?.kwargs?.keys||"";if(!t)return['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(i)} } },`,"});"];let n=e.action_data?.kwargs?.timeout_ms??$l;return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${n} });`]});$("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return Ke("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});$("scroll",e=>{let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]});$("scroll_down",ne.get("scroll"));$("scroll_up",ne.get("scroll"));$("scroll_element",ne.get("scroll"));$("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});$("scroll_on_element",e=>Ke("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));$("go_to_url",e=>{let t=e.action_data?.kwargs?.url||"";return e.action_data?.kwargs?.new_tab===!0?['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)}, new_tab: true } },`,"});"]:['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)} } },`,"});"]});$("open_tab",ne.get("go_to_url"));$("go_back",()=>['await agent.execAction("go_back", page, {});']);$("reload_page",()=>['await agent.execAction("reload_page", page, {});']);$("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);$("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);$("verify",(e,t)=>{let i=e.action_data?.kwargs,n=typeof i?.code=="string",a=n?i?.statement||e.action_description:e.action_description||i?.statement;if(n&&a){let r=i.code.split(`
|
|
4302
4302
|
`),l=JSON.stringify(a);return["{ const _t = Date.now(); try {",...r.map(s=>` ${s}`),` console.log(\`[VERIFY:JS] \u2713 \${((Date.now()-_t)/1000).toFixed(1)}s: ${l}\`);`,"} catch (_e) {",` console.log(\`[VERIFY:JS\u2192AI] JS failed \${((Date.now()-_t)/1000).toFixed(1)}s: (\${_e instanceof Error ? _e.message : String(_e)}), falling back to AI: ${l}\`);`,` await agent.assert(page, ${l}, ${JSON.stringify(t||"")});`,"} }"]}return n?i.code.split(`
|
|
4303
4303
|
`):a?[`await agent.assert(page, ${JSON.stringify(a)}, ${JSON.stringify(t||"")});`]:["// Skipping verify: missing statement or code"]});$("ai_assert",ne.get("verify"));$("assert",ne.get("verify"));$("ai_action",(e,t)=>{let i=e.action_data?.kwargs?.statement;if(!i)return["// Skipping ai_action: missing statement"];let n=JSON.stringify(i),a=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${n}, '${t||""}', ${a});`]});$("ai_step",(e,t)=>{let i=e.action_data?.kwargs?.statement;return i?[`await agent.run(page, ${JSON.stringify(i)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]});$("ai_extract",(e,t)=>{let i=e.action_data?.kwargs?.element_description,n=e.action_data?.kwargs?.variable_name;if(!i||!n)return["// Skipping ai_extract: missing element_description or variable_name"];let a=JSON.stringify(i),o=JSON.stringify(n);return[`await agent.extract(page, ${a}, ${o}, '${t||""}');`]});$("ai_wait_until",(e,t)=>{let i=e.action_data?.kwargs?.condition,n=e.action_data?.kwargs?.timeout_seconds||60;return i?[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${n}, '${t||""}');`]:["// Skipping ai_wait_until: missing condition"]});$("save_variable",e=>{let t=e.action_data?.kwargs?.name||"",i=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(i)} } },`,"});"]});$("js_code",e=>{let t=e.action_data?.kwargs?.code;if(!t)return["// Skipping js_code: missing code"];let i=["{"],n=t.split(`
|
|
4304
|
-
`);for(let a of n)i.push(` ${a}`);return i.push("}"),i});$("function",(e,t,i)=>{let n=e.action_data?.kwargs||{},a=n.functionName;if(a&&a.includes("#")){let[r,l]=a.split("#");if(r&&l){let s=r.replace(/\.(ts|js|mjs)$/,"");if(!s.startsWith(".")
|
|
4305
|
-
`):["// Skipping js_action: missing code"]});Al=5;Cl=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}}});var Fl={};Xe(Fl,{createTestFlowRouter:()=>eh});function Si(e){return e.map(t=>{if(t.type==="ACTION"&&t.action_entity){let i=t.action_entity,n=i.action_data??i.action,a=n?.kwargs?Object.fromEntries(Object.entries(n.kwargs).filter(([r])=>r!=="element_index")):n?.kwargs,o={...i};if(delete o.xpath,n&&a!==void 0){let r={...n,kwargs:a};i.action_data?o.action_data=r:o.action=r}return{...t,action_entity:o}}return t.type==="STEP"?{...t,statements:Si(t.statements)}:t.type==="IF_ELSE"?{...t,then:Si(t.then),...t.else?{else:Si(t.else)}:{}}:t.type==="WHILE_LOOP"?{...t,body:Si(t.body)}:t})}function ze(e){if(!e||e.length===0)return[];let i=(0,ce.stringify)({goal:"_hook",statements:e});return $e(i).statements??[]}async function Rl(e){try{let t=await C.readdir(e,{withFileTypes:!0});for(let i of t)if(!(i.name==="node_modules"||i.name.startsWith("."))&&(i.isFile()&&i.name.endsWith(".test.yaml")||i.isDirectory()&&await Rl(P.join(e,i.name))))return!0}catch{}return!1}function Un(e){let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619)>>>0;return t%2147483647+1}async function Qu(e){let t=new Map,i;try{i=await C.readdir(e)}catch(n){if(n.code==="ENOENT")return t;throw n}for(let n of i.filter(a=>a.endsWith(".yaml")))try{let a=P.join(e,n),r=(0,ce.parse)(await C.readFile(a,"utf-8"))?.name??P.basename(n,".yaml");t.set(Un(r),`templates/${n}`)}catch{}return t}function Ja(e,t){if(Array.isArray(e))return e.map(o=>Ja(o,t));if(!e||typeof e!="object")return e;let i=e,n={};for(let[o,r]of Object.entries(i))n[o]=Ja(r,t);let a=typeof i.reference_id=="number"?i.reference_id:void 0;if(a!==void 0&&typeof n.template_path!="string"){let o=t.get(a);o&&(n.template_path=o,delete n.reference_id)}return n}function Bn(e){return Ln({statements:e}).statements}async function Ei(e,t){for(let i of e)if(i.type==="STEP"){if(i.template_path&&i.statements.length>0){let n=P.join(t,i.template_path);try{let a=(0,ce.parse)(await C.readFile(n,"utf-8"))??{};a.statements=Bn(i.statements),await C.writeFile(n,(0,ce.stringify)(a),"utf-8")}catch{}}await Ei(i.statements,t)}else i.type==="IF_ELSE"?(await Ei(i.then,t),i.else&&await Ei(i.else,t)):i.type==="WHILE_LOOP"&&await Ei(i.body,t)}function eh(e){let{initialDir:t,initialFile:i,projectRoot:n,onFileSelected:a}=e,o=(0,Ll.Router)();function r(){return P.join(n??t,"fixtures")}o.get("/api/files",async(s,c)=>{try{let d=typeof s.query.dir=="string"?s.query.dir:t,u=P.resolve(d),p=await C.readdir(u,{withFileTypes:!0}),h=[];for(let g of p)if(g.name!=="node_modules"&&!g.name.startsWith("."))if(g.isDirectory()){let y=P.join(u,g.name);await Rl(y)&&h.push({name:g.name,type:"directory",path:y})}else g.isFile()&&g.name.endsWith(".test.yaml")&&h.push({name:g.name,type:"file",path:P.join(u,g.name)});h.sort((g,y)=>g.type!==y.type?g.type==="directory"?-1:1:g.name.localeCompare(y.name));let f=P.dirname(u);c.json({dir:u,parent:f!==u?f:null,entries:h,initialFile:i??null,projectRoot:n??t})}catch(d){console.error("[debugger] Error listing files:",d),c.status(500).json({error:d.message})}});function l(s){if(typeof s=="string"&&s){let c=P.resolve(s);return c.endsWith(".test.yaml")?{filePath:c}:{error:"File must be a .test.yaml file"}}return i?{filePath:i}:{error:"No file specified. Pass ?file= parameter."}}return o.get("/api/test-flow",async(s,c)=>{let d=l(s.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=d.filePath;try{a?.(u);let p=await C.readFile(u,"utf-8"),h=await C.stat(u),f=Xa(p),g=Nl(p,u,n);if(g.suite){let y=g.suite,m={tests:y.tests.map(v=>({name:v.name,statements:v.testFlow.statements??[],teardown:v.testFlow.teardown,skip:v.skip,timeout:v.timeout,fail:v.fail,only:v.only,slow:v.slow})),beforeAll:ze(y.beforeAll),afterAll:ze(y.afterAll),beforeEach:ze(y.beforeEach),afterEach:ze(y.afterEach)},b={version:"1.3.0",baseURL:g.use?.baseURL,testGroup:m};c.json({isSuite:!0,testFlow:b,metadata:f,name:g.name,tags:g.tags,use:g.use,filePath:u,fileName:P.basename(u),lastModified:h.mtimeMs})}else{let y=g.testFlow;Rn(p,y),c.json({isSuite:!1,testFlow:y,metadata:f,name:g.name,tags:g.tags,use:g.use,parameters:g.parameters,filePath:u,fileName:P.basename(u),lastModified:h.mtimeMs})}}catch(p){if(p.code==="ENOENT")return c.status(404).json({error:`File not found: ${u}`});console.error("[debugger] Error loading test flow:",p),c.status(500).json({error:p.message})}}),o.put("/api/test-flow",async(s,c)=>{try{let d=l(s.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=d.filePath,{testFlow:p,metadata:h}=s.body;if(!p)return c.status(400).json({error:"testFlow is required"});let f=P.join(n??t,"templates"),g=await Qu(f),y=Ja(p,g),m=Si(y.statements??[]),b={...y,statements:m},v=n??t,S=[b.statements??[],b.teardown??[],...b.testGroup?.tests?.flatMap(O=>[O.statements,...O.teardown?[O.teardown]:[]])??[],...b.testGroup?.beforeEach?[b.testGroup.beforeEach]:[],...b.testGroup?.afterEach?[b.testGroup.afterEach]:[]];for(let O of S)await Ei(O,v);let T=Va(b,h),M=u+".tmp";await C.writeFile(M,T,"utf-8"),await C.rename(M,u);let N=await C.stat(u);c.json({success:!0,lastModified:N.mtimeMs})}catch(d){console.error("[debugger] Error saving test flow:",d),c.status(500).json({error:d.message})}}),o.get("/api/fixtures",async(s,c)=>{try{let d=r();try{let p=(await C.readdir(d,{withFileTypes:!0})).filter(h=>h.isFile()).map(h=>h.name).sort();c.json({files:p,dir:d})}catch(u){if(u.code==="ENOENT")c.json({files:[],dir:d});else throw u}}catch(d){console.error("[debugger] Error listing fixtures:",d),c.status(500).json({error:d.message})}}),o.post("/api/fixtures",async(s,c)=>{try{let d=r();await C.mkdir(d,{recursive:!0});let{name:u,content:p}=s.body;if(!u||!p)return c.status(400).json({error:"name and content are required"});let h=P.basename(u);if(!h)return c.status(400).json({error:"Invalid file name"});let f=P.join(d,h);await C.writeFile(f,Buffer.from(p,"base64")),c.json({fileName:h})}catch(d){console.error("[debugger] Error saving fixture:",d),c.status(500).json({error:d.message})}}),o.get("/api/functions",async(s,c)=>{let d=P.join(n??t,"helpers"),u;try{u=await C.readdir(d)}catch(g){return g.code==="ENOENT"?c.json([]):(console.error("[debugger] Error reading helpers dir:",g),c.status(500).json({error:g.message}))}let p=u.filter(g=>/\.(ts|js|mjs)$/.test(g)),h=[],f=1;for(let g of p){let y=await C.readFile(P.join(d,g),"utf-8"),m=/export\s+async\s+function\s+(\w+)\s*(\([^)]*\))/g,b;for(;(b=m.exec(y))!==null;){let[,v,S]=b,T=S.replace(/\s*:\s*[^,)]+/g,"");h.push({id:f++,name:`helpers/${g}#${v}`,description:"",status:"Active",code:`async function ${v}${T} {}`})}}c.json(h)}),o.get("/api/reusable-steps",async(s,c)=>{let d=P.join(n??t,"templates"),u;try{u=await C.readdir(d)}catch(f){return f.code==="ENOENT"?c.json([]):(console.error("[debugger] Error reading templates dir:",f),c.status(500).json({error:f.message}))}let p=u.filter(f=>f.endsWith(".yaml")).sort(),h=[];for(let f of p)try{let g=await C.readFile(P.join(d,f),"utf-8"),y=(0,ce.parse)(g);if(!y||typeof y!="object")continue;let m=y.name??P.basename(f,".yaml"),b=y.description??"",v=ze(y.statements);h.push({id:Un(m),organizationId:"local",name:m,description:b,statements:v})}catch(g){console.error(`[debugger] Error parsing template ${f}:`,g)}c.json(h)}),o.post("/api/reusable-steps/exists/:name",async(s,c)=>{let d=P.join(n??t,"templates"),u=decodeURIComponent(s.params.name).toLowerCase(),p;try{p=await C.readdir(d)}catch(h){return h.code==="ENOENT"?c.json(!1):c.status(500).json({error:h.message})}for(let h of p.filter(f=>f.endsWith(".yaml")))try{let f=await C.readFile(P.join(d,h),"utf-8");if(((0,ce.parse)(f)?.name??P.basename(h,".yaml")).toLowerCase()===u)return c.json(!0)}catch{}c.json(!1)}),o.post("/api/reusable-steps",async(s,c)=>{let d=P.join(n??t,"templates"),{reusableStep:u}=s.body??{};if(!u?.name||!Array.isArray(u.statements))return c.status(400).json({error:"reusableStep.name and reusableStep.statements are required"});await C.mkdir(d,{recursive:!0});let p=u.name.replace(/[/\\:*?"<>|]/g,"-").trim(),h=P.join(d,`${p}.yaml`),f={name:u.name,statements:Bn(u.statements)};u.description&&(f.description=u.description),await C.writeFile(h,(0,ce.stringify)(f),"utf-8"),c.json({id:Un(u.name),organizationId:"local",name:u.name,description:u.description??"",statements:u.statements})}),o.put("/api/reusable-steps/:id/update",async(s,c)=>{let d=parseInt(s.params.id,10),u=P.join(n??t,"templates"),p;try{p=await C.readdir(u)}catch(h){return h.code==="ENOENT"?c.status(404).json({error:"Templates directory not found"}):c.status(500).json({error:h.message})}for(let h of p.filter(f=>f.endsWith(".yaml")))try{let f=P.join(u,h),g=(0,ce.parse)(await C.readFile(f,"utf-8"))??{},y=g.name??P.basename(h,".yaml");if(Un(y)!==d)continue;let m=s.body??{};return m.description!==void 0&&(g.description=m.description),m.statements!==void 0&&(g.statements=Bn(m.statements)),await C.writeFile(f,(0,ce.stringify)(g),"utf-8"),c.json({id:d,organizationId:"local",...g,statements:m.statements!==void 0?m.statements:ze(g.statements)})}catch{}c.status(404).json({error:`Template with id ${d} not found`})}),o.put("/api/templates/:name",async(s,c)=>{let d=P.join(n??t,"templates"),u=decodeURIComponent(s.params.name),p;try{p=await C.readdir(d)}catch(h){return h.code==="ENOENT"?c.status(404).json({error:"Templates directory not found"}):c.status(500).json({error:h.message})}for(let h of p.filter(f=>f.endsWith(".yaml")))try{let f=P.join(d,h),g=(0,ce.parse)(await C.readFile(f,"utf-8"))??{};if((g.name??P.basename(h,".yaml"))!==u)continue;let m=s.body??{};return m.name!==void 0&&(g.name=m.name),m.description!==void 0&&(g.description=m.description),m.statements!==void 0&&(g.statements=Bn(m.statements)),await C.writeFile(f,(0,ce.stringify)(g),"utf-8"),c.json({organizationId:"local",...g,statements:m.statements!==void 0?m.statements:ze(g.statements)})}catch{}c.status(404).json({error:`Template "${u}" not found`})}),o.get("/api/test-results",async(s,c)=>{let d=l(s.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=n??t,p=P.basename(d.filePath,".test.yaml"),h=P.join(u,".shiplight","artifacts",p),f=[],g=null;try{let y=await C.readdir(h,{withFileTypes:!0});for(let m of y)if(m.isDirectory()){let b=P.join(h,m.name),v=await C.readdir(b);for(let S of v.filter(T=>/\.(png|jpe?g|webp)$/i.test(T))){let T=P.relative(h,P.join(b,S)),M=m.name.match(/^(.+?)_(before|after)$/),N=M?M[1]:m.name,O=M?M[2]:"screenshot";f.push({url:`/api/report-assets/${p}/${T}`,label:O,stepId:N})}}else/\.(webm|mp4)$/i.test(m.name)&&(g||(g=`/api/report-assets/${p}/${m.name}`));f.sort((m,b)=>m.stepId!==b.stepId?(m.stepId??"").localeCompare(b.stepId??""):m.label.localeCompare(b.label))}catch{}if(f.length===0&&!g)return c.status(404).json({error:"No test results found"});c.json({videoPath:g,screenshots:f})}),o}var Ll,C,P,ce,Hl=x(()=>{"use strict";Ll=require("express"),C=Z(require("fs/promises"),1),P=Z(require("path"),1);gt();Dl();ce=require("yaml")});var jl={};Xe(jl,{createIntRunnerRouter:()=>th});function th(e){let t=(0,Wl.Router)();return t.get("/api/browser-cdp",async(i,n)=>{let a=e.getCdpEndpoint();if(!a)return n.status(404).json({error:"No browser running. Start a debug session first."});n.json({cdpUrl:a})}),t.post("/api/int-runner/create-session",async(i,n)=>{try{let a=i.body.startingUrl||i.body.testFlow?.url||i.body.urlOverride,o=i.body.testFilePath,r=await e.createSession({startingUrl:a,testFilePath:o});n.json({status:"success",sessionId:r.sessionId,searchParams:""})}catch(a){console.error("[debugger] create-session error:",a),n.status(500).json({status:"error",message:a.message})}}),t.post("/api/int-runner/login",async(i,n)=>{try{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});let o=await e.executeLogin(a.sessionId);n.json(o)}catch(a){console.error("[debugger] login error:",a),n.status(500).json({status:"error",details:a.message})}}),t.post("/api/int-runner/liveview-url",async(i,n)=>{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});n.json({liveviewUrl:"",browserWsUrl:""})}),t.post("/api/int-runner/end-debug",async(i,n)=>{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});n.json({status:"success"})}),t.post("/api/int-runner/start-debug",async(i,n)=>{try{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});let o=await e.startDebug(a.sessionId);n.json({status:"success",...o})}catch(a){console.error("[debugger] start-debug error:",a),n.status(500).json({status:"error",message:a.message})}}),t.post("/api/int-runner/execute-action",async(i,n)=>{try{let{session:a,actionEntity:o,stepId:r,withSelfHealing:l,stmtUid:s,executionHistory:c}=i.body;if(!a?.sessionId||!o)return n.status(400).json({status:"error",message:"Missing session or actionEntity"});let d=await e.executeAction(a.sessionId,o,r,{withSelfHealing:l,stmtUid:s,executionHistory:c});n.json(d)}catch(a){console.error("[debugger] execute-action error:",a),n.status(500).json({status:"error",details:a.message})}}),t.post("/api/int-runner/run-step",async(i,n)=>{let{session:a,statement:o,stepId:r,executionHistory:l}=i.body;if(!a?.sessionId||!o)return n.status(400).json({success:!1,message:"Session and statement required"});n.setHeader("Content-Type","text/event-stream"),n.setHeader("Cache-Control","no-cache"),n.setHeader("Connection","keep-alive"),n.flushHeaders();let s=c=>{n.write(`data: ${JSON.stringify(c)}
|
|
4304
|
+
`);for(let a of n)i.push(` ${a}`);return i.push("}"),i});$("function",(e,t,i)=>{let n=e.action_data?.kwargs||{},a=n.functionName;if(a&&a.includes("#")){let[r,l]=a.split("#");if(r&&l){let s=r.replace(/\.(ts|js|mjs)$/,"");if(Wn.default.isAbsolute(r))return[`throw new Error(${JSON.stringify(`Absolute paths are not supported in call: references. Use a path relative to the project root (got: "${r}")`)})`];if(!s.startsWith(".")&&i?.projectRoot&&i?.yamlDir){let p=Wn.default.resolve(i.projectRoot,s),h=Wn.default.relative(i.yamlDir,p).replace(/\\/g,"/");s=h.startsWith("..")?h:"./"+h}let c=`import { ${l} } from '${s}';`;i?.imports?.add(c);let d={...n,functionName:l},u=Tl(d);return u?[u.endsWith(";")?u:`${u};`]:["// Skipping function: invalid export pattern"]}}let o=Tl(n);return o?[o.endsWith(";")?o:`${o};`]:["// Skipping function: missing functionName"]});$("generate_2fa_code",e=>{let t=e.action_data?.kwargs?.otp_secret_key||"";return['await agent.execAction("generate_2fa_code", page, {',` action_data: { kwargs: { otp_secret_key: ${JSON.stringify(t)} } },`,"});"]});$("upload_file",e=>{let t=e.action_data?.kwargs||{},i=[],n={};return t.paths?n.paths=t.paths:t.path&&(n.path=t.path),t.use_file_input&&(n.use_file_input=!0),i.push(`action_data: { kwargs: ${JSON.stringify(n)} }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...i.map(a=>` ${a},`),"});"]});$("wait_for_download_complete",e=>['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]);$("switch_tab",e=>['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]);$("close_tab",e=>{let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]});$("set_date_for_native_date_picker",e=>{let t=e.action_data?.kwargs?.date??"",i=[];return i.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...i.map(n=>` ${n},`),"});"]});$("done",()=>["// Done - no action needed"]);$("click_by_coordinates",e=>Ya("click_by_coordinates",e));$("right_click_by_coordinates",e=>Ya("right_click_by_coordinates",e));$("double_click_by_coordinates",e=>Ya("double_click_by_coordinates",e));$("drag_drop",e=>{let t=e.action_data?.kwargs||{},i={};typeof t.relative_x=="number"&&(i.relative_x=t.relative_x),typeof t.relative_y=="number"&&(i.relative_y=t.relative_y),typeof t.delta_x=="number"&&(i.delta_x=t.delta_x),typeof t.delta_y=="number"&&(i.delta_y=t.delta_y),typeof t.coord_source_x=="number"&&(i.coord_source_x=t.coord_source_x),typeof t.coord_source_y=="number"&&(i.coord_source_y=t.coord_source_y),typeof t.coord_target_x=="number"&&(i.coord_target_x=t.coord_target_x),typeof t.coord_target_y=="number"&&(i.coord_target_y=t.coord_target_y);let n=[`action_data: { kwargs: ${JSON.stringify(i)} }`];return e.locator?n.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&n.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&n.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("drag_drop", page, {',...n.map(a=>` ${a},`),"});"]});$("get_dropdown_options",e=>{let t=[];return e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("get_dropdown_options", page, {});']:['await agent.execAction("get_dropdown_options", page, {',...t.map(i=>` ${i},`),"});"]});$("extract_email_content",e=>{let t=e.action_data?.kwargs||{};return['await agent.execAction("extract_email_content", page, {',` action_data: { kwargs: ${JSON.stringify(t)} },`,"});"]});$("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
|
|
4305
|
+
`):["// Skipping js_action: missing code"]});Al=5;Cl=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}}});var Fl={};Xe(Fl,{createTestFlowRouter:()=>th});function Si(e){return e.map(t=>{if(t.type==="ACTION"&&t.action_entity){let i=t.action_entity,n=i.action_data??i.action,a=n?.kwargs?Object.fromEntries(Object.entries(n.kwargs).filter(([r])=>r!=="element_index")):n?.kwargs,o={...i};if(delete o.xpath,n&&a!==void 0){let r={...n,kwargs:a};i.action_data?o.action_data=r:o.action=r}return{...t,action_entity:o}}return t.type==="STEP"?{...t,statements:Si(t.statements)}:t.type==="IF_ELSE"?{...t,then:Si(t.then),...t.else?{else:Si(t.else)}:{}}:t.type==="WHILE_LOOP"?{...t,body:Si(t.body)}:t})}function ze(e){if(!e||e.length===0)return[];let i=(0,ce.stringify)({goal:"_hook",statements:e});return $e(i).statements??[]}async function Rl(e){try{let t=await C.readdir(e,{withFileTypes:!0});for(let i of t)if(!(i.name==="node_modules"||i.name.startsWith("."))&&(i.isFile()&&i.name.endsWith(".test.yaml")||i.isDirectory()&&await Rl(P.join(e,i.name))))return!0}catch{}return!1}function Un(e){let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619)>>>0;return t%2147483647+1}async function eh(e){let t=new Map,i;try{i=await C.readdir(e)}catch(n){if(n.code==="ENOENT")return t;throw n}for(let n of i.filter(a=>a.endsWith(".yaml")))try{let a=P.join(e,n),r=(0,ce.parse)(await C.readFile(a,"utf-8"))?.name??P.basename(n,".yaml");t.set(Un(r),`templates/${n}`)}catch{}return t}function Ja(e,t){if(Array.isArray(e))return e.map(o=>Ja(o,t));if(!e||typeof e!="object")return e;let i=e,n={};for(let[o,r]of Object.entries(i))n[o]=Ja(r,t);let a=typeof i.reference_id=="number"?i.reference_id:void 0;if(a!==void 0&&typeof n.template_path!="string"){let o=t.get(a);o&&(n.template_path=o,delete n.reference_id)}return n}function Bn(e){return Ln({statements:e}).statements}async function Ei(e,t){for(let i of e)if(i.type==="STEP"){if(i.template_path&&i.statements.length>0){let n=P.join(t,i.template_path);try{let a=(0,ce.parse)(await C.readFile(n,"utf-8"))??{};a.statements=Bn(i.statements),await C.writeFile(n,(0,ce.stringify)(a),"utf-8")}catch{}}await Ei(i.statements,t)}else i.type==="IF_ELSE"?(await Ei(i.then,t),i.else&&await Ei(i.else,t)):i.type==="WHILE_LOOP"&&await Ei(i.body,t)}function th(e){let{initialDir:t,initialFile:i,projectRoot:n,onFileSelected:a}=e,o=(0,Ll.Router)();function r(){return P.join(n??t,"fixtures")}o.get("/api/files",async(s,c)=>{try{let d=typeof s.query.dir=="string"?s.query.dir:t,u=P.resolve(d),p=await C.readdir(u,{withFileTypes:!0}),h=[];for(let g of p)if(g.name!=="node_modules"&&!g.name.startsWith("."))if(g.isDirectory()){let y=P.join(u,g.name);await Rl(y)&&h.push({name:g.name,type:"directory",path:y})}else g.isFile()&&g.name.endsWith(".test.yaml")&&h.push({name:g.name,type:"file",path:P.join(u,g.name)});h.sort((g,y)=>g.type!==y.type?g.type==="directory"?-1:1:g.name.localeCompare(y.name));let f=P.dirname(u);c.json({dir:u,parent:f!==u?f:null,entries:h,initialFile:i??null,projectRoot:n??t})}catch(d){console.error("[debugger] Error listing files:",d),c.status(500).json({error:d.message})}});function l(s){if(typeof s=="string"&&s){let c=P.resolve(s);return c.endsWith(".test.yaml")?{filePath:c}:{error:"File must be a .test.yaml file"}}return i?{filePath:i}:{error:"No file specified. Pass ?file= parameter."}}return o.get("/api/test-flow",async(s,c)=>{let d=l(s.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=d.filePath;try{a?.(u);let p=await C.readFile(u,"utf-8"),h=await C.stat(u),f=Xa(p),g=Nl(p,u,n);if(g.suite){let y=g.suite,m={tests:y.tests.map(v=>({name:v.name,statements:v.testFlow.statements??[],teardown:v.testFlow.teardown,skip:v.skip,timeout:v.timeout,fail:v.fail,only:v.only,slow:v.slow})),beforeAll:ze(y.beforeAll),afterAll:ze(y.afterAll),beforeEach:ze(y.beforeEach),afterEach:ze(y.afterEach)},b={version:"1.3.0",baseURL:g.use?.baseURL,testGroup:m};c.json({isSuite:!0,testFlow:b,metadata:f,name:g.name,tags:g.tags,use:g.use,filePath:u,fileName:P.basename(u),lastModified:h.mtimeMs})}else{let y=g.testFlow;Rn(p,y),c.json({isSuite:!1,testFlow:y,metadata:f,name:g.name,tags:g.tags,use:g.use,parameters:g.parameters,filePath:u,fileName:P.basename(u),lastModified:h.mtimeMs})}}catch(p){if(p.code==="ENOENT")return c.status(404).json({error:`File not found: ${u}`});console.error("[debugger] Error loading test flow:",p),c.status(500).json({error:p.message})}}),o.put("/api/test-flow",async(s,c)=>{try{let d=l(s.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=d.filePath,{testFlow:p,metadata:h}=s.body;if(!p)return c.status(400).json({error:"testFlow is required"});let f=P.join(n??t,"templates"),g=await eh(f),y=Ja(p,g),m=Si(y.statements??[]),b={...y,statements:m},v=n??t,S=[b.statements??[],b.teardown??[],...b.testGroup?.tests?.flatMap(O=>[O.statements,...O.teardown?[O.teardown]:[]])??[],...b.testGroup?.beforeEach?[b.testGroup.beforeEach]:[],...b.testGroup?.afterEach?[b.testGroup.afterEach]:[]];for(let O of S)await Ei(O,v);let T=Va(b,h),M=u+".tmp";await C.writeFile(M,T,"utf-8"),await C.rename(M,u);let N=await C.stat(u);c.json({success:!0,lastModified:N.mtimeMs})}catch(d){console.error("[debugger] Error saving test flow:",d),c.status(500).json({error:d.message})}}),o.get("/api/fixtures",async(s,c)=>{try{let d=r();try{let p=(await C.readdir(d,{withFileTypes:!0})).filter(h=>h.isFile()).map(h=>h.name).sort();c.json({files:p,dir:d})}catch(u){if(u.code==="ENOENT")c.json({files:[],dir:d});else throw u}}catch(d){console.error("[debugger] Error listing fixtures:",d),c.status(500).json({error:d.message})}}),o.post("/api/fixtures",async(s,c)=>{try{let d=r();await C.mkdir(d,{recursive:!0});let{name:u,content:p}=s.body;if(!u||!p)return c.status(400).json({error:"name and content are required"});let h=P.basename(u);if(!h)return c.status(400).json({error:"Invalid file name"});let f=P.join(d,h);await C.writeFile(f,Buffer.from(p,"base64")),c.json({fileName:h})}catch(d){console.error("[debugger] Error saving fixture:",d),c.status(500).json({error:d.message})}}),o.get("/api/functions",async(s,c)=>{let d=P.join(n??t,"helpers"),u;try{u=await C.readdir(d)}catch(g){return g.code==="ENOENT"?c.json([]):(console.error("[debugger] Error reading helpers dir:",g),c.status(500).json({error:g.message}))}let p=u.filter(g=>/\.(ts|js|mjs)$/.test(g)),h=[],f=1;for(let g of p){let y=await C.readFile(P.join(d,g),"utf-8"),m=/export\s+async\s+function\s+(\w+)\s*(\([^)]*\))/g,b;for(;(b=m.exec(y))!==null;){let[,v,S]=b,T=S.replace(/\s*:\s*[^,)]+/g,"");h.push({id:f++,name:`helpers/${g}#${v}`,description:"",status:"Active",code:`async function ${v}${T} {}`})}}c.json(h)}),o.get("/api/reusable-steps",async(s,c)=>{let d=P.join(n??t,"templates"),u;try{u=await C.readdir(d)}catch(f){return f.code==="ENOENT"?c.json([]):(console.error("[debugger] Error reading templates dir:",f),c.status(500).json({error:f.message}))}let p=u.filter(f=>f.endsWith(".yaml")).sort(),h=[];for(let f of p)try{let g=await C.readFile(P.join(d,f),"utf-8"),y=(0,ce.parse)(g);if(!y||typeof y!="object")continue;let m=y.name??P.basename(f,".yaml"),b=y.description??"",v=ze(y.statements);h.push({id:Un(m),organizationId:"local",name:m,description:b,statements:v})}catch(g){console.error(`[debugger] Error parsing template ${f}:`,g)}c.json(h)}),o.post("/api/reusable-steps/exists/:name",async(s,c)=>{let d=P.join(n??t,"templates"),u=decodeURIComponent(s.params.name).toLowerCase(),p;try{p=await C.readdir(d)}catch(h){return h.code==="ENOENT"?c.json(!1):c.status(500).json({error:h.message})}for(let h of p.filter(f=>f.endsWith(".yaml")))try{let f=await C.readFile(P.join(d,h),"utf-8");if(((0,ce.parse)(f)?.name??P.basename(h,".yaml")).toLowerCase()===u)return c.json(!0)}catch{}c.json(!1)}),o.post("/api/reusable-steps",async(s,c)=>{let d=P.join(n??t,"templates"),{reusableStep:u}=s.body??{};if(!u?.name||!Array.isArray(u.statements))return c.status(400).json({error:"reusableStep.name and reusableStep.statements are required"});await C.mkdir(d,{recursive:!0});let p=u.name.replace(/[/\\:*?"<>|]/g,"-").trim(),h=P.join(d,`${p}.yaml`),f={name:u.name,statements:Bn(u.statements)};u.description&&(f.description=u.description),await C.writeFile(h,(0,ce.stringify)(f),"utf-8"),c.json({id:Un(u.name),organizationId:"local",name:u.name,description:u.description??"",statements:u.statements})}),o.put("/api/reusable-steps/:id/update",async(s,c)=>{let d=parseInt(s.params.id,10),u=P.join(n??t,"templates"),p;try{p=await C.readdir(u)}catch(h){return h.code==="ENOENT"?c.status(404).json({error:"Templates directory not found"}):c.status(500).json({error:h.message})}for(let h of p.filter(f=>f.endsWith(".yaml")))try{let f=P.join(u,h),g=(0,ce.parse)(await C.readFile(f,"utf-8"))??{},y=g.name??P.basename(h,".yaml");if(Un(y)!==d)continue;let m=s.body??{};return m.description!==void 0&&(g.description=m.description),m.statements!==void 0&&(g.statements=Bn(m.statements)),await C.writeFile(f,(0,ce.stringify)(g),"utf-8"),c.json({id:d,organizationId:"local",...g,statements:m.statements!==void 0?m.statements:ze(g.statements)})}catch{}c.status(404).json({error:`Template with id ${d} not found`})}),o.put("/api/templates/:name",async(s,c)=>{let d=P.join(n??t,"templates"),u=decodeURIComponent(s.params.name),p;try{p=await C.readdir(d)}catch(h){return h.code==="ENOENT"?c.status(404).json({error:"Templates directory not found"}):c.status(500).json({error:h.message})}for(let h of p.filter(f=>f.endsWith(".yaml")))try{let f=P.join(d,h),g=(0,ce.parse)(await C.readFile(f,"utf-8"))??{};if((g.name??P.basename(h,".yaml"))!==u)continue;let m=s.body??{};return m.name!==void 0&&(g.name=m.name),m.description!==void 0&&(g.description=m.description),m.statements!==void 0&&(g.statements=Bn(m.statements)),await C.writeFile(f,(0,ce.stringify)(g),"utf-8"),c.json({organizationId:"local",...g,statements:m.statements!==void 0?m.statements:ze(g.statements)})}catch{}c.status(404).json({error:`Template "${u}" not found`})}),o.get("/api/test-results",async(s,c)=>{let d=l(s.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=n??t,p=P.basename(d.filePath,".test.yaml"),h=P.join(u,".shiplight","artifacts",p),f=[],g=null;try{let y=await C.readdir(h,{withFileTypes:!0});for(let m of y)if(m.isDirectory()){let b=P.join(h,m.name),v=await C.readdir(b);for(let S of v.filter(T=>/\.(png|jpe?g|webp)$/i.test(T))){let T=P.relative(h,P.join(b,S)),M=m.name.match(/^(.+?)_(before|after)$/),N=M?M[1]:m.name,O=M?M[2]:"screenshot";f.push({url:`/api/report-assets/${p}/${T}`,label:O,stepId:N})}}else/\.(webm|mp4)$/i.test(m.name)&&(g||(g=`/api/report-assets/${p}/${m.name}`));f.sort((m,b)=>m.stepId!==b.stepId?(m.stepId??"").localeCompare(b.stepId??""):m.label.localeCompare(b.label))}catch{}if(f.length===0&&!g)return c.status(404).json({error:"No test results found"});c.json({videoPath:g,screenshots:f})}),o}var Ll,C,P,ce,Hl=x(()=>{"use strict";Ll=require("express"),C=Z(require("fs/promises"),1),P=Z(require("path"),1);gt();Dl();ce=require("yaml")});var jl={};Xe(jl,{createIntRunnerRouter:()=>ih});function ih(e){let t=(0,Wl.Router)();return t.get("/api/browser-cdp",async(i,n)=>{let a=e.getCdpEndpoint();if(!a)return n.status(404).json({error:"No browser running. Start a debug session first."});n.json({cdpUrl:a})}),t.post("/api/int-runner/create-session",async(i,n)=>{try{let a=i.body.startingUrl||i.body.testFlow?.url||i.body.urlOverride,o=i.body.testFilePath,r=await e.createSession({startingUrl:a,testFilePath:o});n.json({status:"success",sessionId:r.sessionId,searchParams:""})}catch(a){console.error("[debugger] create-session error:",a),n.status(500).json({status:"error",message:a.message})}}),t.post("/api/int-runner/login",async(i,n)=>{try{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});let o=await e.executeLogin(a.sessionId);n.json(o)}catch(a){console.error("[debugger] login error:",a),n.status(500).json({status:"error",details:a.message})}}),t.post("/api/int-runner/liveview-url",async(i,n)=>{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});n.json({liveviewUrl:"",browserWsUrl:""})}),t.post("/api/int-runner/end-debug",async(i,n)=>{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});n.json({status:"success"})}),t.post("/api/int-runner/start-debug",async(i,n)=>{try{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});let o=await e.startDebug(a.sessionId);n.json({status:"success",...o})}catch(a){console.error("[debugger] start-debug error:",a),n.status(500).json({status:"error",message:a.message})}}),t.post("/api/int-runner/execute-action",async(i,n)=>{try{let{session:a,actionEntity:o,stepId:r,withSelfHealing:l,stmtUid:s,executionHistory:c}=i.body;if(!a?.sessionId||!o)return n.status(400).json({status:"error",message:"Missing session or actionEntity"});let d=await e.executeAction(a.sessionId,o,r,{withSelfHealing:l,stmtUid:s,executionHistory:c});n.json(d)}catch(a){console.error("[debugger] execute-action error:",a),n.status(500).json({status:"error",details:a.message})}}),t.post("/api/int-runner/run-step",async(i,n)=>{let{session:a,statement:o,stepId:r,executionHistory:l}=i.body;if(!a?.sessionId||!o)return n.status(400).json({success:!1,message:"Session and statement required"});n.setHeader("Content-Type","text/event-stream"),n.setHeader("Cache-Control","no-cache"),n.setHeader("Connection","keep-alive"),n.flushHeaders();let s=c=>{n.write(`data: ${JSON.stringify(c)}
|
|
4306
4306
|
|
|
4307
4307
|
`)};try{await e.runStep(a.sessionId,o,r,s,l)}catch(c){s({type:"error",data:{message:c.message}})}finally{n.end()}}),t.post("/api/int-runner/execute-step",async(i,n)=>{let{session:a,statement:o,stepId:r,executionHistory:l,maxSteps:s}=i.body;if(!a?.sessionId||!o)return n.status(400).json({success:!1,message:"Session and statement required"});n.setHeader("Content-Type","text/event-stream"),n.setHeader("Cache-Control","no-cache"),n.setHeader("Connection","keep-alive"),n.flushHeaders();let c=d=>{n.write(`data: ${JSON.stringify(d)}
|
|
4308
4308
|
|
|
4309
4309
|
`)};try{await e.runStep(a.sessionId,o,r,c,l)}catch(d){c({type:"error",data:{message:d.message}})}finally{n.end()}}),t.post("/api/int-runner/stop-run-step",async(i,n)=>{try{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});let o=e.stopRunStep(a.sessionId);n.json({status:"success",aborted:o})}catch(a){console.error("[debugger] stop-run-step error:",a),n.status(500).json({status:"error",aborted:!1,details:a.message})}}),t.post("/api/int-runner/evaluate",async(i,n)=>{try{let{session:a,statement:o,stepId:r,executionHistory:l}=i.body;if(!a?.sessionId||!o)return n.status(400).json({status:"error",message:"Missing session or statement"});let s=await e.evaluate(a.sessionId,o,l);n.json(s)}catch(a){console.error("[debugger] evaluate error:",a),n.status(500).json({status:"error",conclusion:"unknown",explanation:a.message})}}),t.post("/api/int-runner/generate-action",async(i,n)=>{try{let{session:a,statement:o,stepId:r,executionHistory:l,usePureVision:s,includeDebugInfo:c}=i.body;if(!a?.sessionId||!o)return n.status(400).json({status:"error",message:"Missing session or statement"});let d=await e.generateAction(a.sessionId,o,r,{executionHistory:l,usePureVision:s,includeDebugInfo:c});n.json(d)}catch(a){console.error("[debugger] generate-action error:",a),n.status(500).json({status:"error",details:a.message})}}),t.post("/api/int-runner/screenshot",async(i,n)=>{try{let{session:a,s3Path:o}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});let r;if(o){let s=o.split("/").pop()?.replace(/\.png$/,"");s&&(r=s)}let l=await e.takeScreenshot(a.sessionId,r);n.json({status:"success",...l})}catch(a){console.error("[debugger] screenshot error:",a),n.status(500).json({status:"error",message:a.message})}}),t.get("/api/int-runner/session-artifacts",async(i,n)=>{try{let a=e.getSessionArtifacts?.("default")??{screenshots:[]};n.json(a)}catch(a){n.status(500).json({status:"error",message:a.message})}}),t.post("/api/int-runner/start-recorder",async(i,n)=>{let{session:a,testIdAttributeName:o}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});n.setHeader("Content-Type","text/event-stream"),n.setHeader("Cache-Control","no-cache"),n.setHeader("Connection","keep-alive"),n.flushHeaders();let r=l=>{n.write(`data: ${JSON.stringify(l)}
|
|
4310
4310
|
|
|
4311
|
-
`)};try{await e.startRecorder(a.sessionId,r,o)}catch(l){r({type:"error",data:{message:l.message}})}finally{n.end()}}),t.post("/api/int-runner/stop-recorder",async(i,n)=>{try{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});await e.stopRecorder(a.sessionId),n.json({status:"success"})}catch(a){console.error("[debugger] stop-recorder error:",a),n.status(500).json({status:"error",details:a.message})}}),t.post("/api/int-runner/terminate-session",async(i,n)=>{try{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});await e.terminateSession(a.sessionId),n.json({status:"success",details:`Session ${a.sessionId} terminated`})}catch(a){console.error("[debugger] terminate-session error:",a),n.status(500).json({status:"error",details:a.message})}}),t.post("/api/int-runner/session-status",async(i,n)=>{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"timed_out"});n.json({status:"active",remainingSeconds:9999})}),t}var Wl,Ul=x(()=>{"use strict";Wl=require("express")});var
|
|
4311
|
+
`)};try{await e.startRecorder(a.sessionId,r,o)}catch(l){r({type:"error",data:{message:l.message}})}finally{n.end()}}),t.post("/api/int-runner/stop-recorder",async(i,n)=>{try{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});await e.stopRecorder(a.sessionId),n.json({status:"success"})}catch(a){console.error("[debugger] stop-recorder error:",a),n.status(500).json({status:"error",details:a.message})}}),t.post("/api/int-runner/terminate-session",async(i,n)=>{try{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"error",message:"Missing session"});await e.terminateSession(a.sessionId),n.json({status:"success",details:`Session ${a.sessionId} terminated`})}catch(a){console.error("[debugger] terminate-session error:",a),n.status(500).json({status:"error",details:a.message})}}),t.post("/api/int-runner/session-status",async(i,n)=>{let{session:a}=i.body;if(!a?.sessionId)return n.status(400).json({status:"timed_out"});n.json({status:"active",remainingSeconds:9999})}),t}var Wl,Ul=x(()=>{"use strict";Wl=require("express")});var ah={};Xe(ah,{PlaywrightSandboxService:()=>ut,startPlaywrightDebugServer:()=>nh});module.exports=Yl(ah);var Gn=Z(require("express"),1),Ti=Z(require("path"),1);var se=Z(require("path"),1),ht=Z(require("fs/promises"),1),Gs=require("url"),Ks=Z(require("os"),1),zs=require("yaml"),Vs=require("@playwright/test");U();U();Lt();et();var Oa=require("zod"),Jd=Oa.z.object({instruction:Oa.z.string().describe('The instruction of the operation to perform. Can only include one operation. Do not inlcude element indexes just describe the element, e.g. "select the text "Hello, world!" in "Hello, world!""')});function _s(e){e.register({name:"perform_accurate_operation",description:"Perform an operation that requires accurate interaction like dragging or interacting with a specific area of an element. Only use this action when neccecary.",schema:Jd,usesElementIndex:!1,async execute(t,i){let{instruction:n}=t,a={page:i.page,agentServices:i.agentServices,domService:i.domService},o=await Qe(n,a,{});if(o.status==="error"||!o.actionEntity)return{success:!1,actionEntity:{action_description:n,action_data:{action_name:"perform_accurate_operation",kwargs:{instruction:n}}},error:o.error||"Failed to generate action"};let{actionEntity:r}=o,l=await Dt(r,a);return{success:l.success,actionEntity:r,message:l.success?`Successfully executed action: ${r.action_data?.action_name}`:void 0,error:l.error}}})}xe();U();var ks=require("ai"),Ss=require("html-to-text");async function qd(e,t,i){let{apiKey:n,domain:a}=e;if(!n)throw new Error("Mailgun configuration missing. Please provide apiKey and domain");let o=!!e.baseURL,r=e.baseURL||"https://api.mailgun.net",l=e.authHeader||`Basic ${Buffer.from(`api:${n}`).toString("base64")}`,s=[];try{let c=o?`${r}/events`:`${r}/v3/${a}/events`,d={event:"accepted",limit:"10",ascending:"yes",recipient:t};if(i.from_email&&(d.from=i.from_email),i.since)d.begin=Math.floor(i.since/1e3).toString();else{let h=new Date(Date.now()-6e5);d.begin=Math.floor(h.getTime()/1e3).toString()}w.info(`Mailgun params: ${JSON.stringify(d)}`);let u=await fetch(c+"?"+new URLSearchParams(d),{method:"GET",headers:{Authorization:l}});if(!u.ok){let h=await u.text();throw new Error(`Mailgun events API error: ${h}`)}let p=(await u.json()).items||[];for(let h of p.slice(0,10)){if(h.event!=="accepted")continue;let f=(h.storage||{}).url;if(w.info(`message_url: ${f}`),!f){let m=(h.message||{}).headers||{},b=m.subject||"",v=m.from||"",S=m.to||"";if(i.from_email&&!v.toLowerCase().includes(i.from_email.toLowerCase())||i.to_email&&!S.toLowerCase().includes(i.to_email.toLowerCase())||i.subject&&!b.toLowerCase().includes(i.subject.toLowerCase()))continue;s.push({subject:b,from:v,to:S,date:new Date(h.timestamp*1e3).toUTCString(),body:"Message body not available (Mailgun storage disabled)",message_id:m["message-id"]||""});continue}let g=f.split("/"),y=g[g.length-1];if(w.info(`Storage key: ${y}`),y){let m=o?`${r}/messages/${y}`:`${r}/v3/domains/${a}/messages/${y}`;try{let b=await fetch(m,{method:"GET",headers:{Authorization:l,Accept:"application/json"}});if(b.ok){let v=await b.json(),S=v.Subject||"",T=v.From||"",M=v.To||"",N=v.Date||"",O=v["Message-Id"]||"";w.info(`subject: ${S}`),w.info(`from_addr: ${T}`),w.info(`to_addr: ${M}`),w.info(`date: ${N}`),w.info(`message_id: ${O}`);let D=v["body-html"]||v["body-plain"]||"";if(D&&D.includes("<")&&(D=(0,Ss.convert)(D)),w.info(`Body: ${D.substring(0,200)}...`),i.subject&&!S.toLowerCase().includes(i.subject.toLowerCase())||i.body_contains&&!D.toLowerCase().includes(i.body_contains.toLowerCase()))continue;s.push({subject:S,from:T,to:M,date:N,body:D,message_id:O});continue}else w.warn(`Messages API returned ${b.status}`)}catch(b){w.warn(`Failed to parse JSON response: ${b}`)}}try{let m=await fetch(f,{method:"GET",headers:{Authorization:l}});if(!m.ok){w.warn(`Could not fetch stored message: ${m.status}`);continue}let b=await m.text();w.info(`Fallback: Raw email length: ${b.length}`);let v=b.split(`
|
|
4312
4312
|
`),S=!0,T={},M="";for(let ae=0;ae<v.length;ae++){let K=v[ae];if(K.trim()===""&&S){S=!1;continue}if(S){let z=K.match(/^([^:]+):\s*(.+)$/);z&&(T[z[1].toLowerCase()]=z[2])}else M+=K+`
|
|
4313
4313
|
`}let N=T.subject||"",O=T.from||"",D=T.to||"",ie=T.date||"",J=T["message-id"]||"";if(i.subject&&!N.toLowerCase().includes(i.subject.toLowerCase())||i.body_contains&&!M.toLowerCase().includes(i.body_contains.toLowerCase()))continue;s.push({subject:N,from:O,to:D,date:ie,body:M.trim(),message_id:J})}catch(m){w.warn(`Error fetching raw message: ${m}`)}}if(s.length>0){try{s.sort((f,g)=>{let y=new Date(f.date).getTime();return new Date(g.date).getTime()-y})}catch{}let h=s[0];return w.info(`Returning most recent email: ${h.subject}`),[h]}return s}catch(c){throw w.error(`Error fetching emails from Mailgun: ${c.message}`),new Error(`Error fetching emails from Mailgun: ${c.message}`)}}function Zd(e,t){if(e==="verification_code")return`You are analyzing an email to extract an OTP (One-Time Password) or verification code.
|
|
4314
4314
|
|
|
@@ -4384,10 +4384,10 @@ To: ${p.to}
|
|
|
4384
4384
|
Date: ${p.date}
|
|
4385
4385
|
|
|
4386
4386
|
Body:
|
|
4387
|
-
${p.body}`,f=await Qd(h,a,t.model);w.info(`Extracted content: ${f}`),f&&f!=="NOT_FOUND"&&u.push({content:f,email_subject:p.subject,email_from:p.from,email_date:p.date})}if(u.length>0){let p=u[0],h=`$email_${t.extraction_type}`;t.extraction_type==="custom"?h="$email_extracted_content":t.extraction_type==="activation_link"?h="$email_magic_link":t.extraction_type==="verification_code"&&(h="$email_otp_code");let f=(new Date().getTime()-o.getTime())/1e3;return w.info(`Successfully extracted content after ${l} attempts in ${f.toFixed(1)} seconds`),{data:p.content,result_variable:h,status:"success",message:`Successfully extracted content from email: ${p.email_subject.substring(0,50)}... (attempts: ${l})`}}else w.info(`Found emails but no extractable content in attempt ${l}`)}else w.info(`No emails found in attempt ${l}`)}catch(c){w.warn(`Error in polling attempt ${l}: ${c.message}`)}if(new Date(Date.now()+n*1e3)>=r){w.info("Not enough time for another polling attempt");break}w.info(`Waiting ${n} seconds before next attempt...`),await new Promise(c=>setTimeout(c,n*1e3))}let s=(new Date().getTime()-o.getTime())/1e3;return{data:void 0,status:"error",message:`No emails with extractable content found after ${l} attempts over ${s.toFixed(1)} seconds`}}catch(a){return w.error(`Error extracting email content: ${a.message}`),{data:void 0,status:"error",message:`Error extracting email content: ${a.message}`}}}qe();U();oe();var ve=require("zod");function Ts(e){switch(e){case"verification_code":return"email_otp_code";case"activation_link":return"email_magic_link";case"custom":return"email_extracted_content";default:return"email_content"}}var As=class{getMailgunConfig(){let e=X().env||{};if(e.MAILGUN_API_KEY)return{apiKey:e.MAILGUN_API_KEY,domain:e.MAILGUN_DOMAIN||""};let t=e.SHIPLIGHT_API_TOKEN;if(t){let i=`${We(t,e.SHIPLIGHT_API_URL)}/mailgun`;return w.debug(`[extract_email_content] Using Shiplight proxy for Mailgun: ${i}`),{apiKey:t,domain:e.MAILGUN_DOMAIN||"",baseURL:i,authHeader:`Bearer ${t}`}}}async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=this.getMailgunConfig();if(!a)throw new Error("Mailgun configuration not provided. Please configure MAILGUN_API_KEY and MAILGUN_DOMAIN, or set SHIPLIGHT_API_TOKEN to route through the Shiplight proxy.");let o=n.kwargs,r=i.getModel?.()||"gemini-2.5-pro",l=await Es(a,{model:r,forward_email:o.forward_email,extraction_type:o.extraction_type,prompt:o.prompt,filters:{from_email:o.filter_from_email,to_email:o.filter_to_email,subject:o.filter_subject,body_contains:o.filter_body_contains},timeout:o.timeout});if(l.status==="success"&&l.data){let s=l.result_variable?.replace(/^\$/,"")||Ts(o.extraction_type);i.variableStore.set(s,l.data),w.info(`[extract_email_content] Extracted and saved to ${s}`)}else throw new Error(l.message||"Failed to extract email content")}transpile(e){let t=e.action_data?.kwargs||{};return['await agent.execAction("extract_email_content", page, {',` action_data: { kwargs: ${JSON.stringify(t)} },`,"});"]}},eu=ve.z.object({forward_email:ve.z.string().describe("Email address where emails are forwarded to (Mailgun inbox)"),extraction_type:ve.z.enum(["verification_code","activation_link","custom"]).describe("Type of content to extract: verification_code for OTP codes, activation_link for magic links, custom for custom prompts"),prompt:ve.z.string().optional().describe("Custom extraction prompt (required when extraction_type is custom)"),filter_from_email:ve.z.string().optional().describe("Filter emails by sender address"),filter_to_email:ve.z.string().optional().describe("Filter emails by recipient address"),filter_subject:ve.z.string().optional().describe("Filter emails by subject (partial match)"),filter_body_contains:ve.z.string().optional().describe("Filter emails by body content (partial match)"),timeout:ve.z.number().optional().describe("Timeout in seconds for polling (default: 60)")});function $s(e,t){e.register({name:"extract_email_content",description:"Extract verification codes, magic links, or custom content from emails received via Mailgun. Polls the Mailgun inbox for matching emails and uses AI to extract the requested content.",schema:eu,async execute(i,n){let{forward_email:a,extraction_type:o,prompt:r,filter_from_email:l,filter_to_email:s,filter_subject:c,filter_body_contains:d,timeout:u}=i,{page:p,agentServices:h}=n;w.info(`[extract_email_content] Extracting ${o} from ${a}`);try{let f={action_description:`Extract ${o} from email`,action_data:{action_name:"extract_email_content",kwargs:{forward_email:a,extraction_type:o,prompt:r,filter_from_email:l,filter_to_email:s,filter_subject:c,filter_body_contains:d,timeout:u}}};await t.execute(p,f,h);let g=Ts(o);return{success:!0,actionEntity:f,message:`Extracted ${o} and saved to $${g}`}}catch(f){return{success:!1,error:f.message,actionEntity:{action_description:`Extract ${o} from email (failed)`,action_data:{action_name:"extract_email_content",kwargs:{forward_email:a,extraction_type:o,prompt:r,filter_from_email:l,filter_to_email:s,filter_subject:c,filter_body_contains:d,timeout:u}},feedback:f.message}}}}})}Ft();Ht();Wt();jt();Ut();Gt();Kt();zt();Xt();Jt();qt();Qt();ei();ti();ii();ni();ai();oi();si();li();ci();di();ui();hi();mi();pi();gi();var Cn=null;async function _e(){if(Cn)return Cn;let e=(await Promise.resolve().then(()=>(Tn(),En))).default;return Cn=new e,Cn}async function Ms(e){let t=await _e(),i=t.getAction("click"),n=t.getAction("hover"),a=t.getAction("right_click"),o=t.getAction("double_click");return as(e,i),qr(e,n),Wr(e,a),ds(e,o),"Click, hover, double-click, right-click, or drag elements"}async function Is(e){let t=await _e(),i=t.getAction("go_to_url"),n=t.getAction("go_back"),a=t.getAction("reload_page");return Yr(e,i),Xr(e,n),Fr(e,a),"Navigate to URLs, go back, or reload the page"}async function Ps(e){let t=await _e(),i=t.getAction("clear_input"),n=t.getAction("input_text"),a=t.getAction("press");return is(e,i),Or(e,n),Dr(e,a),"Type text into inputs, clear input values, or press keyboard keys"}async function Cs(e){let t=await _e(),i=t.getAction("scroll_on_element"),n=t.getAction("scroll_to_text"),a=t.getAction("scroll");return kr(e,i),Er(e,n),xr(e,a),"Scroll the page or scroll to specific text/elements"}async function Ns(e){let t=await _e(),i=t.getAction("close_tab"),n=t.getAction("switch_tab");return rs(e,i),Cr(e,n),"Switch between browser tabs or close tabs"}async function Os(e){let t=await _e(),i=t.getAction("upload_file"),n=t.getAction("wait_for_download_complete");return ur(e,i),gr(e,n),"Upload files or wait for downloads to complete"}async function Ds(e){let t=await _e(),i=t.getAction("get_dropdown_options"),n=t.getAction("select_dropdown_option"),a=t.getAction("set_date_for_native_date_picker");return Kr(e,i),$r(e,n),Ir(e,a),"Get dropdown options, select dropdown values, or set date for native date picker input"}async function Ls(e){let t=await _e(),i=t.getAction("wait"),n=t.getAction("save_variable"),a=t.getAction("done");return mr(e,i),br(e,n),ls(e,a),_s(e),"Wait for conditions, save variables, or complete tasks"}async function Rs(e){let t=(await _e()).getAction("generate_2fa_code");Ur(e,t);let i=new As;return(await Promise.resolve().then(()=>(Tn(),En))).default.registerAction("extract_email_content",i),$s(e,i),"Generate 2FA codes or extract email/activation codes"}async function Fs(e){let t=await _e(),i=t.getAction("verify"),n=t.getAction("ai_extract"),a=t.getAction("ai_wait_until");return ms(e,i),Qr(e,n),wr(e,a),"Perform AI-powered assertions, extractions, or wait conditions"}Te();var tu=[Ms(B),Is(B),Ps(B),Cs(B),Ns(B),Os(B),Ds(B),Ls(B),Fs(B),Rs(B)],
|
|
4387
|
+
${p.body}`,f=await Qd(h,a,t.model);w.info(`Extracted content: ${f}`),f&&f!=="NOT_FOUND"&&u.push({content:f,email_subject:p.subject,email_from:p.from,email_date:p.date})}if(u.length>0){let p=u[0],h=`$email_${t.extraction_type}`;t.extraction_type==="custom"?h="$email_extracted_content":t.extraction_type==="activation_link"?h="$email_magic_link":t.extraction_type==="verification_code"&&(h="$email_otp_code");let f=(new Date().getTime()-o.getTime())/1e3;return w.info(`Successfully extracted content after ${l} attempts in ${f.toFixed(1)} seconds`),{data:p.content,result_variable:h,status:"success",message:`Successfully extracted content from email: ${p.email_subject.substring(0,50)}... (attempts: ${l})`}}else w.info(`Found emails but no extractable content in attempt ${l}`)}else w.info(`No emails found in attempt ${l}`)}catch(c){w.warn(`Error in polling attempt ${l}: ${c.message}`)}if(new Date(Date.now()+n*1e3)>=r){w.info("Not enough time for another polling attempt");break}w.info(`Waiting ${n} seconds before next attempt...`),await new Promise(c=>setTimeout(c,n*1e3))}let s=(new Date().getTime()-o.getTime())/1e3;return{data:void 0,status:"error",message:`No emails with extractable content found after ${l} attempts over ${s.toFixed(1)} seconds`}}catch(a){return w.error(`Error extracting email content: ${a.message}`),{data:void 0,status:"error",message:`Error extracting email content: ${a.message}`}}}qe();U();oe();var ve=require("zod");function Ts(e){switch(e){case"verification_code":return"email_otp_code";case"activation_link":return"email_magic_link";case"custom":return"email_extracted_content";default:return"email_content"}}var As=class{getMailgunConfig(){let e=X().env||{};if(e.MAILGUN_API_KEY)return{apiKey:e.MAILGUN_API_KEY,domain:e.MAILGUN_DOMAIN||""};let t=e.SHIPLIGHT_API_TOKEN;if(t){let i=`${We(t,e.SHIPLIGHT_API_URL)}/mailgun`;return w.debug(`[extract_email_content] Using Shiplight proxy for Mailgun: ${i}`),{apiKey:t,domain:e.MAILGUN_DOMAIN||"",baseURL:i,authHeader:`Bearer ${t}`}}}async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=this.getMailgunConfig();if(!a)throw new Error("Mailgun configuration not provided. Please configure MAILGUN_API_KEY and MAILGUN_DOMAIN, or set SHIPLIGHT_API_TOKEN to route through the Shiplight proxy.");let o=n.kwargs,r=i.getModel?.()||"gemini-2.5-pro",l=await Es(a,{model:r,forward_email:o.forward_email,extraction_type:o.extraction_type,prompt:o.prompt,filters:{from_email:o.filter_from_email,to_email:o.filter_to_email,subject:o.filter_subject,body_contains:o.filter_body_contains},timeout:o.timeout});if(l.status==="success"&&l.data){let s=l.result_variable?.replace(/^\$/,"")||Ts(o.extraction_type);i.variableStore.set(s,l.data),w.info(`[extract_email_content] Extracted and saved to ${s}`)}else throw new Error(l.message||"Failed to extract email content")}transpile(e){let t=e.action_data?.kwargs||{};return['await agent.execAction("extract_email_content", page, {',` action_data: { kwargs: ${JSON.stringify(t)} },`,"});"]}},eu=ve.z.object({forward_email:ve.z.string().describe("Email address where emails are forwarded to (Mailgun inbox)"),extraction_type:ve.z.enum(["verification_code","activation_link","custom"]).describe("Type of content to extract: verification_code for OTP codes, activation_link for magic links, custom for custom prompts"),prompt:ve.z.string().optional().describe("Custom extraction prompt (required when extraction_type is custom)"),filter_from_email:ve.z.string().optional().describe("Filter emails by sender address"),filter_to_email:ve.z.string().optional().describe("Filter emails by recipient address"),filter_subject:ve.z.string().optional().describe("Filter emails by subject (partial match)"),filter_body_contains:ve.z.string().optional().describe("Filter emails by body content (partial match)"),timeout:ve.z.number().optional().describe("Timeout in seconds for polling (default: 60)")});function $s(e,t){e.register({name:"extract_email_content",description:"Extract verification codes, magic links, or custom content from emails received via Mailgun. Polls the Mailgun inbox for matching emails and uses AI to extract the requested content.",schema:eu,async execute(i,n){let{forward_email:a,extraction_type:o,prompt:r,filter_from_email:l,filter_to_email:s,filter_subject:c,filter_body_contains:d,timeout:u}=i,{page:p,agentServices:h}=n;w.info(`[extract_email_content] Extracting ${o} from ${a}`);try{let f={action_description:`Extract ${o} from email`,action_data:{action_name:"extract_email_content",kwargs:{forward_email:a,extraction_type:o,prompt:r,filter_from_email:l,filter_to_email:s,filter_subject:c,filter_body_contains:d,timeout:u}}};await t.execute(p,f,h);let g=Ts(o);return{success:!0,actionEntity:f,message:`Extracted ${o} and saved to $${g}`}}catch(f){return{success:!1,error:f.message,actionEntity:{action_description:`Extract ${o} from email (failed)`,action_data:{action_name:"extract_email_content",kwargs:{forward_email:a,extraction_type:o,prompt:r,filter_from_email:l,filter_to_email:s,filter_subject:c,filter_body_contains:d,timeout:u}},feedback:f.message}}}}})}Ft();Ht();Wt();jt();Ut();Gt();Kt();zt();Xt();Jt();qt();Qt();ei();ti();ii();ni();ai();oi();si();li();ci();di();ui();hi();mi();pi();gi();var Cn=null;async function _e(){if(Cn)return Cn;let e=(await Promise.resolve().then(()=>(Tn(),En))).default;return Cn=new e,Cn}async function Ms(e){let t=await _e(),i=t.getAction("click"),n=t.getAction("hover"),a=t.getAction("right_click"),o=t.getAction("double_click");return as(e,i),qr(e,n),Wr(e,a),ds(e,o),"Click, hover, double-click, right-click, or drag elements"}async function Is(e){let t=await _e(),i=t.getAction("go_to_url"),n=t.getAction("go_back"),a=t.getAction("reload_page");return Yr(e,i),Xr(e,n),Fr(e,a),"Navigate to URLs, go back, or reload the page"}async function Ps(e){let t=await _e(),i=t.getAction("clear_input"),n=t.getAction("input_text"),a=t.getAction("press");return is(e,i),Or(e,n),Dr(e,a),"Type text into inputs, clear input values, or press keyboard keys"}async function Cs(e){let t=await _e(),i=t.getAction("scroll_on_element"),n=t.getAction("scroll_to_text"),a=t.getAction("scroll");return kr(e,i),Er(e,n),xr(e,a),"Scroll the page or scroll to specific text/elements"}async function Ns(e){let t=await _e(),i=t.getAction("close_tab"),n=t.getAction("switch_tab");return rs(e,i),Cr(e,n),"Switch between browser tabs or close tabs"}async function Os(e){let t=await _e(),i=t.getAction("upload_file"),n=t.getAction("wait_for_download_complete");return ur(e,i),gr(e,n),"Upload files or wait for downloads to complete"}async function Ds(e){let t=await _e(),i=t.getAction("get_dropdown_options"),n=t.getAction("select_dropdown_option"),a=t.getAction("set_date_for_native_date_picker");return Kr(e,i),$r(e,n),Ir(e,a),"Get dropdown options, select dropdown values, or set date for native date picker input"}async function Ls(e){let t=await _e(),i=t.getAction("wait"),n=t.getAction("save_variable"),a=t.getAction("done");return mr(e,i),br(e,n),ls(e,a),_s(e),"Wait for conditions, save variables, or complete tasks"}async function Rs(e){let t=(await _e()).getAction("generate_2fa_code");Ur(e,t);let i=new As;return(await Promise.resolve().then(()=>(Tn(),En))).default.registerAction("extract_email_content",i),$s(e,i),"Generate 2FA codes or extract email/activation codes"}async function Fs(e){let t=await _e(),i=t.getAction("verify"),n=t.getAction("ai_extract"),a=t.getAction("ai_wait_until");return ms(e,i),Qr(e,n),wr(e,a),"Perform AI-powered assertions, extractions, or wait conditions"}Te();var tu=[Ms(B),Is(B),Ps(B),Cs(B),Ns(B),Os(B),Ds(B),Ls(B),Fs(B),Rs(B)],Px=Promise.all(tu);bt();dt();Le();wi();U();var Ra=require("playwright");var Fa=require("child_process"),Us=Z(require("fs"),1),Bs=Z(require("path"),1);function gu(){if(process.platform==="win32"){let i=(0,Fa.execFileSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command","Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,CommandLine | ConvertTo-Json -Compress"],{encoding:"utf-8",timeout:1e4}),n=JSON.parse(i.trim());return(Array.isArray(n)?n:[n]).filter(a=>a!==null&&typeof a=="object").filter(a=>typeof a.ProcessId=="number").map(a=>({pid:a.ProcessId,ppid:typeof a.ParentProcessId=="number"?a.ParentProcessId:0,args:typeof a.CommandLine=="string"?a.CommandLine:""}))}let e=(0,Fa.execFileSync)("ps",["-axo","pid=,ppid=,args="],{encoding:"utf-8"}),t=[];for(let i of e.split(`
|
|
4388
4388
|
`)){let n=i.trimStart().match(/^(\d+)\s+(\d+)\s+(.*)$/);n&&t.push({pid:parseInt(n[1],10),ppid:parseInt(n[2],10),args:n[3]})}return t}function fu(e){let t=gu(),i=new Set([e]),n=!0;for(;n;){n=!1;for(let a of t)!i.has(a.pid)&&i.has(a.ppid)&&(i.add(a.pid),n=!0)}for(let a of t){if(a.pid===e||!i.has(a.pid)||!/chrome|chromium/i.test(a.args))continue;let o=a.args.match(/--user-data-dir=(?:"([^"]+)"|(\S+))/);if(o)return o[1]??o[2]}return null}async function wu(e,t){let i=Bs.join(e,"DevToolsActivePort"),n=Date.now()+t;for(;Date.now()<n;){try{let a=Us.readFileSync(i,"utf-8").trim(),[o,r]=a.split(`
|
|
4389
|
-
`),l=parseInt(o,10);if(Number.isFinite(l)&&l>0&&typeof r=="string"&&r.startsWith("/"))return{port:l,wsPath:r}}catch{}await new Promise(a=>setTimeout(a,100))}throw new Error(`Timed out waiting for ${i} \u2014 Chromium never exposed DevTools`)}async function Ha(e,t=3e4){let i=fu(e);if(!i)throw new Error(`No Chromium descendant of pid ${e} with --user-data-dir found. Did you launch with --remote-debugging-port=0 and is the browser still running?`);let{port:n,wsPath:a}=await wu(i,t);return`ws://127.0.0.1:${n}${a}`}dt();var yu=(e=>(e.Desktop="desktop",e.Mobile="mobile",e))(yu||{});var bi=(e=>(e.Started="started",e.Action="action",e.Completion="completion",e.Error="error",e.Aborted="aborted",e.Keepalive="keepalive",e))(bi||{});Lt();Ue();Wa();re();dt();Le();U();Le();U();var ja=require("otplib"),
|
|
4390
|
-
`),y=new Function("page","agent",`return (async () => { ${g} })();`);try{await y(r,this.agent),s={actionGenerationDebugInfo:this.agent._getContext()?.lastActionDebugInfo}}catch(m){let b=this.agent._getContext();return{status:"error",details:this.agent.getAgentNote()||m.message,actionGenerationDebugInfo:b?.lastActionDebugInfo,testContext:Ua(b?.variableStore)}}}else{let h=i.action_description||o.action_name,f=!!a?.withSelfHealing&&Be.canSelfHeal(i);s=await this.agent.step(r,async()=>{await this.agent.execAction(o.action_name,r,i)},h,n,l,f)}let c=this.agent.getAgentNote(),u=this.agent._getContext()?.variableStore,p={...s,status:"success",testContext:Ua(u)};if(c&&(p.details=c),l){let h=this.agent.getNewActionEntities().get(l);if(h){let{element_index:f,...g}=h.action_data?.kwargs||{};p.newActionEntity={...h,action_data:h.action_data?{...h.action_data,kwargs:g}:h.action_data}}}return p}async runStep(t,i,n,a,o){let r=[];this.abortController=new AbortController;try{let l=await this.agent.run(this.agent.agentServices.validatePage(this.page),i,n,{onAction:c=>{r.push(c),a({type:bi.Action,data:{action_entity:c}})}}),s=this.agent._getContext()?.variableStore;return a({type:bi.Completion,data:{success:l?.success??!0,details:l?.details,testContext:Ua(s)}}),{success:l?.success??!0,actions:r,details:l?.details}}finally{this.abortController=null}}async executeFunction(t){let i=t.functionName,[n,a]=i.split("#");try{
|
|
4389
|
+
`),l=parseInt(o,10);if(Number.isFinite(l)&&l>0&&typeof r=="string"&&r.startsWith("/"))return{port:l,wsPath:r}}catch{}await new Promise(a=>setTimeout(a,100))}throw new Error(`Timed out waiting for ${i} \u2014 Chromium never exposed DevTools`)}async function Ha(e,t=3e4){let i=fu(e);if(!i)throw new Error(`No Chromium descendant of pid ${e} with --user-data-dir found. Did you launch with --remote-debugging-port=0 and is the browser still running?`);let{port:n,wsPath:a}=await wu(i,t);return`ws://127.0.0.1:${n}${a}`}dt();var yu=(e=>(e.Desktop="desktop",e.Mobile="mobile",e))(yu||{});var bi=(e=>(e.Started="started",e.Action="action",e.Completion="completion",e.Error="error",e.Aborted="aborted",e.Keepalive="keepalive",e))(bi||{});Lt();Ue();Wa();re();dt();Le();U();Le();U();var ja=require("otplib"),Wv=(0,ja.createGuardrails)({MIN_SECRET_BYTES:1});dt();tt();xe();var xu=require("ai"),Gv=20*1024*1024;Rt();U();Lt();zi();Gi();Ii();et();Li();Pi();Hi();Je();Ui();Et();St();Te();bt();nn();Ue();$t();Mt();nt();It();Pt();Wa();re();dt();Le();wi();tt();xe();_t();Ze();kt();Oe();qe();Ca();Xi();Yi();Ji();qi();Zi();Qi();en();tn();ln();cn();dn();Ft();Ht();Wt();jt();Ut();Gt();Kt();zt();Xt();Jt();qt();Qt();ei();ti();ii();ni();ai();oi();si();li();ci();di();ui();hi();mi();pi();gi();Nt();_n();Rt();Y();He();U();oe();Ot();Sn();j();Se();function Ua(e){if(!e)return;let t=e.getAll(),i=e.getAllSensitiveKeys();if(i.size===0)return t;let n={};for(let[a,o]of Object.entries(t))n[a]=i.has(a)?"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022":o;return n}function ku(e,t,i){let n=e.startsWith(".")?t:i??process.cwd();return se.resolve(n,e)}var ut=class{page;agent;testDir=process.cwd();projectRoot;sessionId="pw-"+Math.random().toString(36).slice(2,10);abortController=null;recorderStopResolver;recorderEnabled=!1;screenshotHistory=[];yamlFilePath;artifactsDir;constructor(t,i,n,a){this.page=t,this.agent=i,this.projectRoot=a,n&&(this.agent._getContext().testDataDir=n)}cdpEndpoint=null;setCdpEndpoint(t){this.cdpEndpoint=t}getCdpEndpoint(){if(this.cdpEndpoint)return this.cdpEndpoint;let t=this.page.context().browser();if(!t)return null;let i=t.wsEndpoint?.();return typeof i=="string"?i:null}async createSession(t){if(t?.testFilePath){this.testDir=se.dirname(t.testFilePath),this.yamlFilePath=t.testFilePath;let i=this.projectRoot??this.testDir,n=se.basename(t.testFilePath,".test.yaml");if(this.artifactsDir=se.join(i,".shiplight","artifacts",n),t.testFilePath.endsWith(".test.yaml"))try{let a=await ht.readFile(t.testFilePath,"utf-8"),r=(0,zs.parse)(a)?.parameters;if(r&&r.length>0&&r[0].values)for(let[l,s]of Object.entries(r[0].values))this.agent.agentServices.saveVariable(l,s)}catch{}}return{sessionId:this.sessionId}}async executeLogin(t){return{status:"success",details:"Handled by Playwright"}}async ensureBrowser(t){return{page:this.page,liveviewUrl:""}}async startDebug(t){return{sessionId:this.sessionId,liveviewUrl:"",browserWsUrl:""}}async executeAction(t,i,n,a){let o=i.action_data||i.action;if(!o)throw new Error("ActionEntity has no action_data");console.error(`[pw-sandbox] executeAction stepId=${JSON.stringify(n)} action_name=${JSON.stringify(o.action_name)} locator=${JSON.stringify(i.locator)} kwargs=${JSON.stringify(o.kwargs)}`);let r=this.agent.agentServices.validatePage(this.page);if(o.action_name==="js_code"&&n==="prelude"){if(r.url()==="about:blank"){let h=o.kwargs?.code?.match(/PLAYWRIGHT_STARTING_URL \|\| '([^']*)'/)?.[1];h&&await r.goto(h,{waitUntil:"domcontentloaded"})}return{status:"success"}}if(o.action_name==="js_code"&&o.kwargs?.isSync===!0)return this.executeCode(t,o.kwargs.code||"");if(o.action_name==="function"&&o.kwargs?.functionName?.includes("#"))return this.executeFunction(o.kwargs);let l=a?.stmtUid;l&&this.agent.getNewActionEntities().delete(l);let s;if(Be.isAiAction(i)){let g=new fi().transpile(i,n,l).join(`
|
|
4390
|
+
`),y=new Function("page","agent",`return (async () => { ${g} })();`);try{await y(r,this.agent),s={actionGenerationDebugInfo:this.agent._getContext()?.lastActionDebugInfo}}catch(m){let b=this.agent._getContext();return{status:"error",details:this.agent.getAgentNote()||m.message,actionGenerationDebugInfo:b?.lastActionDebugInfo,testContext:Ua(b?.variableStore)}}}else{let h=i.action_description||o.action_name,f=!!a?.withSelfHealing&&Be.canSelfHeal(i);s=await this.agent.step(r,async()=>{await this.agent.execAction(o.action_name,r,i)},h,n,l,f)}let c=this.agent.getAgentNote(),u=this.agent._getContext()?.variableStore,p={...s,status:"success",testContext:Ua(u)};if(c&&(p.details=c),l){let h=this.agent.getNewActionEntities().get(l);if(h){let{element_index:f,...g}=h.action_data?.kwargs||{};p.newActionEntity={...h,action_data:h.action_data?{...h.action_data,kwargs:g}:h.action_data}}}return p}async runStep(t,i,n,a,o){let r=[];this.abortController=new AbortController;try{let l=await this.agent.run(this.agent.agentServices.validatePage(this.page),i,n,{onAction:c=>{r.push(c),a({type:bi.Action,data:{action_entity:c}})}}),s=this.agent._getContext()?.variableStore;return a({type:bi.Completion,data:{success:l?.success??!0,details:l?.details,testContext:Ua(s)}}),{success:l?.success??!0,actions:r,details:l?.details}}finally{this.abortController=null}}async executeFunction(t){let i=t.functionName,[n,a]=i.split("#");try{if(se.isAbsolute(n))return{status:"error",details:`Absolute paths are not supported in call: references. Use a path relative to the project root (got: "${n}")`};let o=ku(n,this.testDir,this.projectRoot),l=(await import((0,Gs.pathToFileURL)(o).href))[a];if(typeof l!="function")return{status:"error",details:`Export "${a}" not found or not a function in ${n}`};let c=l.toString().match(/\(([^)]*)\)/),d=c&&c[1].trim()?c[1].split(",").map(b=>b.split(":")[0].trim().replace(/\?$/,"")):[],u=Array.isArray(t.parameterNames)?t.parameterNames.map(String):[],p=Array.isArray(t.parameterValues)?t.parameterValues.map(String):Array.isArray(t.args)?t.args.map(String):[],h={};u.forEach((b,v)=>{let S=b.split(":")[0].trim();h[S]=p[v]??""});let f=["page","agent","request","testContext"],g=this.agent.agentServices.validatePage(this.page),y=d.map(b=>{if(b==="page")return g;if(b==="agent")return this.agent;if(b==="request")return this.page.context().request;if(b==="testContext")return this.agent._getContext?.()?.variableStore;let v=h[b]??"";return v.startsWith("$")?this.agent.agentServices.readVariable(v.substring(1)):v}),m=d.length>0?y:p.map(b=>b==="page"?g:b==="agent"?this.agent:b==="request"?this.page.context().request:b==="testContext"?this.agent._getContext?.()?.variableStore:b.startsWith("$")?this.agent.agentServices.readVariable(b.substring(1)):b);return await l(...m),{status:"success"}}catch(o){let r=o instanceof Error?o.message:String(o);return{status:"error",details:`Function call failed: ${i} \u2014 ${r}`}}}async executeCode(t,i){try{return{status:"success",result:await new Function("page","expect","agent",`return (async () => { return (${i}); })();`)(this.agent.agentServices.validatePage(this.page),Vs.expect,this.agent)}}catch(n){return{status:"error",details:n instanceof Error?n.message:String(n)}}}stopRunStep(t){return this.abortController?(this.abortController.abort(),!0):!1}async evaluate(t,i,n){try{let a=await this.agent.evaluate(this.agent.agentServices.validatePage(this.page),i);return{status:"success",conclusion:a?"true":"false",explanation:a?`Condition met: ${i}`:`Condition not met: ${i}`}}catch(a){return{status:"error",conclusion:"unknown",explanation:a.message}}}async generateAction(t,i,n,a){let o=await this.agent.generate(this.agent.agentServices.validatePage(this.page),i,n,a?.usePureVision),r=o.actions?.[0];return r?{status:"success",action:r,explanation:o.details,debugInfo:o.debugInfo,completes_instruction:o.success}:{status:"error",explanation:o.details||"Failed to generate action",debugInfo:o.debugInfo}}async takeScreenshot(t,i){let n=await this.agent.agentServices.validatePage(this.page).screenshot(),a=i??`debug-${this.screenshotHistory.length}`,o;if(this.artifactsDir){let r=se.join(this.artifactsDir,a.replace(/\./g,"-"));await ht.mkdir(r,{recursive:!0}),o=se.join(r,"screenshot.png")}else o=se.join(Ks.tmpdir(),`shiplight-screenshot-${Date.now()}.png`);return await ht.writeFile(o,n),this.screenshotHistory.push({stepId:a,path:o}),{screenshot:n.toString("base64"),screenshotPath:o}}getSessionArtifacts(t){return{outputDir:this.artifactsDir,screenshots:[...this.screenshotHistory]}}async startRecorder(t,i,n){let a=this.page.context(),o=new Promise(l=>{this.recorderStopResolver=l}),r={actionAdded:(l,s,c)=>{i({type:"actionAdded",action:s.action,code:c,timestamp:Date.now()})},actionUpdated:(l,s,c)=>{i({type:"actionUpdated",action:s.action,code:c,timestamp:Date.now()})},signalAdded:(l,s)=>{i({type:"signal",signal:s.signal,timestamp:Date.now()})}};if(this.recorderEnabled)a._onRecorderEventSink=r,await this.page.evaluate(()=>window.__pw_recorderSetMode?.("recording")).catch(()=>{});else{let l="x-pw-overlay { display: none !important; }";await a.addInitScript(`(() => {
|
|
4391
4391
|
const orig = Element.prototype.attachShadow;
|
|
4392
4392
|
Element.prototype.attachShadow = function(init) {
|
|
4393
4393
|
const shadow = orig.call(this, init);
|
|
@@ -4409,4 +4409,4 @@ ${p.body}`,f=await Qd(h,a,t.model);w.info(`Extracted content: ${f}`),f&&f!=="NOT
|
|
|
4409
4409
|
}
|
|
4410
4410
|
return shadow;
|
|
4411
4411
|
};
|
|
4412
|
-
})()`).catch(()=>{});await a._enableRecorder({mode:"recording",recorderMode:"api",handleSIGINT:!1,omitCallTracking:!0,testIdAttributeName:n||"data-testid"},r),await this.page.evaluate(()=>window.__pw_recorderSetMode?.("recording")).catch(()=>{})}this.recorderEnabled=!0,await o}async stopRecorder(t){this.page.context()._onRecorderEventSink=void 0,await this.page.evaluate(()=>window.__pw_recorderSetMode?.("standby")).catch(()=>{}),this.recorderStopResolver&&(this.recorderStopResolver(),this.recorderStopResolver=void 0)}async terminateSession(t){console.error("[debugger] Playwright session released")}async cleanupAll(){}};async function
|
|
4412
|
+
})()`).catch(()=>{});await a._enableRecorder({mode:"recording",recorderMode:"api",handleSIGINT:!1,omitCallTracking:!0,testIdAttributeName:n||"data-testid"},r),await this.page.evaluate(()=>window.__pw_recorderSetMode?.("recording")).catch(()=>{})}this.recorderEnabled=!0,await o}async stopRecorder(t){this.page.context()._onRecorderEventSink=void 0,await this.page.evaluate(()=>window.__pw_recorderSetMode?.("standby")).catch(()=>{}),this.recorderStopResolver&&(this.recorderStopResolver(),this.recorderStopResolver=void 0)}async terminateSession(t){console.error("[debugger] Playwright session released")}async cleanupAll(){}};async function nh(e){let{yamlFilePath:t,port:i,page:n,agent:a,projectRoot:o}=e,r=o??Ti.default.dirname(t),l=new ut(n,a,r,o);try{let f=await Ha(process.pid);l.setCdpEndpoint(f),console.error(`[debugger] CDP endpoint: ${f}`)}catch(f){console.error(`[debugger] Could not discover CDP endpoint: ${f.message}`)}let s=(0,Gn.default)();s.use(Gn.default.json({limit:"10mb"})),s.use((f,g,y)=>{if(g.setHeader("Access-Control-Allow-Origin","*"),g.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS"),g.setHeader("Access-Control-Allow-Headers","Content-Type, Accept, Cache-Control, Idempotency-Key"),f.method==="OPTIONS")return g.sendStatus(204);y()});let{createTestFlowRouter:c}=await Promise.resolve().then(()=>(Hl(),Fl)),{createIntRunnerRouter:d}=await Promise.resolve().then(()=>(Ul(),jl)),u=Ti.default.join(o??Ti.default.dirname(t),".shiplight","artifacts");s.use("/api/report-assets",Gn.default.static(u)),s.use(c({initialDir:Ti.default.dirname(t),initialFile:t,projectRoot:o})),s.use(d(l));let p=await new Promise((f,g)=>{let y=s.listen(i,"127.0.0.1",()=>f(y));y.on("error",g)});return{url:`http://localhost:${i}`,close:async()=>{await l.cleanupAll(),await new Promise((f,g)=>{p.close(y=>y?g(y):f())})}}}0&&(module.exports={PlaywrightSandboxService,startPlaywrightDebugServer});
|