shiplightai 0.1.91 → 0.1.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/debugger-pw.cjs +2 -2
- package/dist/cjs/fixture.cjs +5 -5
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/reporter.cjs +1 -1
- package/dist/cli.js +33 -33
- package/dist/debugger-pw.js +2 -2
- package/dist/fixture.js +5 -5
- package/dist/index.js +2 -2
- package/dist/reporter.js +1 -1
- package/package.json +3 -3
package/dist/cjs/index.cjs
CHANGED
|
@@ -4096,7 +4096,7 @@ Based on the above information, please determine if the statement is true.
|
|
|
4096
4096
|
return (async () => {
|
|
4097
4097
|
${n}
|
|
4098
4098
|
})();
|
|
4099
|
-
`)(e,o)}transpile(e){let t=this.generateFunctionCallCode(e.action_data?.kwargs||{});return t?[t.endsWith(";")?t:`${t};`]:["// Skipping function: missing functionName"]}generateFunctionCallCode(e){let t=e.functionName;if(!t)return null;let i;if(Array.isArray(e.args))i=e.args.map(String);else if(Array.isArray(e.parameterNames)){let r=e.parameterValues||[];i=e.parameterNames.map((s,l)=>l<r.length?String(r[l]):"undefined")}else return`await ${t}()`;if(i.length===0)return`await ${t}()`;let a=["page","testContext","request","agent"],n=["undefined","null","true","false"],o=i.map(r=>a.includes(r)||n.includes(r)||/^-?\d+(\.\d+)?$/.test(r)?r:r.startsWith("$")?`agent.agentServices.readVariable('${r.substring(1)}')`:`"${r}"`);return`await ${t}(${o.join(", ")})`}}});var $n=v(()=>{"use strict";wt()});var Rs,yt=v(()=>{"use strict";Rs=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.SILENT=4]="SILENT",e))(Rs||{})});var xt={};it(xt,{evaluateStatement:()=>kt,executeAction:()=>ei,executeStep:()=>_t,generateActionStep:()=>ti,runTask:()=>St});var vt=v(()=>{"use strict";ii();bn();fn();mt();ln();dn();cn();lt();hn();je();mn();zt();Kt();Ce();jt();$n();qe();Jt();wt();Yt();qt();Qt();se();gt();Se();Wt();dt();Ut();Ge();ct();Q();Je();U();ne();yt();B();xe()});var io,Fs,zy,Mn=v(()=>{"use strict";io=require("zod"),Fs=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.statement;if(!n)throw new Error("Missing statement for ai_step");let{runTask:o}=await Promise.resolve().then(()=>(vt(),xt)),r=await o(n,e,i);if(r.status!=="success")throw new Error(r.error||"Task execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;return i?[`await agent.run(page, ${JSON.stringify(i)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]}},zy=io.z.object({statement:io.z.string().describe('The complete step to execute (e.g., "fill in the login form and submit")')})});var Hs,In=v(()=>{"use strict";B();P();Hs=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");if(typeof a.kwargs.relative_x=="number"&&typeof a.kwargs.relative_y=="number"){let n=N(e,t);if(n){await n.waitFor({state:"attached",timeout:L(i,t.action_data?.kwargs?.timeout_ms)});let o=await n.boundingBox();if(o){let r=o.x+a.kwargs.relative_x+o.width/2,s=o.y+a.kwargs.relative_y+o.height/2;await e.mouse.move(r,s),await e.waitForTimeout(200),await e.mouse.click(r,s),await e.waitForTimeout(500)}}else throw new Error("Element-anchored coordinates provided but no locator found")}else if(typeof a.kwargs.x=="number"&&typeof a.kwargs.y=="number")await e.mouse.move(a.kwargs.x,a.kwargs.y),await e.waitForTimeout(200),await e.mouse.click(a.kwargs.x,a.kwargs.y),await e.waitForTimeout(500);else throw new Error("Missing or invalid coordinates")}transpile(e){let t=e.action_data?.kwargs||{},i=[];return typeof t.relative_x=="number"&&typeof t.relative_y=="number"?(i.push(`action_data: { kwargs: { relative_x: ${t.relative_x}, relative_y: ${t.relative_y} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`)):typeof t.x=="number"&&typeof t.y=="number"&&i.push(`action_data: { kwargs: { x: ${t.x}, y: ${t.y} } }`),['await agent.execAction("click_by_coordinates", page, {',...i.map(a=>` ${a},`),"});"]}}});var no,Ws,Zy,Pn=v(()=>{"use strict";no=require("zod"),Ws=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.statement;if(!n)throw new Error("Missing statement for ai_action");let o=a.kwargs.use_pure_vision,{executeStep:r}=await Promise.resolve().then(()=>(vt(),xt)),s=await r(n,e,i,{usePureVision:o});if(s.status!=="success")throw new Error(s.error||"Action execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;if(!i)return["// Skipping ai_action: missing statement"];let a=JSON.stringify(i),n=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${a}, '${t||""}', ${n});`]}},Zy=no.z.object({statement:no.z.string().describe('The action to perform (e.g., "click the submit button")')})});function Bs(e,t){e.register({name:"switch_tab",description:"Switch to a different browser tab by index (0-based).",schema:qu,async execute(i,a){let n=i.tab_index,{page:o,agentServices:r,actionDescription:s}=a;try{let l={action_description:s||`Switch to tab ${n}`,action_data:{action_name:"switch_tab",kwargs:{page_id:n}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Switched to tab ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Switch to tab ${n}`)+" (failed)",action_data:{action_name:"switch_tab",kwargs:{page_id:n}},feedback:l.message}}}}})}var ao,Us,qu,ni=v(()=>{"use strict";ao=require("zod"),Us=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.page_id??a.kwargs.tab_index??0;if(typeof n=="number"){let o=e.context().pages(),r=n===-1?o.length-1:n;if(i){let s=await i.switchTab(r);await s.waitForLoadState("load",{timeout:15e3}).catch(()=>{}),await s.waitForTimeout(500)}}else throw new Error("Missing page_id for switch_tab action")}transpile(e){return['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]}},qu=ao.z.object({tab_index:ao.z.number().int().nonnegative().describe("Index of the tab to switch to (0-based). Use 0 for first tab, 1 for second, etc.")})});async function Ks(e,t,i,a,n,o){let r=Array.isArray(t)?t:[t];if(r.length===0)throw new Error("No file paths provided for upload");let s=r.map(d=>{if(d.startsWith("/")||d.match(/^[A-Za-z]:\\/))return d;let h=a.testDataDir||process.cwd();return js.default.join(h,d)});u.info(`Uploading files: ${s.join(", ")}`);let l=i.timeout||2e4,c={useFileInput:i.useFileInput||!1,timeout:l};if(i.selector&&typeof i.selector!="string"){let d=i.selector;await Cn(e,d,s,c);return}if(i.selector&&typeof i.selector=="string"){let d=i.selector,h=(d.startsWith("xpath="),e.locator(d));await Cn(e,h,s,c);return}if(n){let d=r.map(p=>`"${p}"`).join(", "),h="";i.targetDescription?h=`Upload ${d} to ${i.targetDescription}`:h=`Upload ${d}`,u.info(`Using AI to handle file upload: ${h}`),await n(e,h,o)}else throw new Error("No selector provided and AI action execution is not available")}async function Cn(e,t,i,a){let{useFileInput:n,timeout:o,mockShowOpenFilePicker:r}=a;if(r){u.info("Using mockShowOpenFilePicker approach");let s=i.map(l=>({path:l,buffer:new Uint8Array(Gs.default.readFileSync(l))}));await e.evaluate(l=>{window.__pw_showOpenFilePicker_mock_files=l},s),await t.click({timeout:o}),await e.waitForTimeout(3e3),await e.evaluate(()=>{delete window.__pw_showOpenFilePicker_mock_files})}else if(n)u.info("Using direct file input approach"),await t.setInputFiles(i,{timeout:o}),await e.waitForTimeout(3e3);else{u.info("Using file chooser approach");let s=e.waitForEvent("filechooser",{timeout:o});s.catch(()=>{}),await t.click({timeout:o}),await(await s).setFiles(i),await e.waitForTimeout(3e3)}u.info(`Successfully uploaded ${i.length} file(s)`)}var Gs,js,ai=v(()=>{"use strict";U();Gs=J(require("fs"),1),js=J(require("path"),1)});async function Zu(e,t,i={},a){return{...await H(t,e),action_description:a||"Upload file to element",action_data:{action_name:"upload_file",kwargs:{...i}}}}function zs(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"upload_file",kwargs:t},feedback:"Element not found in DOM"}}function Xs(e,t){e.register({name:"upload_file",description:'Click on target element (usually contains hints like "Upload file" or "Choose file" etc.) to trigger the file upload dialog, and choose the files to upload',schema:Qu,usesElementIndex:!0,async execute(i,a){let{element_index:n,paths:o}=i,{page:r,agentServices:s,actionDescription:l}=a;try{let c=await z(a,n);if(!c)return{success:!1,error:`File input element with index ${n} not found`,actionEntity:zs(l||`Upload file to element ${n}`,{index:n,paths:o})};let d=await Zu(c,r,{paths:o},l);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Uploaded file to element ${n}`}}catch(c){return{success:!1,error:c.message,actionEntity:zs(l||`Upload file to element ${n}`,{index:n,paths:o})}}}})}var ae,Vs,Qu,lx,oi=v(()=>{"use strict";ai();Q();B();ae=require("zod");P();Vs=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=[];if(a.kwargs.paths?n=Array.isArray(a.kwargs.paths)?a.kwargs.paths:[a.kwargs.paths]:a.kwargs.path&&(n=Array.isArray(a.kwargs.path)?a.kwargs.path:[a.kwargs.path]),n.length===0)throw new Error("No file paths provided for upload_file action");await i.downloadTestDataFiles(n);let o=n.map(c=>i.getTestDataFilePath(c)),r=N(e,t);if(!r)throw new Error("Missing locator for upload_file action");let s=a.kwargs.use_file_input||!1,l=i.getActionSettings().mock_show_open_file_picker??!1;await Cn(e,r,o,{useFileInput:s,timeout:L(i,t.action_data?.kwargs?.timeout_ms),mockShowOpenFilePicker:l})}transpile(e){let t=e.action_data?.kwargs||{},i=[],a={};return t.paths?a.paths=t.paths:t.path&&(a.path=t.path),t.use_file_input&&(a.use_file_input=!0),i.push(`action_data: { kwargs: ${JSON.stringify(a)} }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...i.map(n=>` ${n},`),"});"]}};Qu=ae.z.object({element_index:ae.z.number().int().describe("Index of the target element to trigger the file upload dialog"),paths:ae.z.union([ae.z.string(),ae.z.array(ae.z.string())]).describe('Path to a file, relative to the test project root (e.g. "fixtures/data.csv"), or an array of such paths.'),timeout_ms:ae.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")});lx=ae.z.object({element_index:ae.z.number().int().describe("Index of the file input element"),paths:ae.z.union([ae.z.string(),ae.z.array(ae.z.string())]).describe('Path to a file, relative to the test project root (e.g. "fixtures/data.csv"), or an array of such paths.'),timeout_ms:ae.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Ys(e,t){e.register({name:"wait",description:"Wait for a specified number of seconds before continuing.",schema:eh,async execute(i,a){let{seconds:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l={action_description:s||`Wait ${n} seconds`,action_data:{action_name:"wait",kwargs:{seconds:n}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Waited ${n} seconds`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Wait ${n} seconds`)+" (failed)",action_data:{action_name:"wait",kwargs:{seconds:n}},feedback:l.message}}}}})}var oo,Js,eh,ri=v(()=>{"use strict";oo=require("zod"),Js=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let a=i.kwargs.seconds||1;await e.waitForTimeout(a*1e3)}transpile(e){return[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]}},eh=oo.z.object({seconds:oo.z.number().positive().describe("Number of seconds to wait")})});function Zs(e,t){e.register({name:"wait_for_download_complete",description:"Wait for an in-progress download to complete.",schema:th,async execute(i,a){let{timeout_seconds:n=10}=i,{page:o,agentServices:r}=a;try{let s={action_description:`Wait for download to complete (timeout: ${n}s)`,action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:n}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:"Download completed"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Wait for download to complete (failed)",action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:n}},feedback:s.message}}}}})}var ro,qs,th,si=v(()=>{"use strict";ro=require("zod"),qs=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.timeout_seconds||10;await i.waitForDownloadComplete(e,n)}transpile(e){return['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]}},th=ro.z.object({timeout_seconds:ro.z.number().positive().optional().describe("Maximum time in seconds to wait for download to complete (default: 10)")})});function so(e,t){if(!e||typeof e!="string")return e;let i=t instanceof Map?Object.fromEntries(t):t,a=o=>{let r=o.startsWith("$")?o.slice(1):o,s=i[r]??i[`$${r}`];return s!=null?String(s):void 0},n=e;return n=n.replace(/\{\{\s*\$?([^}]+?)\s*\}\}/g,(o,r)=>{let s=a(r.trim());return s!==void 0?s:o}),n=n.replace(/<secret>\$?([\w-]+)<\/secret>/g,(o,r)=>{let s=a(r);return s!==void 0?s:o}),n=n.replace(/\$\{([^}]+)\}/g,(o,r)=>{let s=a(r.trim());return s!==void 0?s:o}),n=n.replace(/\$([a-zA-Z_]\w*)/g,(o,r)=>{let s=a(r);return s!==void 0?s:o}),n}var S,xx,$x,Px,Ox,Ln,el,fx,tl,ih,nh,On,wx,bx,Et,Nn,lo,ah,Qs,oh,li,rh,sh,lh,pe,ch,dh,yx,Ix,Dx,Le=v(()=>{"use strict";xe();S=require("zod"),xx=require("yaml"),$x=require("uuid"),Px=require("uuid"),Ox=require("yaml");Ln=(e=>(e.JS_CODE="JS_CODE",e.AI_MODE="AI_MODE",e))(Ln||{}),el=112,fx=1080-el,tl=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(tl||{}),ih={"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"}},nh={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"]},On=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),nh[e].map(a=>ih[a]).filter(a=>a.defaultBrowserType&&i.includes(a.defaultBrowserType))},wx={desktop:{label:"Desktop",type:"desktop",devices:On("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:On("mobile")}},bx={desktop:{label:"Desktop",type:"desktop",devices:On("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:On("mobile",!0)}},Et=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(Et||{}),Nn=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(Nn||{}),lo=class il{constructor(){Da(this,"data",{}),Da(this,"sensitive",new Set)}get(t){return this.data[t]}set(t,i,a=!1){this.data[t]=i,a?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,a]of Object.entries(t.getAll()))this.set(i,a,t.isSensitive(i))}toJSON(){return{data:{...this.data},sensitiveKeys:Array.from(this.sensitive)}}static fromJSON(t){let i=new il;if(t.data){let a=new Set(t.sensitiveKeys||[]);for(let[n,o]of Object.entries(t.data))i.set(n,o,a.has(n))}return i}},ah=S.z.enum(["JS_CODE","AI_MODE"]),Qs=S.z.object({type:ah,expression:S.z.string()}),oh=S.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),li=S.z.object({uid:S.z.string(),type:oh,comment:S.z.string().optional()}),rh=S.z.object({action_data:S.z.object({action_name:S.z.string(),kwargs:S.z.record(S.z.any()).optional(),args:S.z.array(S.z.any()).optional()}),action_description:S.z.string().optional(),url:S.z.string().optional(),xpath:S.z.string().nullable().optional(),locator:S.z.string().nullable().optional(),css_selector:S.z.string().nullable().optional(),unique_selector:S.z.string().nullable().optional(),element_index:S.z.number().nullable().optional(),frame_path:S.z.array(S.z.any()).optional(),artifacts:S.z.record(S.z.any()).optional(),feedback:S.z.string().optional(),original_browser_use_action:S.z.any().optional()}).passthrough(),sh=li.extend({type:S.z.literal("DRAFT"),description:S.z.string()}),lh=li.extend({type:S.z.literal("ACTION"),description:S.z.string(),action_entity:rh.optional(),locator:S.z.string().optional(),use_pure_vision:S.z.boolean().optional()}),pe=S.z.lazy(()=>S.z.union([sh,lh,li.extend({type:S.z.literal("STEP"),description:S.z.string().optional().default(""),statements:S.z.array(pe),reference_id:S.z.number().optional(),template_path:S.z.string().optional(),template_params:S.z.record(S.z.string()).optional()}),li.extend({type:S.z.literal("IF_ELSE"),description:S.z.string().optional(),condition:Qs,then:S.z.array(pe),else:S.z.array(pe).optional()}),li.extend({type:S.z.literal("WHILE_LOOP"),description:S.z.string().optional(),condition:Qs,body:S.z.array(pe),timeout_ms:S.z.number().optional()})])),ch=S.z.object({name:S.z.string(),statements:S.z.array(pe),teardown:S.z.array(pe).optional(),skip:S.z.union([S.z.boolean(),S.z.string()]).optional(),timeout:S.z.number().optional(),fail:S.z.union([S.z.boolean(),S.z.string()]).optional(),only:S.z.boolean().optional(),slow:S.z.boolean().optional()}),dh=S.z.object({tests:S.z.array(ch).min(1),beforeAll:S.z.array(pe).optional(),afterAll:S.z.array(pe).optional(),beforeEach:S.z.array(pe).optional(),afterEach:S.z.array(pe).optional()}),yx=S.z.object({comment:S.z.string().optional(),version:S.z.string().optional(),goal:S.z.string().optional(),url:S.z.string().optional(),baseURL:S.z.string().optional(),final_feedback:S.z.string().optional(),completed:S.z.boolean().optional(),success:S.z.boolean().optional(),statements:S.z.array(pe).optional(),teardown:S.z.array(pe).optional(),last_modified_at:S.z.string().optional(),testGroup:dh.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"}),Ix=1024*1024,Dx=Object.freeze(["anthropic:claude-sonnet-5","google:gemini-3.1-pro-preview"])});var Ze=v(()=>{"use strict"});async function gh(e,t){let i=new Set,a=Date.now(),n=new Set(["document","stylesheet","image","font","script","iframe"]),o=new Set(["text/html","text/css","application/javascript","image/","font/","application/json"]),r=["analytics","tracking","telemetry","beacon","metrics","doubleclick","adsystem","adserver","advertising","facebook.com/plugins","platform.twitter","linkedin.com/embed","livechat","zendesk","intercom","crisp.chat","hotjar","push-notifications","onesignal","pushwoosh","heartbeat","ping","alive","webrtc","rtmp://","wss://","cloudfront.net","fastly.net"],s=h=>{let p=h.toLowerCase();return p.startsWith("data:")||p.startsWith("blob:")?!0:r.some(g=>p.includes(g))},l=h=>{let p=h.resourceType(),g=h.url();if(!n.has(p)||s(g))return;let w=h.headers();w.purpose==="prefetch"||["video","audio"].includes(w["sec-fetch-dest"])||(i.add(h),a=Date.now())},c=async h=>{let p=h.request();if(!i.has(p))return;let g=(h.headers()["content-type"]||"").toLowerCase();if(["streaming","video","audio","webm","mp4","event-stream","websocket","protobuf"].some(y=>g.includes(y))){i.delete(p);return}if(![...o].some(y=>g.startsWith(y))){i.delete(p);return}let w=h.headers()["content-length"];if(w)try{if(parseInt(w,10)>5*1024*1024){i.delete(p);return}}catch{}i.delete(p),a=Date.now()},d=Date.now()-mh;for(let h of await e.requests()){let p=h.resourceType(),g=h.url(),w=h.timing();n.has(p)&&!s(g)&&w.responseEnd===-1&&w.startTime>=d&&(i.add(h),a=Date.now())}u.debug(`[waitForStableNetwork] Pre-populated ${i.size} in-flight requests`),e.on("request",l),e.on("response",c);try{let h=Date.now(),p=ph;for(;;){await new Promise(w=>setTimeout(w,100));let g=Date.now();if(i.size===0&&g-a>=p){u.debug(`[waitForStableNetwork] Network idle after ${g-h}ms`);break}if(g-h>t){u.debug(`[waitForStableNetwork] Max wait time exceeded (${t}ms), pending: ${i.size}`);break}}}finally{e.removeListener("request",l),e.removeListener("response",c)}}async function Ne(e,t=hh,i=uh){let a=Date.now();try{await Promise.all([e.waitForLoadState("load",{timeout:t}).catch(()=>{}),gh(e,t)])}catch(r){throw r instanceof Error?new Error(`Failed during network stabilization: ${r.message}`):new Error("An unknown error occurred during network stabilization.")}let n=Date.now()-a,o=Math.max(i-n,0);o>0&&await new Promise(r=>setTimeout(r,o))}var uh,hh,ph,mh,Te=v(()=>{"use strict";Ze();U();uh=.5*1e3,hh=30*1e3,ph=1*1e3,mh=3*1e3});async function al(e,t=3e3,i=1e3){try{await Ne(e,t,i)}catch{}}async function ol(e,t,i){let a=i*1e3,n=100,o=Date.now();for(;!t.downloadStatus||t.downloadStatus.status==="inProgress";){if(Date.now()-o>a){let r;throw t.downloadStatus?r=`Timed out after ${a}ms waiting for download to complete`:r="No download in progress or completed",u.error(r),new Error(r)}await e.waitForTimeout(n)}if(t.downloadStatus.status==="failed"){let r=`Download failed: ${t.downloadStatus.error||"Unknown error"}`;throw u.error(r),new Error(r)}t.agentNote=`Download completed: ${t.downloadStatus.filename}`}async function rl(e,t,i,a=60,n){let o=Math.min(a,300),r=Math.max(10,o/10)*1e3,s=Date.now()+o*1e3;for(u.info(`Waiting for condition: "${t}" (timeout: ${o}s)`);;){let l=Date.now();try{if(await i(e,t,n))return u.info(`Condition met: "${t}"`),!0}catch(d){u.warn(`Error evaluating condition: ${d.message}`)}if(Date.now()>s)return u.warn(`Timeout waiting for condition: "${t}"`),!1;let c=r-(Date.now()-l);c>0&&await e.waitForTimeout(c)}}async function Dn(e,t,i=60){let a=Math.min(i,300),n=250,o=Date.now()+a*1e3;u.info(`Waiting for JS condition (timeout: ${a}s)`);let r;for(;;){try{if(await t())return u.info("JS wait condition met"),!0}catch(s){let l=s.message;l!==r&&(u.warn(`Error evaluating JS wait condition: ${l}`),r=l)}if(Date.now()>o)return u.warn("Timeout waiting for JS condition"),!1;await e.waitForTimeout(n)}}var Tt=v(()=>{"use strict";Te();U()});function ll(e,t){e.register({name:"ai_wait_until",description:'Wait until a specific condition is met on the page (e.g., "page loads", "spinner disappears", "button becomes enabled"). Use this instead of wait when the goal is to wait for something to happen rather than waiting a fixed duration.',schema:fh,async execute(i,a){let{condition:n,timeout_seconds:o=60}=i,{page:r,agentServices:s}=a;try{let l={action_description:`Wait until: ${n}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:n,timeout_seconds:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Condition met: ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Wait until: ${n} (failed)`,action_data:{action_name:"ai_wait_until",kwargs:{condition:n,timeout_seconds:o}},feedback:l.message}}}}})}var Rn,sl,fh,ci=v(()=>{"use strict";bt();Le();Tt();Rn=require("zod"),sl=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.condition;if(!n)throw new Error("Missing condition for ai_wait_until");let o=a.kwargs.timeout_seconds||60;if(a.kwargs.condition_type===Ln.JS_CODE){let d=new Function("page","expect","agent",`
|
|
4099
|
+
`)(e,o)}transpile(e){let t=this.generateFunctionCallCode(e.action_data?.kwargs||{});return t?[t.endsWith(";")?t:`${t};`]:["// Skipping function: missing functionName"]}generateFunctionCallCode(e){let t=e.functionName;if(!t)return null;let i;if(Array.isArray(e.args))i=e.args.map(String);else if(Array.isArray(e.parameterNames)){let r=e.parameterValues||[];i=e.parameterNames.map((s,l)=>l<r.length?String(r[l]):"undefined")}else return`await ${t}()`;if(i.length===0)return`await ${t}()`;let a=["page","testContext","request","agent"],n=["undefined","null","true","false"],o=i.map(r=>a.includes(r)||n.includes(r)||/^-?\d+(\.\d+)?$/.test(r)?r:r.startsWith("$")?`agent.agentServices.readVariable('${r.substring(1)}')`:`"${r}"`);return`await ${t}(${o.join(", ")})`}}});var $n=v(()=>{"use strict";wt()});var Rs,yt=v(()=>{"use strict";Rs=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.SILENT=4]="SILENT",e))(Rs||{})});var xt={};it(xt,{evaluateStatement:()=>kt,executeAction:()=>ei,executeStep:()=>_t,generateActionStep:()=>ti,runTask:()=>St});var vt=v(()=>{"use strict";ii();bn();fn();mt();ln();dn();cn();lt();hn();je();mn();zt();Kt();Ce();jt();$n();qe();Jt();wt();Yt();qt();Qt();se();gt();Se();Wt();dt();Ut();Ge();ct();Q();Je();U();ne();yt();B();xe()});var io,Fs,zy,Mn=v(()=>{"use strict";io=require("zod"),Fs=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.statement;if(!n)throw new Error("Missing statement for ai_step");let{runTask:o}=await Promise.resolve().then(()=>(vt(),xt)),r=await o(n,e,i);if(r.status!=="success")throw new Error(r.error||"Task execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;return i?[`await agent.run(page, ${JSON.stringify(i)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]}},zy=io.z.object({statement:io.z.string().describe('The complete step to execute (e.g., "fill in the login form and submit")')})});var Hs,In=v(()=>{"use strict";B();P();Hs=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");if(typeof a.kwargs.relative_x=="number"&&typeof a.kwargs.relative_y=="number"){let n=N(e,t);if(n){await n.waitFor({state:"attached",timeout:L(i,t.action_data?.kwargs?.timeout_ms)});let o=await n.boundingBox();if(o){let r=o.x+a.kwargs.relative_x+o.width/2,s=o.y+a.kwargs.relative_y+o.height/2;await e.mouse.move(r,s),await e.waitForTimeout(200),await e.mouse.click(r,s),await e.waitForTimeout(500)}}else throw new Error("Element-anchored coordinates provided but no locator found")}else if(typeof a.kwargs.x=="number"&&typeof a.kwargs.y=="number")await e.mouse.move(a.kwargs.x,a.kwargs.y),await e.waitForTimeout(200),await e.mouse.click(a.kwargs.x,a.kwargs.y),await e.waitForTimeout(500);else throw new Error("Missing or invalid coordinates")}transpile(e){let t=e.action_data?.kwargs||{},i=[];return typeof t.relative_x=="number"&&typeof t.relative_y=="number"?(i.push(`action_data: { kwargs: { relative_x: ${t.relative_x}, relative_y: ${t.relative_y} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`)):typeof t.x=="number"&&typeof t.y=="number"&&i.push(`action_data: { kwargs: { x: ${t.x}, y: ${t.y} } }`),['await agent.execAction("click_by_coordinates", page, {',...i.map(a=>` ${a},`),"});"]}}});var no,Ws,Zy,Pn=v(()=>{"use strict";no=require("zod"),Ws=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.statement;if(!n)throw new Error("Missing statement for ai_action");let o=a.kwargs.use_pure_vision,{executeStep:r}=await Promise.resolve().then(()=>(vt(),xt)),s=await r(n,e,i,{usePureVision:o});if(s.status!=="success")throw new Error(s.error||"Action execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;if(!i)return["// Skipping ai_action: missing statement"];let a=JSON.stringify(i),n=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${a}, '${t||""}', ${n});`]}},Zy=no.z.object({statement:no.z.string().describe('The action to perform (e.g., "click the submit button")')})});function Bs(e,t){e.register({name:"switch_tab",description:"Switch to a different browser tab by index (0-based).",schema:qu,async execute(i,a){let n=i.tab_index,{page:o,agentServices:r,actionDescription:s}=a;try{let l={action_description:s||`Switch to tab ${n}`,action_data:{action_name:"switch_tab",kwargs:{page_id:n}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Switched to tab ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Switch to tab ${n}`)+" (failed)",action_data:{action_name:"switch_tab",kwargs:{page_id:n}},feedback:l.message}}}}})}var ao,Us,qu,ni=v(()=>{"use strict";ao=require("zod"),Us=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.page_id??a.kwargs.tab_index??0;if(typeof n=="number"){let o=e.context().pages(),r=n===-1?o.length-1:n;if(i){let s=await i.switchTab(r);await s.waitForLoadState("load",{timeout:15e3}).catch(()=>{}),await s.waitForTimeout(500)}}else throw new Error("Missing page_id for switch_tab action")}transpile(e){return['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]}},qu=ao.z.object({tab_index:ao.z.number().int().nonnegative().describe("Index of the tab to switch to (0-based). Use 0 for first tab, 1 for second, etc.")})});async function Ks(e,t,i,a,n,o){let r=Array.isArray(t)?t:[t];if(r.length===0)throw new Error("No file paths provided for upload");let s=r.map(d=>{if(d.startsWith("/")||d.match(/^[A-Za-z]:\\/))return d;let h=a.testDataDir||process.cwd();return js.default.join(h,d)});u.info(`Uploading files: ${s.join(", ")}`);let l=i.timeout||2e4,c={useFileInput:i.useFileInput||!1,timeout:l};if(i.selector&&typeof i.selector!="string"){let d=i.selector;await Cn(e,d,s,c);return}if(i.selector&&typeof i.selector=="string"){let d=i.selector,h=(d.startsWith("xpath="),e.locator(d));await Cn(e,h,s,c);return}if(n){let d=r.map(p=>`"${p}"`).join(", "),h="";i.targetDescription?h=`Upload ${d} to ${i.targetDescription}`:h=`Upload ${d}`,u.info(`Using AI to handle file upload: ${h}`),await n(e,h,o)}else throw new Error("No selector provided and AI action execution is not available")}async function Cn(e,t,i,a){let{useFileInput:n,timeout:o,mockShowOpenFilePicker:r}=a;if(r){u.info("Using mockShowOpenFilePicker approach");let s=i.map(l=>({path:l,buffer:new Uint8Array(Gs.default.readFileSync(l))}));await e.evaluate(l=>{window.__pw_showOpenFilePicker_mock_files=l},s),await t.click({timeout:o}),await e.waitForTimeout(3e3),await e.evaluate(()=>{delete window.__pw_showOpenFilePicker_mock_files})}else if(n)u.info("Using direct file input approach"),await t.setInputFiles(i,{timeout:o}),await e.waitForTimeout(3e3);else{u.info("Using file chooser approach");let s=e.waitForEvent("filechooser",{timeout:o});s.catch(()=>{}),await t.click({timeout:o}),await(await s).setFiles(i),await e.waitForTimeout(3e3)}u.info(`Successfully uploaded ${i.length} file(s)`)}var Gs,js,ai=v(()=>{"use strict";U();Gs=J(require("fs"),1),js=J(require("path"),1)});async function Zu(e,t,i={},a){return{...await H(t,e),action_description:a||"Upload file to element",action_data:{action_name:"upload_file",kwargs:{...i}}}}function zs(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"upload_file",kwargs:t},feedback:"Element not found in DOM"}}function Xs(e,t){e.register({name:"upload_file",description:'Click on target element (usually contains hints like "Upload file" or "Choose file" etc.) to trigger the file upload dialog, and choose the files to upload',schema:Qu,usesElementIndex:!0,async execute(i,a){let{element_index:n,paths:o}=i,{page:r,agentServices:s,actionDescription:l}=a;try{let c=await z(a,n);if(!c)return{success:!1,error:`File input element with index ${n} not found`,actionEntity:zs(l||`Upload file to element ${n}`,{index:n,paths:o})};let d=await Zu(c,r,{paths:o},l);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Uploaded file to element ${n}`}}catch(c){return{success:!1,error:c.message,actionEntity:zs(l||`Upload file to element ${n}`,{index:n,paths:o})}}}})}var ae,Vs,Qu,lx,oi=v(()=>{"use strict";ai();Q();B();ae=require("zod");P();Vs=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=[];if(a.kwargs.paths?n=Array.isArray(a.kwargs.paths)?a.kwargs.paths:[a.kwargs.paths]:a.kwargs.path&&(n=Array.isArray(a.kwargs.path)?a.kwargs.path:[a.kwargs.path]),n.length===0)throw new Error("No file paths provided for upload_file action");await i.downloadTestDataFiles(n);let o=n.map(c=>i.getTestDataFilePath(c)),r=N(e,t);if(!r)throw new Error("Missing locator for upload_file action");let s=a.kwargs.use_file_input||!1,l=i.getActionSettings().mock_show_open_file_picker??!1;await Cn(e,r,o,{useFileInput:s,timeout:L(i,t.action_data?.kwargs?.timeout_ms),mockShowOpenFilePicker:l})}transpile(e){let t=e.action_data?.kwargs||{},i=[],a={};return t.paths?a.paths=t.paths:t.path&&(a.path=t.path),t.use_file_input&&(a.use_file_input=!0),i.push(`action_data: { kwargs: ${JSON.stringify(a)} }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...i.map(n=>` ${n},`),"});"]}};Qu=ae.z.object({element_index:ae.z.number().int().describe("Index of the target element to trigger the file upload dialog"),paths:ae.z.union([ae.z.string(),ae.z.array(ae.z.string())]).describe('Path to a file, relative to the test project root (e.g. "fixtures/data.csv"), or an array of such paths.'),timeout_ms:ae.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")});lx=ae.z.object({element_index:ae.z.number().int().describe("Index of the file input element"),paths:ae.z.union([ae.z.string(),ae.z.array(ae.z.string())]).describe('Path to a file, relative to the test project root (e.g. "fixtures/data.csv"), or an array of such paths.'),timeout_ms:ae.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Ys(e,t){e.register({name:"wait",description:"Wait for a specified number of seconds before continuing.",schema:eh,async execute(i,a){let{seconds:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l={action_description:s||`Wait ${n} seconds`,action_data:{action_name:"wait",kwargs:{seconds:n}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Waited ${n} seconds`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Wait ${n} seconds`)+" (failed)",action_data:{action_name:"wait",kwargs:{seconds:n}},feedback:l.message}}}}})}var oo,Js,eh,ri=v(()=>{"use strict";oo=require("zod"),Js=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let a=i.kwargs.seconds||1;await e.waitForTimeout(a*1e3)}transpile(e){return[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]}},eh=oo.z.object({seconds:oo.z.number().positive().describe("Number of seconds to wait")})});function Zs(e,t){e.register({name:"wait_for_download_complete",description:"Wait for an in-progress download to complete.",schema:th,async execute(i,a){let{timeout_seconds:n=10}=i,{page:o,agentServices:r}=a;try{let s={action_description:`Wait for download to complete (timeout: ${n}s)`,action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:n}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:"Download completed"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Wait for download to complete (failed)",action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:n}},feedback:s.message}}}}})}var ro,qs,th,si=v(()=>{"use strict";ro=require("zod"),qs=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.timeout_seconds||10;await i.waitForDownloadComplete(e,n)}transpile(e){return['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]}},th=ro.z.object({timeout_seconds:ro.z.number().positive().optional().describe("Maximum time in seconds to wait for download to complete (default: 10)")})});function so(e,t){if(!e||typeof e!="string")return e;let i=t instanceof Map?Object.fromEntries(t):t,a=o=>{let r=o.startsWith("$")?o.slice(1):o,s=i[r]??i[`$${r}`];return s!=null?String(s):void 0},n=e;return n=n.replace(/\{\{\s*\$?([^}]+?)\s*\}\}/g,(o,r)=>{let s=a(r.trim());return s!==void 0?s:o}),n=n.replace(/<secret>\$?([\w-]+)<\/secret>/g,(o,r)=>{let s=a(r);return s!==void 0?s:o}),n=n.replace(/\$\{([^}]+)\}/g,(o,r)=>{let s=a(r.trim());return s!==void 0?s:o}),n=n.replace(/\$([a-zA-Z_]\w*)/g,(o,r)=>{let s=a(r);return s!==void 0?s:o}),n}var S,xx,$x,Px,Ox,Ln,Et,Nn,el,fx,tl,ih,nh,On,wx,bx,lo,ah,Qs,oh,li,rh,sh,lh,pe,ch,dh,yx,Ix,Dx,Le=v(()=>{"use strict";xe();S=require("zod"),xx=require("yaml"),$x=require("uuid"),Px=require("uuid"),Ox=require("yaml");Ln=(e=>(e.JS_CODE="JS_CODE",e.AI_MODE="AI_MODE",e))(Ln||{}),Et=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(Et||{}),Nn=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(Nn||{}),el=112,fx=1080-el,tl=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(tl||{}),ih={"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"}},nh={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"]},On=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),nh[e].map(a=>ih[a]).filter(a=>a.defaultBrowserType&&i.includes(a.defaultBrowserType))},wx={desktop:{label:"Desktop",type:"desktop",devices:On("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:On("mobile")}},bx={desktop:{label:"Desktop",type:"desktop",devices:On("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:On("mobile",!0)}},lo=class il{constructor(){Da(this,"data",{}),Da(this,"sensitive",new Set)}get(t){return this.data[t]}set(t,i,a=!1){this.data[t]=i,a?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,a]of Object.entries(t.getAll()))this.set(i,a,t.isSensitive(i))}toJSON(){return{data:{...this.data},sensitiveKeys:Array.from(this.sensitive)}}static fromJSON(t){let i=new il;if(t.data){let a=new Set(t.sensitiveKeys||[]);for(let[n,o]of Object.entries(t.data))i.set(n,o,a.has(n))}return i}},ah=S.z.enum(["JS_CODE","AI_MODE"]),Qs=S.z.object({type:ah,expression:S.z.string()}),oh=S.z.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),li=S.z.object({uid:S.z.string(),type:oh,comment:S.z.string().optional()}),rh=S.z.object({action_data:S.z.object({action_name:S.z.string(),kwargs:S.z.record(S.z.any()).optional(),args:S.z.array(S.z.any()).optional()}),action_description:S.z.string().optional(),url:S.z.string().optional(),xpath:S.z.string().nullable().optional(),locator:S.z.string().nullable().optional(),css_selector:S.z.string().nullable().optional(),unique_selector:S.z.string().nullable().optional(),element_index:S.z.number().nullable().optional(),frame_path:S.z.array(S.z.any()).optional(),artifacts:S.z.record(S.z.any()).optional(),feedback:S.z.string().optional(),original_browser_use_action:S.z.any().optional()}).passthrough(),sh=li.extend({type:S.z.literal("DRAFT"),description:S.z.string()}),lh=li.extend({type:S.z.literal("ACTION"),description:S.z.string(),action_entity:rh.optional(),locator:S.z.string().optional(),use_pure_vision:S.z.boolean().optional()}),pe=S.z.lazy(()=>S.z.union([sh,lh,li.extend({type:S.z.literal("STEP"),description:S.z.string().optional().default(""),statements:S.z.array(pe),reference_id:S.z.number().optional(),template_path:S.z.string().optional(),template_params:S.z.record(S.z.string()).optional()}),li.extend({type:S.z.literal("IF_ELSE"),description:S.z.string().optional(),condition:Qs,then:S.z.array(pe),else:S.z.array(pe).optional()}),li.extend({type:S.z.literal("WHILE_LOOP"),description:S.z.string().optional(),condition:Qs,body:S.z.array(pe),timeout_ms:S.z.number().optional()})])),ch=S.z.object({name:S.z.string(),statements:S.z.array(pe),teardown:S.z.array(pe).optional(),skip:S.z.union([S.z.boolean(),S.z.string()]).optional(),timeout:S.z.number().optional(),fail:S.z.union([S.z.boolean(),S.z.string()]).optional(),only:S.z.boolean().optional(),slow:S.z.boolean().optional()}),dh=S.z.object({tests:S.z.array(ch).min(1),beforeAll:S.z.array(pe).optional(),afterAll:S.z.array(pe).optional(),beforeEach:S.z.array(pe).optional(),afterEach:S.z.array(pe).optional()}),yx=S.z.object({comment:S.z.string().optional(),version:S.z.string().optional(),goal:S.z.string().optional(),url:S.z.string().optional(),baseURL:S.z.string().optional(),final_feedback:S.z.string().optional(),completed:S.z.boolean().optional(),success:S.z.boolean().optional(),statements:S.z.array(pe).optional(),teardown:S.z.array(pe).optional(),last_modified_at:S.z.string().optional(),testGroup:dh.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"}),Ix=1024*1024,Dx=Object.freeze(["anthropic:claude-sonnet-5","google:gemini-3.1-pro-preview"])});var Ze=v(()=>{"use strict"});async function gh(e,t){let i=new Set,a=Date.now(),n=new Set(["document","stylesheet","image","font","script","iframe"]),o=new Set(["text/html","text/css","application/javascript","image/","font/","application/json"]),r=["analytics","tracking","telemetry","beacon","metrics","doubleclick","adsystem","adserver","advertising","facebook.com/plugins","platform.twitter","linkedin.com/embed","livechat","zendesk","intercom","crisp.chat","hotjar","push-notifications","onesignal","pushwoosh","heartbeat","ping","alive","webrtc","rtmp://","wss://","cloudfront.net","fastly.net"],s=h=>{let p=h.toLowerCase();return p.startsWith("data:")||p.startsWith("blob:")?!0:r.some(g=>p.includes(g))},l=h=>{let p=h.resourceType(),g=h.url();if(!n.has(p)||s(g))return;let w=h.headers();w.purpose==="prefetch"||["video","audio"].includes(w["sec-fetch-dest"])||(i.add(h),a=Date.now())},c=async h=>{let p=h.request();if(!i.has(p))return;let g=(h.headers()["content-type"]||"").toLowerCase();if(["streaming","video","audio","webm","mp4","event-stream","websocket","protobuf"].some(y=>g.includes(y))){i.delete(p);return}if(![...o].some(y=>g.startsWith(y))){i.delete(p);return}let w=h.headers()["content-length"];if(w)try{if(parseInt(w,10)>5*1024*1024){i.delete(p);return}}catch{}i.delete(p),a=Date.now()},d=Date.now()-mh;for(let h of await e.requests()){let p=h.resourceType(),g=h.url(),w=h.timing();n.has(p)&&!s(g)&&w.responseEnd===-1&&w.startTime>=d&&(i.add(h),a=Date.now())}u.debug(`[waitForStableNetwork] Pre-populated ${i.size} in-flight requests`),e.on("request",l),e.on("response",c);try{let h=Date.now(),p=ph;for(;;){await new Promise(w=>setTimeout(w,100));let g=Date.now();if(i.size===0&&g-a>=p){u.debug(`[waitForStableNetwork] Network idle after ${g-h}ms`);break}if(g-h>t){u.debug(`[waitForStableNetwork] Max wait time exceeded (${t}ms), pending: ${i.size}`);break}}}finally{e.removeListener("request",l),e.removeListener("response",c)}}async function Ne(e,t=hh,i=uh){let a=Date.now();try{await Promise.all([e.waitForLoadState("load",{timeout:t}).catch(()=>{}),gh(e,t)])}catch(r){throw r instanceof Error?new Error(`Failed during network stabilization: ${r.message}`):new Error("An unknown error occurred during network stabilization.")}let n=Date.now()-a,o=Math.max(i-n,0);o>0&&await new Promise(r=>setTimeout(r,o))}var uh,hh,ph,mh,Te=v(()=>{"use strict";Ze();U();uh=.5*1e3,hh=30*1e3,ph=1*1e3,mh=3*1e3});async function al(e,t=3e3,i=1e3){try{await Ne(e,t,i)}catch{}}async function ol(e,t,i){let a=i*1e3,n=100,o=Date.now();for(;!t.downloadStatus||t.downloadStatus.status==="inProgress";){if(Date.now()-o>a){let r;throw t.downloadStatus?r=`Timed out after ${a}ms waiting for download to complete`:r="No download in progress or completed",u.error(r),new Error(r)}await e.waitForTimeout(n)}if(t.downloadStatus.status==="failed"){let r=`Download failed: ${t.downloadStatus.error||"Unknown error"}`;throw u.error(r),new Error(r)}t.agentNote=`Download completed: ${t.downloadStatus.filename}`}async function rl(e,t,i,a=60,n){let o=Math.min(a,300),r=Math.max(10,o/10)*1e3,s=Date.now()+o*1e3;for(u.info(`Waiting for condition: "${t}" (timeout: ${o}s)`);;){let l=Date.now();try{if(await i(e,t,n))return u.info(`Condition met: "${t}"`),!0}catch(d){u.warn(`Error evaluating condition: ${d.message}`)}if(Date.now()>s)return u.warn(`Timeout waiting for condition: "${t}"`),!1;let c=r-(Date.now()-l);c>0&&await e.waitForTimeout(c)}}async function Dn(e,t,i=60){let a=Math.min(i,300),n=250,o=Date.now()+a*1e3;u.info(`Waiting for JS condition (timeout: ${a}s)`);let r;for(;;){try{if(await t())return u.info("JS wait condition met"),!0}catch(s){let l=s.message;l!==r&&(u.warn(`Error evaluating JS wait condition: ${l}`),r=l)}if(Date.now()>o)return u.warn("Timeout waiting for JS condition"),!1;await e.waitForTimeout(n)}}var Tt=v(()=>{"use strict";Te();U()});function ll(e,t){e.register({name:"ai_wait_until",description:'Wait until a specific condition is met on the page (e.g., "page loads", "spinner disappears", "button becomes enabled"). Use this instead of wait when the goal is to wait for something to happen rather than waiting a fixed duration.',schema:fh,async execute(i,a){let{condition:n,timeout_seconds:o=60}=i,{page:r,agentServices:s}=a;try{let l={action_description:`Wait until: ${n}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:n,timeout_seconds:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Condition met: ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Wait until: ${n} (failed)`,action_data:{action_name:"ai_wait_until",kwargs:{condition:n,timeout_seconds:o}},feedback:l.message}}}}})}var Rn,sl,fh,ci=v(()=>{"use strict";bt();Le();Tt();Rn=require("zod"),sl=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.condition;if(!n)throw new Error("Missing condition for ai_wait_until");let o=a.kwargs.timeout_seconds||60;if(a.kwargs.condition_type===Ln.JS_CODE){let d=new Function("page","expect","agent",`
|
|
4100
4100
|
return (async () => (${n}))();
|
|
4101
4101
|
`);if(!await Dn(e,()=>d(e,ze.expect,i.agent),o))throw new Error(`Timeout waiting for condition: ${n}`);return}let r=o*1e3,s=5e3,l=Date.now(),{evaluateStatement:c}=await Promise.resolve().then(()=>(vt(),xt));for(;Date.now()-l<r;){if((await c(n,e,i,{})).success)return;await e.waitForTimeout(s)}throw new Error(`Timeout waiting for condition: ${n}`)}transpile(e,t){let i=e.action_data?.kwargs?.condition,a=e.action_data?.kwargs?.timeout_seconds||60;return i?e.action_data?.kwargs?.condition_type===Ln.JS_CODE?[`await agent.waitForJs(page, async () => (${i}), ${a}, '${t}');`]:[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${a}, '${t}');`]:["// Skipping ai_wait_until: missing condition"]}},fh=Rn.z.object({condition:Rn.z.string().describe('The condition to wait for (e.g., "the loading spinner disappears")'),timeout_seconds:Rn.z.number().positive().optional().describe("Timeout in seconds (default: 60)")})});function dl(e,t){e.register({name:"save_variable",description:"Save a value to a named variable for later use in the test.",schema:wh,async execute(i,a){let{name:n,value:o}=i,{page:r,agentServices:s}=a;try{let l={action_description:`Save variable "${n}" = "${o}"`,action_data:{action_name:"save_variable",kwargs:{name:n,value:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Saved variable "${n}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Save variable "${n}" (failed)`,action_data:{action_name:"save_variable",kwargs:{name:n,value:o}},feedback:l.message}}}}})}var Fn,cl,wh,di=v(()=>{"use strict";Fn=require("zod"),cl=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.name,o=a.kwargs.value;if(!n||o===void 0)throw new Error("Missing variable name or value for save_variable");n.startsWith("$")&&(n=n.slice(1)),i.saveVariable(n,o)}transpile(e){let t=e.action_data?.kwargs?.name||"",i=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(i)} } },`,"});"]}},wh=Fn.z.object({name:Fn.z.string().describe("Variable name to save"),value:Fn.z.string().describe("Value to save in the variable")})});async function bh(e,t,i={}){return{action_description:t,action_data:{action_name:e,kwargs:{...i}}}}function yh(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Scroll failed!"}}function ul(e,t){e.register({name:"scroll",description:"Scroll the page by specified number of pages (set down=True to scroll down, down=False to scroll up, num_pages=number of pages to scroll like 0.5 for half page, 1.0 for one page, etc.). ",schema:xh,async execute(i,a){let{down:n,num_pages:o}=i,{page:r,agentServices:s,actionDescription:l}=a;try{let c=l||`Scroll ${n?"down":"up"} ${o} page(s)`,d=await bh("scroll",c,{down:n,num_pages:o});return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Scrolled ${n?"down":"up"} ${o} page(s)`}}catch(c){return{success:!1,error:c.message,actionEntity:yh(l||`Scroll ${n?"down":"up"} ${o} page(s)`,"scroll",{down:n,num_pages:o})}}}})}var Hn,ui,xh,hi=v(()=>{"use strict";Hn=require("zod"),ui=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let a=i.kwargs.down??!0,n=i.kwargs.num_pages??1,o=a?1:-1;await e.evaluate(`window.scrollBy(0, window.innerHeight * ${n} * ${o})`)}transpile(e){let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]}};xh=Hn.z.object({down:Hn.z.boolean().describe("True to scroll down, False to scroll up"),num_pages:Hn.z.number().nonnegative().describe("Number of pages to scroll (0.5 = half page, 1.0 = one page, etc.)")})});async function vh(e,t,i,a,n={}){return{...await H(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function hl(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function ml(e,t){e.register({name:"scroll_on_element",description:"Scroll on a scrollable element horizontally and vertically.",schema:_h,usesElementIndex:!0,async execute(i,a){let{element_index:n,delta_x:o,delta_y:r}=i,{page:s,agentServices:l}=a;try{let c=await z(a,n);if(!c)return{success:!1,error:`Element with index ${n} not found`,actionEntity:hl(`Scroll on element ${n} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:n,delta_x:o,delta_y:r})};let d=await vh("scroll_on_element",`Scroll on element ${n} horizontally: ${o}px, vertically: ${r}px`,c,s,{delta_x:o,delta_y:r});return await t.execute(s,d,l),{success:!0,actionEntity:d,message:`Scrolled on element ${n} horizontally: ${o}px, vertically: ${r}px`}}catch(c){return{success:!1,error:c.message,actionEntity:hl(`Scroll on element ${n} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:n,delta_x:o,delta_y:r})}}}})}var At,pl,_h,pi=v(()=>{"use strict";Q();B();At=require("zod");P();pl=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.delta_x||0,o=a.kwargs.delta_y||0,r=N(e,t),s=L(i,t.action_data?.kwargs?.timeout_ms);if(r)await r.hover({timeout:s}),await e.mouse.wheel(n,o);else throw new Error("No locator found for scroll_on_element action")}transpile(e){let t=Be(e);if(!t){let n=e.action_data?.kwargs?.delta_x||0,o=e.action_data?.kwargs?.delta_y||0;return['await agent.execAction("scroll_on_element", page, {',` action_data: { kwargs: { delta_x: ${n}, delta_y: ${o} } },`,"});"]}let i=e.action_data?.kwargs?.delta_x||0,a=e.action_data?.kwargs?.delta_y||0;return[`await ${t}.hover({ timeout: ${L()} });`,`await page.mouse.wheel(${i}, ${a});`]}};_h=At.z.object({element_index:At.z.number().int().describe("Index of the scrollable element"),delta_x:At.z.number().optional().describe("The number of pixels to scroll horizontally. Positive values scroll right, negative values scroll left."),delta_y:At.z.number().optional().describe("The number of pixels to scroll vertically. Positive values scroll down, negative values scroll up."),timeout_ms:At.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function fl(e,t){e.register({name:"scroll_to_text",description:"Scroll the page until specified text becomes visible.",schema:kh,async execute(i,a){let{text:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l={action_description:s||`Scroll to text "${n}"`,action_data:{action_name:"scroll_to_text",kwargs:{text:n}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Scrolled to text "${n}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Scroll to text "${n}"`)+" (failed)",action_data:{action_name:"scroll_to_text",kwargs:{text:n}},feedback:l.message}}}}})}var co,gl,kh,mi=v(()=>{"use strict";co=require("zod"),gl=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let a=i.kwargs.text;if(a)await e.getByText(a,{exact:!1}).first().scrollIntoViewIfNeeded(),await e.waitForTimeout(500);else throw new Error("Missing text for scroll_to_text action")}transpile(e){let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]}},kh=co.z.object({text:co.z.string().describe("Text to scroll to on the page")})});async function Sh(e,t,i,a){return{...await H(t,e),action_description:a||`Select option "${i}"`,action_data:{action_name:"select_dropdown_option",kwargs:{text:i}}}}function wl(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"select_dropdown_option",kwargs:t},feedback:"Element not found in DOM"}}function yl(e,t){e.register({name:"select_dropdown_option",description:"Select an option from a dropdown/select element by value, label, or index.",schema:Eh,usesElementIndex:!0,async execute(i,a){let{element_index:n,option:o}=i,{page:r,agentServices:s,actionDescription:l}=a;try{let c=await z(a,n);if(!c)return{success:!1,error:`Dropdown element with index ${n} not found`,actionEntity:wl(l||`Select option in dropdown ${n}`,{index:n,option:o})};let d=await Sh(c,r,o,l);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Selected option "${o}" in dropdown ${n}`}}catch(c){return{success:!1,error:c.message,actionEntity:wl(`Select option in dropdown ${n}`,{index:n,option:o})}}}})}var gi,bl,Eh,fi=v(()=>{"use strict";Q();B();gi=require("zod");P();bl=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.text||a.kwargs.option,o=N(e,t),r=L(i,t.action_data?.kwargs?.timeout_ms);if(o&&n)await o.selectOption(n,{timeout:r});else throw new Error("Missing locator or option label for select_dropdown_option action")}transpile(e){let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"",i=[];return i.push(`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("select_dropdown_option", page, {',...i.map(a=>` ${a},`),"});"]}};Eh=gi.z.object({element_index:gi.z.number().int().describe("Index of the dropdown/select element"),option:gi.z.string().describe("Option value, label, or index to select"),timeout_ms:gi.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function Th(e,t,i,a){return{...await H(i,t),action_description:e,action_data:{action_name:"set_date_for_native_date_picker",kwargs:{date:a}}}}function uo(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"set_date_for_native_date_picker",kwargs:t},feedback:"Element not found in DOM"}}function vl(e,t){e.register({name:"set_date_for_native_date_picker",description:`Set a date in a native HTML date picker input (<input type="date">).
|
|
4102
4102
|
|
|
@@ -4367,7 +4367,7 @@ ${p.join(`
|
|
|
4367
4367
|
`)}function kd(e,t){let i=[],a=t?.version||"unknown";i.push(`// @generated by shiplightai v${a}`),i.push(...pr()),i.push(""),t?.use&&Object.keys(t.use).length>0&&(i.push(`test.use(${JSON.stringify(t.use,null,2)});`),i.push(""));let n=new Set,o={imports:n,actionEntityStore:t?.actionEntityStore,yamlDir:t?.yamlDir,projectRoot:t?.projectRoot},r=t?.testName||"Test Suite",s=wa(t?.tags);i.push(`test.describe.serial('${s}${be(r)}', () => {`),e.beforeAll&&e.beforeAll.length>0&&(i.push(...ji("beforeAll",e.beforeAll,o,1)),i.push("")),e.beforeEach&&e.beforeEach.length>0&&(i.push(...ji("beforeEach",e.beforeEach,o,1)),i.push(""));for(let c=0;c<e.tests.length;c++){let d=e.tests[c],h=d.timeout||d.skip!==void 0||d.fail!==void 0||d.only||d.slow?{timeout:d.timeout,skip:d.skip,fail:d.fail,only:d.only,slow:d.slow}:void 0;if(d.parameters&&d.parameters.length>0)for(let p of d.parameters)i.push(...Xi(d.testFlow,`${be(d.name)} [${be(p.name)}]`,o,1,h,p.name,p.values)),i.push("");else i.push(...Xi(d.testFlow,be(d.name),o,1,h)),(c<e.tests.length-1||e.afterEach||e.afterAll)&&i.push("")}return e.afterEach&&e.afterEach.length>0&&(i.push(...ji("afterEach",e.afterEach,o,1)),i.push("")),e.afterAll&&e.afterAll.length>0&&i.push(...ji("afterAll",e.afterAll,o,1)),i.push("});"),mr(i,n),i.join(`
|
|
4368
4368
|
`)}function wa(e){return e&&e.length>0?e.map(t=>`@${t}`).join(" ")+" ":""}var Sd=["testContext","request"];function Vi(e){let t=new Set;function i(a){for(let n of a)switch(n.type){case ge.ACTION:{let r=n.action_entity?.action_data?.kwargs,s=[...Array.isArray(r?.args)?r.args:[],...Array.isArray(r?.parameterValues)?r.parameterValues:[]];for(let l of s)typeof l=="string"&&Sd.includes(l)&&t.add(l);break}case ge.STEP:i(n.statements);break;case ge.IF_ELSE:{let o=n;i(o.then),o.else&&i(o.else);break}case ge.WHILE_LOOP:i(n.body);break}}return i(e),t}function Ed(e){let t=Vi(e.statements??[]);if(e.teardown)for(let i of Vi(e.teardown))t.add(i);return t}function va(e){return`{ ${["page","agent",...Array.from(e).sort()].join(", ")} }`}function Xi(e,t,i,a=0,n,o,r){let s=" ".repeat(a),l=[],c=Ed(e),d=va(c),h=n?.only?"test.only":"test",p=o?`, { tag: '@${be(o)}' }`:"";if(l.push(`${s}${h}('${t}'${p}, async (${d}) => {`),n?.skip===!0?l.push(`${s} test.skip();`):typeof n?.skip=="string"&&l.push(`${s} test.skip(true, '${be(n.skip)}');`),n?.fail===!0?l.push(`${s} test.fail();`):typeof n?.fail=="string"&&l.push(`${s} test.fail(true, '${be(n.fail)}');`),n?.slow&&l.push(`${s} test.slow();`),n?.timeout&&l.push(`${s} test.setTimeout(${n.timeout});`),r){for(let[y,b]of Object.entries(r))l.push(`${s} agent.agentServices.saveVariable(${JSON.stringify(y)}, ${JSON.stringify(b)});`);l.push("")}let g=e.teardown&&e.teardown.length>0,w=a+1;if(g){if(l.push(`${s} try {`),e.statements&&e.statements.length>0){l.push(`${s} // Test steps`);let b=ye(e.statements,w+1,i);l.push(...b)}l.push(`${s} } finally {`),l.push(`${s} // Teardown`);let y=ye(e.teardown,w+1,i,"teardown");l.push(...y),l.push(`${s} }`)}else if(e.statements&&e.statements.length>0){l.push(`${s} // Test steps`);let y=ye(e.statements,w,i);l.push(...y)}return l.push(`${s}});`),l}function cr(e,t,i){let a=[],n=hr(t),o=Vi(n),r=va(o);return a.push(`test.${e}(async (${r}) => {`),a.push(...ye(n,1,i,e)),a.push("});"),a}function ji(e,t,i,a){let n=" ".repeat(a),o=[],r=hr(t);if(e==="beforeAll"||e==="afterAll"){let l={...i,noAgent:!0};o.push(`${n}test.${e}(async ({ browser }, workerInfo) => {`),o.push(`${n} const page = await browser.newPage({ baseURL: workerInfo.project.use.baseURL });`),o.push(...ye(r,a+1,l,e)),o.push(`${n} await page.close();`),o.push(`${n}});`)}else{let l=Vi(r),c=va(l);o.push(`${n}test.${e}(async (${c}) => {`),o.push(...ye(r,a+1,i,e)),o.push(`${n}});`)}return o}function hr(e){let i=(0,ur.stringify)({goal:"_hook",statements:e});return Ie(i).statements??[]}function pr(){return["import { test, expect } from 'shiplightai/fixture';"]}function mr(e,t){if(t.size>0){let i=0;for(let n=0;n<e.length;n++)e[n].startsWith("import ")&&(i=n+1);let a=Array.from(t);e.splice(i,0,...a)}}var dr=5;function fr(e,t,i){let a={expandingPaths:new Set([(0,rt.resolve)(t)]),depth:0,referencedPaths:new Set,basePath:i},n={...e};Array.isArray(n.statements)&&(n.statements=We(n.statements,t,a)),Array.isArray(n.teardown)&&(n.teardown=We(n.teardown,t,a));for(let o of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(n[o])&&(n[o]=We(n[o],t,a));return{doc:n,referencedTemplatePaths:Array.from(a.referencedPaths)}}function We(e,t,i){let a=[];for(let n of e)if(Td(n)){let o=Ad(n,t,i);a.push(o)}else a.push($d(n,t,i));return a}function Td(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function Ad(e,t,i){if(i.depth>=dr)throw new Error(`Template expansion exceeded maximum depth of ${dr}. Check for deeply nested or circular template references.`);let a=(0,rt.resolve)((0,rt.dirname)(t),e.template),n=!(0,Ji.existsSync)(a)&&i.basePath?(0,rt.resolve)(i.basePath,e.template):a;if(i.expandingPaths.has(n))throw new Error(`Circular template reference detected: ${n} is already being expanded. Stack: ${Array.from(i.expandingPaths).join(" \u2192 ")} \u2192 ${n}`);i.referencedPaths.add(n);let o;try{o=(0,Ji.readFileSync)(n,"utf-8")}catch(w){throw new Error(`Failed to read template file: ${n} (referenced from ${t}): ${w.message}`)}let r=(0,Ot.parse)(o);if(!r||typeof r!="object")throw new Error(`Invalid template file: ${n} \u2014 expected a YAML object`);let s=r.params||[],l=e.params||{};for(let w of s)if(!(w in l))throw new Error(`Template ${e.template} requires param "${w}" but it was not provided. Required params: [${s.join(", ")}]`);let c=r.statements;if(!Array.isArray(c))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(l).length>0){let y=(0,Ot.stringify)(c);for(let[b,m]of Object.entries(l))y=y.split(`<<${b}>>`).join(String(m));c=(0,Ot.parse)(y)}let d={expandingPaths:new Set([...i.expandingPaths,n]),depth:i.depth+1,referencedPaths:i.referencedPaths},h=We(c,n,d),g={STEP:r.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:h};return Object.keys(l).length>0&&(g.template_params=l),g}function $d(e,t,i){if(typeof e!="object"||e===null)return e;let a={...e};return Array.isArray(a.statements)&&(a.statements=We(a.statements,t,i)),Array.isArray(a.THEN)&&(a.THEN=We(a.THEN,t,i)),Array.isArray(a.ELSE)&&(a.ELSE=We(a.ELSE,t,i)),Array.isArray(a.DO)&&(a.DO=We(a.DO,t,i)),a}var _a=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}};function ka(e,t,i){let a=(0,Lt.parse)(e),n=a?.name,o=a?.tags,r=a?.use;if(a&&(a.name!==void 0||a.tags!==void 0||a.use!==void 0)&&(delete a.name,delete a.tags,delete a.use),a?.suite){if(a.goal||a.statements)throw new _a('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return Id(a,n,o,r,t,i)}return Md(a,n,o,r,t,i)}function Md(e,t,i,a,n,o){let r=e?.beforeEach,s=e?.afterEach,l=wr(e?.parameters),c=e?.timeout,d=e?.skip,h=e?.fail,p=e?.only,g=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 _a(`The "url" field is not supported in local YAML tests. Use "base_url: ${e.url}" and add "- URL: /" as the first statement instead.`);e&&!e.goal&&t&&(e.goal=t);let w=[];if(n&&e&&typeof e=="object"){let m=fr(e,n,o);e=m.doc,w=m.referencedTemplatePaths}let y=(0,Lt.stringify)(e),b=Ie(y);return n&&(ot(b.statements??[],n,"main"),b.teardown&&ot(b.teardown,n,"teardown")),{testFlow:b,name:t,tags:i,use:a,beforeEach:r,afterEach:s,parameters:l,timeout:c,skip:d,fail:h,only:p,slow:g,referencedTemplatePaths:w}}function Id(e,t,i,a,n,o){let r=e.suite;if(!Array.isArray(r.tests)||r.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let s=r.beforeAll,l=r.afterAll,c=r.beforeEach,d=r.afterEach,h=[],p=r.tests.map(y=>{if(!y.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(y.statements)||y.statements.length===0)throw new Error(`Suite test "${y.name}" must have a non-empty "statements" array.`);let b={goal:y.name,statements:y.statements};y.teardown&&(b.teardown=y.teardown);let m=[],x=b;if(n&&typeof b=="object"){let $=fr(b,n,o);x=$.doc,m=$.referencedTemplatePaths,h.push(...m)}let _=(0,Lt.stringify)(x),E=Ie(_),T=wr(y.parameters);return{testFlow:E,name:y.name,tags:Array.isArray(y.tags)?y.tags:void 0,parameters:T,timeout:y.timeout,skip:y.skip,fail:y.fail,only:y.only,slow:y.slow}}),g=r.base_url,w=g?{...a,baseURL:g}:a;return{suite:{beforeAll:s,afterAll:l,beforeEach:c,afterEach:d,tests:p},name:t,tags:i,use:w,referencedTemplatePaths:h}}function wr(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,i)=>{if(!t.name)throw new Error(`Parameter set at index ${i} must have a "name" field.`);if(!t.values||typeof t.values!="object")throw new Error(`Parameter set "${t.name}" must have a "values" object.`);return{name:t.name,values:t.values}})}function ot(e,t,i){for(let a=0;a<e.length;a++){let n=e[a],o=`${i}.${a}`,r=n.description||"";if(n.uid=Pd(t,o,r),n.type===ge.STEP)ot(n.statements,t,o);else if(n.type===ge.IF_ELSE){let s=n;ot(s.then,t,`${o}.then`),s.else&&ot(s.else,t,`${o}.else`)}else n.type===ge.WHILE_LOOP&&ot(n.body,t,`${o}.body`)}}function Pd(e,t,i){let a=(0,gr.createHash)("sha256").update(`${e}:${t}:${i}`).digest("hex");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20,32)}`}function br(e,t,i){let a=/\btemplate:\s/.test(e),n=/^suite:/m.test(e),o=a||n?null:ma(e);if(o&&!o.valid)return{valid:!1,errors:o.errors,warnings:[],stats:o.stats};let r,s,l=[];try{let c=i?.parsed??ka(e,t,i?.basePath);l=c.referencedTemplatePaths;let d={version:i?.version,actionEntityStore:i?.actionEntityStore,yamlDir:(0,ba.dirname)(t),projectRoot:i?.projectRoot??i?.basePath},h=c.testFlow?.baseURL?{...c.use,baseURL:c.testFlow.baseURL}:c.use;c.suite?r=kd(c.suite,{...d,testName:c.name,tags:c.tags,use:c.use}):r=_d(c.testFlow,{...d,testName:c.name,tags:c.tags,use:h,beforeEach:c.beforeEach,afterEach:c.afterEach,parameters:c.parameters,timeout:c.timeout,skip:c.skip,fail:c.fail,only:c.only,slow:c.slow});let p=r.split(`
|
|
4369
4369
|
`).filter(g=>!g.startsWith("import ")).join(`
|
|
4370
|
-
`);new Function(p),s=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),(0,Nt.mkdirSync)((0,ba.dirname)(s),{recursive:!0}),(0,Nt.writeFileSync)(s,r)}catch(c){let d=c instanceof _a?"":c.message.includes("Unexpected token")?" This usually means a YAML escaping issue \u2014 in double-quoted strings, use \\\\/ instead of \\/ for regex patterns, or use single quotes / block scalars.":" This may indicate a transpiler bug \u2014 please report it.";return{valid:!1,errors:[`Transpilation failed: ${c.message}.${d}`],warnings:[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},referencedTemplatePaths:l}}return{valid:!0,errors:[],warnings:o?.warnings??[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},specFile:s,referencedTemplatePaths:l}}var Sa="0.1.
|
|
4370
|
+
`);new Function(p),s=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),(0,Nt.mkdirSync)((0,ba.dirname)(s),{recursive:!0}),(0,Nt.writeFileSync)(s,r)}catch(c){let d=c instanceof _a?"":c.message.includes("Unexpected token")?" This usually means a YAML escaping issue \u2014 in double-quoted strings, use \\\\/ instead of \\/ for regex patterns, or use single quotes / block scalars.":" This may indicate a transpiler bug \u2014 please report it.";return{valid:!1,errors:[`Transpilation failed: ${c.message}.${d}`],warnings:[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},referencedTemplatePaths:l}}return{valid:!0,errors:[],warnings:o?.warnings??[],stats:o?.stats??{total:0,action:0,draft:0,coverage:0},specFile:s,referencedTemplatePaths:l}}var Sa="0.1.92";function yr(e){try{return(0,Ue.statSync)(e).mtimeMs}catch{return 0}}var Cd=`// @generated by shiplightai v${Sa}`;function Od(e,t){if(!(0,Ue.existsSync)(e)||(0,Ue.readFileSync)(e,"utf-8").split(`
|
|
4371
4371
|
`,1)[0]!==Cd)return!1;let a=yr(e);for(let n of t)if(yr(n)>a)return!1;return!0}function Ld(e,t=process.argv.slice(2)){let i=[],a=(0,st.resolve)(e);for(let n of t){if(n.startsWith("-"))continue;let o=n.endsWith(".yaml.spec.ts")?n.replace(/\.yaml\.spec\.ts$/,".test.yaml"):n;if(!o.endsWith(".test.yaml"))continue;let r=(0,st.resolve)(e,o);(0,Ue.existsSync)(r)&&i.push(r.startsWith(a)?r.slice(a.length+1):o)}return i.length>0?i:null}function vr(e){let t=Ld(e.cwd),i=t??(0,xr.globSync)("**/*.test.yaml",{cwd:e.cwd,ignore:["**/node_modules/**"]}),a=[];for(let n of i){let o=(0,st.resolve)(e.cwd,n),r=o.replace(/\.test\.yaml$/,".yaml.spec.ts"),s=(0,Ue.readFileSync)(o,"utf-8");try{let l=ka(s,o,e.projectRoot??e.cwd),c=(0,st.relative)(e.cwd,o),d=e.actionEntityStores?.get(c)??e.actionEntityStores?.get("*");if(!(d&&Object.keys(d.entries).length>0)&&Od(r,[o,...l.referencedTemplatePaths]))continue;let p=br(s,o,{version:Sa,actionEntityStore:d,parsed:l,projectRoot:e.projectRoot??e.cwd});if(!p.valid)throw new Error(p.errors.join("; "))}catch(l){console.error(`[shiplight] Failed to transpile ${n}:`,l),a.push({file:n,error:l})}}if(a.length>0){let n=`[shiplight] Transpilation failed for ${a.length} file(s):
|
|
4372
4372
|
`+a.map(o=>` - ${o.file}`).join(`
|
|
4373
4373
|
`);if(t)throw new Error(n);console.warn(n+" (skipped)")}}var ce=J(require("fs"),1),Dt=J(require("path"),1),Cr=require("glob");Zi();function Or(e){let t=qi().SHIPLIGHT_API_TOKEN;return process.env.CI&&t?new Ia:new Ma(e)}var Vd=".shiplight/action-cache";function Pr(e){return e.replace(/\//g,"__")+".json"}function Xd(e){return e.replace(/\.json$/,"").replace(/__/g,"/")}var Ma=class{constructor(t){this.cwd=t;this.cacheDir=Dt.join(t,Vd)}isCloud=!1;cacheDir;async lookup(t){let i=new Map;if(t.length===0||!ce.existsSync(this.cacheDir))return i;for(let a of t){let n=Dt.join(this.cacheDir,Pr(a));try{if(ce.existsSync(n)){let o=ce.readFileSync(n,"utf-8");i.set(a,JSON.parse(o))}}catch{}}return i}async update(t){if(t.size===0)return 0;ce.mkdirSync(this.cacheDir,{recursive:!0});let i=0;for(let[a,n]of t)try{let o=Dt.join(this.cacheDir,Pr(a)),r=ga();if(ce.existsSync(o))try{r=JSON.parse(ce.readFileSync(o,"utf-8"))}catch{}let s={...r,entries:{...r.entries,...n.entries}};ce.writeFileSync(o,JSON.stringify(s,null,2)),i++}catch{}return i}loadAll(){if(!ce.existsSync(this.cacheDir))return;let t=(0,Cr.globSync)("*.json",{cwd:this.cacheDir});if(t.length===0)return;let i=new Map,a=0;for(let n of t)try{let o=ce.readFileSync(Dt.join(this.cacheDir,n),"utf-8"),r=JSON.parse(o),s=Xd(n);i.set(s,r),a+=Object.keys(r.entries??{}).length}catch{}if(i.size!==0)return console.log(`[shiplight] Cache: loaded ${a} cached action entit${a===1?"y":"ies"} for ${i.size} test file${i.size!==1?"s":""}`),i}},Ia=class{isCloud=!0;async lookup(t){let{lookupActionStores:i}=await Promise.resolve().then(()=>($a(),Aa));return i(t)}async update(t){let{updateActionStores:i}=await Promise.resolve().then(()=>($a(),Aa));return i(t)}loadAll(){}};Zi();function Jd(e,t,i){let a=t.SHIPLIGHT_PROJECT_ROOT||i;return{scanDir:e.scanDir||a,projectRoot:a}}function Dr(e={}){let{scanDir:t,projectRoot:i}=Jd(e,process.env,process.cwd());e.dotenv!==!1&&qd(t);let n=Or(t).loadAll();vr({cwd:t,projectRoot:i,actionEntityStores:n});let o=process.env.SHIPLIGHT_REPORT_DIR,r=process.env.SHIPLIGHT_RUN_ID??Yd();process.env.SHIPLIGHT_RUN_ID=r;let s=[];return process.env.PLAYWRIGHT_JSON_OUTPUT_FILE&&s.push(["json",{outputFile:process.env.PLAYWRIGHT_JSON_OUTPUT_FILE}]),o?{outputDir:`test-results/${r}`,reporter:[["list"],["shiplightai/reporter",{outputFolder:o,open:"never"}],...s]}:{outputDir:`test-results/${r}`,reporter:[["list"],["shiplightai/reporter",{outputFolder:`shiplight-report/${r}`,latestSymlinkDir:"shiplight-report",open:"never"}],...s]}}function Yd(){let e=new Date,t=(i,a=2)=>String(i).padStart(a,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}-${t(e.getMinutes())}-${t(e.getSeconds())}-${t(e.getMilliseconds(),3)}`}function Rr(e,...t){return(0,Nr.defineConfig)(e,...t)}function qd(e){Sr(e);for(let t of Ea(e))Lr.default.config({path:t})}U();U();ii();mt();var $o=require("zod"),dp=$o.z.object({instruction:$o.z.string().describe('The instruction of the operation to perform. Can only include one operation. Do not inlcude element indexes just describe the element, e.g. "select the text "Hello, world!" in "Hello, world!""')});function dc(e){e.register({name:"perform_accurate_operation",description:"Perform an operation that requires accurate interaction like dragging or interacting with a specific area of an element. Only use this action when neccecary.",schema:dp,usesElementIndex:!1,async execute(t,i){let{instruction:a}=t,n={page:i.page,agentServices:i.agentServices,domService:i.domService},o=await pt(a,n,{});if(o.status==="error"||!o.actionEntity)return{success:!1,actionEntity:{action_description:a,action_data:{action_name:"perform_accurate_operation",kwargs:{instruction:a}}},error:o.error||"Failed to generate action"};let{actionEntity:r}=o,s=await ei(r,n);return{success:s.success,actionEntity:r,message:s.success?`Successfully executed action: ${r.action_data?.action_name}`:void 0,error:s.error}}})}Se();U();var uc=require("ai"),hc=require("html-to-text");async function up(e,t,i){let{apiKey:a,domain:n}=e;if(!a)throw new Error("Mailgun configuration missing. Please provide apiKey and domain");let o=!!e.baseURL,r=e.baseURL||"https://api.mailgun.net",s=e.authHeader||`Basic ${Buffer.from(`api:${a}`).toString("base64")}`,l=[];try{let c=o?`${r}/events`:`${r}/v3/${n}/events`,d={event:"accepted",limit:"10",ascending:"yes",recipient:t};if(i.from_email&&(d.from=i.from_email),i.since)d.begin=Math.floor(i.since/1e3).toString();else{let g=new Date(Date.now()-6e5);d.begin=Math.floor(g.getTime()/1e3).toString()}u.info(`Mailgun params: ${JSON.stringify(d)}`);let h=await fetch(c+"?"+new URLSearchParams(d),{method:"GET",headers:{Authorization:s}});if(!h.ok){let g=await h.text();throw new Error(`Mailgun events API error: ${g}`)}let p=(await h.json()).items||[];for(let g of p.slice(0,10)){if(g.event!=="accepted")continue;let w=(g.storage||{}).url;if(u.info(`message_url: ${w}`),!w){let m=(g.message||{}).headers||{},x=m.subject||"",_=m.from||"",E=m.to||"";if(i.from_email&&!_.toLowerCase().includes(i.from_email.toLowerCase())||i.to_email&&!E.toLowerCase().includes(i.to_email.toLowerCase())||i.subject&&!x.toLowerCase().includes(i.subject.toLowerCase()))continue;l.push({subject:x,from:_,to:E,date:new Date(g.timestamp*1e3).toUTCString(),body:"Message body not available (Mailgun storage disabled)",message_id:m["message-id"]||""});continue}let y=w.split("/"),b=y[y.length-1];if(u.info(`Storage key: ${b}`),b){let m=o?`${r}/messages/${b}`:`${r}/v3/domains/${n}/messages/${b}`;try{let x=await fetch(m,{method:"GET",headers:{Authorization:s,Accept:"application/json"}});if(x.ok){let _=await x.json(),E=_.Subject||"",T=_.From||"",$=_.To||"",C=_.Date||"",D=_["Message-Id"]||"";u.info(`subject: ${E}`),u.info(`from_addr: ${T}`),u.info(`to_addr: ${$}`),u.info(`date: ${C}`),u.info(`message_id: ${D}`);let I=_["body-html"]||_["body-plain"]||"";if(I&&I.includes("<")&&(I=(0,hc.convert)(I)),u.info(`Body: ${I.substring(0,200)}...`),i.from_email&&!T.toLowerCase().includes(i.from_email.toLowerCase())||i.to_email&&!$.toLowerCase().includes(i.to_email.toLowerCase())||i.subject&&!E.toLowerCase().includes(i.subject.toLowerCase())||i.body_contains&&!I.toLowerCase().includes(i.body_contains.toLowerCase()))continue;l.push({subject:E,from:T,to:$,date:C,body:I,message_id:D});continue}else u.warn(`Messages API returned ${x.status}`)}catch(x){u.warn(`Failed to parse JSON response: ${x}`)}}try{let m=await fetch(w,{method:"GET",headers:{Authorization:s}});if(!m.ok){u.warn(`Could not fetch stored message: ${m.status}`);continue}let x=await m.text();u.info(`Fallback: Raw email length: ${x.length}`);let _=x.split(`
|
package/dist/cjs/reporter.cjs
CHANGED
|
@@ -883,7 +883,7 @@
|
|
|
883
883
|
});
|
|
884
884
|
</script>
|
|
885
885
|
</body>
|
|
886
|
-
</html>`}var Ce=N(require("fs"),1),oe=N(require("path"),1),Fe=require("glob");function Ot(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 Lt(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 Ne(e,t){let r=e[t];return typeof r=="number"?r:0}function It(e,t,r,i){return`${e}\0${t}\0${r}\0${i}`}function De(e,t={}){let r=t.routing??"proxy",i=t.providerOf??Ot,n=new Map;for(let o of e??[]){let l=Lt(o);if(l)for(let p of o.tokenUsages??[]){let u=p.model??"unknown",y=i(u),b=It(l,y,u,r),c=n.get(b);c||(c={operation:l,provider:y,model:u,routing:r,calls:0,input_tokens:0,output_tokens:0,thinking_tokens:0,cache_read_tokens:0},n.set(b,c)),c.calls+=1,c.input_tokens+=p.prompt_tokens||0,c.output_tokens+=p.completion_tokens||0,c.thinking_tokens+=Ne(p,"thinking_tokens"),c.cache_read_tokens+=Ne(p,"cache_read_tokens")}}return{by_operation:Array.from(n.values()).sort((o,l)=>o.operation!==l.operation?o.operation.localeCompare(l.operation):o.provider!==l.provider?o.provider.localeCompare(l.provider):o.model.localeCompare(l.model))}}function Nt(){let e=process.env.SHIPLIGHT_USAGE_ROUTING;return e==="proxy"||e==="byok"||e==="custom_endpoint"?e:"proxy"}function We(e){let t=oe.join(e,"test-results"),r;try{r=(0,Fe.globSync)("**/ai-actions.json",{cwd:t})}catch{return}if(r.length===0)return;let i=[];for(let a of r)try{let o=JSON.parse(Ce.readFileSync(oe.join(t,a),"utf-8"));Array.isArray(o)&&i.push(...o)}catch{}if(i.length===0)return;let n=De(i,{routing:Nt()});return n.by_operation.length>0?n:void 0}var Re="0.1.
|
|
886
|
+
</html>`}var Ce=N(require("fs"),1),oe=N(require("path"),1),Fe=require("glob");function Ot(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 Lt(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 Ne(e,t){let r=e[t];return typeof r=="number"?r:0}function It(e,t,r,i){return`${e}\0${t}\0${r}\0${i}`}function De(e,t={}){let r=t.routing??"proxy",i=t.providerOf??Ot,n=new Map;for(let o of e??[]){let l=Lt(o);if(l)for(let p of o.tokenUsages??[]){let u=p.model??"unknown",y=i(u),b=It(l,y,u,r),c=n.get(b);c||(c={operation:l,provider:y,model:u,routing:r,calls:0,input_tokens:0,output_tokens:0,thinking_tokens:0,cache_read_tokens:0},n.set(b,c)),c.calls+=1,c.input_tokens+=p.prompt_tokens||0,c.output_tokens+=p.completion_tokens||0,c.thinking_tokens+=Ne(p,"thinking_tokens"),c.cache_read_tokens+=Ne(p,"cache_read_tokens")}}return{by_operation:Array.from(n.values()).sort((o,l)=>o.operation!==l.operation?o.operation.localeCompare(l.operation):o.provider!==l.provider?o.provider.localeCompare(l.provider):o.model.localeCompare(l.model))}}function Nt(){let e=process.env.SHIPLIGHT_USAGE_ROUTING;return e==="proxy"||e==="byok"||e==="custom_endpoint"?e:"proxy"}function We(e){let t=oe.join(e,"test-results"),r;try{r=(0,Fe.globSync)("**/ai-actions.json",{cwd:t})}catch{return}if(r.length===0)return;let i=[];for(let a of r)try{let o=JSON.parse(Ce.readFileSync(oe.join(t,a),"utf-8"));Array.isArray(o)&&i.push(...o)}catch{}if(i.length===0)return;let n=De(i,{routing:Nt()});return n.by_operation.length>0?n:void 0}var Re="0.1.92",Be=Re!=="dev"?Re:void 0;var Mn=3600*1e3,Pn=10080*60*1e3;var Dt={before:0,main:1,teardown:2,after:3};function Ge(e){let t=e.split(".")[0];return Dt[t]??1}function Ue(e){return e.split(".").map(t=>{let r=Number(t);return Number.isNaN(r)?0:r})}function Ct(e){return[...e].sort(([t],[r])=>{let i=Ge(t),n=Ge(r);if(i!==n)return i-n;let a=Ue(t),o=Ue(r);for(let l=0;l<Math.max(a.length,o.length);l++){let p=a[l]??-1,u=o[l]??-1;if(p!==u)return p-u}return 0})}function Ft(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 Wt(e,t){let r=e.toLowerCase();return r.includes("before")?"before":r.includes("after")?"after":t}function ae(e,t="main",r,i,n){r===void 0&&(r=!Ft(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 p=Wt(o.title,t);a.push(...ae(o.steps,p,r,i,n));continue}if(o.category==="test.step"||r&&(o.category==="expect"||o.category==="pw:api")){let p=n.get(t)??0;n.set(t,p+1);let u=`${t}.${p}`,y={stepId:u,description:o.title,status:o.error?"failure":o.duration===-1?"skipped":"success",duration:o.duration>=0?o.duration:void 0};o.error&&(y.error=o.error.message??o.error.stack),i&&o.location&&i.set(u,o.location),a.push(y),o.steps.length>0&&a.push(...ae(o.steps,u,r,i,n))}}return a}function Rt(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)}`)}}var se=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})}async onEnd(t){if(this.collected.length===0)return;let r=new Map;for(let u of this.collected){let y=u.test.titlePath().join(" > "),b=r.get(y);b||(b=[],r.set(y,b)),b.push(u)}let i=[];for(let[,u]of r.entries()){let y=u[0].test.location.file,b=[],c,d,m;for(let w=0;w<u.length;w++){let{test:_,result:T}=u[w],$=await this.buildReportTest(_,T,y);c=$,d||(d=$.startTime),m=$.endTime,b.push({attemptNumber:w+1,status:T.status,duration:T.duration,steps:$.steps,error:$.error,videoPath:$.videoPath,tracePath:$.tracePath})}let f=b[b.length-1],{test:S}=u[u.length-1],g={title:S.title,baseTitle:c?.baseTitle,file:v.relative(process.cwd(),y),status:f.status,duration:f.duration,steps:f.steps,error:f.error,videoPath:f.videoPath,tracePath:f.tracePath,actionStepsMap:c?.actionStepsMap,tags:c?.tags,baseUrl:c?.baseUrl,skip:c?.skip,slow:c?.slow,timeout:c?.timeout,parameterSetName:c?.parameterSetName,startTime:d,endTime:m,suiteName:c?.suiteName};b.length>1&&(g.retries=b.length-1,g.attempts=b,b.some(_=>_.status==="failed"||_.status==="timedOut")&&f.status==="passed"&&(g.flaky=!0)),i.push(g)}let n={tests:i,totalDuration:t.duration,timestamp:new Date().toISOString(),shiplightVersion:Be,usageSummary:We(process.cwd())},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 y=n.tests[u],b=y.attempts&&y.attempts.length>0,c=[{obj:y,prefix:b?`test-${u}-attempt-0`:`test-${u}`,screenshotSubDir:`test-${u}`}];if(y.attempts)for(let d=0;d<y.attempts.length;d++)c.push({obj:y.attempts[d],prefix:`test-${u}-attempt-${d+1}`,screenshotSubDir:`test-${u}/attempt-${d}`});for(let{obj:d,prefix:m,screenshotSubDir:f}of c){let S=v.join(o,f),g=!1;for(let w of d.steps)if(w.screenshot&&v.isAbsolute(w.screenshot))try{g||(x.mkdirSync(S,{recursive:!0}),g=!0);let _=`${w.stepId.replace(/\./g,"-")}.png`;x.copyFileSync(w.screenshot,v.join(S,_)),w.screenshot=`screenshots/${f}/${_}`}catch(_){console.warn(`[reporter] Failed to copy screenshot for ${w.stepId}:`,_)}if(d.videoPath&&v.isAbsolute(d.videoPath)){let w=v.extname(d.videoPath)||".webm",_=`${m}-video${w}`;try{x.copyFileSync(d.videoPath,v.join(a,_)),d.videoPath=_}catch{d.videoPath=void 0}}if(d.tracePath&&v.isAbsolute(d.tracePath)){let w=v.extname(d.tracePath)||".zip",_=`${m}-trace${w}`;try{x.copyFileSync(d.tracePath,v.join(a,_)),d.tracePath=_}catch{d.tracePath=void 0}}}}let l=v.join(a,"report-data.json");x.writeFileSync(l,JSON.stringify(n,null,2),"utf-8");let p=v.join(a,"index.html");if(x.writeFileSync(p,Ie({...n,outputDir:a}),"utf-8"),console.log(`
|
|
887
887
|
Shiplight report written to: ${p}`),this.latestSymlinkDir&&Rt(this.latestSymlinkDir,v.basename(a)),this.openMode==="always"||this.openMode==="on-failure"&&t.status!=="passed")try{let u=(await import("open")).default;await u(p)}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(c=>c.message||c.stack||String(c)).join(`
|
|
888
888
|
|
|
889
889
|
`)),r.stdout.length>0&&(n.stdout=r.stdout.map(c=>typeof c=="string"?c:c.toString()).join("")),r.stderr.length>0&&(n.stderr=r.stderr.map(c=>typeof c=="string"?c:c.toString()).join(""));for(let c of r.attachments)c.name==="video"&&c.path&&(n.videoPath=c.path),c.name==="trace"&&c.path&&(n.tracePath=c.path);let a=r.attachments.find(c=>c.name==="shiplight-results"),o=null;if(a)try{if(a.body)o=JSON.parse(a.body.toString("utf-8"));else if(a.path){let c=x.readFileSync(a.path,"utf-8");o=JSON.parse(c)}}catch{}let l=i.replace(/\.yaml\.spec\.ts$/,".test.yaml"),p={},u=t.title.match(/^(.*)\s+\[([^\]]+)\]$/),y=u?u[1]:t.title,b=u?u[2]:void 0;if(b&&(n.parameterSetName=b),x.existsSync(l))try{let c=x.readFileSync(l,"utf-8"),d=Me(c,l,this.config.rootDir);if(d.suite){let m=d.suite.tests.find(f=>f.name===y);m&&(p=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=d.name,d.tags?.length&&(n.suiteTags=d.tags),d.use?.baseURL&&(n.baseUrl=d.use.baseURL)}else d.testFlow&&(p=z(d.testFlow),n.baseTitle=d.name||d.testFlow?.goal,d.tags?.length&&(n.tags=d.tags),d.use?.baseURL&&(n.baseUrl=d.use.baseURL))}catch{}if(o||Object.keys(p).length>0){let c=new Set([...Object.keys(p),...Object.keys(o||{})]),d=Array.from(c).map(f=>[f,null]),m=Ct(d);for(let[f]of m){let S=p[f],g=o?.[f],w=S?.description;if(!w||w==="Action"||w==="Draft"){let T=S?.action_entity;w=T?.action_description||T?.action_data?.kwargs?.description||g?.description||f}let _={stepId:f,description:w,status:g?.status||"pending",duration:g?.duration};if(g?.message){let T=typeof g.message=="string"?g.message:JSON.stringify(g.message,null,2);g.status==="failure"?_.error=T:_.message=T}if(g?.screenshot){let T=g.screenshot,$=a?.path?v.dirname(a.path):"",L=v.isAbsolute(T)?T:v.join($,T);x.existsSync(L)&&(_.screenshot=L)}g?.code&&(_.code=g.code),g?.type&&(_.type=g.type),g?.startTime&&(_.startTime=g.startTime),g?.autoHealed&&(_.autoHealed=g.autoHealed),g?.healedAction&&(_.healedAction=g.healedAction),g?.dismissedModalActions?.length&&(_.dismissedModalActions=g.dismissedModalActions),g?.contextBefore&&(_.contextBefore=g.contextBefore),g?.contextAfter&&(_.contextAfter=g.contextAfter),n.steps.push(_)}}if(o===null&&Object.keys(p).length===0&&!i.endsWith(".yaml.spec.ts")){let c=new Map;if(n.steps=ae(r.steps,"main",void 0,c),n.steps.length>0){let d=new Map;n.actionStepsMap=Object.fromEntries(n.steps.map(m=>{let f=c.get(m.stepId),S;if(f?.file){if(!d.has(f.file))try{d.set(f.file,x.readFileSync(f.file,"utf-8").split(`
|