shiplightai 0.1.91 → 0.1.93
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 +69 -69
- package/dist/cjs/fixture.cjs +64 -64
- package/dist/cjs/index.cjs +89 -89
- package/dist/cjs/reporter.cjs +8 -8
- package/dist/cli.js +45 -45
- package/dist/debugger-pw.js +68 -68
- package/dist/fixture.js +64 -64
- package/dist/index.js +58 -58
- package/dist/reporter.js +10 -10
- package/dist/static-embedded/assets/{index-Dm1PmCd3.js → index-BW-lK2en.js} +24 -14
- package/dist/static-embedded/assets/{index-CzL8SI3t.js → index-DVziGDLg.js} +2 -2
- package/dist/static-embedded/index.html +1 -1
- package/package.json +5 -5
package/dist/cjs/debugger-pw.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var ac=Object.create;var Oi=Object.defineProperty;var oc=Object.getOwnPropertyDescriptor;var rc=Object.getOwnPropertyNames;var sc=Object.getPrototypeOf,lc=Object.prototype.hasOwnProperty;var x=(e,t)=>()=>(e&&(t=e(e=0)),t);var Qe=(e,t)=>{for(var i in t)Oi(e,i,{get:t[i],enumerable:!0})},wo=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of rc(t))!lc.call(e,a)&&a!==i&&Oi(e,a,{get:()=>t[a],enumerable:!(n=oc(t,a))||n.enumerable});return e};var te=(e,t,i)=>(i=e!=null?ac(sc(e)):{},wo(t||!e||!e.__esModule?Oi(i,"default",{value:e,enumerable:!0}):i,e)),cc=e=>wo(Oi({},"__esModule",{value:!0}),e);function q(){return yo.getConfig()}var dc,yo,Li,ae=x(()=>{"use strict";dc=class{constructor(){this.config=this.getDefaultConfig()}getDefaultConfig(){return{logLevel:1,debugAgent:!1,testResultsJsonPath:void 0,consoleLogsPath:void 0}}getConfig(){return{...this.config}}updateConfig(e){this.config={...this.config,...e}}resetConfig(){this.config=this.getDefaultConfig()}get(e){return this.config[e]}set(e,t){this.config[e]=t}},yo=new dc,Li=yo});var uc,hc,f,G=x(()=>{"use strict";ae();uc=class{getLevel(){return Li.get("logLevel")}isStderrOnly(){return Li.get("stderrOnly")===!0}debug(...e){this.getLevel()<=0&&(this.isStderrOnly()?console.error("[DEBUG]",...e):console.log("[DEBUG]",...e))}info(...e){this.getLevel()<=1&&(this.isStderrOnly()?console.error("[INFO]",...e):console.log("[INFO]",...e))}log(...e){this.info(...e)}warn(...e){this.getLevel()<=2&&console.warn("[WARN]",...e)}error(...e){this.getLevel()<=3&&console.error("[ERROR]",...e)}setLevel(e){Li.set("logLevel",e)}},hc=new uc,f=hc});var Zn,mc,T,re=x(()=>{"use strict";ae();Zn=require("fs"),mc=class{constructor(){this.initialized=!1}init(){if(this.initialized)return;let e=q().agentLogPath;if(e)try{(0,Zn.appendFileSync)(e,`
|
|
2
2
|
=== Agent Execution Log ===
|
|
3
3
|
Started: ${new Date().toISOString()}
|
|
4
4
|
|
|
@@ -11,9 +11,9 @@ ${e}`)}prompt(e,t){this.section("LLM Prompt"),this.log(`System Prompt:
|
|
|
11
11
|
${e}`),this.log(`
|
|
12
12
|
User Prompt:
|
|
13
13
|
${t}`)}response(e){this.log(`LLM Response:
|
|
14
|
-
${e}`)}error(e,t){this.log(`ERROR: ${e}`),t&&(this.log(`Error details: ${t.message}`),t.stack&&this.log(`Stack: ${t.stack}`))}isEnabled(){return!!q().agentLogPath}},T=new uc});var ea,hc,mc,pc,yo,Di,Qn,bo,ta,Se=x(()=>{"use strict";ea=Object.defineProperty,hc=Object.getOwnPropertyDescriptor,mc=Object.getOwnPropertyNames,pc=Object.prototype.hasOwnProperty,yo=(e,t)=>()=>(e&&(t=e(e=0)),t),Di=(e,t)=>{for(var i in t)ea(e,i,{get:t[i],enumerable:!0})},Qn=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of mc(t))!pc.call(e,a)&&a!==i&&ea(e,a,{get:()=>t[a],enumerable:!(n=hc(t,a))||n.enumerable});return e},bo=(e,t,i)=>(Qn(e,t,"default"),i&&Qn(i,t,"default")),ta=e=>Qn(ea({},"__esModule",{value:!0}),e)});function R(e,t){return t??e?.getActionSettings()?.action_timeout_ms??na}function gc(e){return e.replace(/\r\n/g," ").replace(/\n/g," ").replace(/\r/g," ").trim()}function F(e,t){let i=Le(t);return i?new Function("page",`return ${i}`)(e):null}async function ia(e,t=[]){let i=e;for(let n of t){let a=await i.locator(n).elementHandle();if(!a)return null;let o=await a.contentFrame();if(await a.dispose(),!o)return null;i=o}return i}function fc(e){let t={action_data:e.action_data};return e.locator&&(t.locator=e.locator),e.xpath&&(t.xpath=e.xpath),e.frame_path&&(t.frame_path=e.frame_path),t}function wc(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function yc(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 Le(e){let t=wc(e),i=e.locator;if(typeof i=="string"&&i.trim())return i=i.trim(),i.endsWith("first()")?`${t}.${i}`:`${t}.${i}.first()`;let n=yc(e);if(n){let a=JSON.stringify(n);return`${t}.locator(${a}).first()`}return null}var Ri,Et,na,fe,C,G=x(()=>{"use strict";Se();Ri={};Di(Ri,{ACTION_TIMEOUT:()=>na,GOTO_TIMEOUT:()=>fe,LOCATOR_TIMEOUT:()=>Et,getActionTimeoutMs:()=>R,getFrameContext:()=>ia,getLocator:()=>F,getMinimalActionEntity:()=>fc,getPageLocatorExpression:()=>Le,sanitizeForComment:()=>gc});C=yo(()=>{Et=5e3,na=1e4,fe=2e4})});async function aa(e,t,i=[],n=[]){try{let a=await ia(e,i);if(!a)return f.warn(`Could not find frame context for xpath: ${t}`),null;let o=null;if(n.length>0){let s=n[0];if(!s)return f.warn(`Missing shadow host xpath for element: ${t}`),null;let l=a.locator(`xpath=${xo(s)}`),c=bc(t);if(o=await(c?l.locator(`css=${c}`):l.locator(`xpath=${xo(t)}`)).elementHandle({timeout:Et}),!o)return f.warn(`Could not find shadow DOM element with xpath: ${t}`),null}else if(o=await a.locator(`xpath=${t}`).elementHandle({timeout:Et}),!o)return f.warn(`Could not find element with xpath: ${t}`),null;let r=await a.evaluate(s=>typeof playwright<"u"&&playwright.generateLocator?playwright.generateLocator(s):null,o);return await o.dispose(),r?(f.debug(`Generated locator for ${t}: ${r}`),r):(f.debug("playwright.generateLocator is not available (PWDEBUG=console not set), using xpath fallback"),null)}catch(a){return f.error(`Error in pickBestLocator: ${a}`),null}}async function oa(e,t){try{let i=await(await t.ownerFrame()??e).evaluate(n=>typeof playwright<"u"&&playwright.generateLocator?playwright.generateLocator(n):null,t);return await t.dispose(),i?(f.debug(`Generated locator: ${i}`),i):(f.debug("playwright.generateLocator is not available (PWDEBUG=console not set), using xpath fallback"),null)}catch(i){return f.error(`Error in pickBestLocator: ${i}`),null}}function xo(e){let t=e.trim();return t.startsWith("/")||t.startsWith("(")||t.startsWith(".")?t:`//${t}`}function bc(e){let t=e.trim().replace(/^\/+/,"");if(!t)return null;let i=t.split("/").filter(Boolean),n=[];for(let a of i){let o=a.match(/^([a-zA-Z][\w-]*)(?:\[(\d+)\])?$/);if(!o)return null;let r=o[1].toLowerCase(),s=o[2]?`:nth-of-type(${o[2]})`:"";n.push(`${r}${s}`)}return n.join(" > ")}var je=x(()=>{"use strict";z();G();C()});async function Tt(e,t,i){await e.evaluate(()=>{document.getElementById("playwright-highlight-container")?.remove(),window._highlightCleanupFunctions&&(window._highlightCleanupFunctions.forEach(l=>l()),window._highlightCleanupFunctions=[])});let n=await e.screenshot({type:"png",fullPage:!1}),{default:a}=await import("sharp"),o=a(n),{width:r=0,height:s=0}=await o.metadata();return T.log(`Screenshot actual: ${r}x${s}, viewport: ${t}x${i}`),(r!==t||s!==i?await o.resize(t,i).png().toBuffer():n).toString("base64")}async function Ee(e,t,i){let n=await e.evaluateHandle(r=>document.elementFromPoint(r.x,r.y),{x:t,y:i}),a=n.asElement();if(!a)throw await n.dispose(),new Error(`No element found at (${t}, ${i})`);let o=await a.boundingBox();if(!o)throw await n.dispose(),new Error(`Element at (${t}, ${i}) has no bounding box`);return{relative_x:t-(o.x+o.width/2),relative_y:i-(o.y+o.height/2),element:a}}async function Fi(e,t){if(!t)return{xpath:void 0,locator:void 0,frame_path:[]};let i=await t.evaluate(a=>{let o=[],r=a;for(;r&&r.nodeType===Node.ELEMENT_NODE;){let s=1,l=r.previousElementSibling;for(;l;)l.tagName===r.tagName&&s++,l=l.previousElementSibling;o.unshift(`${r.tagName.toLowerCase()}[${s}]`),r=r.parentElement}return o.length?`/${o.join("/")}`:null}).catch(()=>null),n=await oa(e,t);return{xpath:i??void 0,locator:n??void 0,frame_path:[]}}function Hi(e,t,i){return{action_description:e,action_data:t,locator:i.locator??void 0,xpath:i.xpath??void 0,frame_path:i.frame_path}}var et=x(()=>{"use strict";re();je()});function kc(e){return e.startsWith(xc)}function Be(e,t){let i=t?.trim();return i?Sc(i):kc(e)?vc:_c}function Sc(e){return e.endsWith("/")?e.slice(0,-1):e}var xc,vc,_c,tt=x(()=>{"use strict";xc="shp_",vc="https://nova-api.shiplight.ai",_c="https://api.shiplight.ai"});function vo(e,t){return`${Be(e,t)}/llm/v1`}function _o(e,t){return`${Be(e,t)}/llm/v1`}function ko(e,t){return`${Be(e,t)}/llm/v1beta`}function So(e,t){return`${Be(e,t)}/llm`}var De=x(()=>{"use strict";tt()});function Wi(){let e=(q().env||{}).GOOGLE_GENAI_USE_VERTEXAI;return e==="True"||e==="true"}function Ao(e){let t=q().env||{};if(Wi()){let a=t.GOOGLE_CLOUD_PROJECT;if(!a)throw new Error("GOOGLE_CLOUD_PROJECT is required when using Vertex AI");let o=e.startsWith("gemini-3")?"global":t.GOOGLE_CLOUD_LOCATION;if(!o)throw new Error("GOOGLE_CLOUD_LOCATION is required when using Vertex AI");return f.debug(`Using Vertex AI provider: model=${e}, location=${o}`),(0,To.createVertex)({project:a,location:o})(e)}let i=t.GOOGLE_API_KEY;if(i)return f.debug(`Using Google AI provider (API key): model=${e}`),(0,ra.createGoogleGenerativeAI)({apiKey:i})(e);let n=t.SHIPLIGHT_API_TOKEN;if(n){let a=ko(n,t.SHIPLIGHT_API_URL);return f.debug(`Using Shiplight LLM proxy (Google): model=${e}, baseURL=${a}`),(0,ra.createGoogleGenerativeAI)({apiKey:n,baseURL:a})(e)}throw new Error("Google API key is missing. Set GOOGLE_API_KEY in SDK config or environment.")}function $o(e,t){let i={thinkingConfig:{thinkingBudget:512,includeThoughts:!0}},n={thinkingConfig:{thinkingLevel:"minimal",includeThoughts:!0},mediaResolution:Eo.MEDIA_RESOLUTION_HIGH},a;switch(t){case"gemini-3-flash-preview":a={...n};break;default:a={...i},e===1&&(a.mediaResolution=Eo.MEDIA_RESOLUTION_HIGH)}return Wi()?{vertex:a}:{google:a}}var ra,To,Eo,it=x(()=>{"use strict";De();z();ae();ra=require("@ai-sdk/google"),To=require("@ai-sdk/google-vertex"),Eo={MEDIA_RESOLUTION_HIGH:"MEDIA_RESOLUTION_HIGH",MEDIA_RESOLUTION_MEDIUM:"MEDIA_RESOLUTION_MEDIUM",MEDIA_RESOLUTION_LOW:"MEDIA_RESOLUTION_LOW"}});function we(e,t){return Math.round(e/1e3*t)}async function Tc(e,t,i,n,a){let o=null,r=null;try{switch(t){case"click_at":{let s=we(i.x,n),l=we(i.y,a),c=await Ee(e,s,l);o={action_name:"click_by_coordinates",kwargs:{relative_x:c.relative_x,relative_y:c.relative_y}},r=c.element;break}case"right_click_at":{let s=we(i.x,n),l=we(i.y,a),c=await Ee(e,s,l);o={action_name:"right_click_by_coordinates",kwargs:{relative_x:c.relative_x,relative_y:c.relative_y}},r=c.element;break}case"double_click_at":{let s=we(i.x,n),l=we(i.y,a),c=await Ee(e,s,l);o={action_name:"double_click_by_coordinates",kwargs:{relative_x:c.relative_x,relative_y:c.relative_y}},r=c.element;break}case"drag_and_drop":{let s=we(i.x,n),l=we(i.y,a),c=we(i.destination_x,n),d=we(i.destination_y,a),u=await Ee(e,s,l);o={action_name:"drag_drop",kwargs:{relative_x:u.relative_x,relative_y:u.relative_y,delta_x:c-s,delta_y:d-l}},r=u.element;break}default:T.log(`Unsupported Gemini function: ${t}`)}}catch(s){T.error(`Error mapping Gemini action "${t}"`,s)}return{action_data:o,locatorInfo:await Fi(e,r)}}async function Io(e){let{statement:t,page:i,screenshotB64:n,viewportWidth:a,viewportHeight:o,modelId:r}=e,s=r||Ac,l=q(),c;if(Wi()){let b=l.env?.GOOGLE_CLOUD_PROJECT;if(!b)return{status:"error",error:"GOOGLE_CLOUD_PROJECT is required when using Vertex AI."};let v=l.env?.GOOGLE_CLOUD_LOCATION??"global";c={vertexai:!0,project:b,location:v}}else{let b=l.env?.GOOGLE_API_KEY;if(b)f.debug(`Using Google AI provider (API key): model=${s}`),c={apiKey:b};else{let v=l.env?.SHIPLIGHT_API_TOKEN;if(v){let S=So(v,l.env?.SHIPLIGHT_API_URL);f.debug(`Using Shiplight LLM proxy (Google CUA): model=${s}, baseUrl=${S}`),c={apiKey:v,httpOptions:{baseUrl:S}}}else return{status:"error",error:"Google API key is missing. Set GOOGLE_API_KEY in SDK config or environment."}}}let d=new Ui.GoogleGenAI(c);T.log(`Sending request to Gemini CUA (model=${s})...`);let u=await d.models.generateContent({model:s,contents:[{role:"user",parts:[{text:`Execute this action: ${t}`},{inlineData:{mimeType:"image/png",data:n}}]}],config:{tools:[{computerUse:{environment:Ui.Environment.ENVIRONMENT_BROWSER,excludedPredefinedFunctions:["search","type_text_at","scroll_document","navigate","go_back","go_forward","key_combination","hover_at","scroll_at"]}},{functionDeclarations:Ec}],temperature:.1}});T.log("Received response from Gemini CUA");let p=u.candidates?.[0];if(!p)return{status:"error",error:"No candidates in Gemini response"};let m=p.content?.parts?.find(b=>b.functionCall);if(!m)return{status:"error",reasoning:p.content?.parts?.filter(b=>b.text).map(b=>b.text).join(" ")||"No action generated",error:"No function call in Gemini response"};let{name:y,args:g}=m.functionCall;T.log(`Generated function call: ${y} with args ${JSON.stringify(g)}`),f.debug(`Generated function call: ${y} with args ${JSON.stringify(g)}`);let{action_data:w,locatorInfo:h}=await Tc(i,y,g,a,o);return w?{status:"success",actionEntity:Hi(t,w,h),reasoning:"Action generated successfully using Gemini computer use",goalAccomplished:!0}:{status:"error",error:`Unsupported or invalid Gemini action: ${y}`}}var Ui,Mo,Ec,Ac,ji=x(()=>{"use strict";et();re();it();De();z();ae();Ui=require("@google/genai");Mo={type:"object",properties:{x:{type:"integer",description:"X coordinate in the 0-1000 normalized space."},y:{type:"integer",description:"Y coordinate in the 0-1000 normalized space."}},required:["x","y"]},Ec=[{name:"right_click_at",description:"Right-click at the given normalized coordinate.",parameters:Mo},{name:"double_click_at",description:"Double-click at the given normalized coordinate.",parameters:Mo}];Ac="gemini-3-flash-preview"});function Po(e){return e!=null&&typeof e=="object"}function nt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Co(e){return typeof e=="string"?e:void 0}function $c(e){let t,i;return Array.isArray(e)?(t=nt(e[0]),i=nt(e[1])):Po(e)&&(t=nt(e.x),i=nt(e.y)),t===void 0||i===void 0?null:{x:t,y:i}}function Oo(e){if(!Po(e))return{};let t=Array.isArray(e.path)?e.path.map($c).filter(i=>i!==null):void 0;return{type:Co(e.type),x:nt(e.x),y:nt(e.y),button:Co(e.button),path:t}}var Bi=x(()=>{"use strict"});async function Mc(e,t){let i=Oo(t),n=null,a=null;switch(i.type){case"click":{if(i.x===void 0||i.y===void 0)break;let o=i.button==="right"?"right_click_by_coordinates":"click_by_coordinates",r=await Ee(e,i.x,i.y);n={action_name:o,kwargs:{relative_x:r.relative_x,relative_y:r.relative_y}},a=r.element;break}case"double_click":{if(i.x===void 0||i.y===void 0)break;let o=await Ee(e,i.x,i.y);n={action_name:"double_click_by_coordinates",kwargs:{relative_x:o.relative_x,relative_y:o.relative_y}},a=o.element;break}case"drag":{if(!i.path||i.path.length<2)break;let o=i.path[0],r=i.path[i.path.length-1],s=await Ee(e,o.x,o.y);n={action_name:"drag_drop",kwargs:{relative_x:s.relative_x,relative_y:s.relative_y,delta_x:r.x-o.x,delta_y:r.y-o.y}},a=s.element;break}}return{action_data:n,locatorInfo:await Fi(e,a)}}async function Do(e){let{statement:t,page:i,viewportWidth:n,viewportHeight:a,modelId:o}=e,r=o||Ic,s=await Tt(i,n,a),l=q(),c=l.env?.OPENAI_API_KEY;if(!c)return{status:"error",error:"OPENAI_API_KEY not found in SDK env config."};let d=l.env?.OPENAI_BASE_URL,u=new Lo.default({apiKey:c,...d&&{baseURL:d}}),p=u.responses.create.bind(u.responses);T.log(`Sending request to OpenAI CUA (model=${r})...`);let m=[{role:"user",content:[{type:"input_text",text:t},{type:"input_image",detail:"original",image_url:`data:image/png;base64,${s}`}]}];async function y(v,S){let E={model:r,tools:[Cc],input:v,temperature:.1};return S&&(E.previous_response_id=S),p(E)}let g=await y(m,void 0),w;for(let v=0;v<No;v++){T.log(`Received response from OpenAI CUA (turn ${v+1})`);let S=g.output.find(O=>O.type==="computer_call");if(!S)return{status:"error",reasoning:g.output_text||"Invalid action generation response",error:"No computer_call in OpenAI response"};let E=S.actions??[];if(E.length>1&&T.log(`[openai CUA] dropping ${E.length-1} batched action(s); only the first is executed`),w=E[0],!w)return{status:"error",error:"OpenAI CUA returned a computer_call with no actions"};if(w.type!=="screenshot")break;s=await Tt(i,n,a);let $=[{type:"computer_call_output",call_id:S.call_id,output:{type:"computer_screenshot",image_url:`data:image/png;base64,${s}`,detail:"original"}}];g=await y($,g.id)}if(!w)return{status:"error",error:"OpenAI CUA loop ended without an action"};if(w.type==="screenshot")return{status:"error",error:`OpenAI CUA kept requesting screenshots after ${No} turns`};T.log(`Generated action: ${JSON.stringify(w)}`);let{action_data:h,locatorInfo:b}=await Mc(i,w);return h?{status:"success",actionEntity:Hi(t,h,b),reasoning:"Action generated successfully using OpenAI computer use",goalAccomplished:!0}:{status:"error",error:`Failed to map OpenAI action: ${JSON.stringify(w)}`}}var Lo,Ic,Cc,No,Gi=x(()=>{"use strict";Bi();et();re();ae();Lo=te(require("openai"),1);Ic="gpt-5.4",Cc={type:"computer"},No=4});function Fo(){let e=q().env?.WEB_AGENT_LLM_TIMEOUT_MS;if(e===void 0||e==="")return Ro;let t=Number.parseInt(e,10);return!Number.isFinite(t)||t<0?Ro:t}function Ho(e,t){let i=[e,t].filter(n=>!!n);if(i.length!==0)return i.length===1?i[0]:AbortSignal.any(i)}function Pc(e){if(At.APICallError.isInstance(e))return e.statusCode;if(At.RetryError.isInstance(e)&&At.APICallError.isInstance(e.lastError))return e.lastError.statusCode}function sa(e){let t=Pc(e);return!(t===400||t===422)}async function at(e,t,i){if(e.length===0)throw new Error("runWithModelFallback: no models provided");let n;for(let a=0;a<e.length;a++){let o=e[a];try{return await t(o)}catch(r){if(n=r,a===e.length-1||Oc(r)||!sa(r))throw r;i?.(o,e[a+1],r)}}throw n}function Oc(e){return e?.name==="AI_NoObjectGeneratedError"}var At,Ro,Re=x(()=>{"use strict";ae();At=require("ai"),Ro=15e4});function Nc(e){if(!e)return!1;let t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}function Lc(){return Nc(q().env?.ANTHROPIC_MODELS_USE_VERTEXAI)}function Uo(e){let t=q();if(Lc()){let a=t.env?.GOOGLE_CLOUD_PROJECT,o=t.env?.GOOGLE_CLOUD_LOCATION;if(!a)throw new Error("GOOGLE_CLOUD_PROJECT is required when ANTHROPIC_MODELS_USE_VERTEXAI is enabled");if(!o)throw new Error("GOOGLE_CLOUD_LOCATION is required when ANTHROPIC_MODELS_USE_VERTEXAI is enabled");return f.debug(`Using Anthropic via Vertex AI provider: model=${e}, project=${a}, location=${o}`),(0,Wo.createVertexAnthropic)({project:a,location:o})(e)}let i=t.env?.ANTHROPIC_API_KEY;if(i)return f.debug(`Using Anthropic provider: model=${e}`),(0,la.createAnthropic)({apiKey:i})(e);let n=t.env?.SHIPLIGHT_API_TOKEN;if(n){let a=_o(n,t.env?.SHIPLIGHT_API_URL);return f.debug(`Using Shiplight LLM proxy (Anthropic): model=${e}, baseURL=${a}`),(0,la.createAnthropic)({apiKey:n,baseURL:a})(e)}throw new Error("ANTHROPIC_API_KEY not configured in SDK config")}function jo(e){return/^claude-(opus-4-[0-6]|sonnet-4-[0-6]|haiku-[34]|[23])/.test(e)}function ca(e){return{anthropic:{structuredOutputMode:"jsonTool"}}}var la,Wo,$t=x(()=>{"use strict";De();z();ae();la=require("@ai-sdk/anthropic"),Wo=require("@ai-sdk/google-vertex/anthropic")});function Bo(e){let t=q(),i=t.env?.OPENAI_API_KEY;if(i){let a=t.env?.OPENAI_BASE_URL;return f.debug(`Using OpenAI provider: model=${e}${a?`, baseURL=${a}`:""}`),(0,da.createOpenAI)({apiKey:i,baseURL:a})(e)}let n=t.env?.SHIPLIGHT_API_TOKEN;if(n){let a=vo(n,t.env?.SHIPLIGHT_API_URL);return f.debug(`Using Shiplight LLM proxy (OpenAI): model=${e}, baseURL=${a}`),(0,da.createOpenAI)({apiKey:n,baseURL:a})(e)}throw new Error("OPENAI_API_KEY not configured in SDK config")}function Go(e){return{}}var da,Mt=x(()=>{"use strict";De();z();ae();da=require("@ai-sdk/openai")});function ua(e){if(e.startsWith("claude-"))return"anthropic";if(e.startsWith("gemini-"))return"google";if(Dc.test(e))return"openai"}function It(e){let t=e.indexOf(":");if(t>0){let i=e.slice(0,t);if(Rc.has(i))return{provider:i,modelId:e.slice(t+1)}}return{provider:void 0,modelId:e}}function ye(e){let{provider:t,modelId:i}=It(e),n=t??ua(i);if(!n)throw new Error(`Cannot determine provider for model: ${e}. Use a known model prefix (claude-*, gemini-*, gpt-*) or specify a provider (e.g., "openai:${i}", "azure:${i}", "bedrock:${i}").`);if(!i)throw new Error(`Empty model ID in model string: "${e}". Specify a model after the provider prefix (e.g., "${n}:gpt-5.4-mini").`);let a=Ko[n];if(!a)throw new Error(`Provider "${n}" is not yet implemented. Supported providers: ${Object.keys(Ko).join(", ")}. See packages/sdk-core/src/agent/llm/DESIGN.md for the roadmap.`);return a(i)}function be(e,t){let{provider:i,modelId:n}=It(e),a=i??ua(n);return a==="anthropic"||a==="vertex"?ca(n):a==="openai"||a==="azure"?Go(n):a==="bedrock"?n.startsWith("anthropic.")?ca(n):{}:$o(t,n)}function Te(e,t){let i=t??0,{provider:n,modelId:a}=It(e),o=n??ua(a),r;if((o==="anthropic"||o==="vertex")&&a.startsWith("claude-"))r=a;else if(o==="bedrock"){let s=a.match(/^(?:[a-z]{2}\.)?anthropic\.(claude-.+)$/);s&&(r=s[1])}return r!==void 0?jo(r)?i:void 0:i}var Dc,Rc,Ko,xe=x(()=>{"use strict";$t();it();Mt();Dc=/^(gpt-|o\d|chatgpt-)/;Rc=new Set(["anthropic","google","openai","vertex","azure","bedrock"]);Ko={anthropic:Uo,google:Ao,openai:Bo}});function Hc(e){return e.startsWith("gemini-")?"google":"openai"}async function ot(e,t,i={}){let{page:n}=t,a=n.viewportSize();if(!a)return{status:"error",error:"Viewport size not available"};let{width:o,height:r}=a;T.log(`Viewport: ${o}x${r}`);let s=await Tt(n,o,r),l=t.agentServices.getComputerUseModel();if(!l)return{status:"error",error:"No computer use model configured"};let c=[l,...t.agentServices.getComputerUseFallbackModels().filter(d=>d!==l)];try{return await at(c,d=>{let{modelId:u}=It(d),p=Hc(u),m=Fc[p];return T.log(`Using CUA provider: ${p} (model: ${u})`),m({statement:e,page:n,screenshotB64:s,viewportWidth:o,viewportHeight:r,modelId:u})},(d,u)=>T.log(`CUA model ${d} unavailable; falling back to ${u}`))}catch(d){return T.error("CUA provider threw an error",d),{status:"error",error:d.message??"CUA provider failed"}}}var Fc,rt=x(()=>{"use strict";ji();Gi();et();Re();re();xe();Fc={google:Io,openai:Do}});function Ki(e){let t=(0,zo.zodToJsonSchema)(e,{$refStrategy:"none"});if(t.$schema&&delete t.$schema,t.type!=="object")throw new Error(`Schema must be a Zod object schema, got type: ${t.type}`);return Ct(t),t}function Ct(e){if(!(typeof e!="object"||e===null)){if(e.type==="object"&&(e.additionalProperties=!1,e.properties)){let t=Object.keys(e.properties);e.required=t;for(let i of Object.values(e.properties))Ct(i)}e.type==="array"&&e.items&&Ct(e.items);for(let t of["anyOf","oneOf","allOf"])Array.isArray(e[t])&&e[t].forEach(Ct);for(let[t,i]of Object.entries(e))typeof i=="object"&&i!==null&&!["properties","items","anyOf","oneOf","allOf"].includes(t)&&Ct(i)}}var zo,Pt=x(()=>{"use strict";zo=require("zod-to-json-schema")});var ha,zi=x(()=>{"use strict";Pt();ha=class{constructor(e){this.registry=e}getToolDefinitions(){return this.registry.getTools().filter(e=>e.availability.openai).map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:Ki(e.schema),strict:!0}}))}getToolDefinitionsFiltered(e){let t=new Set(e);return this.registry.getTools().filter(i=>t.has(i.name)&&i.availability.openai).map(i=>({type:"function",function:{name:i.name,description:i.description,parameters:Ki(i.schema),strict:!0}}))}toJSON(){return this.getToolDefinitions()}getToolDefinition(e){let t=this.registry.get(e);if(t)return{type:"function",function:{name:t.name,description:t.description,parameters:Ki(t.schema),strict:!0}}}getToolCount(){return this.registry.size()}getToolNames(){return this.registry.getToolNames()}}});function Wc(e,t){let i=new Map;for(let l of t)l.hash&&l.url?i.set(l.hash,l.url):l.uuid&&l.url&&i.set(l.uuid,l.url);let n=/!\[([^\]]*)\]\(image:([a-f0-9]{64}|[a-zA-Z0-9\-]+)\)/g,a=[],o=0,r;for(;(r=n.exec(e))!==null;){let l=e.slice(o,r.index);l&&a.push({type:"text",text:l});let c=r[2];i.has(c)?a.push({type:"image",image:new URL(i.get(c))}):a.push({type:"text",text:r[0]}),o=r.index+r[0].length}let s=e.slice(o);return s&&a.push({type:"text",text:s}),a.length===0&&a.push({type:"text",text:e}),a}function Uc(e){let t=[];for(let i of e){let n=i.content||"",a=i.images||[],o=Wc(n,a);t.length>0&&o.length>0&&t.push({type:"text",text:`
|
|
14
|
+
${e}`)}error(e,t){this.log(`ERROR: ${e}`),t&&(this.log(`Error details: ${t.message}`),t.stack&&this.log(`Stack: ${t.stack}`))}isEnabled(){return!!q().agentLogPath}},T=new mc});var ea,pc,gc,fc,bo,Di,Qn,xo,ta,Se=x(()=>{"use strict";ea=Object.defineProperty,pc=Object.getOwnPropertyDescriptor,gc=Object.getOwnPropertyNames,fc=Object.prototype.hasOwnProperty,bo=(e,t)=>()=>(e&&(t=e(e=0)),t),Di=(e,t)=>{for(var i in t)ea(e,i,{get:t[i],enumerable:!0})},Qn=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of gc(t))!fc.call(e,a)&&a!==i&&ea(e,a,{get:()=>t[a],enumerable:!(n=pc(t,a))||n.enumerable});return e},xo=(e,t,i)=>(Qn(e,t,"default"),i&&Qn(i,t,"default")),ta=e=>Qn(ea({},"__esModule",{value:!0}),e)});function R(e,t){return t??e?.getActionSettings()?.action_timeout_ms??na}function wc(e){return e.replace(/\r\n/g," ").replace(/\n/g," ").replace(/\r/g," ").trim()}function F(e,t){let i=Le(t);return i?new Function("page",`return ${i}`)(e):null}async function ia(e,t=[]){let i=e;for(let n of t){let a=await i.locator(n).elementHandle();if(!a)return null;let o=await a.contentFrame();if(await a.dispose(),!o)return null;i=o}return i}function yc(e){let t={action_data:e.action_data};return e.locator&&(t.locator=e.locator),e.xpath&&(t.xpath=e.xpath),e.frame_path&&(t.frame_path=e.frame_path),t}function bc(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function xc(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 Le(e){let t=bc(e),i=e.locator;if(typeof i=="string"&&i.trim())return i=i.trim(),i.endsWith("first()")?`${t}.${i}`:`${t}.${i}.first()`;let n=xc(e);if(n){let a=JSON.stringify(n);return`${t}.locator(${a}).first()`}return null}var Ri,Et,na,fe,C,K=x(()=>{"use strict";Se();Ri={};Di(Ri,{ACTION_TIMEOUT:()=>na,GOTO_TIMEOUT:()=>fe,LOCATOR_TIMEOUT:()=>Et,getActionTimeoutMs:()=>R,getFrameContext:()=>ia,getLocator:()=>F,getMinimalActionEntity:()=>yc,getPageLocatorExpression:()=>Le,sanitizeForComment:()=>wc});C=bo(()=>{Et=5e3,na=1e4,fe=2e4})});async function aa(e,t,i=[],n=[]){try{let a=await ia(e,i);if(!a)return f.warn(`Could not find frame context for xpath: ${t}`),null;let o=null;if(n.length>0){let s=n[0];if(!s)return f.warn(`Missing shadow host xpath for element: ${t}`),null;let l=a.locator(`xpath=${vo(s)}`),c=vc(t);if(o=await(c?l.locator(`css=${c}`):l.locator(`xpath=${vo(t)}`)).elementHandle({timeout:Et}),!o)return f.warn(`Could not find shadow DOM element with xpath: ${t}`),null}else if(o=await a.locator(`xpath=${t}`).elementHandle({timeout:Et}),!o)return f.warn(`Could not find element with xpath: ${t}`),null;let r=await a.evaluate(s=>typeof playwright<"u"&&playwright.generateLocator?playwright.generateLocator(s):null,o);return await o.dispose(),r?(f.debug(`Generated locator for ${t}: ${r}`),r):(f.debug("playwright.generateLocator is not available (PWDEBUG=console not set), using xpath fallback"),null)}catch(a){return f.error(`Error in pickBestLocator: ${a}`),null}}async function oa(e,t){try{let i=await(await t.ownerFrame()??e).evaluate(n=>typeof playwright<"u"&&playwright.generateLocator?playwright.generateLocator(n):null,t);return await t.dispose(),i?(f.debug(`Generated locator: ${i}`),i):(f.debug("playwright.generateLocator is not available (PWDEBUG=console not set), using xpath fallback"),null)}catch(i){return f.error(`Error in pickBestLocator: ${i}`),null}}function vo(e){let t=e.trim();return t.startsWith("/")||t.startsWith("(")||t.startsWith(".")?t:`//${t}`}function vc(e){let t=e.trim().replace(/^\/+/,"");if(!t)return null;let i=t.split("/").filter(Boolean),n=[];for(let a of i){let o=a.match(/^([a-zA-Z][\w-]*)(?:\[(\d+)\])?$/);if(!o)return null;let r=o[1].toLowerCase(),s=o[2]?`:nth-of-type(${o[2]})`:"";n.push(`${r}${s}`)}return n.join(" > ")}var Ue=x(()=>{"use strict";G();K();C()});async function Tt(e,t,i){await e.evaluate(()=>{document.getElementById("playwright-highlight-container")?.remove(),window._highlightCleanupFunctions&&(window._highlightCleanupFunctions.forEach(l=>l()),window._highlightCleanupFunctions=[])});let n=await e.screenshot({type:"png",fullPage:!1}),{default:a}=await import("sharp"),o=a(n),{width:r=0,height:s=0}=await o.metadata();return T.log(`Screenshot actual: ${r}x${s}, viewport: ${t}x${i}`),(r!==t||s!==i?await o.resize(t,i).png().toBuffer():n).toString("base64")}async function Ee(e,t,i){let n=await e.evaluateHandle(r=>document.elementFromPoint(r.x,r.y),{x:t,y:i}),a=n.asElement();if(!a)throw await n.dispose(),new Error(`No element found at (${t}, ${i})`);let o=await a.boundingBox();if(!o)throw await n.dispose(),new Error(`Element at (${t}, ${i}) has no bounding box`);return{relative_x:t-(o.x+o.width/2),relative_y:i-(o.y+o.height/2),element:a}}async function Fi(e,t){if(!t)return{xpath:void 0,locator:void 0,frame_path:[]};let i=await t.evaluate(a=>{let o=[],r=a;for(;r&&r.nodeType===Node.ELEMENT_NODE;){let s=1,l=r.previousElementSibling;for(;l;)l.tagName===r.tagName&&s++,l=l.previousElementSibling;o.unshift(`${r.tagName.toLowerCase()}[${s}]`),r=r.parentElement}return o.length?`/${o.join("/")}`:null}).catch(()=>null),n=await oa(e,t);return{xpath:i??void 0,locator:n??void 0,frame_path:[]}}function Hi(e,t,i){return{action_description:e,action_data:t,locator:i.locator??void 0,xpath:i.xpath??void 0,frame_path:i.frame_path}}var et=x(()=>{"use strict";re();Ue()});function Ec(e){return e.startsWith(_c)}function Be(e,t){let i=t?.trim();return i?Tc(i):Ec(e)?kc:Sc}function Tc(e){return e.endsWith("/")?e.slice(0,-1):e}var _c,kc,Sc,tt=x(()=>{"use strict";_c="shp_",kc="https://nova-api.shiplight.ai",Sc="https://api.shiplight.ai"});function _o(e,t){return`${Be(e,t)}/llm/v1`}function ko(e,t){return`${Be(e,t)}/llm/v1`}function So(e,t){return`${Be(e,t)}/llm/v1beta`}function Eo(e,t){return`${Be(e,t)}/llm`}var De=x(()=>{"use strict";tt()});function Wi(){let e=(q().env||{}).GOOGLE_GENAI_USE_VERTEXAI;return e==="True"||e==="true"}function $o(e){let t=q().env||{};if(Wi()){let a=t.GOOGLE_CLOUD_PROJECT;if(!a)throw new Error("GOOGLE_CLOUD_PROJECT is required when using Vertex AI");let o=e.startsWith("gemini-3")?"global":t.GOOGLE_CLOUD_LOCATION;if(!o)throw new Error("GOOGLE_CLOUD_LOCATION is required when using Vertex AI");return f.debug(`Using Vertex AI provider: model=${e}, location=${o}`),(0,Ao.createVertex)({project:a,location:o})(e)}let i=t.GOOGLE_API_KEY;if(i)return f.debug(`Using Google AI provider (API key): model=${e}`),(0,ra.createGoogleGenerativeAI)({apiKey:i})(e);let n=t.SHIPLIGHT_API_TOKEN;if(n){let a=So(n,t.SHIPLIGHT_API_URL);return f.debug(`Using Shiplight LLM proxy (Google): model=${e}, baseURL=${a}`),(0,ra.createGoogleGenerativeAI)({apiKey:n,baseURL:a})(e)}throw new Error("Google API key is missing. Set GOOGLE_API_KEY in SDK config or environment.")}function Mo(e,t){let i={thinkingConfig:{thinkingBudget:512,includeThoughts:!0}},n={thinkingConfig:{thinkingLevel:"minimal",includeThoughts:!0},mediaResolution:To.MEDIA_RESOLUTION_HIGH},a;switch(t){case"gemini-3-flash-preview":a={...n};break;default:a={...i},e===1&&(a.mediaResolution=To.MEDIA_RESOLUTION_HIGH)}return Wi()?{vertex:a}:{google:a}}var ra,Ao,To,it=x(()=>{"use strict";De();G();ae();ra=require("@ai-sdk/google"),Ao=require("@ai-sdk/google-vertex"),To={MEDIA_RESOLUTION_HIGH:"MEDIA_RESOLUTION_HIGH",MEDIA_RESOLUTION_MEDIUM:"MEDIA_RESOLUTION_MEDIUM",MEDIA_RESOLUTION_LOW:"MEDIA_RESOLUTION_LOW"}});function we(e,t){return Math.round(e/1e3*t)}async function $c(e,t,i,n,a){let o=null,r=null;try{switch(t){case"click_at":{let s=we(i.x,n),l=we(i.y,a),c=await Ee(e,s,l);o={action_name:"click_by_coordinates",kwargs:{relative_x:c.relative_x,relative_y:c.relative_y}},r=c.element;break}case"right_click_at":{let s=we(i.x,n),l=we(i.y,a),c=await Ee(e,s,l);o={action_name:"right_click_by_coordinates",kwargs:{relative_x:c.relative_x,relative_y:c.relative_y}},r=c.element;break}case"double_click_at":{let s=we(i.x,n),l=we(i.y,a),c=await Ee(e,s,l);o={action_name:"double_click_by_coordinates",kwargs:{relative_x:c.relative_x,relative_y:c.relative_y}},r=c.element;break}case"drag_and_drop":{let s=we(i.x,n),l=we(i.y,a),c=we(i.destination_x,n),d=we(i.destination_y,a),u=await Ee(e,s,l);o={action_name:"drag_drop",kwargs:{relative_x:u.relative_x,relative_y:u.relative_y,delta_x:c-s,delta_y:d-l}},r=u.element;break}default:T.log(`Unsupported Gemini function: ${t}`)}}catch(s){T.error(`Error mapping Gemini action "${t}"`,s)}return{action_data:o,locatorInfo:await Fi(e,r)}}async function Co(e){let{statement:t,page:i,screenshotB64:n,viewportWidth:a,viewportHeight:o,modelId:r}=e,s=r||Mc,l=q(),c;if(Wi()){let b=l.env?.GOOGLE_CLOUD_PROJECT;if(!b)return{status:"error",error:"GOOGLE_CLOUD_PROJECT is required when using Vertex AI."};let v=l.env?.GOOGLE_CLOUD_LOCATION??"global";c={vertexai:!0,project:b,location:v}}else{let b=l.env?.GOOGLE_API_KEY;if(b)f.debug(`Using Google AI provider (API key): model=${s}`),c={apiKey:b};else{let v=l.env?.SHIPLIGHT_API_TOKEN;if(v){let S=Eo(v,l.env?.SHIPLIGHT_API_URL);f.debug(`Using Shiplight LLM proxy (Google CUA): model=${s}, baseUrl=${S}`),c={apiKey:v,httpOptions:{baseUrl:S}}}else return{status:"error",error:"Google API key is missing. Set GOOGLE_API_KEY in SDK config or environment."}}}let d=new ji.GoogleGenAI(c);T.log(`Sending request to Gemini CUA (model=${s})...`);let u=await d.models.generateContent({model:s,contents:[{role:"user",parts:[{text:`Execute this action: ${t}`},{inlineData:{mimeType:"image/png",data:n}}]}],config:{tools:[{computerUse:{environment:ji.Environment.ENVIRONMENT_BROWSER,excludedPredefinedFunctions:["search","type_text_at","scroll_document","navigate","go_back","go_forward","key_combination","hover_at","scroll_at"]}},{functionDeclarations:Ac}],temperature:.1}});T.log("Received response from Gemini CUA");let m=u.candidates?.[0];if(!m)return{status:"error",error:"No candidates in Gemini response"};let p=m.content?.parts?.find(b=>b.functionCall);if(!p)return{status:"error",reasoning:m.content?.parts?.filter(b=>b.text).map(b=>b.text).join(" ")||"No action generated",error:"No function call in Gemini response"};let{name:w,args:g}=p.functionCall;T.log(`Generated function call: ${w} with args ${JSON.stringify(g)}`),f.debug(`Generated function call: ${w} with args ${JSON.stringify(g)}`);let{action_data:y,locatorInfo:h}=await $c(i,w,g,a,o);return y?{status:"success",actionEntity:Hi(t,y,h),reasoning:"Action generated successfully using Gemini computer use",goalAccomplished:!0}:{status:"error",error:`Unsupported or invalid Gemini action: ${w}`}}var ji,Io,Ac,Mc,Ui=x(()=>{"use strict";et();re();it();De();G();ae();ji=require("@google/genai");Io={type:"object",properties:{x:{type:"integer",description:"X coordinate in the 0-1000 normalized space."},y:{type:"integer",description:"Y coordinate in the 0-1000 normalized space."}},required:["x","y"]},Ac=[{name:"right_click_at",description:"Right-click at the given normalized coordinate.",parameters:Io},{name:"double_click_at",description:"Double-click at the given normalized coordinate.",parameters:Io}];Mc="gemini-3-flash-preview"});function No(e){return e!=null&&typeof e=="object"}function nt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Po(e){return typeof e=="string"?e:void 0}function Ic(e){let t,i;return Array.isArray(e)?(t=nt(e[0]),i=nt(e[1])):No(e)&&(t=nt(e.x),i=nt(e.y)),t===void 0||i===void 0?null:{x:t,y:i}}function Oo(e){if(!No(e))return{};let t=Array.isArray(e.path)?e.path.map(Ic).filter(i=>i!==null):void 0;return{type:Po(e.type),x:nt(e.x),y:nt(e.y),button:Po(e.button),path:t}}var Bi=x(()=>{"use strict"});async function Cc(e,t){let i=Oo(t),n=null,a=null;switch(i.type){case"click":{if(i.x===void 0||i.y===void 0)break;let o=i.button==="right"?"right_click_by_coordinates":"click_by_coordinates",r=await Ee(e,i.x,i.y);n={action_name:o,kwargs:{relative_x:r.relative_x,relative_y:r.relative_y}},a=r.element;break}case"double_click":{if(i.x===void 0||i.y===void 0)break;let o=await Ee(e,i.x,i.y);n={action_name:"double_click_by_coordinates",kwargs:{relative_x:o.relative_x,relative_y:o.relative_y}},a=o.element;break}case"drag":{if(!i.path||i.path.length<2)break;let o=i.path[0],r=i.path[i.path.length-1],s=await Ee(e,o.x,o.y);n={action_name:"drag_drop",kwargs:{relative_x:s.relative_x,relative_y:s.relative_y,delta_x:r.x-o.x,delta_y:r.y-o.y}},a=s.element;break}}return{action_data:n,locatorInfo:await Fi(e,a)}}async function Ro(e){let{statement:t,page:i,viewportWidth:n,viewportHeight:a,modelId:o}=e,r=o||Pc,s=await Tt(i,n,a),l=q(),c=l.env?.OPENAI_API_KEY;if(!c)return{status:"error",error:"OPENAI_API_KEY not found in SDK env config."};let d=l.env?.OPENAI_BASE_URL,u=new Do.default({apiKey:c,...d&&{baseURL:d}}),m=u.responses.create.bind(u.responses);T.log(`Sending request to OpenAI CUA (model=${r})...`);let p=[{role:"user",content:[{type:"input_text",text:t},{type:"input_image",detail:"original",image_url:`data:image/png;base64,${s}`}]}];async function w(v,S){let E={model:r,tools:[Nc],input:v,temperature:.1};return S&&(E.previous_response_id=S),m(E)}let g=await w(p,void 0),y;for(let v=0;v<Lo;v++){T.log(`Received response from OpenAI CUA (turn ${v+1})`);let S=g.output.find(N=>N.type==="computer_call");if(!S)return{status:"error",reasoning:g.output_text||"Invalid action generation response",error:"No computer_call in OpenAI response"};let E=S.actions??[];if(E.length>1&&T.log(`[openai CUA] dropping ${E.length-1} batched action(s); only the first is executed`),y=E[0],!y)return{status:"error",error:"OpenAI CUA returned a computer_call with no actions"};if(y.type!=="screenshot")break;s=await Tt(i,n,a);let $=[{type:"computer_call_output",call_id:S.call_id,output:{type:"computer_screenshot",image_url:`data:image/png;base64,${s}`,detail:"original"}}];g=await w($,g.id)}if(!y)return{status:"error",error:"OpenAI CUA loop ended without an action"};if(y.type==="screenshot")return{status:"error",error:`OpenAI CUA kept requesting screenshots after ${Lo} turns`};T.log(`Generated action: ${JSON.stringify(y)}`);let{action_data:h,locatorInfo:b}=await Cc(i,y);return h?{status:"success",actionEntity:Hi(t,h,b),reasoning:"Action generated successfully using OpenAI computer use",goalAccomplished:!0}:{status:"error",error:`Failed to map OpenAI action: ${JSON.stringify(y)}`}}var Do,Pc,Nc,Lo,Gi=x(()=>{"use strict";Bi();et();re();ae();Do=te(require("openai"),1);Pc="gpt-5.4",Nc={type:"computer"},Lo=4});function Ho(){let e=q().env?.WEB_AGENT_LLM_TIMEOUT_MS;if(e===void 0||e==="")return Fo;let t=Number.parseInt(e,10);return!Number.isFinite(t)||t<0?Fo:t}function Wo(e,t){let i=[e,t].filter(n=>!!n);if(i.length!==0)return i.length===1?i[0]:AbortSignal.any(i)}function Oc(e){if(At.APICallError.isInstance(e))return e.statusCode;if(At.RetryError.isInstance(e)&&At.APICallError.isInstance(e.lastError))return e.lastError.statusCode}function sa(e){let t=Oc(e);return!(t===400||t===422)}async function at(e,t,i){if(e.length===0)throw new Error("runWithModelFallback: no models provided");let n;for(let a=0;a<e.length;a++){let o=e[a];try{return await t(o)}catch(r){if(n=r,a===e.length-1||Lc(r)||!sa(r))throw r;i?.(o,e[a+1],r)}}throw n}function Lc(e){return e?.name==="AI_NoObjectGeneratedError"}var At,Fo,Re=x(()=>{"use strict";ae();At=require("ai"),Fo=15e4});function Dc(e){if(!e)return!1;let t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}function Rc(){return Dc(q().env?.ANTHROPIC_MODELS_USE_VERTEXAI)}function Uo(e){let t=q();if(Rc()){let a=t.env?.GOOGLE_CLOUD_PROJECT,o=t.env?.GOOGLE_CLOUD_LOCATION;if(!a)throw new Error("GOOGLE_CLOUD_PROJECT is required when ANTHROPIC_MODELS_USE_VERTEXAI is enabled");if(!o)throw new Error("GOOGLE_CLOUD_LOCATION is required when ANTHROPIC_MODELS_USE_VERTEXAI is enabled");return f.debug(`Using Anthropic via Vertex AI provider: model=${e}, project=${a}, location=${o}`),(0,jo.createVertexAnthropic)({project:a,location:o})(e)}let i=t.env?.ANTHROPIC_API_KEY;if(i)return f.debug(`Using Anthropic provider: model=${e}`),(0,la.createAnthropic)({apiKey:i})(e);let n=t.env?.SHIPLIGHT_API_TOKEN;if(n){let a=ko(n,t.env?.SHIPLIGHT_API_URL);return f.debug(`Using Shiplight LLM proxy (Anthropic): model=${e}, baseURL=${a}`),(0,la.createAnthropic)({apiKey:n,baseURL:a})(e)}throw new Error("ANTHROPIC_API_KEY not configured in SDK config")}function Bo(e){return/^claude-(opus-4-[0-6]|sonnet-4-[0-6]|haiku-[34]|[23])/.test(e)}function ca(e){return{anthropic:{structuredOutputMode:"jsonTool"}}}var la,jo,$t=x(()=>{"use strict";De();G();ae();la=require("@ai-sdk/anthropic"),jo=require("@ai-sdk/google-vertex/anthropic")});function Go(e){let t=q(),i=t.env?.OPENAI_API_KEY;if(i){let a=t.env?.OPENAI_BASE_URL;return f.debug(`Using OpenAI provider: model=${e}${a?`, baseURL=${a}`:""}`),(0,da.createOpenAI)({apiKey:i,baseURL:a})(e)}let n=t.env?.SHIPLIGHT_API_TOKEN;if(n){let a=_o(n,t.env?.SHIPLIGHT_API_URL);return f.debug(`Using Shiplight LLM proxy (OpenAI): model=${e}, baseURL=${a}`),(0,da.createOpenAI)({apiKey:n,baseURL:a})(e)}throw new Error("OPENAI_API_KEY not configured in SDK config")}function Ko(e){return{}}var da,Mt=x(()=>{"use strict";De();G();ae();da=require("@ai-sdk/openai")});function ua(e){if(e.startsWith("claude-"))return"anthropic";if(e.startsWith("gemini-"))return"google";if(Fc.test(e))return"openai"}function It(e){let t=e.indexOf(":");if(t>0){let i=e.slice(0,t);if(Hc.has(i))return{provider:i,modelId:e.slice(t+1)}}return{provider:void 0,modelId:e}}function ye(e){let{provider:t,modelId:i}=It(e),n=t??ua(i);if(!n)throw new Error(`Cannot determine provider for model: ${e}. Use a known model prefix (claude-*, gemini-*, gpt-*) or specify a provider (e.g., "openai:${i}", "azure:${i}", "bedrock:${i}").`);if(!i)throw new Error(`Empty model ID in model string: "${e}". Specify a model after the provider prefix (e.g., "${n}:gpt-5.4-mini").`);let a=zo[n];if(!a)throw new Error(`Provider "${n}" is not yet implemented. Supported providers: ${Object.keys(zo).join(", ")}. See packages/sdk-core/src/agent/llm/DESIGN.md for the roadmap.`);return a(i)}function be(e,t){let{provider:i,modelId:n}=It(e),a=i??ua(n);return a==="anthropic"||a==="vertex"?ca(n):a==="openai"||a==="azure"?Ko(n):a==="bedrock"?n.startsWith("anthropic.")?ca(n):{}:Mo(t,n)}function Te(e,t){let i=t??0,{provider:n,modelId:a}=It(e),o=n??ua(a),r;if((o==="anthropic"||o==="vertex")&&a.startsWith("claude-"))r=a;else if(o==="bedrock"){let s=a.match(/^(?:[a-z]{2}\.)?anthropic\.(claude-.+)$/);s&&(r=s[1])}return r!==void 0?Bo(r)?i:void 0:i}var Fc,Hc,zo,xe=x(()=>{"use strict";$t();it();Mt();Fc=/^(gpt-|o\d|chatgpt-)/;Hc=new Set(["anthropic","google","openai","vertex","azure","bedrock"]);zo={anthropic:Uo,google:$o,openai:Go}});function jc(e){return e.startsWith("gemini-")?"google":"openai"}async function ot(e,t,i={}){let{page:n}=t,a=n.viewportSize();if(!a)return{status:"error",error:"Viewport size not available"};let{width:o,height:r}=a;T.log(`Viewport: ${o}x${r}`);let s=await Tt(n,o,r),l=t.agentServices.getComputerUseModel();if(!l)return{status:"error",error:"No computer use model configured"};let c=[l,...t.agentServices.getComputerUseFallbackModels().filter(d=>d!==l)];try{return await at(c,d=>{let{modelId:u}=It(d),m=jc(u),p=Wc[m];return T.log(`Using CUA provider: ${m} (model: ${u})`),p({statement:e,page:n,screenshotB64:s,viewportWidth:o,viewportHeight:r,modelId:u})},(d,u)=>T.log(`CUA model ${d} unavailable; falling back to ${u}`))}catch(d){return T.error("CUA provider threw an error",d),{status:"error",error:d.message??"CUA provider failed"}}}var Wc,rt=x(()=>{"use strict";Ui();Gi();et();Re();re();xe();Wc={google:Co,openai:Ro}});function Ki(e){let t=(0,Vo.zodToJsonSchema)(e,{$refStrategy:"none"});if(t.$schema&&delete t.$schema,t.type!=="object")throw new Error(`Schema must be a Zod object schema, got type: ${t.type}`);return Ct(t),t}function Ct(e){if(!(typeof e!="object"||e===null)){if(e.type==="object"&&(e.additionalProperties=!1,e.properties)){let t=Object.keys(e.properties);e.required=t;for(let i of Object.values(e.properties))Ct(i)}e.type==="array"&&e.items&&Ct(e.items);for(let t of["anyOf","oneOf","allOf"])Array.isArray(e[t])&&e[t].forEach(Ct);for(let[t,i]of Object.entries(e))typeof i=="object"&&i!==null&&!["properties","items","anyOf","oneOf","allOf"].includes(t)&&Ct(i)}}var Vo,Pt=x(()=>{"use strict";Vo=require("zod-to-json-schema")});var ha,zi=x(()=>{"use strict";Pt();ha=class{constructor(e){this.registry=e}getToolDefinitions(){return this.registry.getTools().filter(e=>e.availability.openai).map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:Ki(e.schema),strict:!0}}))}getToolDefinitionsFiltered(e){let t=new Set(e);return this.registry.getTools().filter(i=>t.has(i.name)&&i.availability.openai).map(i=>({type:"function",function:{name:i.name,description:i.description,parameters:Ki(i.schema),strict:!0}}))}toJSON(){return this.getToolDefinitions()}getToolDefinition(e){let t=this.registry.get(e);if(t)return{type:"function",function:{name:t.name,description:t.description,parameters:Ki(t.schema),strict:!0}}}getToolCount(){return this.registry.size()}getToolNames(){return this.registry.getToolNames()}}});function Uc(e,t){let i=new Map;for(let l of t)l.hash&&l.url?i.set(l.hash,l.url):l.uuid&&l.url&&i.set(l.uuid,l.url);let n=/!\[([^\]]*)\]\(image:([a-f0-9]{64}|[a-zA-Z0-9\-]+)\)/g,a=[],o=0,r;for(;(r=n.exec(e))!==null;){let l=e.slice(o,r.index);l&&a.push({type:"text",text:l});let c=r[2];i.has(c)?a.push({type:"image",image:new URL(i.get(c))}):a.push({type:"text",text:r[0]}),o=r.index+r[0].length}let s=e.slice(o);return s&&a.push({type:"text",text:s}),a.length===0&&a.push({type:"text",text:e}),a}function Bc(e){let t=[];for(let i of e){let n=i.content||"",a=i.images||[],o=Uc(n,a);t.length>0&&o.length>0&&t.push({type:"text",text:`
|
|
15
15
|
|
|
16
|
-
`}),t.push(...o)}return t}function Vi(e,t=
|
|
16
|
+
`}),t.push(...o)}return t}function Vi(e,t=Xo){if(t){let i=Bc(e);if(i.length===0)return[];let n={type:"text",text:`
|
|
17
17
|
|
|
18
18
|
<retrieved_knowledge>
|
|
19
19
|
|
|
@@ -33,7 +33,7 @@ Below are expert curated knowledge that are retrieved from the knowledge base; A
|
|
|
33
33
|
|
|
34
34
|
</retrieved_knowledge>
|
|
35
35
|
|
|
36
|
-
`}]:[]}}function
|
|
36
|
+
`}]:[]}}function Jo(e,t=Xo){if(!t)return 0;let i=0;for(let n of e)n.images&&(i+=n.images.length);return i}var Xo,Nt=x(()=>{"use strict";Xo=!1});function Gc(){let e=new Date,t=new Intl.DateTimeFormat("en-US",{timeZone:"America/Los_Angeles",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZoneName:"short"}).formatToParts(e),i=t.find(d=>d.type==="year").value,n=t.find(d=>d.type==="month").value,a=t.find(d=>d.type==="day").value,o=t.find(d=>d.type==="hour").value,r=t.find(d=>d.type==="minute").value,s=t.find(d=>d.type==="second").value,l=t.find(d=>d.type==="timeZoneName").value,c=String(e.getMilliseconds()).padStart(3,"0");return`${i}-${n}-${a} ${o}:${r}:${s}.${c} ${l}`}function Yo(e){return`# Your Role
|
|
37
37
|
You are part of a end-to-end testing system that is designed to automate the testing of a website. Given an instruction in natural language, your job is to translate it into an action in the predefined actions. The instruction might not match any action in the predefined actions or might require to interact with an element that is not on the page. It's your job to detect these cases and return an empty action.
|
|
38
38
|
|
|
39
39
|
# Rules
|
|
@@ -93,11 +93,11 @@ Example of empty action when the target element is not on the page, or the instr
|
|
|
93
93
|
"action": {}, // empty action object to indicate the instruction cannot be completed
|
|
94
94
|
"completes_instruction": false
|
|
95
95
|
}
|
|
96
|
-
`}function
|
|
96
|
+
`}function Kc(e){if(!e||e.length===0)return"";let t="";return e.forEach(([i,n],a)=>{t+=`(${a+1}) Description: ${i}
|
|
97
97
|
Feedback: ${n}
|
|
98
98
|
`}),`## Additional context
|
|
99
99
|
You just executed following steps in order:
|
|
100
|
-
${t}`}function
|
|
100
|
+
${t}`}function qo(e,t,i,n,a,o,r=!1,s=Gc(),l=!1,c){let d=[],u=`
|
|
101
101
|
# Instruction
|
|
102
102
|
"${t}"
|
|
103
103
|
|
|
@@ -117,12 +117,12 @@ ${e.tabsText}
|
|
|
117
117
|
|
|
118
118
|
## Interactive elements from current page:
|
|
119
119
|
${e.elementsText}
|
|
120
|
-
`;if(d.push({type:"text",text:u}),r&&e.slicedScreenshotsBase64)for(let
|
|
120
|
+
`;if(d.push({type:"text",text:u}),r&&e.slicedScreenshotsBase64)for(let p of e.slicedScreenshotsBase64)d.push({type:"text",text:"The following images provided are sliced screenshots of the current webpage, with interactive elements highlighted. The element index label locate at the top right corner of the bounding box."}),d.push({type:"image",image:p});else o&&(d.push({type:"text",text:"The following image provided is a screenshot of the current webpage, with interactive elements highlighted. The element index label locate at the top right corner of the bounding box."}),d.push({type:"image",image:o}));if(a&&a.length>0){let p=Vi(a,l);d.push(...p)}let m="";if(m+=`
|
|
121
121
|
Current local time is ${s}.
|
|
122
|
-
`,i&&Object.keys(i).length>0){let
|
|
122
|
+
`,i&&Object.keys(i).length>0){let p=[];for(let w of Object.keys(i))if(c?.has(w))p.push(` - ${w}: [SENSITIVE - value hidden]`);else{let g=i[w],y=typeof g=="string"?g:JSON.stringify(g);p.push(` - ${w}: "${y}"`)}m+=`
|
|
123
123
|
## Available Data Placeholders
|
|
124
124
|
The following placeholders are available for use in your actions:
|
|
125
|
-
${
|
|
125
|
+
${p.join(`
|
|
126
126
|
`)}
|
|
127
127
|
|
|
128
128
|
To use them, write Jinja-like template syntax: {{ placeholder_name }}
|
|
@@ -130,32 +130,32 @@ To use them, write Jinja-like template syntax: {{ placeholder_name }}
|
|
|
130
130
|
- Do NOT use the actual value directly
|
|
131
131
|
- The values shown are for context only to help you understand what data is available
|
|
132
132
|
- In action descriptions, describe what the placeholder represents in natural language (e.g., "Type the first user name" instead of "Type {{ firstUserName }}")
|
|
133
|
-
`}if(n&&n.length>0){let
|
|
134
|
-
`+
|
|
133
|
+
`}if(n&&n.length>0){let p=Kc(n);m+=`
|
|
134
|
+
`+p}return m+=`
|
|
135
135
|
Based on the above information, please determine the right action to accomplish the task.
|
|
136
|
-
`,d.push({type:"text",text:
|
|
136
|
+
`,d.push({type:"text",text:m}),d}var Xi=x(()=>{"use strict";Nt()});async function zc(e){let t=e.context().pages(),i=null,n=[];for(let o=0;o<t.length;o++){let r=t[o];r===e&&(i=o);let s="(title unavailable)";try{s=await Promise.race([r.title(),new Promise((c,d)=>setTimeout(()=>d(new Error("timeout")),1e3))])}catch{}let l=`Tab ${o}: ${r.url()}`;s&&(l+=` - ${s.slice(0,50)}`),n.push(l)}let a=n.length>0?n.join(`
|
|
137
137
|
`):"";return{currentTabText:i!==null?`Current tab: ${i}
|
|
138
|
-
`:"",tabsText:a}}async function
|
|
138
|
+
`:"",tabsText:a}}async function Vc(e,t){let{currentTabText:i,tabsText:n}=await zc(e);return{elementsText:t,currentUrl:e.url(),currentTitle:await e.title(),currentTabText:i,tabsText:n}}async function Ji(e,t){let{page:i,domService:n,agentServices:a}=e,o=typeof t=="boolean"?{useCleanScreenshot:t}:t||{},r=a.getInteractiveClassNames(),s=a.getIframeFallbackDomains(),{domState:l,screenshotBase64:c,slicedScreenshotsBase64:d}=await n.getClickableElementsWithScreenshot(i,{interactiveClassNames:r,playwrightFrameFallbackDomains:s,useCleanScreenshot:o.useCleanScreenshot,useSlicedScreenshots:o.useSlicedScreenshots,resizeSlicedScreenshots:o.resizeSlicedScreenshots,useAccessibilityTree:o.useAccessibilityTree,actionIntent:o.actionIntent}),u=l.elementTree.clickableElementsToString(),m=await Vc(i,u);return d&&(m.slicedScreenshotsBase64=d),{domTree:u,screenshotBase64:c,slicedScreenshotsBase64:d,domState:l,pageContext:m}}var Ot=x(()=>{"use strict"});var ue,ma,X,Ae=x(()=>{"use strict";ue=require("zod"),ma=class{constructor(){this.tools=new Map}register(e){if(this.tools.has(e.name))throw new Error(`Tool '${e.name}' is already registered`);let t={name:e.name,description:e.description,schema:e.schema,execute:e.execute,usesElementIndex:e.usesElementIndex??!1,availability:{openai:e.availability?.openai??!0,mcp:e.availability?.mcp??!0}};this.tools.set(e.name,t)}get(e){return this.tools.get(e)}has(e){return this.tools.has(e)}getToolNames(){return Array.from(this.tools.keys())}getTools(){return Array.from(this.tools.values())}async execute(e,t,i){let n=this.tools.get(e);if(!n)throw new Error(`Tool not found: ${e}`);try{let a=t?.description,o={...t};delete o.description;let r=n.schema.parse(o),s={...i,actionDescription:a};return await n.execute(r,s)}catch(a){if(a instanceof ue.z.ZodError){let o=a.issues.map(r=>`${r.path.join(".")}: ${r.message}`).join(", ");return{success:!1,error:`Invalid arguments for tool '${e}': ${o}`,actionEntity:{action_description:t?.description||`${e} (validation failed)`,action_data:{action_name:e,kwargs:t},feedback:`Validation error: ${o}`}}}throw a}}clear(){this.tools.clear()}size(){return this.tools.size}buildActionUnionSchema(){let e=this.getTools().filter(t=>t.availability.openai);return this.buildUnionSchemaFromTools(e)}buildActionUnionSchemaForTools(e,t=!1){let i=new Set(e),n=this.getTools().filter(a=>i.has(a.name));return this.buildUnionSchemaFromTools(n,t)}buildUnionSchemaFromTools(e,t=!1){if(e.length===0)return ue.z.object({done:ue.z.any()});let i=e.map(r=>{let s=r.schema;if(t&&s instanceof ue.z.ZodObject){let l=s._def.shape();s=ue.z.object({...l,description:ue.z.string().describe("Semantic, human-readable description of the action")})}if(s instanceof ue.z.ZodObject){let l=s._def.shape();Object.keys(l).length===0&&(s=ue.z.object({_empty:ue.z.boolean().optional()}))}return ue.z.object({[r.name]:s})});if(i.length===1)return i[0];let[n,a,...o]=i;return ue.z.union([n,a,...o])}},X=new ma});function Ge(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}var st=x(()=>{"use strict"});async function J(e,t){if(t<0)return;let{page:i,domService:n}=e;return(e.domState||await n.getClickableElements(i)).selectorMap.get(t)}function Xc(e){let t=e.split("/").filter(a=>a);if(t.length===0)return"*";let i=t[t.length-1],n=i.match(/^(\w+)(?:\[(\d+)\])?$/);if(n){let[,a,o]=n;return o?`${a}:nth-of-type(${o})`:a}return i}function Jc(e,t=!0){try{let i=Xc(e.xpath);if(e.attributes.class&&t){let a=/^[a-zA-Z_][a-zA-Z0-9_-]*$/,o=e.attributes.class.split(/\s+/);for(let r of o)r.trim()&&a.test(r)&&(i+=`.${r}`)}let n=new Set(["id","name","type","placeholder","aria-label","aria-labelledby","aria-describedby","role","for","autocomplete","required","readonly","alt","title","target"]);t&&["data-id","data-qa","data-cy","data-testid","data-handlepos"].forEach(a=>n.add(a));for(let[a,o]of Object.entries(e.attributes)){if(a==="class"||!a.trim()||!n.has(a))continue;let r=a.replace(/:/g,"\\:");if(o==="")i+=`[${r}]`;else if(/["'<>`\n\r\t]/.test(o)){let s=o;o.includes(`
|
|
139
139
|
`)&&(s=o.split(`
|
|
140
|
-
`)[0]),s=s.replace(/\s+/g," ").trim();let l=s.replace(/"/g,'\\"');i+=`[${r}*="${l}"]`}else i+=`[${r}="${o}"]`}return i}catch{return`${e.tagName||"*"}[highlight_index='${e.highlightIndex}']`}}function
|
|
140
|
+
`)[0]),s=s.replace(/\s+/g," ").trim();let l=s.replace(/"/g,'\\"');i+=`[${r}*="${l}"]`}else i+=`[${r}="${o}"]`}return i}catch{return`${e.tagName||"*"}[highlight_index='${e.highlightIndex}']`}}function Yc(e){let t=e.attributes;if(t.title)return`iframe[title="${t.title.replace(/"/g,'\\"')}"]`;if(t.id)return`iframe#${t.id}`;if(t.name)return`iframe[name="${t.name.replace(/"/g,'\\"')}"]`;if(t.src){try{let i=new URL(t.src);if(i.protocol==="chrome-extension:")return`iframe[src^="${i.origin}"]`}catch{}return`iframe[src="${t.src.replace(/"/g,'\\"')}"]`}return Jc(e,!1)}function Zo(e){let t=[],i=e;for(;i&&i.parent!==null;){let o=i.parent;t.push(o),i=o}t.reverse();let n=[],a=t.filter(o=>o.tagName==="iframe");for(let o of a){let r=Yc(o);f.debug("[frame-path] iframe attrs:",JSON.stringify(o.attributes),"\u2192",r),n.push(r)}return n}async function U(e,t){let i=null,n=Zo(t);return t.xpath&&(i=await aa(e,t.xpath,n,t.shadowHostXPaths??[])),{locator:i||void 0,xpath:i?void 0:t.xpath,frame_path:n}}var Q=x(()=>{"use strict";Ue();G()});function qc(e){let t=e.toLowerCase();return[/\b(type|enter|input|fill|write|set)\b/,/\b(text|value|field|box)\b.*\b(to|with|as)\b/,/\b(username|password|email|search|query)\b/].some(i=>i.test(t))?"input":[/\bscroll\b/,/\b(scroll|swipe)\s*(up|down|left|right)\b/,/\b(page|move)\s*(down|up)\b/].some(i=>i.test(t))?"scroll":[/\b(click|tap|press|select|choose|pick|check|toggle)\b/,/\b(open|close|submit|confirm|cancel|dismiss)\b/,/\b(button|link|menu|dropdown|checkbox|radio)\b/].some(i=>i.test(t))?"click":"all"}function Zc(e){if(!e)return null;if(e instanceof URL)return e.href;if(typeof e=="object"&&e.href)return String(e.href);if(typeof e=="object"&&typeof e.toString=="function"){let t=e.toString();if(t.startsWith("http://")||t.startsWith("https://"))return t}return typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://"))?e:null}function Qc(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=Zc(n);if(a)return{type:"image",file:a};let o=typeof n=="string"?n:"";return{type:"image",file:o.startsWith("data:")?o:`data:image/png;base64,${o}`}}return{type:"text",text:i.text}}):t.content}))}async function Qo(e,t,i={}){let{page:n,agentServices:a}=t,o=a.getModel(),r=a.retrieveKnowledges(e).catch(O=>(T.log(`Failed to retrieve knowledges: ${O.message}`),[])),s=a.isSlicedScreenshotsEnabled(),l=a.isResizeSlicedScreenshotsEnabled(),c=a.isKnowledgeImagesEnabled(),d=a.isAccessibilityTreeEnabled(),u=a.isActionIntentFilteringEnabled(),m=u?qc(e):"all";u&&m!=="all"&&T.log(`Action intent filtering: detected '${m}' intent from statement`);let{screenshotBase64:p,domState:w,pageContext:g}=await Ji(t,{useSlicedScreenshots:s,resizeSlicedScreenshots:l,useAccessibilityTree:d,actionIntent:m});t.domState=w;let y=new ha(X).getToolDefinitions().map(O=>{let V=O.function;return`${V.name}: ${V.description}
|
|
141
141
|
Parameters: ${JSON.stringify(V.parameters,null,2)}`}).join(`
|
|
142
142
|
|
|
143
|
-
`),h=
|
|
143
|
+
`),h=Yo(y),b=await r,v=qo(g,e,t.variables,t.executionHistory,b.length>0?b:void 0,p,s,void 0,c,t.sensitiveKeys),S=[];i.chatHistory&&i.chatHistory.length>0&&i.chatHistory.forEach(O=>{O.role==="user"?S.push({role:"user",content:O.content}):O.role==="assistant"&&S.push({role:"assistant",content:O.content})}),S.push({role:"user",content:v});let E=Qc(S),$=X.buildActionUnionSchema(),N=Lt.z.object({thought:Lt.z.string().describe("Step by step reasoning of your decision making process").optional().default(""),description:Lt.z.string().describe("Detailed description of the action to be performed").optional().default(""),action:$,completes_instruction:Lt.z.boolean().describe("Whether this action completes the given instruction").optional().default(!0)}),D=Array.isArray(v)?v.filter(O=>O.type==="image").length:0,I=[o,...a.getFallbackModels().filter(O=>O!==o)],W=o,z;try{z=await at(I,O=>{W=O;let V=Te(O,i.temperature);return(0,lt.generateText)({model:ye(O),system:h,messages:S,...V!==void 0?{temperature:V}:{},output:lt.Output.object({schema:N}),providerOptions:be(O,D),maxRetries:4})},(O,V)=>T.log(`Action-gen model ${O} unavailable; falling back to ${V}`))}catch(O){if(lt.NoObjectGeneratedError.isInstance(O)){let V={},Ze=!1;if(O.text!=null)try{V=JSON.parse(O.text),Ze=!0}catch{}let Oe=V.thought||V.description||"",ho=Oe.length>300?`${Oe.slice(0,300)}\u2026`:Oe,nc=!V.action||typeof V.action=="object"&&Object.keys(V.action).length===0,mo=[],po=Ge(O.usage,W);po&&mo.push(po);let go={systemPrompt:h,userPrompt:E,rawLlmResponse:O.text??"",tokenUsages:mo};if(Ze&&nc)return{status:"error",reasoning:Oe||"No matching element/action found",goalAccomplished:V.completes_instruction??!1,error:ho?`No matching element/action: ${ho}`:"Agent did not generate any action (no matching element found)",debugInfo:go};let fo=Ze?"Action generation failed: the model returned an action that did not match any known action schema.":"Action generation failed: the model returned a response that could not be parsed as a valid action.";return{status:"error",reasoning:Oe||fo,goalAccomplished:V.completes_instruction??!1,error:fo,debugInfo:go}}throw O}if(z.output==null){let O=z.finishReason,V=O==="length"?"Action generation failed: the model response was truncated before a complete action could be produced (token limit reached).":O==="content-filter"?"Action generation failed: the model response was blocked by a content filter.":`Action generation failed: the model stopped before producing an action (finishReason=${O??"unknown"}).`,Ze=[],Oe=Ge(z.usage,W);return Oe&&Ze.push(Oe),{status:"error",reasoning:"",goalAccomplished:!1,error:V,debugInfo:{systemPrompt:h,userPrompt:E,rawLlmResponse:z.text??"",tokenUsages:Ze}}}let ee=z.reasoningText;f.info(`Action Generation Reasoning: ${ee}`);let B=z.output,Y=JSON.stringify(B,null,2);f.info(`Generate Action Raw Output: ${Y}`);let ge=[],Ye=Ge(z.usage,W);Ye&&ge.push(Ye);let Ce={systemPrompt:h,userPrompt:E,rawLlmResponse:Y,tokenUsages:ge},ke=B.thought||"",Pe=B.description||"",qe=B.action||{},j=B.completes_instruction||!1;if(!qe||Object.keys(qe).length===0)return{status:"error",reasoning:ke||Pe||"No action generated",goalAccomplished:j,error:"Agent did not generate any action",debugInfo:Ce};let Z=Object.keys(qe)[0];if(Z==="done")return{status:"error",reasoning:ke||Pe||"Task marked as done",goalAccomplished:j,error:"Agent indicated task is done without generating an action",debugInfo:Ce};if(Z==="perform_accurate_operation")return await ot(e,t,i);if(!j){let O="Can't complete the instruction in one action";return{status:"error",reasoning:ke||Pe||O,goalAccomplished:!1,error:O,debugInfo:Ce}}let ne=qe[Z]||{},Ne={};if(typeof ne.element_index=="number"){let O=ne.element_index;if(O<0)return{status:"error",reasoning:ke||Pe||"No action generated",goalAccomplished:j,error:"Agent did not generate any action",debugInfo:Ce};let V=w.selectorMap.get(O);V&&(Ne=await U(n,V))}let uo=Pe;return Z==="verify"&&(uo=e,ne.statement=e),{status:"success",actionEntity:{...Ne,action_description:uo||ke||`${Z}(${JSON.stringify(ne)})`,action_data:{action_name:Z,kwargs:ne}},reasoning:ke||Pe,goalAccomplished:j,debugInfo:Ce}}var lt,Lt,Yi=x(()=>{"use strict";rt();zi();Re();Xi();Ot();Ae();re();st();xe();Q();G();lt=require("ai"),Lt=require("zod")});function ed(e){if(!e)return null;if(e instanceof URL)return e.href;if(typeof e=="object"&&e.href)return String(e.href);if(typeof e=="object"&&typeof e.toString=="function"){let t=e.toString();if(t.startsWith("http://")||t.startsWith("https://"))return t}return typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://"))?e:null}async function pa(e,t,i={}){return i.usePureVision?ot(e,t,i):Qo(e,t,i)}function id(){let e=new Date,t=e.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"America/Los_Angeles"}),i=e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZoneName:"short",timeZone:"America/Los_Angeles"});return{dateString:t,timeString:i}}function nd(){return`# Role
|
|
144
144
|
You are an experienced QA person for web applications.
|
|
145
145
|
You are tasked to verify the validity of a given statement based on the screenshot and element tree of a web page.
|
|
146
|
-
`}async function
|
|
146
|
+
`}async function er(e,t,i={}){let{page:n,executionHistory:a}=t,o=t.agentServices.getModel();try{let r=t.agentServices.isSlicedScreenshotsEnabled(),s=t.agentServices.isResizeSlicedScreenshotsEnabled(),l=t.agentServices.isKnowledgeImagesEnabled(),c=t.agentServices.isAccessibilityTreeEnabled(),{domTree:d,screenshotBase64:u,slicedScreenshotsBase64:m,domState:p,pageContext:w}=await Ji(t,{useCleanScreenshot:i.useCleanScreenshotForAssertion,useSlicedScreenshots:r,resizeSlicedScreenshots:s,useAccessibilityTree:c});t.domState=p;let g="";a&&a.length>0&&(g=`
|
|
147
147
|
# Previous actions in this session:
|
|
148
|
-
${a.map(([
|
|
148
|
+
${a.map(([j,Z],ne)=>`${ne+1}. Action: ${j}
|
|
149
149
|
Result: ${Z}`).join(`
|
|
150
150
|
`)}
|
|
151
|
-
`);let{dateString:
|
|
151
|
+
`);let{dateString:y,timeString:h}=id(),b=`
|
|
152
152
|
# User statement
|
|
153
153
|
"${e}"
|
|
154
154
|
|
|
155
155
|
# Current webpage state
|
|
156
156
|
## Tab information:
|
|
157
|
-
${
|
|
158
|
-
${
|
|
157
|
+
${w.currentTabText}Available tabs:
|
|
158
|
+
${w.tabsText}
|
|
159
159
|
|
|
160
160
|
## Element interaction guidelines:
|
|
161
161
|
- Each element has a unique index number (e.g., "[33]<button>")
|
|
@@ -166,23 +166,23 @@ ${y.tabsText}
|
|
|
166
166
|
${d}
|
|
167
167
|
|
|
168
168
|
## Screenshot
|
|
169
|
-
${r&&
|
|
170
|
-
`,v="";if(t.variables&&Object.keys(t.variables).length>0){let
|
|
169
|
+
${r&&m?"The following images are sliced screenshots of the current webpage (left, middle, right sections).":"The image provided is a screenshot of the current webpage."}
|
|
170
|
+
`,v="";if(t.variables&&Object.keys(t.variables).length>0){let j=[];for(let Z of Object.keys(t.variables))if(!t.sensitiveKeys?.has(Z)){let ne=t.variables[Z],Ne=typeof ne=="string"?ne:JSON.stringify(ne);j.push(` - ${Z}: "${Ne}"`)}j.length>0&&(v=`
|
|
171
171
|
## Available Variables
|
|
172
172
|
The following non-sensitive variables are available:
|
|
173
|
-
${
|
|
173
|
+
${j.join(`
|
|
174
174
|
`)}`)}let S=`
|
|
175
175
|
${v}
|
|
176
176
|
${g}
|
|
177
177
|
|
|
178
|
-
Today is ${
|
|
178
|
+
Today is ${y}. Current local time is ${h}.
|
|
179
179
|
Based on the above information, please determine if the statement is true.
|
|
180
|
-
`,E=await t.agentServices.retrieveKnowledges(e),$=[{type:"text",text:b}],
|
|
180
|
+
`,E=await t.agentServices.retrieveKnowledges(e),$=[{type:"text",text:b}],N=0;if(r&&m&&m.length>0)for(let j of m)$.push({type:"image",image:j}),N++;else $.push({type:"image",image:u}),N=1;if(E&&E.length>0){let j=Vi(E,l);$.push(...j)}$.push({type:"text",text:S});let D=E?Jo(E,l):0,I=N+D,W=nd(),z=[o,...t.agentServices.getFallbackModels().filter(j=>j!==o)],ee=o,B=await at(z,j=>{ee=j;let Z=Te(j,i.temperature);return(0,qi.generateText)({model:ye(j),system:W,messages:[{role:"user",content:$}],output:qi.Output.object({schema:td}),...Z!==void 0?{temperature:Z}:{},providerOptions:be(j,I)})}),{conclusion:Y,explanation:ge}=B.output,Ye=JSON.stringify(B.output,null,2),Ce=[],ke=Ge(B.usage,ee);ke&&Ce.push(ke);let Pe=[{role:"user",content:$.map(j=>{if(j.type==="text")return{type:"text",text:j.text};if(j.type==="image"){let Z=j.image,ne=ed(Z);if(ne)return{type:"image",file:ne};let Ne=typeof Z=="string"?Z:"";return{type:"image",file:Ne.startsWith("data:")?Ne:`data:image/png;base64,${Ne}`}}return{type:"text",text:"[unknown content type]"}})}],qe={systemPrompt:W,userPrompt:Pe,rawLlmResponse:Ye,screenshotWithSom:u,tokenUsages:Ce,retrievedKnowledges:E&&E.length>0?E:void 0,elementTree:d};return{success:Y==="true",explanation:ge,debugInfo:qe}}catch(r){return{success:!1,error:r.message}}}var qi,Dt,td,Zi=x(()=>{"use strict";Yi();rt();Re();Ot();Nt();st();xe();qi=require("ai"),Dt=require("zod");td=Dt.z.object({screenshotDescription:Dt.z.string().describe(`Description of the screenshot content, listing out key elements along with their Set of Mark indices,
|
|
181
181
|
and a description of their location: formatting example: [12] A red button with text "Submit", next to [11]
|
|
182
182
|
[45] A modal dialog titled "Confirmation",
|
|
183
|
-
in the center of the screen`),explanation:Dt.z.string().describe("Step by step reasoning explaining your conclusion about the statement"),conclusion:Dt.z.enum(["true","false","unknown"]).describe("Whether the statement is true, false, or unknown if you cannot make a conclusion")})});async function
|
|
184
|
-
`).trim()}clickableElementsToString(t){let i=t?.includeAttributes??
|
|
185
|
-
`)}}});var fa,wa,ya,ba,
|
|
183
|
+
in the center of the screen`),explanation:Dt.z.string().describe("Step by step reasoning explaining your conclusion about the statement"),conclusion:Dt.z.enum(["true","false","unknown"]).describe("Whether the statement is true, false, or unknown if you cannot make a conclusion")})});async function ir(){let{default:e}=await import("sharp");return e}async function ga(e,t){let i=await ir(),n=await i(e).metadata(),a=n.width||0,o=n.height||0;if(a===0||o===0)throw new Error("Invalid image dimensions");let r=o,s=0,l=Math.floor((a-r)/2),c=Math.max(0,a-r),d=(w,g)=>{let y=i(e).extract({left:w,top:0,width:g,height:r});return t?.resize&&(y=y.resize(tr,tr)),y.png().toBuffer()},[u,m,p]=await Promise.all([d(s,Math.min(r,a)),d(l,Math.min(r,a-l)),d(c,Math.min(r,a-c))]);return[u,m,p]}async function nr(e){let t=(await ir())(e),i=await t.metadata(),n=i.width||0,a=i.height||0;if(n===0||a===0)throw new Error("Invalid image dimensions");let{data:o}=await t.grayscale().raw().toBuffer({resolveWithObject:!0}),r=[];for(let s=0;s<a;s++){r[s]=[];for(let l=0;l<n;l++)r[s][l]=o[s*n+l]}return{pixels:r,width:n,height:a}}var tr,Rt=x(()=>{"use strict";tr=768});function ar(e,t){return e.length>t?e.slice(0,t)+"...":e}var Ft=x(()=>{"use strict"});var or,rr,Ht=x(()=>{"use strict";or=["title","type","checked","name","role","value","placeholder","data-date-format","alt","aria-label","aria-expanded","data-state","aria-checked","data-id","data-testid","data-test-id","data-handlepos","data-item-id"],rr={"react-flow__(\\S+)":"$1"}});var sr,Wt,$e,ct=x(()=>{"use strict";Ft();Ht();sr=class{constructor(e,t=null){this.isVisible=e,this.parent=t}},Wt=class extends sr{constructor(e,t,i=null){super(t,i),this.text=e,this.type="TEXT_NODE"}hasParentWithHighlightIndex(){let e=this.parent;for(;e!==null;){if(e.highlightIndex!==null)return!0;e=e.parent}return!1}isParentInViewport(){return this.parent===null?!1:this.parent.isInViewport}isParentTopElement(){return this.parent===null?!1:this.parent.isTopElement}},$e=class Qi extends sr{constructor(t,i,n,a,o,r=!1,s=!1,l=!1,c=!1,d=!1,u=!1,m=null,p=null,w=null,g=null,y=[],h=null){super(o,h),this.tagName=t,this.xpath=i,this.attributes=n,this.children=a,this.isInteractive=r,this.isScrollable=s,this.markAsClickable=l,this.isTopElement=c,this.isInViewport=d,this.shadowRoot=u,this.highlightIndex=m,this.viewportCoordinates=p,this.pageCoordinates=w,this.viewportInfo=g,this.isNew=null,this.shadowHostXPaths=y}getAllTextTillNextClickableElement(t=-1){let i=[],n=(a,o)=>{if(!(t!==-1&&o>t)&&!(a instanceof Qi&&a!==this&&a.highlightIndex!==null)){if(a instanceof Wt)i.push(a.text);else if(a instanceof Qi)for(let r of a.children)n(r,o+1)}};return n(this,0),i.join(`
|
|
184
|
+
`).trim()}clickableElementsToString(t){let i=t?.includeAttributes??or,n=t?.includeClassesWithRename??rr,a=[],o=(r,s)=>{let l=s,c=" ".repeat(s);if(r instanceof Qi){if(r.highlightIndex!==null){l+=1;let d=r.isScrollable?"":r.getAllTextTillNextClickableElement(),u=null;if(i.length>0){let h={};for(let S of Object.keys(r.attributes))if(i.includes(S)){let E=r.attributes[S].trim();E!==""&&(h[S]=E)}let b=i.filter(S=>S in h);if(b.length>1){let S=new Set,E={};for(let $ of b){let N=h[$];N.length>5&&(N in E?S.add($):E[N]=$)}for(let $ of S)delete h[$]}r.tagName===h.role&&delete h.role;let v=["aria-label","placeholder","title"];for(let S of v)h[S]&&h[S].trim().toLowerCase()===d.trim().toLowerCase()&&delete h[S];Object.keys(h).length>0&&(u=Object.entries(h).map(([S,E])=>`${S}=${ar(E,200)}`).join(" "))}let m=r.isNew?`*[${r.highlightIndex}]`:`[${r.highlightIndex}]`,p=[];if(Object.keys(n).length>0&&r.attributes.class){let h=r.attributes.class.split(/\s+/);for(let b of h)for(let[v,S]of Object.entries(n))try{let E=new RegExp(`^${v}$`);if(b.match(E)){let $=b.replace(E,S);$&&p.push($);break}}catch{continue}}let w=r.isScrollable?" (SCROLLABLE)":"",g=r.markAsClickable?" (CLICKABLE)":"",y=`${c}${m}${w}${g}<${r.tagName}`;if(p.length>0&&(y+=` ${p.join(" ")}`),u&&(y+=` ${u}`),d){let h=d.trim();u||(y+=" "),y+=`>${h}`}else u||(y+=" ");y+=" />",a.push(y)}else{let d=["data-testid","data-test-id"].filter(u=>r.attributes[u]);d.length>0&&(l+=1,a.push(`${c}<${r.tagName} ${d.map(u=>`${u}="${r.attributes[u]}"`).join(" ")} />`))}for(let d of r.children)o(d,l)}else if(r instanceof Wt){if(r.hasParentWithHighlightIndex())return;r.parent&&r.parent.isVisible&&r.parent.isTopElement&&a.push(`${c}${r.text}`)}};return o(this,0),a.join(`
|
|
185
|
+
`)}}});var fa,wa,ya,ba,jt=x(()=>{"use strict";fa=new Set(["button","link","textbox","checkbox","radio","combobox","listbox","menuitem","menuitemcheckbox","menuitemradio","option","tab","switch","slider","spinbutton","searchbox","scrollbar","treeitem","gridcell"]),wa=new Set(["click","mousedown","mouseup","dblclick","pointerdown","pointerup","touchstart","touchend"]),ya=["[onclick]","[onmousedown]","[ontouchstart]","div","span","li","tr","td","[role]",'[class*="btn"]','[class*="button"]','[class*="click"]',"[data-action]","[data-click]"],ba=500});function rd(e){return e==="about:blank"||e==="chrome://newtab/"||e==="edge://newtab/"||e==="about:newtab"}var ad,od,Fe,Ke=x(()=>{"use strict";Rt();ct();jt();G();ad=`(
|
|
186
186
|
args = {
|
|
187
187
|
doHighlightElements: true,
|
|
188
188
|
focusHighlightIndex: -1,
|
|
@@ -1950,7 +1950,7 @@ Based on the above information, please determine if the statement is true.
|
|
|
1950
1950
|
|
|
1951
1951
|
return { rootId, map: DOM_HASH_MAP };
|
|
1952
1952
|
}
|
|
1953
|
-
`,
|
|
1953
|
+
`,od=`((args = {
|
|
1954
1954
|
doHighlightElements: true,
|
|
1955
1955
|
focusHighlightIndex: -1,
|
|
1956
1956
|
viewportExpansion: 0,
|
|
@@ -3998,7 +3998,7 @@ Based on the above information, please determine if the statement is true.
|
|
|
3998
3998
|
// Return element data from boxes phase for use in labels phase
|
|
3999
3999
|
elementData: phase === 'boxes' ? collectedElementData : undefined,
|
|
4000
4000
|
};
|
|
4001
|
-
})`;Fe=class{normalizeDomain(e){let t=e.trim().toLowerCase();if(!t)return"";try{if(t.includes("://"))return new URL(t).hostname.toLowerCase()}catch{return""}return t.split("/")[0].split(":")[0]}isConfiguredIframeFallbackDomain(e,t){let i;try{i=new URL(e).hostname.toLowerCase()}catch{return!1}for(let n of t){let a=this.normalizeDomain(n);if(a&&(i===a||i.endsWith(`.${a}`)))return!0}return!1}shouldProcessWithPlaywrightFrameFallback(e,t){if(!e.inaccessibleFrame)return!1;let i=e.attributes?.src;return i?i.startsWith("chrome-extension://")?!0:this.isConfiguredIframeFallbackDomain(i,t):!1}constructor(e={}){f.debug("\u{1F333} Initializing DomService with options:",e),this.useDomTreeTs=e.useDomTreeTs??!1,this.domTreeRoot=e.domTreeRoot??"body",this.jsCode=this.useDomTreeTs?
|
|
4001
|
+
})`;Fe=class{normalizeDomain(e){let t=e.trim().toLowerCase();if(!t)return"";try{if(t.includes("://"))return new URL(t).hostname.toLowerCase()}catch{return""}return t.split("/")[0].split(":")[0]}isConfiguredIframeFallbackDomain(e,t){let i;try{i=new URL(e).hostname.toLowerCase()}catch{return!1}for(let n of t){let a=this.normalizeDomain(n);if(a&&(i===a||i.endsWith(`.${a}`)))return!0}return!1}shouldProcessWithPlaywrightFrameFallback(e,t){if(!e.inaccessibleFrame)return!1;let i=e.attributes?.src;return i?i.startsWith("chrome-extension://")?!0:this.isConfiguredIframeFallbackDomain(i,t):!1}constructor(e={}){f.debug("\u{1F333} Initializing DomService with options:",e),this.useDomTreeTs=e.useDomTreeTs??!1,this.domTreeRoot=e.domTreeRoot??"body",this.jsCode=this.useDomTreeTs?od:ad}async getClickableElements(e,t={}){let{highlightElements:i=!0,focusElement:n=-1,viewportExpansion:a=0,interactiveClassNames:o=[],playwrightFrameFallbackDomains:r=[],alwaysHighlightFileInput:s=!1,sameRectIoUThreshold:l,actionIntent:c="all"}=t,[d,u]=await this.buildDomTree(e,i,n,a,o,r,s,l,c);return{elementTree:d,selectorMap:u}}async getClickableElementsWithScreenshot(e,t={}){if(t.useAccessibilityTree)return this.getClickableElementsWithAXTree(e,t);let i;t.useCleanScreenshot&&(i=await e.screenshot({type:"png",fullPage:!1}));let n=await this.getClickableElements(e,t);if(await e.waitForTimeout(100),t.useCleanScreenshot||(i=await e.screenshot({type:"png",fullPage:!1})),await this.removeHighlights(e,t.playwrightFrameFallbackDomains||[]),!i)throw new Error("Failed to capture screenshot: screenshot buffer is undefined");let a=i.toString("base64"),o;if(t.useSlicedScreenshots)try{o=(await ga(i,{resize:t.resizeSlicedScreenshots})).map(r=>r.toString("base64"))}catch(r){f.warn("Failed to slice screenshot:",r)}return{domState:n,screenshotBase64:a,screenshot:i,slicedScreenshotsBase64:o}}async getClickableElementsWithAXTree(e,t={}){f.debug("\u{1F333} Using CDP Accessibility Tree for element detection");let i;t.useCleanScreenshot&&(i=await e.screenshot({type:"png",fullPage:!1}));let n=await e.context().newCDPSession(e),{nodes:a}=await n.send("Accessibility.getFullAXTree",{depth:-1});f.debug(`\u{1F4CA} Got ${a.length} AXNodes from accessibility tree`);let o=a.filter(h=>{if(h.ignored)return!1;let b=h.role?.value;return!(!b||!fa.has(b)||h.properties?.find(v=>v.name==="disabled")?.value?.value||!h.backendDOMNodeId)});f.debug(`\u2705 Found ${o.length} interactive elements from AXTree`);let r=a.filter(h=>h.role?.value==="button");f.debug(`\u{1F518} Total buttons in AXTree: ${r.length}`);for(let h of r){let b=[];h.ignored&&b.push("ignored"),h.backendDOMNodeId||b.push("no-backendDOMNodeId"),h.properties?.find(v=>v.name==="disabled")?.value?.value&&b.push("disabled"),f.debug(` - "${h.name?.value||"(no name)"}" ${b.length>0?`[SKIPPED: ${b.join(", ")}]`:"[INCLUDED]"}`)}let s=new Set(o.map(h=>h.backendDOMNodeId)),l=await this.getElementsWithEventListeners(n,t.eventListenerLimit??500),c=0;for(let h of l)s.has(h.backendNodeId)||(o.push({nodeId:`synthetic-${h.backendNodeId}`,ignored:!1,backendDOMNodeId:h.backendNodeId,role:{type:"role",value:"generic"},name:{type:"string",value:""},properties:[{name:"eventListeners",value:{type:"string",value:h.eventTypes.join(",")}}]}),s.add(h.backendNodeId),c++);f.debug(`\u{1F3AF} Added ${c} elements from event listeners (total: ${o.length})`);let d=await this.resolveAXNodesToDOM(n,o),u=d.filter(h=>h.isVisible&&h.isInViewport&&h.isTopElement&&h.boundingRect),m=d.filter(h=>!(h.isVisible&&h.isInViewport&&h.isTopElement&&h.boundingRect));if(m.length>0){f.debug(`\u{1F6AB} Filtered out ${m.length} elements:`);for(let h of m){let b=[];h.isVisible||b.push("not-visible"),h.isInViewport||b.push("not-in-viewport"),h.isTopElement||b.push("not-top-element"),h.boundingRect||b.push("no-bounding-rect"),f.debug(` - <${h.tagName}> "${h.axNode.name?.value||""}" [${b.join(", ")}]`)}}f.debug(`\u{1F441}\uFE0F ${u.length} elements are visible and in viewport`);let{domState:p,highlightIndex:w}=await this.buildDomStateFromAXTree(u);t.highlightElements!==!1&&w>0&&(await this.renderHighlightsForAXElements(e,u.slice(0,w)),await e.waitForTimeout(100)),t.useCleanScreenshot||(i=await e.screenshot({type:"png",fullPage:!1})),await this.removeHighlights(e,t.playwrightFrameFallbackDomains||[]);try{await n.detach()}catch{}if(!i)throw new Error("Failed to capture screenshot: screenshot buffer is undefined");let g=i.toString("base64"),y;if(t.useSlicedScreenshots)try{y=(await ga(i,{resize:t.resizeSlicedScreenshots})).map(h=>h.toString("base64"))}catch(h){f.warn("Failed to slice screenshot:",h)}return{domState:p,screenshotBase64:g,screenshot:i,slicedScreenshotsBase64:y}}async resolveAXNodesToDOM(e,t){let i=[],n=t.map(o=>o.backendDOMNodeId).filter(o=>o!==void 0);if(n.length===0)return i;let a=[];for(let o of n)try{let{object:r}=await e.send("DOM.resolveNode",{backendNodeId:o});a.push(r.objectId||null)}catch{a.push(null)}for(let o=0;o<t.length;o++){let r=t[o],s=a[o];if(s)try{let{result:l}=await e.send("Runtime.callFunctionOn",{objectId:s,functionDeclaration:`function() {
|
|
4002
4002
|
const el = this;
|
|
4003
4003
|
const rect = el.getBoundingClientRect();
|
|
4004
4004
|
const rects = el.getClientRects();
|
|
@@ -4082,38 +4082,38 @@ Based on the above information, please determine if the statement is true.
|
|
|
4082
4082
|
} : null,
|
|
4083
4083
|
clientRects: clientRectsArray
|
|
4084
4084
|
};
|
|
4085
|
-
}`,returnByValue:!0});l.value&&i.push({axNode:r,...l.value})}catch(l){f.debug(`Failed to resolve element: ${l}`)}}return i}async getElementsWithEventListeners(e,t=ba){let i=[];try{let{root:n}=await e.send("DOM.getDocument",{depth:0}),a=ya.join(","),{nodeIds:o}=await e.send("DOM.querySelectorAll",{nodeId:n.nodeId,selector:a});f.debug(`\u{1F50D} Checking ${Math.min(o.length,t)} elements for event listeners`);for(let r of o.slice(0,t))try{let{object:s}=await e.send("DOM.resolveNode",{nodeId:r});if(!s.objectId)continue;let{listeners:l}=await e.send("DOMDebugger.getEventListeners",{objectId:s.objectId}),c=l.filter(d=>wa.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:s.objectId})}catch{}f.debug(`\u2705 Found ${i.length} elements with interaction event listeners`)}catch(n){f.warn("Failed to get elements with event listeners:",n)}return i}async buildDomStateFromAXTree(e){let t=new Map,i=new $e("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||"",s=["button","link","menuitem","tab","switch"].includes(o),l=new $e(a.tagName,a.xpath,a.attributes,[],a.isVisible,!0,o==="scrollbar",s,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 Wt(r,!0,l);l.children.push(c)}i.children.push(l),t.set(n,l),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((s,l)=>{if(!s.boundingRect)return;let c=a[l%a.length],d=s.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=l>=100?"8px":"12px",p.textContent=String(l);let m=Math.max(0,d.y-16),y=Math.max(0,Math.min(d.x+d.width-20,window.innerWidth-25));p.style.top=`${m}px`,p.style.left=`${y}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),f.debug("\u2705 Highlights removed from page")}catch(n){f.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(s=>s.map(l=>l.src)),i=s=>{try{let l=new URL(s);return["doubleclick.net","adroll.com","googletagmanager.com"].some(c=>l.hostname.includes(c))}catch{return!1}},n=e.url(),a=new URL(n).hostname,o=e.frames(),r=[];for(let s of o){let l=s.url();try{let c=new URL(l).hostname;c&&c!==a&&!t.includes(l)&&!i(l)&&r.push(l)}catch{continue}}return r}async buildDomTree(e,t,i,n,a,o,r,s,l="all"){if(await e.evaluate("1+1")!==2)throw new Error("The page cannot evaluate javascript code properly");if(ad(e.url()))return[new $e("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:s,actionIntent:l,domTreeRoot:this.domTreeRoot};f.debug(`\u{1F527} Starting JavaScript DOM analysis for ${e.url().slice(0,50)}...`);let d,u=null;if(this.useDomTreeTs&&t)try{let w={...c,phase:"boxes",grayscaleImage:null},h=await e.evaluate(({code:O,argsObj:D})=>new Function("return "+O)()(D),{code:this.jsCode,argsObj:w});f.debug(`\u{1F4E6} Phase 1: Drew ${h.elementData?.length||0} bounding boxes`);let b=await e.screenshot({type:"png",fullPage:!1});f.debug("\u{1F4F8} Captured screenshot with bounding boxes");let v=performance.now(),S=await ir(b);u=S.pixels;let E=Math.round(performance.now()-v);f.debug(`\u{1F5BC}\uFE0F Generated grayscale image (${S.width}x${S.height}) in ${E}ms`);let $={...c,phase:"labels",grayscaleImage:u,elementData:h.elementData};d=await e.evaluate(({code:O,argsObj:D})=>new Function("return "+O)()(D),{code:this.jsCode,argsObj:$}),d.map=h.map,d.rootId=h.rootId,d.highlightCount=h.highlightCount,d.perfMetrics=h.perfMetrics,f.debug("\u2705 Phase 2: Labels placed using grayscale-based positioning")}catch(w){f.warn("Two-phase rendering failed, falling back to legacy mode:",w.message),u=null;let h={...c,grayscaleImage:null};d=await e.evaluate(({code:b,argsObj:v})=>new Function("return "+b)()(v),{code:this.jsCode,argsObj:h}),f.debug("\u2705 JavaScript DOM analysis completed (legacy mode)")}else try{d=await e.evaluate(({code:w,argsObj:h})=>new Function("return "+w)()(h),{code:this.jsCode,argsObj:c}),f.debug("\u2705 JavaScript DOM analysis completed")}catch(w){throw f.error("Error evaluating JavaScript:",w.message),w}if(!d||typeof d!="object")throw f.error("JavaScript returned invalid result:",d),new Error("JavaScript DOM analysis returned invalid result");if(!d.map||!d.rootId)throw f.error("JavaScript result missing map or rootId:",JSON.stringify(d,null,2)),new Error("JavaScript result missing required fields (map or rootId)");if(l!=="all"&&d.highlightCount===0){f.debug(`\u26A0\uFE0F No elements matched intent '${l}', falling back to 'all'`);let w={...c,actionIntent:"all"};d=await e.evaluate(({code:h,argsObj:b})=>new Function("return "+h)()(b),{code:this.jsCode,argsObj:w})}let p=Object.entries(d.map).filter(([,w])=>w.tagName==="iframe");f.debug(`\u{1F50D} [ext-iframe] Total iframe nodes in map: ${p.length}`);for(let[w,h]of p){let b=h;f.debug(`\u{1F50D} [ext-iframe] iframe node id=${w} src=${b.attributes?.src} inaccessibleFrame=${b.inaccessibleFrame}`)}let m=e.frames();f.debug(`\u{1F50D} [ext-iframe] Playwright frames count: ${m.length}`);for(let w of m)f.debug(`\u{1F50D} [ext-iframe] Playwright frame url=${w.url()}`);let y=[];for(let[w,h]of Object.entries(d.map)){let b=h;this.shouldProcessWithPlaywrightFrameFallback(b,o)&&y.push({nodeId:w,src:b.attributes.src})}if(f.debug(`\u{1F50D} [ext-iframe] Inaccessible fallback iframes found: ${y.length}`),y.length>0){f.debug(`\u{1F50C} Found ${y.length} inaccessible iframe(s) for Playwright fallback, processing`);let w=-1;for(let h of Object.values(d.map)){let b=h;b.highlightIndex!=null&&(w=Math.max(w,b.highlightIndex))}f.debug(`\u{1F50D} [ext-iframe] Main page max highlight index: ${w}`);for(let h=0;h<y.length;h++){let{nodeId:b,src:v}=y[h];f.debug(`\u{1F50D} [ext-iframe] Processing fallback iframe [${h}]: ${v}`);let S=D=>{try{let I=new URL(D);if(I.protocol==="chrome-extension:"&&I.hostname)return`chrome-extension://${I.hostname}`;let W=I.origin;return W==="null"?null:W}catch{return null}},E=S(v);f.debug(`\u{1F50D} [ext-iframe] iframe src origin=${E??"null"}`);let $=null,O=e.frames().find(D=>{let I=D.url();if(I===v)return $="exact",f.debug(`\u{1F50D} [ext-iframe] Candidate frame matched by exact URL: ${I}`),!0;let W=S(I);return f.debug(`\u{1F50D} [ext-iframe] Candidate frame compare url=${I} origin=${W??"null"} vs srcOrigin=${E??"null"}`),E&&W===E?($="origin",f.debug(`\u{1F50D} [ext-iframe] Candidate frame matched by origin: ${I}`),!0):!1});if(!O){f.debug(`\u26A0\uFE0F [ext-iframe] No Playwright frame found for fallback iframe: ${v}`),f.debug(`\u26A0\uFE0F [ext-iframe] Available frame URLs: ${e.frames().map(D=>D.url()).join(", ")}`);continue}f.debug(`\u{1F50D} [ext-iframe] Found matching Playwright frame for: ${v} (frame url: ${O.url()})`);try{let D={...c,initialHighlightIndex:w+1,domTreeRoot:"body"};f.debug(`\u{1F50D} [ext-iframe] Running dom-tree in extension frame with initialHighlightIndex=${D.initialHighlightIndex}`);let I=await O.evaluate(({code:B,argsObj:Y})=>new Function("return "+B)()(Y),{code:this.jsCode,argsObj:D});if(f.debug(`\u{1F50D} [ext-iframe] frameEval result: map size=${Object.keys(I?.map??{}).length} rootId=${I?.rootId}`),!I?.map||!I.rootId){f.debug("\u26A0\uFE0F [ext-iframe] frameEval missing map or rootId, skipping");continue}let W=Object.values(I.map).filter(B=>B.highlightIndex!=null);f.debug(`\u{1F50D} [ext-iframe] Interactive elements in extension frame: ${W.length}`);for(let B of W){let Y=B;f.debug(`\u{1F50D} [ext-iframe] - <${Y.tagName}> highlightIndex=${Y.highlightIndex} text="${Y.children?.length?"...":""}"`)}for(let B of Object.values(I.map)){let Y=B;Y.highlightIndex!=null&&(w=Math.max(w,Y.highlightIndex))}let K=`ext_${h}_`;for(let[B,Y]of Object.entries(I.map)){let ge={...Y};ge.children&&(ge.children=ge.children.map(Ye=>`${K}${Ye}`)),d.map[`${K}${B}`]=ge}let ee=d.map[b];ee?(ee.children=[...ee.children||[],`${K}${I.rootId}`],f.debug(`\u{1F50D} [ext-iframe] Attached frame root to iframe node ${b}`)):f.debug(`\u26A0\uFE0F [ext-iframe] iframe node ${b} not found in map`),f.debug(`\u2705 Merged fallback iframe content from: ${v}`)}catch(D){f.warn(`Failed to process fallback iframe ${v}:`,D)}}}if(d&&d.perfMetrics){let w=d.perfMetrics.nodeMetrics?.totalNodes??0,h=0;if(d.map)for(let v of Object.values(d.map))typeof v=="object"&&v!==null&&v.isInteractive&&h++;let b=e.url().length>50?e.url().slice(0,50)+"...":e.url();f.debug(`\u{1F50E} Ran buildDOMTree.js interactive element detection on: ${b} interactive=${h}/${w}`)}f.debug("\u{1F504} Starting TypeScript DOM tree construction...");let g=await this.constructDomTree(d);return f.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[s,l]of Object.entries(t)){let[c,d]=this.parseNode(l);c!==null&&(a.set(s,c),o.set(s,d),c instanceof $e&&c.highlightIndex!==null&&n.set(c.highlightIndex,c))}for(let[s,l]of o){let c=a.get(s);if(c instanceof $e)for(let d of l){let u=a.get(d);u&&(u.parent=c,c.children.push(u))}}let r=a.get(i);if(!r||!(r instanceof $e))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 Wt(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 $e(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 sr,lr,Ep,en=x(()=>{"use strict";sr=require("zod"),lr=class{async execute(e,t){await e.waitForLoadState("networkidle",{timeout:5e3}).catch(()=>{}),await e.waitForLoadState("domcontentloaded")}transpile(e){return["await page.waitForLoadState('domcontentloaded');"]}},Ep=sr.z.object({})});var cr,tn=x(()=>{"use strict";G();C();cr=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=F(e,t);if(a){await a.waitFor({state:"attached",timeout:R(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,s=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.move(r,s),await e.waitForTimeout(200),await e.mouse.click(r,s,{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 dr,nn=x(()=>{"use strict";G();C();dr=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=F(e,t),r=R(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=Le(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=R();return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${n} });`]}}});var ur,an=x(()=>{"use strict";ur=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});l.value&&i.push({axNode:r,...l.value})}catch(l){f.debug(`Failed to resolve element: ${l}`)}}return i}async getElementsWithEventListeners(e,t=ba){let i=[];try{let{root:n}=await e.send("DOM.getDocument",{depth:0}),a=ya.join(","),{nodeIds:o}=await e.send("DOM.querySelectorAll",{nodeId:n.nodeId,selector:a});f.debug(`\u{1F50D} Checking ${Math.min(o.length,t)} elements for event listeners`);for(let r of o.slice(0,t))try{let{object:s}=await e.send("DOM.resolveNode",{nodeId:r});if(!s.objectId)continue;let{listeners:l}=await e.send("DOMDebugger.getEventListeners",{objectId:s.objectId}),c=l.filter(d=>wa.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:s.objectId})}catch{}f.debug(`\u2705 Found ${i.length} elements with interaction event listeners`)}catch(n){f.warn("Failed to get elements with event listeners:",n)}return i}async buildDomStateFromAXTree(e){let t=new Map,i=new $e("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||"",s=["button","link","menuitem","tab","switch"].includes(o),l=new $e(a.tagName,a.xpath,a.attributes,[],a.isVisible,!0,o==="scrollbar",s,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 Wt(r,!0,l);l.children.push(c)}i.children.push(l),t.set(n,l),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((s,l)=>{if(!s.boundingRect)return;let c=a[l%a.length],d=s.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 m=document.createElement("div");m.style.position="fixed",m.style.background=c,m.style.color="white",m.style.padding="1px 4px",m.style.borderRadius="4px",m.style.fontSize=l>=100?"8px":"12px",m.textContent=String(l);let p=Math.max(0,d.y-16),w=Math.max(0,Math.min(d.x+d.width-20,window.innerWidth-25));m.style.top=`${p}px`,m.style.left=`${w}px`,r.appendChild(m)})},{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),f.debug("\u2705 Highlights removed from page")}catch(n){f.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(s=>s.map(l=>l.src)),i=s=>{try{let l=new URL(s);return["doubleclick.net","adroll.com","googletagmanager.com"].some(c=>l.hostname.includes(c))}catch{return!1}},n=e.url(),a=new URL(n).hostname,o=e.frames(),r=[];for(let s of o){let l=s.url();try{let c=new URL(l).hostname;c&&c!==a&&!t.includes(l)&&!i(l)&&r.push(l)}catch{continue}}return r}async buildDomTree(e,t,i,n,a,o,r,s,l="all"){if(await e.evaluate("1+1")!==2)throw new Error("The page cannot evaluate javascript code properly");if(rd(e.url()))return[new $e("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:s,actionIntent:l,domTreeRoot:this.domTreeRoot};f.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},h=await e.evaluate(({code:N,argsObj:D})=>new Function("return "+N)()(D),{code:this.jsCode,argsObj:y});f.debug(`\u{1F4E6} Phase 1: Drew ${h.elementData?.length||0} bounding boxes`);let b=await e.screenshot({type:"png",fullPage:!1});f.debug("\u{1F4F8} Captured screenshot with bounding boxes");let v=performance.now(),S=await nr(b);u=S.pixels;let E=Math.round(performance.now()-v);f.debug(`\u{1F5BC}\uFE0F Generated grayscale image (${S.width}x${S.height}) in ${E}ms`);let $={...c,phase:"labels",grayscaleImage:u,elementData:h.elementData};d=await e.evaluate(({code:N,argsObj:D})=>new Function("return "+N)()(D),{code:this.jsCode,argsObj:$}),d.map=h.map,d.rootId=h.rootId,d.highlightCount=h.highlightCount,d.perfMetrics=h.perfMetrics,f.debug("\u2705 Phase 2: Labels placed using grayscale-based positioning")}catch(y){f.warn("Two-phase rendering failed, falling back to legacy mode:",y.message),u=null;let h={...c,grayscaleImage:null};d=await e.evaluate(({code:b,argsObj:v})=>new Function("return "+b)()(v),{code:this.jsCode,argsObj:h}),f.debug("\u2705 JavaScript DOM analysis completed (legacy mode)")}else try{d=await e.evaluate(({code:y,argsObj:h})=>new Function("return "+y)()(h),{code:this.jsCode,argsObj:c}),f.debug("\u2705 JavaScript DOM analysis completed")}catch(y){throw f.error("Error evaluating JavaScript:",y.message),y}if(!d||typeof d!="object")throw f.error("JavaScript returned invalid result:",d),new Error("JavaScript DOM analysis returned invalid result");if(!d.map||!d.rootId)throw f.error("JavaScript result missing map or rootId:",JSON.stringify(d,null,2)),new Error("JavaScript result missing required fields (map or rootId)");if(l!=="all"&&d.highlightCount===0){f.debug(`\u26A0\uFE0F No elements matched intent '${l}', falling back to 'all'`);let y={...c,actionIntent:"all"};d=await e.evaluate(({code:h,argsObj:b})=>new Function("return "+h)()(b),{code:this.jsCode,argsObj:y})}let m=Object.entries(d.map).filter(([,y])=>y.tagName==="iframe");f.debug(`\u{1F50D} [ext-iframe] Total iframe nodes in map: ${m.length}`);for(let[y,h]of m){let b=h;f.debug(`\u{1F50D} [ext-iframe] iframe node id=${y} src=${b.attributes?.src} inaccessibleFrame=${b.inaccessibleFrame}`)}let p=e.frames();f.debug(`\u{1F50D} [ext-iframe] Playwright frames count: ${p.length}`);for(let y of p)f.debug(`\u{1F50D} [ext-iframe] Playwright frame url=${y.url()}`);let w=[];for(let[y,h]of Object.entries(d.map)){let b=h;this.shouldProcessWithPlaywrightFrameFallback(b,o)&&w.push({nodeId:y,src:b.attributes.src})}if(f.debug(`\u{1F50D} [ext-iframe] Inaccessible fallback iframes found: ${w.length}`),w.length>0){f.debug(`\u{1F50C} Found ${w.length} inaccessible iframe(s) for Playwright fallback, processing`);let y=-1;for(let h of Object.values(d.map)){let b=h;b.highlightIndex!=null&&(y=Math.max(y,b.highlightIndex))}f.debug(`\u{1F50D} [ext-iframe] Main page max highlight index: ${y}`);for(let h=0;h<w.length;h++){let{nodeId:b,src:v}=w[h];f.debug(`\u{1F50D} [ext-iframe] Processing fallback iframe [${h}]: ${v}`);let S=D=>{try{let I=new URL(D);if(I.protocol==="chrome-extension:"&&I.hostname)return`chrome-extension://${I.hostname}`;let W=I.origin;return W==="null"?null:W}catch{return null}},E=S(v);f.debug(`\u{1F50D} [ext-iframe] iframe src origin=${E??"null"}`);let $=null,N=e.frames().find(D=>{let I=D.url();if(I===v)return $="exact",f.debug(`\u{1F50D} [ext-iframe] Candidate frame matched by exact URL: ${I}`),!0;let W=S(I);return f.debug(`\u{1F50D} [ext-iframe] Candidate frame compare url=${I} origin=${W??"null"} vs srcOrigin=${E??"null"}`),E&&W===E?($="origin",f.debug(`\u{1F50D} [ext-iframe] Candidate frame matched by origin: ${I}`),!0):!1});if(!N){f.debug(`\u26A0\uFE0F [ext-iframe] No Playwright frame found for fallback iframe: ${v}`),f.debug(`\u26A0\uFE0F [ext-iframe] Available frame URLs: ${e.frames().map(D=>D.url()).join(", ")}`);continue}f.debug(`\u{1F50D} [ext-iframe] Found matching Playwright frame for: ${v} (frame url: ${N.url()})`);try{let D={...c,initialHighlightIndex:y+1,domTreeRoot:"body"};f.debug(`\u{1F50D} [ext-iframe] Running dom-tree in extension frame with initialHighlightIndex=${D.initialHighlightIndex}`);let I=await N.evaluate(({code:B,argsObj:Y})=>new Function("return "+B)()(Y),{code:this.jsCode,argsObj:D});if(f.debug(`\u{1F50D} [ext-iframe] frameEval result: map size=${Object.keys(I?.map??{}).length} rootId=${I?.rootId}`),!I?.map||!I.rootId){f.debug("\u26A0\uFE0F [ext-iframe] frameEval missing map or rootId, skipping");continue}let W=Object.values(I.map).filter(B=>B.highlightIndex!=null);f.debug(`\u{1F50D} [ext-iframe] Interactive elements in extension frame: ${W.length}`);for(let B of W){let Y=B;f.debug(`\u{1F50D} [ext-iframe] - <${Y.tagName}> highlightIndex=${Y.highlightIndex} text="${Y.children?.length?"...":""}"`)}for(let B of Object.values(I.map)){let Y=B;Y.highlightIndex!=null&&(y=Math.max(y,Y.highlightIndex))}let z=`ext_${h}_`;for(let[B,Y]of Object.entries(I.map)){let ge={...Y};ge.children&&(ge.children=ge.children.map(Ye=>`${z}${Ye}`)),d.map[`${z}${B}`]=ge}let ee=d.map[b];ee?(ee.children=[...ee.children||[],`${z}${I.rootId}`],f.debug(`\u{1F50D} [ext-iframe] Attached frame root to iframe node ${b}`)):f.debug(`\u26A0\uFE0F [ext-iframe] iframe node ${b} not found in map`),f.debug(`\u2705 Merged fallback iframe content from: ${v}`)}catch(D){f.warn(`Failed to process fallback iframe ${v}:`,D)}}}if(d&&d.perfMetrics){let y=d.perfMetrics.nodeMetrics?.totalNodes??0,h=0;if(d.map)for(let v of Object.values(d.map))typeof v=="object"&&v!==null&&v.isInteractive&&h++;let b=e.url().length>50?e.url().slice(0,50)+"...":e.url();f.debug(`\u{1F50E} Ran buildDOMTree.js interactive element detection on: ${b} interactive=${h}/${y}`)}f.debug("\u{1F504} Starting TypeScript DOM tree construction...");let g=await this.constructDomTree(d);return f.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[s,l]of Object.entries(t)){let[c,d]=this.parseNode(l);c!==null&&(a.set(s,c),o.set(s,d),c instanceof $e&&c.highlightIndex!==null&&n.set(c.highlightIndex,c))}for(let[s,l]of o){let c=a.get(s);if(c instanceof $e)for(let d of l){let u=a.get(d);u&&(u.parent=c,c.children.push(u))}}let r=a.get(i);if(!r||!(r instanceof $e))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 Wt(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 $e(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 lr,cr,Ap,en=x(()=>{"use strict";lr=require("zod"),cr=class{async execute(e,t){await e.waitForLoadState("networkidle",{timeout:5e3}).catch(()=>{}),await e.waitForLoadState("domcontentloaded")}transpile(e){return["await page.waitForLoadState('domcontentloaded');"]}},Ap=lr.z.object({})});var dr,tn=x(()=>{"use strict";K();C();dr=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=F(e,t);if(a){await a.waitFor({state:"attached",timeout:R(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,s=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.move(r,s),await e.waitForTimeout(200),await e.mouse.click(r,s,{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 ur,nn=x(()=>{"use strict";K();C();ur=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=F(e,t),r=R(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=Le(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=R();return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${n} });`]}}});var hr,an=x(()=>{"use strict";hr=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
|
|
4090
|
+
`):["// Skipping js_action: missing code"]}}});var sd,mr,He,dt=x(()=>{"use strict";Se();sd=te(require("playwright/test"),1),mr=te(require("playwright/test"),1),He={};Di(He,{default:()=>mr.default});xo(He,sd)});var xa,pr,jp,on=x(()=>{"use strict";dt();xa=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.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,He.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}},jp=xa.z.object({code:xa.z.string().describe("JavaScript code to execute in the browser context")})});var gr,rn=x(()=>{"use strict";K();C();gr=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=F(e,t);if(a){await a.waitFor({state:"attached",timeout:R(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,s=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.dblclick(r,s,{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 fr,sn=x(()=>{"use strict";K();C();fr=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],s=[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 l=F(e,t);if(!l)throw new Error("No locator found for drag_drop action with element-anchored coordinates");await l.waitFor({state:"attached",timeout:R(i,t.action_data?.kwargs?.timeout_ms)});let c=await(await l).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,m=d+o.delta_x,p=u+o.delta_y;await e.mouse.move(d,u),await e.mouse.down(),n>0?await e.mouse.move(m,p,{steps:n}):await e.mouse.move(m,p),await e.mouse.up()}else if(r.every(l=>typeof l=="number")&&s.every(l=>typeof l=="number")){let[l,c]=r,[d,u]=s;await e.mouse.move(l,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 wr,ln=x(()=>{"use strict";wr=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((s,l)=>l<r.length?String(r[l]):"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 cn=x(()=>{"use strict";ct()});var wr,jt=x(()=>{"use strict";wr=(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))(wr||{})});var ut={};Qe(ut,{evaluateStatement:()=>hn,executeAction:()=>Bt,executeStep:()=>un,generateActionStep:()=>dn,runTask:()=>mn});var ht=x(()=>{"use strict";Gt();Zi();Yi();rt();ji();Gi();Bi();et();zi();Re();Xi();Nt();Ot();Ae();Pt();cn();Ke();Rt();ct();Ft();Ht();Ut();re();st();xe();$t();it();Mt();De();tt();Q();je();z();ae();jt();G();Se()});var va,yr,Dg,pn=x(()=>{"use strict";va=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.statement;if(!a)throw new Error("Missing statement for ai_step");let{runTask:o}=await Promise.resolve().then(()=>(ht(),ut)),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"]}},Dg=va.z.object({statement:va.z.string().describe('The complete step to execute (e.g., "fill in the login form and submit")')})});var br,gn=x(()=>{"use strict";G();C();br=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=F(e,t);if(a){await a.waitFor({state:"attached",timeout:R(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,s=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.move(r,s),await e.waitForTimeout(200),await e.mouse.click(r,s),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 _a,xr,jg,fn=x(()=>{"use strict";_a=require("zod"),xr=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(()=>(ht(),ut)),s=await r(a,e,i,{usePureVision:o});if(s.status!=="success")throw new Error(s.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});`]}},jg=_a.z.object({statement:_a.z.string().describe('The action to perform (e.g., "click the submit button")')})});function _r(e,t){e.register({name:"switch_tab",description:"Switch to a different browser tab by index (0-based).",schema:rd,async execute(i,n){let a=i.tab_index,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Switch to tab ${a}`,action_data:{action_name:"switch_tab",kwargs:{page_id:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Switched to tab ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Switch to tab ${a}`)+" (failed)",action_data:{action_name:"switch_tab",kwargs:{page_id:a}},feedback:l.message}}}}})}var ka,vr,rd,Kt=x(()=>{"use strict";ka=require("zod"),vr=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 s=await i.switchTab(r);await s.waitForLoadState("load",{timeout:15e3}).catch(()=>{}),await s.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} } },`,"});"]}},rd=ka.z.object({tab_index:ka.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 Sr(e,t,i,n){let{useFileInput:a,timeout:o,mockShowOpenFilePicker:r}=n;if(r){f.info("Using mockShowOpenFilePicker approach");let s=i.map(l=>({path:l,buffer:new Uint8Array(kr.default.readFileSync(l))}));await e.evaluate(l=>{window.__pw_showOpenFilePicker_mock_files=l},s),await t.click({timeout:o}),await e.waitForTimeout(3e3),await e.evaluate(()=>{delete window.__pw_showOpenFilePicker_mock_files})}else if(a)f.info("Using direct file input approach"),await t.setInputFiles(i,{timeout:o}),await e.waitForTimeout(3e3);else{f.info("Using file chooser approach");let s=e.waitForEvent("filechooser",{timeout:o});s.catch(()=>{}),await t.click({timeout:o}),await(await s).setFiles(i),await e.waitForTimeout(3e3)}f.info(`Successfully uploaded ${i.length} file(s)`)}var kr,zt=x(()=>{"use strict";z();kr=te(require("fs"),1)});async function sd(e,t,i={},n){return{...await j(t,e),action_description:n||"Upload file to element",action_data:{action_name:"upload_file",kwargs:{...i}}}}function Er(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 Ar(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:ld,usesElementIndex:!0,async execute(i,n){let{element_index:a,paths:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=await J(n,a);if(!c)return{success:!1,error:`File input element with index ${a} not found`,actionEntity:Er(l||`Upload file to element ${a}`,{index:a,paths:o})};let d=await sd(c,r,{paths:o},l);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Uploaded file to element ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:Er(l||`Upload file to element ${a}`,{index:a,paths:o})}}}})}var ie,Tr,ld,Zg,Vt=x(()=>{"use strict";zt();Q();G();ie=require("zod");C();Tr=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=F(e,t);if(!r)throw new Error("Missing locator for upload_file action");let s=n.kwargs.use_file_input||!1,l=i.getActionSettings().mock_show_open_file_picker??!1;await Sr(e,r,o,{useFileInput:s,timeout:R(i,t.action_data?.kwargs?.timeout_ms),mockShowOpenFilePicker:l})}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},`),"});"]}};ld=ie.z.object({element_index:ie.z.number().int().describe("Index of the target element to trigger the file upload dialog"),paths:ie.z.union([ie.z.string(),ie.z.array(ie.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:ie.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")});Zg=ie.z.object({element_index:ie.z.number().int().describe("Index of the file input element"),paths:ie.z.union([ie.z.string(),ie.z.array(ie.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:ie.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:cd,async execute(i,n){let{seconds:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Wait ${a} seconds`,action_data:{action_name:"wait",kwargs:{seconds:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Waited ${a} seconds`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Wait ${a} seconds`)+" (failed)",action_data:{action_name:"wait",kwargs:{seconds:a}},feedback:l.message}}}}})}var Sa,$r,cd,Xt=x(()=>{"use strict";Sa=require("zod"),$r=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});`]}},cd=Sa.z.object({seconds:Sa.z.number().positive().describe("Number of seconds to wait")})});function Cr(e,t){e.register({name:"wait_for_download_complete",description:"Wait for an in-progress download to complete.",schema:dd,async execute(i,n){let{timeout_seconds:a=10}=i,{page:o,agentServices:r}=n;try{let s={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,s,r),{success:!0,actionEntity:s,message:"Download completed"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Wait for download to complete (failed)",action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:a}},feedback:s.message}}}}})}var Ea,Ir,dd,Jt=x(()=>{"use strict";Ea=require("zod"),Ir=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} } },`,"});"]}},dd=Ea.z.object({timeout_seconds:Ea.z.number().positive().optional().describe("Maximum time in seconds to wait for download to complete (default: 10)")})});var _,hf,xf,kf,Ef,yn,Or,lf,Nr,ud,hd,wn,cf,df,Ta,Aa,md,Pr,pd,Yt,gd,fd,wd,ue,yd,bd,uf,_f,$f,We=x(()=>{"use strict";Se();_=require("zod"),hf=require("yaml"),xf=require("uuid"),kf=require("uuid"),Ef=require("yaml"),yn=(e=>(e.JS_CODE="JS_CODE",e.AI_MODE="AI_MODE",e))(yn||{}),Or=112,lf=1080-Or,Nr=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(Nr||{}),ud={"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"}},hd={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"]},wn=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),hd[e].map(n=>ud[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},cf={desktop:{label:"Desktop",type:"desktop",devices:wn("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:wn("mobile")}},df={desktop:{label:"Desktop",type:"desktop",devices:wn("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:wn("mobile",!0)}},Ta=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(Ta||{}),Aa=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(Aa||{}),md=_.z.enum(["JS_CODE","AI_MODE"]),Pr=_.z.object({type:md,expression:_.z.string()}),pd=_.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),Yt=_.z.object({uid:_.z.string(),type:pd,comment:_.z.string().optional()}),gd=_.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(),fd=Yt.extend({type:_.z.literal("DRAFT"),description:_.z.string()}),wd=Yt.extend({type:_.z.literal("ACTION"),description:_.z.string(),action_entity:gd.optional(),locator:_.z.string().optional(),use_pure_vision:_.z.boolean().optional()}),ue=_.z.lazy(()=>_.z.union([fd,wd,Yt.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()}),Yt.extend({type:_.z.literal("IF_ELSE"),description:_.z.string().optional(),condition:Pr,then:_.z.array(ue),else:_.z.array(ue).optional()}),Yt.extend({type:_.z.literal("WHILE_LOOP"),description:_.z.string().optional(),condition:Pr,body:_.z.array(ue),timeout_ms:_.z.number().optional()})])),yd=_.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()}),bd=_.z.object({tests:_.z.array(yd).min(1),beforeAll:_.z.array(ue).optional(),afterAll:_.z.array(ue).optional(),beforeEach:_.z.array(ue).optional(),afterEach:_.z.array(ue).optional()}),uf=_.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:bd.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"}),_f=1024*1024,$f=Object.freeze(["anthropic:claude-sonnet-5","google:gemini-3.1-pro-preview"])});var mt=x(()=>{"use strict"});async function Sd(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"],s=u=>{let p=u.toLowerCase();return p.startsWith("data:")||p.startsWith("blob:")?!0:r.some(m=>p.includes(m))},l=u=>{let p=u.resourceType(),m=u.url();if(!a.has(p)||s(m))return;let y=u.headers();y.purpose==="prefetch"||["video","audio"].includes(y["sec-fetch-dest"])||(i.add(u),n=Date.now())},c=async u=>{let p=u.request();if(!i.has(p))return;let m=(u.headers()["content-type"]||"").toLowerCase();if(["streaming","video","audio","webm","mp4","event-stream","websocket","protobuf"].some(g=>m.includes(g))){i.delete(p);return}if(![...o].some(g=>m.startsWith(g))){i.delete(p);return}let y=u.headers()["content-length"];if(y)try{if(parseInt(y,10)>5*1024*1024){i.delete(p);return}}catch{}i.delete(p),n=Date.now()},d=Date.now()-kd;for(let u of await e.requests()){let p=u.resourceType(),m=u.url(),y=u.timing();a.has(p)&&!s(m)&&y.responseEnd===-1&&y.startTime>=d&&(i.add(u),n=Date.now())}f.debug(`[waitForStableNetwork] Pre-populated ${i.size} in-flight requests`),e.on("request",l),e.on("response",c);try{let u=Date.now(),p=_d;for(;;){await new Promise(y=>setTimeout(y,100));let m=Date.now();if(i.size===0&&m-n>=p){f.debug(`[waitForStableNetwork] Network idle after ${m-u}ms`);break}if(m-u>t){f.debug(`[waitForStableNetwork] Max wait time exceeded (${t}ms), pending: ${i.size}`);break}}}finally{e.removeListener("request",l),e.removeListener("response",c)}}async function pt(e,t=vd,i=xd){let n=Date.now();try{await Promise.all([e.waitForLoadState("load",{timeout:t}).catch(()=>{}),Sd(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 xd,vd,_d,kd,Me=x(()=>{"use strict";mt();z();xd=.5*1e3,vd=30*1e3,_d=1*1e3,kd=3*1e3});async function $a(e,t,i=60){let n=Math.min(i,300),a=250,o=Date.now()+n*1e3;f.info(`Waiting for JS condition (timeout: ${n}s)`);let r;for(;;){try{if(await t())return f.info("JS wait condition met"),!0}catch(s){let l=s.message;l!==r&&(f.warn(`Error evaluating JS wait condition: ${l}`),r=l)}if(Date.now()>o)return f.warn("Timeout waiting for JS condition"),!1;await e.waitForTimeout(a)}}var gt=x(()=>{"use strict";Me();z()});function Rr(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:Ed,async execute(i,n){let{condition:a,timeout_seconds:o=60}=i,{page:r,agentServices:s}=n;try{let l={action_description:`Wait until: ${a}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:a,timeout_seconds:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Condition met: ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Wait until: ${a} (failed)`,action_data:{action_name:"ai_wait_until",kwargs:{condition:a,timeout_seconds:o}},feedback:l.message}}}}})}var bn,Dr,Ed,qt=x(()=>{"use strict";dt();We();gt();bn=require("zod"),Dr=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;if(n.kwargs.condition_type===yn.JS_CODE){let d=new Function("page","expect","agent",`
|
|
4100
|
-
return (async () => (${
|
|
4101
|
-
`);if(!await $a(e,()=>d(e,He.expect,i.agent),o))throw new Error(`Timeout waiting for condition: ${a}`);return}let r=o*1e3,s=5e3,l=Date.now(),{evaluateStatement:c}=await Promise.resolve().then(()=>(ht(),ut));for(;Date.now()-l<r;){if((await c(a,e,i,{})).success)return;await e.waitForTimeout(s)}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?e.action_data?.kwargs?.condition_type===yn.JS_CODE?[`await agent.waitForJs(page, async () => (${i}), ${n}, '${t}');`]:[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${n}, '${t}');`]:["// Skipping ai_wait_until: missing condition"]}},Ed=bn.z.object({condition:bn.z.string().describe('The condition to wait for (e.g., "the loading spinner disappears")'),timeout_seconds:bn.z.number().positive().optional().describe("Timeout in seconds (default: 60)")})});function Hr(e,t){e.register({name:"save_variable",description:"Save a value to a named variable for later use in the test.",schema:Td,async execute(i,n){let{name:a,value:o}=i,{page:r,agentServices:s}=n;try{let l={action_description:`Save variable "${a}" = "${o}"`,action_data:{action_name:"save_variable",kwargs:{name:a,value:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Saved variable "${a}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Save variable "${a}" (failed)`,action_data:{action_name:"save_variable",kwargs:{name:a,value:o}},feedback:l.message}}}}})}var xn,Fr,Td,Zt=x(()=>{"use strict";xn=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.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)} } },`,"});"]}},Td=xn.z.object({name:xn.z.string().describe("Variable name to save"),value:xn.z.string().describe("Value to save in the variable")})});async function Ad(e,t,i={}){return{action_description:t,action_data:{action_name:e,kwargs:{...i}}}}function $d(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Scroll failed!"}}function Wr(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:Md,async execute(i,n){let{down:a,num_pages:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=l||`Scroll ${a?"down":"up"} ${o} page(s)`,d=await Ad("scroll",c,{down:a,num_pages:o});return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Scrolled ${a?"down":"up"} ${o} page(s)`}}catch(c){return{success:!1,error:c.message,actionEntity:$d(l||`Scroll ${a?"down":"up"} ${o} page(s)`,"scroll",{down:a,num_pages:o})}}}})}var vn,Qt,Md,ei=x(()=>{"use strict";vn=require("zod"),Qt=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)})');`]}};Md=vn.z.object({down:vn.z.boolean().describe("True to scroll down, False to scroll up"),num_pages:vn.z.number().nonnegative().describe("Number of pages to scroll (0.5 = half page, 1.0 = one page, etc.)")})});async function Id(e,t,i,n,a={}){return{...await j(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function Ur(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function Br(e,t){e.register({name:"scroll_on_element",description:"Scroll on a scrollable element horizontally and vertically.",schema:Cd,usesElementIndex:!0,async execute(i,n){let{element_index:a,delta_x:o,delta_y:r}=i,{page:s,agentServices:l}=n;try{let c=await J(n,a);if(!c)return{success:!1,error:`Element with index ${a} not found`,actionEntity:Ur(`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:a,delta_x:o,delta_y:r})};let d=await Id("scroll_on_element",`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,c,s,{delta_x:o,delta_y:r});return await t.execute(s,d,l),{success:!0,actionEntity:d,message:`Scrolled on element ${a} horizontally: ${o}px, vertically: ${r}px`}}catch(c){return{success:!1,error:c.message,actionEntity:Ur(`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:a,delta_x:o,delta_y:r})}}}})}var ft,jr,Cd,ti=x(()=>{"use strict";Q();G();ft=require("zod");C();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.delta_x||0,o=n.kwargs.delta_y||0,r=F(e,t),s=R(i,t.action_data?.kwargs?.timeout_ms);if(r)await r.hover({timeout:s}),await e.mouse.wheel(a,o);else throw new Error("No locator found for scroll_on_element action")}transpile(e){let t=Le(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: ${R()} });`,`await page.mouse.wheel(${i}, ${n});`]}};Cd=ft.z.object({element_index:ft.z.number().int().describe("Index of the scrollable element"),delta_x:ft.z.number().optional().describe("The number of pixels to scroll horizontally. Positive values scroll right, negative values scroll left."),delta_y:ft.z.number().optional().describe("The number of pixels to scroll vertically. Positive values scroll down, negative values scroll up."),timeout_ms:ft.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Kr(e,t){e.register({name:"scroll_to_text",description:"Scroll the page until specified text becomes visible.",schema:Pd,async execute(i,n){let{text:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Scroll to text "${a}"`,action_data:{action_name:"scroll_to_text",kwargs:{text:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Scrolled to text "${a}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Scroll to text "${a}"`)+" (failed)",action_data:{action_name:"scroll_to_text",kwargs:{text:a}},feedback:l.message}}}}})}var Ma,Gr,Pd,ii=x(()=>{"use strict";Ma=require("zod"),Gr=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();`]}},Pd=Ma.z.object({text:Ma.z.string().describe("Text to scroll to on the page")})});async function Od(e,t,i,n){return{...await j(t,e),action_description:n||`Select option "${i}"`,action_data:{action_name:"select_dropdown_option",kwargs:{text:i}}}}function zr(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 Xr(e,t){e.register({name:"select_dropdown_option",description:"Select an option from a dropdown/select element by value, label, or index.",schema:Nd,usesElementIndex:!0,async execute(i,n){let{element_index:a,option:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=await J(n,a);if(!c)return{success:!1,error:`Dropdown element with index ${a} not found`,actionEntity:zr(l||`Select option in dropdown ${a}`,{index:a,option:o})};let d=await Od(c,r,o,l);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Selected option "${o}" in dropdown ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:zr(`Select option in dropdown ${a}`,{index:a,option:o})}}}})}var ni,Vr,Nd,ai=x(()=>{"use strict";Q();G();ni=require("zod");C();Vr=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=F(e,t),r=R(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},`),"});"]}};Nd=ni.z.object({element_index:ni.z.number().int().describe("Index of the dropdown/select element"),option:ni.z.string().describe("Option value, label, or index to select"),timeout_ms:ni.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function Ld(e,t,i,n){return{...await j(i,t),action_description:e,action_data:{action_name:"set_date_for_native_date_picker",kwargs:{date:n}}}}function Ia(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 Yr(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((s,l)=>l<r.length?String(r[l]):"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 cn=x(()=>{"use strict";ct()});var yr,Ut=x(()=>{"use strict";yr=(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))(yr||{})});var ut={};Qe(ut,{evaluateStatement:()=>hn,executeAction:()=>Bt,executeStep:()=>un,generateActionStep:()=>dn,runTask:()=>mn});var ht=x(()=>{"use strict";Gt();Zi();Yi();rt();Ui();Gi();Bi();et();zi();Re();Xi();Ot();Nt();Ae();Pt();cn();Ke();Rt();ct();Ft();Ht();jt();re();st();xe();$t();it();Mt();De();tt();Q();Ue();G();ae();Ut();K();Se()});var va,br,Fg,pn=x(()=>{"use strict";va=require("zod"),br=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(()=>(ht(),ut)),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"]}},Fg=va.z.object({statement:va.z.string().describe('The complete step to execute (e.g., "fill in the login form and submit")')})});var xr,gn=x(()=>{"use strict";K();C();xr=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=F(e,t);if(a){await a.waitFor({state:"attached",timeout:R(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,s=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.move(r,s),await e.waitForTimeout(200),await e.mouse.click(r,s),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 _a,vr,Gg,fn=x(()=>{"use strict";_a=require("zod"),vr=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(()=>(ht(),ut)),s=await r(a,e,i,{usePureVision:o});if(s.status!=="success")throw new Error(s.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});`]}},Gg=_a.z.object({statement:_a.z.string().describe('The action to perform (e.g., "click the submit button")')})});function kr(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:s}=n;try{let l={action_description:s||`Switch to tab ${a}`,action_data:{action_name:"switch_tab",kwargs:{page_id:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Switched to tab ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Switch to tab ${a}`)+" (failed)",action_data:{action_name:"switch_tab",kwargs:{page_id:a}},feedback:l.message}}}}})}var ka,_r,ld,Kt=x(()=>{"use strict";ka=require("zod"),_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.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 s=await i.switchTab(r);await s.waitForLoadState("load",{timeout:15e3}).catch(()=>{}),await s.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=ka.z.object({tab_index:ka.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 Er(e,t,i,n){let{useFileInput:a,timeout:o,mockShowOpenFilePicker:r}=n;if(r){f.info("Using mockShowOpenFilePicker approach");let s=i.map(l=>({path:l,buffer:new Uint8Array(Sr.default.readFileSync(l))}));await e.evaluate(l=>{window.__pw_showOpenFilePicker_mock_files=l},s),await t.click({timeout:o}),await e.waitForTimeout(3e3),await e.evaluate(()=>{delete window.__pw_showOpenFilePicker_mock_files})}else if(a)f.info("Using direct file input approach"),await t.setInputFiles(i,{timeout:o}),await e.waitForTimeout(3e3);else{f.info("Using file chooser approach");let s=e.waitForEvent("filechooser",{timeout:o});s.catch(()=>{}),await t.click({timeout:o}),await(await s).setFiles(i),await e.waitForTimeout(3e3)}f.info(`Successfully uploaded ${i.length} file(s)`)}var Sr,zt=x(()=>{"use strict";G();Sr=te(require("fs"),1)});async function cd(e,t,i={},n){return{...await U(t,e),action_description:n||"Upload file to element",action_data:{action_name:"upload_file",kwargs:{...i}}}}function Tr(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 $r(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:dd,usesElementIndex:!0,async execute(i,n){let{element_index:a,paths:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=await J(n,a);if(!c)return{success:!1,error:`File input element with index ${a} not found`,actionEntity:Tr(l||`Upload file to element ${a}`,{index:a,paths:o})};let d=await cd(c,r,{paths:o},l);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Uploaded file to element ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:Tr(l||`Upload file to element ${a}`,{index:a,paths:o})}}}})}var ie,Ar,dd,ef,Vt=x(()=>{"use strict";zt();Q();K();ie=require("zod");C();Ar=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=F(e,t);if(!r)throw new Error("Missing locator for upload_file action");let s=n.kwargs.use_file_input||!1,l=i.getActionSettings().mock_show_open_file_picker??!1;await Er(e,r,o,{useFileInput:s,timeout:R(i,t.action_data?.kwargs?.timeout_ms),mockShowOpenFilePicker:l})}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},`),"});"]}};dd=ie.z.object({element_index:ie.z.number().int().describe("Index of the target element to trigger the file upload dialog"),paths:ie.z.union([ie.z.string(),ie.z.array(ie.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:ie.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")});ef=ie.z.object({element_index:ie.z.number().int().describe("Index of the file input element"),paths:ie.z.union([ie.z.string(),ie.z.array(ie.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:ie.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Ir(e,t){e.register({name:"wait",description:"Wait for a specified number of seconds before continuing.",schema:ud,async execute(i,n){let{seconds:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Wait ${a} seconds`,action_data:{action_name:"wait",kwargs:{seconds:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Waited ${a} seconds`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Wait ${a} seconds`)+" (failed)",action_data:{action_name:"wait",kwargs:{seconds:a}},feedback:l.message}}}}})}var Sa,Mr,ud,Xt=x(()=>{"use strict";Sa=require("zod"),Mr=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});`]}},ud=Sa.z.object({seconds:Sa.z.number().positive().describe("Number of seconds to wait")})});function Pr(e,t){e.register({name:"wait_for_download_complete",description:"Wait for an in-progress download to complete.",schema:hd,async execute(i,n){let{timeout_seconds:a=10}=i,{page:o,agentServices:r}=n;try{let s={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,s,r),{success:!0,actionEntity:s,message:"Download completed"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Wait for download to complete (failed)",action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:a}},feedback:s.message}}}}})}var Ea,Cr,hd,Jt=x(()=>{"use strict";Ea=require("zod"),Cr=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} } },`,"});"]}},hd=Ea.z.object({timeout_seconds:Ea.z.number().positive().optional().describe("Maximum time in seconds to wait for download to complete (default: 10)")})});var _,pf,_f,Ef,Af,yn,Or,df,Lr,md,pd,wn,uf,hf,Ta,Aa,gd,Nr,fd,Yt,wd,yd,bd,he,xd,vd,mf,Sf,If,We=x(()=>{"use strict";Se();_=require("zod"),pf=require("yaml"),_f=require("uuid"),Ef=require("uuid"),Af=require("yaml"),yn=(e=>(e.JS_CODE="JS_CODE",e.AI_MODE="AI_MODE",e))(yn||{}),Or=112,df=1080-Or,Lr=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(Lr||{}),md={"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"}},pd={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"]},wn=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),pd[e].map(n=>md[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},uf={desktop:{label:"Desktop",type:"desktop",devices:wn("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:wn("mobile")}},hf={desktop:{label:"Desktop",type:"desktop",devices:wn("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:wn("mobile",!0)}},Ta=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(Ta||{}),Aa=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(Aa||{}),gd=_.z.enum(["JS_CODE","AI_MODE"]),Nr=_.z.object({type:gd,expression:_.z.string()}),fd=_.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),Yt=_.z.object({uid:_.z.string(),type:fd,comment:_.z.string().optional()}),wd=_.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(),yd=Yt.extend({type:_.z.literal("DRAFT"),description:_.z.string()}),bd=Yt.extend({type:_.z.literal("ACTION"),description:_.z.string(),action_entity:wd.optional(),locator:_.z.string().optional(),use_pure_vision:_.z.boolean().optional()}),he=_.z.lazy(()=>_.z.union([yd,bd,Yt.extend({type:_.z.literal("STEP"),description:_.z.string().optional().default(""),statements:_.z.array(he),reference_id:_.z.number().optional(),template_path:_.z.string().optional(),template_params:_.z.record(_.z.string()).optional()}),Yt.extend({type:_.z.literal("IF_ELSE"),description:_.z.string().optional(),condition:Nr,then:_.z.array(he),else:_.z.array(he).optional()}),Yt.extend({type:_.z.literal("WHILE_LOOP"),description:_.z.string().optional(),condition:Nr,body:_.z.array(he),timeout_ms:_.z.number().optional()})])),xd=_.z.object({name:_.z.string(),statements:_.z.array(he),teardown:_.z.array(he).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()}),vd=_.z.object({tests:_.z.array(xd).min(1),beforeAll:_.z.array(he).optional(),afterAll:_.z.array(he).optional(),beforeEach:_.z.array(he).optional(),afterEach:_.z.array(he).optional()}),mf=_.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(he).optional(),teardown:_.z.array(he).optional(),last_modified_at:_.z.string().optional(),testGroup:vd.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"}),Sf=1024*1024,If=Object.freeze(["anthropic:claude-sonnet-5","google:gemini-3.1-pro-preview"])});var mt=x(()=>{"use strict"});async function Td(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"],s=u=>{let m=u.toLowerCase();return m.startsWith("data:")||m.startsWith("blob:")?!0:r.some(p=>m.includes(p))},l=u=>{let m=u.resourceType(),p=u.url();if(!a.has(m)||s(p))return;let w=u.headers();w.purpose==="prefetch"||["video","audio"].includes(w["sec-fetch-dest"])||(i.add(u),n=Date.now())},c=async u=>{let m=u.request();if(!i.has(m))return;let p=(u.headers()["content-type"]||"").toLowerCase();if(["streaming","video","audio","webm","mp4","event-stream","websocket","protobuf"].some(g=>p.includes(g))){i.delete(m);return}if(![...o].some(g=>p.startsWith(g))){i.delete(m);return}let w=u.headers()["content-length"];if(w)try{if(parseInt(w,10)>5*1024*1024){i.delete(m);return}}catch{}i.delete(m),n=Date.now()},d=Date.now()-Ed;for(let u of await e.requests()){let m=u.resourceType(),p=u.url(),w=u.timing();a.has(m)&&!s(p)&&w.responseEnd===-1&&w.startTime>=d&&(i.add(u),n=Date.now())}f.debug(`[waitForStableNetwork] Pre-populated ${i.size} in-flight requests`),e.on("request",l),e.on("response",c);try{let u=Date.now(),m=Sd;for(;;){await new Promise(w=>setTimeout(w,100));let p=Date.now();if(i.size===0&&p-n>=m){f.debug(`[waitForStableNetwork] Network idle after ${p-u}ms`);break}if(p-u>t){f.debug(`[waitForStableNetwork] Max wait time exceeded (${t}ms), pending: ${i.size}`);break}}}finally{e.removeListener("request",l),e.removeListener("response",c)}}async function pt(e,t=kd,i=_d){let n=Date.now();try{await Promise.all([e.waitForLoadState("load",{timeout:t}).catch(()=>{}),Td(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 _d,kd,Sd,Ed,Me=x(()=>{"use strict";mt();G();_d=.5*1e3,kd=30*1e3,Sd=1*1e3,Ed=3*1e3});async function $a(e,t,i=60){let n=Math.min(i,300),a=250,o=Date.now(),r=o+n*1e3;f.info(`Waiting for JS condition (timeout: ${n}s)`);let s=0,l=0,c,d;for(;;){try{if(s++,await t())return f.info("JS wait condition met"),{met:!0,evalCount:s,errorCount:l,lastError:c,elapsedMs:Date.now()-o}}catch(u){l++;let m=u.message;c=m,m!==d&&(f.warn(`Error evaluating JS wait condition: ${m}`),d=m)}if(Date.now()>r)return f.warn("Timeout waiting for JS condition"),{met:!1,evalCount:s,errorCount:l,lastError:c,elapsedMs:Date.now()-o};await e.waitForTimeout(a)}}function Ma(e){let t=(e.elapsedMs/1e3).toFixed(1);if(e.met){let n=`${e.evalCount} evaluation${e.evalCount===1?"":"s"}`;return`Condition met after ${t}s (${n})`}if(e.evalCount>0&&e.errorCount===e.evalCount)return`Condition never evaluated successfully (${e.evalCount} attempts, all errored) \u2014 the expression is likely invalid: ${e.lastError}. Waited the full ${t}s \u2014 continuing`;let i=e.errorCount>0?`, ${e.errorCount} errored`:"";return`Condition not met within ${t}s (evaluated ${e.evalCount} times${i}) \u2014 continuing`}var gt=x(()=>{"use strict";Me();G()});async function Rr(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,r=Math.min(o,300);if(n.kwargs.condition_type===yn.JS_CODE){let u=typeof n.kwargs.js=="string"?n.kwargs.js:a,m;try{m=new Function("page","expect","agent",`
|
|
4100
|
+
return (async () => (${u}))();
|
|
4101
|
+
`)}catch(w){return await e.waitForTimeout(r*1e3),{met:!1,message:`Condition could not be parsed as JavaScript: ${w.message}. Waited the full ${r}s \u2014 continuing`}}let p=await $a(e,()=>m(e,He.expect,i.agent),r);return{met:p.met,message:Ma(p)}}let s=r*1e3,l=5e3,c=Date.now(),{evaluateStatement:d}=await Promise.resolve().then(()=>(ht(),ut));for(;Date.now()-c<s;){if((await d(a,e,i,{})).success)return{met:!0,message:`Condition met: ${a}`};await e.waitForTimeout(l)}return{met:!1,message:`Condition not met within ${r}s: ${a} \u2014 continuing`}}function Hr(e){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:Ad,async execute(t,i){let{condition:n,timeout_seconds:a=60}=t,{page:o,agentServices:r}=i;try{let s={action_description:`Wait until: ${n}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:n,timeout_seconds:a}}},l=await Rr(o,s,r);return l.met||r.addNote?.(l.message),{success:!0,actionEntity:s,message:l.message}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:`Wait until: ${n} (failed)`,action_data:{action_name:"ai_wait_until",kwargs:{condition:n,timeout_seconds:a}},feedback:s.message}}}}})}var bn,Fr,Ad,qt=x(()=>{"use strict";dt();We();gt();G();bn=require("zod");Fr=class{async execute(e,t,i){let n=await Rr(e,t,i);n.met||(f.warn(n.message),i.addNote?.(n.message))}transpile(e,t){let i=e.action_data?.kwargs?.condition,n=e.action_data?.kwargs?.timeout_seconds||60;if(!i)return["// Skipping ai_wait_until: missing condition"];if(e.action_data?.kwargs?.condition_type===yn.JS_CODE){let a=e.action_data?.kwargs?.js,o=typeof a=="string"?a:i,r=typeof a=="string"?`, ${JSON.stringify(i)}`:"";return[`await agent.waitForJs(page, async () => (${o}), ${n}, '${t}'${r});`]}return[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${n}, '${t}');`]}},Ad=bn.z.object({condition:bn.z.string().describe('The condition to wait for (e.g., "the loading spinner disappears")'),timeout_seconds:bn.z.number().positive().optional().describe("Timeout in seconds (default: 60)")})});function jr(e,t){e.register({name:"save_variable",description:"Save a value to a named variable for later use in the test.",schema:$d,async execute(i,n){let{name:a,value:o}=i,{page:r,agentServices:s}=n;try{let l={action_description:`Save variable "${a}" = "${o}"`,action_data:{action_name:"save_variable",kwargs:{name:a,value:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Saved variable "${a}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Save variable "${a}" (failed)`,action_data:{action_name:"save_variable",kwargs:{name:a,value:o}},feedback:l.message}}}}})}var xn,Wr,$d,Zt=x(()=>{"use strict";xn=require("zod"),Wr=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)} } },`,"});"]}},$d=xn.z.object({name:xn.z.string().describe("Variable name to save"),value:xn.z.string().describe("Value to save in the variable")})});async function Md(e,t,i={}){return{action_description:t,action_data:{action_name:e,kwargs:{...i}}}}function Id(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Scroll failed!"}}function Ur(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:Cd,async execute(i,n){let{down:a,num_pages:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=l||`Scroll ${a?"down":"up"} ${o} page(s)`,d=await Md("scroll",c,{down:a,num_pages:o});return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Scrolled ${a?"down":"up"} ${o} page(s)`}}catch(c){return{success:!1,error:c.message,actionEntity:Id(l||`Scroll ${a?"down":"up"} ${o} page(s)`,"scroll",{down:a,num_pages:o})}}}})}var vn,Qt,Cd,ei=x(()=>{"use strict";vn=require("zod"),Qt=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)})');`]}};Cd=vn.z.object({down:vn.z.boolean().describe("True to scroll down, False to scroll up"),num_pages:vn.z.number().nonnegative().describe("Number of pages to scroll (0.5 = half page, 1.0 = one page, etc.)")})});async function Pd(e,t,i,n,a={}){return{...await U(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function Br(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:Nd,usesElementIndex:!0,async execute(i,n){let{element_index:a,delta_x:o,delta_y:r}=i,{page:s,agentServices:l}=n;try{let c=await J(n,a);if(!c)return{success:!1,error:`Element with index ${a} not found`,actionEntity:Br(`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:a,delta_x:o,delta_y:r})};let d=await Pd("scroll_on_element",`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,c,s,{delta_x:o,delta_y:r});return await t.execute(s,d,l),{success:!0,actionEntity:d,message:`Scrolled on element ${a} horizontally: ${o}px, vertically: ${r}px`}}catch(c){return{success:!1,error:c.message,actionEntity:Br(`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:a,delta_x:o,delta_y:r})}}}})}var ft,Gr,Nd,ti=x(()=>{"use strict";Q();K();ft=require("zod");C();Gr=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=F(e,t),s=R(i,t.action_data?.kwargs?.timeout_ms);if(r)await r.hover({timeout:s}),await e.mouse.wheel(a,o);else throw new Error("No locator found for scroll_on_element action")}transpile(e){let t=Le(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: ${R()} });`,`await page.mouse.wheel(${i}, ${n});`]}};Nd=ft.z.object({element_index:ft.z.number().int().describe("Index of the scrollable element"),delta_x:ft.z.number().optional().describe("The number of pixels to scroll horizontally. Positive values scroll right, negative values scroll left."),delta_y:ft.z.number().optional().describe("The number of pixels to scroll vertically. Positive values scroll down, negative values scroll up."),timeout_ms:ft.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Vr(e,t){e.register({name:"scroll_to_text",description:"Scroll the page until specified text becomes visible.",schema:Od,async execute(i,n){let{text:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Scroll to text "${a}"`,action_data:{action_name:"scroll_to_text",kwargs:{text:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Scrolled to text "${a}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Scroll to text "${a}"`)+" (failed)",action_data:{action_name:"scroll_to_text",kwargs:{text:a}},feedback:l.message}}}}})}var Ia,zr,Od,ii=x(()=>{"use strict";Ia=require("zod"),zr=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();`]}},Od=Ia.z.object({text:Ia.z.string().describe("Text to scroll to on the page")})});async function Ld(e,t,i,n){return{...await U(t,e),action_description:n||`Select option "${i}"`,action_data:{action_name:"select_dropdown_option",kwargs:{text:i}}}}function Xr(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 Yr(e,t){e.register({name:"select_dropdown_option",description:"Select an option from a dropdown/select element by value, label, or index.",schema:Dd,usesElementIndex:!0,async execute(i,n){let{element_index:a,option:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=await J(n,a);if(!c)return{success:!1,error:`Dropdown element with index ${a} not found`,actionEntity:Xr(l||`Select option in dropdown ${a}`,{index:a,option:o})};let d=await Ld(c,r,o,l);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Selected option "${o}" in dropdown ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:Xr(`Select option in dropdown ${a}`,{index:a,option:o})}}}})}var ni,Jr,Dd,ai=x(()=>{"use strict";Q();K();ni=require("zod");C();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.text||n.kwargs.option,o=F(e,t),r=R(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},`),"});"]}};Dd=ni.z.object({element_index:ni.z.number().int().describe("Index of the dropdown/select element"),option:ni.z.string().describe("Option value, label, or index to select"),timeout_ms:ni.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function Rd(e,t,i,n){return{...await U(i,t),action_description:e,action_data:{action_name:"set_date_for_native_date_picker",kwargs:{date:n}}}}function Ca(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 Zr(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">).
|
|
4102
4102
|
|
|
4103
4103
|
IMPORTANT: ONLY use this action for input elements that have type="date" attribute (native HTML date picker).
|
|
4104
4104
|
Do NOT use it for custom/non-native date pickers
|
|
4105
4105
|
|
|
4106
|
-
The date must be in YYYY-MM-DD format (e.g., 2024-03-15).`,schema:Dd,usesElementIndex:!0,async execute(i,n){let{element_index:a,date:o}=i,{page:r,agentServices:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Date picker element with index ${a} not found`,actionEntity:Ia(`Set date to ${o} on element ${a}`,{index:a,date:o})};let c=l.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:Ia(`Set date to ${o} on element ${a}`,{index:a,date:o})};let d=await Ld(`Set date to ${o} on element ${a}`,l,r,o);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Set date to ${o} on element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:Ia(`Set date to ${o} on element ${a}`,{index:a,date:o})}}}})}var oi,Jr,Dd,ri=x(()=>{"use strict";Q();G();oi=require("zod");C();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.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=F(e,t);if(r){let s=await r.getAttribute("type").catch(()=>null);if(s&&s!=="date")throw new Error(`Element is not a native date picker (type="${s}"). This action only works with <input type="date">. For custom date pickers, use AI-powered actions.`);await r.fill(o,{timeout:R(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},`),"});"]}};Dd=oi.z.object({element_index:oi.z.number().int().describe("Index of the native date picker input element"),date:oi.z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Date in YYYY-MM-DD format (e.g., 2024-03-15)"),timeout_ms:oi.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function Rd(e,t,i,n,a={}){return{...await j(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function qr(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 Zr(e,t){e.register({name:"hover",description:"Hover over an interactive element.",schema:Fd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:qr(`Hover element ${a}`,"hover",{index:a})};let c=s||`Hover over element ${a}`,d=await Rd("hover",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Hovered over element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:qr(`Hover element ${a}`,"hover",{index:a})}}}})}var _n,Ca,Fd,si=x(()=>{"use strict";Q();G();_n=require("zod");C();Ca=class{async execute(e,t,i){let n=F(e,t),a=R(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 s=r.x+r.width/2,l=r.y+r.height/2;await e.mouse.move(s,l)}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},`),"});"]}};Fd=_n.z.object({element_index:_n.z.number().int().describe("Index of the element to hover over"),timeout_ms:_n.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function Hd(e,t,i,n,a={}){return{...await j(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function Qr(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 es(e,t){e.register({name:"input_text",description:"Type text into an input field. To replace existing content, use clear_input first.",schema:Wd,usesElementIndex:!0,async execute(i,n){let{element_index:a,text:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=await J(n,a);if(!c)return{success:!1,error:`Input element with index ${a} not found`,actionEntity:Qr(l||`Input text to element ${a}`,"input_text",{index:a,text:o})};let d=l||`Input text to element ${a}`,u=await Hd("input_text",d,c,r,{text:o});return await t.execute(r,u,s),{success:!0,actionEntity:u,message:`Input text to element ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:Qr(`Input text to element ${a}`,"input_text",{index:a,text:o})}}}})}var li,Pa,Wd,ci=x(()=>{"use strict";Q();G();li=require("zod");C();Pa=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=F(e,t),s=R(i,t.action_data?.kwargs?.timeout_ms);if(r){await r.evaluate(c=>{c.value&&(c.value="")},null,{timeout:s}),await r.click({timeout:s}),await e.waitForTimeout(200);let l=i.getActionSettings().type_delay;l!==void 0?await e.keyboard.type(o,{delay:l}):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},`),"});"]}};Wd=li.z.object({element_index:li.z.number().int().describe("Index of the input element"),text:li.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:li.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function ts(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:s}=n;try{let l={action_description:s||`Press keys "${a}"`,action_data:{action_name:"press",kwargs:{keys:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Pressed keys "${a}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Press keys "${a}"`)+" (failed)",action_data:{action_name:"press",kwargs:{keys:a}},feedback:l.message}}}}})}var Oa,Na,Ud,di=x(()=>{"use strict";Oa=require("zod"),Na=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=Oa.z.object({keys:Oa.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 as(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:jd,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 is,ns,jd,ui=x(()=>{"use strict";G();is=require("zod");C();ns=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, {});']}},jd=is.z.object({})});async function Bd(e,t,i,n,a={}){return{...await j(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function os(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 rs(e,t){e.register({name:"right_click",description:"Right-click an interactive element.",schema:Gd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:os(`Right-click element ${a}`,"right_click",{index:a})};let c=s||`Right-click element ${a}`,d=await Bd("right_click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Right-clicked element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:os(`Right-click element ${a}`,"right_click",{index:a})}}}})}var kn,La,Gd,hi=x(()=>{"use strict";Q();G();kn=require("zod");C();La=class{async execute(e,t,i){let n=F(e,t),a=R(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},`),"});"]}};Gd=kn.z.object({element_index:kn.z.number().int().describe("Index of the element to right-click"),timeout_ms:kn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function Kd(e,t,i,n,a={}){return{...await j(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function ss(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 ls(e,t){e.register({name:"double_click",description:"Double-click an interactive element.",schema:zd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:ss(`Double-click element ${a}`,"double_click",{index:a})};let c=s||`Double-click element ${a}`,d=await Kd("double_click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Double-clicked element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:ss(`Double-click element ${a}`,"double_click",{index:a})}}}})}var Sn,Da,zd,mi=x(()=>{"use strict";Q();G();Sn=require("zod");C();Da=class{async execute(e,t,i){let n=F(e,t),a=R(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},`),"});"]}};zd=Sn.z.object({element_index:Sn.z.number().int().describe("Index of the element to double-click"),timeout_ms:Sn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function ds(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:Vd,async execute(i,n){let{otp_secret_key:a}=i,{page:o,agentServices:r}=n;try{let s={action_description:"Generate 2FA code",action_data:{action_name:"generate_2fa_code",kwargs:{otp_secret_key:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:'Generated 2FA code and saved to variable "otp_code"'}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Generate 2FA code (failed)",action_data:{action_name:"generate_2fa_code",kwargs:{otp_secret_key:a}},feedback:s.message}}}}})}var Ra,cs,Vd,pi=x(()=>{"use strict";Ra=require("zod"),cs=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)} } },`,"});"]}},Vd=Ra.z.object({otp_secret_key:Ra.z.string().describe("The OTP secret key to generate the 2FA code from")})});async function Xd(e,t,i){return{...await j(t,e),action_description:i||"Get dropdown options",action_data:{action_name:"get_dropdown_options",kwargs:{}}}}function us(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 ms(e,t){e.register({name:"get_dropdown_options",description:"Get all options from a native dropdown",schema:Jd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Dropdown element with index ${a} not found`,actionEntity:us(s||`Get options from dropdown ${a}`,{index:a})};let c=await Xd(l,o,s);return await t.execute(o,c,r),{success:!0,actionEntity:c,message:c.feedback||"No options found"}}catch(l){return{success:!1,error:l.message,actionEntity:us(s||`Get options from dropdown ${a}`,{index:a})}}}})}var Fa,hs,Jd,gi=x(()=>{"use strict";Q();Fa=require("zod"),hs=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 s=document.evaluate(r,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return s?{options:Array.from(s.options).map(l=>({text:l.text,value:l.value,index:l.index})),id:s.id,name:s.name}:null},t.xpath);if(o){let r=[];for(let s of o.options){let l=JSON.stringify(s.text);r.push(`${s.index}: text=${l}`)}n.push(...r)}}catch{}if(n.length>0){let a=n.join(`
|
|
4106
|
+
The date must be in YYYY-MM-DD format (e.g., 2024-03-15).`,schema:Fd,usesElementIndex:!0,async execute(i,n){let{element_index:a,date:o}=i,{page:r,agentServices:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Date picker element with index ${a} not found`,actionEntity:Ca(`Set date to ${o} on element ${a}`,{index:a,date:o})};let c=l.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:Ca(`Set date to ${o} on element ${a}`,{index:a,date:o})};let d=await Rd(`Set date to ${o} on element ${a}`,l,r,o);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Set date to ${o} on element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:Ca(`Set date to ${o} on element ${a}`,{index:a,date:o})}}}})}var oi,qr,Fd,ri=x(()=>{"use strict";Q();K();oi=require("zod");C();qr=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=F(e,t);if(r){let s=await r.getAttribute("type").catch(()=>null);if(s&&s!=="date")throw new Error(`Element is not a native date picker (type="${s}"). This action only works with <input type="date">. For custom date pickers, use AI-powered actions.`);await r.fill(o,{timeout:R(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},`),"});"]}};Fd=oi.z.object({element_index:oi.z.number().int().describe("Index of the native date picker input element"),date:oi.z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Date in YYYY-MM-DD format (e.g., 2024-03-15)"),timeout_ms:oi.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function Hd(e,t,i,n,a={}){return{...await U(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function Qr(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 es(e,t){e.register({name:"hover",description:"Hover over an interactive element.",schema:Wd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:Qr(`Hover element ${a}`,"hover",{index:a})};let c=s||`Hover over element ${a}`,d=await Hd("hover",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Hovered over element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:Qr(`Hover element ${a}`,"hover",{index:a})}}}})}var _n,Pa,Wd,si=x(()=>{"use strict";Q();K();_n=require("zod");C();Pa=class{async execute(e,t,i){let n=F(e,t),a=R(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 s=r.x+r.width/2,l=r.y+r.height/2;await e.mouse.move(s,l)}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},`),"});"]}};Wd=_n.z.object({element_index:_n.z.number().int().describe("Index of the element to hover over"),timeout_ms:_n.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function jd(e,t,i,n,a={}){return{...await U(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function ts(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:"input_text",description:"Type text into an input field. To replace existing content, use clear_input first.",schema:Ud,usesElementIndex:!0,async execute(i,n){let{element_index:a,text:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=await J(n,a);if(!c)return{success:!1,error:`Input element with index ${a} not found`,actionEntity:ts(l||`Input text to element ${a}`,"input_text",{index:a,text:o})};let d=l||`Input text to element ${a}`,u=await jd("input_text",d,c,r,{text:o});return await t.execute(r,u,s),{success:!0,actionEntity:u,message:`Input text to element ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:ts(`Input text to element ${a}`,"input_text",{index:a,text:o})}}}})}var li,Na,Ud,ci=x(()=>{"use strict";Q();K();li=require("zod");C();Na=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=F(e,t),s=R(i,t.action_data?.kwargs?.timeout_ms);if(r){await r.evaluate(c=>{c.value&&(c.value="")},null,{timeout:s}),await r.click({timeout:s}),await e.waitForTimeout(200);let l=i.getActionSettings().type_delay;l!==void 0?await e.keyboard.type(o,{delay:l}):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},`),"});"]}};Ud=li.z.object({element_index:li.z.number().int().describe("Index of the input element"),text:li.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:li.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function ns(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:Bd,async execute(i,n){let{keys:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Press keys "${a}"`,action_data:{action_name:"press",kwargs:{keys:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Pressed keys "${a}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Press keys "${a}"`)+" (failed)",action_data:{action_name:"press",kwargs:{keys:a}},feedback:l.message}}}}})}var Oa,La,Bd,di=x(()=>{"use strict";Oa=require("zod"),La=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)});`]}},Bd=Oa.z.object({keys:Oa.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 rs(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:Gd,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 as,os,Gd,ui=x(()=>{"use strict";K();as=require("zod");C();os=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, {});']}},Gd=as.z.object({})});async function Kd(e,t,i,n,a={}){return{...await U(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function ss(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 ls(e,t){e.register({name:"right_click",description:"Right-click an interactive element.",schema:zd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:ss(`Right-click element ${a}`,"right_click",{index:a})};let c=s||`Right-click element ${a}`,d=await Kd("right_click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Right-clicked element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:ss(`Right-click element ${a}`,"right_click",{index:a})}}}})}var kn,Da,zd,hi=x(()=>{"use strict";Q();K();kn=require("zod");C();Da=class{async execute(e,t,i){let n=F(e,t),a=R(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},`),"});"]}};zd=kn.z.object({element_index:kn.z.number().int().describe("Index of the element to right-click"),timeout_ms:kn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function Vd(e,t,i,n,a={}){return{...await U(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:Xd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:cs(`Double-click element ${a}`,"double_click",{index:a})};let c=s||`Double-click element ${a}`,d=await Vd("double_click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Double-clicked element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:cs(`Double-click element ${a}`,"double_click",{index:a})}}}})}var Sn,Ra,Xd,mi=x(()=>{"use strict";Q();K();Sn=require("zod");C();Ra=class{async execute(e,t,i){let n=F(e,t),a=R(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},`),"});"]}};Xd=Sn.z.object({element_index:Sn.z.number().int().describe("Index of the element to double-click"),timeout_ms:Sn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function hs(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:Jd,async execute(i,n){let{otp_secret_key:a}=i,{page:o,agentServices:r}=n;try{let s={action_description:"Generate 2FA code",action_data:{action_name:"generate_2fa_code",kwargs:{otp_secret_key:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:'Generated 2FA code and saved to variable "otp_code"'}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Generate 2FA code (failed)",action_data:{action_name:"generate_2fa_code",kwargs:{otp_secret_key:a}},feedback:s.message}}}}})}var Fa,us,Jd,pi=x(()=>{"use strict";Fa=require("zod"),us=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)} } },`,"});"]}},Jd=Fa.z.object({otp_secret_key:Fa.z.string().describe("The OTP secret key to generate the 2FA code from")})});async function Yd(e,t,i){return{...await U(t,e),action_description:i||"Get dropdown options",action_data:{action_name:"get_dropdown_options",kwargs:{}}}}function ms(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 gs(e,t){e.register({name:"get_dropdown_options",description:"Get all options from a native dropdown",schema:qd,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Dropdown element with index ${a} not found`,actionEntity:ms(s||`Get options from dropdown ${a}`,{index:a})};let c=await Yd(l,o,s);return await t.execute(o,c,r),{success:!0,actionEntity:c,message:c.feedback||"No options found"}}catch(l){return{success:!1,error:l.message,actionEntity:ms(s||`Get options from dropdown ${a}`,{index:a})}}}})}var Ha,ps,qd,gi=x(()=>{"use strict";Q();Ha=require("zod"),ps=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 s=document.evaluate(r,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return s?{options:Array.from(s.options).map(l=>({text:l.text,value:l.value,index:l.index})),id:s.id,name:s.name}:null},t.xpath);if(o){let r=[];for(let s of o.options){let l=JSON.stringify(s.text);r.push(`${s.index}: text=${l}`)}n.push(...r)}}catch{}if(n.length>0){let a=n.join(`
|
|
4107
4107
|
`);a+=`
|
|
4108
|
-
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},`),"});"]}};
|
|
4108
|
+
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},`),"});"]}};qd=Ha.z.object({element_index:Ha.z.number().int().describe("Index of the dropdown/select element")})});function ys(e,t){e.register({name:"go_back",description:"Navigate back to the previous page in browser history.",schema:Zd,async execute(i,n){let{page:a,agentServices:o,actionDescription:r}=n;try{let s={action_description:r||"Go back",action_data:{action_name:"go_back",kwargs:{}}};return await t.execute(a,s,o),{success:!0,actionEntity:s,message:"Navigated back"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(r||"Go back")+" (failed)",action_data:{action_name:"go_back",kwargs:{}},feedback:s.message}}}}})}var fs,ws,Zd,fi=x(()=>{"use strict";K();fs=require("zod");C();ws=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, {});']}},Zd=fs.z.object({})});function bs(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:Qd,async execute(i,n){let{url:a,new_tab:o,timeout_seconds:r}=i,{page:s,agentServices:l,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 m=o?`Open ${a} in new tab`:`Navigate to ${a}`,p={action_description:c||m,action_data:{action_name:"go_to_url",kwargs:d}};return await t.execute(s,p,l),{success:!0,actionEntity:p,message:(o?`Opened ${a} in new tab`:`Navigated to ${a}`)+u}}catch(m){let p=o?`Open ${a} in new tab`:`Navigate to ${a}`;return{success:!1,error:m.message,actionEntity:{action_description:(c||p)+" (failed)",action_data:{action_name:"go_to_url",kwargs:d},feedback:m.message}}}}})}var wi,Wa,Qd,yi=x(()=>{"use strict";K();wi=require("zod");C();Wa=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 s=n.kwargs.timeout_seconds?n.kwargs.timeout_seconds*1e3:fe,l=e;o&&(l=await e.context().newPage(),i.setPage(l)),await l.goto(r,{timeout:s})}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(", ")} } },`,"});"]}},Qd=wi.z.object({url:wi.z.string().describe('URL to navigate to (HTTP/HTTPS URL, or a path like "/home")'),new_tab:wi.z.boolean().optional().describe("If true, open the URL in a new tab instead of the current page. Default is false."),timeout_seconds:wi.z.number().positive().optional().describe("Navigation timeout in seconds. Default is 20 seconds.")})});function vs(e){if(!e.trim())return!1;try{return(0,xs.parse)(e,{sourceType:"module",plugins:["typescript"]}),!0}catch{return!1}}var xs,En=x(()=>{"use strict";xs=require("@babel/parser")});function _s(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:eu,async execute(i,n){let{statement:a}=i,{page:o,agentServices:r}=n;try{let s={action_description:`${a}`,action_data:{action_name:"verify",kwargs:{statement:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Assertion verified: ${a}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:`Verify: ${a} (failed)`,action_data:{action_name:"verify",kwargs:{statement:a}},feedback:s.message}}}},availability:{openai:!0,mcp:!0}})}var ja,Tn,eu,bi=x(()=>{"use strict";dt();En();G();ja=require("zod"),Tn=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),f.info(`[VERIFY:JS] \u2713 ${((Date.now()-d)/1e3).toFixed(1)}s: ${o}`),i.addNote(`Assertion passed: ${o}`);return}catch(u){let m=((Date.now()-d)/1e3).toFixed(1);f.info(`[VERIFY:JS\u2192AI] JS failed ${m}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),f.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();f.info(`[VERIFY:AI] Evaluating: ${o}`);let{evaluateStatement:s}=await Promise.resolve().then(()=>(ht(),ut)),l=await s(o,e,i,{useCleanScreenshotForAssertion:!0}),c=l.explanation||l.error||(l.success?`Assertion passed: ${o}`:"Assertion failed");if(i.addNote(c),!l.success)throw f.info(`[VERIFY:AI] \u2717 ${((Date.now()-r)/1e3).toFixed(1)}s: ${o}`),new Error(l.error||l.explanation||"Assertion failed");f.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",`
|
|
4109
4109
|
return (async () => {
|
|
4110
4110
|
${t}
|
|
4111
4111
|
})();
|
|
4112
|
-
`)(e,He.expect,n)}catch(a){throw new Error(`Assertion failed: ${a instanceof Error?a.message:String(a)}`)}}transpile(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,o=JSON.stringify(t||"");if(n){let r=i.code;if(!
|
|
4112
|
+
`)(e,He.expect,n)}catch(a){throw new Error(`Assertion failed: ${a instanceof Error?a.message:String(a)}`)}}transpile(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,o=JSON.stringify(t||"");if(n){let r=i.code;if(!vs(r))return[`throw new Error("Invalid assertion code syntax: " + ${JSON.stringify(r)});`];if(a){let s=r.split(`
|
|
4113
4113
|
`),l=JSON.stringify(a);return["{ const _t = Date.now(); try {",...s.map(c=>` ${c}`),` 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}, ${o});`,"} }"]}return r.split(`
|
|
4114
|
-
`)}return a?[`await agent.assert(page, ${JSON.stringify(a)}, ${o});`]:["// Skipping verify: missing statement or code"]}},Zd=Wa.z.object({statement:Wa.z.string().describe('The nature language statement to verify (e.g., "The login was successful")')})});function _s(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:Qd,async execute(i,n){let{element_description:a,variable_name:o}=i,{page:r,agentServices:s}=n;try{let l={action_description:`Extract ${a} to ${o}`,action_data:{action_name:"ai_extract",kwargs:{element_description:a,variable_name:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Extracted ${a} to ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Extract ${a} (failed)`,action_data:{action_name:"ai_extract",kwargs:{element_description:a,variable_name:o}},feedback:l.message}}}},availability:{openai:!1,mcp:!0}})}var An,vs,Qd,xi=x(()=>{"use strict";An=require("zod"),vs=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:s}=await Promise.resolve().then(()=>(ht(),ut)),l=await s(r,e,i);if(l.status!=="success")throw new Error(l.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||""}');`]}},Qd=An.z.object({element_description:An.z.string().describe('Description of the element to extract (e.g., "the price of the product")'),variable_name:An.z.string().describe("Name of the variable to store the extracted value")})});async function eu(e,t,i,n,a={}){return{...await j(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function ks(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 Es(e,t){e.register({name:"clear_input",description:"Clear the contents of an input field, textarea, or other editable element.",schema:tu,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Input element with index ${a} not found`,actionEntity:ks(s||`Clear element ${a}`,"clear_input",{index:a})};let c=s||`Clear element ${a}`,d=await eu("clear_input",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Cleared element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:ks(`Clear element ${a}`,"clear_input",{index:a})}}}})}var $n,Ss,tu,vi=x(()=>{"use strict";Q();G();$n=require("zod");C();Ss=class{async execute(e,t,i){let n=F(e,t),a=R(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},`),"});"]}};tu=$n.z.object({element_index:$n.z.number().int().describe("Index of the input element to clear"),timeout_ms:$n.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function iu(e,t,i,n,a={}){return{...await j(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function Ts(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:nu,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:Ts(`Click element ${a}`,"click",{index:a})};let c=s||`Click element ${a}`,d=await iu("click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Clicked element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:Ts(`Click element ${a}`,"click",{index:a})}}}})}var Mn,In,nu,_i=x(()=>{"use strict";Q();G();Mn=require("zod");C();In=class{async execute(e,t,i){let n=F(e,t),a=R(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=Le(e);if(!t)return['await agent.execAction("click", page, {});'];let i=R();return[`await ${t}.click({ timeout: ${i} });`]}};nu=Mn.z.object({element_index:Mn.z.number().int().describe("Index of the element to click (0-based). Return -1 if no element found"),timeout_ms:Mn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Ms(e,t){e.register({name:"close_tab",description:"Close a browser tab by index. If no index is specified, closes the current tab.",schema:au,async execute(i,n){let{index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Close tab ${a}`,action_data:{action_name:"close_tab",kwargs:{page_id:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Closed tab ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||"Close tab")+" (failed)",action_data:{action_name:"close_tab",kwargs:{}},feedback:l.message}}}}})}var Ua,$s,au,ki=x(()=>{"use strict";Ua=require("zod"),$s=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} } },`,"});"]}},au=Ua.z.object({index:Ua.z.number().int().nonnegative().optional().describe("Index of the tab to close (0-based). Defaults to current tab if not specified.")})});function Cs(e,t){e.register({name:"done",description:"Mark the current task as complete. Use when you have finished all requested actions.",schema:ou,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 Cn,Is,ou,Si=x(()=>{"use strict";Cn=require("zod"),Is=class{async execute(e,t){}transpile(e){return["// Done - no action needed"]}},ou=Cn.z.object({success:Cn.z.boolean().describe("Whether the task was completed successfully"),summary:Cn.z.string().describe("Summary of what was accomplished or why it failed")})});var ru,su,ze,Pn=x(()=>{"use strict";ru=["ai_action","ai_step","ai_assert","ai_extract","ai_wait_until","verify","assert"],su=["js_code","function","wait","wait_for_download_complete","wait_for_page_ready","extract_email_content","extract_activation_code"],ze=class{static isAiAction(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:ru.includes(t)}static getAiStatement(e){let t=e.action_data?.action_name;if(!t)return null;let i=e.action_data?.kwargs||{};switch(t){case"ai_action":case"ai_step":return i.statement||null;case"verify":case"ai_assert":case"assert":return i.statement||e.action_description||null;case"ai_extract":let n=i.element_description,a=i.variable_name;return n&&a?`Extract ${n} and save to ${a}`:null;case"ai_wait_until":return i.condition||null;default:return null}}static canSelfHeal(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:!su.includes(t)}}});var ja,Ba,Ei,Ga=x(()=>{"use strict";en();tn();nn();an();on();rn();sn();ln();pn();gn();fn();Kt();Vt();Xt();Jt();qt();Zt();ei();ti();ii();ai();ri();si();ci();di();ui();hi();mi();pi();gi();fi();yi();bi();xi();vi();_i();ki();Si();Pn();G();Se();ja=class A{static registerAction(t,i){A.actions.set(t,i)}constructor(){A.initialized||(this.registerBuiltinActions(),A.initialized=!0)}registerBuiltinActions(){A.registerAction("go_to_url",new Ha),A.registerAction("go_back",new gs),A.registerAction("reload_page",new ns),A.registerAction("close_tab",new $s),A.registerAction("switch_tab",new vr),A.registerAction("click",new In),A.registerAction("hover",new Ca),A.registerAction("right_click",new La),A.registerAction("double_click",new Da),A.registerAction("click_by_coordinates",new br),A.registerAction("right_click_by_coordinates",new cr),A.registerAction("double_click_by_coordinates",new pr),A.registerAction("drag_drop",new gr),A.registerAction("input_text",new Pa),A.registerAction("clear_input",new Ss),A.registerAction("press",new Na),A.registerAction("send_keys_on_element",new dr),A.registerAction("scroll_on_element",new jr),A.registerAction("scroll_to_text",new Gr),A.registerAction("scroll",new Qt),A.registerAction("upload_file",new Tr),A.registerAction("wait_for_download_complete",new Ir),A.registerAction("get_dropdown_options",new hs),A.registerAction("select_dropdown_option",new Vr),A.registerAction("set_date_for_native_date_picker",new Jr),A.registerAction("verify",new Tn),A.registerAction("ai_action",new xr),A.registerAction("ai_extract",new vs),A.registerAction("ai_step",new yr),A.registerAction("ai_wait_until",new Dr),A.registerAction("generate_2fa_code",new cs),A.registerAction("wait",new $r),A.registerAction("wait_for_page_ready",new lr),A.registerAction("save_variable",new Fr),A.registerAction("js_code",new mr),A.registerAction("js_action",new ur),A.registerAction("function",new fr),A.registerAction("done",new Is),A.registerAction("click_element",new In),A.registerAction("click_element_by_index",new In),A.registerAction("hover_element_by_index",new Ca),A.registerAction("right_click_on_element",new La),A.registerAction("double_click_on_element",new Da),A.registerAction("scroll_down",new Qt),A.registerAction("scroll_up",new Qt),A.registerAction("scroll_element",new Qt),A.registerAction("send_keys",new Na),A.registerAction("open_tab",new Ha),A.registerAction("fill",new Pa),A.registerAction("ai_assert",new Tn),A.registerAction("assert",new Tn)}getAction(t){return A.actions.get(t)}hasAction(t){return A.actions.has(t)}getActionNames(){return Array.from(A.actions.keys())}async execute(t,i,n){if(!n)throw new Error("AgentServices not found");let a=i.action_data?.action_name;if(!a)throw new Error("Action name not found in action_data");let o=this.getAction(a);if(!o)throw new Error(`Unknown action: ${a}`);await o.execute(t,i,n)}transpile(t,i,n){let{sanitizeForComment:a}=(C(),ta(Ri)),o=t.action_description||"",r=t.action_data?.action_name||"",s=this.getAction(r);if(!s)return[`// ${i}: Unknown action: ${r}`];let l=s.transpile(t,i);if(ze.isAiAction(t))return[`// ${i}: ${a(o)}`,"page = agent.agentServices.validatePage(page);",...l];let c=JSON.stringify(o),d=l.map(m=>` ${m}`),u=ze.canSelfHeal(t),p=n?JSON.stringify(n):"undefined";return[`// ${i}: ${a(o)}`,"page = agent.agentServices.validatePage(page);","await agent.step(page, async () => {",...d,`}, ${c}, '${i}', ${p}, ${u});`]}transpileUncachedAction(t,i,n=!1,a=!1,o){let{sanitizeForComment:r}=(C(),ta(Ri));if(!t)return[`// ${i}: Skipping - no description`];let s=JSON.stringify(t);if(a){let l=o?`, { stmtUid: ${JSON.stringify(o)} }`:"";return[`// ${i}: ${r(t)}`,"page = agent.agentServices.validatePage(page);",`await agent.run(page, ${s}, '${i}'${l});`]}return[`// ${i}: ${r(t)}`,"page = agent.agentServices.validatePage(page);",`await agent.execute(page, ${s}, '${i}', ${n});`]}};ja.actions=new Map,ja.initialized=!1;Ba=ja,Ei=Ba});var On={};Qe(On,{ActionHandler:()=>Ba,default:()=>Ei});var Nn=x(()=>{"use strict";Ga();en();tn();nn();an();on();rn();sn();ln();pn();gn();fn();Kt();Vt();Xt();Jt();qt();Zt();ei();ti();ii();ai();ri();si();ci();di();ui();hi();mi();pi();gi();fi();yi();bi();dt();xi();vi();_i();ki();Si();En();zt();Q();je();We();gt();Me();mt();z();ae();jt();Pn();G();Se()});function Ln(e,t,i){let n=()=>e.stepHistory.length===0?"":`**Recent Steps**:
|
|
4115
|
-
${e.stepHistory.slice(-3).map(l=>{let c=`${l.outcome.success?"\u2713":"\u2717"} Step ${l.stepNumber}: ${l.goal}`;if(l.actions.length>1)l.actions.forEach((d,u)=>{let
|
|
4116
|
-
\u2192 Action ${u+1}: ${
|
|
4114
|
+
`)}return a?[`await agent.assert(page, ${JSON.stringify(a)}, ${o});`]:["// Skipping verify: missing statement or code"]}},eu=ja.z.object({statement:ja.z.string().describe('The nature language statement to verify (e.g., "The login was successful")')})});function Ss(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:tu,async execute(i,n){let{element_description:a,variable_name:o}=i,{page:r,agentServices:s}=n;try{let l={action_description:`Extract ${a} to ${o}`,action_data:{action_name:"ai_extract",kwargs:{element_description:a,variable_name:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Extracted ${a} to ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Extract ${a} (failed)`,action_data:{action_name:"ai_extract",kwargs:{element_description:a,variable_name:o}},feedback:l.message}}}},availability:{openai:!1,mcp:!0}})}var An,ks,tu,xi=x(()=>{"use strict";An=require("zod"),ks=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:s}=await Promise.resolve().then(()=>(ht(),ut)),l=await s(r,e,i);if(l.status!=="success")throw new Error(l.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||""}');`]}},tu=An.z.object({element_description:An.z.string().describe('Description of the element to extract (e.g., "the price of the product")'),variable_name:An.z.string().describe("Name of the variable to store the extracted value")})});async function iu(e,t,i,n,a={}){return{...await U(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 As(e,t){e.register({name:"clear_input",description:"Clear the contents of an input field, textarea, or other editable element.",schema:nu,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Input element with index ${a} not found`,actionEntity:Es(s||`Clear element ${a}`,"clear_input",{index:a})};let c=s||`Clear element ${a}`,d=await iu("clear_input",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Cleared element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:Es(`Clear element ${a}`,"clear_input",{index:a})}}}})}var $n,Ts,nu,vi=x(()=>{"use strict";Q();K();$n=require("zod");C();Ts=class{async execute(e,t,i){let n=F(e,t),a=R(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},`),"});"]}};nu=$n.z.object({element_index:$n.z.number().int().describe("Index of the input element to clear"),timeout_ms:$n.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function au(e,t,i,n,a={}){return{...await U(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function $s(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 Ms(e,t){e.register({name:"click",description:"Click an interactive element.",schema:ou,usesElementIndex:!0,async execute(i,n){let{element_index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l=await J(n,a);if(!l)return{success:!1,error:`Element with index ${a} not found.`,actionEntity:$s(`Click element ${a}`,"click",{index:a})};let c=s||`Click element ${a}`,d=await au("click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Clicked element ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:$s(`Click element ${a}`,"click",{index:a})}}}})}var Mn,In,ou,_i=x(()=>{"use strict";Q();K();Mn=require("zod");C();In=class{async execute(e,t,i){let n=F(e,t),a=R(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=Le(e);if(!t)return['await agent.execAction("click", page, {});'];let i=R();return[`await ${t}.click({ timeout: ${i} });`]}};ou=Mn.z.object({element_index:Mn.z.number().int().describe("Index of the element to click (0-based). Return -1 if no element found"),timeout_ms:Mn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Cs(e,t){e.register({name:"close_tab",description:"Close a browser tab by index. If no index is specified, closes the current tab.",schema:ru,async execute(i,n){let{index:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Close tab ${a}`,action_data:{action_name:"close_tab",kwargs:{page_id:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Closed tab ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||"Close tab")+" (failed)",action_data:{action_name:"close_tab",kwargs:{}},feedback:l.message}}}}})}var Ua,Is,ru,ki=x(()=>{"use strict";Ua=require("zod"),Is=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} } },`,"});"]}},ru=Ua.z.object({index:Ua.z.number().int().nonnegative().optional().describe("Index of the tab to close (0-based). Defaults to current tab if not specified.")})});function Ns(e,t){e.register({name:"done",description:"Mark the current task as complete. Use when you have finished all requested actions.",schema:su,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 Cn,Ps,su,Si=x(()=>{"use strict";Cn=require("zod"),Ps=class{async execute(e,t){}transpile(e){return["// Done - no action needed"]}},su=Cn.z.object({success:Cn.z.boolean().describe("Whether the task was completed successfully"),summary:Cn.z.string().describe("Summary of what was accomplished or why it failed")})});var lu,cu,ze,Pn=x(()=>{"use strict";lu=["ai_action","ai_step","ai_assert","ai_extract","ai_wait_until","verify","assert"],cu=["js_code","function","wait","wait_for_download_complete","wait_for_page_ready","extract_email_content","extract_activation_code"],ze=class{static isAiAction(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:lu.includes(t)}static getAiStatement(e){let t=e.action_data?.action_name;if(!t)return null;let i=e.action_data?.kwargs||{};switch(t){case"ai_action":case"ai_step":return i.statement||null;case"verify":case"ai_assert":case"assert":return i.statement||e.action_description||null;case"ai_extract":let n=i.element_description,a=i.variable_name;return n&&a?`Extract ${n} and save to ${a}`:null;case"ai_wait_until":return i.condition||null;default:return null}}static canSelfHeal(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:!cu.includes(t)}}});var Ba,Ga,Ei,Ka=x(()=>{"use strict";en();tn();nn();an();on();rn();sn();ln();pn();gn();fn();Kt();Vt();Xt();Jt();qt();Zt();ei();ti();ii();ai();ri();si();ci();di();ui();hi();mi();pi();gi();fi();yi();bi();xi();vi();_i();ki();Si();Pn();K();Se();Ba=class A{static registerAction(t,i){A.actions.set(t,i)}constructor(){A.initialized||(this.registerBuiltinActions(),A.initialized=!0)}registerBuiltinActions(){A.registerAction("go_to_url",new Wa),A.registerAction("go_back",new ws),A.registerAction("reload_page",new os),A.registerAction("close_tab",new Is),A.registerAction("switch_tab",new _r),A.registerAction("click",new In),A.registerAction("hover",new Pa),A.registerAction("right_click",new Da),A.registerAction("double_click",new Ra),A.registerAction("click_by_coordinates",new xr),A.registerAction("right_click_by_coordinates",new dr),A.registerAction("double_click_by_coordinates",new gr),A.registerAction("drag_drop",new fr),A.registerAction("input_text",new Na),A.registerAction("clear_input",new Ts),A.registerAction("press",new La),A.registerAction("send_keys_on_element",new ur),A.registerAction("scroll_on_element",new Gr),A.registerAction("scroll_to_text",new zr),A.registerAction("scroll",new Qt),A.registerAction("upload_file",new Ar),A.registerAction("wait_for_download_complete",new Cr),A.registerAction("get_dropdown_options",new ps),A.registerAction("select_dropdown_option",new Jr),A.registerAction("set_date_for_native_date_picker",new qr),A.registerAction("verify",new Tn),A.registerAction("ai_action",new vr),A.registerAction("ai_extract",new ks),A.registerAction("ai_step",new br),A.registerAction("ai_wait_until",new Fr),A.registerAction("generate_2fa_code",new us),A.registerAction("wait",new Mr),A.registerAction("wait_for_page_ready",new cr),A.registerAction("save_variable",new Wr),A.registerAction("js_code",new pr),A.registerAction("js_action",new hr),A.registerAction("function",new wr),A.registerAction("done",new Ps),A.registerAction("click_element",new In),A.registerAction("click_element_by_index",new In),A.registerAction("hover_element_by_index",new Pa),A.registerAction("right_click_on_element",new Da),A.registerAction("double_click_on_element",new Ra),A.registerAction("scroll_down",new Qt),A.registerAction("scroll_up",new Qt),A.registerAction("scroll_element",new Qt),A.registerAction("send_keys",new La),A.registerAction("open_tab",new Wa),A.registerAction("fill",new Na),A.registerAction("ai_assert",new Tn),A.registerAction("assert",new Tn)}getAction(t){return A.actions.get(t)}hasAction(t){return A.actions.has(t)}getActionNames(){return Array.from(A.actions.keys())}async execute(t,i,n){if(!n)throw new Error("AgentServices not found");let a=i.action_data?.action_name;if(!a)throw new Error("Action name not found in action_data");let o=this.getAction(a);if(!o)throw new Error(`Unknown action: ${a}`);await o.execute(t,i,n)}transpile(t,i,n){let{sanitizeForComment:a}=(C(),ta(Ri)),o=t.action_description||"",r=t.action_data?.action_name||"",s=this.getAction(r);if(!s)return[`// ${i}: Unknown action: ${r}`];let l=s.transpile(t,i);if(ze.isAiAction(t))return[`// ${i}: ${a(o)}`,"page = agent.agentServices.validatePage(page);",...l];let c=JSON.stringify(o),d=l.map(p=>` ${p}`),u=ze.canSelfHeal(t),m=n?JSON.stringify(n):"undefined";return[`// ${i}: ${a(o)}`,"page = agent.agentServices.validatePage(page);","await agent.step(page, async () => {",...d,`}, ${c}, '${i}', ${m}, ${u});`]}transpileUncachedAction(t,i,n=!1,a=!1,o){let{sanitizeForComment:r}=(C(),ta(Ri));if(!t)return[`// ${i}: Skipping - no description`];let s=JSON.stringify(t);if(a){let l=o?`, { stmtUid: ${JSON.stringify(o)} }`:"";return[`// ${i}: ${r(t)}`,"page = agent.agentServices.validatePage(page);",`await agent.run(page, ${s}, '${i}'${l});`]}return[`// ${i}: ${r(t)}`,"page = agent.agentServices.validatePage(page);",`await agent.execute(page, ${s}, '${i}', ${n});`]}};Ba.actions=new Map,Ba.initialized=!1;Ga=Ba,Ei=Ga});var Nn={};Qe(Nn,{ActionHandler:()=>Ga,default:()=>Ei});var On=x(()=>{"use strict";Ka();en();tn();nn();an();on();rn();sn();ln();pn();gn();fn();Kt();Vt();Xt();Jt();qt();Zt();ei();ti();ii();ai();ri();si();ci();di();ui();hi();mi();pi();gi();fi();yi();bi();dt();xi();vi();_i();ki();Si();En();zt();Q();Ue();We();gt();Me();mt();G();ae();Ut();Pn();K();Se()});function Ln(e,t,i){let n=()=>e.stepHistory.length===0?"":`**Recent Steps**:
|
|
4115
|
+
${e.stepHistory.slice(-3).map(l=>{let c=`${l.outcome.success?"\u2713":"\u2717"} Step ${l.stepNumber}: ${l.goal}`;if(l.actions.length>1)l.actions.forEach((d,u)=>{let m=d.action_description||"Unknown action";c+=`
|
|
4116
|
+
\u2192 Action ${u+1}: ${m}`});else if(l.actions.length===1){let d=l.actions[0]?.action_description||"Unknown action";c+=`
|
|
4117
4117
|
\u2192 ${d}`}if(!l.outcome.success&&l.outcome.error){let d=l.outcome.error.substring(0,100);c+=`
|
|
4118
4118
|
Error: ${d}${l.outcome.error.length>100?"...":""}`}return l.evaluation&&(c+=`
|
|
4119
4119
|
Eval: ${l.evaluation}`),c}).join(`
|
|
@@ -4131,7 +4131,7 @@ ${e.memory.map((l,c)=>`${c+1}. ${l}`).join(`
|
|
|
4131
4131
|
**Current URL**: ${i}
|
|
4132
4132
|
**Step**: ${e.currentStep+1}/${e.maxSteps}
|
|
4133
4133
|
|
|
4134
|
-
${o()}${r()}${a()}${n()}${s()}`.trim()}function
|
|
4134
|
+
${o()}${r()}${a()}${n()}${s()}`.trim()}function Os(){return`
|
|
4135
4135
|
\u26A0\uFE0F **FINAL STEP WARNING** \u26A0\uFE0F
|
|
4136
4136
|
|
|
4137
4137
|
This is your last step. You MUST use the "done" action now.
|
|
@@ -4140,7 +4140,7 @@ This is your last step. You MUST use the "done" action now.
|
|
|
4140
4140
|
- If the task is incomplete or partially complete, set success=false
|
|
4141
4141
|
- Include everything you've accomplished in the done action's text field
|
|
4142
4142
|
- No other actions are allowed on this step
|
|
4143
|
-
`.trim()}function
|
|
4143
|
+
`.trim()}function du(){let e=X.getTools().filter(i=>!i.name.startsWith("ai_")&&!["set_goal","evaluate_step","update_memory","mark_complete"].includes(i.name)).map(i=>{let n="";if(i.schema instanceof wt.z.ZodObject){let a=i.schema.shape,o=[];Object.keys(a).forEach(r=>{let s=a[r],l="any";s instanceof wt.z.ZodNumber?l="number":s instanceof wt.z.ZodString?l="string":s instanceof wt.z.ZodBoolean?l="boolean":s instanceof wt.z.ZodEnum&&(l=s._def.values.map(c=>`"${c}"`).join(" | ")),o.push(`${r}: ${l}`)}),n=`{${o.join(", ")}}`}return{name:i.name,description:i.description,params:n}}).sort((i,n)=>i.name.localeCompare(n.name)),t=[];return t.push("## AVAILABLE ACTIONS"),t.push(""),t.push("Use these exact action names in your JSON response:"),t.push(""),e.forEach(i=>{t.push(`- \`${i.name}\` - ${i.description} (kwargs: ${i.params})`)}),t.push(""),t.join(`
|
|
4144
4144
|
`)}function Dn(e,t={}){if(e)return e;let{useThinking:i=!0,useMemory:n=!0,useEvaluation:a=!0,useMultiAction:o=!0}=t,r=a?`
|
|
4145
4145
|
1. **Evaluate Previous Step**: After each action, evaluate whether the previous goal was accomplished:
|
|
4146
4146
|
- "success: <reason>" if the goal was fully achieved
|
|
@@ -4163,7 +4163,7 @@ This is your last step. You MUST use the "done" action now.
|
|
|
4163
4163
|
`:"",c=i?` "thinking": "<your internal reasoning about current state and next action>", // Optional
|
|
4164
4164
|
`:"",d=a?` "evaluation_previous_goal": "success: <reason>" | "partial: <reason>" | "failure: <reason>" | "", // Empty on first step
|
|
4165
4165
|
`:"",u=n?` "memory": "<important facts to remember>", // Update only when learning something new
|
|
4166
|
-
`:"",
|
|
4166
|
+
`:"",m=o?` "actions": [ // Can be single action or multiple actions in sequence
|
|
4167
4167
|
{
|
|
4168
4168
|
"description": "<human readable description WITHOUT element index, e.g. 'Click the Submit button'>",
|
|
4169
4169
|
"action_name": "<name of action to execute>",
|
|
@@ -4174,7 +4174,7 @@ This is your last step. You MUST use the "done" action now.
|
|
|
4174
4174
|
"description": "<human readable description WITHOUT element index, e.g. 'Click the Submit button'>>",
|
|
4175
4175
|
"action_name": "<name of action to execute>",
|
|
4176
4176
|
"kwargs": { ... } // Action parameters
|
|
4177
|
-
}],`,
|
|
4177
|
+
}],`,p=o?`
|
|
4178
4178
|
## When to Use Multiple Actions:
|
|
4179
4179
|
- Multiple actions can be batched if they all execute on the CURRENT page state
|
|
4180
4180
|
- Good: Type username \u2192 Tab \u2192 Type password \u2192 Click submit (all on same page, submit can be last)
|
|
@@ -4248,7 +4248,7 @@ CRITICAL: Detect when you are stuck and stop immediately:
|
|
|
4248
4248
|
|
|
4249
4249
|
When stuck, call \`done\` with success=false and explain what happened.
|
|
4250
4250
|
|
|
4251
|
-
${
|
|
4251
|
+
${du()}
|
|
4252
4252
|
## Reasoning Rules
|
|
4253
4253
|
|
|
4254
4254
|
Use the \`thinking\` field to reason about each step:
|
|
@@ -4266,7 +4266,7 @@ You must ALWAYS respond with a valid JSON in this exact format:
|
|
|
4266
4266
|
\`\`\`json
|
|
4267
4267
|
{
|
|
4268
4268
|
${c}${d}${u} "current_goal": "State the current goal. Include only what to achieve, not how to achieve it.",
|
|
4269
|
-
${
|
|
4269
|
+
${m}
|
|
4270
4270
|
"completes_instruction": true | false // Is the entire task complete?
|
|
4271
4271
|
}
|
|
4272
4272
|
\`\`\`
|
|
@@ -4284,13 +4284,13 @@ ${p}
|
|
|
4284
4284
|
**Current Goal Examples:**
|
|
4285
4285
|
- "Add the product to the cart"
|
|
4286
4286
|
- "Find more product listings and extract details from the next 5 items on the page"
|
|
4287
|
-
${
|
|
4287
|
+
${p}`.trim()}var wt,Rn=x(()=>{"use strict";Ae();wt=require("zod")});var Fn,za=x(()=>{"use strict";Rn();re();Fn=class{constructor(e){this.messages=[],this.systemPrompt=e}getMessages(){return{system:this.systemPrompt,messages:[...this.messages]}}addStateMessage(e,t,i,n,a,o={}){let{executionHistory:r,placeholderData:s,sensitiveKeys:l,isFinalStep:c,finalStepWarning:d}=o,u=[],m=Ln(a,e,t);if(u.push({type:"text",text:m}),u.push({type:"text",text:`## CURRENT PAGE STATE
|
|
4288
4288
|
|
|
4289
4289
|
**Interactive Elements**:
|
|
4290
|
-
${i}`}),r&&Array.isArray(r)&&r.length>0){let
|
|
4290
|
+
${i}`}),r&&Array.isArray(r)&&r.length>0){let p=r.map(([w,g],y)=>`${y+1}. ${w} \u2192 ${g}`);u.push({type:"text",text:`## EXECUTION HISTORY (from test)
|
|
4291
4291
|
|
|
4292
|
-
${
|
|
4293
|
-
`)}`})}if(s&&Object.keys(s).length>0){T.log("Adding placeholder data description");let
|
|
4292
|
+
${p.join(`
|
|
4293
|
+
`)}`})}if(s&&Object.keys(s).length>0){T.log("Adding placeholder data description");let p=this.getPlaceholderDataDescription(s,l);T.log(`Placeholder data description: ${p}`),p&&u.push({type:"text",text:p})}c&&d&&u.push({type:"text",text:d}),u.push({type:"image",image:n}),T.log(`Adding state message: ${u.length} parts`),this.messages.push({role:"user",content:u})}addAssistantMessage(e){this.messages.push({role:"assistant",content:e})}addTextMessage(e,t){this.messages.push({role:e,content:t})}getMessageCount(){return this.messages.length}clear(){this.messages=[]}getRecentMessages(e){return this.messages.slice(-e)}updateSystemPrompt(e){this.systemPrompt=e}addAssistantMessageWithToolCalls(e){this.messages.push({role:"assistant",content:e.map(t=>({type:"tool-call",toolCallId:t.toolCallId,toolName:t.toolName,input:t.input}))})}addToolResponseMessage(e,t,i){this.messages.push({role:"tool",content:[{type:"tool-result",toolCallId:t,toolName:i,output:typeof e=="string"?{type:"text",value:e}:{type:"json",value:e}}]})}getPlaceholderDataDescription(e,t){let i=[];for(let a of Object.keys(e))if(e[a])if(t?.has(a))i.push(` - ${a}: [SENSITIVE - value hidden]`);else{let o=e[a],r=typeof o=="string"?o:JSON.stringify(o);i.push(` - ${a}: "${r}"`)}if(i.length===0)return"";let n=`## DATA PLACEHOLDERS
|
|
4294
4294
|
|
|
4295
4295
|
`;return n+=`The following placeholders are available for use in your actions:
|
|
4296
4296
|
`,n+=`${i.join(`
|
|
@@ -4300,19 +4300,19 @@ ${m.join(`
|
|
|
4300
4300
|
`,n+=`- Use the EXACT placeholder name as shown above
|
|
4301
4301
|
`,n+=`- Do NOT use the actual value directly in the action
|
|
4302
4302
|
`,n+=`- The values shown are for context only to help you understand what data is available
|
|
4303
|
-
`,n+='- In action descriptions, describe what the placeholder represents in natural language (e.g., "Type the first user name" instead of "Type {{ firstUserName }}")',n}}});function cu(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 Ls(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(),s=[r,...t.agentServices.getFallbackModels().filter(v=>v!==r)],l=0,c=r,d=t.domService||new Fe(t.agentServices.getDomServiceOptions()),u={...t,domService:d};T.init(),T.section("Task Execution Started"),T.log(`Task: ${e}`),T.log(`Max steps: ${a}`),T.log(`Model: ${s.length>1?s.join(" \u2192 "):r}`);let p={currentStep:0,maxSteps:a,consecutiveFailures:0,maxFailures:o,lastFailReason:null,stepHistory:[],memory:[],lastGoal:null,lastEvaluation:null},m=[],y=Dn(i.customPrompt),g=new Fn(y);T.log(`System prompt length: ${y.length} chars`);let w=!1,h="",b=[];try{for(i.onEvent?.({type:"start",task:e,maxSteps:a});p.currentStep<a;){if(i.abortSignal?.aborted)throw new Error("Task aborted by user");p.currentStep++;let v=Date.now();T.section(`Step ${p.currentStep}/${a}`),T.log(`URL: ${u.page.url()}`),i.onEvent?.({type:"step_start",step:p.currentStep});try{T.log("Waiting for page to stabilize..."),await pt(u.page),T.log("Page stabilized")}catch{T.log("Page stabilization timed out, continuing anyway")}let S;try{T.log("Preparing context (DOM + screenshot)...");let W=u.agentServices.getInteractiveClassNames(),K=u.agentServices.getIframeFallbackDomains();S=await Os(u.page,u.domService,W,K),T.log("Context prepared")}catch(W){if(W.message.includes("Execution context was destroyed")){T.log("Page navigating, waiting for load..."),await pt(u.page);let K=u.agentServices.getInteractiveClassNames(),ee=u.agentServices.getIframeFallbackDomains();S=await Os(u.page,u.domService,K,ee)}else throw T.error("Error preparing context",W),W}g.addStateMessage(e,S.currentUrl,S.domTree,S.screenshotBase64,p,{isFinalStep:p.currentStep===a-1,placeholderData:t.variables,sensitiveKeys:t.sensitiveKeys});let E=await uu(g,s,l,i,S.screenshotBase64);if(typeof E.modelIndexUsed=="number"&&(l=E.modelIndexUsed,c=s[E.modelIndexUsed]??c),E.tokenUsages&&E.tokenUsages.length>0&&m.push(...E.tokenUsages),!E.stepOutput){if(T.error("Failed to get valid LLM response"),p.consecutiveFailures++,p.consecutiveFailures>=o){h="Reached the maximum allowed consecutive failures. Most recent error: Unable to get a valid response from the language model.";break}continue}let $=E.stepOutput;gu(p.currentStep,a,$);let O=await mu($,u,S.domState,p.currentStep,i.onEvent,S.screenshotBase64,E.debugInfo);b.push(...O.actionEntities);let D=pu(p.currentStep,$,O,p,v,E.debugInfo,E.tokenUsages),I=Date.now()-v;if(i.onEvent?.({type:"step_complete",step:p.currentStep,duration:I}),p.consecutiveFailures>=o){T.error(`Too many consecutive failures (${p.consecutiveFailures}), stopping`),h=`Reached the maximum allowed consecutive failures. Most recent error: ${p.lastFailReason}`;break}if(O.doneResult){w=O.doneResult.success,h=O.doneResult.summary;break}if(O.completesInstruction){w=!0,h="Instruction completed";break}}return p.currentStep>=a&&!w&&(h="Reached the maximum allowed steps."),i.onEvent?.({type:"complete",totalSteps:p.currentStep,duration:Date.now()-n}),T.log(`Build success result: summary=${h}, completed=${w}, actions=${b.length}, tokens=${m.length}`),fu(p,b,w,h,n,m,c)}catch(v){let S=v.message;return T.error(`Task execution failed: ${S}`,v),i.onEvent?.({type:"error",error:S,recoverable:!1}),wu(p,S,n,m,c)}}async function Os(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 du(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 uu(e,t,i,n,a){let{messages:o}=e.getMessages(),r=0;for(let d of o)Array.isArray(d.content)&&(r+=d.content.filter(u=>u.type==="image").length);let s=Fo(),l=3,c=Math.max(0,Math.min(i,t.length-1));for(let d=c;d<t.length;d++){let u=t[d],p=d===t.length-1,m=be(u,r),y=Te(u,n.temperature);try{for(let g=0;g<l;g++){let{system:w,messages:h}=e.getMessages(),b={model:ye(u),system:w,messages:h,providerOptions:m};y!==void 0&&(b.temperature=y);let v=new AbortController,S=s>0?setTimeout(()=>v.abort(),s):void 0,E=Ho(n.abortSignal,s>0?v.signal:void 0);E&&(b.abortSignal=E);let $;try{let Y=Date.now();d===c?T.log(`Calling LLM (${u})...`):T.log(`Calling LLM (${u}) [fallback ${d}/${t.length-1}]...`),$=await(0,Ns.generateText)(b);let ge=Date.now()-Y;T.llmCall(u,ge,$.usage)}finally{S&&clearTimeout(S)}let O=$,D=O.usage,I=O.reasoningText;I&&(T.thinking(I),n.onEvent?.({type:"thinking",text:I})),e.addAssistantMessage($.text);let W={systemPrompt:w,userPrompt:du(h),rawLlmResponse:$.text,reasoningContent:I,screenshotWithSom:a},K=[],ee=cu(D,u);ee&&K.push(ee);let B=hu($.text);if(!B){if(g<l-1){T.log(`Attempt ${g+1}/${l}: 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.");continue}return T.error("All parsing attempts failed"),{stepOutput:null,debugInfo:W,tokenUsages:K,modelIndexUsed:d}}return{stepOutput:B,debugInfo:W,tokenUsages:K,modelIndexUsed:d}}}catch(g){if(n.abortSignal?.aborted)throw g;if(!p&&sa(g)){T.log(`Model "${u}" failed (${g.message}); falling back to "${t[d+1]}"`);continue}throw T.error("All LLM call attempts failed",g),g}}return{stepOutput:null}}function hu(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 T.error("Missing required field: current_goal"),null;if(!i.actions||!Array.isArray(i.actions)||i.actions.length===0)return T.error("Missing required field: actions (must be non-empty array)"),null;for(let n of i.actions){if(!n.action_name)return T.error("Action missing required field: action_name"),null;if(!n.description)return T.error("Action missing required field: description"),null}return i}catch(i){return T.error(`Failed to parse LLM JSON response: ${t.substring(0,500)}`),T.error(`Parse error: ${i.message}`),null}}async function mu(e,t,i,n,a,o,r){let s=[],l=!0,c=null;T.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 m of e.actions){if(m.action_name==="done"){d={success:m.kwargs.success??!0,summary:m.kwargs.summary||m.kwargs.text||"Task completed"};break}let y={},g=m.kwargs?.element_index??m.kwargs?.index;if(typeof g=="number"){let h=i.selectorMap.get(g);h&&(y=await j(t.page,h))}let w={...y,action_description:m.description,action_data:{action_name:m.action_name,kwargs:m.kwargs}};try{let h=await X.execute(m.action_name,m.kwargs,u);m.action_name==="perform_accurate_operation"&&(w=h.actionEntity);let b=await u.agentServices.getCurrentPage();if(b&&(u.page=b,t.page=u.page),h?.success===!1){l=!1,T.log("Action failed, stopping execution of remaining actions in this step"),c=h.error||"Action execution failed";break}s.push(w),a?.({type:"action",action_entity:w,step:n,debugInfo:r})}catch(h){l=!1,c=h.message,T.error(`Action execution failed: ${h.message}`);break}}return{allSuccess:l,failReason:c,actionEntities:s,doneResult:d,completesInstruction:e.completes_instruction??!1}}function pu(e,t,i,n,a,o,r){let s={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 l=t.memory.trim();n.memory.includes(l)||(n.memory.push(l),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(s),s}function gu(e,t,i){if(T.log(`Step ${e}/${t}`),i.thinking&&T.log(`Thinking: ${i.thinking}`),i.evaluation_previous_goal&&T.log(`Evaluation: ${i.evaluation_previous_goal}`),i.memory&&T.log(`Memory: ${i.memory}`),T.log(`Goal: ${i.current_goal}`),i.actions.length===1){let n=i.actions[0];T.log(`Action: ${n.action_name}(${JSON.stringify(n.kwargs)}) - ${n.description}`)}else T.log(`Actions (${i.actions.length}):`),i.actions.forEach((n,a)=>{T.log(` ${a+1}. ${n.action_name}(${JSON.stringify(n.kwargs)}) - ${n.description}`)})}function fu(e,t,i,n,a,o,r){let s=o.reduce((d,u)=>d+u.prompt_tokens,0),l=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:s,completionTokens:l,totalTokens:c,tokenUsages:o}}}function wu(e,t,i,n,a){let o=n.reduce((l,c)=>l+c.prompt_tokens,0),r=n.reduce((l,c)=>l+c.completion_tokens,0),s=n.reduce((l,c)=>l+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(l=>l.outcome.success).length,failedSteps:e.stepHistory.filter(l=>!l.outcome.success).length,promptTokens:o,completionTokens:r,totalTokens:s,tokenUsages:n}}}var Ns,Ds=x(()=>{"use strict";Ka();Rn();Re();Ae();Ke();re();xe();Q();Me();Ns=require("ai")});var Rs={};Qe(Rs,{TaskMessageManager:()=>Fn,formatFinalStepWarning:()=>Ps,formatTaskContext:()=>Ln,getBrowserTaskJSONPrompt:()=>Dn,runTaskLoop:()=>Ls});var Fs=x(()=>{"use strict";Ds();Ka();Rn();Re();Ae();cn();Ke();Rt();ct();Ft();Ht();Ut();re();xe();$t();it();Mt();De();tt();Q();je();Me();mt();z();ae();jt();G();Se()});async function Bt(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(X.has(i)){let a=await X.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 yu()).execute(a,e,o),{success:!0,error:void 0}}}catch(i){return{success:!1,error:i.message}}}async function yu(){if(Hn)return Hn;let e=await Promise.resolve().then(()=>(Nn(),On));return Hn=new e.default,Hn}async function dn(e,t,i,n={},a){let o=a||{page:t,agentServices:i,domService:new Fe(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},r=i.replaceVariables(e),s=await pa(r,o,n);return s.status==="error"?{status:"error",completed:s.goalAccomplished||!1,actionEntities:[],explanation:s.reasoning,error:s.error,debugInfo:s.debugInfo}:{status:"success",completed:s.goalAccomplished||!1,actionEntities:s.actionEntity?[s.actionEntity]:[],explanation:s.reasoning,debugInfo:s.debugInfo}}async function un(e,t,i,n={},a){let o=a||{page:t,agentServices:i,domService:new Fe(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},r=i.replaceVariables(e),s=await pa(r,o,n);if(s.status==="error"||!s.actionEntity)return{status:"error",completed:s.goalAccomplished||!1,actionEntities:[],explanation:s.reasoning,error:s.error||"No action generated",debugInfo:s.debugInfo};let{actionEntity:l,reasoning:c,goalAccomplished:d,debugInfo:u}=s,p=await Bt(l,o);return p.success?(c&&i.addNote(c),{status:"success",completed:d||!1,actionEntities:[l],explanation:c,debugInfo:u}):{status:"error",completed:!1,actionEntities:[l],error:p.error||"Action execution failed",debugInfo:u}}async function hn(e,t,i,n={}){let a={page:t,agentServices:i,domService:new Fe(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},o=i.replaceVariables(e);return n.useCleanScreenshotForAssertion??(n.useCleanScreenshotForAssertion=i.isUseCleanScreenshotForAssertion()),Qo(o,a,n)}async function mn(e,t,i,n,a={}){let{runTaskLoop:o}=await Promise.resolve().then(()=>(Fs(),Rs)),r=n?l=>{n(l)}:void 0,s=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:s.success?"success":"error",completed:s.completed,actionEntities:s.trajectory.actions,explanation:s.summary,error:s.error,tokenUsages:s.metadata.tokenUsages}}var Hn,Gt=x(()=>{"use strict";Zi();Ae();Ke();Hn=null});var Ya=x(()=>{"use strict";re();Me()});var ll=x(()=>{"use strict"});var cl=x(()=>{"use strict"});var dl=x(()=>{"use strict"});var Un=x(()=>{"use strict"});var k,ul,Qa,hl,xt,ml,pl,gl,le,fl,jn,eo,to=x(()=>{"use strict";k=require("zod"),ul=k.z.enum(["JS_CODE","AI_MODE"]),Qa=k.z.object({type:ul,expression:k.z.string()}),hl=k.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),xt=k.z.object({uid:k.z.string(),type:hl,comment:k.z.string().optional()}),ml=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(),pl=xt.extend({type:k.z.literal("DRAFT"),description:k.z.string()}),gl=xt.extend({type:k.z.literal("ACTION"),description:k.z.string(),action_entity:ml.optional(),locator:k.z.string().optional(),use_pure_vision:k.z.boolean().optional()}),le=k.z.lazy(()=>k.z.union([pl,gl,xt.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()}),xt.extend({type:k.z.literal("IF_ELSE"),description:k.z.string().optional(),condition:Qa,then:k.z.array(le),else:k.z.array(le).optional()}),xt.extend({type:k.z.literal("WHILE_LOOP"),description:k.z.string().optional(),condition:Qa,body:k.z.array(le),timeout_ms:k.z.number().optional()})])),fl=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()}),jn=k.z.object({tests:k.z.array(fl).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()}),eo=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:jn.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 Bn(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 no(e,t){if(e.testGroup)return vl(e,t);let i=Bn(e,t),n=new H.Document(i),a=n.contents?.get("tags",!0);return(0,H.isSeq)(a)&&(a.flow=!0),e.comment&&(n.commentBefore=e.comment),wl(n,e.statements??[]),e.teardown&&wl(n,e.teardown,"teardown"),n.toString(xl)}function wl(e,t,i="statements"){let n=e.contents;if(!n||!(0,H.isMap)(n))return;let a=n.get(i,!0);(0,H.isSeq)(a)&&Ai(a,t)}function Ai(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,H.isMap)(a)){let o=a;if(n.type==="STEP"){let r=o.get("statements",!0);(0,H.isSeq)(r)&&Ai(r,n.statements)}else if(n.type==="IF_ELSE"){let r=o.get("THEN",!0);(0,H.isSeq)(r)&&Ai(r,n.then);let s=o.get("ELSE",!0);(0,H.isSeq)(s)&&n.else&&Ai(s,n.else)}else if(n.type==="WHILE_LOOP"){let r=o.get("DO",!0);(0,H.isSeq)(r)&&Ai(r,n.body)}}}}function vl(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(s=>{let l={name:s.name};return s.skip!==void 0&&(l.skip=s.skip),s.timeout!==void 0&&(l.timeout=s.timeout),s.fail!==void 0&&(l.fail=s.fail),s.only!==void 0&&(l.only=s.only),s.slow!==void 0&&(l.slow=s.slow),l.statements=s.statements.map(me),s.teardown&&s.teardown.length>0&&(l.teardown=s.teardown.map(me)),l}),n.suite=a;let o=new H.Document(n),r=o.contents?.get("tags",!0);return(0,H.isSeq)(r)&&(r.flow=!0),o.toString(xl)}function me(e){switch(e.type){case"DRAFT":return Fu(e);case"ACTION":return Hu(e);case"STEP":return Wu(e);case"IF_ELSE":return Uu(e);case"WHILE_LOOP":return ju(e)}}function Fu(e){return{intent:e.description}}function Hu(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 s=i?.statement;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let l=i?.code;return typeof l=="string"&&l.trim()?{VERIFY:s,js:l}:{VERIFY:s}}}if(t==="go_to_url"){let s=i?.url;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let l={URL:s};return i?.new_tab===!0&&(l.new_tab=!0),typeof i?.timeout_seconds=="number"&&(l.timeout_seconds=i.timeout_seconds),l}}if(t==="js_action"){let s=i?.code;if(typeof s=="string"&&s.trim()&&e.description)return{description:e.description,js:s}}if(t==="ai_wait_until"){let s=i?.condition;if(typeof s=="string"){let l=i?.condition_type==="JS_CODE"?"JS_CODE":"AI_MODE",c={WAIT_UNTIL:ao({type:l,expression:s})};return typeof i?.timeout_seconds=="number"&&i.timeout_seconds!==60&&(c.timeout_seconds=i.timeout_seconds),c}}if(t==="wait"){let s=i?.seconds,c={WAIT:e.description||`Wait ${s}s`};return typeof s=="number"&&(c.seconds=s),c}if(t==="js_code"){let s=i?.code;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath)return{description:e.description||"Code block",js:s}}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[s,l]of Object.entries(n.kwargs))s!=="uid"&&(s==="statement"&&(t==="ai_action"||t==="ai_step")||(a[s]=l));return n.args&&n.args.length>0&&(a.args=n.args),a}function Wu(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 Uu(e){let t={IF:ao(e.condition),THEN:e.then.map(me)};return e.else&&e.else.length>0&&(t.ELSE=e.else.map(me)),t}function ju(e){let t={WHILE:ao(e.condition),DO:e.body.map(me)};return e.timeout_ms!==void 0&&(t.timeout_ms=e.timeout_ms),t}function ao(e){return e.type==="JS_CODE"?`js:${e.expression}`:e.expression}function oo(e){try{let t=(0,H.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 io(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(io);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]=io(o);return n}function Ie(e){if(e.length>yl)throw new Error(`YAML input too large (${e.length} bytes, max ${yl})`);let t=io((0,H.parse)(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Bu(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=eo.safeParse(i);if(!n.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(n.error.errors)}`);let a=n.data;return Gn(e,a),a}function Bu(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(s=>{if(!s.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(s.statements)||s.statements.length===0)throw new Error(`Suite test "${s.name}" must have a non-empty "statements" array`);let l={name:s.name,statements:pe(s.statements)};return Array.isArray(s.teardown)&&s.teardown.length>0&&(l.teardown=pe(s.teardown)),s.skip!==void 0&&(l.skip=s.skip),typeof s.timeout=="number"&&(l.timeout=s.timeout),s.fail!==void 0&&(l.fail=s.fail),s.only===!0&&(l.only=!0),s.slow===!0&&(l.slow=!0),l})};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=jn.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(Gu)}function Gu(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 Ku(t);if("WHILE"in t)return zu(t);if("STEP"in t)return Vu(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=ro(typeof t.WAIT_UNTIL=="string"?t.WAIT_UNTIL:String(t.WAIT_UNTIL)),n=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;return{uid:(0,he.v4)(),type:"ACTION",description:`Wait until: ${i.expression}`,action_entity:{action_description:`Wait until: ${i.expression}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:i.expression,condition_type:i.type,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 bl({...n,action:"function",functionName:i})}if("action"in t)return bl(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 ro(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 Ku(e){let t=ro(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 zu(e){let t=ro(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 Vu(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 bl(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))Xu.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 s={action_description:i,action_data:{action_name:t,kwargs:Object.keys(r).length>0?r:{}}};n&&(s.locator=n),a&&(s.xpath=a);let l={uid:(0,he.v4)(),type:"ACTION",description:i,action_entity:s};return o&&(l.use_pure_vision=!0),l}function Gn(e,t){let i;try{i=(0,H.parseDocument)(e)}catch{return}let n=i.contents;if(!n||!(0,H.isMap)(n))return;if(i.commentBefore)t.comment=i.commentBefore;else{let l=n.items?.[0];l?.key&&l.key.commentBefore&&(t.comment=l.key.commentBefore)}let a=n,o=a.get("statements",!0);(0,H.isSeq)(o)&&t.statements&&vt(o,t.statements);let r=a.get("teardown",!0);(0,H.isSeq)(r)&&t.teardown&&vt(r,t.teardown)}function vt(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,H.isMap)(n)){let o=n.get("statements",!0);(0,H.isSeq)(o)&&vt(o,a.statements)}else if(a.type==="IF_ELSE"&&(0,H.isMap)(n)){let o=n.get("THEN",!0);(0,H.isSeq)(o)&&vt(o,a.then);let r=n.get("ELSE",!0);(0,H.isSeq)(r)&&a.else&&vt(r,a.else)}else if(a.type==="WHILE_LOOP"&&(0,H.isMap)(n)){let o=n.get("DO",!0);(0,H.isSeq)(o)&&vt(o,a.body)}}}var H,he,xl,yl,Xu,Kn=x(()=>{"use strict";to();H=require("yaml"),he=require("uuid");xl={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};yl=1024*1024;Xu=new Set(["action","intent","desc","locator","xpath","use_pure_vision"])});var _l=x(()=>{"use strict";Un();Kn()});var kl=x(()=>{"use strict";Un()});var qu,Sl=x(()=>{"use strict";qu=require("uuid")});var El,Tl=x(()=>{"use strict";Kn();El=require("yaml")});var Ve,Al=x(()=>{"use strict";Ve=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(Ve||{})});var zn=x(()=>{"use strict"});var $l=x(()=>{"use strict";zn()});var Ml=x(()=>{"use strict";zn()});var Il,eh,Cl,Pl,$i,th,ih,Ol=x(()=>{"use strict";Il=112,eh=1080-Il,Cl={"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"}},Pl={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"]},$i=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),Pl[e].map(n=>Cl[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},th={desktop:{label:"Desktop",type:"desktop",devices:$i("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:$i("mobile")}},ih={desktop:{label:"Desktop",type:"desktop",devices:$i("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:$i("mobile",!0)}}});var Nl=x(()=>{"use strict"});var Ll=x(()=>{"use strict"});var nh,Dl=x(()=>{"use strict";nh=Object.freeze(["anthropic:claude-sonnet-5","google:gemini-3.1-pro-preview"])});var Rl=x(()=>{"use strict"});var _t=x(()=>{"use strict";ll();cl();dl();_l();kl();Sl();Un();Tl();Kn();Al();to();$l();Ml();zn();Ol();Nl();Ll();Dl();Rl()});function sh(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function lh(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 Ul(e){let t=sh(e),i=e.locator;if(typeof i=="string"&&i.trim())return i=i.trim(),i.endsWith("first()")?`${t}.${i}`:`${t}.${i}.first()`;let n=lh(e);if(n){let a=JSON.stringify(n);return`${t}.locator(${a}).first()`}return null}function M(e,t){oe.set(e,t)}function Xe(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 so(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 Fl(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 Bl(e,t,i){let n={expandingPaths:new Set([(0,St.resolve)(t)]),depth:0,referencedPaths:new Set,basePath:i},a={...e};Array.isArray(a.statements)&&(a.statements=Ue(a.statements,t,n)),Array.isArray(a.teardown)&&(a.teardown=Ue(a.teardown,t,n));for(let o of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(a[o])&&(a[o]=Ue(a[o],t,n));return{doc:a,referencedTemplatePaths:Array.from(n.referencedPaths)}}function Ue(e,t,i){let n=[];for(let a of e)if(ch(a)){let o=dh(a,t,i);n.push(o)}else n.push(uh(a,t,i));return n}function ch(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function dh(e,t,i){if(i.depth>=Hl)throw new Error(`Template expansion exceeded maximum depth of ${Hl}. Check for deeply nested or circular template references.`);let n=(0,St.resolve)((0,St.dirname)(t),e.template),a=!(0,Xn.existsSync)(n)&&i.basePath?(0,St.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,Xn.readFileSync)(a,"utf-8")}catch(y){throw new Error(`Failed to read template file: ${a} (referenced from ${t}): ${y.message}`)}let r=(0,Mi.parse)(o);if(!r||typeof r!="object")throw new Error(`Invalid template file: ${a} \u2014 expected a YAML object`);let s=r.params||[],l=e.params||{};for(let y of s)if(!(y in l))throw new Error(`Template ${e.template} requires param "${y}" but it was not provided. Required params: [${s.join(", ")}]`);let c=r.statements;if(!Array.isArray(c))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(l).length>0){let g=(0,Mi.stringify)(c);for(let[w,h]of Object.entries(l))g=g.split(`<<${w}>>`).join(String(h));c=(0,Mi.parse)(g)}let d={expandingPaths:new Set([...i.expandingPaths,a]),depth:i.depth+1,referencedPaths:i.referencedPaths},u=Ue(c,a,d),m={STEP:r.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:u};return Object.keys(l).length>0&&(m.template_params=l),m}function uh(e,t,i){if(typeof e!="object"||e===null)return e;let n={...e};return Array.isArray(n.statements)&&(n.statements=Ue(n.statements,t,i)),Array.isArray(n.THEN)&&(n.THEN=Ue(n.THEN,t,i)),Array.isArray(n.ELSE)&&(n.ELSE=Ue(n.ELSE,t,i)),Array.isArray(n.DO)&&(n.DO=Ue(n.DO,t,i)),n}function Kl(e,t,i){let n=(0,Ii.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 Gl('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return mh(n,a,o,r,t,i)}return hh(n,a,o,r,t,i)}function hh(e,t,i,n,a,o){let r=e?.beforeEach,s=e?.afterEach,l=zl(e?.parameters),c=e?.timeout,d=e?.skip,u=e?.fail,p=e?.only,m=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 Gl(`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 y=[];if(a&&e&&typeof e=="object"){let h=Bl(e,a,o);e=h.doc,y=h.referencedTemplatePaths}let g=(0,Ii.stringify)(e),w=Ie(g);return a&&(kt(w.statements??[],a,"main"),w.teardown&&kt(w.teardown,a,"teardown")),{testFlow:w,name:t,tags:i,use:n,beforeEach:r,afterEach:s,parameters:l,timeout:c,skip:d,fail:u,only:p,slow:m,referencedTemplatePaths:y}}function mh(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 s=r.beforeAll,l=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 w={goal:g.name,statements:g.statements};g.teardown&&(w.teardown=g.teardown);let h=[],b=w;if(a&&typeof w=="object"){let $=Bl(w,a,o);b=$.doc,h=$.referencedTemplatePaths,u.push(...h)}let v=(0,Ii.stringify)(b),S=Ie(v),E=zl(g.parameters);return{testFlow:S,name:g.name,tags:Array.isArray(g.tags)?g.tags:void 0,parameters:E,timeout:g.timeout,skip:g.skip,fail:g.fail,only:g.only,slow:g.slow}}),m=r.base_url,y=m?{...n,baseURL:m}:n;return{suite:{beforeAll:s,afterAll:l,beforeEach:c,afterEach:d,tests:p},name:t,tags:i,use:y,referencedTemplatePaths:u}}function zl(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 kt(e,t,i){for(let n=0;n<e.length;n++){let a=e[n],o=`${i}.${n}`,r=a.description||"";if(a.uid=ph(t,o,r),a.type===Ve.STEP)kt(a.statements,t,o);else if(a.type===Ve.IF_ELSE){let s=a;kt(s.then,t,`${o}.then`),s.else&&kt(s.else,t,`${o}.else`)}else a.type===Ve.WHILE_LOOP&&kt(a.body,t,`${o}.body`)}}function ph(e,t,i){let n=(0,jl.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 rh,Vn,jl,Ii,Xn,St,Mi,Wl,oe,Hl,Gl,Vl=x(()=>{"use strict";_t();rh=require("yaml");_t();Vn=te(require("path"),1),jl=require("crypto"),Ii=require("yaml");_t();Xn=require("fs"),St=require("path"),Mi=require("yaml");_t();Wl=5e3;oe=new Map;M("click",e=>{let t=Ul(e);if(!t)return['await agent.execAction("click", page, {});'];let i=e.action_data?.kwargs?.timeout_ms??Wl;return[`await ${t}.click({ timeout: ${i} });`]});M("click_element",oe.get("click"));M("click_element_by_index",oe.get("click"));M("double_click",e=>Xe("double_click",e));M("double_click_on_element",oe.get("double_click"));M("right_click",e=>Xe("right_click",e));M("right_click_on_element",oe.get("right_click"));M("hover",e=>Xe("hover",e));M("hover_element_by_index",oe.get("hover"));M("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return Xe("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});M("fill",oe.get("input_text"));M("clear_input",e=>Xe("clear_input",e));M("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});M("send_keys",oe.get("press"));M("send_keys_on_element",e=>{let t=Ul(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??Wl;return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${n} });`]});M("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return Xe("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});M("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)})');`]});M("scroll_down",oe.get("scroll"));M("scroll_up",oe.get("scroll"));M("scroll_element",oe.get("scroll"));M("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});M("scroll_on_element",e=>Xe("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));M("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)} } },`,"});"]});M("open_tab",oe.get("go_to_url"));M("go_back",()=>['await agent.execAction("go_back", page, {});']);M("reload_page",()=>['await agent.execAction("reload_page", page, {});']);M("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);M("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);M("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(`
|
|
4303
|
+
`,n+='- In action descriptions, describe what the placeholder represents in natural language (e.g., "Type the first user name" instead of "Type {{ firstUserName }}")',n}}});function uu(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 Rs(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(),s=[r,...t.agentServices.getFallbackModels().filter(v=>v!==r)],l=0,c=r,d=t.domService||new Fe(t.agentServices.getDomServiceOptions()),u={...t,domService:d};T.init(),T.section("Task Execution Started"),T.log(`Task: ${e}`),T.log(`Max steps: ${a}`),T.log(`Model: ${s.length>1?s.join(" \u2192 "):r}`);let m={currentStep:0,maxSteps:a,consecutiveFailures:0,maxFailures:o,lastFailReason:null,stepHistory:[],memory:[],lastGoal:null,lastEvaluation:null},p=[],w=Dn(i.customPrompt),g=new Fn(w);T.log(`System prompt length: ${w.length} chars`);let y=!1,h="",b=[];try{for(i.onEvent?.({type:"start",task:e,maxSteps:a});m.currentStep<a;){if(i.abortSignal?.aborted)throw new Error("Task aborted by user");m.currentStep++;let v=Date.now();T.section(`Step ${m.currentStep}/${a}`),T.log(`URL: ${u.page.url()}`),i.onEvent?.({type:"step_start",step:m.currentStep});try{T.log("Waiting for page to stabilize..."),await pt(u.page),T.log("Page stabilized")}catch{T.log("Page stabilization timed out, continuing anyway")}let S;try{T.log("Preparing context (DOM + screenshot)...");let W=u.agentServices.getInteractiveClassNames(),z=u.agentServices.getIframeFallbackDomains();S=await Ls(u.page,u.domService,W,z),T.log("Context prepared")}catch(W){if(W.message.includes("Execution context was destroyed")){T.log("Page navigating, waiting for load..."),await pt(u.page);let z=u.agentServices.getInteractiveClassNames(),ee=u.agentServices.getIframeFallbackDomains();S=await Ls(u.page,u.domService,z,ee)}else throw T.error("Error preparing context",W),W}g.addStateMessage(e,S.currentUrl,S.domTree,S.screenshotBase64,m,{isFinalStep:m.currentStep===a-1,placeholderData:t.variables,sensitiveKeys:t.sensitiveKeys});let E=await mu(g,s,l,i,S.screenshotBase64);if(typeof E.modelIndexUsed=="number"&&(l=E.modelIndexUsed,c=s[E.modelIndexUsed]??c),E.tokenUsages&&E.tokenUsages.length>0&&p.push(...E.tokenUsages),!E.stepOutput){if(T.error("Failed to get valid LLM response"),m.consecutiveFailures++,m.consecutiveFailures>=o){h="Reached the maximum allowed consecutive failures. Most recent error: Unable to get a valid response from the language model.";break}continue}let $=E.stepOutput;wu(m.currentStep,a,$);let N=await gu($,u,S.domState,m.currentStep,i.onEvent,S.screenshotBase64,E.debugInfo);b.push(...N.actionEntities);let D=fu(m.currentStep,$,N,m,v,E.debugInfo,E.tokenUsages),I=Date.now()-v;if(i.onEvent?.({type:"step_complete",step:m.currentStep,duration:I}),m.consecutiveFailures>=o){T.error(`Too many consecutive failures (${m.consecutiveFailures}), stopping`),h=`Reached the maximum allowed consecutive failures. Most recent error: ${m.lastFailReason}`;break}if(N.doneResult){y=N.doneResult.success,h=N.doneResult.summary;break}if(N.completesInstruction){y=!0,h="Instruction completed";break}}return m.currentStep>=a&&!y&&(h="Reached the maximum allowed steps."),i.onEvent?.({type:"complete",totalSteps:m.currentStep,duration:Date.now()-n}),T.log(`Build success result: summary=${h}, completed=${y}, actions=${b.length}, tokens=${p.length}`),yu(m,b,y,h,n,p,c)}catch(v){let S=v.message;return T.error(`Task execution failed: ${S}`,v),i.onEvent?.({type:"error",error:S,recoverable:!1}),bu(m,S,n,p,c)}}async function Ls(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 hu(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 mu(e,t,i,n,a){let{messages:o}=e.getMessages(),r=0;for(let d of o)Array.isArray(d.content)&&(r+=d.content.filter(u=>u.type==="image").length);let s=Ho(),l=3,c=Math.max(0,Math.min(i,t.length-1));for(let d=c;d<t.length;d++){let u=t[d],m=d===t.length-1,p=be(u,r),w=Te(u,n.temperature);try{for(let g=0;g<l;g++){let{system:y,messages:h}=e.getMessages(),b={model:ye(u),system:y,messages:h,providerOptions:p};w!==void 0&&(b.temperature=w);let v=new AbortController,S=s>0?setTimeout(()=>v.abort(),s):void 0,E=Wo(n.abortSignal,s>0?v.signal:void 0);E&&(b.abortSignal=E);let $;try{let Y=Date.now();d===c?T.log(`Calling LLM (${u})...`):T.log(`Calling LLM (${u}) [fallback ${d}/${t.length-1}]...`),$=await(0,Ds.generateText)(b);let ge=Date.now()-Y;T.llmCall(u,ge,$.usage)}finally{S&&clearTimeout(S)}let N=$,D=N.usage,I=N.reasoningText;I&&(T.thinking(I),n.onEvent?.({type:"thinking",text:I})),e.addAssistantMessage($.text);let W={systemPrompt:y,userPrompt:hu(h),rawLlmResponse:$.text,reasoningContent:I,screenshotWithSom:a},z=[],ee=uu(D,u);ee&&z.push(ee);let B=pu($.text);if(!B){if(g<l-1){T.log(`Attempt ${g+1}/${l}: 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.");continue}return T.error("All parsing attempts failed"),{stepOutput:null,debugInfo:W,tokenUsages:z,modelIndexUsed:d}}return{stepOutput:B,debugInfo:W,tokenUsages:z,modelIndexUsed:d}}}catch(g){if(n.abortSignal?.aborted)throw g;if(!m&&sa(g)){T.log(`Model "${u}" failed (${g.message}); falling back to "${t[d+1]}"`);continue}throw T.error("All LLM call attempts failed",g),g}}return{stepOutput:null}}function pu(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 T.error("Missing required field: current_goal"),null;if(!i.actions||!Array.isArray(i.actions)||i.actions.length===0)return T.error("Missing required field: actions (must be non-empty array)"),null;for(let n of i.actions){if(!n.action_name)return T.error("Action missing required field: action_name"),null;if(!n.description)return T.error("Action missing required field: description"),null}return i}catch(i){return T.error(`Failed to parse LLM JSON response: ${t.substring(0,500)}`),T.error(`Parse error: ${i.message}`),null}}async function gu(e,t,i,n,a,o,r){let s=[],l=!0,c=null;T.log(`Using pre-captured DOM state with ${i.selectorMap.size} elements for ${e.actions.length} action(s)`);let d=null,u={...t,domState:i},m=o;for(let p of e.actions){if(p.action_name==="done"){d={success:p.kwargs.success??!0,summary:p.kwargs.summary||p.kwargs.text||"Task completed"};break}let w={},g=p.kwargs?.element_index??p.kwargs?.index;if(typeof g=="number"){let h=i.selectorMap.get(g);h&&(w=await U(t.page,h))}let y={...w,action_description:p.description,action_data:{action_name:p.action_name,kwargs:p.kwargs}};try{let h=await X.execute(p.action_name,p.kwargs,u);p.action_name==="perform_accurate_operation"&&(y=h.actionEntity);let b=await u.agentServices.getCurrentPage();if(b&&(u.page=b,t.page=u.page),h?.success===!1){l=!1,T.log("Action failed, stopping execution of remaining actions in this step"),c=h.error||"Action execution failed";break}s.push(y),a?.({type:"action",action_entity:y,step:n,debugInfo:r})}catch(h){l=!1,c=h.message,T.error(`Action execution failed: ${h.message}`);break}}return{allSuccess:l,failReason:c,actionEntities:s,doneResult:d,completesInstruction:e.completes_instruction??!1}}function fu(e,t,i,n,a,o,r){let s={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 l=t.memory.trim();n.memory.includes(l)||(n.memory.push(l),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(s),s}function wu(e,t,i){if(T.log(`Step ${e}/${t}`),i.thinking&&T.log(`Thinking: ${i.thinking}`),i.evaluation_previous_goal&&T.log(`Evaluation: ${i.evaluation_previous_goal}`),i.memory&&T.log(`Memory: ${i.memory}`),T.log(`Goal: ${i.current_goal}`),i.actions.length===1){let n=i.actions[0];T.log(`Action: ${n.action_name}(${JSON.stringify(n.kwargs)}) - ${n.description}`)}else T.log(`Actions (${i.actions.length}):`),i.actions.forEach((n,a)=>{T.log(` ${a+1}. ${n.action_name}(${JSON.stringify(n.kwargs)}) - ${n.description}`)})}function yu(e,t,i,n,a,o,r){let s=o.reduce((d,u)=>d+u.prompt_tokens,0),l=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:s,completionTokens:l,totalTokens:c,tokenUsages:o}}}function bu(e,t,i,n,a){let o=n.reduce((l,c)=>l+c.prompt_tokens,0),r=n.reduce((l,c)=>l+c.completion_tokens,0),s=n.reduce((l,c)=>l+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(l=>l.outcome.success).length,failedSteps:e.stepHistory.filter(l=>!l.outcome.success).length,promptTokens:o,completionTokens:r,totalTokens:s,tokenUsages:n}}}var Ds,Fs=x(()=>{"use strict";za();Rn();Re();Ae();Ke();re();xe();Q();Me();Ds=require("ai")});var Hs={};Qe(Hs,{TaskMessageManager:()=>Fn,formatFinalStepWarning:()=>Os,formatTaskContext:()=>Ln,getBrowserTaskJSONPrompt:()=>Dn,runTaskLoop:()=>Rs});var Ws=x(()=>{"use strict";Fs();za();Rn();Re();Ae();cn();Ke();Rt();ct();Ft();Ht();jt();re();xe();$t();it();Mt();De();tt();Q();Ue();Me();mt();G();ae();Ut();K();Se()});async function Bt(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(X.has(i)){let a=await X.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 xu()).execute(a,e,o),{success:!0,error:void 0}}}catch(i){return{success:!1,error:i.message}}}async function xu(){if(Hn)return Hn;let e=await Promise.resolve().then(()=>(On(),Nn));return Hn=new e.default,Hn}async function dn(e,t,i,n={},a){let o=a||{page:t,agentServices:i,domService:new Fe(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},r=i.replaceVariables(e),s=await pa(r,o,n);return s.status==="error"?{status:"error",completed:s.goalAccomplished||!1,actionEntities:[],explanation:s.reasoning,error:s.error,debugInfo:s.debugInfo}:{status:"success",completed:s.goalAccomplished||!1,actionEntities:s.actionEntity?[s.actionEntity]:[],explanation:s.reasoning,debugInfo:s.debugInfo}}async function un(e,t,i,n={},a){let o=a||{page:t,agentServices:i,domService:new Fe(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},r=i.replaceVariables(e),s=await pa(r,o,n);if(s.status==="error"||!s.actionEntity)return{status:"error",completed:s.goalAccomplished||!1,actionEntities:[],explanation:s.reasoning,error:s.error||"No action generated",debugInfo:s.debugInfo};let{actionEntity:l,reasoning:c,goalAccomplished:d,debugInfo:u}=s,m=await Bt(l,o);return m.success?(c&&i.addNote(c),{status:"success",completed:d||!1,actionEntities:[l],explanation:c,debugInfo:u}):{status:"error",completed:!1,actionEntities:[l],error:m.error||"Action execution failed",debugInfo:u}}async function hn(e,t,i,n={}){let a={page:t,agentServices:i,domService:new Fe(i.getDomServiceOptions()),executionHistory:n.executionHistory,variables:n.variables,sensitiveKeys:n.sensitiveKeys},o=i.replaceVariables(e);return n.useCleanScreenshotForAssertion??(n.useCleanScreenshotForAssertion=i.isUseCleanScreenshotForAssertion()),er(o,a,n)}async function mn(e,t,i,n,a={}){let{runTaskLoop:o}=await Promise.resolve().then(()=>(Ws(),Hs)),r=n?l=>{n(l)}:void 0,s=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:s.success?"success":"error",completed:s.completed,actionEntities:s.trajectory.actions,explanation:s.summary,error:s.error,tokenUsages:s.metadata.tokenUsages}}var Hn,Gt=x(()=>{"use strict";Zi();Ae();Ke();Hn=null});var qa=x(()=>{"use strict";re();Me()});var dl=x(()=>{"use strict"});var ul=x(()=>{"use strict"});var hl=x(()=>{"use strict"});var jn=x(()=>{"use strict"});var k,ml,eo,pl,xt,gl,fl,wl,le,yl,Un,to,io=x(()=>{"use strict";k=require("zod"),ml=k.z.enum(["JS_CODE","AI_MODE"]),eo=k.z.object({type:ml,expression:k.z.string()}),pl=k.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),xt=k.z.object({uid:k.z.string(),type:pl,comment:k.z.string().optional()}),gl=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(),fl=xt.extend({type:k.z.literal("DRAFT"),description:k.z.string()}),wl=xt.extend({type:k.z.literal("ACTION"),description:k.z.string(),action_entity:gl.optional(),locator:k.z.string().optional(),use_pure_vision:k.z.boolean().optional()}),le=k.z.lazy(()=>k.z.union([fl,wl,xt.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()}),xt.extend({type:k.z.literal("IF_ELSE"),description:k.z.string().optional(),condition:eo,then:k.z.array(le),else:k.z.array(le).optional()}),xt.extend({type:k.z.literal("WHILE_LOOP"),description:k.z.string().optional(),condition:eo,body:k.z.array(le),timeout_ms:k.z.number().optional()})])),yl=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()}),Un=k.z.object({tests:k.z.array(yl).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()}),to=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:Un.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 Bn(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 ao(e,t){if(e.testGroup)return kl(e,t);let i=Bn(e,t),n=new H.Document(i),a=n.contents?.get("tags",!0);return(0,H.isSeq)(a)&&(a.flow=!0),e.comment&&(n.commentBefore=e.comment),bl(n,e.statements??[]),e.teardown&&bl(n,e.teardown,"teardown"),n.toString(_l)}function bl(e,t,i="statements"){let n=e.contents;if(!n||!(0,H.isMap)(n))return;let a=n.get(i,!0);(0,H.isSeq)(a)&&Ai(a,t)}function Ai(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,H.isMap)(a)){let o=a;if(n.type==="STEP"){let r=o.get("statements",!0);(0,H.isSeq)(r)&&Ai(r,n.statements)}else if(n.type==="IF_ELSE"){let r=o.get("THEN",!0);(0,H.isSeq)(r)&&Ai(r,n.then);let s=o.get("ELSE",!0);(0,H.isSeq)(s)&&n.else&&Ai(s,n.else)}else if(n.type==="WHILE_LOOP"){let r=o.get("DO",!0);(0,H.isSeq)(r)&&Ai(r,n.body)}}}}function kl(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(s=>{let l={name:s.name};return s.skip!==void 0&&(l.skip=s.skip),s.timeout!==void 0&&(l.timeout=s.timeout),s.fail!==void 0&&(l.fail=s.fail),s.only!==void 0&&(l.only=s.only),s.slow!==void 0&&(l.slow=s.slow),l.statements=s.statements.map(me),s.teardown&&s.teardown.length>0&&(l.teardown=s.teardown.map(me)),l}),n.suite=a;let o=new H.Document(n),r=o.contents?.get("tags",!0);return(0,H.isSeq)(r)&&(r.flow=!0),o.toString(_l)}function me(e){switch(e.type){case"DRAFT":return Wu(e);case"ACTION":return ju(e);case"STEP":return Uu(e);case"IF_ELSE":return Bu(e);case"WHILE_LOOP":return Gu(e)}}function Wu(e){return{intent:e.description}}function ju(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 s=i?.statement;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let l=i?.code;return typeof l=="string"&&l.trim()?{VERIFY:s,js:l}:{VERIFY:s}}}if(t==="go_to_url"){let s=i?.url;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let l={URL:s};return i?.new_tab===!0&&(l.new_tab=!0),typeof i?.timeout_seconds=="number"&&(l.timeout_seconds=i.timeout_seconds),l}}if(t==="js_action"){let s=i?.code;if(typeof s=="string"&&s.trim()&&e.description)return{description:e.description,js:s}}if(t==="ai_wait_until"){let s=i?.condition;if(typeof s=="string"){let l=typeof i?.js=="string"&&i.js.trim()?i.js:void 0,c={};if(l)c.WAIT_UNTIL=s,c.js=l;else{let d=i?.condition_type==="JS_CODE"?"JS_CODE":"AI_MODE";c.WAIT_UNTIL=oo({type:d,expression:s})}return typeof i?.timeout_seconds=="number"&&i.timeout_seconds!==60&&(c.timeout_seconds=i.timeout_seconds),c}}if(t==="wait"){let s=i?.seconds,c={WAIT:e.description||`Wait ${s}s`};return typeof s=="number"&&(c.seconds=s),c}if(t==="js_code"){let s=i?.code;if(typeof s=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath)return{description:e.description||"Code block",js:s}}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[s,l]of Object.entries(n.kwargs))s!=="uid"&&(s==="statement"&&(t==="ai_action"||t==="ai_step")||(a[s]=l));return n.args&&n.args.length>0&&(a.args=n.args),a}function Uu(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 Bu(e){let t={IF:oo(e.condition),THEN:e.then.map(me)};return e.else&&e.else.length>0&&(t.ELSE=e.else.map(me)),t}function Gu(e){let t={WHILE:oo(e.condition),DO:e.body.map(me)};return e.timeout_ms!==void 0&&(t.timeout_ms=e.timeout_ms),t}function oo(e){return e.type==="JS_CODE"?`js:${e.expression}`:e.expression}function ro(e){try{let t=(0,H.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 no(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(no);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]=no(o);return n}function Ie(e){if(e.length>xl)throw new Error(`YAML input too large (${e.length} bytes, max ${xl})`);let t=no((0,H.parse)(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Ku(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=to.safeParse(i);if(!n.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(n.error.errors)}`);let a=n.data;return Gn(e,a),a}function Ku(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(s=>{if(!s.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(s.statements)||s.statements.length===0)throw new Error(`Suite test "${s.name}" must have a non-empty "statements" array`);let l={name:s.name,statements:pe(s.statements)};return Array.isArray(s.teardown)&&s.teardown.length>0&&(l.teardown=pe(s.teardown)),s.skip!==void 0&&(l.skip=s.skip),typeof s.timeout=="number"&&(l.timeout=s.timeout),s.fail!==void 0&&(l.fail=s.fail),s.only===!0&&(l.only=!0),s.slow===!0&&(l.slow=!0),l})};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=Un.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(zu)}function zu(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 Vu(t);if("WHILE"in t)return Xu(t);if("STEP"in t)return Ju(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,ce.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,ce.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=typeof t.WAIT_UNTIL=="string"?t.WAIT_UNTIL:String(t.WAIT_UNTIL),n=so(i),a=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;if(typeof t.js=="string"){if(n.type==="JS_CODE")throw new Error('WAIT_UNTIL cannot combine a "js:"-prefixed condition with a sibling "js:" key \u2014 put the intent in WAIT_UNTIL and the expression in js:');return{uid:(0,ce.v4)(),type:"ACTION",description:`Wait until: ${i}`,action_entity:{action_description:`Wait until: ${i}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:i,condition_type:"JS_CODE",js:t.js,timeout_seconds:a}}}}}return{uid:(0,ce.v4)(),type:"ACTION",description:`Wait until: ${n.expression}`,action_entity:{action_description:`Wait until: ${n.expression}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:n.expression,condition_type:n.type,timeout_seconds:a}}}}}if("WAIT"in t){let i=t.WAIT,n=typeof t.seconds=="number"?t.seconds:3;return{uid:(0,ce.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,ce.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,ce.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 vl({...n,action:"function",functionName:i})}if("action"in t)return vl(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:(0,ce.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 so(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 Vu(e){let t=so(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let n={uid:(0,ce.v4)(),type:"IF_ELSE",condition:t,then:pe(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(n.else=pe(e.ELSE)),n}function Xu(e){let t=so(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let n={uid:(0,ce.v4)(),type:"WHILE_LOOP",condition:t,body:pe(i)};return typeof e.timeout_ms=="number"&&(n.timeout_ms=e.timeout_ms),n}function Ju(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,ce.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 vl(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))Yu.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 s={action_description:i,action_data:{action_name:t,kwargs:Object.keys(r).length>0?r:{}}};n&&(s.locator=n),a&&(s.xpath=a);let l={uid:(0,ce.v4)(),type:"ACTION",description:i,action_entity:s};return o&&(l.use_pure_vision=!0),l}function Gn(e,t){let i;try{i=(0,H.parseDocument)(e)}catch{return}let n=i.contents;if(!n||!(0,H.isMap)(n))return;if(i.commentBefore)t.comment=i.commentBefore;else{let l=n.items?.[0];l?.key&&l.key.commentBefore&&(t.comment=l.key.commentBefore)}let a=n,o=a.get("statements",!0);(0,H.isSeq)(o)&&t.statements&&vt(o,t.statements);let r=a.get("teardown",!0);(0,H.isSeq)(r)&&t.teardown&&vt(r,t.teardown)}function vt(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,H.isMap)(n)){let o=n.get("statements",!0);(0,H.isSeq)(o)&&vt(o,a.statements)}else if(a.type==="IF_ELSE"&&(0,H.isMap)(n)){let o=n.get("THEN",!0);(0,H.isSeq)(o)&&vt(o,a.then);let r=n.get("ELSE",!0);(0,H.isSeq)(r)&&a.else&&vt(r,a.else)}else if(a.type==="WHILE_LOOP"&&(0,H.isMap)(n)){let o=n.get("DO",!0);(0,H.isSeq)(o)&&vt(o,a.body)}}}var H,ce,_l,xl,Yu,Kn=x(()=>{"use strict";io();H=require("yaml"),ce=require("uuid");_l={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};xl=1024*1024;Yu=new Set(["action","intent","desc","locator","xpath","use_pure_vision"])});var Sl=x(()=>{"use strict";jn();Kn()});var El=x(()=>{"use strict";jn()});var Qu,Tl=x(()=>{"use strict";Qu=require("uuid")});var Al,$l=x(()=>{"use strict";Kn();Al=require("yaml")});var Ve,Ml=x(()=>{"use strict";Ve=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(Ve||{})});var zn=x(()=>{"use strict"});var Il=x(()=>{"use strict";zn()});var Cl=x(()=>{"use strict";zn()});var Pl,ih,Nl,Ol,$i,nh,ah,Ll=x(()=>{"use strict";Pl=112,ih=1080-Pl,Nl={"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"}},Ol={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"]},$i=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),Ol[e].map(n=>Nl[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},nh={desktop:{label:"Desktop",type:"desktop",devices:$i("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:$i("mobile")}},ah={desktop:{label:"Desktop",type:"desktop",devices:$i("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:$i("mobile",!0)}}});var Dl=x(()=>{"use strict"});var Rl=x(()=>{"use strict"});var oh,Fl=x(()=>{"use strict";oh=Object.freeze(["anthropic:claude-sonnet-5","google:gemini-3.1-pro-preview"])});var Hl=x(()=>{"use strict"});var _t=x(()=>{"use strict";dl();ul();hl();Sl();El();Tl();jn();$l();Kn();Ml();io();Il();Cl();zn();Ll();Dl();Rl();Fl();Hl()});function ch(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function dh(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 Bl(e){let t=ch(e),i=e.locator;if(typeof i=="string"&&i.trim())return i=i.trim(),i.endsWith("first()")?`${t}.${i}`:`${t}.${i}.first()`;let n=dh(e);if(n){let a=JSON.stringify(n);return`${t}.locator(${a}).first()`}return null}function M(e,t){oe.set(e,t)}function Xe(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 lo(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 Wl(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 Kl(e,t,i){let n={expandingPaths:new Set([(0,St.resolve)(t)]),depth:0,referencedPaths:new Set,basePath:i},a={...e};Array.isArray(a.statements)&&(a.statements=je(a.statements,t,n)),Array.isArray(a.teardown)&&(a.teardown=je(a.teardown,t,n));for(let o of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(a[o])&&(a[o]=je(a[o],t,n));return{doc:a,referencedTemplatePaths:Array.from(n.referencedPaths)}}function je(e,t,i){let n=[];for(let a of e)if(uh(a)){let o=hh(a,t,i);n.push(o)}else n.push(mh(a,t,i));return n}function uh(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function hh(e,t,i){if(i.depth>=jl)throw new Error(`Template expansion exceeded maximum depth of ${jl}. Check for deeply nested or circular template references.`);let n=(0,St.resolve)((0,St.dirname)(t),e.template),a=!(0,Xn.existsSync)(n)&&i.basePath?(0,St.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,Xn.readFileSync)(a,"utf-8")}catch(w){throw new Error(`Failed to read template file: ${a} (referenced from ${t}): ${w.message}`)}let r=(0,Mi.parse)(o);if(!r||typeof r!="object")throw new Error(`Invalid template file: ${a} \u2014 expected a YAML object`);let s=r.params||[],l=e.params||{};for(let w of s)if(!(w in l))throw new Error(`Template ${e.template} requires param "${w}" but it was not provided. Required params: [${s.join(", ")}]`);let c=r.statements;if(!Array.isArray(c))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(l).length>0){let g=(0,Mi.stringify)(c);for(let[y,h]of Object.entries(l))g=g.split(`<<${y}>>`).join(String(h));c=(0,Mi.parse)(g)}let d={expandingPaths:new Set([...i.expandingPaths,a]),depth:i.depth+1,referencedPaths:i.referencedPaths},u=je(c,a,d),p={STEP:r.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:u};return Object.keys(l).length>0&&(p.template_params=l),p}function mh(e,t,i){if(typeof e!="object"||e===null)return e;let n={...e};return Array.isArray(n.statements)&&(n.statements=je(n.statements,t,i)),Array.isArray(n.THEN)&&(n.THEN=je(n.THEN,t,i)),Array.isArray(n.ELSE)&&(n.ELSE=je(n.ELSE,t,i)),Array.isArray(n.DO)&&(n.DO=je(n.DO,t,i)),n}function Vl(e,t,i){let n=(0,Ii.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 zl('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return gh(n,a,o,r,t,i)}return ph(n,a,o,r,t,i)}function ph(e,t,i,n,a,o){let r=e?.beforeEach,s=e?.afterEach,l=Xl(e?.parameters),c=e?.timeout,d=e?.skip,u=e?.fail,m=e?.only,p=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 zl(`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 w=[];if(a&&e&&typeof e=="object"){let h=Kl(e,a,o);e=h.doc,w=h.referencedTemplatePaths}let g=(0,Ii.stringify)(e),y=Ie(g);return a&&(kt(y.statements??[],a,"main"),y.teardown&&kt(y.teardown,a,"teardown")),{testFlow:y,name:t,tags:i,use:n,beforeEach:r,afterEach:s,parameters:l,timeout:c,skip:d,fail:u,only:m,slow:p,referencedTemplatePaths:w}}function gh(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 s=r.beforeAll,l=r.afterAll,c=r.beforeEach,d=r.afterEach,u=[],m=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 h=[],b=y;if(a&&typeof y=="object"){let $=Kl(y,a,o);b=$.doc,h=$.referencedTemplatePaths,u.push(...h)}let v=(0,Ii.stringify)(b),S=Ie(v),E=Xl(g.parameters);return{testFlow:S,name:g.name,tags:Array.isArray(g.tags)?g.tags:void 0,parameters:E,timeout:g.timeout,skip:g.skip,fail:g.fail,only:g.only,slow:g.slow}}),p=r.base_url,w=p?{...n,baseURL:p}:n;return{suite:{beforeAll:s,afterAll:l,beforeEach:c,afterEach:d,tests:m},name:t,tags:i,use:w,referencedTemplatePaths:u}}function Xl(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 kt(e,t,i){for(let n=0;n<e.length;n++){let a=e[n],o=`${i}.${n}`,r=a.description||"";if(a.uid=fh(t,o,r),a.type===Ve.STEP)kt(a.statements,t,o);else if(a.type===Ve.IF_ELSE){let s=a;kt(s.then,t,`${o}.then`),s.else&&kt(s.else,t,`${o}.else`)}else a.type===Ve.WHILE_LOOP&&kt(a.body,t,`${o}.body`)}}function fh(e,t,i){let n=(0,Gl.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 lh,Vn,Gl,Ii,Xn,St,Mi,Ul,oe,jl,zl,Jl=x(()=>{"use strict";_t();lh=require("yaml");_t();Vn=te(require("path"),1),Gl=require("crypto"),Ii=require("yaml");_t();Xn=require("fs"),St=require("path"),Mi=require("yaml");_t();Ul=5e3;oe=new Map;M("click",e=>{let t=Bl(e);if(!t)return['await agent.execAction("click", page, {});'];let i=e.action_data?.kwargs?.timeout_ms??Ul;return[`await ${t}.click({ timeout: ${i} });`]});M("click_element",oe.get("click"));M("click_element_by_index",oe.get("click"));M("double_click",e=>Xe("double_click",e));M("double_click_on_element",oe.get("double_click"));M("right_click",e=>Xe("right_click",e));M("right_click_on_element",oe.get("right_click"));M("hover",e=>Xe("hover",e));M("hover_element_by_index",oe.get("hover"));M("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return Xe("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});M("fill",oe.get("input_text"));M("clear_input",e=>Xe("clear_input",e));M("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});M("send_keys",oe.get("press"));M("send_keys_on_element",e=>{let t=Bl(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??Ul;return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${n} });`]});M("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return Xe("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});M("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)})');`]});M("scroll_down",oe.get("scroll"));M("scroll_up",oe.get("scroll"));M("scroll_element",oe.get("scroll"));M("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});M("scroll_on_element",e=>Xe("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));M("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)} } },`,"});"]});M("open_tab",oe.get("go_to_url"));M("go_back",()=>['await agent.execAction("go_back", page, {});']);M("reload_page",()=>['await agent.execAction("reload_page", page, {});']);M("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);M("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);M("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(`
|
|
4304
4304
|
`),s=JSON.stringify(a);return["{ const _t = Date.now(); try {",...r.map(l=>` ${l}`),` console.log(\`[VERIFY:JS] \u2713 \${((Date.now()-_t)/1000).toFixed(1)}s: ${s}\`);`,"} 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: ${s}\`);`,` await agent.assert(page, ${s}, ${JSON.stringify(t||"")});`,"} }"]}return n?i.code.split(`
|
|
4305
|
-
`):a?[`await agent.assert(page, ${JSON.stringify(a)}, ${JSON.stringify(t||"")});`]:["// Skipping verify: missing statement or code"]});M("ai_assert",oe.get("verify"));M("assert",oe.get("verify"));M("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});`]});M("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"]});M("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||""}');`]});M("ai_wait_until",(e,t)=>{let i=e.action_data?.kwargs?.condition,n=e.action_data?.kwargs?.timeout_seconds||60;return
|
|
4306
|
-
`);for(let a of n)i.push(` ${a}`);return i.push("}"),i});M("function",(e,t,i)=>{let n=e.action_data?.kwargs||{},a=n.functionName;if(a&&a.includes("#")){let[r,s]=a.split("#");if(r&&s){let l=r.replace(/\.(ts|js|mjs)$/,"");if(Vn.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(!l.startsWith(".")&&i?.projectRoot&&i?.yamlDir){let
|
|
4307
|
-
`):["// Skipping js_action: missing code"]});Hl=5;Gl=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}}});var Yl={};Qe(Yl,{createTestFlowRouter:()=>fh});function Ci(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:Ci(t.statements)}:t.type==="IF_ELSE"?{...t,then:Ci(t.then),...t.else?{else:Ci(t.else)}:{}}:t.type==="WHILE_LOOP"?{...t,body:Ci(t.body)}:t})}function Je(e){if(!e||e.length===0)return[];let i=(0,ce.stringify)({goal:"_hook",statements:e});return Ie(i).statements??[]}async function Jl(e){try{let t=await L.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 Jl(P.join(e,i.name))))return!0}catch{}return!1}function Jn(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 gh(e){let t=new Map,i;try{i=await L.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 L.readFile(a,"utf-8"))?.name??P.basename(n,".yaml");t.set(Jn(r),`templates/${n}`)}catch{}return t}function lo(e,t){if(Array.isArray(e))return e.map(o=>lo(o,t));if(!e||typeof e!="object")return e;let i=e,n={};for(let[o,r]of Object.entries(i))n[o]=lo(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 Yn(e){return Bn({statements:e}).statements}async function Pi(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 L.readFile(n,"utf-8"))??{};a.statements=Yn(i.statements),await L.writeFile(n,(0,ce.stringify)(a),"utf-8")}catch{}}await Pi(i.statements,t)}else i.type==="IF_ELSE"?(await Pi(i.then,t),i.else&&await Pi(i.else,t)):i.type==="WHILE_LOOP"&&await Pi(i.body,t)}function fh(e){let{initialDir:t,initialFile:i,projectRoot:n,onFileSelected:a}=e,o=(0,Xl.Router)();function r(){return P.join(n??t,"fixtures")}o.get("/api/files",async(l,c)=>{try{let d=typeof l.query.dir=="string"?l.query.dir:t,u=P.resolve(d),p=await L.readdir(u,{withFileTypes:!0}),m=[];for(let g of p)if(g.name!=="node_modules"&&!g.name.startsWith("."))if(g.isDirectory()){let w=P.join(u,g.name);await Jl(w)&&m.push({name:g.name,type:"directory",path:w})}else g.isFile()&&g.name.endsWith(".test.yaml")&&m.push({name:g.name,type:"file",path:P.join(u,g.name)});m.sort((g,w)=>g.type!==w.type?g.type==="directory"?-1:1:g.name.localeCompare(w.name));let y=P.dirname(u);c.json({dir:u,parent:y!==u?y:null,entries:m,initialFile:i??null,projectRoot:n??t})}catch(d){console.error("[debugger] Error listing files:",d),c.status(500).json({error:d.message})}});function s(l){if(typeof l=="string"&&l){let c=P.resolve(l);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(l,c)=>{let d=s(l.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=d.filePath;try{a?.(u);let p=await L.readFile(u,"utf-8"),m=await L.stat(u),y=oo(p),g=Kl(p,u,n);if(g.suite){let w=g.suite,h={tests:w.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:Je(w.beforeAll),afterAll:Je(w.afterAll),beforeEach:Je(w.beforeEach),afterEach:Je(w.afterEach)},b={version:"1.3.0",baseURL:g.use?.baseURL,testGroup:h};c.json({isSuite:!0,testFlow:b,metadata:y,name:g.name,tags:g.tags,use:g.use,filePath:u,fileName:P.basename(u),lastModified:m.mtimeMs})}else{let w=g.testFlow;Gn(p,w),c.json({isSuite:!1,testFlow:w,metadata:y,name:g.name,tags:g.tags,use:g.use,parameters:g.parameters,filePath:u,fileName:P.basename(u),lastModified:m.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(l,c)=>{try{let d=s(l.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=d.filePath,{testFlow:p,metadata:m}=l.body;if(!p)return c.status(400).json({error:"testFlow is required"});let y=P.join(n??t,"templates"),g=await gh(y),w=lo(p,g),h=Ci(w.statements??[]),b={...w,statements:h},v=n??t,S=[b.statements??[],b.teardown??[],...b.testGroup?.tests?.flatMap(D=>[D.statements,...D.teardown?[D.teardown]:[]])??[],...b.testGroup?.beforeEach?[b.testGroup.beforeEach]:[],...b.testGroup?.afterEach?[b.testGroup.afterEach]:[]];for(let D of S)await Pi(D,v);let E=no(b,m),$=u+".tmp";await L.writeFile($,E,"utf-8"),await L.rename($,u);let O=await L.stat(u);c.json({success:!0,lastModified:O.mtimeMs})}catch(d){console.error("[debugger] Error saving test flow:",d),c.status(500).json({error:d.message})}}),o.get("/api/fixtures",async(l,c)=>{try{let d=r();try{let p=(await L.readdir(d,{withFileTypes:!0})).filter(m=>m.isFile()).map(m=>m.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(l,c)=>{try{let d=r();await L.mkdir(d,{recursive:!0});let{name:u,content:p}=l.body;if(!u||!p)return c.status(400).json({error:"name and content are required"});let m=P.basename(u);if(!m)return c.status(400).json({error:"Invalid file name"});let y=P.join(d,m);await L.writeFile(y,Buffer.from(p,"base64")),c.json({fileName:m})}catch(d){console.error("[debugger] Error saving fixture:",d),c.status(500).json({error:d.message})}}),o.get("/api/functions",async(l,c)=>{let d=P.join(n??t,"helpers"),u;try{u=await L.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)),m=[],y=1;for(let g of p){let w=await L.readFile(P.join(d,g),"utf-8"),h=/export\s+async\s+function\s+(\w+)\s*(\([^)]*\))/g,b;for(;(b=h.exec(w))!==null;){let[,v,S]=b,E=S.replace(/\s*:\s*[^,)]+/g,"");m.push({id:y++,name:`helpers/${g}#${v}`,description:"",status:"Active",code:`async function ${v}${E} {}`})}}c.json(m)}),o.get("/api/reusable-steps",async(l,c)=>{let d=P.join(n??t,"templates"),u;try{u=await L.readdir(d)}catch(y){return y.code==="ENOENT"?c.json([]):(console.error("[debugger] Error reading templates dir:",y),c.status(500).json({error:y.message}))}let p=u.filter(y=>y.endsWith(".yaml")).sort(),m=[];for(let y of p)try{let g=await L.readFile(P.join(d,y),"utf-8"),w=(0,ce.parse)(g);if(!w||typeof w!="object")continue;let h=w.name??P.basename(y,".yaml"),b=w.description??"",v=Je(w.statements);m.push({id:Jn(h),organizationId:"local",name:h,description:b,statements:v})}catch(g){console.error(`[debugger] Error parsing template ${y}:`,g)}c.json(m)}),o.post("/api/reusable-steps/exists/:name",async(l,c)=>{let d=P.join(n??t,"templates"),u=decodeURIComponent(l.params.name).toLowerCase(),p;try{p=await L.readdir(d)}catch(m){return m.code==="ENOENT"?c.json(!1):c.status(500).json({error:m.message})}for(let m of p.filter(y=>y.endsWith(".yaml")))try{let y=await L.readFile(P.join(d,m),"utf-8");if(((0,ce.parse)(y)?.name??P.basename(m,".yaml")).toLowerCase()===u)return c.json(!0)}catch{}c.json(!1)}),o.post("/api/reusable-steps",async(l,c)=>{let d=P.join(n??t,"templates"),{reusableStep:u}=l.body??{};if(!u?.name||!Array.isArray(u.statements))return c.status(400).json({error:"reusableStep.name and reusableStep.statements are required"});await L.mkdir(d,{recursive:!0});let p=u.name.replace(/[/\\:*?"<>|]/g,"-").trim(),m=P.join(d,`${p}.yaml`),y={name:u.name,statements:Yn(u.statements)};u.description&&(y.description=u.description),await L.writeFile(m,(0,ce.stringify)(y),"utf-8"),c.json({id:Jn(u.name),organizationId:"local",name:u.name,description:u.description??"",statements:u.statements})}),o.put("/api/reusable-steps/:id/update",async(l,c)=>{let d=parseInt(l.params.id,10),u=P.join(n??t,"templates"),p;try{p=await L.readdir(u)}catch(m){return m.code==="ENOENT"?c.status(404).json({error:"Templates directory not found"}):c.status(500).json({error:m.message})}for(let m of p.filter(y=>y.endsWith(".yaml")))try{let y=P.join(u,m),g=(0,ce.parse)(await L.readFile(y,"utf-8"))??{},w=g.name??P.basename(m,".yaml");if(Jn(w)!==d)continue;let h=l.body??{};return h.description!==void 0&&(g.description=h.description),h.statements!==void 0&&(g.statements=Yn(h.statements)),await L.writeFile(y,(0,ce.stringify)(g),"utf-8"),c.json({id:d,organizationId:"local",...g,statements:h.statements!==void 0?h.statements:Je(g.statements)})}catch{}c.status(404).json({error:`Template with id ${d} not found`})}),o.put("/api/templates/:name",async(l,c)=>{let d=P.join(n??t,"templates"),u=decodeURIComponent(l.params.name),p;try{p=await L.readdir(d)}catch(m){return m.code==="ENOENT"?c.status(404).json({error:"Templates directory not found"}):c.status(500).json({error:m.message})}for(let m of p.filter(y=>y.endsWith(".yaml")))try{let y=P.join(d,m),g=(0,ce.parse)(await L.readFile(y,"utf-8"))??{};if((g.name??P.basename(m,".yaml"))!==u)continue;let h=l.body??{};return h.name!==void 0&&(g.name=h.name),h.description!==void 0&&(g.description=h.description),h.statements!==void 0&&(g.statements=Yn(h.statements)),await L.writeFile(y,(0,ce.stringify)(g),"utf-8"),c.json({organizationId:"local",...g,statements:h.statements!==void 0?h.statements:Je(g.statements)})}catch{}c.status(404).json({error:`Template "${u}" not found`})}),o.get("/api/test-results",async(l,c)=>{let d=s(l.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"),m=P.join(u,".shiplight","artifacts",p),y=[],g=null;try{let w=await L.readdir(m,{withFileTypes:!0});for(let h of w)if(h.isDirectory()){let b=P.join(m,h.name),v=await L.readdir(b);for(let S of v.filter(E=>/\.(png|jpe?g|webp)$/i.test(E))){let E=P.relative(m,P.join(b,S)),$=h.name.match(/^(.+?)_(before|after)$/),O=$?$[1]:h.name,D=$?$[2]:"screenshot";y.push({url:`/api/report-assets/${p}/${E}`,label:D,stepId:O})}}else/\.(webm|mp4)$/i.test(h.name)&&(g||(g=`/api/report-assets/${p}/${h.name}`));y.sort((h,b)=>h.stepId!==b.stepId?(h.stepId??"").localeCompare(b.stepId??""):h.label.localeCompare(b.label))}catch{}if(y.length===0&&!g)return c.status(404).json({error:"No test results found"});c.json({videoPath:g,screenshots:y})}),o}var Xl,L,P,ce,ql=x(()=>{"use strict";Xl=require("express"),L=te(require("fs/promises"),1),P=te(require("path"),1);_t();Vl();ce=require("yaml")});var Ql={};Qe(Ql,{createIntRunnerRouter:()=>wh});function wh(e){let t=(0,Zl.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:s,stmtUid:l,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:s,stmtUid:l,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: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 l=c=>{n.write(`data: ${JSON.stringify(c)}
|
|
4305
|
+
`):a?[`await agent.assert(page, ${JSON.stringify(a)}, ${JSON.stringify(t||"")});`]:["// Skipping verify: missing statement or code"]});M("ai_assert",oe.get("verify"));M("assert",oe.get("verify"));M("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});`]});M("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"]});M("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||""}');`]});M("ai_wait_until",(e,t)=>{let i=e.action_data?.kwargs?.condition,n=e.action_data?.kwargs?.timeout_seconds||60;if(!i)return["// Skipping ai_wait_until: missing condition"];if(e.action_data?.kwargs?.condition_type==="JS_CODE"){let o=e.action_data?.kwargs?.js,r=typeof o=="string"?o:i,s=typeof o=="string"?`, ${JSON.stringify(i)}`:"";return[`await agent.waitForJs(page, async () => (${r}), ${n}, '${t||""}'${s});`]}return[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${n}, '${t||""}');`]});M("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)} } },`,"});"]});M("js_code",e=>{let t=e.action_data?.kwargs?.code;if(!t)return["// Skipping js_code: missing code"];let i=["{"],n=t.split(`
|
|
4306
|
+
`);for(let a of n)i.push(` ${a}`);return i.push("}"),i});M("function",(e,t,i)=>{let n=e.action_data?.kwargs||{},a=n.functionName;if(a&&a.includes("#")){let[r,s]=a.split("#");if(r&&s){let l=r.replace(/\.(ts|js|mjs)$/,"");if(Vn.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(!l.startsWith(".")&&i?.projectRoot&&i?.yamlDir){let m=Vn.default.resolve(i.projectRoot,l),p=Vn.default.relative(i.yamlDir,m).replace(/\\/g,"/");l=p.startsWith("..")?p:"./"+p}let c=`import { ${s} } from '${l}';`;i?.imports?.add(c);let d={...n,functionName:s},u=Wl(d);return u?[u.endsWith(";")?u:`${u};`]:["// Skipping function: invalid export pattern"]}}let o=Wl(n);return o?[o.endsWith(";")?o:`${o};`]:["// Skipping function: missing functionName"]});M("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)} } },`,"});"]});M("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},`),"});"]});M("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} } },`,"});"]);M("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} } },`,"});"]);M("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} } },`,"});"]});M("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},`),"});"]});M("done",()=>["// Done - no action needed"]);M("click_by_coordinates",e=>lo("click_by_coordinates",e));M("right_click_by_coordinates",e=>lo("right_click_by_coordinates",e));M("double_click_by_coordinates",e=>lo("double_click_by_coordinates",e));M("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},`),"});"]});M("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},`),"});"]});M("extract_email_content",e=>{let t=e.action_data?.kwargs||{};return['await agent.execAction("extract_email_content", page, {',` action_data: { kwargs: ${JSON.stringify(t)} },`,"});"]});M("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
|
|
4307
|
+
`):["// Skipping js_action: missing code"]});jl=5;zl=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}}});var Zl={};Qe(Zl,{createTestFlowRouter:()=>yh});function Ci(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:Ci(t.statements)}:t.type==="IF_ELSE"?{...t,then:Ci(t.then),...t.else?{else:Ci(t.else)}:{}}:t.type==="WHILE_LOOP"?{...t,body:Ci(t.body)}:t})}function Je(e){if(!e||e.length===0)return[];let i=(0,de.stringify)({goal:"_hook",statements:e});return Ie(i).statements??[]}async function ql(e){try{let t=await L.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 ql(P.join(e,i.name))))return!0}catch{}return!1}function Jn(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 wh(e){let t=new Map,i;try{i=await L.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,de.parse)(await L.readFile(a,"utf-8"))?.name??P.basename(n,".yaml");t.set(Jn(r),`templates/${n}`)}catch{}return t}function co(e,t){if(Array.isArray(e))return e.map(o=>co(o,t));if(!e||typeof e!="object")return e;let i=e,n={};for(let[o,r]of Object.entries(i))n[o]=co(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 Yn(e){return Bn({statements:e}).statements}async function Pi(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,de.parse)(await L.readFile(n,"utf-8"))??{};a.statements=Yn(i.statements),await L.writeFile(n,(0,de.stringify)(a),"utf-8")}catch{}}await Pi(i.statements,t)}else i.type==="IF_ELSE"?(await Pi(i.then,t),i.else&&await Pi(i.else,t)):i.type==="WHILE_LOOP"&&await Pi(i.body,t)}function yh(e){let{initialDir:t,initialFile:i,projectRoot:n,onFileSelected:a}=e,o=(0,Yl.Router)();function r(){return P.join(n??t,"fixtures")}o.get("/api/files",async(l,c)=>{try{let d=typeof l.query.dir=="string"?l.query.dir:t,u=P.resolve(d),m=await L.readdir(u,{withFileTypes:!0}),p=[];for(let g of m)if(g.name!=="node_modules"&&!g.name.startsWith("."))if(g.isDirectory()){let y=P.join(u,g.name);await ql(y)&&p.push({name:g.name,type:"directory",path:y})}else g.isFile()&&g.name.endsWith(".test.yaml")&&p.push({name:g.name,type:"file",path:P.join(u,g.name)});p.sort((g,y)=>g.type!==y.type?g.type==="directory"?-1:1:g.name.localeCompare(y.name));let w=P.dirname(u);c.json({dir:u,parent:w!==u?w:null,entries:p,initialFile:i??null,projectRoot:n??t})}catch(d){console.error("[debugger] Error listing files:",d),c.status(500).json({error:d.message})}});function s(l){if(typeof l=="string"&&l){let c=P.resolve(l);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(l,c)=>{let d=s(l.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=d.filePath;try{a?.(u);let m=await L.readFile(u,"utf-8"),p=await L.stat(u),w=ro(m),g=Vl(m,u,n);if(g.suite){let y=g.suite,h={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:Je(y.beforeAll),afterAll:Je(y.afterAll),beforeEach:Je(y.beforeEach),afterEach:Je(y.afterEach)},b={version:"1.3.0",baseURL:g.use?.baseURL,testGroup:h};c.json({isSuite:!0,testFlow:b,metadata:w,name:g.name,tags:g.tags,use:g.use,filePath:u,fileName:P.basename(u),lastModified:p.mtimeMs})}else{let y=g.testFlow;Gn(m,y),c.json({isSuite:!1,testFlow:y,metadata:w,name:g.name,tags:g.tags,use:g.use,parameters:g.parameters,filePath:u,fileName:P.basename(u),lastModified:p.mtimeMs})}}catch(m){if(m.code==="ENOENT")return c.status(404).json({error:`File not found: ${u}`});console.error("[debugger] Error loading test flow:",m),c.status(500).json({error:m.message})}}),o.put("/api/test-flow",async(l,c)=>{try{let d=s(l.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=d.filePath,{testFlow:m,metadata:p}=l.body;if(!m)return c.status(400).json({error:"testFlow is required"});let w=P.join(n??t,"templates"),g=await wh(w),y=co(m,g),h=Ci(y.statements??[]),b={...y,statements:h},v=n??t,S=[b.statements??[],b.teardown??[],...b.testGroup?.tests?.flatMap(D=>[D.statements,...D.teardown?[D.teardown]:[]])??[],...b.testGroup?.beforeEach?[b.testGroup.beforeEach]:[],...b.testGroup?.afterEach?[b.testGroup.afterEach]:[]];for(let D of S)await Pi(D,v);let E=ao(b,p),$=u+".tmp";await L.writeFile($,E,"utf-8"),await L.rename($,u);let N=await L.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(l,c)=>{try{let d=r();try{let m=(await L.readdir(d,{withFileTypes:!0})).filter(p=>p.isFile()).map(p=>p.name).sort();c.json({files:m,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(l,c)=>{try{let d=r();await L.mkdir(d,{recursive:!0});let{name:u,content:m}=l.body;if(!u||!m)return c.status(400).json({error:"name and content are required"});let p=P.basename(u);if(!p)return c.status(400).json({error:"Invalid file name"});let w=P.join(d,p);await L.writeFile(w,Buffer.from(m,"base64")),c.json({fileName:p})}catch(d){console.error("[debugger] Error saving fixture:",d),c.status(500).json({error:d.message})}}),o.get("/api/functions",async(l,c)=>{let d=P.join(n??t,"helpers"),u;try{u=await L.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 m=u.filter(g=>/\.(ts|js|mjs)$/.test(g)),p=[],w=1;for(let g of m){let y=await L.readFile(P.join(d,g),"utf-8"),h=/export\s+async\s+function\s+(\w+)\s*(\([^)]*\))/g,b;for(;(b=h.exec(y))!==null;){let[,v,S]=b,E=S.replace(/\s*:\s*[^,)]+/g,"");p.push({id:w++,name:`helpers/${g}#${v}`,description:"",status:"Active",code:`async function ${v}${E} {}`})}}c.json(p)}),o.get("/api/reusable-steps",async(l,c)=>{let d=P.join(n??t,"templates"),u;try{u=await L.readdir(d)}catch(w){return w.code==="ENOENT"?c.json([]):(console.error("[debugger] Error reading templates dir:",w),c.status(500).json({error:w.message}))}let m=u.filter(w=>w.endsWith(".yaml")).sort(),p=[];for(let w of m)try{let g=await L.readFile(P.join(d,w),"utf-8"),y=(0,de.parse)(g);if(!y||typeof y!="object")continue;let h=y.name??P.basename(w,".yaml"),b=y.description??"",v=Je(y.statements);p.push({id:Jn(h),organizationId:"local",name:h,description:b,statements:v})}catch(g){console.error(`[debugger] Error parsing template ${w}:`,g)}c.json(p)}),o.post("/api/reusable-steps/exists/:name",async(l,c)=>{let d=P.join(n??t,"templates"),u=decodeURIComponent(l.params.name).toLowerCase(),m;try{m=await L.readdir(d)}catch(p){return p.code==="ENOENT"?c.json(!1):c.status(500).json({error:p.message})}for(let p of m.filter(w=>w.endsWith(".yaml")))try{let w=await L.readFile(P.join(d,p),"utf-8");if(((0,de.parse)(w)?.name??P.basename(p,".yaml")).toLowerCase()===u)return c.json(!0)}catch{}c.json(!1)}),o.post("/api/reusable-steps",async(l,c)=>{let d=P.join(n??t,"templates"),{reusableStep:u}=l.body??{};if(!u?.name||!Array.isArray(u.statements))return c.status(400).json({error:"reusableStep.name and reusableStep.statements are required"});await L.mkdir(d,{recursive:!0});let m=u.name.replace(/[/\\:*?"<>|]/g,"-").trim(),p=P.join(d,`${m}.yaml`),w={name:u.name,statements:Yn(u.statements)};u.description&&(w.description=u.description),await L.writeFile(p,(0,de.stringify)(w),"utf-8"),c.json({id:Jn(u.name),organizationId:"local",name:u.name,description:u.description??"",statements:u.statements})}),o.put("/api/reusable-steps/:id/update",async(l,c)=>{let d=parseInt(l.params.id,10),u=P.join(n??t,"templates"),m;try{m=await L.readdir(u)}catch(p){return p.code==="ENOENT"?c.status(404).json({error:"Templates directory not found"}):c.status(500).json({error:p.message})}for(let p of m.filter(w=>w.endsWith(".yaml")))try{let w=P.join(u,p),g=(0,de.parse)(await L.readFile(w,"utf-8"))??{},y=g.name??P.basename(p,".yaml");if(Jn(y)!==d)continue;let h=l.body??{};return h.description!==void 0&&(g.description=h.description),h.statements!==void 0&&(g.statements=Yn(h.statements)),await L.writeFile(w,(0,de.stringify)(g),"utf-8"),c.json({id:d,organizationId:"local",...g,statements:h.statements!==void 0?h.statements:Je(g.statements)})}catch{}c.status(404).json({error:`Template with id ${d} not found`})}),o.put("/api/templates/:name",async(l,c)=>{let d=P.join(n??t,"templates"),u=decodeURIComponent(l.params.name),m;try{m=await L.readdir(d)}catch(p){return p.code==="ENOENT"?c.status(404).json({error:"Templates directory not found"}):c.status(500).json({error:p.message})}for(let p of m.filter(w=>w.endsWith(".yaml")))try{let w=P.join(d,p),g=(0,de.parse)(await L.readFile(w,"utf-8"))??{};if((g.name??P.basename(p,".yaml"))!==u)continue;let h=l.body??{};return h.name!==void 0&&(g.name=h.name),h.description!==void 0&&(g.description=h.description),h.statements!==void 0&&(g.statements=Yn(h.statements)),await L.writeFile(w,(0,de.stringify)(g),"utf-8"),c.json({organizationId:"local",...g,statements:h.statements!==void 0?h.statements:Je(g.statements)})}catch{}c.status(404).json({error:`Template "${u}" not found`})}),o.get("/api/test-results",async(l,c)=>{let d=s(l.query.file);if("error"in d)return c.status(400).json({error:d.error});let u=n??t,m=P.basename(d.filePath,".test.yaml"),p=P.join(u,".shiplight","artifacts",m),w=[],g=null;try{let y=await L.readdir(p,{withFileTypes:!0});for(let h of y)if(h.isDirectory()){let b=P.join(p,h.name),v=await L.readdir(b);for(let S of v.filter(E=>/\.(png|jpe?g|webp)$/i.test(E))){let E=P.relative(p,P.join(b,S)),$=h.name.match(/^(.+?)_(before|after)$/),N=$?$[1]:h.name,D=$?$[2]:"screenshot";w.push({url:`/api/report-assets/${m}/${E}`,label:D,stepId:N})}}else/\.(webm|mp4)$/i.test(h.name)&&(g||(g=`/api/report-assets/${m}/${h.name}`));w.sort((h,b)=>h.stepId!==b.stepId?(h.stepId??"").localeCompare(b.stepId??""):h.label.localeCompare(b.label))}catch{}if(w.length===0&&!g)return c.status(404).json({error:"No test results found"});c.json({videoPath:g,screenshots:w})}),o}var Yl,L,P,de,Ql=x(()=>{"use strict";Yl=require("express"),L=te(require("fs/promises"),1),P=te(require("path"),1);_t();Jl();de=require("yaml")});var tc={};Qe(tc,{createIntRunnerRouter:()=>bh});function bh(e){let t=(0,ec.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:s,stmtUid:l,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:s,stmtUid:l,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: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 l=c=>{n.write(`data: ${JSON.stringify(c)}
|
|
4308
4308
|
|
|
4309
4309
|
`)};try{await e.runStep(a.sessionId,o,r,l,s)}catch(c){l({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:s,maxSteps: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 c=d=>{n.write(`data: ${JSON.stringify(d)}
|
|
4310
4310
|
|
|
4311
4311
|
`)};try{await e.runStep(a.sessionId,o,r,c,s)}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:s}=i.body;if(!a?.sessionId||!o)return n.status(400).json({status:"error",message:"Missing session or statement"});let l=await e.evaluate(a.sessionId,o,s);n.json(l)}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:s,usePureVision:l,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:s,usePureVision:l,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 l=o.split("/").pop()?.replace(/\.png$/,"");l&&(r=l)}let s=await e.takeScreenshot(a.sessionId,r);n.json({status:"success",...s})}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=s=>{n.write(`data: ${JSON.stringify(s)}
|
|
4312
4312
|
|
|
4313
|
-
`)};try{await e.startRecorder(a.sessionId,r,o)}catch(s){r({type:"error",data:{message:s.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
|
|
4313
|
+
`)};try{await e.startRecorder(a.sessionId,r,o)}catch(s){r({type:"error",data:{message:s.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 ec,ic=x(()=>{"use strict";ec=require("express")});var vh={};Qe(vh,{PlaywrightSandboxService:()=>yt,startPlaywrightDebugServer:()=>xh});module.exports=cc(vh);var qn=te(require("express"),1),Ni=te(require("path"),1);var se=te(require("path"),1),bt=te(require("fs/promises"),1),rl=require("url"),sl=te(require("os"),1),ll=require("yaml"),cl=require("@playwright/test");G();G();Gt();rt();var Va=require("zod"),vu=Va.z.object({instruction:Va.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 js(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:vu,usesElementIndex:!1,async execute(t,i){let{instruction:n}=t,a={page:i.page,agentServices:i.agentServices,domService:i.domService},o=await ot(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,s=await Bt(r,a);return{success:s.success,actionEntity:r,message:s.success?`Successfully executed action: ${r.action_data?.action_name}`:void 0,error:s.error}}})}xe();G();var Us=require("ai"),Bs=require("html-to-text");async function _u(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",s=e.authHeader||`Basic ${Buffer.from(`api:${n}`).toString("base64")}`,l=[];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 p=new Date(Date.now()-6e5);d.begin=Math.floor(p.getTime()/1e3).toString()}f.info(`Mailgun params: ${JSON.stringify(d)}`);let u=await fetch(c+"?"+new URLSearchParams(d),{method:"GET",headers:{Authorization:s}});if(!u.ok){let p=await u.text();throw new Error(`Mailgun events API error: ${p}`)}let m=(await u.json()).items||[];for(let p of m.slice(0,10)){if(p.event!=="accepted")continue;let w=(p.storage||{}).url;if(f.info(`message_url: ${w}`),!w){let h=(p.message||{}).headers||{},b=h.subject||"",v=h.from||"",S=h.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;l.push({subject:b,from:v,to:S,date:new Date(p.timestamp*1e3).toUTCString(),body:"Message body not available (Mailgun storage disabled)",message_id:h["message-id"]||""});continue}let g=w.split("/"),y=g[g.length-1];if(f.info(`Storage key: ${y}`),y){let h=o?`${r}/messages/${y}`:`${r}/v3/domains/${a}/messages/${y}`;try{let b=await fetch(h,{method:"GET",headers:{Authorization:s,Accept:"application/json"}});if(b.ok){let v=await b.json(),S=v.Subject||"",E=v.From||"",$=v.To||"",N=v.Date||"",D=v["Message-Id"]||"";f.info(`subject: ${S}`),f.info(`from_addr: ${E}`),f.info(`to_addr: ${$}`),f.info(`date: ${N}`),f.info(`message_id: ${D}`);let I=v["body-html"]||v["body-plain"]||"";if(I&&I.includes("<")&&(I=(0,Bs.convert)(I)),f.info(`Body: ${I.substring(0,200)}...`),i.from_email&&!E.toLowerCase().includes(i.from_email.toLowerCase())||i.to_email&&!$.toLowerCase().includes(i.to_email.toLowerCase())||i.subject&&!S.toLowerCase().includes(i.subject.toLowerCase())||i.body_contains&&!I.toLowerCase().includes(i.body_contains.toLowerCase()))continue;l.push({subject:S,from:E,to:$,date:N,body:I,message_id:D});continue}else f.warn(`Messages API returned ${b.status}`)}catch(b){f.warn(`Failed to parse JSON response: ${b}`)}}try{let h=await fetch(w,{method:"GET",headers:{Authorization:s}});if(!h.ok){f.warn(`Could not fetch stored message: ${h.status}`);continue}let b=await h.text();f.info(`Fallback: Raw email length: ${b.length}`);let v=b.split(`
|
|
4314
4314
|
`),S=!0,E={},$="";for(let ee=0;ee<v.length;ee++){let B=v[ee];if(B.trim()===""&&S){S=!1;continue}if(S){let Y=B.match(/^([^:]+):\s*(.+)$/);Y&&(E[Y[1].toLowerCase()]=Y[2])}else $+=B+`
|
|
4315
|
-
`}let
|
|
4315
|
+
`}let N=E.subject||"",D=E.from||"",I=E.to||"",W=E.date||"",z=E["message-id"]||"";if(i.from_email&&!D.toLowerCase().includes(i.from_email.toLowerCase())||i.to_email&&!I.toLowerCase().includes(i.to_email.toLowerCase())||i.subject&&!N.toLowerCase().includes(i.subject.toLowerCase())||i.body_contains&&!$.toLowerCase().includes(i.body_contains.toLowerCase()))continue;l.push({subject:N,from:D,to:I,date:W,body:$.trim(),message_id:z})}catch(h){f.warn(`Error fetching raw message: ${h}`)}}if(l.length>0){try{l.sort((w,g)=>{let y=new Date(w.date).getTime();return new Date(g.date).getTime()-y})}catch{}let p=l[0];return f.info(`Returning most recent email: ${p.subject}`),[p]}return l}catch(c){throw f.error(`Error fetching emails from Mailgun: ${c.message}`),new Error(`Error fetching emails from Mailgun: ${c.message}`)}}function ku(e,t){if(e==="verification_code")return`You are analyzing an email to extract an OTP (One-Time Password) or verification code.
|
|
4316
4316
|
|
|
4317
4317
|
Please carefully examine the email content and look for:
|
|
4318
4318
|
1. Numeric codes (usually 4-8 digits)
|
|
@@ -4369,27 +4369,27 @@ Examples of what to extract:
|
|
|
4369
4369
|
Extract: https://service.com/v/longtoken123456789abcdefghijklmnopqrstuvwxyz?param1=value1¶m2=value2
|
|
4370
4370
|
|
|
4371
4371
|
Return ONLY the complete extracted URL or "NOT_FOUND".`;if(e==="custom"){if(!t)throw new Error("Custom prompt is required when extraction_type is custom");return t+`
|
|
4372
|
-
Return only the required content or 'NOT_FOUND'.`}else throw new Error(`Unsupported extraction type: ${e}`)}async function
|
|
4372
|
+
Return only the required content or 'NOT_FOUND'.`}else throw new Error(`Unsupported extraction type: ${e}`)}async function Su(e,t,i){try{let n=`${t}
|
|
4373
4373
|
---
|
|
4374
4374
|
Email Content:
|
|
4375
4375
|
---
|
|
4376
4376
|
${e}
|
|
4377
4377
|
---
|
|
4378
|
-
`,a=ye(i),o=Te(i,void 0);return(await(0,
|
|
4378
|
+
`,a=ye(i),o=Te(i,void 0);return(await(0,Us.generateText)({model:a,messages:[{role:"user",content:n}],...o!==void 0?{temperature:o}:{},providerOptions:be(i,0)})).text.trim()||"NOT_FOUND"}catch(n){throw f.error(`Error in LLM extraction: ${n.message}`),new Error(`Error in LLM extraction: ${n.message}`)}}async function Gs(e,t){f.info(`extract_email_content:
|
|
4379
4379
|
forward_email: ${t.forward_email}
|
|
4380
4380
|
extraction_type: ${t.extraction_type}
|
|
4381
4381
|
filters: ${JSON.stringify(t.filters||{})}
|
|
4382
4382
|
timeout: ${t.timeout||60}
|
|
4383
|
-
polling_interval: 10`);let i=t.timeout||60,n=10;try{if(t.extraction_type==="custom"&&!t.prompt)return{data:void 0,status:"error",message:"Custom prompt is required when extraction_type is custom"};let a=
|
|
4384
|
-
From: ${
|
|
4385
|
-
To: ${
|
|
4386
|
-
Date: ${
|
|
4383
|
+
polling_interval: 10`);let i=t.timeout||60,n=10;try{if(t.extraction_type==="custom"&&!t.prompt)return{data:void 0,status:"error",message:"Custom prompt is required when extraction_type is custom"};let a=ku(t.extraction_type,t.prompt),o=new Date,r=new Date(o.getTime()+i*1e3),s=0;for(f.info(`Starting email polling for ${i} seconds with ${n}s intervals`);new Date<r;){s++,f.info(`Polling attempt ${s}`);try{let c=t.filters||{},d=await _u(e,t.forward_email,c);if(d.length>0){f.info(`Found ${d.length} emails matching criteria`);let u=[];for(let m of d){let p=`Subject: ${m.subject}
|
|
4384
|
+
From: ${m.from}
|
|
4385
|
+
To: ${m.to}
|
|
4386
|
+
Date: ${m.date}
|
|
4387
4387
|
|
|
4388
4388
|
Body:
|
|
4389
|
-
${
|
|
4390
|
-
`)){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
|
|
4391
|
-
`),s=parseInt(o,10);if(Number.isFinite(s)&&s>0&&typeof r=="string"&&r.startsWith("/"))return{port:s,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
|
|
4392
|
-
`),
|
|
4389
|
+
${m.body}`,w=await Su(p,a,t.model);f.info(`Extracted content: ${w}`),w&&w!=="NOT_FOUND"&&u.push({content:w,email_subject:m.subject,email_from:m.from,email_date:m.date})}if(u.length>0){let m=u[0],p=`$email_${t.extraction_type}`;t.extraction_type==="custom"?p="$email_extracted_content":t.extraction_type==="activation_link"?p="$email_magic_link":t.extraction_type==="verification_code"&&(p="$email_otp_code");let w=(new Date().getTime()-o.getTime())/1e3;return f.info(`Successfully extracted content after ${s} attempts in ${w.toFixed(1)} seconds`),{data:m.content,result_variable:p,status:"success",message:`Successfully extracted content from email: ${m.email_subject.substring(0,50)}... (attempts: ${s})`}}else f.info(`Found emails but no extractable content in attempt ${s}`)}else f.info(`No emails found in attempt ${s}`)}catch(c){f.warn(`Error in polling attempt ${s}: ${c.message}`)}if(new Date(Date.now()+n*1e3)>=r){f.info("Not enough time for another polling attempt");break}f.info(`Waiting ${n} seconds before next attempt...`),await new Promise(c=>setTimeout(c,n*1e3))}let l=(new Date().getTime()-o.getTime())/1e3;return{data:void 0,status:"error",message:`No emails with extractable content found after ${s} attempts over ${l.toFixed(1)} seconds`}}catch(a){return f.error(`Error extracting email content: ${a.message}`),{data:void 0,status:"error",message:`Error extracting email content: ${a.message}`}}}tt();G();ae();var ve=require("zod");function Ks(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 zs=class{getMailgunConfig(){let e=q().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=`${Be(t,e.SHIPLIGHT_API_URL)}/mailgun`;return f.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",s=await Gs(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(s.status==="success"&&s.data){let l=s.result_variable?.replace(/^\$/,"")||Ks(o.extraction_type);i.variableStore.set(l,s.data),f.info(`[extract_email_content] Extracted and saved to ${l}`)}else throw new Error(s.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 Vs(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:s,filter_to_email:l,filter_subject:c,filter_body_contains:d,timeout:u}=i,{page:m,agentServices:p}=n;f.info(`[extract_email_content] Extracting ${o} from ${a}`);try{let w={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:s,filter_to_email:l,filter_subject:c,filter_body_contains:d,timeout:u}}};await t.execute(m,w,p);let g=Ks(o);return{success:!0,actionEntity:w,message:`Extracted ${o} and saved to $${g}`}}catch(w){return{success:!1,error:w.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:s,filter_to_email:l,filter_subject:c,filter_body_contains:d,timeout:u}},feedback:w.message}}}}})}Kt();Vt();Xt();Jt();qt();Zt();ei();ti();ii();ai();ri();si();ci();di();ui();hi();mi();pi();gi();fi();yi();bi();xi();vi();_i();ki();Si();var Wn=null;async function _e(){if(Wn)return Wn;let e=(await Promise.resolve().then(()=>(On(),Nn))).default;return Wn=new e,Wn}async function Xs(e){let t=await _e(),i=t.getAction("click"),n=t.getAction("hover"),a=t.getAction("right_click"),o=t.getAction("double_click");return Ms(e,i),es(e,n),ls(e,a),ds(e,o),"Click, hover, double-click, right-click, or drag elements"}async function Js(e){let t=await _e(),i=t.getAction("go_to_url"),n=t.getAction("go_back"),a=t.getAction("reload_page");return bs(e,i),ys(e,n),rs(e,a),"Navigate to URLs, go back, or reload the page"}async function Ys(e){let t=await _e(),i=t.getAction("clear_input"),n=t.getAction("input_text"),a=t.getAction("press");return As(e,i),is(e,n),ns(e,a),"Type text into inputs, clear input values, or press keyboard keys"}async function qs(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),Vr(e,n),Ur(e,a),"Scroll the page or scroll to specific text/elements"}async function Zs(e){let t=await _e(),i=t.getAction("close_tab"),n=t.getAction("switch_tab");return Cs(e,i),kr(e,n),"Switch between browser tabs or close tabs"}async function Qs(e){let t=await _e(),i=t.getAction("upload_file"),n=t.getAction("wait_for_download_complete");return $r(e,i),Pr(e,n),"Upload files or wait for downloads to complete"}async function el(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 gs(e,i),Yr(e,n),Zr(e,a),"Get dropdown options, select dropdown values, or set date for native date picker input"}async function tl(e){let t=await _e(),i=t.getAction("wait"),n=t.getAction("save_variable"),a=t.getAction("done");return Ir(e,i),jr(e,n),Ns(e,a),js(e),"Wait for conditions, save variables, or complete tasks"}async function il(e){let t=(await _e()).getAction("generate_2fa_code");hs(e,t);let i=new zs;return(await Promise.resolve().then(()=>(On(),Nn))).default.registerAction("extract_email_content",i),Vs(e,i),"Generate 2FA codes or extract email/activation codes"}async function nl(e){let t=await _e(),i=t.getAction("verify"),n=t.getAction("ai_extract");return _s(e,i),Ss(e,n),Hr(e),"Perform AI-powered assertions, extractions, or wait conditions"}Ae();var Tu=[Xs(X),Js(X),Ys(X),qs(X),Zs(X),Qs(X),el(X),tl(X),nl(X),il(X)],Rv=Promise.all(Tu);Pt();We();Me();mt();G();var Xa=require("playwright");var Ja=require("child_process"),al=te(require("fs"),1),ol=te(require("path"),1);function Cu(){if(process.platform==="win32"){let i=(0,Ja.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,Ja.execFileSync)("ps",["-axo","pid=,ppid=,args="],{encoding:"utf-8"}),t=[];for(let i of e.split(`
|
|
4390
|
+
`)){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 Pu(e){let t=Cu(),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 Nu(e,t){let i=ol.join(e,"DevToolsActivePort"),n=Date.now()+t;for(;Date.now()<n;){try{let a=al.readFileSync(i,"utf-8").trim(),[o,r]=a.split(`
|
|
4391
|
+
`),s=parseInt(o,10);if(Number.isFinite(s)&&s>0&&typeof r=="string"&&r.startsWith("/"))return{port:s,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 Ya(e,t=3e4){let i=Pu(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 Nu(i,t);return`ws://127.0.0.1:${n}${a}`}We();var Ou=(e=>(e.Desktop="desktop",e.Mobile="mobile",e))(Ou||{});var Ti=(e=>(e.Started="started",e.Action="action",e.Completion="completion",e.Error="error",e.Aborted="aborted",e.Keepalive="keepalive",e))(Ti||{});Gt();Ke();qa();re();We();gt();Me();G();var Za=require("otplib"),v_=(0,Za.createGuardrails)({MIN_SECRET_BYTES:1});st();xe();var Du=require("ai"),E_=20*1024*1024;zt();We();gt();G();Gt();Zi();Yi();rt();Ui();Gi();Bi();et();zi();Re();Xi();Ot();Nt();Ae();Pt();cn();Ke();Rt();ct();Ft();Ht();jt();qa();re();st();xe();$t();it();Mt();De();tt();Ka();en();tn();nn();an();on();rn();sn();ln();pn();gn();fn();Kt();Vt();Xt();Jt();qt();Zt();ei();ti();ii();ai();ri();si();ci();di();ui();hi();mi();pi();gi();fi();yi();bi();dt();xi();vi();_i();ki();Si();En();zt();Q();Ue();We();gt();Me();mt();G();ae();Ut();Pn();K();Se();function Qa(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 Hu(e,t,i){let n=e.startsWith(".")?t:i??process.cwd();return se.resolve(n,e)}var yt=class{page;agent;testContext;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,o){this.page=t,this.agent=i,this.testContext=o,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 bt.readFile(t.testFilePath,"utf-8"),r=(0,ll.parse)(a)?.parameters;if(r&&r.length>0&&r[0].values)for(let[s,l]of Object.entries(r[0].values))this.agent.agentServices.saveVariable(s,l)}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 p=o.kwargs?.code?.match(/PLAYWRIGHT_STARTING_URL \|\| '([^']*)'/)?.[1];p&&await r.goto(p,{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 s=a?.stmtUid;s&&this.agent.getNewActionEntities().delete(s);let l;if(ze.isAiAction(i)){let g=new Ei().transpile(i,n,s).join(`
|
|
4392
|
+
`),y=new Function("page","agent",`return (async () => { ${g} })();`);try{await y(r,this.agent),l={actionGenerationDebugInfo:this.agent._getContext()?.lastActionDebugInfo}}catch(h){let b=this.agent._getContext();return{status:"error",details:this.agent.getAgentNote()||h.message,actionGenerationDebugInfo:b?.lastActionDebugInfo,testContext:Qa(b?.variableStore)}}}else{let p=i.action_description||o.action_name,w=!!a?.withSelfHealing&&ze.canSelfHeal(i);l=await this.agent.step(r,async()=>{await this.agent.execAction(o.action_name,r,i)},p,n,s,w)}let c=this.agent.getAgentNote(),u=this.agent._getContext()?.variableStore,m={...l,status:"success",testContext:Qa(u)};if(c&&(m.details=c),s){let p=this.agent.getNewActionEntities().get(s);if(p){let{element_index:w,...g}=p.action_data?.kwargs||{};m.newActionEntity={...p,action_data:p.action_data?{...p.action_data,kwargs:g}:p.action_data}}}return m}async runStep(t,i,n,a,o){let r=[];this.abortController=new AbortController;try{let s=await this.agent.run(this.agent.agentServices.validatePage(this.page),i,n,{onAction:c=>{r.push(c),a({type:Ti.Action,data:{action_entity:c}})}}),l=this.agent._getContext()?.variableStore;return a({type:Ti.Completion,data:{success:s?.success??!0,details:s?.details,testContext:Qa(l)}}),{success:s?.success??!0,actions:r,details:s?.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=Hu(n,this.testDir,this.projectRoot),s=(await import((0,rl.pathToFileURL)(o).href))[a];if(typeof s!="function")return{status:"error",details:`Export "${a}" not found or not a function in ${n}`};let c=s.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):[],m=Array.isArray(t.parameterValues)?t.parameterValues.map(String):Array.isArray(t.args)?t.args.map(String):[],p={};u.forEach((b,v)=>{let S=b.split(":")[0].trim();p[S]=m[v]??""});let w=["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.testContext;let v=p[b]??"";return v.startsWith("$")?this.agent.agentServices.readVariable(v.substring(1)):v}),h=d.length>0?y:m.map(b=>b==="page"?g:b==="agent"?this.agent:b==="request"?this.page.context().request:b==="testContext"?this.testContext:b.startsWith("$")?this.agent.agentServices.readVariable(b.substring(1)):b);return await s(...h),{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),cl.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 bt.mkdir(r,{recursive:!0}),o=se.join(r,"screenshot.png")}else o=se.join(sl.tmpdir(),`shiplight-screenshot-${Date.now()}.png`);return await bt.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(s=>{this.recorderStopResolver=s}),r={actionAdded:(s,l,c)=>{i({type:"actionAdded",action:l.action,code:c,timestamp:Date.now()})},actionUpdated:(s,l,c)=>{i({type:"actionUpdated",action:l.action,code:c,timestamp:Date.now()})},signalAdded:(s,l)=>{i({type:"signal",signal:l.signal,timestamp:Date.now()})}};if(this.recorderEnabled)a._onRecorderEventSink=r,await this.page.evaluate(()=>window.__pw_recorderSetMode?.("recording")).catch(()=>{});else{let s="x-pw-overlay { display: none !important; }";await a.addInitScript(`(() => {
|
|
4393
4393
|
const orig = Element.prototype.attachShadow;
|
|
4394
4394
|
Element.prototype.attachShadow = function(init) {
|
|
4395
4395
|
const shadow = orig.call(this, init);
|
|
@@ -4411,4 +4411,4 @@ ${p.body}`,y=await _u(m,a,t.model);f.info(`Extracted content: ${y}`),y&&y!=="NOT
|
|
|
4411
4411
|
}
|
|
4412
4412
|
return shadow;
|
|
4413
4413
|
};
|
|
4414
|
-
})()`).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
|
|
4414
|
+
})()`).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 xh(e){let{yamlFilePath:t,port:i,page:n,agent:a,testContext:o,projectRoot:r}=e,s=r??Ni.default.dirname(t),l=new yt(n,a,s,r,o);try{let g=await Ya(process.pid);l.setCdpEndpoint(g),console.error(`[debugger] CDP endpoint: ${g}`)}catch(g){console.error(`[debugger] Could not discover CDP endpoint: ${g.message}`)}let c=(0,qn.default)();c.use(qn.default.json({limit:"10mb"})),c.use((g,y,h)=>{if(y.setHeader("Access-Control-Allow-Origin","*"),y.setHeader("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS"),y.setHeader("Access-Control-Allow-Headers","Content-Type, Accept, Cache-Control, Idempotency-Key"),g.method==="OPTIONS")return y.sendStatus(204);h()});let{createTestFlowRouter:d}=await Promise.resolve().then(()=>(Ql(),Zl)),{createIntRunnerRouter:u}=await Promise.resolve().then(()=>(ic(),tc)),m=Ni.default.join(r??Ni.default.dirname(t),".shiplight","artifacts");c.use("/api/report-assets",qn.default.static(m)),c.use(d({initialDir:Ni.default.dirname(t),initialFile:t,projectRoot:r})),c.use(u(l));let p=await new Promise((g,y)=>{let h=c.listen(i,"127.0.0.1",()=>g(h));h.on("error",y)});return{url:`http://localhost:${i}`,close:async()=>{await l.cleanupAll(),await new Promise((g,y)=>{p.close(h=>h?y(h):g())})}}}0&&(module.exports={PlaywrightSandboxService,startPlaywrightDebugServer});
|