shiplightai 0.1.20 → 0.1.22
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/agentHelpers-ZM2YPYUG.js +3 -0
- package/dist/agentLogin-TVTERJCC.js +3 -0
- package/dist/chunk-47OHTDHW.js +18 -0
- package/dist/chunk-4MP3EHVU.js +11 -0
- package/dist/{chunk-32JFHFFG.js → chunk-AEEQXF3N.js} +29 -29
- package/dist/chunk-C6BVAOFE.js +3 -0
- package/dist/{chunk-RTTIJBGI.js → chunk-CSHDULY4.js} +28 -28
- package/dist/chunk-EEEG4LZX.js +3 -0
- package/dist/chunk-HJNJZWUA.js +5 -0
- package/dist/chunk-ID5JNGPZ.js +18 -0
- package/dist/{chunk-YHOTGR6H.js → chunk-J4TZ3OFZ.js} +1 -1
- package/dist/chunk-JQ2K2XJ4.js +61 -0
- package/dist/chunk-L5JSAS2D.js +3 -0
- package/dist/{chunk-YDR4P3GA.js → chunk-NLZ3YJX4.js} +1 -1
- package/dist/{chunk-JHSENQ4F.js → chunk-SFCNGCFT.js} +27 -27
- package/dist/{chunk-2F3YRAA7.js → chunk-VLVDPV2E.js} +13 -13
- package/dist/cjs/debugger-pw.cjs +8 -4
- package/dist/cjs/fixture.cjs +162 -147
- package/dist/cjs/index.cjs +229 -309
- package/dist/cjs/reporter.cjs +725 -0
- package/dist/cli.js +2107 -937
- package/dist/config-BUSI76YU.js +3 -0
- package/dist/debugger-pw.d.ts +5 -0
- package/dist/debugger-pw.js +1 -1
- package/dist/dist-3HGFS7M3-T7FMZHX4.js +3 -0
- package/dist/dist-K7NWI5BS.js +3 -0
- package/dist/dist-SIZHXBHX.js +3 -0
- package/dist/fixture.js +1 -1
- package/dist/handler-J6CCKSPE.js +3 -0
- package/dist/index.d.ts +1 -48
- package/dist/index.js +4 -19
- package/dist/{intRunner-5A6M6JSJ.js → intRunner-ZYEEZ6MK.js} +1 -1
- package/dist/reporter.d.ts +28 -0
- package/dist/reporter.js +723 -0
- package/dist/task-EDC5BGTS.js +192 -0
- package/dist/testFlow-HYGLHAP6.js +3 -0
- package/package.json +8 -1
- package/dist/agentHelpers-2TII7YCW.js +0 -3
- package/dist/agentLogin-GDOU6BCP.js +0 -3
- package/dist/chunk-DJDHFWEV.js +0 -3
- package/dist/chunk-JNRJXAJS.js +0 -18
- package/dist/chunk-LPSNOKYP.js +0 -61
- package/dist/chunk-USRSZQWN.js +0 -5
- package/dist/dist-CXOVVE77.js +0 -3
- package/dist/dist-SRXGJZ7P.js +0 -3
- package/dist/handler-BAP4TGW6.js +0 -3
- package/dist/task-VW6MUEKX.js +0 -192
- package/dist/testFlow-DPEUSVQO.js +0 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "module";
|
|
2
|
+
const require = __createRequire(import.meta.url);
|
|
3
|
+
import{d as t,e as o,f as r,g as p,h as i}from"./chunk-AEEQXF3N.js";import"./chunk-CSHDULY4.js";import"./chunk-NLZ3YJX4.js";import"./chunk-YU3XZJIJ.js";import"./chunk-HJNJZWUA.js";import"./chunk-EEEG4LZX.js";import"./chunk-C6BVAOFE.js";import"./chunk-L5JSAS2D.js";import"./chunk-CSINHOOD.js";export{p as evaluateStatement,t as executeAction,r as executeStep,o as generateActionStep,i as runTask};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "module";
|
|
2
|
+
const require = __createRequire(import.meta.url);
|
|
3
|
+
import{a as o,b as t,c as i,d as r,e as s,f as e}from"./chunk-JQ2K2XJ4.js";import{S as a}from"./chunk-ID5JNGPZ.js";import"./chunk-J4TZ3OFZ.js";import"./chunk-NLZ3YJX4.js";import"./chunk-EEEG4LZX.js";import"./chunk-C6BVAOFE.js";import"./chunk-L5JSAS2D.js";import"./chunk-CSINHOOD.js";export{a as LoginType,o as checkLocators,r as createUnsignedInContext,e as generateAndValidateLoginLocators,s as generateValidationLocators,i as validateLogin,t as validateLoginLocators};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "module";
|
|
2
|
+
const require = __createRequire(import.meta.url);
|
|
3
|
+
var Re=[/iphone/i,/ipad/i,/android/i,/pixel/i,/galaxy/i,/mobile/i,/nexus/i,/blackberry/i,/kindle/i];function Ue(e){if(!e)return"desktop";for(let t of Re)if(t.test(e))return"mobile";return"desktop"}function $e(e,t){if(!e||typeof e!="string")return e;let i=t instanceof Map?Object.fromEntries(t):t,r=n=>{let l=n.startsWith("$")?n.slice(1):n,a=i[l]??i[`$${l}`];return a!=null?String(a):void 0},o=e;return o=o.replace(/\{\{\s*\$?([^}]+?)\s*\}\}/g,(n,l)=>{let a=r(l.trim());return a!==void 0?a:n}),o=o.replace(/<secret>\$?([\w-]+)<\/secret>/g,(n,l)=>{let a=r(l);return a!==void 0?a:n}),o=o.replace(/\$\{([^}]+)\}/g,(n,l)=>{let a=r(l.trim());return a!==void 0?a:n}),o=o.replace(/\$([a-zA-Z_]\w*)/g,(n,l)=>{let a=r(l);return a!==void 0?a:n}),o}var ze=class{version;goal;url;constructor(e,t){this.version=e,this.goal=t.goal,this.url=t.url}generatePrelude(){let e=`// version ${this.version}
|
|
4
|
+
`,t=this.goal,i=this.url;e+=`// Navigate to the specified URL
|
|
5
|
+
const targetUrl = process.env.PLAYWRIGHT_STARTING_URL || '${i}';
|
|
6
|
+
if (targetUrl !== null) {
|
|
7
|
+
await page.goto(targetUrl, { waitUntil: 'domcontentloaded' });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// wait for page to load and give it a chance to stabilize
|
|
11
|
+
await page.waitForLoadState('load', { timeout: 15000 });
|
|
12
|
+
await page.waitForTimeout(2000);
|
|
13
|
+
|
|
14
|
+
`,e+=` // Goal:
|
|
15
|
+
`;let r=t.trim().split(`
|
|
16
|
+
`);for(let o of r)e+=` // ${o}
|
|
17
|
+
`;return e}generatePostlude(){return""}};var P="android:",A="ios:";function Ve(e){return e?e.startsWith(P)?"android":e.startsWith(A)?"ios":"web":"web"}function Xe(e){return e?e.startsWith(P)||e.startsWith(A):!1}function Ye(e){return!!e&&e.startsWith(P)}function je(e){return!!e&&e.startsWith(A)}function Je(e){return e.startsWith(P)?e.slice(P.length):e.startsWith(A)?e.slice(A.length):e}function qe(e){return`${P}${e}`}function Ze(e){return`${A}${e}`}function X(e){return e?e.startsWith("http://")||e.startsWith("https://"):!1}function Qe(e){return e?!X(e):!1}function ee(e){return e?X(e)?["web"]:["android","ios"]:["web","android","ios"]}function et(e,t){if(!t)return!0;let i=ee(t);return e==="desktop"||e==="mobile"?i.includes("web"):i.includes(e)}function tt(e){return e.startsWith(A)?e:`${A}${e}`}function it(e){let t=e.iosVersion?` (iOS ${e.iosVersion})`:"";return e.deviceType==="simulator"?`${e.name}${t} - Simulator`:`${e.name}${t}`}function rt(e){return!!(/^[0-9a-fA-F]{40}$/.test(e)||/^[0-9a-fA-F]{8}-[0-9a-fA-F]{16}$/.test(e))}var te="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",Y=112,ie=1920,re=1080,oe=1920,ne=1080-Y,ae=1280,se=720,le=500,ce=500,C="Desktop Chrome",he=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(he||{}),N={"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"}},ue=(e=>(e.Desktop="desktop",e.Mobile="mobile",e))(ue||{}),de={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"]},F=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),de[e].map(r=>N[r]).filter(r=>r.defaultBrowserType&&i.includes(r.defaultBrowserType))},ot=()=>Object.keys(N),H=e=>N[e],nt={desktop:{label:"Desktop",type:"desktop",devices:F("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:F("mobile")}},at={desktop:{label:"Desktop",type:"desktop",devices:F("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:F("mobile",!0)}},j=(e,t=!1)=>{let i={userAgent:te,viewport:{width:oe,height:ne},isMobile:!1,hasTouch:!1};if(!e||e===C)return i;let r=H(e);if(!r)return i;let{width:o,height:n}=r.viewport,l=Math.max(le/o,1),a=Math.max(ce/n,1),c=Math.max(l,a),u={width:Math.round(o*c),height:Math.round(n*c)};return{userAgent:r.userAgent,viewport:t?u:r.viewport,isMobile:r.isMobile,hasTouch:r.hasTouch}},st=e=>{let t={width:ie,height:re};if(!e||e===C)return t;let i=j(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height+Y}:t},lt=e=>{let t={width:ae,height:se};if(!e||e===C)return t;let i=j(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height}:t},ct=e=>!e||e===C?void 0:H(e)?.channel,ht=e=>!e||e===C?"chromium":H(e)?.defaultBrowserType??"chromium";var pe=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(pe||{}),fe=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(fe||{});import{z as s}from"zod";var me=s.enum(["JS_CODE","AI_MODE"]),J=s.object({type:me,expression:s.string()}),ge=s.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),G=s.object({uid:s.string(),type:ge}),we=s.object({action_data:s.object({action_name:s.string(),kwargs:s.record(s.any()).optional(),args:s.array(s.any()).optional()}),action_description:s.string().optional(),url:s.string().optional(),xpath:s.string().nullable().optional(),locator:s.string().nullable().optional(),css_selector:s.string().nullable().optional(),unique_selector:s.string().nullable().optional(),element_index:s.number().nullable().optional(),frame_path:s.array(s.any()).optional(),artifacts:s.record(s.any()).optional(),feedback:s.string().optional(),original_browser_use_action:s.any().optional()}).passthrough(),ye=G.extend({type:s.literal("DRAFT"),description:s.string()}),Se=G.extend({type:s.literal("ACTION"),description:s.string(),action_entity:we.optional(),locator:s.string().optional(),use_pure_vision:s.boolean().optional()}),S=s.lazy(()=>s.union([ye,Se,G.extend({type:s.literal("STEP"),description:s.string().optional().default(""),statements:s.array(S),reference_id:s.number().optional()}),G.extend({type:s.literal("IF_ELSE"),description:s.string().optional(),condition:J,then:s.array(S),else:s.array(S).optional()}),G.extend({type:s.literal("WHILE_LOOP"),description:s.string().optional(),condition:J,body:s.array(S),timeout_ms:s.number().optional()})])),be=s.object({name:s.string(),statements:s.array(S),teardown:s.array(S).optional(),skip:s.union([s.boolean(),s.string()]).optional(),timeout:s.number().optional(),fail:s.union([s.boolean(),s.string()]).optional(),only:s.boolean().optional(),slow:s.boolean().optional()}),R=s.object({tests:s.array(be).min(1),beforeAll:s.array(S).optional(),afterAll:s.array(S).optional(),beforeEach:s.array(S).optional(),afterEach:s.array(S).optional()}),q=s.object({version:s.string().optional(),goal:s.string().optional(),url:s.string().optional(),baseURL:s.string().optional(),final_feedback:s.string().optional(),completed:s.boolean().optional(),success:s.boolean().optional(),statements:s.array(S).optional(),teardown:s.array(S).optional(),last_modified_at:s.string().optional(),testGroup:R.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 U,parse as Z,parseAllDocuments as ut}from"yaml";import{v4 as v}from"uuid";function Pe(e,t){let i={...t?.test_case_id!==void 0?{test_case_id:t.test_case_id}:{},...t?.name?{name:t.name}:{},goal:e.goal??"",url:e.url,base_url:e.baseURL,statements:(e.statements??[]).map(b)};return e.final_feedback&&(i.final_feedback=e.final_feedback),e.teardown&&e.teardown.length>0&&(i.teardown=e.teardown.map(b)),i}var $={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};function dt(e,t){return e.testGroup?Ae(e,t):U(Pe(e,t),$)}function Ae(e,t){let i=e.testGroup;if(!i)throw new Error("suiteToYaml requires a TestFlow with testGroup");let r={};t?.test_case_id!==void 0&&(r.test_case_id=t.test_case_id),t?.name&&(r.name=t.name),t?.tags&&t.tags.length>0&&(r.tags=t.tags),t?.use&&Object.keys(t.use).length>0&&(r.use=t.use);let o={};return e.baseURL&&(o.base_url=e.baseURL),i.beforeAll&&i.beforeAll.length>0&&(o.beforeAll=i.beforeAll.map(b)),i.beforeEach&&i.beforeEach.length>0&&(o.beforeEach=i.beforeEach.map(b)),i.afterEach&&i.afterEach.length>0&&(o.afterEach=i.afterEach.map(b)),i.afterAll&&i.afterAll.length>0&&(o.afterAll=i.afterAll.map(b)),o.tests=i.tests.map(n=>{let l={name:n.name};return n.skip!==void 0&&(l.skip=n.skip),n.timeout!==void 0&&(l.timeout=n.timeout),n.fail!==void 0&&(l.fail=n.fail),n.only!==void 0&&(l.only=n.only),n.slow!==void 0&&(l.slow=n.slow),l.statements=n.statements.map(b),n.teardown&&n.teardown.length>0&&(l.teardown=n.teardown.map(b)),l}),r.suite=o,U(r,$)}function pt(e){return e.map(t=>U(t,$)).join(`---
|
|
18
|
+
`)}function b(e){switch(e.type){case"DRAFT":return ft(e);case"ACTION":return mt(e);case"STEP":return gt(e);case"IF_ELSE":return wt(e);case"WHILE_LOOP":return yt(e)}}function ft(e){return{desc:e.description}}function mt(e){let t=e.action_entity?.action_data?.action_name??e.action_entity?.action?.action_name,i=e.action_entity?.action_data?.kwargs??e.action_entity?.action?.kwargs;if(t==="verify"){let a=i?.statement;if(typeof a=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let c=i?.code;return typeof c=="string"?{VERIFY:a,js:c}:{VERIFY:a}}}if(t==="go_to_url"){let a=i?.url;if(typeof a=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let c={URL:a};return i?.new_tab===!0&&(c.new_tab=!0),typeof i?.timeout_seconds=="number"&&(c.timeout_seconds=i.timeout_seconds),c}}if(t==="js_action"){let a=i?.code;if(typeof a=="string"&&e.description)return{desc:e.description,js:a}}if(t==="js_code"){let a=i?.code;if(typeof a=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath)return{CODE:a}}if(!e.action_entity)return{desc:e.description};let r=e.action_entity.action_data??e.action_entity.action;if(!r)return{desc:e.description};let o={desc:e.description,action:r.action_name},n=e.locator??e.action_entity.locator;n&&(o.locator=n);let l=e.action_entity.xpath;if(l&&(o.xpath=l),e.use_pure_vision&&(o.use_pure_vision=!0),r.kwargs&&Object.keys(r.kwargs).length>0)for(let[a,c]of Object.entries(r.kwargs))o[a]=c;return r.args&&r.args.length>0&&(o.args=r.args),o}function gt(e){let t={STEP:e.description,statements:e.statements.map(b)};return e.reference_id!==void 0&&(t.reference_id=e.reference_id),t}function wt(e){let t={IF:ve(e.condition),THEN:e.then.map(b)};return e.else&&e.else.length>0&&(t.ELSE=e.else.map(b)),t}function yt(e){let t={WHILE:ve(e.condition),DO:e.body.map(b)};return e.timeout_ms!==void 0&&(t.timeout_ms=e.timeout_ms),t}function ve(e){return e.type==="JS_CODE"?`js:${e.expression}`:e.expression}function St(e){let t=ut(e),i;if(t.length>1||t.length===1&&!Array.isArray(t[0]?.toJSON()))i=t.map((r,o)=>r.errors.length>0?{__parseError:`Document ${o+1}: ${r.errors[0].message}`}:r.toJSON());else{let r;try{r=Z(e)}catch(o){throw new Error(`Invalid YAML: ${o instanceof Error?o.message:String(o)}`)}if(!Array.isArray(r))throw new Error("Expected a YAML array or multi-document YAML (separated by ---)");i=r}return i.map((r,o)=>{try{if(r&&typeof r=="object"&&"__parseError"in r)return{error:r.__parseError};if(!r||typeof r!="object")return{error:`Item ${o+1}: expected an object`};let n=r,l=typeof n.name=="string"&&n.name.trim()||void 0,a=typeof n.goal=="string"?n.goal.trim():"";if(!a)return{error:`Item ${o+1}: missing "goal" field`};if(Array.isArray(n.statements))try{let c=U(n,$),u=K(c);return{name:l,goal:u.goal??a,testFlow:u}}catch{}return{name:l,goal:a}}catch(n){return{error:`Item ${o+1}: ${n instanceof Error?n.message:String(n)}`}}})}function bt(e){try{let t=Z(e);if(!t||typeof t!="object")return{};let i={};return typeof t.test_case_id=="number"&&Number.isFinite(t.test_case_id)&&(i.test_case_id=t.test_case_id),typeof t.template_id=="number"&&Number.isFinite(t.template_id)&&(i.template_id=t.template_id),typeof t.name=="string"&&t.name.trim()&&(i.name=t.name.trim()),i}catch{return{}}}var Te=1024*1024;function K(e){if(e.length>Te)throw new Error(`YAML input too large (${e.length} bytes, max ${Te})`);let t=Z(e);if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return Tt(t);let i={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:T(t.statements??[])};t.final_feedback&&(i.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(i.teardown=T(t.teardown));let r=q.safeParse(i);if(!r.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(r.error.errors)}`);return r.data}function Tt(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let i=t.tests;if(!Array.isArray(i)||i.length===0)throw new Error('Suite must have a non-empty "tests" array');let o={tests:i.map(a=>{if(!a.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(a.statements)||a.statements.length===0)throw new Error(`Suite test "${a.name}" must have a non-empty "statements" array`);let c={name:a.name,statements:T(a.statements)};return Array.isArray(a.teardown)&&a.teardown.length>0&&(c.teardown=T(a.teardown)),a.skip!==void 0&&(c.skip=a.skip),typeof a.timeout=="number"&&(c.timeout=a.timeout),a.fail!==void 0&&(c.fail=a.fail),a.only===!0&&(c.only=!0),a.slow===!0&&(c.slow=!0),c})};Array.isArray(t.beforeAll)&&t.beforeAll.length>0&&(o.beforeAll=T(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(o.afterAll=T(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(o.beforeEach=T(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(o.afterEach=T(t.afterEach));let n=R.safeParse(o);if(!n.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(n.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:n.data}}function T(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(Mt)}function Mt(e){if(typeof e=="string")throw new Error(`Plain string statements are not supported. Use "desc: ${e}" instead.`);if(typeof e!="object"||e===null)throw new Error(`Invalid statement: expected object, got ${typeof e}`);let t=e;if("IF"in t)return Pt(t);if("WHILE"in t)return At(t);if("STEP"in t)return vt(t);if("VERIFY"in t){let i=t.VERIFY,r={statement:typeof i=="string"?i:String(i)};return typeof t.js=="string"&&(r.code=t.js),{uid:v(),type:"ACTION",description:`Verify: ${i}`,action_entity:{action_description:`Verify: ${i}`,action_data:{action_name:"verify",kwargs:r}}}}if("URL"in t){let i=t.URL,r=t.new_tab===!0?!0:void 0,o=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,n={url:typeof i=="string"?i:String(i)};return r&&(n.new_tab=!0),o!==void 0&&(n.timeout_seconds=o),{uid:v(),type:"ACTION",description:`Navigate to ${i}`,action_entity:{action_description:`Navigate to ${i}`,action_data:{action_name:"go_to_url",kwargs:n}}}}if("CODE"in t){let i=t.CODE;return{uid:v(),type:"ACTION",description:"Code block",action_entity:{action_description:"Code block",action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("js"in t&&"desc"in t&&!("VERIFY"in t)){let i=t.js,r=typeof t.desc=="string"?t.desc:"";return{uid:v(),type:"ACTION",description:r,action_entity:{action_description:r,action_data:{action_name:"js_action",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:i,...r}=t;return Me({...r,action:"function",functionName:i})}if("action"in t)return Me(t);if("desc"in t&&typeof t.desc=="string")return{uid:v(),type:"DRAFT",description:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function _e(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 Pt(e){let t=_e(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let r={uid:v(),type:"IF_ELSE",condition:t,then:T(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(r.else=T(e.ELSE)),r}function At(e){let t=_e(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let r={uid:v(),type:"WHILE_LOOP",condition:t,body:T(i)};return typeof e.timeout_ms=="number"&&(r.timeout_ms=e.timeout_ms),r}function vt(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let i={uid:v(),type:"STEP",description:t,statements:T(e.statements)};return typeof e.reference_id=="number"&&(i.reference_id=e.reference_id),i}var _t=new Set(["action","desc","locator","xpath","use_pure_vision"]);function Me(e){let t=typeof e.action=="string"?e.action:String(e.action),i=typeof e.desc=="string"?e.desc:"",r=typeof e.locator=="string"?e.locator:void 0,o=typeof e.xpath=="string"?e.xpath:void 0,n=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,l={};for(let[u,h]of Object.entries(e))_t.has(u)||(l[u]=h);let a={action_description:i,action_data:{action_name:t,kwargs:Object.keys(l).length>0?l:{}}};r&&(a.locator=r),o&&(a.xpath=o);let c={uid:v(),type:"ACTION",description:i,action_entity:a};return n&&(c.use_pure_vision=!0),c}import{parse as Et,stringify as kt}from"yaml";function Ee(e,t){let i=[];t.version!=="1.0"&&i.push(`Unsupported patch version: ${t.version}`),(!Array.isArray(t.operations)||t.operations.length===0)&&i.push("Patch must have at least one operation");for(let r=0;r<t.operations.length;r++){let o=t.operations[r],n=`operations[${r}]`;switch(o.reason||i.push(`${n}: missing reason`),o.op){case"remove":{(typeof o.index!="number"||o.index<0||o.index>=e.length)&&i.push(`${n}: index ${o.index} out of bounds (0..${e.length-1})`);break}case"modify":{(typeof o.index!="number"||o.index<0||o.index>=e.length)&&i.push(`${n}: index ${o.index} out of bounds (0..${e.length-1})`),(o.statement===void 0||o.statement===null)&&i.push(`${n}: missing statement`);break}case"insert":{(typeof o.index!="number"||o.index<0||o.index>=e.length)&&i.push(`${n}: index ${o.index} out of bounds (0..${e.length-1})`),o.position!=="before"&&o.position!=="after"&&i.push(`${n}: position must be 'before' or 'after'`),(o.statement===void 0||o.statement===null)&&i.push(`${n}: missing statement`);break}default:i.push(`${n}: unknown operation type "${o.op}"`)}}return{valid:i.length===0,errors:i}}function ke(e,t){let i=Ee(e,t);if(!i.valid)throw new Error(`Invalid patch: ${i.errors.join("; ")}`);let r=[...e],o=t.operations.map((a,c)=>({...a,originalOrder:c})),n={remove:0,modify:1,insert:2},l=[...o].sort((a,c)=>a.index!==c.index?c.index-a.index:n[a.op]-n[c.op]);for(let a of l)switch(a.op){case"remove":r.splice(a.index,1);break;case"modify":r[a.index]=a.statement;break;case"insert":a.position==="before"?r.splice(a.index,0,a.statement):r.splice(a.index+1,0,a.statement);break}return r}function Ot(e,t){let i=Et(e);if(!i||typeof i!="object")throw new Error("Invalid YAML: expected an object at root level");let r=i.statements;if(!Array.isArray(r))throw new Error('YAML must have a "statements" array');let o=ke(r,t);i.statements=o;let n=kt(i,{lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"});return K(n),{modifiedYaml:n,modifiedStatements:o}}var k=e=>{let t=[];switch(e.type){case"STEP":e.statements&&t.push({key:"statements",statements:e.statements});break;case"IF_ELSE":e.then&&t.push({key:"then",statements:e.then}),e.else&&t.push({key:"else",statements:e.else});break;case"WHILE_LOOP":e.body&&t.push({key:"body",statements:e.body});break}return t},M=(e,t,i=void 0,r="root")=>{for(let o=0;o<e.length;o++){let n=e[o],l=n.uid;if(l===t)return{stableId:l,path:[o],statement:n,parent:i,containerKey:r,index:o};let a=k(n);for(let c of a){let u=M(c.statements,t,n,c.key);if(u)return{...u,path:[o,c.key,...u.path]}}}return null},x=(e,t,i)=>{let r=M(e,t);if(!r)return null;let{statement:o,parent:n,containerKey:l,index:a}=r,c=null;switch(o.type){case"DRAFT":case"ACTION":c=L(e,r)||I(e,r);break;case"STEP":if(o.statements&&o.statements.length>0)return o.statements[0];c=L(e,r)||I(e,r);break;case"IF_ELSE":if(i===!0&&o.then&&o.then.length>0)return o.then[0];if(i===!1&&o.else&&o.else.length>0)return o.else[0];c=L(e,r)||I(e,r);break;case"WHILE_LOOP":if(i===!0&&o.body&&o.body.length>0)return o.body[0];c=L(e,r)||I(e,r);break;default:c=L(e,r)||I(e,r);break}if(n&&n.type==="WHILE_LOOP"&&l==="body"){if(!c)return n;let u=M(e,c.uid);if(!u||u.parent!==n)return n}return c},L=(e,t)=>{if(!t.parent)return e[t.index+1]||null;let r=k(t.parent).find(o=>o.key===t.containerKey);return r&&t.index+1<r.statements.length?r.statements[t.index+1]:null},I=(e,t)=>{if(!t.parent)return null;let i=t.parent.uid,r=M(e,i);return r?L(e,r)||I(e,r):null},z=e=>{let t=[],i=r=>{for(let o of r){t.push(o);let n=k(o);for(let l of n)i(l.statements)}};return i(e),t},xt=e=>{switch(e.type){case"DRAFT":case"ACTION":return!0;case"STEP":return!0;case"IF_ELSE":case"WHILE_LOOP":return!0;default:return!1}},Lt=(e,t,i)=>{if(!M(e,t))return null;if(i===null){let a=[],c=t;for(;c!==null&&M(e,c);)if(a.push(c),c=x(e,c)?.uid||null,a.length>1e3)return null;return a}if(!M(e,i))return null;if(t===i)return[];let n=[],l=t;for(;l&&l!==i;){let a=M(e,l);if(!a)break;if(n.push(l),a.statement.type==="IF_ELSE"){let c=It(a.statement,i);c?l=x(e,l,c==="then")?.uid||null:l=x(e,l)?.uid||null}else a.statement.type==="WHILE_LOOP"?Dt(a.statement,i)?l=x(e,l,!0)?.uid||null:l=x(e,l,!1)?.uid||null:l=x(e,l)?.uid||null;if(n.length>1e3)return null}return l===i?n:null},It=(e,t)=>{if(e.type!=="IF_ELSE")return null;let i=e;return i.then&&M(i.then,t)?"then":i.else&&M(i.else,t)?"else":null},Dt=(e,t)=>{if(e.type!=="WHILE_LOOP")return!1;let i=e;return!!(i.body&&M(i.body,t))};function Oe(e){for(let t of e){if(t.type==="STEP"&&t.reference_id)return!0;let i=k(t);for(let r of i)if(Oe(r.statements))return!0}return!1}function Wt(e){let t=new Set;function i(r){for(let o of r){o.type==="STEP"&&o.reference_id&&t.add(o.reference_id);let n=k(o);for(let l of n)i(l.statements)}}return i(e),Array.from(t)}var Ct=e=>e.startsWith("ai_")?!0:["js_code","function","assert","verify","wait_for_download_complete","extract_activation_code","extract_email_content"].includes(e),Gt=e=>!["js_code","function","assert","ai_assert","verify","ai_extract","ai_wait_until","upload_file","login","extract_activation_code","extract_email_content","ai_step"].includes(e),D=(e,t,i)=>{e.forEach((r,o)=>{let n=`${t}.${o}`;r.type==="DRAFT"?i[n]={description:r.description||"Draft",action_entity:void 0}:r.type==="ACTION"?i[n]={description:r.description||"Action",action_entity:r.action_entity}:r.type==="STEP"&&r.statements?D(r.statements,n,i):r.type==="IF_ELSE"?(i[n]={description:"IF "+(r.condition?.expression||""),action_entity:void 0},r.then&&D(r.then,`${n}.then`,i),r.else&&D(r.else,`${n}.else`,i)):r.type==="WHILE_LOOP"&&(i[n]={description:"WHILE "+(r.condition?.expression||""),action_entity:void 0},r.body&&D(r.body,`${n}.body`,i))})};function Kt(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return D(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&D(e.teardown,"teardown",t),t}function E(e,t,i){let r=e+".",o=t.filter(([h])=>h===e||h.startsWith(r));if(o.length===0)return[];let n=[],l=new Set;for(let[h]of o){let p=h===e?"":h.slice(r.length);if(!p)continue;let d=p.split(".")[0];l.has(d)||l.add(d)}let a=Array.from(l);a.sort((h,p)=>{let d=/^\d+$/.test(h)?parseInt(h,10):-1,m=/^\d+$/.test(p)?parseInt(p,10):-1;return d>=0&&m>=0?d-m:h==="then"&&p==="else"?-1:h==="else"&&p==="then"||h==="body"?1:p==="body"?-1:h.localeCompare(p)});function c(h){return i[h]}function u(h){let p=h.match(/^(IF|WHILE)\s+([\s\S]+)$/);return{type:"JS_CODE",expression:(p?p[2].trim():h)||"true"}}for(let h of a){let p=e?`${e}.${h}`:h,d=c(p),m=d?.description??"",w=p;if(h==="then"){let f=`${e}.then`,_=`${e}.else`,y=E(f,t,i),O=E(_,t,i),B=c(e),He=B?u(B.description):{type:"JS_CODE",expression:"true"};n.push({uid:e,type:"IF_ELSE",condition:He,then:y,...O.length>0?{else:O}:{}});continue}if(h==="else")continue;if(h==="body"){let f=`${e}.body`,_=E(f,t,i),y=c(e),O=y?u(y.description):{type:"JS_CODE",expression:"true"};n.push({uid:e,type:"WHILE_LOOP",condition:O,body:_});continue}let g=`${e}.${h}`,W=t.some(([f])=>f.startsWith(g+".then.")||f===g+".then"),V=t.some(([f])=>f.startsWith(g+".else.")||f===g+".else"),Be=t.some(([f])=>f.startsWith(g+".body.")||f===g+".body"),Ne=t.filter(([f])=>{if(!f.startsWith(g+"."))return!1;let y=f.slice(g.length+1).split(".")[0];return/^\d+$/.test(y)&&y!=="then"&&y!=="else"&&y!=="body"});if(W||V){let f=g+".then",_=g+".else",y=E(f,t,i),O=E(_,t,i),B=d?u(m):{type:"JS_CODE",expression:"true"};n.push({uid:p,type:"IF_ELSE",condition:B,then:y,...O.length>0?{else:O}:{}})}else if(Be){let f=g+".body",_=E(f,t,i),y=d?u(m):{type:"JS_CODE",expression:"true"};n.push({uid:p,type:"WHILE_LOOP",condition:y,body:_})}else if(Ne.length>0){let f=E(g,t,i);n.push({uid:p,type:"STEP",description:m||"Group",statements:f})}else n.push({uid:p,type:"ACTION",description:m||"Action",action_entity:d?.action_entity})}return n}function Ft(e){let t=Object.entries(e),i=r=>{let o=r+".";return t.some(([l])=>l===r||l.startsWith(o))?E(r,t,e):[]};return{before:i("before"),main:i("main"),teardown:i("teardown"),after:i("after")}}var Bt=.5;function Nt(e){try{return new Function(`return async function() { ${e} }`),null}catch(t){return t.message}}function xe(e){try{return new Function(`return async function() { return (${e}) }`),null}catch(t){return t.message}}function Ht(e,t){let i=t?.coverageThreshold??Bt,r=[],o=[],n;try{n=K(e)}catch(d){return{valid:!1,errors:[`Invalid YAML: ${d.message}`],warnings:[],stats:{total:0,withLocator:0,coverage:0}}}n.goal||r.push('Missing required field: "goal"'),n.statements?.length||r.push('Missing required field: "statements"');let l=[...z(n.statements??[]),...n.teardown?z(n.teardown):[]],a=0,c=0;for(let d of l)if(!(d.type!=="DRAFT"&&d.type!=="ACTION"||(d.description?.toLowerCase()??"").startsWith("verify:"))){if(d.type==="ACTION"){let g=d.action_entity?.action_data?.action_name??"";if(g==="verify"||g==="ai_assert"||g==="done")continue}if(a++,d.type==="ACTION"){let w=d;if((w.action_entity?.action_data?.action_name??"")==="js_action"){let W=w.action_entity?.action_data?.kwargs?.code??"";/page\.(getBy|locator\(|frameLocator\()/.test(W)&&c++}else(w.action_entity?.locator||w.action_entity?.xpath)&&c++}}let u="Hint: in YAML double-quoted strings, backslashes are escape characters \u2014 use \\\\/ instead of \\/ for regex, or use single quotes.";for(let d of l){if(d.type==="ACTION"){let m=d,w=m.action_entity?.action_data?.action_name??"";if(w==="js_code"||w==="js_action"||w==="verify"||w==="ai_assert"){let g=m.action_entity?.action_data?.kwargs?.code;if(typeof g=="string"){let W=Nt(g);if(W){let V=m.description||w;r.push(`Invalid JS in "${V}": ${W}. ${u}`)}}}}if(d.type==="IF_ELSE"){let m=d;if(m.condition.type==="JS_CODE"){let w=xe(m.condition.expression);w&&r.push(`Invalid JS in IF condition "${m.condition.expression}": ${w}. ${u}`)}}if(d.type==="WHILE_LOOP"){let m=d;if(m.condition.type==="JS_CODE"){let w=xe(m.condition.expression);w&&r.push(`Invalid JS in WHILE condition "${m.condition.expression}": ${w}. ${u}`)}}}let h=a>0?c/a:0,p=Math.round(h*100);return a>0&&h<i&&o.push(`Low locator coverage: ${c}/${a} statements (${p}%) have locators. Tests with locators replay ~10x faster. Use MCP tools (act, get_locators) to enrich your test flow.`),{valid:r.length===0,errors:r,warnings:o,stats:{total:a,withLocator:c,coverage:p}}}function Rt(){return{version:"1.0",entries:{}}}function Ut(e,t){return{action_entity:e,updated_at:new Date().toISOString(),updated_by:{source:"runner",test_run_id:t}}}function $t(e,t){let i=t?.entries[e.uid],r=i?.action_entity??e.action_entity;return e.locator&&r?{...r,locator:e.locator}:i?i.action_entity:e.action_entity?e.action_entity:null}function zt(e,t,i,r){return e.entries[t]={action_entity:i,updated_at:new Date().toISOString(),updated_by:r},e}function Vt(e,t){let i=e??{version:"1.0",entries:{}};for(let[r,o]of t)i.entries[r]=o;return i}function Xt(e){return e?Object.keys(e.entries).length===0:!0}function Yt(e){return e?Object.keys(e.entries).length:0}function jt(e,t){if(!t||Object.keys(t.entries).length===0)return e;let i=Q(e.statements??[],t),r=e.teardown?Q(e.teardown,t):void 0;return{...e,statements:i,teardown:r}}function Q(e,t){return e.map(i=>Jt(i,t))}function Jt(e,t){if(e.type==="ACTION"){let o=e,n=t.entries[o.uid];return n?{...o,action_entity:n.action_entity}:o}let i=k(e);if(i.length===0)return e;let r={};for(let o of i)r[o.key]=Q(o.statements,t);return{...e,...r}}var Le=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(Le||{}),Ie=(e=>(e.JS_CODE="JS_CODE",e.AI_MODE="AI_MODE",e))(Ie||{}),qt=18e4;var Zt=class De{data={};sensitive=new Set;get(t){return this.data[t]}set(t,i,r=!1){this.data[t]=i,r?this.sensitive.add(t):this.sensitive.has(t)&&this.sensitive.delete(t)}getAll(){return{...this.data}}isSensitive(t){return this.sensitive.has(t)}getAllSensitiveKeys(){return new Set(this.sensitive)}delete(t){return this.sensitive.delete(t),delete this.data[t]}clear(){this.data={},this.sensitive.clear()}has(t){return t in this.data}get size(){return Object.keys(this.data).length}merge(t){for(let[i,r]of Object.entries(t.getAll()))this.set(i,r,t.isSensitive(i))}toJSON(){return{data:{...this.data},sensitiveKeys:Array.from(this.sensitive)}}static fromJSON(t){let i=new De;if(t.data){let r=new Set(t.sensitiveKeys||[]);for(let[o,n]of Object.entries(t.data))i.set(o,n,r.has(o))}return i}};var We="claude-sonnet-4-6",Ce="gemini-2.5-pro",Ge="claude-haiku-4-5",Ke="gemini-2.5-pro";function Qt(e){return{copilot:e?.models?.copilot||We,webagent:e?.models?.webagent||Ce}}function ei(e){if(e){if(e.WEB_AGENT_MODEL)return e.WEB_AGENT_MODEL;if(e.ANTHROPIC_API_KEY)return Ge;if(e.GOOGLE_API_KEY)return Ke}}var Fe=(e=>(e.INITIALIZING="initializing",e.READY="ready",e.PROCESSING="processing",e.STOPPING="stopping",e.WAITING_USER="waiting_user",e.COMPLETED="completed",e.FAILED="failed",e))(Fe||{});function ti(e){let t=e.trim();if(!t||t.startsWith("List of devices"))return null;let i=t.split(/\s+/);if(i.length<2)return null;let r=i[0],o=i[1],n="usb";return r.startsWith("emulator-")?n="emulator":r.includes(":")&&(n="wifi"),{id:r,state:o,connectionType:n}}function ii(e){return e.startsWith(P)?e:`${P}${e}`}function ri(e){return e.model?`${e.model} (${e.id})`:e.connectionType==="emulator"?`Android Emulator (${e.id})`:e.id}export{Ue as a,$e as b,ze as c,P as d,A as e,Ve as f,Xe as g,Ye as h,je as i,Je as j,qe as k,Ze as l,X as m,Qe as n,ee as o,et as p,tt as q,it as r,rt as s,te as t,Y as u,ie as v,re as w,oe as x,ne as y,ae as z,se as A,le as B,ce as C,C as D,he as E,N as F,ue as G,de as H,F as I,ot as J,H as K,nt as L,at as M,j as N,st as O,lt as P,ct as Q,ht as R,pe as S,fe as T,me as U,J as V,ge as W,G as X,we as Y,ye as Z,Se as _,S as $,be as aa,R as ba,q as ca,Pe as da,dt as ea,Ae as fa,pt as ga,St as ha,bt as ia,K as ja,Ee as ka,ke as la,Ot as ma,k as na,M as oa,x as pa,L as qa,I as ra,z as sa,xt as ta,Lt as ua,Oe as va,Wt as wa,Ct as xa,Gt as ya,D as za,Kt as Aa,Ft as Ba,Ht as Ca,Rt as Da,Ut as Ea,$t as Fa,zt as Ga,Vt as Ha,Xt as Ia,Yt as Ja,jt as Ka,Le as La,Ie as Ma,qt as Na,Zt as Oa,We as Pa,Ce as Qa,Ge as Ra,Ke as Sa,Qt as Ta,ei as Ua,Fe as Va,ti as Wa,ii as Xa,ri as Ya};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "module";
|
|
2
|
+
const require = __createRequire(import.meta.url);
|
|
3
|
+
import{Ca as C,Na as Y,ea as F,ja as b}from"./chunk-47OHTDHW.js";import{stringify as X}from"yaml";import{parse as ge,stringify as I}from"yaml";import{readFileSync as de}from"fs";import{resolve as z,dirname as me}from"path";import{parse as H,stringify as he}from"yaml";import{readFileSync as Fe,writeFileSync as Ae,mkdirSync as xe}from"fs";import{dirname as be}from"path";var O=1e4;function k(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function d(e){return e.replace(/\r\n/g," ").replace(/\n/g," ").replace(/\r/g," ").trim()}function Q(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function Z(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 J(e){let t=Q(e),a=e.locator;if(typeof a=="string"&&a.trim())return a=a.trim(),a.endsWith("first()")?`${t}.${a}`:`${t}.${a}.first()`;let r=Z(e);if(r){let n=JSON.stringify(r);return`${t}.locator(${n}).first()`}return null}var ee=["ai_action","ai_step","ai_assert","ai_extract","ai_wait_until","verify","assert"],te=["js_code","function","wait","wait_for_download_complete","wait_for_page_ready","extract_email_content","extract_activation_code"];function U(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:ee.includes(t)}function ae(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:!te.includes(t)}var m=new Map;function l(e,t){m.set(e,t)}function ne(e){return m.get(e)}function x(e,t,a=[]){let r=[...a];return t.locator?r.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&r.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&r.push(`frame_path: ${JSON.stringify(t.frame_path)}`),r.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...r.map(n=>` ${n},`),"});"]}l("click",e=>{let t=J(e);return t?[`await ${t}.click({ timeout: ${O} });`]:['await agent.execAction("click", page, {});']});l("click_element",m.get("click"));l("click_element_by_index",m.get("click"));l("double_click",e=>x("double_click",e));l("double_click_on_element",m.get("double_click"));l("right_click",e=>x("right_click",e));l("right_click_on_element",m.get("right_click"));l("hover",e=>x("hover",e));l("hover_element_by_index",m.get("hover"));l("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return x("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});l("fill",m.get("input_text"));l("clear_input",e=>x("clear_input",e));l("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});l("send_keys",m.get("press"));l("send_keys_on_element",e=>{let t=J(e),a=e.action_data?.kwargs?.keys||"";return t?[`await ${t}.press(${JSON.stringify(a)}, { timeout: ${O} });`]:['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(a)} } },`,"});"]});l("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return x("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});l("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)})');`]});l("scroll_down",m.get("scroll"));l("scroll_up",m.get("scroll"));l("scroll_element",m.get("scroll"));l("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});l("scroll_on_element",e=>x("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));l("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)} } },`,"});"]});l("open_tab",m.get("go_to_url"));l("go_back",()=>['await agent.execAction("go_back", page, {});']);l("reload_page",()=>['await agent.execAction("reload_page", page, {});']);l("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);l("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);l("verify",(e,t)=>{let a=e.action_data?.kwargs,r=typeof a?.code=="string",n=r?a?.statement||e.action_description:e.action_description||a?.statement;if(r&&n){let i=a.code.split(`
|
|
4
|
+
`),u=JSON.stringify(n);return["{ const _t = Date.now(); try {",...i.map(p=>` ${p}`),` console.log(\`[VERIFY:JS] \u2713 \${((Date.now()-_t)/1000).toFixed(1)}s: ${u}\`);`,"} 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: ${u}\`);`,` await agent.assert(page, ${u}, ${JSON.stringify(t||"")});`,"} }"]}return r?a.code.split(`
|
|
5
|
+
`):n?[`await agent.assert(page, ${JSON.stringify(n)}, ${JSON.stringify(t||"")});`]:["// Skipping verify: missing statement or code"]});l("ai_assert",m.get("verify"));l("assert",m.get("verify"));l("ai_action",(e,t)=>{let a=e.action_data?.kwargs?.statement;if(!a)return["// Skipping ai_action: missing statement"];let r=JSON.stringify(a),n=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${r}, '${t||""}', ${n});`]});l("ai_step",(e,t)=>{let a=e.action_data?.kwargs?.statement;return a?[`await agent.run(page, ${JSON.stringify(a)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]});l("ai_extract",(e,t)=>{let a=e.action_data?.kwargs?.element_description,r=e.action_data?.kwargs?.variable_name;if(!a||!r)return["// Skipping ai_extract: missing element_description or variable_name"];let n=JSON.stringify(a),s=JSON.stringify(r);return[`await agent.extract(page, ${n}, ${s}, '${t||""}');`]});l("ai_wait_until",(e,t)=>{let a=e.action_data?.kwargs?.condition,r=e.action_data?.kwargs?.timeout_seconds||60;return a?[`await agent.waitUntilCondition(page, ${JSON.stringify(a)}, ${r}, '${t||""}');`]:["// Skipping ai_wait_until: missing condition"]});l("save_variable",e=>{let t=e.action_data?.kwargs?.name||"",a=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(a)} } },`,"});"]});l("js_code",e=>{let t=e.action_data?.kwargs?.code;if(!t)return["// Skipping js_code: missing code"];let a=["{"],r=t.split(`
|
|
6
|
+
`);for(let n of r)a.push(` ${n}`);return a.push("}"),a});l("function",(e,t,a)=>{let r=e.action_data?.kwargs||{},n=r.functionName;if(n&&n.includes("#")){let[i,u]=n.split("#");if(i&&u){let p=i.replace(/\.(ts|js|mjs)$/,""),o=`import { ${u} } from '${p}';`;a?.imports?.add(o);let c={...r,functionName:u},f=W(c);return f?[f.endsWith(";")?f:`${f};`]:["// Skipping function: invalid export pattern"]}}let s=W(r);return s?[s.endsWith(";")?s:`${s};`]:["// Skipping function: missing functionName"]});l("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)} } },`,"});"]});l("upload_file",e=>{let t=e.action_data?.kwargs||{},a=[],r={};return t.paths?r.paths=t.paths:t.path&&(r.path=t.path),t.use_file_input&&(r.use_file_input=!0),a.push(`action_data: { kwargs: ${JSON.stringify(r)} }`),e.locator?a.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&a.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&a.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...a.map(n=>` ${n},`),"});"]});l("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} } },`,"});"]);l("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} } },`,"});"]);l("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} } },`,"});"]});l("set_date_for_native_date_picker",e=>{let t=e.action_data?.kwargs?.date??"",a=[];return a.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?a.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&a.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&a.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...a.map(r=>` ${r},`),"});"]});l("done",()=>["// Done - no action needed"]);l("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
|
|
7
|
+
`):["// Skipping js_action: missing code"]});function W(e){let t=e.functionName;if(!t)return null;let a=Array.isArray(e.args)?e.args.map(String):[];if(a.length===0)return`await ${t}()`;let r=["page","testContext","request","agent"],n=["undefined","null","true","false"],s=a.map(i=>r.includes(i)||n.includes(i)||/^-?\d+(\.\d+)?$/.test(i)?i:i.startsWith("$")?`agent.agentServices.readVariable('${i.substring(1)}')`:`"${i}"`);return`await ${t}(${s.join(", ")})`}function w(e,t,a,r="main"){let n=[];for(let s=0;s<e.length;s++){let i=e[s],u=`${r}.${s}`,p=re(i,t,u,a);p.length>0&&(n.push(...p),s<e.length-1&&n.push(""))}return n}function re(e,t,a,r){let n=" ".repeat(t);switch(e.type){case"DRAFT":return se(e,t,a,r);case"ACTION":return ie(e,t,a,r);case"STEP":return oe(e,t,a,r);case"IF_ELSE":return ce(e,t,a,r);case"WHILE_LOOP":return le(e,t,a,r);default:return[`${n}// Unknown statement type: ${e.type}`]}}function se(e,t,a,r){let n=" ".repeat(t),s=e.description?.trim()||"";if(!s)return[`${n}// ${a}: Skipping - no description`];if(r.noAgent)return[`${n}// ${a}: ${d(s)}`,`${n}// DRAFT: ${d(s)} (requires agent - skipped in hook)`];let i=JSON.stringify(s);return[`${n}// ${a}: ${d(s)}`,`${n}// \u26A0 DRAFT: AI-resolved at runtime (~5-10s). Add a locator to make this <1s.`,`${n}page = agent.agentServices.validatePage(page);`,`${n}await agent.run(page, ${i}, '${a}');`]}function ie(e,t,a,r){let n=" ".repeat(t),s=e.description,i=e.uid,p=r.actionEntityStore?.entries[e.uid]?.action_entity??e.action_entity;if(!p){if(!s)return[`${n}// ${a}: Skipping - no description`];if(r.noAgent)return[`${n}// ${a}: ${d(s)}`,`${n}// DRAFT: ${d(s)} (requires agent - skipped in hook)`];let _=JSON.stringify(s),v=!!e.use_pure_vision;return[`${n}// ${a}: ${d(s)}`,`${n}// \u26A0 DRAFT: AI-resolved at runtime (~5-10s). Add a locator to make this <1s.`,`${n}page = agent.agentServices.validatePage(page);`,`${n}await agent.execute(page, ${_}, '${a}', ${v});`]}let o=e.locator?{...p,locator:e.locator}:p;s&&s!==o.action_description&&(o={...o,action_description:s});let c=o.action_data?.action_name||"",f=o.action_description||"",h=ne(c);if(!h)return[`${n}// ${a}: Unknown action: ${c}`];let $={imports:r.imports},g=h(o,a,$);if(r.noAgent){if(U(o))return[`${n}// ${a}: ${d(f)}`,`${n}// AI action: ${d(f)} (requires agent - skipped in hook)`];let _=ue(o,c,n,a);return _||[`${n}// ${a}: ${d(f)}`,...g.map(v=>`${n}${v}`)]}if(U(o))return[`${n}// ${a}: ${d(f)}`,`${n}page = agent.agentServices.validatePage(page);`,...g.map(_=>`${n}${_}`)];let S=JSON.stringify(f),A=g.map(_=>`${n} ${_}`),N=ae(o),j=i?`'${i}'`:"undefined";return[`${n}// ${a}: ${d(f)}`,`${n}page = agent.agentServices.validatePage(page);`,`${n}await agent.step(page, async () => {`,...A,`${n}}, ${S}, '${a}', ${j}, ${N});`]}function oe(e,t,a,r){let n=" ".repeat(t),s=[];e.description&&e.description.trim()&&s.push(`${n}// Step: ${d(e.description)}`);let i=w(e.statements,t,r,a);return s.push(...i),s}function ce(e,t,a,r){let n=" ".repeat(t),s=[];if(s.push(`${n}// ${a}: Conditional check`),e.condition.type==="JS_CODE")s.push(`${n}if (${e.condition.expression}) {`);else{s.push(`${n}// AI Condition: ${d(e.condition.expression)}`);let u=JSON.stringify(e.condition.expression);s.push(`${n}if (await agent.evaluate(page, ${u}, "${a}")) {`)}let i=w(e.then,t+1,r,`${a}.then`);if(s.push(...i),e.else&&e.else.length>0){s.push(`${n}} else {`);let u=w(e.else,t+1,r,`${a}.else`);s.push(...u)}return s.push(`${n}}`),s}function le(e,t,a,r){let n=" ".repeat(t),s=[];s.push(`${n}// ${a}: Loop`);let i=e.timeout_ms??Y,u=i/1e3,p=e.timeout_ms?`While loop exceeded timeout of ${u}s`:`While loop exceeded default timeout of ${u}s`,o=`loop_${a.replace(/\./g,"_")}`;if(s.push(`${n}const ${o}_start = Date.now();`),s.push(`${n}const ${o}_timeout = ${i};`),s.push(`${n}const ${o}_check = () => {`),s.push(`${n} if (Date.now() - ${o}_start > ${o}_timeout) {`),s.push(`${n} throw new Error('${p}');`),s.push(`${n} }`),s.push(`${n} return true;`),s.push(`${n}};`),e.condition.type==="JS_CODE")s.push(`${n}while (${o}_check() && (${e.condition.expression})) {`);else{s.push(`${n}// AI Loop Condition: ${d(e.condition.expression)}`);let f=JSON.stringify(e.condition.expression);s.push(`${n}while (${o}_check() && await agent.evaluate(page, ${f}, "${a}")) {`)}let c=w(e.body,t+1,r,`${a}.body`);return s.push(...c),s.push(`${n}}`),s}function ue(e,t,a,r){let n=e.action_description||"",s=e.action_data?.kwargs||{};switch(t){case"go_to_url":case"open_tab":{let i=s.url||"";return[`${a}// ${r}: ${d(n)}`,`${a}await page.goto(${JSON.stringify(i)}, { waitUntil: 'domcontentloaded' });`]}case"go_back":return[`${a}// ${r}: ${d(n)}`,`${a}await page.goBack();`];case"go_forward":return[`${a}// ${r}: ${d(n)}`,`${a}await page.goForward();`];case"input_text":{let i=s.text||"",u=J(e);return u?[`${a}// ${r}: ${d(n)}`,`${a}await ${u}.fill(${JSON.stringify(i)}, { timeout: ${O} });`]:null}case"select_dropdown_option":{let i=s.text||s.label||"",u=J(e);return u?[`${a}// ${r}: ${d(n)}`,`${a}await ${u}.selectOption({ label: ${JSON.stringify(i)} }, { timeout: ${O} });`]:null}default:return null}}function pe(e,t){let a=[],r=t?.version||"unknown";a.push(`// @generated by shiplightai v${r}`),a.push(...D()),a.push(""),t?.use&&Object.keys(t.use).length>0&&(a.push(`test.use(${JSON.stringify(t.use,null,2)});`),a.push(""));let n=new Set,s={imports:n};t?.beforeEach&&t.beforeEach.length>0&&(a.push(...M("beforeEach",t.beforeEach,s)),a.push(""));let i=t?.timeout||t?.skip!==void 0||t?.fail!==void 0||t?.only||t?.slow?{timeout:t.timeout,skip:t.skip,fail:t.fail,only:t.only,slow:t.slow}:void 0;if(t?.parameters&&t.parameters.length>0){let u=t?.testName||e.goal||"Generated test",p=P(t?.tags);for(let o of t.parameters){let c=V(e,o.values);a.push(...E(c,`${p}${k(u)} [${k(o.name)}]`,s,0,i)),a.push("")}}else{let u=t?.testName||e.goal||"Generated test",p=P(t?.tags);a.push(...E(e,`${p}${k(u)}`,s,0,i))}return t?.afterEach&&t.afterEach.length>0&&(a.push(""),a.push(...M("afterEach",t.afterEach,s))),R(a,n),a.join(`
|
|
8
|
+
`)}function fe(e,t){let a=[],r=t?.version||"unknown";a.push(`// @generated by shiplightai v${r}`),a.push(...D()),a.push(""),t?.use&&Object.keys(t.use).length>0&&(a.push(`test.use(${JSON.stringify(t.use,null,2)});`),a.push(""));let n=new Set,s={imports:n},i=t?.testName||"Test Suite",u=P(t?.tags);a.push(`test.describe.serial('${u}${k(i)}', () => {`),e.beforeAll&&e.beforeAll.length>0&&(a.push(...T("beforeAll",e.beforeAll,s,1)),a.push("")),e.beforeEach&&e.beforeEach.length>0&&(a.push(...T("beforeEach",e.beforeEach,s,1)),a.push(""));for(let o=0;o<e.tests.length;o++){let c=e.tests[o],f=c.timeout||c.skip!==void 0||c.fail!==void 0||c.only||c.slow?{timeout:c.timeout,skip:c.skip,fail:c.fail,only:c.only,slow:c.slow}:void 0;if(c.parameters&&c.parameters.length>0)for(let h of c.parameters){let $=V(c.testFlow,h.values);a.push(...E($,`${k(c.name)} [${k(h.name)}]`,s,1,f)),a.push("")}else a.push(...E(c.testFlow,k(c.name),s,1,f)),(o<e.tests.length-1||e.afterEach||e.afterAll)&&a.push("")}return e.afterEach&&e.afterEach.length>0&&(a.push(...T("afterEach",e.afterEach,s,1)),a.push("")),e.afterAll&&e.afterAll.length>0&&a.push(...T("afterAll",e.afterAll,s,1)),a.push("});"),R(a,n),a.join(`
|
|
9
|
+
`)}function P(e){return e&&e.length>0?e.map(t=>`@${t}`).join(" ")+" ":""}function E(e,t,a,r=0,n){let s=" ".repeat(r),i=[],u=n?.only?"test.only":"test";i.push(`${s}${u}('${t}', async ({ page, agent }) => {`),n?.skip===!0?i.push(`${s} test.skip();`):typeof n?.skip=="string"&&i.push(`${s} test.skip(true, '${k(n.skip)}');`),n?.fail===!0?i.push(`${s} test.fail();`):typeof n?.fail=="string"&&i.push(`${s} test.fail(true, '${k(n.fail)}');`),n?.slow&&i.push(`${s} test.slow();`),n?.timeout&&i.push(`${s} test.setTimeout(${n.timeout});`);let p=e.teardown&&e.teardown.length>0,o=r+1;if(p){if(i.push(`${s} try {`),e.statements&&e.statements.length>0){i.push(`${s} // Test steps`);let f=w(e.statements,o+1,a);i.push(...f)}i.push(`${s} } finally {`),i.push(`${s} // Teardown`);let c=w(e.teardown,o+1,a,"teardown");i.push(...c),i.push(`${s} }`)}else if(e.statements&&e.statements.length>0){i.push(`${s} // Test steps`);let c=w(e.statements,o,a);i.push(...c)}return i.push(`${s}});`),i}function M(e,t,a){let r=[],n=B(t);return r.push(`test.${e}(async ({ page, agent }) => {`),r.push(...w(n,1,a,e)),r.push("});"),r}function T(e,t,a,r){let n=" ".repeat(r),s=[],i=B(t);if(e==="beforeAll"||e==="afterAll"){let p={...a,noAgent:!0};s.push(`${n}test.${e}(async ({ browser }, workerInfo) => {`),s.push(`${n} const page = await browser.newPage({ baseURL: workerInfo.project.use.baseURL });`),s.push(...w(i,r+1,p,e)),s.push(`${n} await page.close();`),s.push(`${n}});`)}else s.push(`${n}test.${e}(async ({ page, agent }) => {`),s.push(...w(i,r+1,a,e)),s.push(`${n}});`);return s}function B(e){let a=X({goal:"_hook",statements:e});return b(a).statements??[]}function V(e,t){let a=F(e);for(let[r,n]of Object.entries(t))a=a.split(`<<${r}>>`).join(String(n));return b(a)}function D(){return["import { test, expect } from 'shiplightai/fixture';"]}function R(e,t){if(t.size>0){let a=0;for(let n=0;n<e.length;n++)e[n].startsWith("import ")&&(a=n+1);let r=Array.from(t);e.splice(a,0,...r)}}var q=5;function K(e,t){let a={expandingPaths:new Set([z(t)]),depth:0,referencedPaths:new Set},r={...e};Array.isArray(r.statements)&&(r.statements=y(r.statements,t,a)),Array.isArray(r.teardown)&&(r.teardown=y(r.teardown,t,a));for(let n of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(r[n])&&(r[n]=y(r[n],t,a));return{doc:r,referencedTemplatePaths:Array.from(a.referencedPaths)}}function y(e,t,a){let r=[];for(let n of e)if($e(n)){let s=_e(n,t,a);r.push(...s)}else r.push(we(n,t,a));return r}function $e(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function _e(e,t,a){if(a.depth>=q)throw new Error(`Template expansion exceeded maximum depth of ${q}. Check for deeply nested or circular template references.`);let r=z(me(t),e.template);if(a.expandingPaths.has(r))throw new Error(`Circular template reference detected: ${r} is already being expanded. Stack: ${Array.from(a.expandingPaths).join(" \u2192 ")} \u2192 ${r}`);a.referencedPaths.add(r);let n;try{n=de(r,"utf-8")}catch(c){throw new Error(`Failed to read template file: ${r} (referenced from ${t}): ${c.message}`)}let s=H(n);if(!s||typeof s!="object")throw new Error(`Invalid template file: ${r} \u2014 expected a YAML object`);let i=s.params||[],u=e.params||{};for(let c of i)if(!(c in u))throw new Error(`Template ${e.template} requires param "${c}" but it was not provided. Required params: [${i.join(", ")}]`);let p=s.statements;if(!Array.isArray(p))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(u).length>0){let f=he(p);for(let[h,$]of Object.entries(u))f=f.split(`<<${h}>>`).join(String($));p=H(f)}let o={expandingPaths:new Set([...a.expandingPaths,r]),depth:a.depth+1,referencedPaths:a.referencedPaths};return y(p,r,o)}function we(e,t,a){if(typeof e!="object"||e===null)return e;let r={...e};return Array.isArray(r.statements)&&(r.statements=y(r.statements,t,a)),Array.isArray(r.THEN)&&(r.THEN=y(r.THEN,t,a)),Array.isArray(r.ELSE)&&(r.ELSE=y(r.ELSE,t,a)),Array.isArray(r.DO)&&(r.DO=y(r.DO,t,a)),r}function ke(e,t){let a=ge(e),r=a?.name,n=a?.tags,s=a?.use;if(a&&(a.name!==void 0||a.tags!==void 0||a.use!==void 0)&&(delete a.name,delete a.tags,delete a.use),a?.suite){if(a.goal||a.statements)throw new Error('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return Se(a,r,n,s,t)}return ye(a,r,n,s,t)}function ye(e,t,a,r,n){let s=e?.beforeEach,i=e?.afterEach,u=G(e?.parameters),p=e?.timeout,o=e?.skip,c=e?.fail,f=e?.only,h=e?.slow;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&&!e.goal&&t&&(e.goal=t);let $=[];if(n&&e&&typeof e=="object"){let A=K(e,n);e=A.doc,$=A.referencedTemplatePaths}let g=I(e);return{testFlow:b(g),name:t,tags:a,use:r,beforeEach:s,afterEach:i,parameters:u,timeout:p,skip:o,fail:c,only:f,slow:h,referencedTemplatePaths:$}}function Se(e,t,a,r,n){let s=e.suite;if(!Array.isArray(s.tests)||s.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let i=s.beforeAll,u=s.afterAll,p=s.beforeEach,o=s.afterEach,c=[],f=s.tests.map(g=>{if(!g.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(g.statements)||g.statements.length===0)throw new Error(`Suite test "${g.name}" must have a non-empty "statements" array.`);let S={goal:g.name,statements:g.statements};g.teardown&&(S.teardown=g.teardown);let A=[],N=S;if(n&&typeof S=="object"){let L=K(S,n);N=L.doc,A=L.referencedTemplatePaths,c.push(...A)}let j=I(N),_=b(j),v=G(g.parameters);return{testFlow:_,name:g.name,parameters:v,timeout:g.timeout,skip:g.skip,fail:g.fail,only:g.only,slow:g.slow}}),h=s.base_url,$=h?{...r,baseURL:h}:r;return{suite:{beforeAll:i,afterAll:u,beforeEach:p,afterEach:o,tests:f},name:t,tags:a,use:$,referencedTemplatePaths:c}}function G(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,a)=>{if(!t.name)throw new Error(`Parameter set at index ${a} 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 Ue(e,t,a){let r=/\btemplate:\s/.test(e),n=/^suite:/m.test(e),s=r||n?null:C(e);if(s&&!s.valid)return{valid:!1,errors:s.errors,warnings:[],stats:s.stats};let i,u,p=[];try{let o=ke(e,t);p=o.referencedTemplatePaths;let c={version:a?.version},f=o.testFlow?.baseURL?{...o.use,baseURL:o.testFlow.baseURL}:o.use;o.suite?i=fe(o.suite,{...c,testName:o.name,tags:o.tags,use:o.use}):i=pe(o.testFlow,{...c,testName:o.name,tags:o.tags,use:f,beforeEach:o.beforeEach,afterEach:o.afterEach,parameters:o.parameters,timeout:o.timeout,skip:o.skip,fail:o.fail,only:o.only,slow:o.slow});let h=i.split(`
|
|
10
|
+
`).filter($=>!$.startsWith("import ")).join(`
|
|
11
|
+
`);new Function(h),u=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),xe(be(u),{recursive:!0}),Ae(u,i)}catch(o){let c=o.message.includes("Unexpected token")?" This usually means a YAML escaping issue \u2014 in double-quoted strings, use \\\\/ instead of \\/ for regex patterns, or use single quotes / block scalars.":" This may indicate a transpiler bug \u2014 please report it.";return{valid:!1,errors:[`Transpilation failed: ${o.message}.${c}`],warnings:[],stats:s?.stats??{total:0,withLocator:0,coverage:0},referencedTemplatePaths:p}}return{valid:!0,errors:[],warnings:s?.warnings??[],stats:s?.stats??{total:0,withLocator:0,coverage:0},specFile:u,referencedTemplatePaths:p}}export{ke as a,Ue as b};
|