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/index.js
CHANGED
|
@@ -4096,7 +4096,7 @@ Based on the above information, please determine if the statement is true.
|
|
|
4096
4096
|
return (async () => {
|
|
4097
4097
|
${a}
|
|
4098
4098
|
})();
|
|
4099
|
-
`)(e,o)}transpile(e){let t=this.generateFunctionCallCode(e.action_data?.kwargs||{});return t?[t.endsWith(";")?t:`${t};`]:["// Skipping function: missing functionName"]}generateFunctionCallCode(e){let t=e.functionName;if(!t)return null;let i;if(Array.isArray(e.args))i=e.args.map(String);else if(Array.isArray(e.parameterNames)){let r=e.parameterValues||[];i=e.parameterNames.map((s,l)=>l<r.length?String(r[l]):"undefined")}else return`await ${t}()`;if(i.length===0)return`await ${t}()`;let n=["page","testContext","request","agent"],a=["undefined","null","true","false"],o=i.map(r=>n.includes(r)||a.includes(r)||/^-?\d+(\.\d+)?$/.test(r)?r:r.startsWith("$")?`agent.agentServices.readVariable('${r.substring(1)}')`:`"${r}"`);return`await ${t}(${o.join(", ")})`}}});var un=v(()=>{"use strict";ut()});var Zr,pt=v(()=>{"use strict";Zr=(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))(Zr||{})});var mt={};St(mt,{evaluateStatement:()=>wt,executeAction:()=>Ut,executeStep:()=>ft,generateActionStep:()=>Bt,runTask:()=>bt});var gt=v(()=>{"use strict";Gt();en();Zi();ct();Gi();Ki();ji();nt();Vi();Ue();Ji();Nt();Lt();Me();Ot();un();Xe();Dt();ut();Rt();Ft();Wt();ae();dt();_e();Mt();ot();It();We();at();q();ze();U();te();pt();B();be()});import{z as Qr}from"zod";var es,jx,hn=v(()=>{"use strict";es=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.statement;if(!a)throw new Error("Missing statement for ai_step");let{runTask:o}=await Promise.resolve().then(()=>(gt(),mt)),r=await o(a,e,i);if(r.status!=="success")throw new Error(r.error||"Task execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;return i?[`await agent.run(page, ${JSON.stringify(i)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]}},jx=Qr.object({statement:Qr.string().describe('The complete step to execute (e.g., "fill in the login form and submit")')})});var ts,pn=v(()=>{"use strict";B();P();ts=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");if(typeof n.kwargs.relative_x=="number"&&typeof n.kwargs.relative_y=="number"){let a=N(e,t);if(a){await a.waitFor({state:"attached",timeout:L(i,t.action_data?.kwargs?.timeout_ms)});let o=await a.boundingBox();if(o){let r=o.x+n.kwargs.relative_x+o.width/2,s=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.move(r,s),await e.waitForTimeout(200),await e.mouse.click(r,s),await e.waitForTimeout(500)}}else throw new Error("Element-anchored coordinates provided but no locator found")}else if(typeof n.kwargs.x=="number"&&typeof n.kwargs.y=="number")await e.mouse.move(n.kwargs.x,n.kwargs.y),await e.waitForTimeout(200),await e.mouse.click(n.kwargs.x,n.kwargs.y),await e.waitForTimeout(500);else throw new Error("Missing or invalid coordinates")}transpile(e){let t=e.action_data?.kwargs||{},i=[];return typeof t.relative_x=="number"&&typeof t.relative_y=="number"?(i.push(`action_data: { kwargs: { relative_x: ${t.relative_x}, relative_y: ${t.relative_y} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`)):typeof t.x=="number"&&typeof t.y=="number"&&i.push(`action_data: { kwargs: { x: ${t.x}, y: ${t.y} } }`),['await agent.execAction("click_by_coordinates", page, {',...i.map(n=>` ${n},`),"});"]}}});import{z as is}from"zod";var ns,qx,mn=v(()=>{"use strict";ns=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.statement;if(!a)throw new Error("Missing statement for ai_action");let o=n.kwargs.use_pure_vision,{executeStep:r}=await Promise.resolve().then(()=>(gt(),mt)),s=await r(a,e,i,{usePureVision:o});if(s.status!=="success")throw new Error(s.error||"Action execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;if(!i)return["// Skipping ai_action: missing statement"];let n=JSON.stringify(i),a=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${n}, '${t||""}', ${a});`]}},qx=is.object({statement:is.string().describe('The action to perform (e.g., "click the submit button")')})});import{z as as}from"zod";function rs(e,t){e.register({name:"switch_tab",description:"Switch to a different browser tab by index (0-based).",schema:zu,async execute(i,n){let a=i.tab_index,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Switch to tab ${a}`,action_data:{action_name:"switch_tab",kwargs:{page_id:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Switched to tab ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Switch to tab ${a}`)+" (failed)",action_data:{action_name:"switch_tab",kwargs:{page_id:a}},feedback:l.message}}}}})}var os,zu,jt=v(()=>{"use strict";os=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.page_id??n.kwargs.tab_index??0;if(typeof a=="number"){let o=e.context().pages(),r=a===-1?o.length-1:a;if(i){let s=await i.switchTab(r);await s.waitForLoadState("load",{timeout:15e3}).catch(()=>{}),await s.waitForTimeout(500)}}else throw new Error("Missing page_id for switch_tab action")}transpile(e){return['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]}},zu=as.object({tab_index:as.number().int().nonnegative().describe("Index of the tab to switch to (0-based). Use 0 for first tab, 1 for second, etc.")})});import Vu from"fs";import Xu from"path";async function ss(e,t,i,n,a,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=n.testDataDir||process.cwd();return Xu.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 gn(e,d,s,c);return}if(i.selector&&typeof i.selector=="string"){let d=i.selector,h=(d.startsWith("xpath="),e.locator(d));await gn(e,h,s,c);return}if(a){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 a(e,h,o)}else throw new Error("No selector provided and AI action execution is not available")}async function gn(e,t,i,n){let{useFileInput:a,timeout:o,mockShowOpenFilePicker:r}=n;if(r){u.info("Using mockShowOpenFilePicker approach");let s=i.map(l=>({path:l,buffer:new Uint8Array(Vu.readFileSync(l))}));await e.evaluate(l=>{window.__pw_showOpenFilePicker_mock_files=l},s),await t.click({timeout:o}),await e.waitForTimeout(3e3),await e.evaluate(()=>{delete window.__pw_showOpenFilePicker_mock_files})}else if(a)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 Kt=v(()=>{"use strict";U()});import{z as oe}from"zod";async function Ju(e,t,i={},n){return{...await H(t,e),action_description:n||"Upload file to element",action_data:{action_name:"upload_file",kwargs:{...i}}}}function ls(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 ds(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:Yu,usesElementIndex:!0,async execute(i,n){let{element_index:a,paths:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=await z(n,a);if(!c)return{success:!1,error:`File input element with index ${a} not found`,actionEntity:ls(l||`Upload file to element ${a}`,{index:a,paths:o})};let d=await Ju(c,r,{paths:o},l);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Uploaded file to element ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:ls(l||`Upload file to element ${a}`,{index:a,paths:o})}}}})}var cs,Yu,uv,zt=v(()=>{"use strict";Kt();q();B();P();cs=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=[];if(n.kwargs.paths?a=Array.isArray(n.kwargs.paths)?n.kwargs.paths:[n.kwargs.paths]:n.kwargs.path&&(a=Array.isArray(n.kwargs.path)?n.kwargs.path:[n.kwargs.path]),a.length===0)throw new Error("No file paths provided for upload_file action");await i.downloadTestDataFiles(a);let o=a.map(c=>i.getTestDataFilePath(c)),r=N(e,t);if(!r)throw new Error("Missing locator for upload_file action");let s=n.kwargs.use_file_input||!1,l=i.getActionSettings().mock_show_open_file_picker??!1;await gn(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=[],n={};return t.paths?n.paths=t.paths:t.path&&(n.path=t.path),t.use_file_input&&(n.use_file_input=!0),i.push(`action_data: { kwargs: ${JSON.stringify(n)} }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...i.map(a=>` ${a},`),"});"]}};Yu=oe.object({element_index:oe.number().int().describe("Index of the target element to trigger the file upload dialog"),paths:oe.union([oe.string(),oe.array(oe.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:oe.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")});uv=oe.object({element_index:oe.number().int().describe("Index of the file input element"),paths:oe.union([oe.string(),oe.array(oe.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:oe.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});import{z as us}from"zod";function ps(e,t){e.register({name:"wait",description:"Wait for a specified number of seconds before continuing.",schema:qu,async execute(i,n){let{seconds:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Wait ${a} seconds`,action_data:{action_name:"wait",kwargs:{seconds:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Waited ${a} seconds`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Wait ${a} seconds`)+" (failed)",action_data:{action_name:"wait",kwargs:{seconds:a}},feedback:l.message}}}}})}var hs,qu,Vt=v(()=>{"use strict";hs=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.seconds||1;await e.waitForTimeout(n*1e3)}transpile(e){return[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]}},qu=us.object({seconds:us.number().positive().describe("Number of seconds to wait")})});import{z as ms}from"zod";function fs(e,t){e.register({name:"wait_for_download_complete",description:"Wait for an in-progress download to complete.",schema:Zu,async execute(i,n){let{timeout_seconds:a=10}=i,{page:o,agentServices:r}=n;try{let s={action_description:`Wait for download to complete (timeout: ${a}s)`,action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:"Download completed"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Wait for download to complete (failed)",action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:a}},feedback:s.message}}}}})}var gs,Zu,Xt=v(()=>{"use strict";gs=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.timeout_seconds||10;await i.waitForDownloadComplete(e,a)}transpile(e){return['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]}},Zu=ms.object({timeout_seconds:ms.number().positive().optional().describe("Maximum time in seconds to wait for download to complete (default: 10)")})});import{z as S}from"zod";import"yaml";import"uuid";import"uuid";import"yaml";function $a(e,t){if(!e||typeof e!="string")return e;let i=t instanceof Map?Object.fromEntries(t):t,n=o=>{let r=o.startsWith("$")?o.slice(1):o,s=i[r]??i[`$${r}`];return s!=null?String(s):void 0},a=e;return a=a.replace(/\{\{\s*\$?([^}]+?)\s*\}\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/<secret>\$?([\w-]+)<\/secret>/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a=a.replace(/\$\{([^}]+)\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/\$([a-zA-Z_]\w*)/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a}var wn,bs,vv,ys,Qu,eh,fn,_v,kv,yt,bn,xs,th,ws,ih,Jt,nh,ah,oh,ce,rh,sh,Ev,Dv,Bv,Pe=v(()=>{"use strict";be();wn=(e=>(e.JS_CODE="JS_CODE",e.AI_MODE="AI_MODE",e))(wn||{}),bs=112,vv=1080-bs,ys=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(ys||{}),Qu={"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"}},eh={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"]},fn=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),eh[e].map(n=>Qu[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},_v={desktop:{label:"Desktop",type:"desktop",devices:fn("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:fn("mobile")}},kv={desktop:{label:"Desktop",type:"desktop",devices:fn("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:fn("mobile",!0)}},yt=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(yt||{}),bn=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(bn||{}),xs=class vs{constructor(){ha(this,"data",{}),ha(this,"sensitive",new Set)}get(t){return this.data[t]}set(t,i,n=!1){this.data[t]=i,n?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,n]of Object.entries(t.getAll()))this.set(i,n,t.isSensitive(i))}toJSON(){return{data:{...this.data},sensitiveKeys:Array.from(this.sensitive)}}static fromJSON(t){let i=new vs;if(t.data){let n=new Set(t.sensitiveKeys||[]);for(let[a,o]of Object.entries(t.data))i.set(a,o,n.has(a))}return i}},th=S.enum(["JS_CODE","AI_MODE"]),ws=S.object({type:th,expression:S.string()}),ih=S.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),Jt=S.object({uid:S.string(),type:ih,comment:S.string().optional()}),nh=S.object({action_data:S.object({action_name:S.string(),kwargs:S.record(S.any()).optional(),args:S.array(S.any()).optional()}),action_description:S.string().optional(),url:S.string().optional(),xpath:S.string().nullable().optional(),locator:S.string().nullable().optional(),css_selector:S.string().nullable().optional(),unique_selector:S.string().nullable().optional(),element_index:S.number().nullable().optional(),frame_path:S.array(S.any()).optional(),artifacts:S.record(S.any()).optional(),feedback:S.string().optional(),original_browser_use_action:S.any().optional()}).passthrough(),ah=Jt.extend({type:S.literal("DRAFT"),description:S.string()}),oh=Jt.extend({type:S.literal("ACTION"),description:S.string(),action_entity:nh.optional(),locator:S.string().optional(),use_pure_vision:S.boolean().optional()}),ce=S.lazy(()=>S.union([ah,oh,Jt.extend({type:S.literal("STEP"),description:S.string().optional().default(""),statements:S.array(ce),reference_id:S.number().optional(),template_path:S.string().optional(),template_params:S.record(S.string()).optional()}),Jt.extend({type:S.literal("IF_ELSE"),description:S.string().optional(),condition:ws,then:S.array(ce),else:S.array(ce).optional()}),Jt.extend({type:S.literal("WHILE_LOOP"),description:S.string().optional(),condition:ws,body:S.array(ce),timeout_ms:S.number().optional()})])),rh=S.object({name:S.string(),statements:S.array(ce),teardown:S.array(ce).optional(),skip:S.union([S.boolean(),S.string()]).optional(),timeout:S.number().optional(),fail:S.union([S.boolean(),S.string()]).optional(),only:S.boolean().optional(),slow:S.boolean().optional()}),sh=S.object({tests:S.array(rh).min(1),beforeAll:S.array(ce).optional(),afterAll:S.array(ce).optional(),beforeEach:S.array(ce).optional(),afterEach:S.array(ce).optional()}),Ev=S.object({comment:S.string().optional(),version:S.string().optional(),goal:S.string().optional(),url:S.string().optional(),baseURL:S.string().optional(),final_feedback:S.string().optional(),completed:S.boolean().optional(),success:S.boolean().optional(),statements:S.array(ce).optional(),teardown:S.array(ce).optional(),last_modified_at:S.string().optional(),testGroup:sh.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"}),Dv=1024*1024,Bv=Object.freeze(["anthropic:claude-sonnet-5","google:gemini-3.1-pro-preview"])});var Je=v(()=>{"use strict"});async function hh(e,t){let i=new Set,n=Date.now(),a=new Set(["document","stylesheet","image","font","script","iframe"]),o=new Set(["text/html","text/css","application/javascript","image/","font/","application/json"]),r=["analytics","tracking","telemetry","beacon","metrics","doubleclick","adsystem","adserver","advertising","facebook.com/plugins","platform.twitter","linkedin.com/embed","livechat","zendesk","intercom","crisp.chat","hotjar","push-notifications","onesignal","pushwoosh","heartbeat","ping","alive","webrtc","rtmp://","wss://","cloudfront.net","fastly.net"],s=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(!a.has(p)||s(g))return;let w=h.headers();w.purpose==="prefetch"||["video","audio"].includes(w["sec-fetch-dest"])||(i.add(h),n=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),n=Date.now()},d=Date.now()-uh;for(let h of await e.requests()){let p=h.resourceType(),g=h.url(),w=h.timing();a.has(p)&&!s(g)&&w.responseEnd===-1&&w.startTime>=d&&(i.add(h),n=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=dh;for(;;){await new Promise(w=>setTimeout(w,100));let g=Date.now();if(i.size===0&&g-n>=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 Ce(e,t=ch,i=lh){let n=Date.now();try{await Promise.all([e.waitForLoadState("load",{timeout:t}).catch(()=>{}),hh(e,t)])}catch(r){throw r instanceof Error?new Error(`Failed during network stabilization: ${r.message}`):new Error("An unknown error occurred during network stabilization.")}let a=Date.now()-n,o=Math.max(i-a,0);o>0&&await new Promise(r=>setTimeout(r,o))}var lh,ch,dh,uh,Se=v(()=>{"use strict";Je();U();lh=.5*1e3,ch=30*1e3,dh=1*1e3,uh=3*1e3});async function ks(e,t=3e3,i=1e3){try{await Ce(e,t,i)}catch{}}async function Ss(e,t,i){let n=i*1e3,a=100,o=Date.now();for(;!t.downloadStatus||t.downloadStatus.status==="inProgress";){if(Date.now()-o>n){let r;throw t.downloadStatus?r=`Timed out after ${n}ms waiting for download to complete`:r="No download in progress or completed",u.error(r),new Error(r)}await e.waitForTimeout(a)}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 Es(e,t,i,n=60,a){let o=Math.min(n,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,a))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 yn(e,t,i=60){let n=Math.min(i,300),a=250,o=Date.now()+n*1e3;u.info(`Waiting for JS condition (timeout: ${n}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(a)}}var xt=v(()=>{"use strict";Se();U()});import{z as Ma}from"zod";function As(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:ph,async execute(i,n){let{condition:a,timeout_seconds:o=60}=i,{page:r,agentServices:s}=n;try{let l={action_description:`Wait until: ${a}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:a,timeout_seconds:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Condition met: ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Wait until: ${a} (failed)`,action_data:{action_name:"ai_wait_until",kwargs:{condition:a,timeout_seconds:o}},feedback:l.message}}}}})}var Ts,ph,Yt=v(()=>{"use strict";ht();Pe();xt();Ts=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.condition;if(!a)throw new Error("Missing condition for ai_wait_until");let o=n.kwargs.timeout_seconds||60;if(n.kwargs.condition_type===wn.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 n=["page","testContext","request","agent"],a=["undefined","null","true","false"],o=i.map(r=>n.includes(r)||a.includes(r)||/^-?\d+(\.\d+)?$/.test(r)?r:r.startsWith("$")?`agent.agentServices.readVariable('${r.substring(1)}')`:`"${r}"`);return`await ${t}(${o.join(", ")})`}}});var un=v(()=>{"use strict";ut()});var Zr,pt=v(()=>{"use strict";Zr=(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))(Zr||{})});var mt={};St(mt,{evaluateStatement:()=>wt,executeAction:()=>Ut,executeStep:()=>ft,generateActionStep:()=>Bt,runTask:()=>bt});var gt=v(()=>{"use strict";Gt();en();Zi();ct();Gi();Ki();ji();nt();Vi();Ue();Ji();Nt();Lt();Me();Ot();un();Xe();Dt();ut();Rt();Ft();Wt();ae();dt();_e();Mt();ot();It();We();at();q();ze();U();te();pt();B();be()});import{z as Qr}from"zod";var es,jx,hn=v(()=>{"use strict";es=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.statement;if(!a)throw new Error("Missing statement for ai_step");let{runTask:o}=await Promise.resolve().then(()=>(gt(),mt)),r=await o(a,e,i);if(r.status!=="success")throw new Error(r.error||"Task execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;return i?[`await agent.run(page, ${JSON.stringify(i)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]}},jx=Qr.object({statement:Qr.string().describe('The complete step to execute (e.g., "fill in the login form and submit")')})});var ts,pn=v(()=>{"use strict";B();P();ts=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");if(typeof n.kwargs.relative_x=="number"&&typeof n.kwargs.relative_y=="number"){let a=N(e,t);if(a){await a.waitFor({state:"attached",timeout:L(i,t.action_data?.kwargs?.timeout_ms)});let o=await a.boundingBox();if(o){let r=o.x+n.kwargs.relative_x+o.width/2,s=o.y+n.kwargs.relative_y+o.height/2;await e.mouse.move(r,s),await e.waitForTimeout(200),await e.mouse.click(r,s),await e.waitForTimeout(500)}}else throw new Error("Element-anchored coordinates provided but no locator found")}else if(typeof n.kwargs.x=="number"&&typeof n.kwargs.y=="number")await e.mouse.move(n.kwargs.x,n.kwargs.y),await e.waitForTimeout(200),await e.mouse.click(n.kwargs.x,n.kwargs.y),await e.waitForTimeout(500);else throw new Error("Missing or invalid coordinates")}transpile(e){let t=e.action_data?.kwargs||{},i=[];return typeof t.relative_x=="number"&&typeof t.relative_y=="number"?(i.push(`action_data: { kwargs: { relative_x: ${t.relative_x}, relative_y: ${t.relative_y} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`)):typeof t.x=="number"&&typeof t.y=="number"&&i.push(`action_data: { kwargs: { x: ${t.x}, y: ${t.y} } }`),['await agent.execAction("click_by_coordinates", page, {',...i.map(n=>` ${n},`),"});"]}}});import{z as is}from"zod";var ns,qx,mn=v(()=>{"use strict";ns=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.statement;if(!a)throw new Error("Missing statement for ai_action");let o=n.kwargs.use_pure_vision,{executeStep:r}=await Promise.resolve().then(()=>(gt(),mt)),s=await r(a,e,i,{usePureVision:o});if(s.status!=="success")throw new Error(s.error||"Action execution failed")}transpile(e,t){let i=e.action_data?.kwargs?.statement;if(!i)return["// Skipping ai_action: missing statement"];let n=JSON.stringify(i),a=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${n}, '${t||""}', ${a});`]}},qx=is.object({statement:is.string().describe('The action to perform (e.g., "click the submit button")')})});import{z as as}from"zod";function rs(e,t){e.register({name:"switch_tab",description:"Switch to a different browser tab by index (0-based).",schema:zu,async execute(i,n){let a=i.tab_index,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Switch to tab ${a}`,action_data:{action_name:"switch_tab",kwargs:{page_id:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Switched to tab ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Switch to tab ${a}`)+" (failed)",action_data:{action_name:"switch_tab",kwargs:{page_id:a}},feedback:l.message}}}}})}var os,zu,jt=v(()=>{"use strict";os=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.page_id??n.kwargs.tab_index??0;if(typeof a=="number"){let o=e.context().pages(),r=a===-1?o.length-1:a;if(i){let s=await i.switchTab(r);await s.waitForLoadState("load",{timeout:15e3}).catch(()=>{}),await s.waitForTimeout(500)}}else throw new Error("Missing page_id for switch_tab action")}transpile(e){return['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]}},zu=as.object({tab_index:as.number().int().nonnegative().describe("Index of the tab to switch to (0-based). Use 0 for first tab, 1 for second, etc.")})});import Vu from"fs";import Xu from"path";async function ss(e,t,i,n,a,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=n.testDataDir||process.cwd();return Xu.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 gn(e,d,s,c);return}if(i.selector&&typeof i.selector=="string"){let d=i.selector,h=(d.startsWith("xpath="),e.locator(d));await gn(e,h,s,c);return}if(a){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 a(e,h,o)}else throw new Error("No selector provided and AI action execution is not available")}async function gn(e,t,i,n){let{useFileInput:a,timeout:o,mockShowOpenFilePicker:r}=n;if(r){u.info("Using mockShowOpenFilePicker approach");let s=i.map(l=>({path:l,buffer:new Uint8Array(Vu.readFileSync(l))}));await e.evaluate(l=>{window.__pw_showOpenFilePicker_mock_files=l},s),await t.click({timeout:o}),await e.waitForTimeout(3e3),await e.evaluate(()=>{delete window.__pw_showOpenFilePicker_mock_files})}else if(a)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 Kt=v(()=>{"use strict";U()});import{z as oe}from"zod";async function Ju(e,t,i={},n){return{...await H(t,e),action_description:n||"Upload file to element",action_data:{action_name:"upload_file",kwargs:{...i}}}}function ls(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 ds(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:Yu,usesElementIndex:!0,async execute(i,n){let{element_index:a,paths:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=await z(n,a);if(!c)return{success:!1,error:`File input element with index ${a} not found`,actionEntity:ls(l||`Upload file to element ${a}`,{index:a,paths:o})};let d=await Ju(c,r,{paths:o},l);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Uploaded file to element ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:ls(l||`Upload file to element ${a}`,{index:a,paths:o})}}}})}var cs,Yu,uv,zt=v(()=>{"use strict";Kt();q();B();P();cs=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=[];if(n.kwargs.paths?a=Array.isArray(n.kwargs.paths)?n.kwargs.paths:[n.kwargs.paths]:n.kwargs.path&&(a=Array.isArray(n.kwargs.path)?n.kwargs.path:[n.kwargs.path]),a.length===0)throw new Error("No file paths provided for upload_file action");await i.downloadTestDataFiles(a);let o=a.map(c=>i.getTestDataFilePath(c)),r=N(e,t);if(!r)throw new Error("Missing locator for upload_file action");let s=n.kwargs.use_file_input||!1,l=i.getActionSettings().mock_show_open_file_picker??!1;await gn(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=[],n={};return t.paths?n.paths=t.paths:t.path&&(n.path=t.path),t.use_file_input&&(n.use_file_input=!0),i.push(`action_data: { kwargs: ${JSON.stringify(n)} }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...i.map(a=>` ${a},`),"});"]}};Yu=oe.object({element_index:oe.number().int().describe("Index of the target element to trigger the file upload dialog"),paths:oe.union([oe.string(),oe.array(oe.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:oe.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")});uv=oe.object({element_index:oe.number().int().describe("Index of the file input element"),paths:oe.union([oe.string(),oe.array(oe.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:oe.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});import{z as us}from"zod";function ps(e,t){e.register({name:"wait",description:"Wait for a specified number of seconds before continuing.",schema:qu,async execute(i,n){let{seconds:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Wait ${a} seconds`,action_data:{action_name:"wait",kwargs:{seconds:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Waited ${a} seconds`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Wait ${a} seconds`)+" (failed)",action_data:{action_name:"wait",kwargs:{seconds:a}},feedback:l.message}}}}})}var hs,qu,Vt=v(()=>{"use strict";hs=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.seconds||1;await e.waitForTimeout(n*1e3)}transpile(e){return[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]}},qu=us.object({seconds:us.number().positive().describe("Number of seconds to wait")})});import{z as ms}from"zod";function fs(e,t){e.register({name:"wait_for_download_complete",description:"Wait for an in-progress download to complete.",schema:Zu,async execute(i,n){let{timeout_seconds:a=10}=i,{page:o,agentServices:r}=n;try{let s={action_description:`Wait for download to complete (timeout: ${a}s)`,action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:a}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:"Download completed"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Wait for download to complete (failed)",action_data:{action_name:"wait_for_download_complete",kwargs:{timeout_seconds:a}},feedback:s.message}}}}})}var gs,Zu,Xt=v(()=>{"use strict";gs=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.timeout_seconds||10;await i.waitForDownloadComplete(e,a)}transpile(e){return['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]}},Zu=ms.object({timeout_seconds:ms.number().positive().optional().describe("Maximum time in seconds to wait for download to complete (default: 10)")})});import{z as S}from"zod";import"yaml";import"uuid";import"uuid";import"yaml";function $a(e,t){if(!e||typeof e!="string")return e;let i=t instanceof Map?Object.fromEntries(t):t,n=o=>{let r=o.startsWith("$")?o.slice(1):o,s=i[r]??i[`$${r}`];return s!=null?String(s):void 0},a=e;return a=a.replace(/\{\{\s*\$?([^}]+?)\s*\}\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/<secret>\$?([\w-]+)<\/secret>/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a=a.replace(/\$\{([^}]+)\}/g,(o,r)=>{let s=n(r.trim());return s!==void 0?s:o}),a=a.replace(/\$([a-zA-Z_]\w*)/g,(o,r)=>{let s=n(r);return s!==void 0?s:o}),a}var wn,yt,bn,bs,vv,ys,Qu,eh,fn,_v,kv,xs,th,ws,ih,Jt,nh,ah,oh,ce,rh,sh,Ev,Dv,Bv,Pe=v(()=>{"use strict";be();wn=(e=>(e.JS_CODE="JS_CODE",e.AI_MODE="AI_MODE",e))(wn||{}),yt=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(yt||{}),bn=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(bn||{}),bs=112,vv=1080-bs,ys=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(ys||{}),Qu={"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"}},eh={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"]},fn=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),eh[e].map(n=>Qu[n]).filter(n=>n.defaultBrowserType&&i.includes(n.defaultBrowserType))},_v={desktop:{label:"Desktop",type:"desktop",devices:fn("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:fn("mobile")}},kv={desktop:{label:"Desktop",type:"desktop",devices:fn("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:fn("mobile",!0)}},xs=class vs{constructor(){ha(this,"data",{}),ha(this,"sensitive",new Set)}get(t){return this.data[t]}set(t,i,n=!1){this.data[t]=i,n?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,n]of Object.entries(t.getAll()))this.set(i,n,t.isSensitive(i))}toJSON(){return{data:{...this.data},sensitiveKeys:Array.from(this.sensitive)}}static fromJSON(t){let i=new vs;if(t.data){let n=new Set(t.sensitiveKeys||[]);for(let[a,o]of Object.entries(t.data))i.set(a,o,n.has(a))}return i}},th=S.enum(["JS_CODE","AI_MODE"]),ws=S.object({type:th,expression:S.string()}),ih=S.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),Jt=S.object({uid:S.string(),type:ih,comment:S.string().optional()}),nh=S.object({action_data:S.object({action_name:S.string(),kwargs:S.record(S.any()).optional(),args:S.array(S.any()).optional()}),action_description:S.string().optional(),url:S.string().optional(),xpath:S.string().nullable().optional(),locator:S.string().nullable().optional(),css_selector:S.string().nullable().optional(),unique_selector:S.string().nullable().optional(),element_index:S.number().nullable().optional(),frame_path:S.array(S.any()).optional(),artifacts:S.record(S.any()).optional(),feedback:S.string().optional(),original_browser_use_action:S.any().optional()}).passthrough(),ah=Jt.extend({type:S.literal("DRAFT"),description:S.string()}),oh=Jt.extend({type:S.literal("ACTION"),description:S.string(),action_entity:nh.optional(),locator:S.string().optional(),use_pure_vision:S.boolean().optional()}),ce=S.lazy(()=>S.union([ah,oh,Jt.extend({type:S.literal("STEP"),description:S.string().optional().default(""),statements:S.array(ce),reference_id:S.number().optional(),template_path:S.string().optional(),template_params:S.record(S.string()).optional()}),Jt.extend({type:S.literal("IF_ELSE"),description:S.string().optional(),condition:ws,then:S.array(ce),else:S.array(ce).optional()}),Jt.extend({type:S.literal("WHILE_LOOP"),description:S.string().optional(),condition:ws,body:S.array(ce),timeout_ms:S.number().optional()})])),rh=S.object({name:S.string(),statements:S.array(ce),teardown:S.array(ce).optional(),skip:S.union([S.boolean(),S.string()]).optional(),timeout:S.number().optional(),fail:S.union([S.boolean(),S.string()]).optional(),only:S.boolean().optional(),slow:S.boolean().optional()}),sh=S.object({tests:S.array(rh).min(1),beforeAll:S.array(ce).optional(),afterAll:S.array(ce).optional(),beforeEach:S.array(ce).optional(),afterEach:S.array(ce).optional()}),Ev=S.object({comment:S.string().optional(),version:S.string().optional(),goal:S.string().optional(),url:S.string().optional(),baseURL:S.string().optional(),final_feedback:S.string().optional(),completed:S.boolean().optional(),success:S.boolean().optional(),statements:S.array(ce).optional(),teardown:S.array(ce).optional(),last_modified_at:S.string().optional(),testGroup:sh.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"}),Dv=1024*1024,Bv=Object.freeze(["anthropic:claude-sonnet-5","google:gemini-3.1-pro-preview"])});var Je=v(()=>{"use strict"});async function hh(e,t){let i=new Set,n=Date.now(),a=new Set(["document","stylesheet","image","font","script","iframe"]),o=new Set(["text/html","text/css","application/javascript","image/","font/","application/json"]),r=["analytics","tracking","telemetry","beacon","metrics","doubleclick","adsystem","adserver","advertising","facebook.com/plugins","platform.twitter","linkedin.com/embed","livechat","zendesk","intercom","crisp.chat","hotjar","push-notifications","onesignal","pushwoosh","heartbeat","ping","alive","webrtc","rtmp://","wss://","cloudfront.net","fastly.net"],s=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(!a.has(p)||s(g))return;let w=h.headers();w.purpose==="prefetch"||["video","audio"].includes(w["sec-fetch-dest"])||(i.add(h),n=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),n=Date.now()},d=Date.now()-uh;for(let h of await e.requests()){let p=h.resourceType(),g=h.url(),w=h.timing();a.has(p)&&!s(g)&&w.responseEnd===-1&&w.startTime>=d&&(i.add(h),n=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=dh;for(;;){await new Promise(w=>setTimeout(w,100));let g=Date.now();if(i.size===0&&g-n>=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 Ce(e,t=ch,i=lh){let n=Date.now();try{await Promise.all([e.waitForLoadState("load",{timeout:t}).catch(()=>{}),hh(e,t)])}catch(r){throw r instanceof Error?new Error(`Failed during network stabilization: ${r.message}`):new Error("An unknown error occurred during network stabilization.")}let a=Date.now()-n,o=Math.max(i-a,0);o>0&&await new Promise(r=>setTimeout(r,o))}var lh,ch,dh,uh,Se=v(()=>{"use strict";Je();U();lh=.5*1e3,ch=30*1e3,dh=1*1e3,uh=3*1e3});async function ks(e,t=3e3,i=1e3){try{await Ce(e,t,i)}catch{}}async function Ss(e,t,i){let n=i*1e3,a=100,o=Date.now();for(;!t.downloadStatus||t.downloadStatus.status==="inProgress";){if(Date.now()-o>n){let r;throw t.downloadStatus?r=`Timed out after ${n}ms waiting for download to complete`:r="No download in progress or completed",u.error(r),new Error(r)}await e.waitForTimeout(a)}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 Es(e,t,i,n=60,a){let o=Math.min(n,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,a))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 yn(e,t,i=60){let n=Math.min(i,300),a=250,o=Date.now()+n*1e3;u.info(`Waiting for JS condition (timeout: ${n}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(a)}}var xt=v(()=>{"use strict";Se();U()});import{z as Ma}from"zod";function As(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:ph,async execute(i,n){let{condition:a,timeout_seconds:o=60}=i,{page:r,agentServices:s}=n;try{let l={action_description:`Wait until: ${a}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:a,timeout_seconds:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Condition met: ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Wait until: ${a} (failed)`,action_data:{action_name:"ai_wait_until",kwargs:{condition:a,timeout_seconds:o}},feedback:l.message}}}}})}var Ts,ph,Yt=v(()=>{"use strict";ht();Pe();xt();Ts=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.condition;if(!a)throw new Error("Missing condition for ai_wait_until");let o=n.kwargs.timeout_seconds||60;if(n.kwargs.condition_type===wn.JS_CODE){let d=new Function("page","expect","agent",`
|
|
4100
4100
|
return (async () => (${a}))();
|
|
4101
4101
|
`);if(!await yn(e,()=>d(e,Ge.expect,i.agent),o))throw new Error(`Timeout waiting for condition: ${a}`);return}let r=o*1e3,s=5e3,l=Date.now(),{evaluateStatement:c}=await Promise.resolve().then(()=>(gt(),mt));for(;Date.now()-l<r;){if((await c(a,e,i,{})).success)return;await e.waitForTimeout(s)}throw new Error(`Timeout waiting for condition: ${a}`)}transpile(e,t){let i=e.action_data?.kwargs?.condition,n=e.action_data?.kwargs?.timeout_seconds||60;return i?e.action_data?.kwargs?.condition_type===wn.JS_CODE?[`await agent.waitForJs(page, async () => (${i}), ${n}, '${t}');`]:[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${n}, '${t}');`]:["// Skipping ai_wait_until: missing condition"]}},ph=Ma.object({condition:Ma.string().describe('The condition to wait for (e.g., "the loading spinner disappears")'),timeout_seconds:Ma.number().positive().optional().describe("Timeout in seconds (default: 60)")})});import{z as Ia}from"zod";function Ms(e,t){e.register({name:"save_variable",description:"Save a value to a named variable for later use in the test.",schema:mh,async execute(i,n){let{name:a,value:o}=i,{page:r,agentServices:s}=n;try{let l={action_description:`Save variable "${a}" = "${o}"`,action_data:{action_name:"save_variable",kwargs:{name:a,value:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Saved variable "${a}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Save variable "${a}" (failed)`,action_data:{action_name:"save_variable",kwargs:{name:a,value:o}},feedback:l.message}}}}})}var $s,mh,qt=v(()=>{"use strict";$s=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.name,o=n.kwargs.value;if(!a||o===void 0)throw new Error("Missing variable name or value for save_variable");a.startsWith("$")&&(a=a.slice(1)),i.saveVariable(a,o)}transpile(e){let t=e.action_data?.kwargs?.name||"",i=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(i)} } },`,"});"]}},mh=Ia.object({name:Ia.string().describe("Variable name to save"),value:Ia.string().describe("Value to save in the variable")})});import{z as Pa}from"zod";async function gh(e,t,i={}){return{action_description:t,action_data:{action_name:e,kwargs:{...i}}}}function fh(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Scroll failed!"}}function Is(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:wh,async execute(i,n){let{down:a,num_pages:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=l||`Scroll ${a?"down":"up"} ${o} page(s)`,d=await gh("scroll",c,{down:a,num_pages:o});return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Scrolled ${a?"down":"up"} ${o} page(s)`}}catch(c){return{success:!1,error:c.message,actionEntity:fh(l||`Scroll ${a?"down":"up"} ${o} page(s)`,"scroll",{down:a,num_pages:o})}}}})}var Zt,wh,Qt=v(()=>{"use strict";Zt=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.down??!0,a=i.kwargs.num_pages??1,o=n?1:-1;await e.evaluate(`window.scrollBy(0, window.innerHeight * ${a} * ${o})`)}transpile(e){let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]}};wh=Pa.object({down:Pa.boolean().describe("True to scroll down, False to scroll up"),num_pages:Pa.number().nonnegative().describe("Number of pages to scroll (0.5 = half page, 1.0 = one page, etc.)")})});import{z as ei}from"zod";async function bh(e,t,i,n,a={}){return{...await H(n,i),action_description:t,action_data:{action_name:e,kwargs:{...a}}}}function Ps(e,t,i){return{action_description:`${e} (failed)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function Os(e,t){e.register({name:"scroll_on_element",description:"Scroll on a scrollable element horizontally and vertically.",schema:yh,usesElementIndex:!0,async execute(i,n){let{element_index:a,delta_x:o,delta_y:r}=i,{page:s,agentServices:l}=n;try{let c=await z(n,a);if(!c)return{success:!1,error:`Element with index ${a} not found`,actionEntity:Ps(`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:a,delta_x:o,delta_y:r})};let d=await bh("scroll_on_element",`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,c,s,{delta_x:o,delta_y:r});return await t.execute(s,d,l),{success:!0,actionEntity:d,message:`Scrolled on element ${a} horizontally: ${o}px, vertically: ${r}px`}}catch(c){return{success:!1,error:c.message,actionEntity:Ps(`Scroll on element ${a} horizontally: ${o}px, vertically: ${r}px`,"scroll_on_element",{index:a,delta_x:o,delta_y:r})}}}})}var Cs,yh,ti=v(()=>{"use strict";q();B();P();Cs=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.delta_x||0,o=n.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(a,o);else throw new Error("No locator found for scroll_on_element action")}transpile(e){let t=He(e);if(!t){let a=e.action_data?.kwargs?.delta_x||0,o=e.action_data?.kwargs?.delta_y||0;return['await agent.execAction("scroll_on_element", page, {',` action_data: { kwargs: { delta_x: ${a}, delta_y: ${o} } },`,"});"]}let i=e.action_data?.kwargs?.delta_x||0,n=e.action_data?.kwargs?.delta_y||0;return[`await ${t}.hover({ timeout: ${L()} });`,`await page.mouse.wheel(${i}, ${n});`]}};yh=ei.object({element_index:ei.number().int().describe("Index of the scrollable element"),delta_x:ei.number().optional().describe("The number of pixels to scroll horizontally. Positive values scroll right, negative values scroll left."),delta_y:ei.number().optional().describe("The number of pixels to scroll vertically. Positive values scroll down, negative values scroll up."),timeout_ms:ei.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});import{z as Ls}from"zod";function Ds(e,t){e.register({name:"scroll_to_text",description:"Scroll the page until specified text becomes visible.",schema:xh,async execute(i,n){let{text:a}=i,{page:o,agentServices:r,actionDescription:s}=n;try{let l={action_description:s||`Scroll to text "${a}"`,action_data:{action_name:"scroll_to_text",kwargs:{text:a}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Scrolled to text "${a}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Scroll to text "${a}"`)+" (failed)",action_data:{action_name:"scroll_to_text",kwargs:{text:a}},feedback:l.message}}}}})}var Ns,xh,ii=v(()=>{"use strict";Ns=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.text;if(n)await e.getByText(n,{exact:!1}).first().scrollIntoViewIfNeeded(),await e.waitForTimeout(500);else throw new Error("Missing text for scroll_to_text action")}transpile(e){let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]}},xh=Ls.object({text:Ls.string().describe("Text to scroll to on the page")})});import{z as xn}from"zod";async function vh(e,t,i,n){return{...await H(t,e),action_description:n||`Select option "${i}"`,action_data:{action_name:"select_dropdown_option",kwargs:{text:i}}}}function Rs(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 Hs(e,t){e.register({name:"select_dropdown_option",description:"Select an option from a dropdown/select element by value, label, or index.",schema:_h,usesElementIndex:!0,async execute(i,n){let{element_index:a,option:o}=i,{page:r,agentServices:s,actionDescription:l}=n;try{let c=await z(n,a);if(!c)return{success:!1,error:`Dropdown element with index ${a} not found`,actionEntity:Rs(l||`Select option in dropdown ${a}`,{index:a,option:o})};let d=await vh(c,r,o,l);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Selected option "${o}" in dropdown ${a}`}}catch(c){return{success:!1,error:c.message,actionEntity:Rs(`Select option in dropdown ${a}`,{index:a,option:o})}}}})}var Fs,_h,ni=v(()=>{"use strict";q();B();P();Fs=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let a=n.kwargs.text||n.kwargs.option,o=N(e,t),r=L(i,t.action_data?.kwargs?.timeout_ms);if(o&&a)await o.selectOption(a,{timeout:r});else throw new Error("Missing locator or option label for select_dropdown_option action")}transpile(e){let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"",i=[];return i.push(`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("select_dropdown_option", page, {',...i.map(n=>` ${n},`),"});"]}};_h=xn.object({element_index:xn.number().int().describe("Index of the dropdown/select element"),option:xn.string().describe("Option value, label, or index to select"),timeout_ms:xn.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});import{z as vn}from"zod";async function kh(e,t,i,n){return{...await H(i,t),action_description:e,action_data:{action_name:"set_date_for_native_date_picker",kwargs:{date:n}}}}function Ca(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"set_date_for_native_date_picker",kwargs:t},feedback:"Element not found in DOM"}}function Us(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 Uc(e,t){let i=[],n=t?.version||"unknown";i.push(`// @generated by shiplightai v${n}`),i.push(...Co()),i.push(""),t?.use&&Object.keys(t.use).length>0&&(i.push(`test.use(${JSON.stringify(t.use,null,2)});`),i.push(""));let a=new Set,o={imports:a,actionEntityStore:t?.actionEntityStore,yamlDir:t?.yamlDir,projectRoot:t?.projectRoot},r=t?.testName||"Test Suite",s=Xn(t?.tags);i.push(`test.describe.serial('${s}${fe(r)}', () => {`),e.beforeAll&&e.beforeAll.length>0&&(i.push(...Mi("beforeAll",e.beforeAll,o,1)),i.push("")),e.beforeEach&&e.beforeEach.length>0&&(i.push(...Mi("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(...Ci(d.testFlow,`${fe(d.name)} [${fe(p.name)}]`,o,1,h,p.name,p.values)),i.push("");else i.push(...Ci(d.testFlow,fe(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(...Mi("afterEach",e.afterEach,o,1)),i.push("")),e.afterAll&&e.afterAll.length>0&&i.push(...Mi("afterAll",e.afterAll,o,1)),i.push("});"),Oo(i,a),i.join(`
|
|
4368
4368
|
`)}function Xn(e){return e&&e.length>0?e.map(t=>`@${t}`).join(" ")+" ":""}var Bc=["testContext","request"];function Pi(e){let t=new Set;function i(n){for(let a of n)switch(a.type){case he.ACTION:{let r=a.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"&&Bc.includes(l)&&t.add(l);break}case he.STEP:i(a.statements);break;case he.IF_ELSE:{let o=a;i(o.then),o.else&&i(o.else);break}case he.WHILE_LOOP:i(a.body);break}}return i(e),t}function Gc(e){let t=Pi(e.statements??[]);if(e.teardown)for(let i of Pi(e.teardown))t.add(i);return t}function Zn(e){return`{ ${["page","agent",...Array.from(e).sort()].join(", ")} }`}function Ci(e,t,i,n=0,a,o,r){let s=" ".repeat(n),l=[],c=Gc(e),d=Zn(c),h=a?.only?"test.only":"test",p=o?`, { tag: '@${fe(o)}' }`:"";if(l.push(`${s}${h}('${t}'${p}, async (${d}) => {`),a?.skip===!0?l.push(`${s} test.skip();`):typeof a?.skip=="string"&&l.push(`${s} test.skip(true, '${fe(a.skip)}');`),a?.fail===!0?l.push(`${s} test.fail();`):typeof a?.fail=="string"&&l.push(`${s} test.fail(true, '${fe(a.fail)}');`),a?.slow&&l.push(`${s} test.slow();`),a?.timeout&&l.push(`${s} test.setTimeout(${a.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=n+1;if(g){if(l.push(`${s} try {`),e.statements&&e.statements.length>0){l.push(`${s} // Test steps`);let b=we(e.statements,w+1,i);l.push(...b)}l.push(`${s} } finally {`),l.push(`${s} // Teardown`);let y=we(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=we(e.statements,w,i);l.push(...y)}return l.push(`${s}});`),l}function Ao(e,t,i){let n=[],a=Po(t),o=Pi(a),r=Zn(o);return n.push(`test.${e}(async (${r}) => {`),n.push(...we(a,1,i,e)),n.push("});"),n}function Mi(e,t,i,n){let a=" ".repeat(n),o=[],r=Po(t);if(e==="beforeAll"||e==="afterAll"){let l={...i,noAgent:!0};o.push(`${a}test.${e}(async ({ browser }, workerInfo) => {`),o.push(`${a} const page = await browser.newPage({ baseURL: workerInfo.project.use.baseURL });`),o.push(...we(r,n+1,l,e)),o.push(`${a} await page.close();`),o.push(`${a}});`)}else{let l=Pi(r),c=Zn(l);o.push(`${a}test.${e}(async (${c}) => {`),o.push(...we(r,n+1,i,e)),o.push(`${a}});`)}return o}function Po(e){let i=Tc({goal:"_hook",statements:e});return Ae(i).statements??[]}function Co(){return["import { test, expect } from 'shiplightai/fixture';"]}function Oo(e,t){if(t.size>0){let i=0;for(let a=0;a<e.length;a++)e[a].startsWith("import ")&&(i=a+1);let n=Array.from(t);e.splice(i,0,...n)}}var Mo=5;function No(e,t,i){let n={expandingPaths:new Set([Jn(t)]),depth:0,referencedPaths:new Set,basePath:i},a={...e};Array.isArray(a.statements)&&(a.statements=Fe(a.statements,t,n)),Array.isArray(a.teardown)&&(a.teardown=Fe(a.teardown,t,n));for(let o of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(a[o])&&(a[o]=Fe(a[o],t,n));return{doc:a,referencedTemplatePaths:Array.from(n.referencedPaths)}}function Fe(e,t,i){let n=[];for(let a of e)if(Yc(a)){let o=qc(a,t,i);n.push(o)}else n.push(Zc(a,t,i));return n}function Yc(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function qc(e,t,i){if(i.depth>=Mo)throw new Error(`Template expansion exceeded maximum depth of ${Mo}. Check for deeply nested or circular template references.`);let n=Jn(Xc(t),e.template),a=!Vc(n)&&i.basePath?Jn(i.basePath,e.template):n;if(i.expandingPaths.has(a))throw new Error(`Circular template reference detected: ${a} is already being expanded. Stack: ${Array.from(i.expandingPaths).join(" \u2192 ")} \u2192 ${a}`);i.referencedPaths.add(a);let o;try{o=zc(a,"utf-8")}catch(w){throw new Error(`Failed to read template file: ${a} (referenced from ${t}): ${w.message}`)}let r=$o(o);if(!r||typeof r!="object")throw new Error(`Invalid template file: ${a} \u2014 expected a YAML object`);let s=r.params||[],l=e.params||{};for(let w of s)if(!(w in l))throw new Error(`Template ${e.template} requires param "${w}" but it was not provided. Required params: [${s.join(", ")}]`);let c=r.statements;if(!Array.isArray(c))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(l).length>0){let y=Jc(c);for(let[b,m]of Object.entries(l))y=y.split(`<<${b}>>`).join(String(m));c=$o(y)}let d={expandingPaths:new Set([...i.expandingPaths,a]),depth:i.depth+1,referencedPaths:i.referencedPaths},h=Fe(c,a,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 Zc(e,t,i){if(typeof e!="object"||e===null)return e;let n={...e};return Array.isArray(n.statements)&&(n.statements=Fe(n.statements,t,i)),Array.isArray(n.THEN)&&(n.THEN=Fe(n.THEN,t,i)),Array.isArray(n.ELSE)&&(n.ELSE=Fe(n.ELSE,t,i)),Array.isArray(n.DO)&&(n.DO=Fe(n.DO,t,i)),n}var Qn=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}};function ea(e,t,i){let n=Kc(e),a=n?.name,o=n?.tags,r=n?.use;if(n&&(n.name!==void 0||n.tags!==void 0||n.use!==void 0)&&(delete n.name,delete n.tags,delete n.use),n?.suite){if(n.goal||n.statements)throw new Qn('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return ed(n,a,o,r,t,i)}return Qc(n,a,o,r,t,i)}function Qc(e,t,i,n,a,o){let r=e?.beforeEach,s=e?.afterEach,l=Do(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 Qn(`The "url" field is not supported in local YAML tests. Use "base_url: ${e.url}" and add "- URL: /" as the first statement instead.`);e&&!e.goal&&t&&(e.goal=t);let w=[];if(a&&e&&typeof e=="object"){let m=No(e,a,o);e=m.doc,w=m.referencedTemplatePaths}let y=Lo(e),b=Ae(y);return a&&(it(b.statements??[],a,"main"),b.teardown&&it(b.teardown,a,"teardown")),{testFlow:b,name:t,tags:i,use:n,beforeEach:r,afterEach:s,parameters:l,timeout:c,skip:d,fail:h,only:p,slow:g,referencedTemplatePaths:w}}function ed(e,t,i,n,a,o){let r=e.suite;if(!Array.isArray(r.tests)||r.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let s=r.beforeAll,l=r.afterAll,c=r.beforeEach,d=r.afterEach,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(a&&typeof b=="object"){let $=No(b,a,o);x=$.doc,m=$.referencedTemplatePaths,h.push(...m)}let _=Lo(x),E=Ae(_),T=Do(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?{...n,baseURL:g}:n;return{suite:{beforeAll:s,afterAll:l,beforeEach:c,afterEach:d,tests:p},name:t,tags:i,use:w,referencedTemplatePaths:h}}function Do(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 it(e,t,i){for(let n=0;n<e.length;n++){let a=e[n],o=`${i}.${n}`,r=a.description||"";if(a.uid=td(t,o,r),a.type===he.STEP)it(a.statements,t,o);else if(a.type===he.IF_ELSE){let s=a;it(s.then,t,`${o}.then`),s.else&&it(s.else,t,`${o}.else`)}else a.type===he.WHILE_LOOP&&it(a.body,t,`${o}.body`)}}function td(e,t,i){let n=jc("sha256").update(`${e}:${t}:${i}`).digest("hex");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20,32)}`}function Ro(e,t,i){let n=/\btemplate:\s/.test(e),a=/^suite:/m.test(e),o=n||a?null:jn(e);if(o&&!o.valid)return{valid:!1,errors:o.errors,warnings:[],stats:o.stats};let r,s,l=[];try{let c=i?.parsed??ea(e,t,i?.basePath);l=c.referencedTemplatePaths;let d={version:i?.version,actionEntityStore:i?.actionEntityStore,yamlDir:Io(t),projectRoot:i?.projectRoot??i?.basePath},h=c.testFlow?.baseURL?{...c.use,baseURL:c.testFlow.baseURL}:c.use;c.suite?r=Uc(c.suite,{...d,testName:c.name,tags:c.tags,use:c.use}):r=Wc(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"),nd(Io(s),{recursive:!0}),id(s,r)}catch(c){let d=c instanceof Qn?"":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 ta="0.1.
|
|
4370
|
+
`);new Function(p),s=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),nd(Io(s),{recursive:!0}),id(s,r)}catch(c){let d=c instanceof Qn?"":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 ta="0.1.92";function Fo(e){try{return ad(e).mtimeMs}catch{return 0}}var sd=`// @generated by shiplightai v${ta}`;function ld(e,t){if(!Wo(e)||Ho(e,"utf-8").split(`
|
|
4371
4371
|
`,1)[0]!==sd)return!1;let n=Fo(e);for(let a of t)if(Fo(a)>n)return!1;return!0}function cd(e,t=process.argv.slice(2)){let i=[],n=ia(e);for(let a of t){if(a.startsWith("-"))continue;let o=a.endsWith(".yaml.spec.ts")?a.replace(/\.yaml\.spec\.ts$/,".test.yaml"):a;if(!o.endsWith(".test.yaml"))continue;let r=ia(e,o);Wo(r)&&i.push(r.startsWith(n)?r.slice(n.length+1):o)}return i.length>0?i:null}function Uo(e){let t=cd(e.cwd),i=t??rd("**/*.test.yaml",{cwd:e.cwd,ignore:["**/node_modules/**"]}),n=[];for(let a of i){let o=ia(e.cwd,a),r=o.replace(/\.test\.yaml$/,".yaml.spec.ts"),s=Ho(o,"utf-8");try{let l=ea(s,o,e.projectRoot??e.cwd),c=od(e.cwd,o),d=e.actionEntityStores?.get(c)??e.actionEntityStores?.get("*");if(!(d&&Object.keys(d.entries).length>0)&&ld(r,[o,...l.referencedTemplatePaths]))continue;let p=Ro(s,o,{version:ta,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 ${a}:`,l),n.push({file:a,error:l})}}if(n.length>0){let a=`[shiplight] Transpilation failed for ${n.length} file(s):
|
|
4372
4372
|
`+n.map(o=>` - ${o.file}`).join(`
|
|
4373
4373
|
`);if(t)throw new Error(a);console.warn(a+" (skipped)")}}import*as se from"fs";import*as Tt from"path";import{globSync as kd}from"glob";Ni();function qo(e){let t=Li().SHIPLIGHT_API_TOKEN;return process.env.CI&&t?new la:new sa(e)}var Sd=".shiplight/action-cache";function Yo(e){return e.replace(/\//g,"__")+".json"}function Ed(e){return e.replace(/\.json$/,"").replace(/__/g,"/")}var sa=class{constructor(t){this.cwd=t;this.cacheDir=Tt.join(t,Sd)}isCloud=!1;cacheDir;async lookup(t){let i=new Map;if(t.length===0||!se.existsSync(this.cacheDir))return i;for(let n of t){let a=Tt.join(this.cacheDir,Yo(n));try{if(se.existsSync(a)){let o=se.readFileSync(a,"utf-8");i.set(n,JSON.parse(o))}}catch{}}return i}async update(t){if(t.size===0)return 0;se.mkdirSync(this.cacheDir,{recursive:!0});let i=0;for(let[n,a]of t)try{let o=Tt.join(this.cacheDir,Yo(n)),r=Kn();if(se.existsSync(o))try{r=JSON.parse(se.readFileSync(o,"utf-8"))}catch{}let s={...r,entries:{...r.entries,...a.entries}};se.writeFileSync(o,JSON.stringify(s,null,2)),i++}catch{}return i}loadAll(){if(!se.existsSync(this.cacheDir))return;let t=kd("*.json",{cwd:this.cacheDir});if(t.length===0)return;let i=new Map,n=0;for(let a of t)try{let o=se.readFileSync(Tt.join(this.cacheDir,a),"utf-8"),r=JSON.parse(o),s=Ed(a);i.set(s,r),n+=Object.keys(r.entries??{}).length}catch{}if(i.size!==0)return console.log(`[shiplight] Cache: loaded ${n} cached action entit${n===1?"y":"ies"} for ${i.size} test file${i.size!==1?"s":""}`),i}},la=class{isCloud=!0;async lookup(t){let{lookupActionStores:i}=await Promise.resolve().then(()=>(ra(),oa));return i(t)}async update(t){let{updateActionStores:i}=await Promise.resolve().then(()=>(ra(),oa));return i(t)}loadAll(){}};Ni();function $d(e,t,i){let n=t.SHIPLIGHT_PROJECT_ROOT||i;return{scanDir:e.scanDir||n,projectRoot:n}}function Md(e={}){let{scanDir:t,projectRoot:i}=$d(e,process.env,process.cwd());e.dotenv!==!1&&Cd(t);let a=qo(t).loadAll();Uo({cwd:t,projectRoot:i,actionEntityStores:a});let o=process.env.SHIPLIGHT_REPORT_DIR,r=process.env.SHIPLIGHT_RUN_ID??Id();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 Id(){let e=new Date,t=(i,n=2)=>String(i).padStart(n,"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 Pd(e,...t){return Ad(e,...t)}function Cd(e){Go(e);for(let t of na(e))Td.config({path:t})}U();U();Gt();ct();import{z as Pl}from"zod";var up=Pl.object({instruction:Pl.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 Cl(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:up,usesElementIndex:!1,async execute(t,i){let{instruction:n}=t,a={page:i.page,agentServices:i.agentServices,domService:i.domService},o=await lt(n,a,{});if(o.status==="error"||!o.actionEntity)return{success:!1,actionEntity:{action_description:n,action_data:{action_name:"perform_accurate_operation",kwargs:{instruction:n}}},error:o.error||"Failed to generate action"};let{actionEntity:r}=o,s=await Ut(r,a);return{success:s.success,actionEntity:r,message:s.success?`Successfully executed action: ${r.action_data?.action_name}`:void 0,error:s.error}}})}_e();U();import{generateText as hp}from"ai";import{convert as pp}from"html-to-text";async function mp(e,t,i){let{apiKey:n,domain:a}=e;if(!n)throw new Error("Mailgun configuration missing. Please provide apiKey and domain");let o=!!e.baseURL,r=e.baseURL||"https://api.mailgun.net",s=e.authHeader||`Basic ${Buffer.from(`api:${n}`).toString("base64")}`,l=[];try{let c=o?`${r}/events`:`${r}/v3/${a}/events`,d={event:"accepted",limit:"10",ascending:"yes",recipient:t};if(i.from_email&&(d.from=i.from_email),i.since)d.begin=Math.floor(i.since/1e3).toString();else{let 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/${a}/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=pp(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/reporter.js
CHANGED
|
@@ -883,7 +883,7 @@ import*as x from"fs";import*as v from"path";var I=(e,t,r)=>{e.forEach((i,n)=>{le
|
|
|
883
883
|
});
|
|
884
884
|
</script>
|
|
885
885
|
</body>
|
|
886
|
-
</html>`}import*as Oe from"fs";import*as ee from"path";import{globSync as Tt}from"glob";function xt(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 kt(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 Me(e,t){let r=e[t];return typeof r=="number"?r:0}function At(e,t,r,i){return`${e}\0${t}\0${r}\0${i}`}function Pe(e,t={}){let r=t.routing??"proxy",i=t.providerOf??xt,n=new Map;for(let o of e??[]){let l=kt(o);if(l)for(let p of o.tokenUsages??[]){let u=p.model??"unknown",y=i(u),b=At(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+=Me(p,"thinking_tokens"),c.cache_read_tokens+=Me(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 $t(){let e=process.env.SHIPLIGHT_USAGE_ROUTING;return e==="proxy"||e==="byok"||e==="custom_endpoint"?e:"proxy"}function Le(e){let t=ee.join(e,"test-results"),r;try{r=Tt("**/ai-actions.json",{cwd:t})}catch{return}if(r.length===0)return;let i=[];for(let a of r)try{let o=JSON.parse(Oe.readFileSync(ee.join(t,a),"utf-8"));Array.isArray(o)&&i.push(...o)}catch{}if(i.length===0)return;let n=Pe(i,{routing:$t()});return n.by_operation.length>0?n:void 0}var Ie="0.1.
|
|
886
|
+
</html>`}import*as Oe from"fs";import*as ee from"path";import{globSync as Tt}from"glob";function xt(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 kt(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 Me(e,t){let r=e[t];return typeof r=="number"?r:0}function At(e,t,r,i){return`${e}\0${t}\0${r}\0${i}`}function Pe(e,t={}){let r=t.routing??"proxy",i=t.providerOf??xt,n=new Map;for(let o of e??[]){let l=kt(o);if(l)for(let p of o.tokenUsages??[]){let u=p.model??"unknown",y=i(u),b=At(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+=Me(p,"thinking_tokens"),c.cache_read_tokens+=Me(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 $t(){let e=process.env.SHIPLIGHT_USAGE_ROUTING;return e==="proxy"||e==="byok"||e==="custom_endpoint"?e:"proxy"}function Le(e){let t=ee.join(e,"test-results"),r;try{r=Tt("**/ai-actions.json",{cwd:t})}catch{return}if(r.length===0)return;let i=[];for(let a of r)try{let o=JSON.parse(Oe.readFileSync(ee.join(t,a),"utf-8"));Array.isArray(o)&&i.push(...o)}catch{}if(i.length===0)return;let n=Pe(i,{routing:$t()});return n.by_operation.length>0?n:void 0}var Ie="0.1.92",Ne=Ie!=="dev"?Ie:void 0;var Un=3600*1e3,Hn=10080*60*1e3;var Et={before:0,main:1,teardown:2,after:3};function De(e){let t=e.split(".")[0];return Et[t]??1}function Ce(e){return e.split(".").map(t=>{let r=Number(t);return Number.isNaN(r)?0:r})}function Mt(e){return[...e].sort(([t],[r])=>{let i=De(t),n=De(r);if(i!==n)return i-n;let a=Ce(t),o=Ce(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 Pt(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 Ot(e,t){let r=e.toLowerCase();return r.includes("before")?"before":r.includes("after")?"after":t}function te(e,t="main",r,i,n){r===void 0&&(r=!Pt(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=Ot(o.title,t);a.push(...te(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(...te(o.steps,u,r,i,n))}}return a}function Lt(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 re=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:A}=u[w],T=await this.buildReportTest(_,A,y);c=T,d||(d=T.startTime),m=T.endTime,b.push({attemptNumber:w+1,status:A.status,duration:A.duration,steps:T.steps,error:T.error,videoPath:T.videoPath,tracePath:T.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:Ne,usageSummary:Le(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,Ee({...n,outputDir:a}),"utf-8"),console.log(`
|
|
887
887
|
Shiplight report written to: ${p}`),this.latestSymlinkDir&&Lt(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=xe(c,l,this.config.rootDir);if(d.suite){let m=d.suite.tests.find(f=>f.name===y);m&&(p=U(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=U(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=Mt(d);for(let[f]of m){let S=p[f],g=o?.[f],w=S?.description;if(!w||w==="Action"||w==="Draft"){let A=S?.action_entity;w=A?.action_description||A?.action_data?.kwargs?.description||g?.description||f}let _={stepId:f,description:w,status:g?.status||"pending",duration:g?.duration};if(g?.message){let A=typeof g.message=="string"?g.message:JSON.stringify(g.message,null,2);g.status==="failure"?_.error=A:_.message=A}if(g?.screenshot){let A=g.screenshot,T=a?.path?v.dirname(a.path):"",O=v.isAbsolute(A)?A:v.join(T,A);x.existsSync(O)&&(_.screenshot=O)}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=te(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(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shiplightai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.92",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shiplight CLI for running and debugging .test.yaml files",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -98,13 +98,13 @@
|
|
|
98
98
|
"tsup": "^8.3.5",
|
|
99
99
|
"typescript": "5.5.4",
|
|
100
100
|
"mcp-tools": "1.0.0",
|
|
101
|
-
"sdk-core": "0.1.0",
|
|
102
101
|
"sdk-internal": "0.1.1",
|
|
103
102
|
"shiplight-tools": "1.0.0",
|
|
103
|
+
"sdk-core": "0.1.0",
|
|
104
104
|
"shiplight-types": "0.1.0"
|
|
105
105
|
},
|
|
106
106
|
"peerDependencies": {
|
|
107
|
-
"@playwright/test": "
|
|
107
|
+
"@playwright/test": "1.60.0"
|
|
108
108
|
},
|
|
109
109
|
"engines": {
|
|
110
110
|
"node": ">=22.0.0"
|