shiplightai 0.1.96 → 0.1.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/reporter.js CHANGED
@@ -1,9 +1,9 @@
1
- import*as x from"fs";import*as v from"path";var R=(e,t,r)=>{e.forEach((i,n)=>{let a=`${t}.${n}`;i.type==="DRAFT"?r[a]={description:i.description||"Draft",action_entity:void 0}:i.type==="ACTION"?r[a]={description:i.description||"Action",action_entity:i.action_entity,locator:i.locator}:i.type==="STEP"&&i.statements?R(i.statements,a,r):i.type==="IF_ELSE"?(r[a]={description:"IF "+(i.condition?.expression||""),action_entity:void 0},i.then&&R(i.then,`${a}.then`,r),i.else&&R(i.else,`${a}.else`,r)):i.type==="WHILE_LOOP"&&(r[a]={description:"WHILE "+(i.condition?.expression||""),action_entity:void 0},i.body&&R(i.body,`${a}.body`,r))})};function z(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return R(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&R(e.teardown,"teardown",t),t}import{z as c}from"zod";var xe=c.enum(["JS_CODE","AI_MODE"]),se=c.object({type:xe,expression:c.string()}),ke=c.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),G=c.object({uid:c.string(),type:ke,comment:c.string().optional()}),Ae=c.object({action_data:c.object({action_name:c.string(),kwargs:c.record(c.any()).optional(),args:c.array(c.any()).optional()}),action_description:c.string().optional(),url:c.string().optional(),xpath:c.string().nullable().optional(),locator:c.string().nullable().optional(),css_selector:c.string().nullable().optional(),unique_selector:c.string().nullable().optional(),element_index:c.number().nullable().optional(),frame_path:c.array(c.any()).optional(),artifacts:c.record(c.any()).optional(),feedback:c.string().optional(),original_browser_use_action:c.any().optional()}).passthrough(),Te=G.extend({type:c.literal("DRAFT"),description:c.string()}),Ee=G.extend({type:c.literal("ACTION"),description:c.string(),action_entity:Ae.optional(),locator:c.string().optional(),use_pure_vision:c.boolean().optional()}),I=c.lazy(()=>c.union([Te,Ee,G.extend({type:c.literal("STEP"),description:c.string().optional().default(""),statements:c.array(I),reference_id:c.number().optional(),template_path:c.string().optional(),template_params:c.record(c.string()).optional()}),G.extend({type:c.literal("IF_ELSE"),description:c.string().optional(),condition:se,then:c.array(I),else:c.array(I).optional()}),G.extend({type:c.literal("WHILE_LOOP"),description:c.string().optional(),condition:se,body:c.array(I),timeout_ms:c.number().optional()})])),$e=c.object({name:c.string(),statements:c.array(I),teardown:c.array(I).optional(),skip:c.union([c.boolean(),c.string()]).optional(),timeout:c.number().optional(),fail:c.union([c.boolean(),c.string()]).optional(),only:c.boolean().optional(),slow:c.boolean().optional()}),J=c.object({tests:c.array($e).min(1),beforeAll:c.array(I).optional(),afterAll:c.array(I).optional(),beforeEach:c.array(I).optional(),afterEach:c.array(I).optional()}),ce=c.object({comment:c.string().optional(),version:c.string().optional(),goal:c.string().optional(),url:c.string().optional(),baseURL:c.string().optional(),final_feedback:c.string().optional(),completed:c.boolean().optional(),success:c.boolean().optional(),statements:c.array(I).optional(),teardown:c.array(I).optional(),last_modified_at:c.string().optional(),testGroup:J.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"});import{stringify as Pr,parse as gt,parseAllDocuments as Or,parseDocument as mt,Document as Ir,isMap as Y,isSeq as U}from"yaml";import{v4 as L}from"uuid";function le(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(le);let t=e,r=Object.keys(t);if(r.length===1){let n=r[0];if(n.startsWith("{ ")&&n.endsWith(" }")&&t[n]===null)return`{{${n.slice(2,-2)}}}`}let i={};for(let[n,a]of Object.entries(t))i[n]=le(a);return i}var Me=1024*1024;function F(e){if(e.length>Me)throw new Error(`YAML input too large (${e.length} bytes, max ${Me})`);let t=le(gt(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return yt(t);let r={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:C(t.statements??[])};t.final_feedback&&(r.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(r.teardown=C(t.teardown));let i=ce.safeParse(r);if(!i.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(i.error.errors)}`);let n=i.data;return Oe(e,n),n}function yt(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let r=t.tests;if(!Array.isArray(r)||r.length===0)throw new Error('Suite must have a non-empty "tests" array');let n={tests:r.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:C(s.statements)};return Array.isArray(s.teardown)&&s.teardown.length>0&&(l.teardown=C(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=C(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(n.afterAll=C(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(n.beforeEach=C(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(n.afterEach=C(t.afterEach));let a=J.safeParse(n);if(!a.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(a.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:a.data}}function C(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(_t)}function _t(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 bt(t);if("WHILE"in t)return wt(t);if("STEP"in t)return St(t);if("VERIFY"in t){let r=t.VERIFY,i={statement:typeof r=="string"?r:String(r)};return typeof t.js=="string"&&(i.code=t.js),{uid:L(),type:"ACTION",description:String(r),action_entity:{action_description:String(r),action_data:{action_name:"verify",kwargs:i}}}}if("URL"in t){let r=t.URL,i=t.new_tab===!0?!0:void 0,n=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,a={url:typeof r=="string"?r:String(r)};return i&&(a.new_tab=!0),n!==void 0&&(a.timeout_seconds=n),{uid:L(),type:"ACTION",description:`Navigate to ${r}`,action_entity:{action_description:`Navigate to ${r}`,action_data:{action_name:"go_to_url",kwargs:a}}}}if("WAIT_UNTIL"in t){let r=typeof t.WAIT_UNTIL=="string"?t.WAIT_UNTIL:String(t.WAIT_UNTIL),i=ue(r),n=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;if(typeof t.js=="string"){if(i.type==="JS_CODE")throw new Error('WAIT_UNTIL cannot combine a "js:"-prefixed condition with a sibling "js:" key \u2014 put the intent in WAIT_UNTIL and the expression in js:');return{uid:L(),type:"ACTION",description:`Wait until: ${r}`,action_entity:{action_description:`Wait until: ${r}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:r,condition_type:"JS_CODE",js:t.js,timeout_seconds:n}}}}}return{uid:L(),type:"ACTION",description:`Wait until: ${i.expression}`,action_entity:{action_description:`Wait until: ${i.expression}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:i.expression,condition_type:i.type,timeout_seconds:n}}}}}if("WAIT"in t){let r=t.WAIT,i=typeof t.seconds=="number"?t.seconds:3;return{uid:L(),type:"ACTION",description:typeof r=="string"?r:`Wait ${i}s`,action_entity:{action_description:typeof r=="string"?r:`Wait ${i}s`,action_data:{action_name:"wait",kwargs:{seconds:i}}}}}if("CODE"in t){let r=t.CODE;if(r==null)throw new Error('CODE statement has no code. Use "CODE: |" followed by indented code on the next line.');let i=typeof t.description=="string"?t.description:"Code block";return{uid:L(),type:"ACTION",description:i,action_entity:{action_description:i,action_data:{action_name:"js_code",kwargs:{code:typeof r=="string"?r:String(r)}}}}}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 r=typeof t.description=="string"&&t.description.trim()!==""?t.description:"Code block",i=t.js;return{uid:L(),type:"ACTION",description:r,action_entity:{action_description:r,action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:r,...i}=t;return Pe({...i,action:"function",functionName:r})}if("action"in t)return Pe(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:L(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function ue(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 bt(e){let t=ue(e.IF),r=e.THEN;if(!Array.isArray(r))throw new Error("IF_ELSE requires a THEN array");let i={uid:L(),type:"IF_ELSE",condition:t,then:C(r)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(i.else=C(e.ELSE)),i}function wt(e){let t=ue(e.WHILE),r=e.DO;if(!Array.isArray(r))throw new Error("WHILE_LOOP requires a DO array");let i={uid:L(),type:"WHILE_LOOP",condition:t,body:C(r)};return typeof e.timeout_ms=="number"&&(i.timeout_ms=e.timeout_ms),i}function St(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let r={uid:L(),type:"STEP",description:t,statements:C(e.statements)};if(typeof e.reference_id=="number"&&(r.reference_id=e.reference_id),typeof e.template_path=="string"&&(r.template_path=e.template_path),e.template_params&&typeof e.template_params=="object"&&!Array.isArray(e.template_params)){let i=e.template_params,n={};for(let[a,o]of Object.entries(i))n[a]=String(o);r.template_params=n}return r}var vt=new Set(["action","intent","desc","locator","xpath","use_pure_vision"]);function Pe(e){let t=typeof e.action=="string"?e.action:String(e.action),r=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",i=typeof e.locator=="string"?e.locator:void 0,n=typeof e.xpath=="string"?e.xpath:void 0,a=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,o={};for(let[u,_]of Object.entries(e))vt.has(u)||(o[u]=_);t==="verify"&&typeof o.js=="string"&&(o.code=o.js,delete o.js),(t==="ai_action"||t==="ai_step")&&(o.statement===void 0&&(o.statement=r),a&&(o.use_pure_vision=!0));let s={action_description:r,action_data:{action_name:t,kwargs:Object.keys(o).length>0?o:{}}};i&&(s.locator=i),n&&(s.xpath=n);let l={uid:L(),type:"ACTION",description:r,action_entity:s};return a&&(l.use_pure_vision=!0),l}function Oe(e,t){let r;try{r=mt(e)}catch{return}let i=r.contents;if(!i||!Y(i))return;if(r.commentBefore)t.comment=r.commentBefore;else{let l=i.items?.[0];l?.key&&l.key.commentBefore&&(t.comment=l.key.commentBefore)}let n=i,a=n.get("statements",!0);U(a)&&t.statements&&H(a,t.statements);let o=n.get("teardown",!0);U(o)&&t.teardown&&H(o,t.teardown)}function H(e,t){e.commentBefore&&t.length>0&&(t[0].comment=e.commentBefore);for(let r=0;r<Math.min(e.items.length,t.length);r++){let i=e.items[r];i.commentBefore&&!(r===0&&e.commentBefore)&&(t[r].comment=i.commentBefore);let n=t[r];if(n.type==="STEP"&&Y(i)){let a=i.get("statements",!0);U(a)&&H(a,n.statements)}else if(n.type==="IF_ELSE"&&Y(i)){let a=i.get("THEN",!0);U(a)&&H(a,n.then);let o=i.get("ELSE",!0);U(o)&&n.else&&H(o,n.else)}else if(n.type==="WHILE_LOOP"&&Y(i)){let a=i.get("DO",!0);U(a)&&H(a,n.body)}}}import{v4 as Gr}from"uuid";import{parse as Kr,stringify as Vr}from"yaml";var B=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(B||{});var Ie=112;var Et=1080-Ie;var Le={"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 Ce={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"]},V=(e,t=!1)=>{let r=["chromium"];return t&&r.push("webkit"),Ce[e].map(i=>Le[i]).filter(i=>i.defaultBrowserType&&r.includes(i.defaultBrowserType))};var $t={desktop:{label:"Desktop",type:"desktop",devices:V("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:V("mobile")}},Mt={desktop:{label:"Desktop",type:"desktop",devices:V("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:V("mobile",!0)}};var pe=Object.freeze(["lite","standard","pro"]);function de(e){return typeof e=="string"&&pe.includes(e)}var q=1,Z="SHIPLIGHT_TIER_MAP",Q="WEB_AGENT_TIER",Re=Object.freeze(["WEB_AGENT_MODEL","WEB_AGENT_FALLBACK_MODELS","COMPUTER_USE_MODEL"]),ee=Fe({version:q,defaultTier:"lite",tiers:{lite:{webagent:{primary:"google:gemini-3-flash-preview",fallbacks:["anthropic:claude-haiku-4-5","openai:gpt-5.6-luna"]}},standard:{webagent:{primary:"google:gemini-3.5-flash",fallbacks:["anthropic:claude-sonnet-5","openai:gpt-5.6-terra"]}},pro:{webagent:{primary:"anthropic:claude-opus-4-8",fallbacks:["openai:gpt-5.6-sol","anthropic:claude-opus-4-7"]}}},computerUse:{primary:"google:gemini-3-flash-preview",fallbacks:[]}});function Fe(e){if(e!==null&&typeof e=="object"){for(let t of Object.values(e))Fe(t);Object.freeze(e)}return e}function X(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ne(e){if(!X(e))return;let{primary:t,fallbacks:r}=e;if(!(typeof t!="string"||t.trim()!==t||t==="")){if(r===void 0)return{primary:t,fallbacks:[]};if(Array.isArray(r)&&r.every(i=>typeof i=="string"&&i.trim()===i&&i!==""))return{primary:t,fallbacks:[...r]}}}function fe(e){if(!X(e)||e.version!==q||!de(e.defaultTier)||!X(e.tiers))return;let t={};for(let i of pe){let n=e.tiers[i];if(!X(n))return;let a=Ne(n.webagent);if(!a)return;t[i]={webagent:a}}let r=Ne(e.computerUse);if(r)return{version:q,defaultTier:e.defaultTier,tiers:t,computerUse:r}}function Be(e){if(e)try{return fe(JSON.parse(e))}catch{return}}function De(e){return{primary:e.primary,fallbacks:[...e.fallbacks]}}function te(e){let t=Be(e[Z]),r=t??ee,i=t?"server":"baked",n=e[Q]||void 0,a=de(n)?n:void 0,o=n!==void 0&&a===void 0?n:void 0,s=a??r.defaultTier,l=a?"env":i==="server"?"org-default":"baked-default",u=Re.filter(_=>!!e[_]);return{tier:s,tierSource:l,mapSource:i,webagent:De(r.tiers[s].webagent),computerUse:De(r.computerUse),ignoredEnvVars:[...u],...o!==void 0&&{invalidTier:o}}}function he(e){return!!(e.GOOGLE_API_KEY||ge(e)||e.ANTHROPIC_API_KEY||e.OPENAI_API_KEY)}function ge(e){let t=e.GOOGLE_GENAI_USE_VERTEXAI;return(t==="true"||t==="True")&&!!e.GOOGLE_CLOUD_PROJECT}function re(e){return!e.SHIPLIGHT_API_TOKEN||he(e)?!1:!!(e[Z]||e[Q])}var Pt=Object.freeze([...ee.tiers.standard.webagent.fallbacks]);import{stringify as _o}from"yaml";import me from"node:path";import{createHash as Nt}from"crypto";import{parse as Dt,stringify as Ke}from"yaml";import{readFileSync as Rt,existsSync as Ft}from"fs";import{resolve as ye,dirname as Bt}from"path";import{parse as Ge,stringify as Wt}from"yaml";var He=5e3;function Lt(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function Ct(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 je(e){let t=Lt(e),r=e.locator;if(typeof r=="string"&&r.trim())return r=r.trim(),r.endsWith("first()")?`${t}.${r}`:`${t}.${r}.first()`;let i=Ct(e);if(i){let n=JSON.stringify(i);return`${t}.locator(${n}).first()`}return null}var O=new Map;function f(e,t){O.set(e,t)}function W(e,t,r=[]){let i=[...r];return t.locator?i.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&i.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(t.frame_path)}`),i.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...i.map(n=>` ${n},`),"});"]}f("click",e=>{let t=je(e);if(!t)return['await agent.execAction("click", page, {});'];let r=e.action_data?.kwargs?.timeout_ms??He;return[`await ${t}.click({ timeout: ${r} });`]});f("click_element",O.get("click"));f("click_element_by_index",O.get("click"));f("double_click",e=>W("double_click",e));f("double_click_on_element",O.get("double_click"));f("right_click",e=>W("right_click",e));f("right_click_on_element",O.get("right_click"));f("hover",e=>W("hover",e));f("hover_element_by_index",O.get("hover"));f("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return W("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});f("fill",O.get("input_text"));f("clear_input",e=>W("clear_input",e));f("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});f("send_keys",O.get("press"));f("send_keys_on_element",e=>{let t=je(e),r=e.action_data?.kwargs?.keys||"";if(!t)return['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(r)} } },`,"});"];let i=e.action_data?.kwargs?.timeout_ms??He;return[`await ${t}.press(${JSON.stringify(r)}, { timeout: ${i} });`]});f("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return W("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});f("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)})');`]});f("scroll_down",O.get("scroll"));f("scroll_up",O.get("scroll"));f("scroll_element",O.get("scroll"));f("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});f("scroll_on_element",e=>W("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));f("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)} } },`,"});"]});f("open_tab",O.get("go_to_url"));f("go_back",()=>['await agent.execAction("go_back", page, {});']);f("reload_page",()=>['await agent.execAction("reload_page", page, {});']);f("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);f("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);f("verify",(e,t)=>{let r=e.action_data?.kwargs,i=typeof r?.code=="string",n=i?r?.statement||e.action_description:e.action_description||r?.statement;if(i&&n){let o=r.code.split(`
1
+ import*as x from"fs";import*as v from"path";import{z as c}from"zod";var ke=c.enum(["JS_CODE","AI_MODE"]),ce=c.object({type:ke,expression:c.string()}),Ae=c.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),U=c.object({uid:c.string(),type:Ae,comment:c.string().optional()}),Te=c.object({action_data:c.object({action_name:c.string(),kwargs:c.record(c.any()).optional(),args:c.array(c.any()).optional()}),action_description:c.string().optional(),url:c.string().optional(),xpath:c.string().nullable().optional(),locator:c.string().nullable().optional(),css_selector:c.string().nullable().optional(),unique_selector:c.string().nullable().optional(),element_index:c.number().nullable().optional(),frame_path:c.array(c.any()).optional(),artifacts:c.record(c.any()).optional(),feedback:c.string().optional(),original_browser_use_action:c.any().optional()}).passthrough(),Ee=U.extend({type:c.literal("DRAFT"),description:c.string()}),$e=U.extend({type:c.literal("ACTION"),description:c.string(),action_entity:Te.optional(),locator:c.string().optional(),use_pure_vision:c.boolean().optional()}),I=c.lazy(()=>c.union([Ee,$e,U.extend({type:c.literal("STEP"),description:c.string().optional().default(""),statements:c.array(I),reference_id:c.number().optional(),template_path:c.string().optional(),template_params:c.record(c.string()).optional()}),U.extend({type:c.literal("IF_ELSE"),description:c.string().optional(),condition:ce,then:c.array(I),else:c.array(I).optional()}),U.extend({type:c.literal("WHILE_LOOP"),description:c.string().optional(),condition:ce,body:c.array(I),timeout_ms:c.number().optional()})])),Me=c.object({name:c.string(),statements:c.array(I),teardown:c.array(I).optional(),skip:c.union([c.boolean(),c.string()]).optional(),timeout:c.number().optional(),fail:c.union([c.boolean(),c.string()]).optional(),only:c.boolean().optional(),slow:c.boolean().optional()}),z=c.object({tests:c.array(Me).min(1),beforeAll:c.array(I).optional(),afterAll:c.array(I).optional(),beforeEach:c.array(I).optional(),afterEach:c.array(I).optional()}),le=c.object({comment:c.string().optional(),version:c.string().optional(),goal:c.string().optional(),url:c.string().optional(),baseURL:c.string().optional(),final_feedback:c.string().optional(),completed:c.boolean().optional(),success:c.boolean().optional(),statements:c.array(I).optional(),teardown:c.array(I).optional(),last_modified_at:c.string().optional(),testGroup:z.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"});import{stringify as Br,parse as _t,parseAllDocuments as Wr,parseDocument as bt,Document as Ur,isMap as J,isSeq as G}from"yaml";import{v4 as L}from"uuid";function ue(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(ue);let t=e,r=Object.keys(t);if(r.length===1){let n=r[0];if(n.startsWith("{ ")&&n.endsWith(" }")&&t[n]===null)return`{{${n.slice(2,-2)}}}`}let i={};for(let[n,a]of Object.entries(t))i[n]=ue(a);return i}var Pe=1024*1024;function R(e){if(e.length>Pe)throw new Error(`YAML input too large (${e.length} bytes, max ${Pe})`);let t=ue(_t(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return wt(t);let r={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:C(t.statements??[])};t.final_feedback&&(r.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(r.teardown=C(t.teardown));let i=le.safeParse(r);if(!i.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(i.error.errors)}`);let n=i.data;return Ie(e,n),n}function wt(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let r=t.tests;if(!Array.isArray(r)||r.length===0)throw new Error('Suite must have a non-empty "tests" array');let n={tests:r.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:C(s.statements)};return Array.isArray(s.teardown)&&s.teardown.length>0&&(l.teardown=C(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=C(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(n.afterAll=C(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(n.beforeEach=C(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(n.afterEach=C(t.afterEach));let a=z.safeParse(n);if(!a.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(a.error.errors)}`);return{version:"1.3.0",baseURL:(t.base_url??e.base_url)||void 0,testGroup:a.data}}function C(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(St)}function St(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 vt(t);if("WHILE"in t)return xt(t);if("STEP"in t)return kt(t);if("VERIFY"in t){let r=t.VERIFY,i={statement:typeof r=="string"?r:String(r)};return typeof t.js=="string"&&(i.code=t.js),{uid:L(),type:"ACTION",description:String(r),action_entity:{action_description:String(r),action_data:{action_name:"verify",kwargs:i}}}}if("URL"in t){let r=t.URL,i=t.new_tab===!0?!0:void 0,n=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,a={url:typeof r=="string"?r:String(r)};return i&&(a.new_tab=!0),n!==void 0&&(a.timeout_seconds=n),{uid:L(),type:"ACTION",description:`Navigate to ${r}`,action_entity:{action_description:`Navigate to ${r}`,action_data:{action_name:"go_to_url",kwargs:a}}}}if("WAIT_UNTIL"in t){let r=typeof t.WAIT_UNTIL=="string"?t.WAIT_UNTIL:String(t.WAIT_UNTIL),i=pe(r),n=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;if(typeof t.js=="string"){if(i.type==="JS_CODE")throw new Error('WAIT_UNTIL cannot combine a "js:"-prefixed condition with a sibling "js:" key \u2014 put the intent in WAIT_UNTIL and the expression in js:');return{uid:L(),type:"ACTION",description:`Wait until: ${r}`,action_entity:{action_description:`Wait until: ${r}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:r,condition_type:"JS_CODE",js:t.js,timeout_seconds:n}}}}}return{uid:L(),type:"ACTION",description:`Wait until: ${i.expression}`,action_entity:{action_description:`Wait until: ${i.expression}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:i.expression,condition_type:i.type,timeout_seconds:n}}}}}if("WAIT"in t){let r=t.WAIT,i=typeof t.seconds=="number"?t.seconds:3;return{uid:L(),type:"ACTION",description:typeof r=="string"?r:`Wait ${i}s`,action_entity:{action_description:typeof r=="string"?r:`Wait ${i}s`,action_data:{action_name:"wait",kwargs:{seconds:i}}}}}if("CODE"in t){let r=t.CODE;if(r==null)throw new Error('CODE statement has no code. Use "CODE: |" followed by indented code on the next line.');let i=typeof t.description=="string"?t.description:"Code block";return{uid:L(),type:"ACTION",description:i,action_entity:{action_description:i,action_data:{action_name:"js_code",kwargs:{code:typeof r=="string"?r:String(r)}}}}}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 r=typeof t.description=="string"&&t.description.trim()!==""?t.description:"Code block",i=t.js;return{uid:L(),type:"ACTION",description:r,action_entity:{action_description:r,action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:r,...i}=t;return Oe({...i,action:"function",functionName:r})}if("action"in t)return Oe(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:L(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function pe(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 vt(e){let t=pe(e.IF),r=e.THEN;if(!Array.isArray(r))throw new Error("IF_ELSE requires a THEN array");let i={uid:L(),type:"IF_ELSE",condition:t,then:C(r)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(i.else=C(e.ELSE)),i}function xt(e){let t=pe(e.WHILE),r=e.DO;if(!Array.isArray(r))throw new Error("WHILE_LOOP requires a DO array");let i={uid:L(),type:"WHILE_LOOP",condition:t,body:C(r)};return typeof e.timeout_ms=="number"&&(i.timeout_ms=e.timeout_ms),i}function kt(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let r={uid:L(),type:"STEP",description:t,statements:C(e.statements)};if(typeof e.reference_id=="number"&&(r.reference_id=e.reference_id),typeof e.template_path=="string"&&(r.template_path=e.template_path),e.template_params&&typeof e.template_params=="object"&&!Array.isArray(e.template_params)){let i=e.template_params,n={};for(let[a,o]of Object.entries(i))n[a]=String(o);r.template_params=n}return r}var At=new Set(["action","intent","desc","locator","xpath","use_pure_vision"]);function Oe(e){let t=typeof e.action=="string"?e.action:String(e.action),r=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",i=typeof e.locator=="string"?e.locator:void 0,n=typeof e.xpath=="string"?e.xpath:void 0,a=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,o={};for(let[u,_]of Object.entries(e))At.has(u)||(o[u]=_);t==="verify"&&typeof o.js=="string"&&(o.code=o.js,delete o.js),(t==="ai_action"||t==="ai_step")&&(o.statement===void 0&&(o.statement=r),a&&(o.use_pure_vision=!0));let s={action_description:r,action_data:{action_name:t,kwargs:Object.keys(o).length>0?o:{}}};i&&(s.locator=i),n&&(s.xpath=n);let l={uid:L(),type:"ACTION",description:r,action_entity:s};return a&&(l.use_pure_vision=!0),l}function Ie(e,t){let r;try{r=bt(e)}catch{return}let i=r.contents;if(!i||!J(i))return;if(r.commentBefore)t.comment=r.commentBefore;else{let l=i.items?.[0];l?.key&&l.key.commentBefore&&(t.comment=l.key.commentBefore)}let n=i,a=n.get("statements",!0);G(a)&&t.statements&&H(a,t.statements);let o=n.get("teardown",!0);G(o)&&t.teardown&&H(o,t.teardown)}function H(e,t){e.commentBefore&&t.length>0&&(t[0].comment=e.commentBefore);for(let r=0;r<Math.min(e.items.length,t.length);r++){let i=e.items[r];i.commentBefore&&!(r===0&&e.commentBefore)&&(t[r].comment=i.commentBefore);let n=t[r];if(n.type==="STEP"&&J(i)){let a=i.get("statements",!0);G(a)&&H(a,n.statements)}else if(n.type==="IF_ELSE"&&J(i)){let a=i.get("THEN",!0);G(a)&&H(a,n.then);let o=i.get("ELSE",!0);G(o)&&n.else&&H(o,n.else)}else if(n.type==="WHILE_LOOP"&&J(i)){let a=i.get("DO",!0);G(a)&&H(a,n.body)}}}import{parse as Vr,stringify as zr}from"yaml";var F=(e,t,r)=>{e.forEach((i,n)=>{let a=`${t}.${n}`;i.type==="DRAFT"?r[a]={description:i.description||"Draft",action_entity:void 0}:i.type==="ACTION"?r[a]={description:i.description||"Action",action_entity:i.action_entity,locator:i.locator}:i.type==="STEP"&&i.statements?F(i.statements,a,r):i.type==="IF_ELSE"?(r[a]={description:"IF "+(i.condition?.expression||""),action_entity:void 0},i.then&&F(i.then,`${a}.then`,r),i.else&&F(i.else,`${a}.else`,r)):i.type==="WHILE_LOOP"&&(r[a]={description:"WHILE "+(i.condition?.expression||""),action_entity:void 0},i.body&&F(i.body,`${a}.body`,r))})};function Y(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return F(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&F(e.teardown,"teardown",t),t}import{v4 as ii}from"uuid";var B=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(B||{});var Le=112;var Pt=1080-Le;var Ce={"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 Ne={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"]},V=(e,t=!1)=>{let r=["chromium"];return t&&r.push("webkit"),Ne[e].map(i=>Ce[i]).filter(i=>i.defaultBrowserType&&r.includes(i.defaultBrowserType))};var Ot={desktop:{label:"Desktop",type:"desktop",devices:V("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:V("mobile")}},It={desktop:{label:"Desktop",type:"desktop",devices:V("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:V("mobile",!0)}};var de=Object.freeze(["lite","standard","pro"]);function fe(e){return typeof e=="string"&&de.includes(e)}var q=1,Z="SHIPLIGHT_TIER_MAP",Q="WEB_AGENT_TIER",Fe=Object.freeze(["WEB_AGENT_MODEL","WEB_AGENT_FALLBACK_MODELS","COMPUTER_USE_MODEL"]),ee=Be({version:q,defaultTier:"lite",tiers:{lite:{webagent:{primary:"google:gemini-3-flash-preview",fallbacks:["anthropic:claude-haiku-4-5","openai:gpt-5.6-luna"]}},standard:{webagent:{primary:"google:gemini-3.5-flash",fallbacks:["anthropic:claude-sonnet-5","openai:gpt-5.6-terra"]}},pro:{webagent:{primary:"anthropic:claude-opus-4-8",fallbacks:["openai:gpt-5.6-sol","anthropic:claude-opus-4-7"]}}},computerUse:{primary:"google:gemini-3-flash-preview",fallbacks:[]}});function Be(e){if(e!==null&&typeof e=="object"){for(let t of Object.values(e))Be(t);Object.freeze(e)}return e}function X(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function De(e){if(!X(e))return;let{primary:t,fallbacks:r}=e;if(!(typeof t!="string"||t.trim()!==t||t==="")){if(r===void 0)return{primary:t,fallbacks:[]};if(Array.isArray(r)&&r.every(i=>typeof i=="string"&&i.trim()===i&&i!==""))return{primary:t,fallbacks:[...r]}}}function he(e){if(!X(e)||e.version!==q||!fe(e.defaultTier)||!X(e.tiers))return;let t={};for(let i of de){let n=e.tiers[i];if(!X(n))return;let a=De(n.webagent);if(!a)return;t[i]={webagent:a}}let r=De(e.computerUse);if(r)return{version:q,defaultTier:e.defaultTier,tiers:t,computerUse:r}}function We(e){if(e)try{return he(JSON.parse(e))}catch{return}}function Re(e){return{primary:e.primary,fallbacks:[...e.fallbacks]}}function te(e){let t=We(e[Z]),r=t??ee,i=t?"server":"baked",n=e[Q]||void 0,a=fe(n)?n:void 0,o=n!==void 0&&a===void 0?n:void 0,s=a??r.defaultTier,l=a?"env":i==="server"?"org-default":"baked-default",u=Fe.filter(_=>!!e[_]);return{tier:s,tierSource:l,mapSource:i,webagent:Re(r.tiers[s].webagent),computerUse:Re(r.computerUse),ignoredEnvVars:[...u],...o!==void 0&&{invalidTier:o}}}function ge(e){return!!(e.GOOGLE_API_KEY||me(e)||e.ANTHROPIC_API_KEY||e.OPENAI_API_KEY)}function me(e){let t=e.GOOGLE_GENAI_USE_VERTEXAI;return(t==="true"||t==="True")&&!!e.GOOGLE_CLOUD_PROJECT}function re(e){return!e.SHIPLIGHT_API_TOKEN||ge(e)?!1:!!(e[Z]||e[Q])}var Lt=Object.freeze([...ee.tiers.standard.webagent.fallbacks]);import{stringify as Po}from"yaml";import ye from"node:path";import{createHash as Bt}from"crypto";import{parse as Wt,stringify as ze}from"yaml";import{readFileSync as Ut,existsSync as Gt}from"fs";import{resolve as _e,dirname as Ht}from"path";import{parse as Ge,stringify as jt}from"yaml";import{existsSync as Jt}from"fs";import{dirname as Ye,isAbsolute as Yt,join as Xt,relative as qt}from"path";var Ke=5e3;function Rt(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function Ft(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 Ve(e){let t=Rt(e),r=e.locator;if(typeof r=="string"&&r.trim())return r=r.trim(),r.endsWith("first()")?`${t}.${r}`:`${t}.${r}.first()`;let i=Ft(e);if(i){let n=JSON.stringify(i);return`${t}.locator(${n}).first()`}return null}var O=new Map;function f(e,t){O.set(e,t)}function W(e,t,r=[]){let i=[...r];return t.locator?i.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&i.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(t.frame_path)}`),i.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...i.map(n=>` ${n},`),"});"]}f("click",e=>{let t=Ve(e);if(!t)return['await agent.execAction("click", page, {});'];let r=e.action_data?.kwargs?.timeout_ms??Ke;return[`await ${t}.click({ timeout: ${r} });`]});f("click_element",O.get("click"));f("click_element_by_index",O.get("click"));f("double_click",e=>W("double_click",e));f("double_click_on_element",O.get("double_click"));f("right_click",e=>W("right_click",e));f("right_click_on_element",O.get("right_click"));f("hover",e=>W("hover",e));f("hover_element_by_index",O.get("hover"));f("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return W("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});f("fill",O.get("input_text"));f("clear_input",e=>W("clear_input",e));f("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});f("send_keys",O.get("press"));f("send_keys_on_element",e=>{let t=Ve(e),r=e.action_data?.kwargs?.keys||"";if(!t)return['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(r)} } },`,"});"];let i=e.action_data?.kwargs?.timeout_ms??Ke;return[`await ${t}.press(${JSON.stringify(r)}, { timeout: ${i} });`]});f("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return W("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});f("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)})');`]});f("scroll_down",O.get("scroll"));f("scroll_up",O.get("scroll"));f("scroll_element",O.get("scroll"));f("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});f("scroll_on_element",e=>W("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));f("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)} } },`,"});"]});f("open_tab",O.get("go_to_url"));f("go_back",()=>['await agent.execAction("go_back", page, {});']);f("reload_page",()=>['await agent.execAction("reload_page", page, {});']);f("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);f("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);f("verify",(e,t)=>{let r=e.action_data?.kwargs,i=typeof r?.code=="string",n=i?r?.statement||e.action_description:e.action_description||r?.statement;if(i&&n){let o=r.code.split(`
2
2
  `),s=JSON.stringify(n);return["{ const _t = Date.now(); try {",...o.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 i?r.code.split(`
3
3
  `):n?[`await agent.assert(page, ${JSON.stringify(n)}, ${JSON.stringify(t||"")});`]:["// Skipping verify: missing statement or code"]});f("ai_assert",O.get("verify"));f("assert",O.get("verify"));f("ai_action",(e,t)=>{let r=e.action_data?.kwargs?.statement;if(!r)return["// Skipping ai_action: missing statement"];let i=JSON.stringify(r),n=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${i}, '${t||""}', ${n});`]});f("ai_step",(e,t)=>{let r=e.action_data?.kwargs?.statement;return r?[`await agent.run(page, ${JSON.stringify(r)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]});f("ai_extract",(e,t)=>{let r=e.action_data?.kwargs?.element_description,i=e.action_data?.kwargs?.variable_name;if(!r||!i)return["// Skipping ai_extract: missing element_description or variable_name"];let n=JSON.stringify(r),a=JSON.stringify(i);return[`await agent.extract(page, ${n}, ${a}, '${t||""}');`]});f("ai_wait_until",(e,t)=>{let r=e.action_data?.kwargs?.condition,i=e.action_data?.kwargs?.timeout_seconds||60;if(!r)return["// Skipping ai_wait_until: missing condition"];if(e.action_data?.kwargs?.condition_type==="JS_CODE"){let a=e.action_data?.kwargs?.js,o=typeof a=="string"?a:r,s=typeof a=="string"?`, ${JSON.stringify(r)}`:"";return[`await agent.waitForJs(page, async () => (${o}), ${i}, '${t||""}'${s});`]}return[`await agent.waitUntilCondition(page, ${JSON.stringify(r)}, ${i}, '${t||""}');`]});f("save_variable",e=>{let t=e.action_data?.kwargs?.name||"",r=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(r)} } },`,"});"]});f("js_code",e=>{let t=e.action_data?.kwargs?.code;if(!t)return["// Skipping js_code: missing code"];let r=["{"],i=t.split(`
4
- `);for(let n of i)r.push(` ${n}`);return r.push("}"),r});f("function",(e,t,r)=>{let i=e.action_data?.kwargs||{},n=i.functionName;if(n&&n.includes("#")){let[o,s]=n.split("#");if(o&&s){let l=o.replace(/\.(ts|js|mjs)$/,"");if(me.isAbsolute(o))return[`throw new Error(${JSON.stringify(`Absolute paths are not supported in call: references. Use a path relative to the project root (got: "${o}")`)})`];if(!l.startsWith(".")&&r?.projectRoot&&r?.yamlDir){let g=me.resolve(r.projectRoot,l),d=me.relative(r.yamlDir,g).replace(/\\/g,"/");l=d.startsWith("..")?d:"./"+d}let u=`import { ${s} } from '${l}';`;r?.imports?.add(u);let _={...i,functionName:s},b=We(_);return b?[b.endsWith(";")?b:`${b};`]:["// Skipping function: invalid export pattern"]}}let a=We(i);return a?[a.endsWith(";")?a:`${a};`]:["// Skipping function: missing functionName"]});f("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)} } },`,"});"]});f("upload_file",e=>{let t=e.action_data?.kwargs||{},r=[],i={};return t.paths?i.paths=t.paths:t.path&&(i.path=t.path),t.use_file_input&&(i.use_file_input=!0),r.push(`action_data: { kwargs: ${JSON.stringify(i)} }`),e.locator?r.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&r.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...r.map(n=>` ${n},`),"});"]});f("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} } },`,"});"]);f("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} } },`,"});"]);f("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} } },`,"});"]});f("set_date_for_native_date_picker",e=>{let t=e.action_data?.kwargs?.date??"",r=[];return r.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?r.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&r.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...r.map(i=>` ${i},`),"});"]});f("done",()=>["// Done - no action needed"]);function _e(e,t){let r=t.action_data?.kwargs||{},i=[];return typeof r.relative_x=="number"&&typeof r.relative_y=="number"?(i.push(`action_data: { kwargs: { relative_x: ${r.relative_x}, relative_y: ${r.relative_y} } }`),t.locator?i.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&i.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(t.frame_path)}`)):typeof r.x=="number"&&typeof r.y=="number"&&i.push(`action_data: { kwargs: { x: ${r.x}, y: ${r.y} } }`),[`await agent.execAction("${e}", page, {`,...i.map(n=>` ${n},`),"});"]}f("click_by_coordinates",e=>_e("click_by_coordinates",e));f("right_click_by_coordinates",e=>_e("right_click_by_coordinates",e));f("double_click_by_coordinates",e=>_e("double_click_by_coordinates",e));f("drag_drop",e=>{let t=e.action_data?.kwargs||{},r={};typeof t.relative_x=="number"&&(r.relative_x=t.relative_x),typeof t.relative_y=="number"&&(r.relative_y=t.relative_y),typeof t.delta_x=="number"&&(r.delta_x=t.delta_x),typeof t.delta_y=="number"&&(r.delta_y=t.delta_y),typeof t.coord_source_x=="number"&&(r.coord_source_x=t.coord_source_x),typeof t.coord_source_y=="number"&&(r.coord_source_y=t.coord_source_y),typeof t.coord_target_x=="number"&&(r.coord_target_x=t.coord_target_x),typeof t.coord_target_y=="number"&&(r.coord_target_y=t.coord_target_y);let i=[`action_data: { kwargs: ${JSON.stringify(r)} }`];return e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("drag_drop", page, {',...i.map(n=>` ${n},`),"});"]});f("get_dropdown_options",e=>{let t=[];return e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("get_dropdown_options", page, {});']:['await agent.execAction("get_dropdown_options", page, {',...t.map(r=>` ${r},`),"});"]});f("extract_email_content",e=>{let t=e.action_data?.kwargs||{};return['await agent.execAction("extract_email_content", page, {',` action_data: { kwargs: ${JSON.stringify(t)} },`,"});"]});f("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
5
- `):["// Skipping js_action: missing code"]});function We(e){let t=e.functionName;if(!t)return null;let r=Array.isArray(e.args)?e.args.map(String):Array.isArray(e.parameterValues)?e.parameterValues.map(String):[];if(r.length===0)return`await ${t}()`;let i=["page","testContext","request","agent"],n=["undefined","null","true","false"],a=r.map(o=>i.includes(o)||n.includes(o)||/^-?\d+(\.\d+)?$/.test(o)?o:o.startsWith("$")?`agent.agentServices.readVariable('${o.substring(1)}')`:`"${o}"`);return`await ${t}(${a.join(", ")})`}var Ue=5;function Ve(e,t,r){let i={expandingPaths:new Set([ye(t)]),depth:0,referencedPaths:new Set,basePath:r},n={...e};Array.isArray(n.statements)&&(n.statements=N(n.statements,t,i)),Array.isArray(n.teardown)&&(n.teardown=N(n.teardown,t,i));for(let a of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(n[a])&&(n[a]=N(n[a],t,i));return{doc:n,referencedTemplatePaths:Array.from(i.referencedPaths)}}function N(e,t,r){let i=[];for(let n of e)if(Gt(n)){let a=Ut(n,t,r);i.push(a)}else i.push(Ht(n,t,r));return i}function Gt(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function Ut(e,t,r){if(r.depth>=Ue)throw new Error(`Template expansion exceeded maximum depth of ${Ue}. Check for deeply nested or circular template references.`);let i=ye(Bt(t),e.template),n=!Ft(i)&&r.basePath?ye(r.basePath,e.template):i;if(r.expandingPaths.has(n))throw new Error(`Circular template reference detected: ${n} is already being expanded. Stack: ${Array.from(r.expandingPaths).join(" \u2192 ")} \u2192 ${n}`);r.referencedPaths.add(n);let a;try{a=Rt(n,"utf-8")}catch(k){throw new Error(`Failed to read template file: ${n} (referenced from ${t}): ${k.message}`)}let o=Ge(a);if(!o||typeof o!="object")throw new Error(`Invalid template file: ${n} \u2014 expected a YAML object`);let s=o.params||[],l=e.params||{};for(let k of s)if(!(k in l))throw new Error(`Template ${e.template} requires param "${k}" but it was not provided. Required params: [${s.join(", ")}]`);let u=o.statements;if(!Array.isArray(u))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(l).length>0){let y=Wt(u);for(let[E,p]of Object.entries(l))y=y.split(`<<${E}>>`).join(String(p));u=Ge(y)}let _={expandingPaths:new Set([...r.expandingPaths,n]),depth:r.depth+1,referencedPaths:r.referencedPaths},b=N(u,n,_),d={STEP:o.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:b};return Object.keys(l).length>0&&(d.template_params=l),d}function Ht(e,t,r){if(typeof e!="object"||e===null)return e;let i={...e};return Array.isArray(i.statements)&&(i.statements=N(i.statements,t,r)),Array.isArray(i.THEN)&&(i.THEN=N(i.THEN,t,r)),Array.isArray(i.ELSE)&&(i.ELSE=N(i.ELSE,t,r)),Array.isArray(i.DO)&&(i.DO=N(i.DO,t,r)),i}var ze=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}};function Je(e,t,r){let i=Dt(e),n=i?.name,a=i?.tags,o=i?.use;if(i&&(i.name!==void 0||i.tags!==void 0||i.use!==void 0)&&(delete i.name,delete i.tags,delete i.use),i?.suite){if(i.goal||i.statements)throw new ze('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return Kt(i,n,a,o,t,r)}return jt(i,n,a,o,t,r)}function jt(e,t,r,i,n,a){let o=e?.beforeEach,s=e?.afterEach,l=Ye(e?.parameters),u=e?.timeout,_=e?.skip,b=e?.fail,g=e?.only,d=e?.slow;if(e&&(delete e.beforeEach,delete e.afterEach,delete e.parameters,delete e.timeout,delete e.skip,delete e.fail,delete e.only,delete e.slow),e?.url)throw new ze(`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 k=[];if(n&&e&&typeof e=="object"){let p=Ve(e,n,a);e=p.doc,k=p.referencedTemplatePaths}let y=Ke(e),E=F(y);return n&&(D(E.statements??[],n,"main"),E.teardown&&D(E.teardown,n,"teardown")),{testFlow:E,name:t,tags:r,use:i,beforeEach:o,afterEach:s,parameters:l,timeout:u,skip:_,fail:b,only:g,slow:d,referencedTemplatePaths:k}}function Kt(e,t,r,i,n,a){let o=e.suite;if(!Array.isArray(o.tests)||o.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let s=o.beforeAll,l=o.afterAll,u=o.beforeEach,_=o.afterEach,b=[],g=o.tests.map((y,E)=>{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 p={goal:y.name,statements:y.statements};y.teardown&&(p.teardown=y.teardown);let h=[],m=p;if(n&&typeof p=="object"){let $=Ve(p,n,a);m=$.doc,h=$.referencedTemplatePaths,b.push(...h)}let w=Ke(m),T=F(w);if(n){let $=`tests[${E}]`;D(T.statements??[],n,$),T.teardown&&D(T.teardown,n,`${$}.teardown`)}let S=Ye(y.parameters);return{testFlow:T,name:y.name,tags:Array.isArray(y.tags)?y.tags:void 0,parameters:S,timeout:y.timeout,skip:y.skip,fail:y.fail,only:y.only,slow:y.slow}}),d=o.base_url,k=d?{...i,baseURL:d}:i;return{suite:{beforeAll:s,afterAll:l,beforeEach:u,afterEach:_,tests:g},name:t,tags:r,use:k,referencedTemplatePaths:b}}function Ye(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,r)=>{if(!t.name)throw new Error(`Parameter set at index ${r} 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 D(e,t,r){for(let i=0;i<e.length;i++){let n=e[i],a=`${r}.${i}`,o=n.description||"";if(n.uid=Vt(t,a,o),n.type===B.STEP)D(n.statements,t,a);else if(n.type===B.IF_ELSE){let s=n;D(s.then,t,`${a}.then`),s.else&&D(s.else,t,`${a}.else`)}else n.type===B.WHILE_LOOP&&D(n.body,t,`${a}.body`)}}function Vt(e,t,r){let i=Nt("sha256").update(`${e}:${t}:${r}`).digest("hex");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20,32)}`}import Xe from"node:path";function zt(e){switch(e){case"env":return"from WEB_AGENT_TIER";case"org-default":return"org default";case"baked-default":return"built-in default"}return e}function A(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function ne(e){if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/6e4),r=(e%6e4/1e3).toFixed(0);return`${t}m ${r}s`}function Jt(e){return`passed after ${e||"?"} ${e===1?"retry":"retries"}`}function Yt(e,t){let r=e||"?",i=e===1?"retry":"retries";return t==="passed"?`passed after ${r} ${i}`:`failed after ${r} ${i}`}function ie(e){switch(e){case"passed":case"success":return'<span class="status-icon passed">&#x2714;</span>';case"flaky":return'<span class="status-icon flaky">&#x21BB;</span>';case"failed":case"failure":case"timedOut":return'<span class="status-icon failed">&#x2718;</span>';case"skipped":return'<span class="status-icon skipped">&#x2500;</span>';case"interrupted":return'<span class="status-icon failed">&#x26A0;</span>';default:return'<span class="status-icon pending">&#x25CB;</span>'}}function Xt(e){return`<span class="badge badge-${e}">${e}</span>`}function qt(e){if(!e.code)return"";let t=e.code.split(`
6
- `);return e.codeStartLine!=null&&e.codeLine!=null?`<div class="step-code"><pre class="code-block">${t.map((n,a)=>{let o=e.codeStartLine+a,s=o===e.codeLine,l=String(o).padStart(4);return`<span class="code-line${s?" code-line-active":""}">${l} \u2502 ${A(n)}</span>`}).join("")}</pre></div>`:`<div class="step-code"><pre class="code-block">${t.map(i=>`<span class="code-line code-line-body">${A(i)}</span>`).join("")}</pre></div>`}function Zt(e){let t=e.duration!=null?`<span class="step-duration">${ne(e.duration)}</span>`:"",r=ie(e.status);if(e.screenshot||e.message||e.error||e.code){let n="";e.screenshot&&(n=`<img src="${A(e.screenshot)}" alt="Step screenshot" class="step-screenshot" />`);let a=e.screenshot?"":qt(e),o="";e.error&&(o=`<div class="step-error"><pre>${A(e.error)}</pre></div>`);let s="";e.message&&!e.error&&(s=`<div class="step-message">${A(e.message)}</div>`);let l=e.status==="failure"?" open":"";return`
4
+ `);for(let n of i)r.push(` ${n}`);return r.push("}"),r});f("function",(e,t,r)=>{let i=e.action_data?.kwargs||{},n=i.functionName;if(n&&n.includes("#")){let[o,s]=n.split("#");if(o&&s){let l=o.replace(/\.(ts|js|mjs)$/,"");if(ye.isAbsolute(o))return[`throw new Error(${JSON.stringify(`Absolute paths are not supported in call: references. Use a path relative to the project root (got: "${o}")`)})`];if(!l.startsWith(".")&&r?.projectRoot&&r?.yamlDir){let g=ye.resolve(r.projectRoot,l),d=ye.relative(r.yamlDir,g).replace(/\\/g,"/");l=d.startsWith("..")?d:"./"+d}let u=`import { ${s} } from '${l}';`;r?.imports?.add(u);let _={...i,functionName:s},b=Ue(_);return b?[b.endsWith(";")?b:`${b};`]:["// Skipping function: invalid export pattern"]}}let a=Ue(i);return a?[a.endsWith(";")?a:`${a};`]:["// Skipping function: missing functionName"]});f("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)} } },`,"});"]});f("upload_file",e=>{let t=e.action_data?.kwargs||{},r=[],i={};return t.paths?i.paths=t.paths:t.path&&(i.path=t.path),t.use_file_input&&(i.use_file_input=!0),r.push(`action_data: { kwargs: ${JSON.stringify(i)} }`),e.locator?r.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&r.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...r.map(n=>` ${n},`),"});"]});f("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} } },`,"});"]);f("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} } },`,"});"]);f("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} } },`,"});"]});f("set_date_for_native_date_picker",e=>{let t=e.action_data?.kwargs?.date??"",r=[];return r.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?r.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&r.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...r.map(i=>` ${i},`),"});"]});f("done",()=>["// Done - no action needed"]);function be(e,t){let r=t.action_data?.kwargs||{},i=[];return typeof r.relative_x=="number"&&typeof r.relative_y=="number"?(i.push(`action_data: { kwargs: { relative_x: ${r.relative_x}, relative_y: ${r.relative_y} } }`),t.locator?i.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&i.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(t.frame_path)}`)):typeof r.x=="number"&&typeof r.y=="number"&&i.push(`action_data: { kwargs: { x: ${r.x}, y: ${r.y} } }`),[`await agent.execAction("${e}", page, {`,...i.map(n=>` ${n},`),"});"]}f("click_by_coordinates",e=>be("click_by_coordinates",e));f("right_click_by_coordinates",e=>be("right_click_by_coordinates",e));f("double_click_by_coordinates",e=>be("double_click_by_coordinates",e));f("drag_drop",e=>{let t=e.action_data?.kwargs||{},r={};typeof t.relative_x=="number"&&(r.relative_x=t.relative_x),typeof t.relative_y=="number"&&(r.relative_y=t.relative_y),typeof t.delta_x=="number"&&(r.delta_x=t.delta_x),typeof t.delta_y=="number"&&(r.delta_y=t.delta_y),typeof t.coord_source_x=="number"&&(r.coord_source_x=t.coord_source_x),typeof t.coord_source_y=="number"&&(r.coord_source_y=t.coord_source_y),typeof t.coord_target_x=="number"&&(r.coord_target_x=t.coord_target_x),typeof t.coord_target_y=="number"&&(r.coord_target_y=t.coord_target_y);let i=[`action_data: { kwargs: ${JSON.stringify(r)} }`];return e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("drag_drop", page, {',...i.map(n=>` ${n},`),"});"]});f("get_dropdown_options",e=>{let t=[];return e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("get_dropdown_options", page, {});']:['await agent.execAction("get_dropdown_options", page, {',...t.map(r=>` ${r},`),"});"]});f("extract_email_content",e=>{let t=e.action_data?.kwargs||{};return['await agent.execAction("extract_email_content", page, {',` action_data: { kwargs: ${JSON.stringify(t)} },`,"});"]});f("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
5
+ `):["// Skipping js_action: missing code"]});function Ue(e){let t=e.functionName;if(!t)return null;let r=Array.isArray(e.args)?e.args.map(String):Array.isArray(e.parameterValues)?e.parameterValues.map(String):[];if(r.length===0)return`await ${t}()`;let i=["page","testContext","request","agent"],n=["undefined","null","true","false"],a=r.map(o=>i.includes(o)||n.includes(o)||/^-?\d+(\.\d+)?$/.test(o)?o:o.startsWith("$")?`agent.agentServices.readVariable('${o.substring(1)}')`:`"${o}"`);return`await ${t}(${a.join(", ")})`}var He=5;function Je(e,t,r){let i={expandingPaths:new Set([_e(t)]),depth:0,referencedPaths:new Set,basePath:r},n={...e};Array.isArray(n.statements)&&(n.statements=N(n.statements,t,i)),Array.isArray(n.teardown)&&(n.teardown=N(n.teardown,t,i));for(let a of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(n[a])&&(n[a]=N(n[a],t,i));return{doc:n,referencedTemplatePaths:Array.from(i.referencedPaths)}}function N(e,t,r){let i=[];for(let n of e)if(Kt(n)){let a=Vt(n,t,r);i.push(a)}else i.push(zt(n,t,r));return i}function Kt(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function Vt(e,t,r){if(r.depth>=He)throw new Error(`Template expansion exceeded maximum depth of ${He}. Check for deeply nested or circular template references.`);let i=_e(Ht(t),e.template),n=!Gt(i)&&r.basePath?_e(r.basePath,e.template):i;if(r.expandingPaths.has(n))throw new Error(`Circular template reference detected: ${n} is already being expanded. Stack: ${Array.from(r.expandingPaths).join(" \u2192 ")} \u2192 ${n}`);r.referencedPaths.add(n);let a;try{a=Ut(n,"utf-8")}catch(k){throw new Error(`Failed to read template file: ${n} (referenced from ${t}): ${k.message}`)}let o=Ge(a);if(!o||typeof o!="object")throw new Error(`Invalid template file: ${n} \u2014 expected a YAML object`);let s=o.params||[],l=e.params||{};for(let k of s)if(!(k in l))throw new Error(`Template ${e.template} requires param "${k}" but it was not provided. Required params: [${s.join(", ")}]`);let u=o.statements;if(!Array.isArray(u))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(l).length>0){let y=jt(u);for(let[E,p]of Object.entries(l))y=y.split(`<<${E}>>`).join(String(p));u=Ge(y)}let _={expandingPaths:new Set([...r.expandingPaths,n]),depth:r.depth+1,referencedPaths:r.referencedPaths},b=N(u,n,_),d={STEP:o.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:b};return Object.keys(l).length>0&&(d.template_params=l),d}function zt(e,t,r){if(typeof e!="object"||e===null)return e;let i={...e};return Array.isArray(i.statements)&&(i.statements=N(i.statements,t,r)),Array.isArray(i.THEN)&&(i.THEN=N(i.THEN,t,r)),Array.isArray(i.ELSE)&&(i.ELSE=N(i.ELSE,t,r)),Array.isArray(i.DO)&&(i.DO=N(i.DO,t,r)),i}var ie=new Map;function Zt(e){let t=[],r=e;for(;;){let i=ie.get(r);if(i!==void 0){for(let a of t)ie.set(a,i);return i}if(t.push(r),Jt(Xt(r,".git"))){for(let a of t)ie.set(a,r);return r}let n=Ye(r);if(n===r){for(let a of t)ie.set(a,null);return null}r=n}}function je(e){return e.split(/[\\/]/).join("/")}function Qt(e){if(!Yt(e))return je(e);let t=Zt(Ye(e));return je(t?qt(t,e):e)}var Xe=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}};function qe(e,t,r){let i=Wt(e),n=i?.name,a=i?.tags,o=i?.use;if(i&&(i.name!==void 0||i.tags!==void 0||i.use!==void 0)&&(delete i.name,delete i.tags,delete i.use),i?.suite){if(i.goal||i.statements)throw new Xe('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return tr(i,n,a,o,t,r)}return er(i,n,a,o,t,r)}function er(e,t,r,i,n,a){let o=e?.beforeEach,s=e?.afterEach,l=Ze(e?.parameters),u=e?.timeout,_=e?.skip,b=e?.fail,g=e?.only,d=e?.slow;if(e&&(delete e.beforeEach,delete e.afterEach,delete e.parameters,delete e.timeout,delete e.skip,delete e.fail,delete e.only,delete e.slow),e?.url)throw new Xe(`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 k=[];if(n&&e&&typeof e=="object"){let p=Je(e,n,a);e=p.doc,k=p.referencedTemplatePaths}let y=ze(e),E=R(y);return n&&(D(E.statements??[],n,"main"),E.teardown&&D(E.teardown,n,"teardown")),{testFlow:E,name:t,tags:r,use:i,beforeEach:o,afterEach:s,parameters:l,timeout:u,skip:_,fail:b,only:g,slow:d,referencedTemplatePaths:k}}function tr(e,t,r,i,n,a){let o=e.suite;if(!Array.isArray(o.tests)||o.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let s=o.beforeAll,l=o.afterAll,u=o.beforeEach,_=o.afterEach,b=[],g=o.tests.map((y,E)=>{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 p={goal:y.name,statements:y.statements};y.teardown&&(p.teardown=y.teardown);let h=[],m=p;if(n&&typeof p=="object"){let $=Je(p,n,a);m=$.doc,h=$.referencedTemplatePaths,b.push(...h)}let w=ze(m),T=R(w);if(n){let $=`tests[${E}]`;D(T.statements??[],n,$),T.teardown&&D(T.teardown,n,`${$}.teardown`)}let S=Ze(y.parameters);return{testFlow:T,name:y.name,tags:Array.isArray(y.tags)?y.tags:void 0,parameters:S,timeout:y.timeout,skip:y.skip,fail:y.fail,only:y.only,slow:y.slow}}),d=o.base_url??e.base_url,k=d?{...i,baseURL:d}:i;return{suite:{beforeAll:s,afterAll:l,beforeEach:u,afterEach:_,tests:g},name:t,tags:r,use:k,referencedTemplatePaths:b}}function Ze(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,r)=>{if(!t.name)throw new Error(`Parameter set at index ${r} 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 D(e,t,r){for(let i=0;i<e.length;i++){let n=e[i],a=`${r}.${i}`,o=n.description||"";if(n.uid=rr(t,a,o),n.type===B.STEP)D(n.statements,t,a);else if(n.type===B.IF_ELSE){let s=n;D(s.then,t,`${a}.then`),s.else&&D(s.else,t,`${a}.else`)}else n.type===B.WHILE_LOOP&&D(n.body,t,`${a}.body`)}}function rr(e,t,r){let i=Qt(e),n=Bt("sha256").update(`${i}:${t}:${r}`).digest("hex");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20,32)}`}import Qe from"node:path";function ir(e){switch(e){case"env":return"from WEB_AGENT_TIER";case"org-default":return"org default";case"baked-default":return"built-in default"}return e}function A(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function oe(e){if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/6e4),r=(e%6e4/1e3).toFixed(0);return`${t}m ${r}s`}function nr(e){return`passed after ${e||"?"} ${e===1?"retry":"retries"}`}function or(e,t){let r=e||"?",i=e===1?"retry":"retries";return t==="passed"?`passed after ${r} ${i}`:`failed after ${r} ${i}`}function ne(e){switch(e){case"passed":case"success":return'<span class="status-icon passed">&#x2714;</span>';case"flaky":return'<span class="status-icon flaky">&#x21BB;</span>';case"failed":case"failure":case"timedOut":return'<span class="status-icon failed">&#x2718;</span>';case"skipped":return'<span class="status-icon skipped">&#x2500;</span>';case"interrupted":return'<span class="status-icon failed">&#x26A0;</span>';default:return'<span class="status-icon pending">&#x25CB;</span>'}}function ar(e){return`<span class="badge badge-${e}">${e}</span>`}function sr(e){if(!e.code)return"";let t=e.code.split(`
6
+ `);return e.codeStartLine!=null&&e.codeLine!=null?`<div class="step-code"><pre class="code-block">${t.map((n,a)=>{let o=e.codeStartLine+a,s=o===e.codeLine,l=String(o).padStart(4);return`<span class="code-line${s?" code-line-active":""}">${l} \u2502 ${A(n)}</span>`}).join("")}</pre></div>`:`<div class="step-code"><pre class="code-block">${t.map(i=>`<span class="code-line code-line-body">${A(i)}</span>`).join("")}</pre></div>`}function cr(e){let t=e.duration!=null?`<span class="step-duration">${oe(e.duration)}</span>`:"",r=ne(e.status);if(e.screenshot||e.message||e.error||e.code){let n="";e.screenshot&&(n=`<img src="${A(e.screenshot)}" alt="Step screenshot" class="step-screenshot" />`);let a=e.screenshot?"":sr(e),o="";e.error&&(o=`<div class="step-error"><pre>${A(e.error)}</pre></div>`);let s="";e.message&&!e.error&&(s=`<div class="step-message">${A(e.message)}</div>`);let l=e.status==="failure"?" open":"";return`
7
7
  <details class="step-details step step-${e.status}"${l}>
8
8
  <summary class="step-header">
9
9
  ${r}
@@ -26,7 +26,7 @@ import*as x from"fs";import*as v from"path";var R=(e,t,r)=>{e.forEach((i,n)=>{le
26
26
  <span class="step-description">${A(e.description)}</span>
27
27
  ${t}
28
28
  </div>
29
- </div>`}function Qt(e,t,r,i){let n=[];e&&n.push(`
29
+ </div>`}function lr(e,t,r,i){let n=[];e&&n.push(`
30
30
  <details class="artifact-section">
31
31
  <summary class="artifact-summary">Video</summary>
32
32
  <div class="artifact-content">
@@ -58,38 +58,38 @@ import*as x from"fs";import*as v from"path";var R=(e,t,r)=>{e.forEach((i,n)=>{le
58
58
  <p class="trace-hint">Run this command in your terminal to open the interactive Trace Viewer</p>
59
59
  <p class="trace-hint"><a href="${A(t)}" class="attachment-link" download>Download trace.zip</a></p>
60
60
  </div>
61
- </details>`)}return n.length===0?"":`<div class="test-artifacts">${n.join("")}</div>`}function qe(e,t,r,i,n){let a=e.map(Zt).join(`
62
- `),o="";t&&!e.some(l=>l.error)&&(o=`<div class="test-error"><pre>${A(t)}</pre></div>`);let s=Qt(r,i,e,n);return`
61
+ </details>`)}return n.length===0?"":`<div class="test-artifacts">${n.join("")}</div>`}function et(e,t,r,i,n){let a=e.map(cr).join(`
62
+ `),o="";t&&!e.some(l=>l.error)&&(o=`<div class="test-error"><pre>${A(t)}</pre></div>`);let s=lr(r,i,e,n);return`
63
63
  ${o}
64
64
  <div class="steps-list">
65
65
  ${a||'<div class="no-steps">No YAML step details available</div>'}
66
66
  </div>
67
- ${s}`}function er(e,t){let r=e.flaky?"flaky":e.status,i=ie(r),n;if(e.attempts&&e.attempts.length>1){let a=`tabs-${t}`,s=e.attempts.length-1,l=e.attempts.map((g,d)=>{let k=d===s,y=g.status==="passed"?"passed":"failed",E=`Attempt ${g.attemptNumber}`;return`<button class="attempt-tab ${k?"active":""} attempt-tab-${y}"
67
+ ${s}`}function ur(e,t){let r=e.flaky?"flaky":e.status,i=ne(r),n;if(e.attempts&&e.attempts.length>1){let a=`tabs-${t}`,s=e.attempts.length-1,l=e.attempts.map((g,d)=>{let k=d===s,y=g.status==="passed"?"passed":"failed",E=`Attempt ${g.attemptNumber}`;return`<button class="attempt-tab ${k?"active":""} attempt-tab-${y}"
68
68
  onclick="switchAttemptTab('${a}', ${d})"
69
- data-tab-index="${d}">${ie(y)} ${E} <span class="attempt-tab-badge badge-${y}">${g.status}</span></button>`}).join(""),u=e.attempts.map((g,d)=>{let k=d===s,y=qe(g.steps,g.error,g.videoPath,g.tracePath,`${t}-attempt-${d}`);return`<div class="attempt-panel ${k?"active":""}" data-panel-index="${d}">
69
+ data-tab-index="${d}">${ne(y)} ${E} <span class="attempt-tab-badge badge-${y}">${g.status}</span></button>`}).join(""),u=e.attempts.map((g,d)=>{let k=d===s,y=et(g.steps,g.error,g.videoPath,g.tracePath,`${t}-attempt-${d}`);return`<div class="attempt-panel ${k?"active":""}" data-panel-index="${d}">
70
70
  <div class="attempt-meta">
71
- ${ie(g.status==="passed"?"passed":"failed")}
72
- <span class="attempt-meta-text">Attempt ${g.attemptNumber} &mdash; ${g.status} in ${ne(g.duration)}</span>
71
+ ${ne(g.status==="passed"?"passed":"failed")}
72
+ <span class="attempt-meta-text">Attempt ${g.attemptNumber} &mdash; ${g.status} in ${oe(g.duration)}</span>
73
73
  </div>
74
74
  ${y}
75
- </div>`}).join(""),_=e.flaky?`Flaky &mdash; ${Jt(e.retries)}`:`Retried &mdash; ${Yt(e.retries,e.status)}`;n=`
75
+ </div>`}).join(""),_=e.flaky?`Flaky &mdash; ${nr(e.retries)}`:`Retried &mdash; ${or(e.retries,e.status)}`;n=`
76
76
  <div class="${e.flaky?"flaky-note":"retried-note"}">${_}</div>
77
77
  <div class="attempt-tabs" id="${a}">
78
78
  <div class="attempt-tab-bar">${l}</div>
79
79
  ${u}
80
- </div>`}else n=qe(e.steps,e.error,e.videoPath,e.tracePath,String(t));return`
80
+ </div>`}else n=et(e.steps,e.error,e.videoPath,e.tracePath,String(t));return`
81
81
  <details class="test-details" ${e.status==="failed"||e.status==="timedOut"?"open":""}>
82
82
  <summary class="test-summary test-${r}">
83
83
  ${i}
84
84
  <span class="test-title">${A(e.title)}</span>
85
85
  <span class="test-file">${A(e.file)}</span>
86
- ${Xt(r)}
87
- <span class="test-duration">${ne(e.duration)}</span>
86
+ ${ar(r)}
87
+ <span class="test-duration">${oe(e.duration)}</span>
88
88
  </summary>
89
89
  <div class="test-body">
90
90
  ${n}
91
91
  </div>
92
- </details>`}function Ze(e,t){return!e||!t||Xe.isAbsolute(e)?e:Xe.join(t,e)}function tr(e,t){return t?{...e,tracePath:Ze(e.tracePath,t),attempts:e.attempts?.map(r=>({...r,tracePath:Ze(r.tracePath,t)}))}:e}function Qe(e){let t=e.tests.filter(u=>u.flaky).length,r=e.tests.filter(u=>!u.flaky&&u.retries!=null&&u.retries>0).length,i=e.tests.filter(u=>u.status==="passed"&&!u.flaky).length,n=e.tests.filter(u=>u.status==="failed"||u.status==="timedOut").length,a=e.tests.filter(u=>u.status==="skipped").length,o=e.tests.length,l=e.tests.map(u=>tr(u,e.outputDir)).map((u,_)=>er(u,_)).join(`
92
+ </details>`}function tt(e,t){return!e||!t||Qe.isAbsolute(e)?e:Qe.join(t,e)}function pr(e,t){return t?{...e,tracePath:tt(e.tracePath,t),attempts:e.attempts?.map(r=>({...r,tracePath:tt(r.tracePath,t)}))}:e}function rt(e){let t=e.tests.filter(u=>u.flaky).length,r=e.tests.filter(u=>!u.flaky&&u.retries!=null&&u.retries>0).length,i=e.tests.filter(u=>u.status==="passed"&&!u.flaky).length,n=e.tests.filter(u=>u.status==="failed"||u.status==="timedOut").length,a=e.tests.filter(u=>u.status==="skipped").length,o=e.tests.length,l=e.tests.map(u=>pr(u,e.outputDir)).map((u,_)=>ur(u,_)).join(`
93
93
  `);return`<!DOCTYPE html>
94
94
  <html lang="en">
95
95
  <head>
@@ -739,7 +739,7 @@ import*as x from"fs";import*as v from"path";var R=(e,t,r)=>{e.forEach((i,n)=>{le
739
739
  ${r>0?`<span class="summary-stat retried">${r} retried</span>`:""}
740
740
  ${n>0?`<span class="summary-stat failed">${n} failed</span>`:""}
741
741
  ${a>0?`<span class="summary-stat skipped">${a} skipped</span>`:""}
742
- <span class="summary-stat">${ne(e.totalDuration)}</span>
742
+ <span class="summary-stat">${oe(e.totalDuration)}</span>
743
743
  ${e.timestamp?`<span class="summary-stat" style="margin-left:auto;color:var(--color-text-secondary)">${new Date(e.timestamp).toLocaleString()}</span>`:""}
744
744
  </div>
745
745
  </div>${e.cacheSummary?`
@@ -756,7 +756,7 @@ import*as x from"fs";import*as v from"path";var R=(e,t,r)=>{e.forEach((i,n)=>{le
756
756
  ${l}
757
757
  </div>
758
758
  <div class="footer">
759
- Generated by Shiplight Reporter${e.shiplightVersion?` \xB7 shiplightai v${A(e.shiplightVersion)}`:""}${e.modelTierProvenance?` \xB7 tier: ${A(e.modelTierProvenance.tier)} (${A(zt(e.modelTierProvenance.tierSource))}) \u2192 ${A(e.modelTierProvenance.webagentPrimary)} [${e.modelTierProvenance.mapSource==="server"?"org settings":"built-in defaults"}]`:""}
759
+ Generated by Shiplight Reporter${e.shiplightVersion?` \xB7 shiplightai v${A(e.shiplightVersion)}`:""}${e.modelTierProvenance?` \xB7 tier: ${A(e.modelTierProvenance.tier)} (${A(ir(e.modelTierProvenance.tierSource))}) \u2192 ${A(e.modelTierProvenance.webagentPrimary)} [${e.modelTierProvenance.mapSource==="server"?"org settings":"built-in defaults"}]`:""}
760
760
  </div>
761
761
  </div>
762
762
 
@@ -883,9 +883,9 @@ import*as x from"fs";import*as v from"path";var R=(e,t,r)=>{e.forEach((i,n)=>{le
883
883
  });
884
884
  </script>
885
885
  </body>
886
- </html>`}import*as it from"fs";import*as be from"path";import{globSync as sr}from"glob";function rr(e){let t=e.toLowerCase();return t.includes("claude")||t.includes("anthropic")?"anthropic":t.includes("gemini")||t.includes("google")?"gemini":t.startsWith("gpt")||t.startsWith("o1")||t.startsWith("o3")||t.startsWith("o4")||t.includes("openai")?"openai":"unknown"}function ir(e){switch(e.actionType){case"execute":case"run":return"action";case"generate":return"draft";case"assert":return"verify_ai";case"evaluate":return e.conditionKind==="while"?"evaluate_while":e.conditionKind==="wait_until"?"evaluate_wait_until":"evaluate_if";default:return null}}function et(e,t){let r=e[t];return typeof r=="number"?r:0}function nr(e,t,r,i){return`${e}\0${t}\0${r}\0${i}`}function tt(e,t={}){let r=t.routing??"proxy",i=t.providerOf??rr,n=new Map;for(let o of e??[]){let s=ir(o);if(s)for(let l of o.tokenUsages??[]){let u=l.model??"unknown",_=i(u),b=nr(s,_,u,r),g=n.get(b);g||(g={operation:s,provider:_,model:u,routing:r,calls:0,input_tokens:0,output_tokens:0,thinking_tokens:0,cache_read_tokens:0},n.set(b,g)),g.calls+=1,g.input_tokens+=l.prompt_tokens||0,g.output_tokens+=l.completion_tokens||0,g.thinking_tokens+=et(l,"thinking_tokens"),g.cache_read_tokens+=et(l,"cache_read_tokens")}}return{by_operation:Array.from(n.values()).sort((o,s)=>o.operation!==s.operation?o.operation.localeCompare(s.operation):o.provider!==s.provider?o.provider.localeCompare(s.provider):o.model.localeCompare(s.model))}}import Co from"dotenv";var or="__shiplightDotenvCache__";function ar(){return globalThis[or]}function oe(){let e=ar();return e===void 0?process.env:e}function cr(e){if(!e)return!1;let t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}var rt={anthropic:e=>e.ANTHROPIC_API_KEY||cr(e.ANTHROPIC_MODELS_USE_VERTEXAI)?"byok":"proxy",gemini:e=>{let t=e.GOOGLE_GENAI_USE_VERTEXAI;return e.GOOGLE_API_KEY||t==="True"||t==="true"?"byok":"proxy"},openai:e=>e.OPENAI_API_KEY?e.OPENAI_BASE_URL?"custom_endpoint":"byok":"proxy"},lr=/^(gpt-|o\d|chatgpt-)/;function ur(e,t){return e!=="unknown"?e:lr.test(t)?"openai":"unknown"}function pr(e,t){let r=t.SHIPLIGHT_USAGE_ROUTING;if(r==="proxy"||r==="byok"||r==="custom_endpoint")return r;let i=rt[e];return i?i(t):Object.values(rt).some(a=>a(t)!=="proxy")?"byok":"proxy"}function nt(e,t){let r=t?.length?t:[be.join(e,"test-results")],i=[];for(let s of r){let l;try{l=sr("**/ai-actions.json",{cwd:s})}catch{continue}for(let u of l)try{let _=JSON.parse(it.readFileSync(be.join(s,u),"utf-8"));Array.isArray(_)&&i.push(..._)}catch{}}if(i.length===0)return;let n=oe(),a=tt(i,{routing:"proxy"}),o=a.by_operation.map(s=>{let l=ur(s.provider,s.model);return{...s,provider:l,routing:pr(l,n)}});return o.sort(dr),o.length>0?{...a,by_operation:o}:void 0}function ot(e){let t=new Map;for(let r of e){if(!r.stepId||r.tokenUsages.length===0)continue;let i=t.get(r.stepId)??[];for(let n of r.tokenUsages)i.push({model:n.model,promptTokens:n.prompt_tokens,completionTokens:n.completion_tokens,totalTokens:n.total_tokens});t.set(r.stepId,i)}return t}function dr(e,t){return e.operation!==t.operation?e.operation.localeCompare(t.operation):e.provider!==t.provider?e.provider.localeCompare(t.provider):e.model!==t.model?e.model.localeCompare(t.model):e.routing.localeCompare(t.routing)}var ae=class{records=new Map;recordStatementSource(t,r,i,n,a,o){this.records.set(t,{statement_hash:t,statement_path:r,description:i,source:n,original_action_entity:a,cached_action_entity:n==="cache_hit"?o:void 0})}recordHealedEntities(t,r){for(let[i,n]of t){let a=r.get(i);if(!a)continue;let o=this.records.get(a);o&&((o.source==="original"||o.source==="cache_hit")&&(o.pre_heal_source=o.source),o.source="healed",o.healed_action_entity=n,o.heal_reason=fr(o.original_action_entity,n))}}recordFailed(t){let r=this.records.get(t);r&&(r.source="failed")}getStatementDetails(){return Array.from(this.records.values())}getSummary(){let t=0,r=0,i=0,n=0,a=0;for(let o of this.records.values())switch(o.source){case"original":t++;break;case"cache_hit":r++;break;case"healed":i++,o.pre_heal_source==="cache_hit"&&n++;break;case"failed":a++;break}return{total_statements:this.records.size,original:t,cache_hits:r,healed:i,healed_from_cache:n,failed:a}}getConsoleSummary(){let t=this.getSummary();if(t.total_statements===0)return"";let r=[];return t.cache_hits>0&&r.push(`${t.cache_hits} cached`),t.healed>0&&r.push(`${t.healed} healed`),t.original>0&&r.push(`${t.original} original`),t.failed>0&&r.push(`${t.failed} failed`),`[Shiplight Cache] ${r.join(", ")}`}};function fr(e,t){if(!e||!t)return;let r=e.locator!==t.locator||e.xpath!==t.xpath,i=e.action_data?.action_name!==t.action_data?.action_name;if(r&&i)return"both";if(r)return"locator_changed";if(i)return"action_changed"}var at="__shiplightRunCacheMetadata__";function we(){let e=globalThis;return e[at]??(e[at]={})}function st(){let e=we();return e.collector??=new ae,e.collector}function ct(){let e=we();return e.cacheInPlay===!0&&e.incomplete!==!0&&e.collector!==void 0&&e.collector.getSummary().total_statements>0}function lt(e){let t=we();if(!t.collector||e.size===0)return;let r=new Map;for(let i of e.keys())r.set(i,i);t.collector.recordHealedEntities(e,r)}function ut(e){if(!re(e))return;let t=te(e);return{tier:t.tier,tierSource:t.tierSource,mapSource:t.mapSource,webagentPrimary:t.webagent.primary,computerUsePrimary:t.computerUse.primary,...t.invalidTier!==void 0&&{invalidTier:t.invalidTier}}}var pt="0.1.96",dt=pt!=="dev"?pt:void 0;var Xo=3600*1e3,qo=10080*60*1e3;var gr={before:0,main:1,teardown:2,after:3};function ft(e){let t=e.split(".")[0];return gr[t]??1}function ht(e){return e.split(".").map(t=>{let r=Number(t);return Number.isNaN(r)?0:r})}function mr(e){return[...e].sort(([t],[r])=>{let i=ft(t),n=ft(r);if(i!==n)return i-n;let a=ht(t),o=ht(r);for(let s=0;s<Math.max(a.length,o.length);s++){let l=a[s]??-1,u=o[s]??-1;if(l!==u)return l-u}return 0})}function yr(e){let t=new Set;for(let r of e)if(t.add(r.category),r.category==="hook")for(let i of r.steps)t.add(i.category);return t}function _r(e,t){let r=e.toLowerCase();return r.includes("before")?"before":r.includes("after")?"after":t}function Se(e,t="main",r,i,n){r===void 0&&(r=!yr(e).has("test.step")),n||(n=new Map);let a=[];for(let o of e){if(o.category==="fixture"||o.category==="test.attach")continue;if(o.category==="hook"){let l=_r(o.title,t);a.push(...Se(o.steps,l,r,i,n));continue}if(o.category==="test.step"||r&&(o.category==="expect"||o.category==="pw:api")){let l=n.get(t)??0;n.set(t,l+1);let u=`${t}.${l}`,_={stepId:u,description:o.title,status:o.error?"failure":o.duration===-1?"skipped":"success",duration:o.duration>=0?o.duration:void 0};o.error&&(_.error=o.error.message??o.error.stack),i&&o.location&&i.set(u,o.location),a.push(_),o.steps.length>0&&a.push(...Se(o.steps,u,r,i,n))}}return a}function br(e,t){let r=v.isAbsolute(e)?e:v.join(process.cwd(),e),i=v.join(r,"latest");try{if(x.lstatSync(i).isSymbolicLink())x.unlinkSync(i);else{console.warn("[report] 'latest' exists and is not a symlink; skipping update");return}}catch{}try{process.platform==="win32"?x.symlinkSync(v.join(r,t),i,"junction"):x.symlinkSync(t,i,"dir")}catch(n){console.warn(`[report] Could not create 'latest' symlink: ${n instanceof Error?n.message:String(n)}`)}}function wr(e){let t=new Map;if(!e)return t;let r;try{r=JSON.parse(e)}catch{return t}if(!r?.entries||typeof r.entries!="object")return t;for(let[i,n]of Object.entries(r.entries))n?.action_entity&&t.set(i,n.action_entity);return t}var ve=class{outputFolder;openMode;latestSymlinkDir;collected=[];config;runStartTime;constructor(t={}){this.outputFolder=t.outputFolder||"shiplight-report",this.openMode=t.open||"on-failure",this.latestSymlinkDir=t.latestSymlinkDir}onBegin(t,r){this.config=t,this.runStartTime=new Date().toISOString()}onTestEnd(t,r){this.collected.push({test:t,result:r})}projectOutputDirs(){let t=new Set;for(let r of this.config?.projects??[])r.outputDir&&t.add(r.outputDir);return Array.from(t)}async onEnd(t){if(this.collected.length===0)return;let r=new Map;for(let u of this.collected){let _=u.test.titlePath().join(" > "),b=r.get(_);b||(b=[],r.set(_,b)),b.push(u)}let i=[];for(let[,u]of r.entries()){let _=u[0].test.location.file,b=[],g,d,k;for(let h=0;h<u.length;h++){let{test:m,result:w}=u[h],T=await this.buildReportTest(m,w,_);g=T,d||(d=T.startTime),k=T.endTime,b.push({attemptNumber:h+1,status:w.status,duration:w.duration,steps:T.steps,error:T.error,videoPath:T.videoPath,tracePath:T.tracePath})}let y=b[b.length-1],{test:E}=u[u.length-1],p={title:E.title,baseTitle:g?.baseTitle,file:v.relative(process.cwd(),_),status:y.status,duration:y.duration,steps:y.steps,error:y.error,videoPath:y.videoPath,tracePath:y.tracePath,actionStepsMap:g?.actionStepsMap,tags:g?.tags,baseUrl:g?.baseUrl,skip:g?.skip,slow:g?.slow,timeout:g?.timeout,parameterSetName:g?.parameterSetName,startTime:d,endTime:k,suiteName:g?.suiteName};b.length>1&&(p.retries=b.length-1,p.attempts=b,b.some(m=>m.status==="failed"||m.status==="timedOut")&&y.status==="passed"&&(p.flaky=!0)),i.push(p)}let n={tests:i,totalDuration:t.duration,timestamp:new Date().toISOString(),shiplightVersion:dt,usageSummary:nt(process.cwd(),this.projectOutputDirs()),cacheSummary:ct()?st().getSummary():void 0,modelTierProvenance:ut(oe())},a=v.isAbsolute(this.outputFolder)?this.outputFolder:v.join(process.cwd(),this.outputFolder);x.mkdirSync(a,{recursive:!0});let o=v.join(a,"screenshots");for(let u=0;u<n.tests.length;u++){let _=n.tests[u],b=_.attempts&&_.attempts.length>0,g=[{obj:_,prefix:b?`test-${u}-attempt-0`:`test-${u}`,screenshotSubDir:`test-${u}`}];if(_.attempts)for(let d=0;d<_.attempts.length;d++)g.push({obj:_.attempts[d],prefix:`test-${u}-attempt-${d+1}`,screenshotSubDir:`test-${u}/attempt-${d}`});for(let{obj:d,prefix:k,screenshotSubDir:y}of g){let E=v.join(o,y),p=!1;for(let h of d.steps)if(h.screenshot&&v.isAbsolute(h.screenshot))try{p||(x.mkdirSync(E,{recursive:!0}),p=!0);let m=`${h.stepId.replace(/\./g,"-")}.png`;x.copyFileSync(h.screenshot,v.join(E,m)),h.screenshot=`screenshots/${y}/${m}`}catch(m){console.warn(`[reporter] Failed to copy screenshot for ${h.stepId}:`,m)}if(d.videoPath&&v.isAbsolute(d.videoPath)){let h=v.extname(d.videoPath)||".webm",m=`${k}-video${h}`;try{x.copyFileSync(d.videoPath,v.join(a,m)),d.videoPath=m}catch{d.videoPath=void 0}}if(d.tracePath&&v.isAbsolute(d.tracePath)){let h=v.extname(d.tracePath)||".zip",m=`${k}-trace${h}`;try{x.copyFileSync(d.tracePath,v.join(a,m)),d.tracePath=m}catch{d.tracePath=void 0}}}}let s=v.join(a,"report-data.json");x.writeFileSync(s,JSON.stringify(n,null,2),"utf-8");let l=v.join(a,"index.html");if(x.writeFileSync(l,Qe({...n,outputDir:a}),"utf-8"),console.log(`
887
- Shiplight report written to: ${l}`),this.latestSymlinkDir&&br(this.latestSymlinkDir,v.basename(a)),this.openMode==="always"||this.openMode==="on-failure"&&t.status!=="passed")try{let u=(await import("open")).default;await u(l)}catch{}}printsToStdio(){return!1}async buildReportTest(t,r,i){let n={title:t.title,file:v.relative(process.cwd(),i),status:r.status,duration:r.duration,steps:[],startTime:new Date(r.startTime).toISOString(),endTime:new Date(r.startTime.getTime()+r.duration).toISOString()};r.errors.length>0&&(n.error=r.errors.map(p=>p.message||p.stack||String(p)).join(`
886
+ </html>`}import*as at from"fs";import*as we from"path";import{globSync as yr}from"glob";function dr(e){let t=e.toLowerCase();return t.includes("claude")||t.includes("anthropic")?"anthropic":t.includes("gemini")||t.includes("google")?"gemini":t.startsWith("gpt")||t.startsWith("o1")||t.startsWith("o3")||t.startsWith("o4")||t.includes("openai")?"openai":"unknown"}function fr(e){switch(e.actionType){case"execute":case"run":return"action";case"generate":return"draft";case"assert":return"verify_ai";case"evaluate":return e.conditionKind==="while"?"evaluate_while":e.conditionKind==="wait_until"?"evaluate_wait_until":"evaluate_if";default:return null}}function it(e,t){let r=e[t];return typeof r=="number"?r:0}function hr(e,t,r,i){return`${e}\0${t}\0${r}\0${i}`}function nt(e,t={}){let r=t.routing??"proxy",i=t.providerOf??dr,n=new Map;for(let o of e??[]){let s=fr(o);if(s)for(let l of o.tokenUsages??[]){let u=l.model??"unknown",_=i(u),b=hr(s,_,u,r),g=n.get(b);g||(g={operation:s,provider:_,model:u,routing:r,calls:0,input_tokens:0,output_tokens:0,thinking_tokens:0,cache_read_tokens:0},n.set(b,g)),g.calls+=1,g.input_tokens+=l.prompt_tokens||0,g.output_tokens+=l.completion_tokens||0,g.thinking_tokens+=it(l,"thinking_tokens"),g.cache_read_tokens+=it(l,"cache_read_tokens")}}return{by_operation:Array.from(n.values()).sort((o,s)=>o.operation!==s.operation?o.operation.localeCompare(s.operation):o.provider!==s.provider?o.provider.localeCompare(s.provider):o.model.localeCompare(s.model))}}import Jo from"dotenv";var gr="__shiplightDotenvCache__";function mr(){return globalThis[gr]}function ae(){let e=mr();return e===void 0?process.env:e}function _r(e){if(!e)return!1;let t=e.trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}var ot={anthropic:e=>e.ANTHROPIC_API_KEY||_r(e.ANTHROPIC_MODELS_USE_VERTEXAI)?"byok":"proxy",gemini:e=>{let t=e.GOOGLE_GENAI_USE_VERTEXAI;return e.GOOGLE_API_KEY||t==="True"||t==="true"?"byok":"proxy"},openai:e=>e.OPENAI_API_KEY?e.OPENAI_BASE_URL?"custom_endpoint":"byok":"proxy"},br=/^(gpt-|o\d|chatgpt-)/;function wr(e,t){return e!=="unknown"?e:br.test(t)?"openai":"unknown"}function Sr(e,t){let r=t.SHIPLIGHT_USAGE_ROUTING;if(r==="proxy"||r==="byok"||r==="custom_endpoint")return r;let i=ot[e];return i?i(t):Object.values(ot).some(a=>a(t)!=="proxy")?"byok":"proxy"}function st(e,t){let r=t?.length?t:[we.join(e,"test-results")],i=[];for(let s of r){let l;try{l=yr("**/ai-actions.json",{cwd:s})}catch{continue}for(let u of l)try{let _=JSON.parse(at.readFileSync(we.join(s,u),"utf-8"));Array.isArray(_)&&i.push(..._)}catch{}}if(i.length===0)return;let n=ae(),a=nt(i,{routing:"proxy"}),o=a.by_operation.map(s=>{let l=wr(s.provider,s.model);return{...s,provider:l,routing:Sr(l,n)}});return o.sort(vr),o.length>0?{...a,by_operation:o}:void 0}function ct(e){let t=new Map;for(let r of e){if(!r.stepId||r.tokenUsages.length===0)continue;let i=t.get(r.stepId)??[];for(let n of r.tokenUsages)i.push({model:n.model,promptTokens:n.prompt_tokens,completionTokens:n.completion_tokens,totalTokens:n.total_tokens});t.set(r.stepId,i)}return t}function vr(e,t){return e.operation!==t.operation?e.operation.localeCompare(t.operation):e.provider!==t.provider?e.provider.localeCompare(t.provider):e.model!==t.model?e.model.localeCompare(t.model):e.routing.localeCompare(t.routing)}var se=class{records=new Map;recordStatementSource(t,r,i,n,a,o){this.records.set(t,{statement_hash:t,statement_path:r,description:i,source:n,original_action_entity:a,cached_action_entity:n==="cache_hit"?o:void 0})}recordHealedEntities(t,r){for(let[i,n]of t){let a=r.get(i);if(!a)continue;let o=this.records.get(a);o&&((o.source==="original"||o.source==="cache_hit")&&(o.pre_heal_source=o.source),o.source="healed",o.healed_action_entity=n,o.heal_reason=xr(o.original_action_entity,n))}}recordFailed(t){let r=this.records.get(t);r&&(r.source="failed")}getStatementDetails(){return Array.from(this.records.values())}getSummary(){let t=0,r=0,i=0,n=0,a=0;for(let o of this.records.values())switch(o.source){case"original":t++;break;case"cache_hit":r++;break;case"healed":i++,o.pre_heal_source==="cache_hit"&&n++;break;case"failed":a++;break}return{total_statements:this.records.size,original:t,cache_hits:r,healed:i,healed_from_cache:n,failed:a}}getConsoleSummary(){let t=this.getSummary();if(t.total_statements===0)return"";let r=[];return t.cache_hits>0&&r.push(`${t.cache_hits} cached`),t.healed>0&&r.push(`${t.healed} healed`),t.original>0&&r.push(`${t.original} original`),t.failed>0&&r.push(`${t.failed} failed`),`[Shiplight Cache] ${r.join(", ")}`}};function xr(e,t){if(!e||!t)return;let r=e.locator!==t.locator||e.xpath!==t.xpath,i=e.action_data?.action_name!==t.action_data?.action_name;if(r&&i)return"both";if(r)return"locator_changed";if(i)return"action_changed"}var lt="__shiplightRunCacheMetadata__";function Se(){let e=globalThis;return e[lt]??(e[lt]={})}function ut(){let e=Se();return e.collector??=new se,e.collector}function pt(){let e=Se();return e.cacheInPlay===!0&&e.incomplete!==!0&&e.collector!==void 0&&e.collector.getSummary().total_statements>0}function dt(e){let t=Se();if(!t.collector||e.size===0)return;let r=new Map;for(let i of e.keys())r.set(i,i);t.collector.recordHealedEntities(e,r)}function ft(e){if(!re(e))return;let t=te(e);return{tier:t.tier,tierSource:t.tierSource,mapSource:t.mapSource,webagentPrimary:t.webagent.primary,computerUsePrimary:t.computerUse.primary,...t.invalidTier!==void 0&&{invalidTier:t.invalidTier}}}var ht="0.1.97",gt=ht!=="dev"?ht:void 0;var ua=3600*1e3,pa=10080*60*1e3;var Ar={before:0,main:1,teardown:2,after:3};function mt(e){let t=e.split(".")[0];return Ar[t]??1}function yt(e){return e.split(".").map(t=>{let r=Number(t);return Number.isNaN(r)?0:r})}function Tr(e){return[...e].sort(([t],[r])=>{let i=mt(t),n=mt(r);if(i!==n)return i-n;let a=yt(t),o=yt(r);for(let s=0;s<Math.max(a.length,o.length);s++){let l=a[s]??-1,u=o[s]??-1;if(l!==u)return l-u}return 0})}function Er(e){let t=new Set;for(let r of e)if(t.add(r.category),r.category==="hook")for(let i of r.steps)t.add(i.category);return t}function $r(e,t){let r=e.toLowerCase();return r.includes("before")?"before":r.includes("after")?"after":t}function ve(e,t="main",r,i,n){r===void 0&&(r=!Er(e).has("test.step")),n||(n=new Map);let a=[];for(let o of e){if(o.category==="fixture"||o.category==="test.attach")continue;if(o.category==="hook"){let l=$r(o.title,t);a.push(...ve(o.steps,l,r,i,n));continue}if(o.category==="test.step"||r&&(o.category==="expect"||o.category==="pw:api")){let l=n.get(t)??0;n.set(t,l+1);let u=`${t}.${l}`,_={stepId:u,description:o.title,status:o.error?"failure":o.duration===-1?"skipped":"success",duration:o.duration>=0?o.duration:void 0};o.error&&(_.error=o.error.message??o.error.stack),i&&o.location&&i.set(u,o.location),a.push(_),o.steps.length>0&&a.push(...ve(o.steps,u,r,i,n))}}return a}function Mr(e,t){let r=v.isAbsolute(e)?e:v.join(process.cwd(),e),i=v.join(r,"latest");try{if(x.lstatSync(i).isSymbolicLink())x.unlinkSync(i);else{console.warn("[report] 'latest' exists and is not a symlink; skipping update");return}}catch{}try{process.platform==="win32"?x.symlinkSync(v.join(r,t),i,"junction"):x.symlinkSync(t,i,"dir")}catch(n){console.warn(`[report] Could not create 'latest' symlink: ${n instanceof Error?n.message:String(n)}`)}}function Pr(e){let t=new Map;if(!e)return t;let r;try{r=JSON.parse(e)}catch{return t}if(!r?.entries||typeof r.entries!="object")return t;for(let[i,n]of Object.entries(r.entries))n?.action_entity&&t.set(i,n.action_entity);return t}var xe=class{outputFolder;openMode;latestSymlinkDir;collected=[];config;runStartTime;constructor(t={}){this.outputFolder=t.outputFolder||"shiplight-report",this.openMode=t.open||"on-failure",this.latestSymlinkDir=t.latestSymlinkDir}onBegin(t,r){this.config=t,this.runStartTime=new Date().toISOString()}onTestEnd(t,r){this.collected.push({test:t,result:r})}projectOutputDirs(){let t=new Set;for(let r of this.config?.projects??[])r.outputDir&&t.add(r.outputDir);return Array.from(t)}async onEnd(t){if(this.collected.length===0)return;let r=new Map;for(let u of this.collected){let _=u.test.titlePath().join(" > "),b=r.get(_);b||(b=[],r.set(_,b)),b.push(u)}let i=[];for(let[,u]of r.entries()){let _=u[0].test.location.file,b=[],g,d,k;for(let h=0;h<u.length;h++){let{test:m,result:w}=u[h],T=await this.buildReportTest(m,w,_);g=T,d||(d=T.startTime),k=T.endTime,b.push({attemptNumber:h+1,status:w.status,duration:w.duration,steps:T.steps,error:T.error,videoPath:T.videoPath,tracePath:T.tracePath})}let y=b[b.length-1],{test:E}=u[u.length-1],p={title:E.title,baseTitle:g?.baseTitle,file:v.relative(process.cwd(),_),status:y.status,duration:y.duration,steps:y.steps,error:y.error,videoPath:y.videoPath,tracePath:y.tracePath,actionStepsMap:g?.actionStepsMap,tags:g?.tags,baseUrl:g?.baseUrl,skip:g?.skip,slow:g?.slow,timeout:g?.timeout,parameterSetName:g?.parameterSetName,startTime:d,endTime:k,suiteName:g?.suiteName};b.length>1&&(p.retries=b.length-1,p.attempts=b,b.some(m=>m.status==="failed"||m.status==="timedOut")&&y.status==="passed"&&(p.flaky=!0)),i.push(p)}let n={tests:i,totalDuration:t.duration,timestamp:new Date().toISOString(),shiplightVersion:gt,usageSummary:st(process.cwd(),this.projectOutputDirs()),cacheSummary:pt()?ut().getSummary():void 0,modelTierProvenance:ft(ae())},a=v.isAbsolute(this.outputFolder)?this.outputFolder:v.join(process.cwd(),this.outputFolder);x.mkdirSync(a,{recursive:!0});let o=v.join(a,"screenshots");for(let u=0;u<n.tests.length;u++){let _=n.tests[u],b=_.attempts&&_.attempts.length>0,g=[{obj:_,prefix:b?`test-${u}-attempt-0`:`test-${u}`,screenshotSubDir:`test-${u}`}];if(_.attempts)for(let d=0;d<_.attempts.length;d++)g.push({obj:_.attempts[d],prefix:`test-${u}-attempt-${d+1}`,screenshotSubDir:`test-${u}/attempt-${d}`});for(let{obj:d,prefix:k,screenshotSubDir:y}of g){let E=v.join(o,y),p=!1;for(let h of d.steps)if(h.screenshot&&v.isAbsolute(h.screenshot))try{p||(x.mkdirSync(E,{recursive:!0}),p=!0);let m=`${h.stepId.replace(/\./g,"-")}.png`;x.copyFileSync(h.screenshot,v.join(E,m)),h.screenshot=`screenshots/${y}/${m}`}catch(m){console.warn(`[reporter] Failed to copy screenshot for ${h.stepId}:`,m)}if(d.videoPath&&v.isAbsolute(d.videoPath)){let h=v.extname(d.videoPath)||".webm",m=`${k}-video${h}`;try{x.copyFileSync(d.videoPath,v.join(a,m)),d.videoPath=m}catch{d.videoPath=void 0}}if(d.tracePath&&v.isAbsolute(d.tracePath)){let h=v.extname(d.tracePath)||".zip",m=`${k}-trace${h}`;try{x.copyFileSync(d.tracePath,v.join(a,m)),d.tracePath=m}catch{d.tracePath=void 0}}}}let s=v.join(a,"report-data.json");x.writeFileSync(s,JSON.stringify(n,null,2),"utf-8");let l=v.join(a,"index.html");if(x.writeFileSync(l,rt({...n,outputDir:a}),"utf-8"),console.log(`
887
+ Shiplight report written to: ${l}`),this.latestSymlinkDir&&Mr(this.latestSymlinkDir,v.basename(a)),this.openMode==="always"||this.openMode==="on-failure"&&t.status!=="passed")try{let u=(await import("open")).default;await u(l)}catch{}}printsToStdio(){return!1}async buildReportTest(t,r,i){let n={title:t.title,file:v.relative(process.cwd(),i),status:r.status,duration:r.duration,steps:[],startTime:new Date(r.startTime).toISOString(),endTime:new Date(r.startTime.getTime()+r.duration).toISOString()};r.errors.length>0&&(n.error=r.errors.map(p=>p.message||p.stack||String(p)).join(`
888
888
 
889
- `)),r.stdout.length>0&&(n.stdout=r.stdout.map(p=>typeof p=="string"?p:p.toString()).join("")),r.stderr.length>0&&(n.stderr=r.stderr.map(p=>typeof p=="string"?p:p.toString()).join(""));for(let p of r.attachments)p.name==="video"&&p.path&&(n.videoPath=p.path),p.name==="trace"&&p.path&&(n.tracePath=p.path);let a=r.attachments.find(p=>p.name==="shiplight-results"),o=a?.path?v.dirname(a.path):"",s=null;if(a)try{if(a.body)s=JSON.parse(a.body.toString("utf-8"));else if(a.path){let p=x.readFileSync(a.path,"utf-8");s=JSON.parse(p)}}catch{}let l=r.attachments.find(p=>p.name==="shiplight-new-action-entities");if(l)try{let p=l.body?l.body.toString("utf-8"):l.path?x.readFileSync(l.path,"utf-8"):null;lt(wr(p))}catch{}let u=r.attachments.find(p=>p.name==="shiplight-ai-actions"),_=[];if(u)try{let p=u.body?u.body.toString("utf-8"):u.path?x.readFileSync(u.path,"utf-8"):null,h=p?JSON.parse(p):null;Array.isArray(h)&&(_=h)}catch{}let b=ot(_),g=i.replace(/\.yaml\.spec\.ts$/,".test.yaml"),d={},k=t.title.match(/^(.*)\s+\[([^\]]+)\]$/),y=k?k[1]:t.title,E=k?k[2]:void 0;if(E&&(n.parameterSetName=E),x.existsSync(g))try{let p=x.readFileSync(g,"utf-8"),h=Je(p,g,this.config.rootDir);if(h.suite){let m=h.suite.tests.find(w=>w.name===y);m&&(d=z(m.testFlow),m.tags?.length&&(n.tags=m.tags),m.skip!==void 0&&(n.skip=m.skip),m.slow&&(n.slow=m.slow),m.timeout!==void 0&&(n.timeout=m.timeout),n.baseTitle=m.name||m.testFlow?.goal),n.suiteName=h.name,h.tags?.length&&(n.suiteTags=h.tags),h.use?.baseURL&&(n.baseUrl=h.use.baseURL)}else h.testFlow&&(d=z(h.testFlow),n.baseTitle=h.name||h.testFlow?.goal,h.tags?.length&&(n.tags=h.tags),h.use?.baseURL&&(n.baseUrl=h.use.baseURL))}catch{}if(s||Object.keys(d).length>0){let p=new Set([...Object.keys(d),...Object.keys(s||{})]),h=Array.from(p).map(w=>[w,null]),m=mr(h);for(let[w]of m){let T=d[w],S=s?.[w],$=T?.description;if(!$||$==="Action"||$==="Draft"){let P=T?.action_entity;$=P?.action_description||P?.action_data?.kwargs?.description||S?.description||w}let M={stepId:w,description:$,status:S?.status||"pending",duration:S?.duration};if(S?.message){let P=typeof S.message=="string"?S.message:JSON.stringify(S.message,null,2);S.status==="failure"?M.error=P:M.message=P}if(S?.screenshot){let P=S.screenshot,K=v.isAbsolute(P)?P:v.join(o,P);x.existsSync(K)&&(M.screenshot=K)}S?.code&&(M.code=S.code),S?.type&&(M.type=S.type),S?.startTime&&(M.startTime=S.startTime),S?.autoHealed&&(M.autoHealed=S.autoHealed),S?.healedAction&&(M.healedAction=S.healedAction),S?.dismissedModalActions?.length&&(M.dismissedModalActions=S.dismissedModalActions),S?.contextBefore&&(M.contextBefore=S.contextBefore),S?.contextAfter&&(M.contextAfter=S.contextAfter);let j=b.get(w);j&&(M.llmUsage=j),n.steps.push(M)}}if(s===null&&Object.keys(d).length===0&&!i.endsWith(".yaml.spec.ts")){let p=new Map;if(n.steps=Se(r.steps,"main",void 0,p),n.steps.length>0){let h=new Map;n.actionStepsMap=Object.fromEntries(n.steps.map(m=>{let w=p.get(m.stepId),T;if(w?.file){if(!h.has(w.file))try{h.set(w.file,x.readFileSync(w.file,"utf-8").split(`
889
+ `)),r.stdout.length>0&&(n.stdout=r.stdout.map(p=>typeof p=="string"?p:p.toString()).join("")),r.stderr.length>0&&(n.stderr=r.stderr.map(p=>typeof p=="string"?p:p.toString()).join(""));for(let p of r.attachments)p.name==="video"&&p.path&&(n.videoPath=p.path),p.name==="trace"&&p.path&&(n.tracePath=p.path);let a=r.attachments.find(p=>p.name==="shiplight-results"),o=a?.path?v.dirname(a.path):"",s=null;if(a)try{if(a.body)s=JSON.parse(a.body.toString("utf-8"));else if(a.path){let p=x.readFileSync(a.path,"utf-8");s=JSON.parse(p)}}catch{}let l=r.attachments.find(p=>p.name==="shiplight-new-action-entities");if(l)try{let p=l.body?l.body.toString("utf-8"):l.path?x.readFileSync(l.path,"utf-8"):null;dt(Pr(p))}catch{}let u=r.attachments.find(p=>p.name==="shiplight-ai-actions"),_=[];if(u)try{let p=u.body?u.body.toString("utf-8"):u.path?x.readFileSync(u.path,"utf-8"):null,h=p?JSON.parse(p):null;Array.isArray(h)&&(_=h)}catch{}let b=ct(_),g=i.replace(/\.yaml\.spec\.ts$/,".test.yaml"),d={},k=t.title.match(/^(.*)\s+\[([^\]]+)\]$/),y=k?k[1]:t.title,E=k?k[2]:void 0;if(E&&(n.parameterSetName=E),x.existsSync(g))try{let p=x.readFileSync(g,"utf-8"),h=qe(p,g,this.config.rootDir);if(h.suite){let m=h.suite.tests.find(w=>w.name===y);m&&(d=Y(m.testFlow),m.tags?.length&&(n.tags=m.tags),m.skip!==void 0&&(n.skip=m.skip),m.slow&&(n.slow=m.slow),m.timeout!==void 0&&(n.timeout=m.timeout),n.baseTitle=m.name||m.testFlow?.goal),n.suiteName=h.name,h.tags?.length&&(n.suiteTags=h.tags),h.use?.baseURL&&(n.baseUrl=h.use.baseURL)}else h.testFlow&&(d=Y(h.testFlow),n.baseTitle=h.name||h.testFlow?.goal,h.tags?.length&&(n.tags=h.tags),h.use?.baseURL&&(n.baseUrl=h.use.baseURL))}catch{}if(s||Object.keys(d).length>0){let p=new Set([...Object.keys(d),...Object.keys(s||{})]),h=Array.from(p).map(w=>[w,null]),m=Tr(h);for(let[w]of m){let T=d[w],S=s?.[w],$=T?.description;if(!$||$==="Action"||$==="Draft"){let P=T?.action_entity;$=P?.action_description||P?.action_data?.kwargs?.description||S?.description||w}let M={stepId:w,description:$,status:S?.status||"pending",duration:S?.duration};if(S?.message){let P=typeof S.message=="string"?S.message:JSON.stringify(S.message,null,2);S.status==="failure"?M.error=P:M.message=P}if(S?.screenshot){let P=S.screenshot,K=v.isAbsolute(P)?P:v.join(o,P);x.existsSync(K)&&(M.screenshot=K)}S?.code&&(M.code=S.code),S?.type&&(M.type=S.type),S?.startTime&&(M.startTime=S.startTime),S?.autoHealed&&(M.autoHealed=S.autoHealed),S?.healedAction&&(M.healedAction=S.healedAction),S?.dismissedModalActions?.length&&(M.dismissedModalActions=S.dismissedModalActions),S?.contextBefore&&(M.contextBefore=S.contextBefore),S?.contextAfter&&(M.contextAfter=S.contextAfter);let j=b.get(w);j&&(M.llmUsage=j),n.steps.push(M)}}if(s===null&&Object.keys(d).length===0&&!i.endsWith(".yaml.spec.ts")){let p=new Map;if(n.steps=ve(r.steps,"main",void 0,p),n.steps.length>0){let h=new Map;n.actionStepsMap=Object.fromEntries(n.steps.map(m=>{let w=p.get(m.stepId),T;if(w?.file){if(!h.has(w.file))try{h.set(w.file,x.readFileSync(w.file,"utf-8").split(`
890
890
  `))}catch{h.set(w.file,[])}let $=h.get(w.file);T=$[w.line-1]?.trim();let M=w.line-2,j=w.line,P=[],K=w.line;M>=0&&(P.push($[M]??""),K=w.line-1),P.push($[w.line-1]??""),j<$.length&&P.push($[j]??""),m.code=P.join(`
891
- `),m.codeStartLine=K,m.codeLine=w.line}let S={description:m.description,...T&&{action_entity:{action_description:m.description,action_data:{action_name:"js_code",args:[],kwargs:{code:T}}}}};return[m.stepId,S]}))}}return Object.keys(d).length>0?n.actionStepsMap=d:s&&n.steps.length>0&&(n.actionStepsMap=Object.fromEntries(n.steps.map(p=>{let h=s[p.stepId],m=h?.type,w={description:p.description,...m&&{action_entity:{action_description:p.description,action_data:{action_name:m==="step"?"js_code":m,args:[],kwargs:m==="step"?{code:h?.code??p.description}:{statement:p.description}}}}};return[p.stepId,w]}))),n}},Sr=ve;export{Sr as default};
891
+ `),m.codeStartLine=K,m.codeLine=w.line}let S={description:m.description,...T&&{action_entity:{action_description:m.description,action_data:{action_name:"js_code",args:[],kwargs:{code:T}}}}};return[m.stepId,S]}))}}return Object.keys(d).length>0?n.actionStepsMap=d:s&&n.steps.length>0&&(n.actionStepsMap=Object.fromEntries(n.steps.map(p=>{let h=s[p.stepId],m=h?.type,w={description:p.description,...m&&{action_entity:{action_description:p.description,action_data:{action_name:m==="step"?"js_code":m,args:[],kwargs:m==="step"?{code:h?.code??p.description}:{statement:p.description}}}}};return[p.stepId,w]}))),n}},Or=xe;export{Or as default};