shiplightai 0.1.65 → 0.1.67

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.
@@ -133,17 +133,17 @@ To use them, write Jinja-like template syntax: {{ placeholder_name }}
133
133
  `}if(a&&a.length>0){let g=nu(a);p+=`
134
134
  `+g}return p+=`
135
135
  Based on the above information, please determine the right action to accomplish the task.
136
- `,d.push({type:"text",text:p}),d}var en=v(()=>{"use strict";Pt()});function tn(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 Ct=v(()=>{"use strict"});async function au(e){let t=e.context().pages(),i=null,a=[];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)}`),a.push(l)}let n=a.length>0?a.join(`
136
+ `,d.push({type:"text",text:p}),d}var en=v(()=>{"use strict";Pt()});async function au(e){let t=e.context().pages(),i=null,a=[];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)}`),a.push(l)}let n=a.length>0?a.join(`
137
137
  `):"";return{currentTabText:i!==null?`Current tab: ${i}
138
- `:"",tabsText:n}}async function ou(e,t){let{currentTabText:i,tabsText:a}=await au(e);return{elementsText:t,currentUrl:e.url(),currentTitle:await e.title(),currentTabText:i,tabsText:a}}async function nn(e,t){let{page:i,domService:a,agentServices:n}=e,o=typeof t=="boolean"?{useCleanScreenshot:t}:t||{},r=n.getInteractiveClassNames(),s=n.getIframeFallbackDomains(),{domState:l,screenshotBase64:c,slicedScreenshotsBase64:d}=await a.getClickableElementsWithScreenshot(i,{interactiveClassNames:r,playwrightFrameFallbackDomains:s,useCleanScreenshot:o.useCleanScreenshot,useSlicedScreenshots:o.useSlicedScreenshots,resizeSlicedScreenshots:o.resizeSlicedScreenshots,useAccessibilityTree:o.useAccessibilityTree,actionIntent:o.actionIntent}),h=l.elementTree.clickableElementsToString(),p=await ou(i,h);return d&&(p.slicedScreenshotsBase64=d),{domTree:h,screenshotBase64:c,slicedScreenshotsBase64:d,domState:l,pageContext:p}}var Ot=v(()=>{"use strict"});var de,Ma,W,Me=v(()=>{"use strict";de=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 a=this.tools.get(e);if(!a)throw new Error(`Tool not found: ${e}`);try{let n=t?.description,o={...t};delete o.description;let r=a.schema.parse(o),s={...i,actionDescription:n};return await a.execute(r,s)}catch(n){if(n instanceof de.z.ZodError){let o=n.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 n}}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),a=this.getTools().filter(n=>i.has(n.name));return this.buildUnionSchemaFromTools(a,t)}buildUnionSchemaFromTools(e,t=!1){if(e.length===0)return de.z.object({done:de.z.any()});let i=e.map(r=>{let s=r.schema;if(t&&s instanceof de.z.ZodObject){let l=s._def.shape();s=de.z.object({...l,description:de.z.string().describe("Semantic, human-readable description of the action")})}if(s instanceof de.z.ZodObject){let l=s._def.shape();Object.keys(l).length===0&&(s=de.z.object({_empty:de.z.boolean().optional()}))}return de.z.object({[r.name]:s})});if(i.length===1)return i[0];let[a,n,...o]=i;return de.z.union([a,n,...o])}},W=new Ma});async function U(e,t){if(t<0)return;let{page:i,domService:a}=e;return(e.domState||await a.getClickableElements(i)).selectorMap.get(t)}function ru(e){let t=e.split("/").filter(n=>n);if(t.length===0)return"*";let i=t[t.length-1],a=i.match(/^(\w+)(?:\[(\d+)\])?$/);if(a){let[,n,o]=a;return o?`${n}:nth-of-type(${o})`:n}return i}function su(e,t=!0){try{let i=ru(e.xpath);if(e.attributes.class&&t){let n=/^[a-zA-Z_][a-zA-Z0-9_-]*$/,o=e.attributes.class.split(/\s+/);for(let r of o)r.trim()&&n.test(r)&&(i+=`.${r}`)}let a=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(n=>a.add(n));for(let[n,o]of Object.entries(e.attributes)){if(n==="class"||!n.trim()||!a.has(n))continue;let r=n.replace(/:/g,"\\:");if(o==="")i+=`[${r}]`;else if(/["'<>`\n\r\t]/.test(o)){let s=o;o.includes(`
138
+ `:"",tabsText:n}}async function ou(e,t){let{currentTabText:i,tabsText:a}=await au(e);return{elementsText:t,currentUrl:e.url(),currentTitle:await e.title(),currentTabText:i,tabsText:a}}async function tn(e,t){let{page:i,domService:a,agentServices:n}=e,o=typeof t=="boolean"?{useCleanScreenshot:t}:t||{},r=n.getInteractiveClassNames(),s=n.getIframeFallbackDomains(),{domState:l,screenshotBase64:c,slicedScreenshotsBase64:d}=await a.getClickableElementsWithScreenshot(i,{interactiveClassNames:r,playwrightFrameFallbackDomains:s,useCleanScreenshot:o.useCleanScreenshot,useSlicedScreenshots:o.useSlicedScreenshots,resizeSlicedScreenshots:o.resizeSlicedScreenshots,useAccessibilityTree:o.useAccessibilityTree,actionIntent:o.actionIntent}),h=l.elementTree.clickableElementsToString(),p=await ou(i,h);return d&&(p.slicedScreenshotsBase64=d),{domTree:h,screenshotBase64:c,slicedScreenshotsBase64:d,domState:l,pageContext:p}}var Ct=v(()=>{"use strict"});function nn(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 Ot=v(()=>{"use strict"});var de,Ma,W,Me=v(()=>{"use strict";de=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 a=this.tools.get(e);if(!a)throw new Error(`Tool not found: ${e}`);try{let n=t?.description,o={...t};delete o.description;let r=a.schema.parse(o),s={...i,actionDescription:n};return await a.execute(r,s)}catch(n){if(n instanceof de.z.ZodError){let o=n.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 n}}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),a=this.getTools().filter(n=>i.has(n.name));return this.buildUnionSchemaFromTools(a,t)}buildUnionSchemaFromTools(e,t=!1){if(e.length===0)return de.z.object({done:de.z.any()});let i=e.map(r=>{let s=r.schema;if(t&&s instanceof de.z.ZodObject){let l=s._def.shape();s=de.z.object({...l,description:de.z.string().describe("Semantic, human-readable description of the action")})}if(s instanceof de.z.ZodObject){let l=s._def.shape();Object.keys(l).length===0&&(s=de.z.object({_empty:de.z.boolean().optional()}))}return de.z.object({[r.name]:s})});if(i.length===1)return i[0];let[a,n,...o]=i;return de.z.union([a,n,...o])}},W=new Ma});async function U(e,t){if(t<0)return;let{page:i,domService:a}=e;return(e.domState||await a.getClickableElements(i)).selectorMap.get(t)}function ru(e){let t=e.split("/").filter(n=>n);if(t.length===0)return"*";let i=t[t.length-1],a=i.match(/^(\w+)(?:\[(\d+)\])?$/);if(a){let[,n,o]=a;return o?`${n}:nth-of-type(${o})`:n}return i}function su(e,t=!0){try{let i=ru(e.xpath);if(e.attributes.class&&t){let n=/^[a-zA-Z_][a-zA-Z0-9_-]*$/,o=e.attributes.class.split(/\s+/);for(let r of o)r.trim()&&n.test(r)&&(i+=`.${r}`)}let a=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(n=>a.add(n));for(let[n,o]of Object.entries(e.attributes)){if(n==="class"||!n.trim()||!a.has(n))continue;let r=n.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 lu(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 su(e,!1)}function Jr(e){let t=[],i=e;for(;i&&i.parent!==null;){let o=i.parent;t.push(o),i=o}t.reverse();let a=[],n=t.filter(o=>o.tagName==="iframe");for(let o of n){let r=lu(o);u.debug("[frame-path] iframe attrs:",JSON.stringify(o.attributes),"\u2192",r),a.push(r)}return a}async function D(e,t){let i=null,a=Jr(t);return t.xpath&&(i=await _a(e,t.xpath,a,t.shadowHostXPaths??[])),{locator:i||void 0,xpath:i?void 0:t.xpath,frame_path:a}}var K=v(()=>{"use strict";Ge();F()});function cu(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 du(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 uu(e){return e.map(t=>({role:t.role,content:Array.isArray(t.content)?t.content.map(i=>{if(i.type==="image"){let a=i.image,n=du(a);if(n)return{type:"image",file:n};let o=typeof a=="string"?a:"";return{type:"image",file:o.startsWith("data:")?o:`data:image/png;base64,${o}`}}return{type:"text",text:i.text}}):t.content}))}async function qr(e,t,i={}){let{page:a,agentServices:n}=t,o=n.getModel(),r=i.temperature??0,s=n.retrieveKnowledges(e).catch(J=>(w.log(`Failed to retrieve knowledges: ${J.message}`),[])),l=n.isSlicedScreenshotsEnabled(),c=n.isResizeSlicedScreenshotsEnabled(),d=n.isKnowledgeImagesEnabled(),h=n.isAccessibilityTreeEnabled(),p=n.isActionIntentFilteringEnabled(),g=p?cu(e):"all";p&&g!=="all"&&w.log(`Action intent filtering: detected '${g}' intent from statement`);let{screenshotBase64:f,domState:y,pageContext:b}=await nn(t,{useSlicedScreenshots:l,resizeSlicedScreenshots:c,useAccessibilityTree:h,actionIntent:g});t.domState=y;let m=new ga(W).getToolDefinitions().map(J=>{let ze=J.function;return`${ze.name}: ${ze.description}
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 lu(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 su(e,!1)}function Jr(e){let t=[],i=e;for(;i&&i.parent!==null;){let o=i.parent;t.push(o),i=o}t.reverse();let a=[],n=t.filter(o=>o.tagName==="iframe");for(let o of n){let r=lu(o);u.debug("[frame-path] iframe attrs:",JSON.stringify(o.attributes),"\u2192",r),a.push(r)}return a}async function D(e,t){let i=null,a=Jr(t);return t.xpath&&(i=await _a(e,t.xpath,a,t.shadowHostXPaths??[])),{locator:i||void 0,xpath:i?void 0:t.xpath,frame_path:a}}var K=v(()=>{"use strict";Ge();F()});function cu(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 du(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 uu(e){return e.map(t=>({role:t.role,content:Array.isArray(t.content)?t.content.map(i=>{if(i.type==="image"){let a=i.image,n=du(a);if(n)return{type:"image",file:n};let o=typeof a=="string"?a:"";return{type:"image",file:o.startsWith("data:")?o:`data:image/png;base64,${o}`}}return{type:"text",text:i.text}}):t.content}))}async function qr(e,t,i={}){let{page:a,agentServices:n}=t,o=n.getModel(),r=i.temperature??0,s=n.retrieveKnowledges(e).catch(J=>(w.log(`Failed to retrieve knowledges: ${J.message}`),[])),l=n.isSlicedScreenshotsEnabled(),c=n.isResizeSlicedScreenshotsEnabled(),d=n.isKnowledgeImagesEnabled(),h=n.isAccessibilityTreeEnabled(),p=n.isActionIntentFilteringEnabled(),g=p?cu(e):"all";p&&g!=="all"&&w.log(`Action intent filtering: detected '${g}' intent from statement`);let{screenshotBase64:f,domState:y,pageContext:b}=await tn(t,{useSlicedScreenshots:l,resizeSlicedScreenshots:c,useAccessibilityTree:h,actionIntent:g});t.domState=y;let m=new ga(W).getToolDefinitions().map(J=>{let ze=J.function;return`${ze.name}: ${ze.description}
141
141
  Parameters: ${JSON.stringify(ze.parameters,null,2)}`}).join(`
142
142
 
143
- `),x=Xr(m),_=await s,E=Yr(b,e,t.variables,t.executionHistory,_.length>0?_:void 0,f,l,void 0,d,t.sensitiveKeys),A=[];i.chatHistory&&i.chatHistory.length>0&&i.chatHistory.forEach(J=>{J.role==="user"?A.push({role:"user",content:J.content}):J.role==="assistant"&&A.push({role:"assistant",content:J.content})}),A.push({role:"user",content:E});let $=uu(A),L=W.buildActionUnionSchema(),R=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:L,completes_instruction:Lt.z.boolean().describe("Whether this action completes the given instruction").optional().default(!0)}),C=Array.isArray(E)?E.filter(J=>J.type==="image").length:0,Y=Ae(o,C),ie=await(0,an.generateText)({model:Te(o),system:x,messages:A,temperature:r,output:an.Output.object({schema:R}),providerOptions:Y}),_e=ie.reasoningText;u.info(`Action Generation Reasoning: ${_e}`);let V=ie.output,q=JSON.stringify(V,null,2);u.info(`Generate Action Raw Output: ${q}`);let ke=[],We=tn(ie.usage,o);We&&ke.push(We);let Le={systemPrompt:x,userPrompt:$,rawLlmResponse:q,tokenUsages:ke},Ne=V.thought||"",De=V.description||"",B=V.action||{},Z=V.completes_instruction||!1;if(!B||Object.keys(B).length===0)return{status:"error",reasoning:Ne||De||"No action generated",goalAccomplished:Z,error:"Agent did not generate any action",debugInfo:Le};let Q=Object.keys(B)[0];if(Q==="done")return{status:"error",reasoning:Ne||De||"Task marked as done",goalAccomplished:Z,error:"Agent indicated task is done without generating an action",debugInfo:Le};if(Q==="perform_accurate_operation")return await it(e,t,i);if(!Z){let J="Can't complete the instruction in one action";return{status:"error",reasoning:Ne||De||J,goalAccomplished:!1,error:J,debugInfo:Le}}let he=B[Q]||{},bo={};if(typeof he.element_index=="number"){let J=he.element_index;if(J<0)return{status:"error",reasoning:Ne||De||"No action generated",goalAccomplished:Z,error:"Agent did not generate any action",debugInfo:Le};let ze=y.selectorMap.get(J);ze&&(bo=await D(a,ze))}let yo=De;return Q==="verify"&&(yo=e,he.statement=e),{status:"success",actionEntity:{...bo,action_description:yo||Ne||`${Q}(${JSON.stringify(he)})`,action_data:{action_name:Q,kwargs:he}},reasoning:Ne||De,goalAccomplished:Z,debugInfo:Le}}var an,Lt,on=v(()=>{"use strict";Ui();nt();en();Ct();Ot();Me();ae();$e();K();F();an=require("ai"),Lt=require("zod")});function hu(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 Ia(e,t,i={}){return i.usePureVision?it(e,t,i):qr(e,t,i)}function pu(){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 gu(){return`# Role
143
+ `),x=Xr(m),_=await s,E=Yr(b,e,t.variables,t.executionHistory,_.length>0?_:void 0,f,l,void 0,d,t.sensitiveKeys),A=[];i.chatHistory&&i.chatHistory.length>0&&i.chatHistory.forEach(J=>{J.role==="user"?A.push({role:"user",content:J.content}):J.role==="assistant"&&A.push({role:"assistant",content:J.content})}),A.push({role:"user",content:E});let $=uu(A),L=W.buildActionUnionSchema(),R=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:L,completes_instruction:Lt.z.boolean().describe("Whether this action completes the given instruction").optional().default(!0)}),C=Array.isArray(E)?E.filter(J=>J.type==="image").length:0,Y=Ae(o,C),ie=await(0,an.generateText)({model:Te(o),system:x,messages:A,temperature:r,output:an.Output.object({schema:R}),providerOptions:Y}),_e=ie.reasoningText;u.info(`Action Generation Reasoning: ${_e}`);let V=ie.output,q=JSON.stringify(V,null,2);u.info(`Generate Action Raw Output: ${q}`);let ke=[],We=nn(ie.usage,o);We&&ke.push(We);let Le={systemPrompt:x,userPrompt:$,rawLlmResponse:q,tokenUsages:ke},Ne=V.thought||"",De=V.description||"",B=V.action||{},Z=V.completes_instruction||!1;if(!B||Object.keys(B).length===0)return{status:"error",reasoning:Ne||De||"No action generated",goalAccomplished:Z,error:"Agent did not generate any action",debugInfo:Le};let Q=Object.keys(B)[0];if(Q==="done")return{status:"error",reasoning:Ne||De||"Task marked as done",goalAccomplished:Z,error:"Agent indicated task is done without generating an action",debugInfo:Le};if(Q==="perform_accurate_operation")return await it(e,t,i);if(!Z){let J="Can't complete the instruction in one action";return{status:"error",reasoning:Ne||De||J,goalAccomplished:!1,error:J,debugInfo:Le}}let he=B[Q]||{},bo={};if(typeof he.element_index=="number"){let J=he.element_index;if(J<0)return{status:"error",reasoning:Ne||De||"No action generated",goalAccomplished:Z,error:"Agent did not generate any action",debugInfo:Le};let ze=y.selectorMap.get(J);ze&&(bo=await D(a,ze))}let yo=De;return Q==="verify"&&(yo=e,he.statement=e),{status:"success",actionEntity:{...bo,action_description:yo||Ne||`${Q}(${JSON.stringify(he)})`,action_data:{action_name:Q,kwargs:he}},reasoning:Ne||De,goalAccomplished:Z,debugInfo:Le}}var an,Lt,on=v(()=>{"use strict";Ui();nt();en();Ct();Ot();Me();ae();$e();K();F();an=require("ai"),Lt=require("zod")});function hu(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 Ia(e,t,i={}){return i.usePureVision?it(e,t,i):qr(e,t,i)}function pu(){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 gu(){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 Zr(e,t,i={}){let{page:a,executionHistory:n}=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:h,slicedScreenshotsBase64:p,domState:g,pageContext:f}=await nn(t,{useCleanScreenshot:i.useCleanScreenshotForAssertion,useSlicedScreenshots:r,resizeSlicedScreenshots:s,useAccessibilityTree:c});t.domState=g;let y="";n&&n.length>0&&(y=`
146
+ `}async function Zr(e,t,i={}){let{page:a,executionHistory:n}=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:h,slicedScreenshotsBase64:p,domState:g,pageContext:f}=await tn(t,{useCleanScreenshot:i.useCleanScreenshotForAssertion,useSlicedScreenshots:r,resizeSlicedScreenshots:s,useAccessibilityTree:c});t.domState=g;let y="";n&&n.length>0&&(y=`
147
147
  # Previous actions in this session:
148
148
  ${n.map(([B,Z],Q)=>`${Q+1}. Action: ${B}
149
149
  Result: ${Z}`).join(`
@@ -177,7 +177,7 @@ ${y}
177
177
 
178
178
  Today is ${b}. Current local time is ${m}.
179
179
  Based on the above information, please determine if the statement is true.
180
- `,A=await t.agentServices.retrieveKnowledges(e),$=[{type:"text",text:x}],L=0;if(r&&p&&p.length>0)for(let B of p)$.push({type:"image",image:B}),L++;else $.push({type:"image",image:h}),L=1;if(A&&A.length>0){let B=Qi(A,l);$.push(...B)}$.push({type:"text",text:E});let R=A?Vr(A,l):0,C=L+R,Y=Ae(o,C),ie=gu(),_e=await(0,rn.generateText)({model:Te(o),system:ie,messages:[{role:"user",content:$}],output:rn.Output.object({schema:mu}),temperature:0,providerOptions:Y}),{conclusion:V,explanation:q}=_e.output,ke=JSON.stringify(_e.output,null,2),We=[],Le=tn(_e.usage,o);Le&&We.push(Le);let Ne=[{role:"user",content:$.map(B=>{if(B.type==="text")return{type:"text",text:B.text};if(B.type==="image"){let Z=B.image,Q=hu(Z);if(Q)return{type:"image",file:Q};let he=typeof Z=="string"?Z:"";return{type:"image",file:he.startsWith("data:")?he:`data:image/png;base64,${he}`}}return{type:"text",text:"[unknown content type]"}})}],De={systemPrompt:ie,userPrompt:Ne,rawLlmResponse:ke,screenshotWithSom:h,tokenUsages:We,retrievedKnowledges:A&&A.length>0?A:void 0,elementTree:d};return{success:V==="true",explanation:q,debugInfo:De}}catch(r){return{success:!1,error:r.message}}}var rn,Nt,mu,sn=v(()=>{"use strict";on();nt();Ct();Ot();Pt();$e();rn=require("ai"),Nt=require("zod");mu=Nt.z.object({screenshotDescription:Nt.z.string().describe(`Description of the screenshot content, listing out key elements along with their Set of Mark indices,
180
+ `,A=await t.agentServices.retrieveKnowledges(e),$=[{type:"text",text:x}],L=0;if(r&&p&&p.length>0)for(let B of p)$.push({type:"image",image:B}),L++;else $.push({type:"image",image:h}),L=1;if(A&&A.length>0){let B=Qi(A,l);$.push(...B)}$.push({type:"text",text:E});let R=A?Vr(A,l):0,C=L+R,Y=Ae(o,C),ie=gu(),_e=await(0,rn.generateText)({model:Te(o),system:ie,messages:[{role:"user",content:$}],output:rn.Output.object({schema:mu}),temperature:0,providerOptions:Y}),{conclusion:V,explanation:q}=_e.output,ke=JSON.stringify(_e.output,null,2),We=[],Le=nn(_e.usage,o);Le&&We.push(Le);let Ne=[{role:"user",content:$.map(B=>{if(B.type==="text")return{type:"text",text:B.text};if(B.type==="image"){let Z=B.image,Q=hu(Z);if(Q)return{type:"image",file:Q};let he=typeof Z=="string"?Z:"";return{type:"image",file:he.startsWith("data:")?he:`data:image/png;base64,${he}`}}return{type:"text",text:"[unknown content type]"}})}],De={systemPrompt:ie,userPrompt:Ne,rawLlmResponse:ke,screenshotWithSom:h,tokenUsages:We,retrievedKnowledges:A&&A.length>0?A:void 0,elementTree:d};return{success:V==="true",explanation:q,debugInfo:De}}catch(r){return{success:!1,error:r.message}}}var rn,Nt,mu,sn=v(()=>{"use strict";on();nt();Ct();Ot();Pt();$e();rn=require("ai"),Nt=require("zod");mu=Nt.z.object({screenshotDescription:Nt.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
183
  in the center of the screen`),explanation:Nt.z.string().describe("Step by step reasoning explaining your conclusion about the statement"),conclusion:Nt.z.enum(["true","false","unknown"]).describe("Whether the statement is true, false, or unknown if you cannot make a conclusion")})});async function es(){let{default:e}=await import("sharp");return e}async function Pa(e,t){let i=await es(),a=await i(e).metadata(),n=a.width||0,o=a.height||0;if(n===0||o===0)throw new Error("Invalid image dimensions");let r=o,s=0,l=Math.floor((n-r)/2),c=Math.max(0,n-r),d=(f,y)=>{let b=i(e).extract({left:f,top:0,width:y,height:r});return t?.resize&&(b=b.resize(Qr,Qr)),b.png().toBuffer()},[h,p,g]=await Promise.all([d(s,Math.min(r,n)),d(l,Math.min(r,n-l)),d(c,Math.min(r,n-c))]);return[h,p,g]}async function ts(e){let t=(await es())(e),i=await t.metadata(),a=i.width||0,n=i.height||0;if(a===0||n===0)throw new Error("Invalid image dimensions");let{data:o}=await t.grayscale().raw().toBuffer({resolveWithObject:!0}),r=[];for(let s=0;s<n;s++){r[s]=[];for(let l=0;l<a;l++)r[s][l]=o[s*a+l]}return{pixels:r,width:a,height:n}}var Qr,Dt=v(()=>{"use strict";Qr=768});var Ca,Oa,La,Na,Rt=v(()=>{"use strict";Ca=new Set(["button","link","textbox","checkbox","radio","combobox","listbox","menuitem","menuitemcheckbox","menuitemradio","option","tab","switch","slider","spinbutton","searchbox","scrollbar","treeitem","gridcell"]),Oa=new Set(["click","mousedown","mouseup","dblclick","pointerdown","pointerup","touchstart","touchend"]),La=["[onclick]","[onmousedown]","[ontouchstart]","div","span","li","tr","td","[role]",'[class*="btn"]','[class*="button"]','[class*="click"]',"[data-action]","[data-click]"],Na=500});function is(e,t){return e.length>t?e.slice(0,t)+"...":e}var Ft=v(()=>{"use strict"});var ns,as,Ht=v(()=>{"use strict";ns=["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"],as={"react-flow__(\\S+)":"$1"}});var os,Wt,Ie,at=v(()=>{"use strict";Ft();Ht();os=class{constructor(e,t=null){this.isVisible=e,this.parent=t}},Wt=class extends os{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}},Ie=class ln extends os{constructor(t,i,a,n,o,r=!1,s=!1,l=!1,c=!1,d=!1,h=!1,p=null,g=null,f=null,y=null,b=[],m=null){super(o,m),this.tagName=t,this.xpath=i,this.attributes=a,this.children=n,this.isInteractive=r,this.isScrollable=s,this.markAsClickable=l,this.isTopElement=c,this.isInViewport=d,this.shadowRoot=h,this.highlightIndex=p,this.viewportCoordinates=g,this.pageCoordinates=f,this.viewportInfo=y,this.isNew=null,this.shadowHostXPaths=b}getAllTextTillNextClickableElement(t=-1){let i=[],a=(n,o)=>{if(!(t!==-1&&o>t)&&!(n instanceof ln&&n!==this&&n.highlightIndex!==null)){if(n instanceof Wt)i.push(n.text);else if(n instanceof ln)for(let r of n.children)a(r,o+1)}};return a(this,0),i.join(`
@@ -4356,8 +4356,8 @@ ${p.join(`
4356
4356
 
4357
4357
  `,h.some(g=>g)){w.log(`Locator validation on unsigned-in page failed (some passed when should fail). Results: ${JSON.stringify(h)}`),w.log(`Validation logs:
4358
4358
  ${p.join(`
4359
- `)}`);continue}}return w.log("Generated validation locators passed dual validation"),d}catch(d){w.log(`Failed to generate validation expressions (attempt ${c+1}/${s}): ${d.message}`)}return w.log("Failed to generate valid locators after max retries"),null}finally{o&&await o.close()}}var jh,Kh,zn=v(()=>{"use strict";ae();Oe();jh=5e3,Kh=1e4});var hc={};Ve(hc,{LoginType:()=>jn,checkLocators:()=>Ei,createUnsignedInContext:()=>ho,generateAndValidateLoginLocators:()=>Kn,generateValidationLocators:()=>mo,validateLogin:()=>Ti,validateLoginLocators:()=>uo});var mc=v(()=>{"use strict";zn();ae();wt();Oe();ft();F();ne();rt();fe()});var Zh={};Ve(Zh,{VariableStore:()=>lo,WebAgent:()=>fo,configureSdk:()=>pa,createAgentContext:()=>wo,defineConfig:()=>xr,shiplightConfig:()=>yr});module.exports=yc(Zh);var wr=X(require("dotenv"),1),br=require("@playwright/test");var Fe=require("fs"),Ze=require("path"),rr=require("glob");var xc=require("uuid");var k=require("zod"),vo=k.z.enum(["JS_CODE","AI_MODE"]),Xn=k.z.object({type:vo,expression:k.z.string()}),_o=k.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),Xe=k.z.object({uid:k.z.string(),type:_o,comment:k.z.string().optional()}),ko=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(),So=Xe.extend({type:k.z.literal("DRAFT"),description:k.z.string()}),Eo=Xe.extend({type:k.z.literal("ACTION"),description:k.z.string(),action_entity:ko.optional(),locator:k.z.string().optional(),use_pure_vision:k.z.boolean().optional()}),oe=k.z.lazy(()=>k.z.union([So,Eo,Xe.extend({type:k.z.literal("STEP"),description:k.z.string().optional().default(""),statements:k.z.array(oe),reference_id:k.z.number().optional(),template_path:k.z.string().optional(),template_params:k.z.record(k.z.string()).optional()}),Xe.extend({type:k.z.literal("IF_ELSE"),description:k.z.string().optional(),condition:Xn,then:k.z.array(oe),else:k.z.array(oe).optional()}),Xe.extend({type:k.z.literal("WHILE_LOOP"),description:k.z.string().optional(),condition:Xn,body:k.z.array(oe),timeout_ms:k.z.number().optional()})])),To=k.z.object({name:k.z.string(),statements:k.z.array(oe),teardown:k.z.array(oe).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()}),Mi=k.z.object({tests:k.z.array(To).min(1),beforeAll:k.z.array(oe).optional(),afterAll:k.z.array(oe).optional(),beforeEach:k.z.array(oe).optional(),afterEach:k.z.array(oe).optional()}),Yn=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(oe).optional(),teardown:k.z.array(oe).optional(),last_modified_at:k.z.string().optional(),testGroup:Mi.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"});var N=require("yaml"),se=require("uuid");function Io(e,t){let i={...t?.test_case_id!==void 0?{test_case_id:t.test_case_id}:{},...t?.name?{name:t.name}:{},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}:{},statements:(e.statements??[]).map(le)};return e.final_feedback&&(i.final_feedback=e.final_feedback),e.teardown&&e.teardown.length>0&&(i.teardown=e.teardown.map(le)),i}var Po={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};function qn(e,t){if(e.testGroup)return Co(e,t);let i=Io(e,t),a=new N.Document(i);return e.comment&&(a.commentBefore=e.comment),Ao(a,e.statements??[]),e.teardown&&Ao(a,e.teardown,"teardown"),a.toString(Po)}function Ao(e,t,i="statements"){let a=e.contents;if(!a||!(0,N.isMap)(a))return;let n=a.get(i,!0);(0,N.isSeq)(n)&&yt(n,t)}function yt(e,t){for(let i=0;i<Math.min(e.items.length,t.length);i++){let a=t[i],n=e.items[i];if(i>0&&(n.spaceBefore=!0),a.comment&&(i===0?e.commentBefore=a.comment:n.commentBefore=a.comment),(0,N.isMap)(n)){let o=n;if(a.type==="STEP"){let r=o.get("statements",!0);(0,N.isSeq)(r)&&yt(r,a.statements)}else if(a.type==="IF_ELSE"){let r=o.get("THEN",!0);(0,N.isSeq)(r)&&yt(r,a.then);let s=o.get("ELSE",!0);(0,N.isSeq)(s)&&a.else&&yt(s,a.else)}else if(a.type==="WHILE_LOOP"){let r=o.get("DO",!0);(0,N.isSeq)(r)&&yt(r,a.body)}}}}function Co(e,t){let i=e.testGroup;if(!i)throw new Error("suiteToYaml requires a TestFlow with testGroup");let a={};t?.test_case_id!==void 0&&(a.test_case_id=t.test_case_id),t?.name&&(a.name=t.name),t?.tags&&t.tags.length>0&&(a.tags=t.tags),t?.use&&Object.keys(t.use).length>0&&(a.use=t.use),t?.settings&&Object.keys(t.settings).length>0&&(a.settings=t.settings);let n={};return e.baseURL&&(n.base_url=e.baseURL),i.beforeAll&&i.beforeAll.length>0&&(n.beforeAll=i.beforeAll.map(le)),i.beforeEach&&i.beforeEach.length>0&&(n.beforeEach=i.beforeEach.map(le)),i.afterEach&&i.afterEach.length>0&&(n.afterEach=i.afterEach.map(le)),i.afterAll&&i.afterAll.length>0&&(n.afterAll=i.afterAll.map(le)),n.tests=i.tests.map(o=>{let r={name:o.name};return o.skip!==void 0&&(r.skip=o.skip),o.timeout!==void 0&&(r.timeout=o.timeout),o.fail!==void 0&&(r.fail=o.fail),o.only!==void 0&&(r.only=o.only),o.slow!==void 0&&(r.slow=o.slow),r.statements=o.statements.map(le),o.teardown&&o.teardown.length>0&&(r.teardown=o.teardown.map(le)),r}),a.suite=n,(0,N.stringify)(a,Po)}function le(e){switch(e.type){case"DRAFT":return vc(e);case"ACTION":return _c(e);case"STEP":return kc(e);case"IF_ELSE":return Sc(e);case"WHILE_LOOP":return Ec(e)}}function vc(e){return{intent:e.description}}function _c(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"?{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"&&e.description)return{intent:e.description,js:s}}if(t==="ai_wait_until"){let s=i?.condition;if(typeof s=="string"){let l={WAIT_UNTIL:s};return typeof i?.timeout_seconds=="number"&&i.timeout_seconds!==60&&(l.timeout_seconds=i.timeout_seconds),l}}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{CODE:s}}if(!e.action_entity)return{intent:e.description};let a=e.action_entity.action_data??e.action_entity.action;if(!a)return{intent:e.description};let n={intent:e.description,action:a.action_name},o=e.locator??e.action_entity.locator;o&&(n.locator=o);let r=e.action_entity.xpath;if(r&&(n.xpath=r),e.use_pure_vision&&(n.use_pure_vision=!0),a.kwargs&&Object.keys(a.kwargs).length>0)for(let[s,l]of Object.entries(a.kwargs))n[s]=l;return a.args&&a.args.length>0&&(n.args=a.args),n}function kc(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(le)};return e.reference_id!==void 0&&(t.reference_id=e.reference_id),t}function Sc(e){let t={IF:Oo(e.condition),THEN:e.then.map(le)};return e.else&&e.else.length>0&&(t.ELSE=e.else.map(le)),t}function Ec(e){let t={WHILE:Oo(e.condition),DO:e.body.map(le)};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 Jn(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Jn);let t=e,i=Object.keys(t);if(i.length===1){let n=i[0];if(n.startsWith("{ ")&&n.endsWith(" }")&&t[n]===null)return`{{${n.slice(2,-2)}}}`}let a={};for(let[n,o]of Object.entries(t))a[n]=Jn(o);return a}var $o=1024*1024;function pe(e){if(e.length>$o)throw new Error(`YAML input too large (${e.length} bytes, max ${$o})`);let t=Jn((0,N.parse)(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Tc(t);let i={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:ce(t.statements??[])};t.final_feedback&&(i.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(i.teardown=ce(t.teardown));let a=Yn.safeParse(i);if(!a.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(a.error.errors)}`);let n=a.data;return No(e,n),n}function Tc(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 n={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:ce(s.statements)};return Array.isArray(s.teardown)&&s.teardown.length>0&&(l.teardown=ce(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&&(n.beforeAll=ce(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(n.afterAll=ce(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(n.beforeEach=ce(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(n.afterEach=ce(t.afterEach));let o=Mi.safeParse(n);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 ce(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(Ac)}function Ac(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 $c(t);if("WHILE"in t)return Mc(t);if("STEP"in t)return Ic(t);if("VERIFY"in t){let i=t.VERIFY,a={statement:typeof i=="string"?i:String(i)};return typeof t.js=="string"&&(a.code=t.js),{uid:(0,se.v4)(),type:"ACTION",description:String(i),action_entity:{action_description:String(i),action_data:{action_name:"verify",kwargs:a}}}}if("URL"in t){let i=t.URL,a=t.new_tab===!0?!0:void 0,n=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,o={url:typeof i=="string"?i:String(i)};return a&&(o.new_tab=!0),n!==void 0&&(o.timeout_seconds=n),{uid:(0,se.v4)(),type:"ACTION",description:`Navigate to ${i}`,action_entity:{action_description:`Navigate to ${i}`,action_data:{action_name:"go_to_url",kwargs:o}}}}if("WAIT_UNTIL"in t){let i=t.WAIT_UNTIL,a=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;return{uid:(0,se.v4)(),type:"ACTION",description:`Wait until: ${i}`,action_entity:{action_description:`Wait until: ${i}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof i=="string"?i:String(i),timeout_seconds:a}}}}}if("WAIT"in t){let i=t.WAIT,a=typeof t.seconds=="number"?t.seconds:3;return{uid:(0,se.v4)(),type:"ACTION",description:typeof i=="string"?i:`Wait ${a}s`,action_entity:{action_description:typeof i=="string"?i:`Wait ${a}s`,action_data:{action_name:"wait",kwargs:{seconds:a}}}}}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.');return{uid:(0,se.v4)(),type:"ACTION",description:"Code block",action_entity:{action_description:"Code block",action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("js"in t&&("intent"in t||"desc"in t)&&!("VERIFY"in t)&&t.action!=="verify"){let i=t.js,a=typeof t.intent=="string"?t.intent:typeof t.desc=="string"?t.desc:"";return{uid:(0,se.v4)(),type:"ACTION",description:a,action_entity:{action_description:a,action_data:{action_name:"js_action",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:i,...a}=t;return Mo({...a,action:"function",functionName:i})}if("action"in t)return Mo(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:(0,se.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 Lo(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 $c(e){let t=Lo(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let a={uid:(0,se.v4)(),type:"IF_ELSE",condition:t,then:ce(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(a.else=ce(e.ELSE)),a}function Mc(e){let t=Lo(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let a={uid:(0,se.v4)(),type:"WHILE_LOOP",condition:t,body:ce(i)};return typeof e.timeout_ms=="number"&&(a.timeout_ms=e.timeout_ms),a}function Ic(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,se.v4)(),type:"STEP",description:t,statements:ce(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 a=e.template_params,n={};for(let[o,r]of Object.entries(a))n[o]=String(r);i.template_params=n}return i}var Pc=new Set(["action","intent","desc","locator","xpath","use_pure_vision"]);function Mo(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:"",a=typeof e.locator=="string"?e.locator:void 0,n=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))Pc.has(c)||(r[c]=d);t==="verify"&&typeof r.js=="string"&&(r.code=r.js,delete r.js);let s={action_description:i,action_data:{action_name:t,kwargs:Object.keys(r).length>0?r:{}}};a&&(s.locator=a),n&&(s.xpath=n);let l={uid:(0,se.v4)(),type:"ACTION",description:i,action_entity:s};return o&&(l.use_pure_vision=!0),l}function No(e,t){let i;try{i=(0,N.parseDocument)(e)}catch{return}let a=i.contents;if(!a||!(0,N.isMap)(a))return;if(i.commentBefore)t.comment=i.commentBefore;else{let l=a.items?.[0];l?.key&&l.key.commentBefore&&(t.comment=l.key.commentBefore)}let n=a,o=n.get("statements",!0);(0,N.isSeq)(o)&&t.statements&&Ye(o,t.statements);let r=n.get("teardown",!0);(0,N.isSeq)(r)&&t.teardown&&Ye(r,t.teardown)}function Ye(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 a=e.items[i];a.commentBefore&&!(i===0&&e.commentBefore)&&(t[i].comment=a.commentBefore);let n=t[i];if(n.type==="STEP"&&(0,N.isMap)(a)){let o=a.get("statements",!0);(0,N.isSeq)(o)&&Ye(o,n.statements)}else if(n.type==="IF_ELSE"&&(0,N.isMap)(a)){let o=a.get("THEN",!0);(0,N.isSeq)(o)&&Ye(o,n.then);let r=a.get("ELSE",!0);(0,N.isSeq)(r)&&n.else&&Ye(r,n.else)}else if(n.type==="WHILE_LOOP"&&(0,N.isMap)(a)){let o=a.get("DO",!0);(0,N.isSeq)(o)&&Ye(o,n.body)}}}var Do=require("yaml");var Zn=e=>{let t=[];switch(e.type){case"STEP":e.statements&&t.push({key:"statements",statements:e.statements});break;case"IF_ELSE":e.then&&t.push({key:"then",statements:e.then}),e.else&&t.push({key:"else",statements:e.else});break;case"WHILE_LOOP":e.body&&t.push({key:"body",statements:e.body});break}return t};var Ii=e=>{let t=[],i=a=>{for(let n of a){t.push(n);let o=Zn(n);for(let r of o)i(r.statements)}};return i(e),t};var Cc=.5,Ro=5,Fo=3,Wo=new Set(["verify","ai_assert","done","go_to_url","ai_wait_until","wait","js_code"]);function Uo(e){let t=0,i=0;for(let a of e)if(a.type==="DRAFT")i++;else if(a.type==="ACTION"){let n=a.action_entity?.action_data?.action_name??"";Wo.has(n)||t++}return{action:t,draft:i}}function Oc(e){try{return new Function(`return async function() { ${e} }`),null}catch(t){return t.message}}function Ho(e){try{return new Function(`return async function() { return (${e}) }`),null}catch(t){return t.message}}function Lc(e){let t=e.split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0&&!o.startsWith("//")),i=t.length,a=t.join(`
4360
- `).match(/\bawait\b/g),n=a?a.length:0;return i<=Ro&&n<=Fo?null:`${i} non-blank line(s), ${n} await(s) \u2014 limits are ${Ro} lines and ${Fo} awaits. The js: field is a cache for one natural-language intent, not a place for multi-step logic. Break this into multiple statements \u2014 one VERIFY or intent+js per UI interaction or assertion \u2014 so each step is visible in the debugger and self-healable.`}function Qn(e,t){let i=t?.coverageThreshold??Cc,a=[],n=[],o;try{o=pe(e)}catch(p){return{valid:!1,errors:[`Invalid YAML: ${p.message}`],warnings:[],stats:{total:0,action:0,draft:0,coverage:0}}}o.goal||a.push('Missing required field: "goal"'),o.statements?.length||a.push('Missing required field: "statements"');let r=[...Ii(o.statements??[]),...o.teardown?Ii(o.teardown):[]],{action:s,draft:l}=Uo(r),c="Hint: in YAML double-quoted strings, backslashes are escape characters \u2014 use \\\\/ instead of \\/ for regex, or use single quotes.";for(let p of r){let g=p;if(g.reference_id!==void 0){let f=g.description||p.uid;a.push(`Unresolved cloud template reference on statement "${f}" (reference_id: ${g.reference_id}). Local YAML tests cannot use reference_id \u2014 inline the template statements or use the local "template:" key instead.`)}if(p.type==="ACTION"){let f=p,y=f.action_entity?.action_data?.action_name??"";if(y==="js_code"||y==="js_action"||y==="verify"||y==="ai_assert"){let b=f.action_entity?.action_data?.kwargs?.code;if(typeof b=="string"){let m=Oc(b);if(m){let x=f.description||y;a.push(`Invalid JS in "${x}": ${m}. ${c}`)}else if(y==="verify"||y==="js_action"){let x=Lc(b);if(x){let _=f.description||y;a.push(`JS cache for "${_}" is too complex: ${x}`)}}}}}if(p.type==="IF_ELSE"){let f=p;if(f.condition.type==="JS_CODE"){let y=Ho(f.condition.expression);y&&a.push(`Invalid JS in IF condition "${f.condition.expression}": ${y}. ${c}`)}}if(p.type==="WHILE_LOOP"){let f=p;if(f.condition.type==="JS_CODE"){let y=Ho(f.condition.expression);y&&a.push(`Invalid JS in WHILE condition "${f.condition.expression}": ${y}. ${c}`)}}}let d=s+l,h=d>0?Math.round(s/d*100):0;return d>0&&h/100<i&&n.push(`Low action coverage: ${s}/${d} statements (${h}%) are enriched with action/js. ${l} draft statement(s) still need enrichment. Use MCP tools (act, get_locators) to convert drafts to actions.`),{valid:a.length===0,errors:a,warnings:n,stats:{total:d,action:s,draft:l,coverage:h}}}var Bo=112;var Dc=1080-Bo;var Go={"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"}};var jo={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"]},xt=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),jo[e].map(a=>Go[a]).filter(a=>a.defaultBrowserType&&i.includes(a.defaultBrowserType))};var Rc={desktop:{label:"Desktop",type:"desktop",devices:xt("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:xt("mobile")}},Fc={desktop:{label:"Desktop",type:"desktop",devices:xt("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:xt("mobile",!0)}};function ea(){return{version:"1.0",entries:{}}}var me=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(me||{});var ta=18e4;var Yo=require("yaml");var er=require("crypto"),_t=require("yaml");var Ni=require("fs"),qe=require("path"),vt=require("yaml"),kt=require("fs"),nr=require("path");var na=5e3;function Se(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function G(e){return e.replace(/\r\n/g," ").replace(/\n/g," ").replace(/\r/g," ").trim()}function Wc(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function Uc(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 Ci(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 a=Uc(e);if(a){let n=JSON.stringify(a);return`${t}.locator(${n}).first()`}return null}var Bc=["ai_action","ai_step","ai_assert","ai_extract","ai_wait_until","verify","assert"],Gc=["js_code","function","wait","wait_for_download_complete","wait_for_page_ready","extract_email_content","extract_activation_code"];function Ko(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:Bc.includes(t)}function jc(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:!Gc.includes(t)}var ee=new Map;function M(e,t){ee.set(e,t)}function Kc(e){return ee.get(e)}function Ue(e,t,i=[]){let a=[...i];return t.locator?a.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&a.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&a.push(`frame_path: ${JSON.stringify(t.frame_path)}`),a.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...a.map(n=>` ${n},`),"});"]}M("click",e=>{let t=Ci(e);if(!t)return['await agent.execAction("click", page, {});'];let i=e.action_data?.kwargs?.timeout_ms??na;return[`await ${t}.click({ timeout: ${i} });`]});M("click_element",ee.get("click"));M("click_element_by_index",ee.get("click"));M("double_click",e=>Ue("double_click",e));M("double_click_on_element",ee.get("double_click"));M("right_click",e=>Ue("right_click",e));M("right_click_on_element",ee.get("right_click"));M("hover",e=>Ue("hover",e));M("hover_element_by_index",ee.get("hover"));M("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return Ue("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});M("fill",ee.get("input_text"));M("clear_input",e=>Ue("clear_input",e));M("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});M("send_keys",ee.get("press"));M("send_keys_on_element",e=>{let t=Ci(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 a=e.action_data?.kwargs?.timeout_ms??na;return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${a} });`]});M("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return Ue("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",ee.get("scroll"));M("scroll_up",ee.get("scroll"));M("scroll_element",ee.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=>Ue("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",ee.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,a=typeof i?.code=="string",n=a?i?.statement||e.action_description:e.action_description||i?.statement;if(a&&n){let r=i.code.split(`
4359
+ `)}`);continue}}return w.log("Generated validation locators passed dual validation"),d}catch(d){w.log(`Failed to generate validation expressions (attempt ${c+1}/${s}): ${d.message}`)}return w.log("Failed to generate valid locators after max retries"),null}finally{o&&await o.close()}}var jh,Kh,zn=v(()=>{"use strict";ae();Oe();jh=5e3,Kh=1e4});var hc={};Ve(hc,{LoginType:()=>jn,checkLocators:()=>Ei,createUnsignedInContext:()=>ho,generateAndValidateLoginLocators:()=>Kn,generateValidationLocators:()=>mo,validateLogin:()=>Ti,validateLoginLocators:()=>uo});var mc=v(()=>{"use strict";zn();ae();wt();Oe();ft();F();ne();rt();fe()});var Zh={};Ve(Zh,{VariableStore:()=>lo,WebAgent:()=>fo,configureSdk:()=>pa,createAgentContext:()=>wo,defineConfig:()=>xr,shiplightConfig:()=>yr});module.exports=yc(Zh);var wr=X(require("dotenv"),1),br=require("@playwright/test");var Fe=require("fs"),Ze=require("path"),rr=require("glob");var xc=require("uuid");var k=require("zod"),vo=k.z.enum(["JS_CODE","AI_MODE"]),Xn=k.z.object({type:vo,expression:k.z.string()}),_o=k.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),Xe=k.z.object({uid:k.z.string(),type:_o,comment:k.z.string().optional()}),ko=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(),So=Xe.extend({type:k.z.literal("DRAFT"),description:k.z.string()}),Eo=Xe.extend({type:k.z.literal("ACTION"),description:k.z.string(),action_entity:ko.optional(),locator:k.z.string().optional(),use_pure_vision:k.z.boolean().optional()}),oe=k.z.lazy(()=>k.z.union([So,Eo,Xe.extend({type:k.z.literal("STEP"),description:k.z.string().optional().default(""),statements:k.z.array(oe),reference_id:k.z.number().optional(),template_path:k.z.string().optional(),template_params:k.z.record(k.z.string()).optional()}),Xe.extend({type:k.z.literal("IF_ELSE"),description:k.z.string().optional(),condition:Xn,then:k.z.array(oe),else:k.z.array(oe).optional()}),Xe.extend({type:k.z.literal("WHILE_LOOP"),description:k.z.string().optional(),condition:Xn,body:k.z.array(oe),timeout_ms:k.z.number().optional()})])),To=k.z.object({name:k.z.string(),statements:k.z.array(oe),teardown:k.z.array(oe).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()}),Mi=k.z.object({tests:k.z.array(To).min(1),beforeAll:k.z.array(oe).optional(),afterAll:k.z.array(oe).optional(),beforeEach:k.z.array(oe).optional(),afterEach:k.z.array(oe).optional()}),Yn=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(oe).optional(),teardown:k.z.array(oe).optional(),last_modified_at:k.z.string().optional(),testGroup:Mi.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"});var N=require("yaml"),se=require("uuid");function Io(e,t){let i={...t?.test_case_id!==void 0?{test_case_id:t.test_case_id}:{},...t?.name?{name:t.name}:{},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}:{},statements:(e.statements??[]).map(le)};return e.final_feedback&&(i.final_feedback=e.final_feedback),e.teardown&&e.teardown.length>0&&(i.teardown=e.teardown.map(le)),i}var Po={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};function qn(e,t){if(e.testGroup)return Co(e,t);let i=Io(e,t),a=new N.Document(i);return e.comment&&(a.commentBefore=e.comment),Ao(a,e.statements??[]),e.teardown&&Ao(a,e.teardown,"teardown"),a.toString(Po)}function Ao(e,t,i="statements"){let a=e.contents;if(!a||!(0,N.isMap)(a))return;let n=a.get(i,!0);(0,N.isSeq)(n)&&yt(n,t)}function yt(e,t){for(let i=0;i<Math.min(e.items.length,t.length);i++){let a=t[i],n=e.items[i];if(i>0&&(n.spaceBefore=!0),a.comment&&(i===0?e.commentBefore=a.comment:n.commentBefore=a.comment),(0,N.isMap)(n)){let o=n;if(a.type==="STEP"){let r=o.get("statements",!0);(0,N.isSeq)(r)&&yt(r,a.statements)}else if(a.type==="IF_ELSE"){let r=o.get("THEN",!0);(0,N.isSeq)(r)&&yt(r,a.then);let s=o.get("ELSE",!0);(0,N.isSeq)(s)&&a.else&&yt(s,a.else)}else if(a.type==="WHILE_LOOP"){let r=o.get("DO",!0);(0,N.isSeq)(r)&&yt(r,a.body)}}}}function Co(e,t){let i=e.testGroup;if(!i)throw new Error("suiteToYaml requires a TestFlow with testGroup");let a={};t?.test_case_id!==void 0&&(a.test_case_id=t.test_case_id),t?.name&&(a.name=t.name),t?.tags&&t.tags.length>0&&(a.tags=t.tags),t?.use&&Object.keys(t.use).length>0&&(a.use=t.use),t?.settings&&Object.keys(t.settings).length>0&&(a.settings=t.settings);let n={};return e.baseURL&&(n.base_url=e.baseURL),i.beforeAll&&i.beforeAll.length>0&&(n.beforeAll=i.beforeAll.map(le)),i.beforeEach&&i.beforeEach.length>0&&(n.beforeEach=i.beforeEach.map(le)),i.afterEach&&i.afterEach.length>0&&(n.afterEach=i.afterEach.map(le)),i.afterAll&&i.afterAll.length>0&&(n.afterAll=i.afterAll.map(le)),n.tests=i.tests.map(o=>{let r={name:o.name};return o.skip!==void 0&&(r.skip=o.skip),o.timeout!==void 0&&(r.timeout=o.timeout),o.fail!==void 0&&(r.fail=o.fail),o.only!==void 0&&(r.only=o.only),o.slow!==void 0&&(r.slow=o.slow),r.statements=o.statements.map(le),o.teardown&&o.teardown.length>0&&(r.teardown=o.teardown.map(le)),r}),a.suite=n,(0,N.stringify)(a,Po)}function le(e){switch(e.type){case"DRAFT":return vc(e);case"ACTION":return _c(e);case"STEP":return kc(e);case"IF_ELSE":return Sc(e);case"WHILE_LOOP":return Ec(e)}}function vc(e){return{intent:e.description}}function _c(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"?{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"&&e.description)return{description:e.description,js:s}}if(t==="ai_wait_until"){let s=i?.condition;if(typeof s=="string"){let l={WAIT_UNTIL:s};return typeof i?.timeout_seconds=="number"&&i.timeout_seconds!==60&&(l.timeout_seconds=i.timeout_seconds),l}}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 a=e.action_entity.action_data??e.action_entity.action;if(!a)return{intent:e.description};let n={intent:e.description,action:a.action_name},o=e.locator??e.action_entity.locator;o&&(n.locator=o);let r=e.action_entity.xpath;if(r&&(n.xpath=r),e.use_pure_vision&&(n.use_pure_vision=!0),a.kwargs&&Object.keys(a.kwargs).length>0)for(let[s,l]of Object.entries(a.kwargs))n[s]=l;return a.args&&a.args.length>0&&(n.args=a.args),n}function kc(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(le)};return e.reference_id!==void 0&&(t.reference_id=e.reference_id),t}function Sc(e){let t={IF:Oo(e.condition),THEN:e.then.map(le)};return e.else&&e.else.length>0&&(t.ELSE=e.else.map(le)),t}function Ec(e){let t={WHILE:Oo(e.condition),DO:e.body.map(le)};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 Jn(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Jn);let t=e,i=Object.keys(t);if(i.length===1){let n=i[0];if(n.startsWith("{ ")&&n.endsWith(" }")&&t[n]===null)return`{{${n.slice(2,-2)}}}`}let a={};for(let[n,o]of Object.entries(t))a[n]=Jn(o);return a}var $o=1024*1024;function pe(e){if(e.length>$o)throw new Error(`YAML input too large (${e.length} bytes, max ${$o})`);let t=Jn((0,N.parse)(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Tc(t);let i={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:ce(t.statements??[])};t.final_feedback&&(i.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(i.teardown=ce(t.teardown));let a=Yn.safeParse(i);if(!a.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(a.error.errors)}`);let n=a.data;return No(e,n),n}function Tc(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 n={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:ce(s.statements)};return Array.isArray(s.teardown)&&s.teardown.length>0&&(l.teardown=ce(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&&(n.beforeAll=ce(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(n.afterAll=ce(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(n.beforeEach=ce(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(n.afterEach=ce(t.afterEach));let o=Mi.safeParse(n);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 ce(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(Ac)}function Ac(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 $c(t);if("WHILE"in t)return Mc(t);if("STEP"in t)return Ic(t);if("VERIFY"in t){let i=t.VERIFY,a={statement:typeof i=="string"?i:String(i)};return typeof t.js=="string"&&(a.code=t.js),{uid:(0,se.v4)(),type:"ACTION",description:String(i),action_entity:{action_description:String(i),action_data:{action_name:"verify",kwargs:a}}}}if("URL"in t){let i=t.URL,a=t.new_tab===!0?!0:void 0,n=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,o={url:typeof i=="string"?i:String(i)};return a&&(o.new_tab=!0),n!==void 0&&(o.timeout_seconds=n),{uid:(0,se.v4)(),type:"ACTION",description:`Navigate to ${i}`,action_entity:{action_description:`Navigate to ${i}`,action_data:{action_name:"go_to_url",kwargs:o}}}}if("WAIT_UNTIL"in t){let i=t.WAIT_UNTIL,a=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;return{uid:(0,se.v4)(),type:"ACTION",description:`Wait until: ${i}`,action_entity:{action_description:`Wait until: ${i}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof i=="string"?i:String(i),timeout_seconds:a}}}}}if("WAIT"in t){let i=t.WAIT,a=typeof t.seconds=="number"?t.seconds:3;return{uid:(0,se.v4)(),type:"ACTION",description:typeof i=="string"?i:`Wait ${a}s`,action_entity:{action_description:typeof i=="string"?i:`Wait ${a}s`,action_data:{action_name:"wait",kwargs:{seconds:a}}}}}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 a=typeof t.description=="string"?t.description:"Code block";return{uid:(0,se.v4)(),type:"ACTION",description:a,action_entity:{action_description:a,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",a=t.js;return{uid:(0,se.v4)(),type:"ACTION",description:i,action_entity:{action_description:i,action_data:{action_name:"js_code",kwargs:{code:typeof a=="string"?a:String(a)}}}}}if("call"in t&&typeof t.call=="string"){let{call:i,...a}=t;return Mo({...a,action:"function",functionName:i})}if("action"in t)return Mo(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:(0,se.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 Lo(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 $c(e){let t=Lo(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let a={uid:(0,se.v4)(),type:"IF_ELSE",condition:t,then:ce(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(a.else=ce(e.ELSE)),a}function Mc(e){let t=Lo(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let a={uid:(0,se.v4)(),type:"WHILE_LOOP",condition:t,body:ce(i)};return typeof e.timeout_ms=="number"&&(a.timeout_ms=e.timeout_ms),a}function Ic(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,se.v4)(),type:"STEP",description:t,statements:ce(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 a=e.template_params,n={};for(let[o,r]of Object.entries(a))n[o]=String(r);i.template_params=n}return i}var Pc=new Set(["action","intent","desc","locator","xpath","use_pure_vision"]);function Mo(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:"",a=typeof e.locator=="string"?e.locator:void 0,n=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))Pc.has(c)||(r[c]=d);t==="verify"&&typeof r.js=="string"&&(r.code=r.js,delete r.js);let s={action_description:i,action_data:{action_name:t,kwargs:Object.keys(r).length>0?r:{}}};a&&(s.locator=a),n&&(s.xpath=n);let l={uid:(0,se.v4)(),type:"ACTION",description:i,action_entity:s};return o&&(l.use_pure_vision=!0),l}function No(e,t){let i;try{i=(0,N.parseDocument)(e)}catch{return}let a=i.contents;if(!a||!(0,N.isMap)(a))return;if(i.commentBefore)t.comment=i.commentBefore;else{let l=a.items?.[0];l?.key&&l.key.commentBefore&&(t.comment=l.key.commentBefore)}let n=a,o=n.get("statements",!0);(0,N.isSeq)(o)&&t.statements&&Ye(o,t.statements);let r=n.get("teardown",!0);(0,N.isSeq)(r)&&t.teardown&&Ye(r,t.teardown)}function Ye(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 a=e.items[i];a.commentBefore&&!(i===0&&e.commentBefore)&&(t[i].comment=a.commentBefore);let n=t[i];if(n.type==="STEP"&&(0,N.isMap)(a)){let o=a.get("statements",!0);(0,N.isSeq)(o)&&Ye(o,n.statements)}else if(n.type==="IF_ELSE"&&(0,N.isMap)(a)){let o=a.get("THEN",!0);(0,N.isSeq)(o)&&Ye(o,n.then);let r=a.get("ELSE",!0);(0,N.isSeq)(r)&&n.else&&Ye(r,n.else)}else if(n.type==="WHILE_LOOP"&&(0,N.isMap)(a)){let o=a.get("DO",!0);(0,N.isSeq)(o)&&Ye(o,n.body)}}}var Do=require("yaml");var Zn=e=>{let t=[];switch(e.type){case"STEP":e.statements&&t.push({key:"statements",statements:e.statements});break;case"IF_ELSE":e.then&&t.push({key:"then",statements:e.then}),e.else&&t.push({key:"else",statements:e.else});break;case"WHILE_LOOP":e.body&&t.push({key:"body",statements:e.body});break}return t};var Ii=e=>{let t=[],i=a=>{for(let n of a){t.push(n);let o=Zn(n);for(let r of o)i(r.statements)}};return i(e),t};var Cc=.5,Ro=5,Fo=3,Wo=new Set(["verify","ai_assert","done","go_to_url","ai_wait_until","wait","js_code"]);function Uo(e){let t=0,i=0;for(let a of e)if(a.type==="DRAFT")i++;else if(a.type==="ACTION"){let n=a.action_entity?.action_data?.action_name??"";Wo.has(n)||t++}return{action:t,draft:i}}function Oc(e){try{return new Function(`return async function() { ${e} }`),null}catch(t){return t.message}}function Ho(e){try{return new Function(`return async function() { return (${e}) }`),null}catch(t){return t.message}}function Lc(e){let t=e.split(/\r?\n/).map(o=>o.trim()).filter(o=>o.length>0&&!o.startsWith("//")),i=t.length,a=t.join(`
4360
+ `).match(/\bawait\b/g),n=a?a.length:0;return i<=Ro&&n<=Fo?null:`${i} non-blank line(s), ${n} await(s) \u2014 limits are ${Ro} lines and ${Fo} awaits. The VERIFY js: field is a cache for one natural-language assertion, not a place for multi-step logic. Break this into multiple statements \u2014 one VERIFY per assertion \u2014 so each step is visible in the debugger and self-healable. For freeform setup code (mocking, storage), use the description: + js: escape hatch, which has no complexity cap.`}function Qn(e,t){let i=t?.coverageThreshold??Cc,a=[],n=[],o;try{o=pe(e)}catch(p){return{valid:!1,errors:[`Invalid YAML: ${p.message}`],warnings:[],stats:{total:0,action:0,draft:0,coverage:0}}}o.goal||a.push('Missing required field: "goal"'),o.statements?.length||a.push('Missing required field: "statements"');let r=[...Ii(o.statements??[]),...o.teardown?Ii(o.teardown):[]],{action:s,draft:l}=Uo(r),c="Hint: in YAML double-quoted strings, backslashes are escape characters \u2014 use \\\\/ instead of \\/ for regex, or use single quotes.";for(let p of r){let g=p;if(g.reference_id!==void 0){let f=g.description||p.uid;a.push(`Unresolved cloud template reference on statement "${f}" (reference_id: ${g.reference_id}). Local YAML tests cannot use reference_id \u2014 inline the template statements or use the local "template:" key instead.`)}if(p.type==="ACTION"){let f=p,y=f.action_entity?.action_data?.action_name??"";if(y==="js_code"||y==="js_action"||y==="verify"||y==="ai_assert"){let b=f.action_entity?.action_data?.kwargs?.code;if(typeof b=="string"){let m=Oc(b);if(m){let x=f.description||y;a.push(`Invalid JS in "${x}": ${m}. ${c}`)}else if(y==="verify"){let x=Lc(b);if(x){let _=f.description||y;a.push(`JS cache for "${_}" is too complex: ${x}`)}}}}}if(p.type==="IF_ELSE"){let f=p;if(f.condition.type==="JS_CODE"){let y=Ho(f.condition.expression);y&&a.push(`Invalid JS in IF condition "${f.condition.expression}": ${y}. ${c}`)}}if(p.type==="WHILE_LOOP"){let f=p;if(f.condition.type==="JS_CODE"){let y=Ho(f.condition.expression);y&&a.push(`Invalid JS in WHILE condition "${f.condition.expression}": ${y}. ${c}`)}}}let d=s+l,h=d>0?Math.round(s/d*100):0;return d>0&&h/100<i&&n.push(`Low action coverage: ${s}/${d} statements (${h}%) are enriched with action/js. ${l} draft statement(s) still need enrichment. Use MCP tools (act, get_locators) to convert drafts to actions.`),{valid:a.length===0,errors:a,warnings:n,stats:{total:d,action:s,draft:l,coverage:h}}}var Bo=112;var Dc=1080-Bo;var Go={"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"}};var jo={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"]},xt=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),jo[e].map(a=>Go[a]).filter(a=>a.defaultBrowserType&&i.includes(a.defaultBrowserType))};var Rc={desktop:{label:"Desktop",type:"desktop",devices:xt("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:xt("mobile")}},Fc={desktop:{label:"Desktop",type:"desktop",devices:xt("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:xt("mobile",!0)}};function ea(){return{version:"1.0",entries:{}}}var me=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(me||{});var ta=18e4;var Yo=require("yaml");var er=require("crypto"),_t=require("yaml");var Ni=require("fs"),qe=require("path"),vt=require("yaml"),kt=require("fs"),nr=require("path");var na=5e3;function Se(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function G(e){return e.replace(/\r\n/g," ").replace(/\n/g," ").replace(/\r/g," ").trim()}function Wc(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function Uc(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 Ci(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 a=Uc(e);if(a){let n=JSON.stringify(a);return`${t}.locator(${n}).first()`}return null}var Bc=["ai_action","ai_step","ai_assert","ai_extract","ai_wait_until","verify","assert"],Gc=["js_code","function","wait","wait_for_download_complete","wait_for_page_ready","extract_email_content","extract_activation_code"];function Ko(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:Bc.includes(t)}function jc(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:!Gc.includes(t)}var ee=new Map;function M(e,t){ee.set(e,t)}function Kc(e){return ee.get(e)}function Ue(e,t,i=[]){let a=[...i];return t.locator?a.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&a.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&a.push(`frame_path: ${JSON.stringify(t.frame_path)}`),a.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...a.map(n=>` ${n},`),"});"]}M("click",e=>{let t=Ci(e);if(!t)return['await agent.execAction("click", page, {});'];let i=e.action_data?.kwargs?.timeout_ms??na;return[`await ${t}.click({ timeout: ${i} });`]});M("click_element",ee.get("click"));M("click_element_by_index",ee.get("click"));M("double_click",e=>Ue("double_click",e));M("double_click_on_element",ee.get("double_click"));M("right_click",e=>Ue("right_click",e));M("right_click_on_element",ee.get("right_click"));M("hover",e=>Ue("hover",e));M("hover_element_by_index",ee.get("hover"));M("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return Ue("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});M("fill",ee.get("input_text"));M("clear_input",e=>Ue("clear_input",e));M("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});M("send_keys",ee.get("press"));M("send_keys_on_element",e=>{let t=Ci(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 a=e.action_data?.kwargs?.timeout_ms??na;return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${a} });`]});M("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return Ue("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",ee.get("scroll"));M("scroll_up",ee.get("scroll"));M("scroll_element",ee.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=>Ue("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",ee.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,a=typeof i?.code=="string",n=a?i?.statement||e.action_description:e.action_description||i?.statement;if(a&&n){let r=i.code.split(`
4361
4361
  `),s=JSON.stringify(n);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 a?i.code.split(`
4362
4362
  `):n?[`await agent.assert(page, ${JSON.stringify(n)}, ${JSON.stringify(t||"")});`]:["// Skipping verify: missing statement or code"]});M("ai_assert",ee.get("verify"));M("assert",ee.get("verify"));M("ai_action",(e,t)=>{let i=e.action_data?.kwargs?.statement;if(!i)return["// Skipping ai_action: missing statement"];let a=JSON.stringify(i),n=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${a}, '${t||""}', ${n});`]});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,a=e.action_data?.kwargs?.variable_name;if(!i||!a)return["// Skipping ai_extract: missing element_description or variable_name"];let n=JSON.stringify(i),o=JSON.stringify(a);return[`await agent.extract(page, ${n}, ${o}, '${t||""}');`]});M("ai_wait_until",(e,t)=>{let i=e.action_data?.kwargs?.condition,a=e.action_data?.kwargs?.timeout_seconds||60;return i?[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${a}, '${t||""}');`]:["// Skipping ai_wait_until: missing condition"]});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=["{"],a=t.split(`
4363
4363
  `);for(let n of a)i.push(` ${n}`);return i.push("}"),i});M("function",(e,t,i)=>{let a=e.action_data?.kwargs||{},n=a.functionName;if(n&&n.includes("#")){let[r,s]=n.split("#");if(r&&s){let l=r.replace(/\.(ts|js|mjs)$/,""),c=`import { ${s} } from '${l}';`;i?.imports?.add(c);let d={...a,functionName:s},h=zo(d);return h?[h.endsWith(";")?h:`${h};`]:["// Skipping function: invalid export pattern"]}}let o=zo(a);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=[],a={};return t.paths?a.paths=t.paths:t.path&&(a.path=t.path),t.use_file_input&&(a.use_file_input=!0),i.push(`action_data: { kwargs: ${JSON.stringify(a)} }`),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(n=>` ${n},`),"});"]});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(a=>` ${a},`),"});"]});M("done",()=>["// Done - no action needed"]);M("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
@@ -4365,7 +4365,7 @@ ${p.join(`
4365
4365
  `)}function ed(e,t){let i=[],a=t?.version||"unknown";i.push(`// @generated by shiplightai v${a}`),i.push(...Zo()),i.push(""),t?.use&&Object.keys(t.use).length>0&&(i.push(`test.use(${JSON.stringify(t.use,null,2)});`),i.push(""));let n=new Set,o={imports:n,actionEntityStore:t?.actionEntityStore},r=t?.testName||"Test Suite",s=ia(t?.tags);i.push(`test.describe.serial('${s}${Se(r)}', () => {`),e.beforeAll&&e.beforeAll.length>0&&(i.push(...Pi("beforeAll",e.beforeAll,o,1)),i.push("")),e.beforeEach&&e.beforeEach.length>0&&(i.push(...Pi("beforeEach",e.beforeEach,o,1)),i.push(""));for(let c=0;c<e.tests.length;c++){let d=e.tests[c],h=d.timeout||d.skip!==void 0||d.fail!==void 0||d.only||d.slow?{timeout:d.timeout,skip:d.skip,fail:d.fail,only:d.only,slow:d.slow}:void 0;if(d.parameters&&d.parameters.length>0)for(let p of d.parameters){let g=qo(d.testFlow,p.values);i.push(...Li(g,`${Se(d.name)} [${Se(p.name)}]`,o,1,h)),i.push("")}else i.push(...Li(d.testFlow,Se(d.name),o,1,h)),(c<e.tests.length-1||e.afterEach||e.afterAll)&&i.push("")}return e.afterEach&&e.afterEach.length>0&&(i.push(...Pi("afterEach",e.afterEach,o,1)),i.push("")),e.afterAll&&e.afterAll.length>0&&i.push(...Pi("afterAll",e.afterAll,o,1)),i.push("});"),Qo(i,n),i.join(`
4366
4366
  `)}function ia(e){return e&&e.length>0?e.map(t=>`@${t}`).join(" ")+" ":""}var td=["testContext","request"];function Oi(e){let t=new Set;function i(a){for(let n of a)switch(n.type){case me.ACTION:{let r=n.action_entity?.action_data?.kwargs;if(r?.args&&Array.isArray(r.args))for(let s of r.args)typeof s=="string"&&td.includes(s)&&t.add(s);break}case me.STEP:i(n.statements);break;case me.IF_ELSE:{let o=n;i(o.then),o.else&&i(o.else);break}case me.WHILE_LOOP:i(n.body);break}}return i(e),t}function id(e){let t=Oi(e.statements??[]);if(e.teardown)for(let i of Oi(e.teardown))t.add(i);return t}function aa(e){return`{ ${["page","agent",...Array.from(e).sort()].join(", ")} }`}function Li(e,t,i,a=0,n){let o=" ".repeat(a),r=[],s=id(e),l=aa(s),c=n?.only?"test.only":"test";r.push(`${o}${c}('${t}', async (${l}) => {`),n?.skip===!0?r.push(`${o} test.skip();`):typeof n?.skip=="string"&&r.push(`${o} test.skip(true, '${Se(n.skip)}');`),n?.fail===!0?r.push(`${o} test.fail();`):typeof n?.fail=="string"&&r.push(`${o} test.fail(true, '${Se(n.fail)}');`),n?.slow&&r.push(`${o} test.slow();`),n?.timeout&&r.push(`${o} test.setTimeout(${n.timeout});`);let d=e.teardown&&e.teardown.length>0,h=a+1;if(d){if(r.push(`${o} try {`),e.statements&&e.statements.length>0){r.push(`${o} // Test steps`);let g=ge(e.statements,h+1,i);r.push(...g)}r.push(`${o} } finally {`),r.push(`${o} // Teardown`);let p=ge(e.teardown,h+1,i,"teardown");r.push(...p),r.push(`${o} }`)}else if(e.statements&&e.statements.length>0){r.push(`${o} // Test steps`);let p=ge(e.statements,h,i);r.push(...p)}return r.push(`${o}});`),r}function Vo(e,t,i){let a=[],n=Jo(t),o=Oi(n),r=aa(o);return a.push(`test.${e}(async (${r}) => {`),a.push(...ge(n,1,i,e)),a.push("});"),a}function Pi(e,t,i,a){let n=" ".repeat(a),o=[],r=Jo(t);if(e==="beforeAll"||e==="afterAll"){let l={...i,noAgent:!0};o.push(`${n}test.${e}(async ({ browser }, workerInfo) => {`),o.push(`${n} const page = await browser.newPage({ baseURL: workerInfo.project.use.baseURL });`),o.push(...ge(r,a+1,l,e)),o.push(`${n} await page.close();`),o.push(`${n}});`)}else{let l=Oi(r),c=aa(l);o.push(`${n}test.${e}(async (${c}) => {`),o.push(...ge(r,a+1,i,e)),o.push(`${n}});`)}return o}function Jo(e){let i=(0,Yo.stringify)({goal:"_hook",statements:e});return pe(i).statements??[]}function qo(e,t){let i=qn(e);for(let[a,n]of Object.entries(t))i=i.split(`<<${a}>>`).join(String(n));return pe(i)}function Zo(){return["import { test, expect } from 'shiplightai/fixture';"]}function Qo(e,t){if(t.size>0){let i=0;for(let n=0;n<e.length;n++)e[n].startsWith("import ")&&(i=n+1);let a=Array.from(t);e.splice(i,0,...a)}}var Xo=5;function tr(e,t,i){let a={expandingPaths:new Set([(0,qe.resolve)(t)]),depth:0,referencedPaths:new Set,basePath:i},n={...e};Array.isArray(n.statements)&&(n.statements=Re(n.statements,t,a)),Array.isArray(n.teardown)&&(n.teardown=Re(n.teardown,t,a));for(let o of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(n[o])&&(n[o]=Re(n[o],t,a));return{doc:n,referencedTemplatePaths:Array.from(a.referencedPaths)}}function Re(e,t,i){let a=[];for(let n of e)if(nd(n)){let o=ad(n,t,i);a.push(o)}else a.push(od(n,t,i));return a}function nd(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function ad(e,t,i){if(i.depth>=Xo)throw new Error(`Template expansion exceeded maximum depth of ${Xo}. Check for deeply nested or circular template references.`);let a=(0,qe.resolve)((0,qe.dirname)(t),e.template),n=!(0,Ni.existsSync)(a)&&i.basePath?(0,qe.resolve)(i.basePath,e.template):a;if(i.expandingPaths.has(n))throw new Error(`Circular template reference detected: ${n} is already being expanded. Stack: ${Array.from(i.expandingPaths).join(" \u2192 ")} \u2192 ${n}`);i.referencedPaths.add(n);let o;try{o=(0,Ni.readFileSync)(n,"utf-8")}catch(f){throw new Error(`Failed to read template file: ${n} (referenced from ${t}): ${f.message}`)}let r=(0,vt.parse)(o);if(!r||typeof r!="object")throw new Error(`Invalid template file: ${n} \u2014 expected a YAML object`);let s=r.params||[],l=e.params||{};for(let f of s)if(!(f in l))throw new Error(`Template ${e.template} requires param "${f}" 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 y=(0,vt.stringify)(c);for(let[b,m]of Object.entries(l))y=y.split(`<<${b}>>`).join(String(m));c=(0,vt.parse)(y)}let d={expandingPaths:new Set([...i.expandingPaths,n]),depth:i.depth+1,referencedPaths:i.referencedPaths},h=Re(c,n,d),g={STEP:r.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:h};return Object.keys(l).length>0&&(g.template_params=l),g}function od(e,t,i){if(typeof e!="object"||e===null)return e;let a={...e};return Array.isArray(a.statements)&&(a.statements=Re(a.statements,t,i)),Array.isArray(a.THEN)&&(a.THEN=Re(a.THEN,t,i)),Array.isArray(a.ELSE)&&(a.ELSE=Re(a.ELSE,t,i)),Array.isArray(a.DO)&&(a.DO=Re(a.DO,t,i)),a}var oa=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}};function ra(e,t,i){let a=(0,_t.parse)(e),n=a?.name,o=a?.tags,r=a?.use;if(a&&(a.name!==void 0||a.tags!==void 0||a.use!==void 0)&&(delete a.name,delete a.tags,delete a.use),a?.suite){if(a.goal||a.statements)throw new oa('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return sd(a,n,o,r,t,i)}return rd(a,n,o,r,t,i)}function rd(e,t,i,a,n,o){let r=e?.beforeEach,s=e?.afterEach,l=ir(e?.parameters),c=e?.timeout,d=e?.skip,h=e?.fail,p=e?.only,g=e?.slow,f=e?.settings,y=a;if(f){let _={};f.auto_dismiss_modal!==void 0&&(_.autoDismissModal=!!f.auto_dismiss_modal),f.browser_timezone!==void 0&&f.browser_timezone!==null&&(_.timezoneId=String(f.browser_timezone)),f.browser_language!==void 0&&f.browser_language!==null&&(_.locale=String(f.browser_language)),f.extra_http_headers!==void 0&&f.extra_http_headers!==null&&typeof f.extra_http_headers=="object"&&(_.extraHTTPHeaders=f.extra_http_headers),Object.keys(_).length>0&&(y={...y,..._})}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,delete e.settings),e?.url)throw new oa(`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 b=[];if(n&&e&&typeof e=="object"){let _=tr(e,n,o);e=_.doc,b=_.referencedTemplatePaths}let m=(0,_t.stringify)(e),x=pe(m);return n&&(Je(x.statements??[],n,"main"),x.teardown&&Je(x.teardown,n,"teardown")),{testFlow:x,name:t,tags:i,use:y,beforeEach:r,afterEach:s,parameters:l,timeout:c,skip:d,fail:h,only:p,slow:g,referencedTemplatePaths:b}}function sd(e,t,i,a,n,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,h=[],p=r.tests.map(y=>{if(!y.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(y.statements)||y.statements.length===0)throw new Error(`Suite test "${y.name}" must have a non-empty "statements" array.`);let b={goal:y.name,statements:y.statements};y.teardown&&(b.teardown=y.teardown);let m=[],x=b;if(n&&typeof b=="object"){let $=tr(b,n,o);x=$.doc,m=$.referencedTemplatePaths,h.push(...m)}let _=(0,_t.stringify)(x),E=pe(_),A=ir(y.parameters);return{testFlow:E,name:y.name,tags:Array.isArray(y.tags)?y.tags:void 0,parameters:A,timeout:y.timeout,skip:y.skip,fail:y.fail,only:y.only,slow:y.slow}}),g=r.base_url,f=g?{...a,baseURL:g}:a;return{suite:{beforeAll:s,afterAll:l,beforeEach:c,afterEach:d,tests:p},name:t,tags:i,use:f,referencedTemplatePaths:h}}function ir(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 Je(e,t,i){for(let a=0;a<e.length;a++){let n=e[a],o=`${i}.${a}`,r=n.description||"";if(n.uid=ld(t,o,r),n.type===me.STEP)Je(n.statements,t,o);else if(n.type===me.IF_ELSE){let s=n;Je(s.then,t,`${o}.then`),s.else&&Je(s.else,t,`${o}.else`)}else n.type===me.WHILE_LOOP&&Je(n.body,t,`${o}.body`)}}function ld(e,t,i){let a=(0,er.createHash)("sha256").update(`${e}:${t}:${i}`).digest("hex");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20,32)}`}function ar(e,t,i){let a=/\btemplate:\s/.test(e),n=/^suite:/m.test(e),o=a||n?null:Qn(e);if(o&&!o.valid)return{valid:!1,errors:o.errors,warnings:[],stats:o.stats};let r,s,l=[];try{let c=i?.parsed??ra(e,t);l=c.referencedTemplatePaths;let d={version:i?.version,actionEntityStore:i?.actionEntityStore},h=c.testFlow?.baseURL?{...c.use,baseURL:c.testFlow.baseURL}:c.use;c.suite?r=ed(c.suite,{...d,testName:c.name,tags:c.tags,use:c.use}):r=Qc(c.testFlow,{...d,testName:c.name,tags:c.tags,use:h,beforeEach:c.beforeEach,afterEach:c.afterEach,parameters:c.parameters,timeout:c.timeout,skip:c.skip,fail:c.fail,only:c.only,slow:c.slow});let p=r.split(`
4367
4367
  `).filter(g=>!g.startsWith("import ")).join(`
4368
- `);new Function(p),s=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),(0,kt.mkdirSync)((0,nr.dirname)(s),{recursive:!0}),(0,kt.writeFileSync)(s,r)}catch(c){let d=c instanceof oa?"":c.message.includes("Unexpected token")?" This usually means a YAML escaping issue \u2014 in double-quoted strings, use \\\\/ instead of \\/ for regex patterns, or use single quotes / block scalars.":" This may indicate a transpiler bug \u2014 please report it.";return{valid:!1,errors:[`Transpilation failed: ${c.message}.${d}`],warnings:[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},referencedTemplatePaths:l}}return{valid:!0,errors:[],warnings:o?.warnings??[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},specFile:s,referencedTemplatePaths:l}}var sa="0.1.65";function or(e){try{return(0,Fe.statSync)(e).mtimeMs}catch{return 0}}var cd=`// @generated by shiplightai v${sa}`;function dd(e,t){if(!(0,Fe.existsSync)(e)||(0,Fe.readFileSync)(e,"utf-8").split(`
4368
+ `);new Function(p),s=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),(0,kt.mkdirSync)((0,nr.dirname)(s),{recursive:!0}),(0,kt.writeFileSync)(s,r)}catch(c){let d=c instanceof oa?"":c.message.includes("Unexpected token")?" This usually means a YAML escaping issue \u2014 in double-quoted strings, use \\\\/ instead of \\/ for regex patterns, or use single quotes / block scalars.":" This may indicate a transpiler bug \u2014 please report it.";return{valid:!1,errors:[`Transpilation failed: ${c.message}.${d}`],warnings:[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},referencedTemplatePaths:l}}return{valid:!0,errors:[],warnings:o?.warnings??[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},specFile:s,referencedTemplatePaths:l}}var sa="0.1.67";function or(e){try{return(0,Fe.statSync)(e).mtimeMs}catch{return 0}}var cd=`// @generated by shiplightai v${sa}`;function dd(e,t){if(!(0,Fe.existsSync)(e)||(0,Fe.readFileSync)(e,"utf-8").split(`
4369
4369
  `,1)[0]!==cd)return!1;let a=or(e);for(let n of t)if(or(n)>a)return!1;return!0}function ud(e){let t=process.argv.slice(2),i=[],a=(0,Ze.resolve)(e);for(let n of t){if(n.startsWith("-"))continue;let o=n.endsWith(".yaml.spec.ts")?n.replace(/\.yaml\.spec\.ts$/,".test.yaml"):n;if(!o.endsWith(".test.yaml"))continue;let r=(0,Ze.resolve)(e,o);(0,Fe.existsSync)(r)&&i.push(r.startsWith(a)?r.slice(a.length+1):o)}return i.length>0?i:null}function sr(e){let t=ud(e.cwd),i=t??(0,rr.globSync)("**/*.test.yaml",{cwd:e.cwd,ignore:["**/node_modules/**"]}),a=[];for(let n of i){let o=(0,Ze.resolve)(e.cwd,n),r=o.replace(/\.test\.yaml$/,".yaml.spec.ts"),s=(0,Fe.readFileSync)(o,"utf-8");try{let l=ra(s,o,e.projectRoot??e.cwd),c=(0,Ze.relative)(e.cwd,o),d=e.actionEntityStores?.get(c)??e.actionEntityStores?.get("*");if(!(d&&Object.keys(d.entries).length>0)&&dd(r,[o,...l.referencedTemplatePaths]))continue;let p=ar(s,o,{version:sa,actionEntityStore:d,parsed:l});if(!p.valid)throw new Error(p.errors.join("; "))}catch(l){console.error(`[shiplight] Failed to transpile ${n}:`,l),a.push({file:n,error:l})}}if(a.length>0){let n=`[shiplight] Transpilation failed for ${a.length} file(s):
4370
4370
  `+a.map(o=>` - ${o.file}`).join(`
4371
4371
  `);if(t)throw new Error(n);console.warn(n+" (skipped)")}}var re=X(require("fs"),1),St=X(require("path"),1),gr=require("glob");Fi();function fr(e){let t=Ri().SHIPLIGHT_API_TOKEN;return process.env.CI&&t?new ha:new ua(e)}var vd=".shiplight/action-cache";function pr(e){return e.replace(/\//g,"__")+".json"}function _d(e){return e.replace(/\.json$/,"").replace(/__/g,"/")}var ua=class{constructor(t){this.cwd=t;this.cacheDir=St.join(t,vd)}isCloud=!1;cacheDir;async lookup(t){let i=new Map;if(t.length===0||!re.existsSync(this.cacheDir))return i;for(let a of t){let n=St.join(this.cacheDir,pr(a));try{if(re.existsSync(n)){let o=re.readFileSync(n,"utf-8");i.set(a,JSON.parse(o))}}catch{}}return i}async update(t){if(t.size===0)return 0;re.mkdirSync(this.cacheDir,{recursive:!0});let i=0;for(let[a,n]of t)try{let o=St.join(this.cacheDir,pr(a)),r=ea();if(re.existsSync(o))try{r=JSON.parse(re.readFileSync(o,"utf-8"))}catch{}let s={...r,entries:{...r.entries,...n.entries}};re.writeFileSync(o,JSON.stringify(s,null,2)),i++}catch{}return i}loadAll(){if(!re.existsSync(this.cacheDir))return;let t=(0,gr.globSync)("*.json",{cwd:this.cacheDir});if(t.length===0)return;let i=new Map,a=0;for(let n of t)try{let o=re.readFileSync(St.join(this.cacheDir,n),"utf-8"),r=JSON.parse(o),s=_d(n);i.set(s,r),a+=Object.keys(r.entries??{}).length}catch{}if(i.size!==0)return console.log(`[shiplight] Cache: loaded ${a} cached action entit${a===1?"y":"ies"} for ${i.size} test file${i.size!==1?"s":""}`),i}},ha=class{isCloud=!0;async lookup(t){let{lookupActionStores:i}=await Promise.resolve().then(()=>(da(),ca));return i(t)}async update(t){let{updateActionStores:i}=await Promise.resolve().then(()=>(da(),ca));return i(t)}loadAll(){}};Fi();function yr(e={}){e.dotenv!==!1&&kd(e.scanDir||process.cwd());let t=e.scanDir||process.cwd(),a=fr(t).loadAll();return sr({cwd:t,projectRoot:process.cwd(),actionEntityStores:a}),{reporter:[["list"],["shiplightai/reporter",{outputFolder:"shiplight-report",open:"never"}]]}}function xr(e,...t){return(0,br.defineConfig)(e,...t)}function kd(e){dr(e);for(let t of la(e))wr.default.config({path:t})}F();F();jt();nt();var ro=require("zod"),Sh=ro.z.object({instruction:ro.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 Dl(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:Sh,usesElementIndex:!1,async execute(t,i){let{instruction:a}=t,n={page:i.page,agentServices:i.agentServices,domService:i.domService},o=await it(a,n,{});if(o.status==="error"||!o.actionEntity)return{success:!1,actionEntity:{action_description:a,action_data:{action_name:"perform_accurate_operation",kwargs:{instruction:a}}},error:o.error||"Failed to generate action"};let{actionEntity:r}=o,s=await Bt(r,n);return{success:s.success,actionEntity:r,message:s.success?`Successfully executed action: ${r.action_data?.action_name}`:void 0,error:s.error}}})}$e();F();var Rl=require("ai"),Fl=require("html-to-text");async function Eh(e,t,i){let{apiKey:a,domain:n}=e;if(!a||!n)throw new Error("Mailgun configuration missing. Please provide apiKey and domain");let o=[];try{let r=`https://api.mailgun.net/v3/${n}/events`,s={event:"accepted",limit:"10",ascending:"yes",recipient:t};if(i.from_email&&(s.from=i.from_email),i.since)s.begin=Math.floor(i.since/1e3).toString();else{let d=new Date(Date.now()-6e5);s.begin=Math.floor(d.getTime()/1e3).toString()}u.info(`Mailgun params: ${JSON.stringify(s)}`);let l=await fetch(r+"?"+new URLSearchParams(s),{method:"GET",headers:{Authorization:`Basic ${Buffer.from(`api:${a}`).toString("base64")}`}});if(!l.ok){let d=await l.text();throw new Error(`Mailgun events API error: ${d}`)}let c=(await l.json()).items||[];for(let d of c.slice(0,10)){if(d.event!=="accepted")continue;let h=(d.storage||{}).url;if(u.info(`message_url: ${h}`),!h){let f=(d.message||{}).headers||{},y=f.subject||"",b=f.from||"",m=f.to||"";if(i.from_email&&!b.toLowerCase().includes(i.from_email.toLowerCase())||i.to_email&&!m.toLowerCase().includes(i.to_email.toLowerCase())||i.subject&&!y.toLowerCase().includes(i.subject.toLowerCase()))continue;o.push({subject:y,from:b,to:m,date:new Date(d.timestamp*1e3).toUTCString(),body:"Message body not available (Mailgun storage disabled)",message_id:f["message-id"]||""});continue}let p=h.split("/"),g=p[p.length-1];if(u.info(`Storage key: ${g}`),g){let f=`https://api.mailgun.net/v3/domains/${n}/messages/${g}`;try{let y=await fetch(f,{method:"GET",headers:{Authorization:`Basic ${Buffer.from(`api:${a}`).toString("base64")}`,Accept:"application/json"}});if(y.ok){let b=await y.json(),m=b.Subject||"",x=b.From||"",_=b.To||"",E=b.Date||"",A=b["Message-Id"]||"";u.info(`subject: ${m}`),u.info(`from_addr: ${x}`),u.info(`to_addr: ${_}`),u.info(`date: ${E}`),u.info(`message_id: ${A}`);let $=b["body-html"]||b["body-plain"]||"";if($&&$.includes("<")&&($=(0,Fl.convert)($)),u.info(`Body: ${$.substring(0,200)}...`),i.subject&&!m.toLowerCase().includes(i.subject.toLowerCase())||i.body_contains&&!$.toLowerCase().includes(i.body_contains.toLowerCase()))continue;o.push({subject:m,from:x,to:_,date:E,body:$,message_id:A});continue}else u.warn(`Messages API returned ${y.status}`)}catch(y){u.warn(`Failed to parse JSON response: ${y}`)}}try{let f=await fetch(h,{method:"GET",headers:{Authorization:`Basic ${Buffer.from(`api:${a}`).toString("base64")}`}});if(!f.ok){u.warn(`Could not fetch stored message: ${f.status}`);continue}let y=await f.text();u.info(`Fallback: Raw email length: ${y.length}`);let b=y.split(`