shiplightai 0.1.85 → 0.1.86
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 +13 -13
- package/dist/cjs/fixture.cjs +1 -8
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/reporter.cjs +23 -23
- package/dist/cli.js +96 -69
- package/dist/debugger-pw.js +12 -12
- package/dist/fixture.js +1 -8
- package/dist/index.js +3 -3
- package/dist/reporter.js +23 -23
- package/package.json +1 -1
package/dist/cjs/fixture.cjs
CHANGED
|
@@ -4104,7 +4104,7 @@ Do NOT use it for custom/non-native date pickers
|
|
|
4104
4104
|
|
|
4105
4105
|
The date must be in YYYY-MM-DD format (e.g., 2024-03-15).`,schema:Vm,usesElementIndex:!0,async execute(i,n){let{element_index:o,date:a}=i,{page:s,agentServices:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Date picker element with index ${o} not found`,actionEntity:ka(`Set date to ${a} on element ${o}`,{index:o,date:a})};let d=l.attributes.type;if(d!=="date")return{success:!1,error:`Element ${o} is not a native date picker (type="${d}"). This action only works with <input type="date">.`,actionEntity:ka(`Set date to ${a} on element ${o}`,{index:o,date:a})};let c=await zm(`Set date to ${a} on element ${o}`,l,s,a);return await t.execute(s,c,r),{success:!0,actionEntity:c,message:`Set date to ${a} on element ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:ka(`Set date to ${a} on element ${o}`,{index:o,date:a})}}}})}var _i,Gl,Vm,ki=w(()=>{"use strict";Q();B();_i=require("zod");C();Gl=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let o=n.kwargs.date;if(!o)throw new Error("Date value is required");if(!/^\d{4}-\d{2}-\d{2}$/.test(o))throw new Error(`Invalid date format: ${o}. Expected format: YYYY-MM-DD (e.g., 2024-03-15)`);let a=i.replaceVariables(String(o)),s=D(e,t);if(s){let r=await s.getAttribute("type").catch(()=>null);if(r&&r!=="date")throw new Error(`Element is not a native date picker (type="${r}"). This action only works with <input type="date">. For custom date pickers, use AI-powered actions.`);await s.fill(a,{timeout:L(i,t.action_data?.kwargs?.timeout_ms)})}else throw new Error("No locator found for set_date_for_native_date_picker action")}transpile(e){let t=e.action_data?.kwargs?.date??"",i=[];return i.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...i.map(n=>` ${n},`),"});"]}};Vm=_i.z.object({element_index:_i.z.number().int().describe("Index of the native date picker input element"),date:_i.z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Date in YYYY-MM-DD format (e.g., 2024-03-15)"),timeout_ms:_i.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function zl(e,t){e.register({name:"switch_tab",description:"Switch to a different browser tab by index (0-based).",schema:Xm,async execute(i,n){let o=i.tab_index,{page:a,agentServices:s,actionDescription:r}=n;try{let l={action_description:r||`Switch to tab ${o}`,action_data:{action_name:"switch_tab",kwargs:{page_id:o}}};return await t.execute(a,l,s),{success:!0,actionEntity:l,message:`Switched to tab ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(r||`Switch to tab ${o}`)+" (failed)",action_data:{action_name:"switch_tab",kwargs:{page_id:o}},feedback:l.message}}}}})}var Sa,Kl,Xm,Si=w(()=>{"use strict";Sa=require("zod"),Kl=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let o=n.kwargs.page_id??n.kwargs.tab_index??0;if(typeof o=="number"){let a=e.context().pages(),s=o===-1?a.length-1:o;if(i){let r=await i.switchTab(s);await r.waitForLoadState("load",{timeout:15e3}).catch(()=>{}),await r.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} } },`,"});"]}},Xm=Sa.z.object({tab_index:Sa.z.number().int().nonnegative().describe("Index of the tab to switch to (0-based). Use 0 for first tab, 1 for second, etc.")})});async function Ym(e,t,i,n,o={}){return{...await F(n,i),action_description:t,action_data:{action_name:e,kwargs:{...o}}}}function Vl(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function Xl(e,t){e.register({name:"input_text",description:"Type text into an input field. To replace existing content, use clear_input first.",schema:Jm,usesElementIndex:!0,async execute(i,n){let{element_index:o,text:a}=i,{page:s,agentServices:r,actionDescription:l}=n;try{let d=await V(n,o);if(!d)return{success:!1,error:`Input element with index ${o} not found`,actionEntity:Vl(l||`Input text to element ${o}`,"input_text",{index:o,text:a})};let c=l||`Input text to element ${o}`,h=await Ym("input_text",c,d,s,{text:a});return await t.execute(s,h,r),{success:!0,actionEntity:h,message:`Input text to element ${o}`}}catch(d){return{success:!1,error:d.message,actionEntity:Vl(`Input text to element ${o}`,"input_text",{index:o,text:a})}}}})}var Ei,Ea,Jm,Ti=w(()=>{"use strict";Q();B();Ei=require("zod");C();Ea=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let o=n.kwargs.text??n.kwargs.value??"",a=i.replaceVariables(String(o)),s=D(e,t),r=L(i,t.action_data?.kwargs?.timeout_ms);if(s){await s.evaluate(d=>{d.value&&(d.value="")},null,{timeout:r}),await s.click({timeout:r}),await e.waitForTimeout(200);let l=i.getActionSettings().type_delay;l!==void 0?await e.keyboard.type(a,{delay:l}):await e.keyboard.type(a)}else throw new Error("No locator found for input_text action")}transpile(e){let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"",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("input_text", page, {',...i.map(n=>` ${n},`),"});"]}};Jm=Ei.z.object({element_index:Ei.z.number().int().describe("Index of the input element"),text:Ei.z.string().describe("Text to type into the input. To use a placeholder, write {{ placeholder_name }} using exact placeholder name. Use clear_input first if you want to replace existing content."),timeout_ms:Ei.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Yl(e,t){e.register({name:"press",description:"Press a single keyboard key or key combination. Supports combinations like `Control+A` for select all. Does NOT support sequences - call this action multiple times to press keys in sequence.",schema:qm,async execute(i,n){let{keys:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l={action_description:r||`Press keys "${o}"`,action_data:{action_name:"press",kwargs:{keys:o}}};return await t.execute(a,l,s),{success:!0,actionEntity:l,message:`Pressed keys "${o}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(r||`Press keys "${o}"`)+" (failed)",action_data:{action_name:"press",kwargs:{keys:o}},feedback:l.message}}}}})}var Ta,Aa,qm,Ai=w(()=>{"use strict";Ta=require("zod"),Aa=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let n=i.kwargs.keys;if(!n||typeof n!="string")throw new Error("Missing or invalid keys for press action");await e.keyboard.press(n),await e.waitForTimeout(500)}transpile(e){let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]}},qm=Ta.z.object({keys:Ta.z.string().describe("A single key or key combination to press (e.g. Escape, Backspace, Insert, PageDown, Delete, Tab, Enter). Key combinations like `Control+o`, `Control+Shift+T`, `ControlOrMeta+a` are supported. Note: This does NOT support sequences - to press multiple keys in sequence (e.g., Control+A then Backspace), call this action multiple times.")})});function Zl(e,t){e.register({name:"reload_page",description:"Reload the current page. WARNING: This will reset any in-progress forms or multi-step flows (like login). Only use when you need to refresh stale data or clear a stuck state. Do NOT use during login, checkout, or form submission flows.",schema:Zm,async execute(i,n){let{page:o,agentServices:a}=n;try{let s={action_description:"Reload page",action_data:{action_name:"reload_page",kwargs:{}}};return await t.execute(o,s,a),{success:!0,actionEntity:s,message:`Reloaded ${o.url()}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Reload page (failed)",action_data:{action_name:"reload_page",kwargs:{}},feedback:s.message}}}}})}var Jl,ql,Zm,Mi=w(()=>{"use strict";B();Jl=require("zod");C();ql=class{async execute(e,t){await e.reload({timeout:Ae}),await e.waitForLoadState("load",{timeout:Ae}),await e.waitForTimeout(1e3)}transpile(e){return['await agent.execAction("reload_page", page, {});']}},Zm=Jl.z.object({})});async function Qm(e,t,i,n,o={}){return{...await F(n,i),action_description:t,action_data:{action_name:e,kwargs:{...o}}}}function Ql(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function ec(e,t){e.register({name:"right_click",description:"Right-click an interactive element.",schema:ep,usesElementIndex:!0,async execute(i,n){let{element_index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Element with index ${o} not found.`,actionEntity:Ql(`Right-click element ${o}`,"right_click",{index:o})};let d=r||`Right-click element ${o}`,c=await Qm("right_click",d,l,a);return await t.execute(a,c,s),{success:!0,actionEntity:c,message:`Right-clicked element ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:Ql(`Right-click element ${o}`,"right_click",{index:o})}}}})}var Xn,Ma,ep,Ii=w(()=>{"use strict";Q();B();Xn=require("zod");C();Ma=class{async execute(e,t,i){let n=D(e,t),o=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.click({button:"right",timeout:o});else throw new Error("No locator found for right_click action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("right_click", page, {});']:['await agent.execAction("right_click", page, {',...t.map(i=>` ${i},`),"});"]}};ep=Xn.z.object({element_index:Xn.z.number().int().describe("Index of the element to right-click"),timeout_ms:Xn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function ic(e,t){e.register({name:"generate_2fa_code",description:'Generate a 2FA code from an OTP secret key. The code is saved to the "otp_code" variable. To use the otp_code, you must use `$otp_code` to access it.',schema:tp,async execute(i,n){let{otp_secret_key:o}=i,{page:a,agentServices:s}=n;try{let r={action_description:"Generate 2FA code",action_data:{action_name:"generate_2fa_code",kwargs:{otp_secret_key:o}}};return await t.execute(a,r,s),{success:!0,actionEntity:r,message:'Generated 2FA code and saved to variable "otp_code"'}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:"Generate 2FA code (failed)",action_data:{action_name:"generate_2fa_code",kwargs:{otp_secret_key:o}},feedback:r.message}}}}})}var Ia,tc,tp,Pi=w(()=>{"use strict";Ia=require("zod"),tc=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let o=n.kwargs.otp_secret_key;if(!o)throw new Error("Missing otp_secret_key for generate_2fa_code");let a=i.replaceVariables(String(o)),s=await i.generate2faCode(a);i.saveVariable("otp_code",s)}transpile(e){let t=e.action_data?.kwargs?.otp_secret_key||"";return['await agent.execAction("generate_2fa_code", page, {',` action_data: { kwargs: { otp_secret_key: ${JSON.stringify(t)} } },`,"});"]}},tp=Ia.z.object({otp_secret_key:Ia.z.string().describe("The OTP secret key to generate the 2FA code from")})});async function ip(e,t,i){return{...await F(t,e),action_description:i||"Get dropdown options",action_data:{action_name:"get_dropdown_options",kwargs:{}}}}function nc(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"get_dropdown_options",kwargs:t},feedback:"Element not found in DOM"}}function ac(e,t){e.register({name:"get_dropdown_options",description:"Get all options from a native dropdown",schema:np,usesElementIndex:!0,async execute(i,n){let{element_index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Dropdown element with index ${o} not found`,actionEntity:nc(r||`Get options from dropdown ${o}`,{index:o})};let d=await ip(l,a,r);return await t.execute(a,d,s),{success:!0,actionEntity:d,message:d.feedback||"No options found"}}catch(l){return{success:!1,error:l.message,actionEntity:nc(r||`Get options from dropdown ${o}`,{index:o})}}}})}var Pa,oc,np,Ci=w(()=>{"use strict";Q();Pa=require("zod"),oc=class{async execute(e,t,i){if(!t.xpath)throw new Error("XPath not found in action entity");let n=[];for(let o of e.frames())try{let a=await o.evaluate(s=>{let r=document.evaluate(s,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return r?{options:Array.from(r.options).map(l=>({text:l.text,value:l.value,index:l.index})),id:r.id,name:r.name}:null},t.xpath);if(a){let s=[];for(let r of a.options){let l=JSON.stringify(r.text);s.push(`${r.index}: text=${l}`)}n.push(...s)}}catch{}if(n.length>0){let o=n.join(`
|
|
4106
4106
|
`);o+=`
|
|
4107
|
-
Use the exact text string in select_dropdown_option`,i.addNote(o)}else i.addNote("No options found in any frame for dropdown")}transpile(e){let t=[];return e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("get_dropdown_options", page, {});']:['await agent.execAction("get_dropdown_options", page, {',...t.map(i=>` ${i},`),"});"]}};np=Pa.z.object({element_index:Pa.z.number().int().describe("Index of the dropdown/select element")})});function lc(e,t){e.register({name:"go_back",description:"Navigate back to the previous page in browser history.",schema:op,async execute(i,n){let{page:o,agentServices:a,actionDescription:s}=n;try{let r={action_description:s||"Go back",action_data:{action_name:"go_back",kwargs:{}}};return await t.execute(o,r,a),{success:!0,actionEntity:r,message:"Navigated back"}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:(s||"Go back")+" (failed)",action_data:{action_name:"go_back",kwargs:{}},feedback:r.message}}}}})}var rc,sc,op,$i=w(()=>{"use strict";B();rc=require("zod");C();sc=class{async execute(e,t){await e.goBack({timeout:Ae}),await e.waitForLoadState("load",{timeout:Ae}),await e.waitForTimeout(1e3)}transpile(e){return['await agent.execAction("go_back", page, {});']}},op=rc.z.object({})});function cc(e,t){e.register({name:"go_to_url",description:"Navigate to a specific URL. Use this to visit web pages. Set new_tab=true to open in a new tab.",schema:ap,async execute(i,n){let{url:o,new_tab:a,timeout_seconds:s}=i,{page:r,agentServices:l,actionDescription:d}=n,c={url:o,new_tab:a??!1};s!==void 0&&(c.timeout_seconds=s);let h=s?` (timeout: ${s}s)`:"";try{let p=a?`Open ${o} in new tab`:`Navigate to ${o}`,g={action_description:d||p,action_data:{action_name:"go_to_url",kwargs:c}};return await t.execute(r,g,l),{success:!0,actionEntity:g,message:(a?`Opened ${o} in new tab`:`Navigated to ${o}`)+h}}catch(p){let g=a?`Open ${o} in new tab`:`Navigate to ${o}`;return{success:!1,error:p.message,actionEntity:{action_description:(d||g)+" (failed)",action_data:{action_name:"go_to_url",kwargs:c},feedback:p.message}}}}})}var Oi,Ca,ap,Li=w(()=>{"use strict";B();Oi=require("zod");C();Ca=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let o=n.kwargs.url;if(!o)throw new Error("Missing URL for go_to_url action");let a=n.kwargs.new_tab===!0,s=i.replaceVariables(String(o));if(s.startsWith("/")){let d=e.url(),c=null;try{let h=new URL(d);h.origin&&h.origin!=="null"&&(c=h.origin)}catch{}c&&(s=c+s)}let r=n.kwargs.timeout_seconds?n.kwargs.timeout_seconds*1e3:Ae,l=e;a&&(l=await e.context().newPage(),i.setPage(l)),await l.goto(s,{timeout:r})}transpile(e){let t=e.action_data?.kwargs?.url||"",i=e.action_data?.kwargs?.new_tab===!0,n=e.action_data?.kwargs?.timeout_seconds,o=[`url: ${JSON.stringify(t)}`];return i&&o.push("new_tab: true"),n&&o.push(`timeout_seconds: ${n}`),['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { ${o.join(", ")} } },`,"});"]}},ap=Oi.z.object({url:Oi.z.string().describe("URL to navigate to (must be a valid HTTP/HTTPS URL)"),new_tab:Oi.z.boolean().optional().describe("If true, open the URL in a new tab instead of the current page. Default is false."),timeout_seconds:Oi.z.number().positive().optional().describe("Navigation timeout in seconds. Default is 20 seconds.")})});async function rp(e,t,i,n,o={}){return{...await F(n,i),action_description:t,action_data:{action_name:e,kwargs:{...o}}}}function dc(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function uc(e,t){e.register({name:"hover",description:"Hover over an interactive element.",schema:sp,usesElementIndex:!0,async execute(i,n){let{element_index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Element with index ${o} not found.`,actionEntity:dc(`Hover element ${o}`,"hover",{index:o})};let d=r||`Hover over element ${o}`,c=await rp("hover",d,l,a);return await t.execute(a,c,s),{success:!0,actionEntity:c,message:`Hovered over element ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:dc(`Hover element ${o}`,"hover",{index:o})}}}})}var Yn,$a,sp,Di=w(()=>{"use strict";Q();B();Yn=require("zod");C();$a=class{async execute(e,t,i){let n=D(e,t),o=L(i,t.action_data?.kwargs?.timeout_ms);if(n){await n.waitFor({state:"attached",timeout:o});let a=await n.elementHandle();if(!a)throw new Error("Unable to obtain element handle for hover action");let s=await a.boundingBox();if(!s)throw new Error("Unable to determine bounding box for hover action");let r=s.x+s.width/2,l=s.y+s.height/2;await e.mouse.move(r,l)}else throw new Error("No locator found for hover action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("hover", page, {});']:['await agent.execAction("hover", page, {',...t.map(i=>` ${i},`),"});"]}};sp=Yn.z.object({element_index:Yn.z.number().int().describe("Index of the element to hover over"),timeout_ms:Yn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function mc(e,t){e.register({name:"ai_extract",description:"Use AI to extract information from the page and save it to a variable. MCP-only tool.",schema:lp,async execute(i,n){let{element_description:o,variable_name:a}=i,{page:s,agentServices:r}=n;try{let l={action_description:`Extract ${o} to ${a}`,action_data:{action_name:"ai_extract",kwargs:{element_description:o,variable_name:a}}};return await t.execute(s,l,r),{success:!0,actionEntity:l,message:`Extracted ${o} to ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Extract ${o} (failed)`,action_data:{action_name:"ai_extract",kwargs:{element_description:o,variable_name:a}},feedback:l.message}}}},availability:{openai:!1,mcp:!0}})}var Jn,hc,lp,Ni=w(()=>{"use strict";Jn=require("zod"),hc=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let o=n.kwargs.element_description,a=n.kwargs.variable_name;if(!o||!a)throw new Error("Missing element_description or variable_name for ai_extract");let s=`Extract ${o} and save to ${a}`,{executeStep:r}=await Promise.resolve().then(()=>(At(),Tt)),l=await r(s,e,i);if(l.status!=="success")throw new Error(l.error||"Extraction failed")}transpile(e,t){let i=e.action_data?.kwargs?.element_description,n=e.action_data?.kwargs?.variable_name;if(!i||!n)return["// Skipping ai_extract: missing element_description or variable_name"];let o=JSON.stringify(i),a=JSON.stringify(n);return[`await agent.extract(page, ${o}, ${a}, '${t||""}');`]}},lp=Jn.z.object({element_description:Jn.z.string().describe('Description of the element to extract (e.g., "the price of the product")'),variable_name:Jn.z.string().describe("Name of the variable to store the extracted value")})});async function cp(e,t,i,n,o={}){return{...await F(n,i),action_description:t,action_data:{action_name:e,kwargs:{...o}}}}function pc(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function fc(e,t){e.register({name:"clear_input",description:"Clear the contents of an input field, textarea, or other editable element.",schema:dp,usesElementIndex:!0,async execute(i,n){let{element_index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Input element with index ${o} not found`,actionEntity:pc(r||`Clear element ${o}`,"clear_input",{index:o})};let d=r||`Clear element ${o}`,c=await cp("clear_input",d,l,a);return await t.execute(a,c,s),{success:!0,actionEntity:c,message:`Cleared element ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:pc(`Clear element ${o}`,"clear_input",{index:o})}}}})}var qn,gc,dp,Ri=w(()=>{"use strict";Q();B();qn=require("zod");C();gc=class{async execute(e,t,i){let n=D(e,t),o=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.click({timeout:o}),await e.keyboard.press("ControlOrMeta+a"),await e.waitForTimeout(200),await e.keyboard.press("Backspace"),await e.waitForTimeout(200);else throw new Error("No locator found for clear_input action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("clear_input", page, {});']:['await agent.execAction("clear_input", page, {',...t.map(i=>` ${i},`),"});"]}};dp=qn.z.object({element_index:qn.z.number().int().describe("Index of the input element to clear"),timeout_ms:qn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function up(e,t,i,n,o={}){return{...await F(n,i),action_description:t,action_data:{action_name:e,kwargs:{...o}}}}function wc(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function bc(e,t){e.register({name:"click",description:"Click an interactive element.",schema:hp,usesElementIndex:!0,async execute(i,n){let{element_index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Element with index ${o} not found.`,actionEntity:wc(`Click element ${o}`,"click",{index:o})};let d=r||`Click element ${o}`,c=await up("click",d,l,a);return await t.execute(a,c,s),{success:!0,actionEntity:c,message:`Clicked element ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:wc(`Click element ${o}`,"click",{index:o})}}}})}var Zn,Qn,hp,Fi=w(()=>{"use strict";Q();B();Zn=require("zod");C();Qn=class{async execute(e,t,i){let n=D(e,t),o=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.click({timeout:o});else throw new Error("No locator found for click action")}transpile(e){let t=We(e);if(!t)return['await agent.execAction("click", page, {});'];let i=L();return[`await ${t}.click({ timeout: ${i} });`]}};hp=Zn.z.object({element_index:Zn.z.number().int().describe("Index of the element to click (0-based). Return -1 if no element found"),timeout_ms:Zn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function xc(e,t){e.register({name:"close_tab",description:"Close a browser tab by index. If no index is specified, closes the current tab.",schema:mp,async execute(i,n){let{index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l={action_description:r||`Close tab ${o}`,action_data:{action_name:"close_tab",kwargs:{page_id:o}}};return await t.execute(a,l,s),{success:!0,actionEntity:l,message:`Closed tab ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(r||"Close tab")+" (failed)",action_data:{action_name:"close_tab",kwargs:{}},feedback:l.message}}}}})}var Oa,yc,mp,Hi=w(()=>{"use strict";Oa=require("zod"),yc=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let o=n.kwargs.page_id??n.kwargs.index;if(o===void 0&&(o=e.context().pages().indexOf(e)),typeof o=="number"){if(o===0)throw new Error("Cannot close the first tab (page_id 0). Skipping close_tab action.");i&&await i.closeTab(o)}else throw new Error("Missing page_id for close_tab action")}transpile(e){let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]}},mp=Oa.z.object({index:Oa.z.number().int().nonnegative().optional().describe("Index of the tab to close (0-based). Defaults to current tab if not specified.")})});function _c(e,t){e.register({name:"done",description:"Mark the current task as complete. Use when you have finished all requested actions.",schema:pp,async execute(i,n){let{page:o,agentServices:a}=n;try{let s={action_description:"Task completed",action_data:{action_name:"done",kwargs:{}}};return await t.execute(o,s,a),{success:!0,actionEntity:s,message:"Task marked as complete"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Task completed (failed)",action_data:{action_name:"done",kwargs:{}},feedback:s.message}}}}})}var eo,vc,pp,Wi=w(()=>{"use strict";eo=require("zod"),vc=class{async execute(e,t){}transpile(e){return["// Done - no action needed"]}},pp=eo.z.object({success:eo.z.boolean().describe("Whether the task was completed successfully"),summary:eo.z.string().describe("Summary of what was accomplished or why it failed")})});async function gp(e,t,i,n,o={}){return{...await F(n,i),action_description:t,action_data:{action_name:e,kwargs:{...o}}}}function kc(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function Sc(e,t){e.register({name:"double_click",description:"Double-click an interactive element.",schema:fp,usesElementIndex:!0,async execute(i,n){let{element_index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Element with index ${o} not found.`,actionEntity:kc(`Double-click element ${o}`,"double_click",{index:o})};let d=r||`Double-click element ${o}`,c=await gp("double_click",d,l,a);return await t.execute(a,c,s),{success:!0,actionEntity:c,message:`Double-clicked element ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:kc(`Double-click element ${o}`,"double_click",{index:o})}}}})}var to,La,fp,Ui=w(()=>{"use strict";Q();B();to=require("zod");C();La=class{async execute(e,t,i){let n=D(e,t),o=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.dblclick({timeout:o});else throw new Error("No locator found for double_click action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("double_click", page, {});']:['await agent.execAction("double_click", page, {',...t.map(i=>` ${i},`),"});"]}};fp=to.z.object({element_index:to.z.number().int().describe("Index of the element to double-click"),timeout_ms:to.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Tc(e){if(!e.trim())return!1;try{return(0,Ec.parse)(e,{sourceType:"module",plugins:["typescript"]}),!0}catch{return!1}}var Ec,io=w(()=>{"use strict";Ec=require("@babel/parser")});function Ac(e,t){e.register({name:"verify",description:"Verify that a statement is true based on the current page state. Use this to check assertions about the page content, element visibility, or any condition.",schema:wp,async execute(i,n){let{statement:o}=i,{page:a,agentServices:s}=n;try{let r={action_description:`${o}`,action_data:{action_name:"verify",kwargs:{statement:o}}};return await t.execute(a,r,s),{success:!0,actionEntity:r,message:`Assertion verified: ${o}`}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:`Verify: ${o} (failed)`,action_data:{action_name:"verify",kwargs:{statement:o}},feedback:r.message}}}},availability:{openai:!0,mcp:!0}})}var Da,no,wp,Bi=w(()=>{"use strict";si();io();U();Da=require("zod"),no=class{async execute(e,t,i){let n=t.action_data?.kwargs,o=typeof n?.code=="string",a=o?n?.statement||t.action_description:t.action_description||n?.statement;if(o&&a){let c=Date.now();try{await this.executeJSAssertion(e,n.code,i),u.info(`[VERIFY:JS] \u2713 ${((Date.now()-c)/1e3).toFixed(1)}s: ${a}`),i.addNote(`Assertion passed: ${a}`);return}catch(h){let p=((Date.now()-c)/1e3).toFixed(1);u.info(`[VERIFY:JS\u2192AI] JS failed ${p}s (${h instanceof Error?h.message:String(h)}), falling back to AI: ${a}`)}}else if(o){let c=Date.now();await this.executeJSAssertion(e,n.code,i),u.info(`[VERIFY:JS] \u2713 ${((Date.now()-c)/1e3).toFixed(1)}s: ${a||"js-only"}`),i.addNote(`Assertion passed: ${a||"js-only"}`);return}if(!a)throw new Error("Missing statement or code for verify action");let s=Date.now();u.info(`[VERIFY:AI] Evaluating: ${a}`);let{evaluateStatement:r}=await Promise.resolve().then(()=>(At(),Tt)),l=await r(a,e,i,{useCleanScreenshotForAssertion:!0}),d=l.explanation||l.error||(l.success?`Assertion passed: ${a}`:"Assertion failed");if(i.addNote(d),!l.success)throw u.info(`[VERIFY:AI] \u2717 ${((Date.now()-s)/1e3).toFixed(1)}s: ${a}`),new Error(l.error||l.explanation||"Assertion failed");u.info(`[VERIFY:AI] \u2713 ${((Date.now()-s)/1e3).toFixed(1)}s: ${a}`)}async executeJSAssertion(e,t,i){let n=i.agent;if(!n)throw new Error("Agent not initialized on AgentServices \u2014 ai_assert requires an agent reference");try{await new Function("page","expect","agent",`
|
|
4107
|
+
Use the exact text string in select_dropdown_option`,i.addNote(o)}else i.addNote("No options found in any frame for dropdown")}transpile(e){let t=[];return e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("get_dropdown_options", page, {});']:['await agent.execAction("get_dropdown_options", page, {',...t.map(i=>` ${i},`),"});"]}};np=Pa.z.object({element_index:Pa.z.number().int().describe("Index of the dropdown/select element")})});function lc(e,t){e.register({name:"go_back",description:"Navigate back to the previous page in browser history.",schema:op,async execute(i,n){let{page:o,agentServices:a,actionDescription:s}=n;try{let r={action_description:s||"Go back",action_data:{action_name:"go_back",kwargs:{}}};return await t.execute(o,r,a),{success:!0,actionEntity:r,message:"Navigated back"}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:(s||"Go back")+" (failed)",action_data:{action_name:"go_back",kwargs:{}},feedback:r.message}}}}})}var rc,sc,op,$i=w(()=>{"use strict";B();rc=require("zod");C();sc=class{async execute(e,t){await e.goBack({timeout:Ae}),await e.waitForLoadState("load",{timeout:Ae}),await e.waitForTimeout(1e3)}transpile(e){return['await agent.execAction("go_back", page, {});']}},op=rc.z.object({})});function cc(e,t){e.register({name:"go_to_url",description:"Navigate to a specific URL. Use this to visit web pages. Set new_tab=true to open in a new tab.",schema:ap,async execute(i,n){let{url:o,new_tab:a,timeout_seconds:s}=i,{page:r,agentServices:l,actionDescription:d}=n,c={url:o,new_tab:a??!1};s!==void 0&&(c.timeout_seconds=s);let h=s?` (timeout: ${s}s)`:"";try{let p=a?`Open ${o} in new tab`:`Navigate to ${o}`,g={action_description:d||p,action_data:{action_name:"go_to_url",kwargs:c}};return await t.execute(r,g,l),{success:!0,actionEntity:g,message:(a?`Opened ${o} in new tab`:`Navigated to ${o}`)+h}}catch(p){let g=a?`Open ${o} in new tab`:`Navigate to ${o}`;return{success:!1,error:p.message,actionEntity:{action_description:(d||g)+" (failed)",action_data:{action_name:"go_to_url",kwargs:c},feedback:p.message}}}}})}var Oi,Ca,ap,Li=w(()=>{"use strict";B();Oi=require("zod");C();Ca=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let o=n.kwargs.url;if(!o)throw new Error("Missing URL for go_to_url action");let a=n.kwargs.new_tab===!0,s=i.replaceVariables(String(o));if(s.startsWith("/")){let d=e.url(),c=null;try{let h=new URL(d);h.origin&&h.origin!=="null"&&(c=h.origin)}catch{}c&&(s=c+s)}let r=n.kwargs.timeout_seconds?n.kwargs.timeout_seconds*1e3:Ae,l=e;a&&(l=await e.context().newPage(),i.setPage(l)),await l.goto(s,{timeout:r})}transpile(e){let t=e.action_data?.kwargs?.url||"",i=e.action_data?.kwargs?.new_tab===!0,n=e.action_data?.kwargs?.timeout_seconds,o=[`url: ${JSON.stringify(t)}`];return i&&o.push("new_tab: true"),n&&o.push(`timeout_seconds: ${n}`),['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { ${o.join(", ")} } },`,"});"]}},ap=Oi.z.object({url:Oi.z.string().describe('URL to navigate to (HTTP/HTTPS URL, or a path like "/home")'),new_tab:Oi.z.boolean().optional().describe("If true, open the URL in a new tab instead of the current page. Default is false."),timeout_seconds:Oi.z.number().positive().optional().describe("Navigation timeout in seconds. Default is 20 seconds.")})});async function rp(e,t,i,n,o={}){return{...await F(n,i),action_description:t,action_data:{action_name:e,kwargs:{...o}}}}function dc(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function uc(e,t){e.register({name:"hover",description:"Hover over an interactive element.",schema:sp,usesElementIndex:!0,async execute(i,n){let{element_index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Element with index ${o} not found.`,actionEntity:dc(`Hover element ${o}`,"hover",{index:o})};let d=r||`Hover over element ${o}`,c=await rp("hover",d,l,a);return await t.execute(a,c,s),{success:!0,actionEntity:c,message:`Hovered over element ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:dc(`Hover element ${o}`,"hover",{index:o})}}}})}var Yn,$a,sp,Di=w(()=>{"use strict";Q();B();Yn=require("zod");C();$a=class{async execute(e,t,i){let n=D(e,t),o=L(i,t.action_data?.kwargs?.timeout_ms);if(n){await n.waitFor({state:"attached",timeout:o});let a=await n.elementHandle();if(!a)throw new Error("Unable to obtain element handle for hover action");let s=await a.boundingBox();if(!s)throw new Error("Unable to determine bounding box for hover action");let r=s.x+s.width/2,l=s.y+s.height/2;await e.mouse.move(r,l)}else throw new Error("No locator found for hover action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("hover", page, {});']:['await agent.execAction("hover", page, {',...t.map(i=>` ${i},`),"});"]}};sp=Yn.z.object({element_index:Yn.z.number().int().describe("Index of the element to hover over"),timeout_ms:Yn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function mc(e,t){e.register({name:"ai_extract",description:"Use AI to extract information from the page and save it to a variable. MCP-only tool.",schema:lp,async execute(i,n){let{element_description:o,variable_name:a}=i,{page:s,agentServices:r}=n;try{let l={action_description:`Extract ${o} to ${a}`,action_data:{action_name:"ai_extract",kwargs:{element_description:o,variable_name:a}}};return await t.execute(s,l,r),{success:!0,actionEntity:l,message:`Extracted ${o} to ${a}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Extract ${o} (failed)`,action_data:{action_name:"ai_extract",kwargs:{element_description:o,variable_name:a}},feedback:l.message}}}},availability:{openai:!1,mcp:!0}})}var Jn,hc,lp,Ni=w(()=>{"use strict";Jn=require("zod"),hc=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let o=n.kwargs.element_description,a=n.kwargs.variable_name;if(!o||!a)throw new Error("Missing element_description or variable_name for ai_extract");let s=`Extract ${o} and save to ${a}`,{executeStep:r}=await Promise.resolve().then(()=>(At(),Tt)),l=await r(s,e,i);if(l.status!=="success")throw new Error(l.error||"Extraction failed")}transpile(e,t){let i=e.action_data?.kwargs?.element_description,n=e.action_data?.kwargs?.variable_name;if(!i||!n)return["// Skipping ai_extract: missing element_description or variable_name"];let o=JSON.stringify(i),a=JSON.stringify(n);return[`await agent.extract(page, ${o}, ${a}, '${t||""}');`]}},lp=Jn.z.object({element_description:Jn.z.string().describe('Description of the element to extract (e.g., "the price of the product")'),variable_name:Jn.z.string().describe("Name of the variable to store the extracted value")})});async function cp(e,t,i,n,o={}){return{...await F(n,i),action_description:t,action_data:{action_name:e,kwargs:{...o}}}}function pc(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function fc(e,t){e.register({name:"clear_input",description:"Clear the contents of an input field, textarea, or other editable element.",schema:dp,usesElementIndex:!0,async execute(i,n){let{element_index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Input element with index ${o} not found`,actionEntity:pc(r||`Clear element ${o}`,"clear_input",{index:o})};let d=r||`Clear element ${o}`,c=await cp("clear_input",d,l,a);return await t.execute(a,c,s),{success:!0,actionEntity:c,message:`Cleared element ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:pc(`Clear element ${o}`,"clear_input",{index:o})}}}})}var qn,gc,dp,Ri=w(()=>{"use strict";Q();B();qn=require("zod");C();gc=class{async execute(e,t,i){let n=D(e,t),o=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.click({timeout:o}),await e.keyboard.press("ControlOrMeta+a"),await e.waitForTimeout(200),await e.keyboard.press("Backspace"),await e.waitForTimeout(200);else throw new Error("No locator found for clear_input action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("clear_input", page, {});']:['await agent.execAction("clear_input", page, {',...t.map(i=>` ${i},`),"});"]}};dp=qn.z.object({element_index:qn.z.number().int().describe("Index of the input element to clear"),timeout_ms:qn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function up(e,t,i,n,o={}){return{...await F(n,i),action_description:t,action_data:{action_name:e,kwargs:{...o}}}}function wc(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function bc(e,t){e.register({name:"click",description:"Click an interactive element.",schema:hp,usesElementIndex:!0,async execute(i,n){let{element_index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Element with index ${o} not found.`,actionEntity:wc(`Click element ${o}`,"click",{index:o})};let d=r||`Click element ${o}`,c=await up("click",d,l,a);return await t.execute(a,c,s),{success:!0,actionEntity:c,message:`Clicked element ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:wc(`Click element ${o}`,"click",{index:o})}}}})}var Zn,Qn,hp,Fi=w(()=>{"use strict";Q();B();Zn=require("zod");C();Qn=class{async execute(e,t,i){let n=D(e,t),o=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.click({timeout:o});else throw new Error("No locator found for click action")}transpile(e){let t=We(e);if(!t)return['await agent.execAction("click", page, {});'];let i=L();return[`await ${t}.click({ timeout: ${i} });`]}};hp=Zn.z.object({element_index:Zn.z.number().int().describe("Index of the element to click (0-based). Return -1 if no element found"),timeout_ms:Zn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function xc(e,t){e.register({name:"close_tab",description:"Close a browser tab by index. If no index is specified, closes the current tab.",schema:mp,async execute(i,n){let{index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l={action_description:r||`Close tab ${o}`,action_data:{action_name:"close_tab",kwargs:{page_id:o}}};return await t.execute(a,l,s),{success:!0,actionEntity:l,message:`Closed tab ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(r||"Close tab")+" (failed)",action_data:{action_name:"close_tab",kwargs:{}},feedback:l.message}}}}})}var Oa,yc,mp,Hi=w(()=>{"use strict";Oa=require("zod"),yc=class{async execute(e,t,i){let n=t.action_data;if(!n)throw new Error("Action data not found");let o=n.kwargs.page_id??n.kwargs.index;if(o===void 0&&(o=e.context().pages().indexOf(e)),typeof o=="number"){if(o===0)throw new Error("Cannot close the first tab (page_id 0). Skipping close_tab action.");i&&await i.closeTab(o)}else throw new Error("Missing page_id for close_tab action")}transpile(e){let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]}},mp=Oa.z.object({index:Oa.z.number().int().nonnegative().optional().describe("Index of the tab to close (0-based). Defaults to current tab if not specified.")})});function _c(e,t){e.register({name:"done",description:"Mark the current task as complete. Use when you have finished all requested actions.",schema:pp,async execute(i,n){let{page:o,agentServices:a}=n;try{let s={action_description:"Task completed",action_data:{action_name:"done",kwargs:{}}};return await t.execute(o,s,a),{success:!0,actionEntity:s,message:"Task marked as complete"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Task completed (failed)",action_data:{action_name:"done",kwargs:{}},feedback:s.message}}}}})}var eo,vc,pp,Wi=w(()=>{"use strict";eo=require("zod"),vc=class{async execute(e,t){}transpile(e){return["// Done - no action needed"]}},pp=eo.z.object({success:eo.z.boolean().describe("Whether the task was completed successfully"),summary:eo.z.string().describe("Summary of what was accomplished or why it failed")})});async function gp(e,t,i,n,o={}){return{...await F(n,i),action_description:t,action_data:{action_name:e,kwargs:{...o}}}}function kc(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function Sc(e,t){e.register({name:"double_click",description:"Double-click an interactive element.",schema:fp,usesElementIndex:!0,async execute(i,n){let{element_index:o}=i,{page:a,agentServices:s,actionDescription:r}=n;try{let l=await V(n,o);if(!l)return{success:!1,error:`Element with index ${o} not found.`,actionEntity:kc(`Double-click element ${o}`,"double_click",{index:o})};let d=r||`Double-click element ${o}`,c=await gp("double_click",d,l,a);return await t.execute(a,c,s),{success:!0,actionEntity:c,message:`Double-clicked element ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:kc(`Double-click element ${o}`,"double_click",{index:o})}}}})}var to,La,fp,Ui=w(()=>{"use strict";Q();B();to=require("zod");C();La=class{async execute(e,t,i){let n=D(e,t),o=L(i,t.action_data?.kwargs?.timeout_ms);if(n)await n.dblclick({timeout:o});else throw new Error("No locator found for double_click action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("double_click", page, {});']:['await agent.execAction("double_click", page, {',...t.map(i=>` ${i},`),"});"]}};fp=to.z.object({element_index:to.z.number().int().describe("Index of the element to double-click"),timeout_ms:to.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Tc(e){if(!e.trim())return!1;try{return(0,Ec.parse)(e,{sourceType:"module",plugins:["typescript"]}),!0}catch{return!1}}var Ec,io=w(()=>{"use strict";Ec=require("@babel/parser")});function Ac(e,t){e.register({name:"verify",description:"Verify that a statement is true based on the current page state. Use this to check assertions about the page content, element visibility, or any condition.",schema:wp,async execute(i,n){let{statement:o}=i,{page:a,agentServices:s}=n;try{let r={action_description:`${o}`,action_data:{action_name:"verify",kwargs:{statement:o}}};return await t.execute(a,r,s),{success:!0,actionEntity:r,message:`Assertion verified: ${o}`}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:`Verify: ${o} (failed)`,action_data:{action_name:"verify",kwargs:{statement:o}},feedback:r.message}}}},availability:{openai:!0,mcp:!0}})}var Da,no,wp,Bi=w(()=>{"use strict";si();io();U();Da=require("zod"),no=class{async execute(e,t,i){let n=t.action_data?.kwargs,o=typeof n?.code=="string",a=o?n?.statement||t.action_description:t.action_description||n?.statement;if(o&&a){let c=Date.now();try{await this.executeJSAssertion(e,n.code,i),u.info(`[VERIFY:JS] \u2713 ${((Date.now()-c)/1e3).toFixed(1)}s: ${a}`),i.addNote(`Assertion passed: ${a}`);return}catch(h){let p=((Date.now()-c)/1e3).toFixed(1);u.info(`[VERIFY:JS\u2192AI] JS failed ${p}s (${h instanceof Error?h.message:String(h)}), falling back to AI: ${a}`)}}else if(o){let c=Date.now();await this.executeJSAssertion(e,n.code,i),u.info(`[VERIFY:JS] \u2713 ${((Date.now()-c)/1e3).toFixed(1)}s: ${a||"js-only"}`),i.addNote(`Assertion passed: ${a||"js-only"}`);return}if(!a)throw new Error("Missing statement or code for verify action");let s=Date.now();u.info(`[VERIFY:AI] Evaluating: ${a}`);let{evaluateStatement:r}=await Promise.resolve().then(()=>(At(),Tt)),l=await r(a,e,i,{useCleanScreenshotForAssertion:!0}),d=l.explanation||l.error||(l.success?`Assertion passed: ${a}`:"Assertion failed");if(i.addNote(d),!l.success)throw u.info(`[VERIFY:AI] \u2717 ${((Date.now()-s)/1e3).toFixed(1)}s: ${a}`),new Error(l.error||l.explanation||"Assertion failed");u.info(`[VERIFY:AI] \u2713 ${((Date.now()-s)/1e3).toFixed(1)}s: ${a}`)}async executeJSAssertion(e,t,i){let n=i.agent;if(!n)throw new Error("Agent not initialized on AgentServices \u2014 ai_assert requires an agent reference");try{await new Function("page","expect","agent",`
|
|
4108
4108
|
return (async () => {
|
|
4109
4109
|
${t}
|
|
4110
4110
|
})();
|
|
@@ -4303,13 +4303,6 @@ ${g.join(`
|
|
|
4303
4303
|
// check to make sure we're not inside the PDF viewer
|
|
4304
4304
|
window.isPdfViewer = !!document?.body?.querySelector('body > embed[type="application/pdf"][width="100%"]')
|
|
4305
4305
|
if (!window.isPdfViewer) {
|
|
4306
|
-
// Permissions
|
|
4307
|
-
const originalQuery = window.navigator.permissions.query;
|
|
4308
|
-
window.navigator.permissions.query = (parameters) => (
|
|
4309
|
-
parameters.name === 'notifications' ?
|
|
4310
|
-
Promise.resolve({ state: Notification.permission }) :
|
|
4311
|
-
originalQuery(parameters)
|
|
4312
|
-
);
|
|
4313
4306
|
window.showOpenFilePicker = async () => {
|
|
4314
4307
|
const files = window.__pw_showOpenFilePicker_mock_files ?? [];
|
|
4315
4308
|
console.log('showOpenFilePicker: ', files);
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -4103,7 +4103,7 @@ Do NOT use it for custom/non-native date pickers
|
|
|
4103
4103
|
|
|
4104
4104
|
The date must be in YYYY-MM-DD format (e.g., 2024-03-15).`,schema:Vu,usesElementIndex:!0,async execute(i,a){let{element_index:n,date:o}=i,{page:r,agentServices:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Date picker element with index ${n} not found`,actionEntity:Ya(`Set date to ${o} on element ${n}`,{index:n,date:o})};let c=l.attributes.type;if(c!=="date")return{success:!1,error:`Element ${n} is not a native date picker (type="${c}"). This action only works with <input type="date">.`,actionEntity:Ya(`Set date to ${o} on element ${n}`,{index:n,date:o})};let d=await zu(`Set date to ${o} on element ${n}`,l,r,o);return await t.execute(r,d,s),{success:!0,actionEntity:d,message:`Set date to ${o} on element ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:Ya(`Set date to ${o} on element ${n}`,{index:n,date:o})}}}})}var li,Js,Vu,ci=v(()=>{"use strict";Y();H();li=require("zod");I();Js=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.date;if(!n)throw new Error("Date value is required");if(!/^\d{4}-\d{2}-\d{2}$/.test(n))throw new Error(`Invalid date format: ${n}. Expected format: YYYY-MM-DD (e.g., 2024-03-15)`);let o=i.replaceVariables(String(n)),r=L(e,t);if(r){let s=await r.getAttribute("type").catch(()=>null);if(s&&s!=="date")throw new Error(`Element is not a native date picker (type="${s}"). This action only works with <input type="date">. For custom date pickers, use AI-powered actions.`);await r.fill(o,{timeout:C(i,t.action_data?.kwargs?.timeout_ms)})}else throw new Error("No locator found for set_date_for_native_date_picker action")}transpile(e){let t=e.action_data?.kwargs?.date??"",i=[];return i.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...i.map(a=>` ${a},`),"});"]}};Vu=li.z.object({element_index:li.z.number().int().describe("Index of the native date picker input element"),date:li.z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe("Date in YYYY-MM-DD format (e.g., 2024-03-15)"),timeout_ms:li.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Qs(e,t){e.register({name:"switch_tab",description:"Switch to a different browser tab by index (0-based).",schema:Xu,async execute(i,a){let n=i.tab_index,{page:o,agentServices:r,actionDescription:s}=a;try{let l={action_description:s||`Switch to tab ${n}`,action_data:{action_name:"switch_tab",kwargs:{page_id:n}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Switched to tab ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Switch to tab ${n}`)+" (failed)",action_data:{action_name:"switch_tab",kwargs:{page_id:n}},feedback:l.message}}}}})}var Ja,Zs,Xu,di=v(()=>{"use strict";Ja=require("zod"),Zs=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.page_id??a.kwargs.tab_index??0;if(typeof n=="number"){let o=e.context().pages(),r=n===-1?o.length-1:n;if(i){let s=await i.switchTab(r);await s.waitForLoadState("load",{timeout:15e3}).catch(()=>{}),await s.waitForTimeout(500)}}else throw new Error("Missing page_id for switch_tab action")}transpile(e){return['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]}},Xu=Ja.z.object({tab_index:Ja.z.number().int().nonnegative().describe("Index of the tab to switch to (0-based). Use 0 for first tab, 1 for second, etc.")})});async function Yu(e,t,i,a,n={}){return{...await R(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function el(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function tl(e,t){e.register({name:"input_text",description:"Type text into an input field. To replace existing content, use clear_input first.",schema:Ju,usesElementIndex:!0,async execute(i,a){let{element_index:n,text:o}=i,{page:r,agentServices:s,actionDescription:l}=a;try{let c=await U(a,n);if(!c)return{success:!1,error:`Input element with index ${n} not found`,actionEntity:el(l||`Input text to element ${n}`,"input_text",{index:n,text:o})};let d=l||`Input text to element ${n}`,h=await Yu("input_text",d,c,r,{text:o});return await t.execute(r,h,s),{success:!0,actionEntity:h,message:`Input text to element ${n}`}}catch(c){return{success:!1,error:c.message,actionEntity:el(`Input text to element ${n}`,"input_text",{index:n,text:o})}}}})}var ui,qa,Ju,hi=v(()=>{"use strict";Y();H();ui=require("zod");I();qa=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.text??a.kwargs.value??"",o=i.replaceVariables(String(n)),r=L(e,t),s=C(i,t.action_data?.kwargs?.timeout_ms);if(r){await r.evaluate(c=>{c.value&&(c.value="")},null,{timeout:s}),await r.click({timeout:s}),await e.waitForTimeout(200);let l=i.getActionSettings().type_delay;l!==void 0?await e.keyboard.type(o,{delay:l}):await e.keyboard.type(o)}else throw new Error("No locator found for input_text action")}transpile(e){let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"",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("input_text", page, {',...i.map(a=>` ${a},`),"});"]}};Ju=ui.z.object({element_index:ui.z.number().int().describe("Index of the input element"),text:ui.z.string().describe("Text to type into the input. To use a placeholder, write {{ placeholder_name }} using exact placeholder name. Use clear_input first if you want to replace existing content."),timeout_ms:ui.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function il(e,t){e.register({name:"press",description:"Press a single keyboard key or key combination. Supports combinations like `Control+A` for select all. Does NOT support sequences - call this action multiple times to press keys in sequence.",schema:qu,async execute(i,a){let{keys:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l={action_description:s||`Press keys "${n}"`,action_data:{action_name:"press",kwargs:{keys:n}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Pressed keys "${n}"`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||`Press keys "${n}"`)+" (failed)",action_data:{action_name:"press",kwargs:{keys:n}},feedback:l.message}}}}})}var Za,Qa,qu,pi=v(()=>{"use strict";Za=require("zod"),Qa=class{async execute(e,t){let i=t.action_data;if(!i)throw new Error("Action data not found");let a=i.kwargs.keys;if(!a||typeof a!="string")throw new Error("Missing or invalid keys for press action");await e.keyboard.press(a),await e.waitForTimeout(500)}transpile(e){let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]}},qu=Za.z.object({keys:Za.z.string().describe("A single key or key combination to press (e.g. Escape, Backspace, Insert, PageDown, Delete, Tab, Enter). Key combinations like `Control+o`, `Control+Shift+T`, `ControlOrMeta+a` are supported. Note: This does NOT support sequences - to press multiple keys in sequence (e.g., Control+A then Backspace), call this action multiple times.")})});function ol(e,t){e.register({name:"reload_page",description:"Reload the current page. WARNING: This will reset any in-progress forms or multi-step flows (like login). Only use when you need to refresh stale data or clear a stuck state. Do NOT use during login, checkout, or form submission flows.",schema:Zu,async execute(i,a){let{page:n,agentServices:o}=a;try{let r={action_description:"Reload page",action_data:{action_name:"reload_page",kwargs:{}}};return await t.execute(n,r,o),{success:!0,actionEntity:r,message:`Reloaded ${n.url()}`}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:"Reload page (failed)",action_data:{action_name:"reload_page",kwargs:{}},feedback:r.message}}}}})}var nl,al,Zu,mi=v(()=>{"use strict";H();nl=require("zod");I();al=class{async execute(e,t){await e.reload({timeout:ve}),await e.waitForLoadState("load",{timeout:ve}),await e.waitForTimeout(1e3)}transpile(e){return['await agent.execAction("reload_page", page, {});']}},Zu=nl.z.object({})});async function Qu(e,t,i,a,n={}){return{...await R(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function rl(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function sl(e,t){e.register({name:"right_click",description:"Right-click an interactive element.",schema:eh,usesElementIndex:!0,async execute(i,a){let{element_index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Element with index ${n} not found.`,actionEntity:rl(`Right-click element ${n}`,"right_click",{index:n})};let c=s||`Right-click element ${n}`,d=await Qu("right_click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Right-clicked element ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:rl(`Right-click element ${n}`,"right_click",{index:n})}}}})}var In,eo,eh,gi=v(()=>{"use strict";Y();H();In=require("zod");I();eo=class{async execute(e,t,i){let a=L(e,t),n=C(i,t.action_data?.kwargs?.timeout_ms);if(a)await a.click({button:"right",timeout:n});else throw new Error("No locator found for right_click action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("right_click", page, {});']:['await agent.execAction("right_click", page, {',...t.map(i=>` ${i},`),"});"]}};eh=In.z.object({element_index:In.z.number().int().describe("Index of the element to right-click"),timeout_ms:In.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function cl(e,t){e.register({name:"generate_2fa_code",description:'Generate a 2FA code from an OTP secret key. The code is saved to the "otp_code" variable. To use the otp_code, you must use `$otp_code` to access it.',schema:th,async execute(i,a){let{otp_secret_key:n}=i,{page:o,agentServices:r}=a;try{let s={action_description:"Generate 2FA code",action_data:{action_name:"generate_2fa_code",kwargs:{otp_secret_key:n}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:'Generated 2FA code and saved to variable "otp_code"'}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:"Generate 2FA code (failed)",action_data:{action_name:"generate_2fa_code",kwargs:{otp_secret_key:n}},feedback:s.message}}}}})}var to,ll,th,fi=v(()=>{"use strict";to=require("zod"),ll=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.otp_secret_key;if(!n)throw new Error("Missing otp_secret_key for generate_2fa_code");let o=i.replaceVariables(String(n)),r=await i.generate2faCode(o);i.saveVariable("otp_code",r)}transpile(e){let t=e.action_data?.kwargs?.otp_secret_key||"";return['await agent.execAction("generate_2fa_code", page, {',` action_data: { kwargs: { otp_secret_key: ${JSON.stringify(t)} } },`,"});"]}},th=to.z.object({otp_secret_key:to.z.string().describe("The OTP secret key to generate the 2FA code from")})});async function ih(e,t,i){return{...await R(t,e),action_description:i||"Get dropdown options",action_data:{action_name:"get_dropdown_options",kwargs:{}}}}function dl(e,t){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:"get_dropdown_options",kwargs:t},feedback:"Element not found in DOM"}}function hl(e,t){e.register({name:"get_dropdown_options",description:"Get all options from a native dropdown",schema:nh,usesElementIndex:!0,async execute(i,a){let{element_index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Dropdown element with index ${n} not found`,actionEntity:dl(s||`Get options from dropdown ${n}`,{index:n})};let c=await ih(l,o,s);return await t.execute(o,c,r),{success:!0,actionEntity:c,message:c.feedback||"No options found"}}catch(l){return{success:!1,error:l.message,actionEntity:dl(s||`Get options from dropdown ${n}`,{index:n})}}}})}var io,ul,nh,wi=v(()=>{"use strict";Y();io=require("zod"),ul=class{async execute(e,t,i){if(!t.xpath)throw new Error("XPath not found in action entity");let a=[];for(let n of e.frames())try{let o=await n.evaluate(r=>{let s=document.evaluate(r,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;return s?{options:Array.from(s.options).map(l=>({text:l.text,value:l.value,index:l.index})),id:s.id,name:s.name}:null},t.xpath);if(o){let r=[];for(let s of o.options){let l=JSON.stringify(s.text);r.push(`${s.index}: text=${l}`)}a.push(...r)}}catch{}if(a.length>0){let n=a.join(`
|
|
4105
4105
|
`);n+=`
|
|
4106
|
-
Use the exact text string in select_dropdown_option`,i.addNote(n)}else i.addNote("No options found in any frame for dropdown")}transpile(e){let t=[];return e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("get_dropdown_options", page, {});']:['await agent.execAction("get_dropdown_options", page, {',...t.map(i=>` ${i},`),"});"]}};nh=io.z.object({element_index:io.z.number().int().describe("Index of the dropdown/select element")})});function gl(e,t){e.register({name:"go_back",description:"Navigate back to the previous page in browser history.",schema:ah,async execute(i,a){let{page:n,agentServices:o,actionDescription:r}=a;try{let s={action_description:r||"Go back",action_data:{action_name:"go_back",kwargs:{}}};return await t.execute(n,s,o),{success:!0,actionEntity:s,message:"Navigated back"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(r||"Go back")+" (failed)",action_data:{action_name:"go_back",kwargs:{}},feedback:s.message}}}}})}var pl,ml,ah,bi=v(()=>{"use strict";H();pl=require("zod");I();ml=class{async execute(e,t){await e.goBack({timeout:ve}),await e.waitForLoadState("load",{timeout:ve}),await e.waitForTimeout(1e3)}transpile(e){return['await agent.execAction("go_back", page, {});']}},ah=pl.z.object({})});function fl(e,t){e.register({name:"go_to_url",description:"Navigate to a specific URL. Use this to visit web pages. Set new_tab=true to open in a new tab.",schema:oh,async execute(i,a){let{url:n,new_tab:o,timeout_seconds:r}=i,{page:s,agentServices:l,actionDescription:c}=a,d={url:n,new_tab:o??!1};r!==void 0&&(d.timeout_seconds=r);let h=r?` (timeout: ${r}s)`:"";try{let m=o?`Open ${n} in new tab`:`Navigate to ${n}`,g={action_description:c||m,action_data:{action_name:"go_to_url",kwargs:d}};return await t.execute(s,g,l),{success:!0,actionEntity:g,message:(o?`Opened ${n} in new tab`:`Navigated to ${n}`)+h}}catch(m){let g=o?`Open ${n} in new tab`:`Navigate to ${n}`;return{success:!1,error:m.message,actionEntity:{action_description:(c||g)+" (failed)",action_data:{action_name:"go_to_url",kwargs:d},feedback:m.message}}}}})}var yi,no,oh,xi=v(()=>{"use strict";H();yi=require("zod");I();no=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.url;if(!n)throw new Error("Missing URL for go_to_url action");let o=a.kwargs.new_tab===!0,r=i.replaceVariables(String(n));if(r.startsWith("/")){let c=e.url(),d=null;try{let h=new URL(c);h.origin&&h.origin!=="null"&&(d=h.origin)}catch{}d&&(r=d+r)}let s=a.kwargs.timeout_seconds?a.kwargs.timeout_seconds*1e3:ve,l=e;o&&(l=await e.context().newPage(),i.setPage(l)),await l.goto(r,{timeout:s})}transpile(e){let t=e.action_data?.kwargs?.url||"",i=e.action_data?.kwargs?.new_tab===!0,a=e.action_data?.kwargs?.timeout_seconds,n=[`url: ${JSON.stringify(t)}`];return i&&n.push("new_tab: true"),a&&n.push(`timeout_seconds: ${a}`),['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { ${n.join(", ")} } },`,"});"]}},oh=yi.z.object({url:yi.z.string().describe("URL to navigate to (must be a valid HTTP/HTTPS URL)"),new_tab:yi.z.boolean().optional().describe("If true, open the URL in a new tab instead of the current page. Default is false."),timeout_seconds:yi.z.number().positive().optional().describe("Navigation timeout in seconds. Default is 20 seconds.")})});async function rh(e,t,i,a,n={}){return{...await R(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function wl(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function bl(e,t){e.register({name:"hover",description:"Hover over an interactive element.",schema:sh,usesElementIndex:!0,async execute(i,a){let{element_index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Element with index ${n} not found.`,actionEntity:wl(`Hover element ${n}`,"hover",{index:n})};let c=s||`Hover over element ${n}`,d=await rh("hover",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Hovered over element ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:wl(`Hover element ${n}`,"hover",{index:n})}}}})}var Pn,ao,sh,vi=v(()=>{"use strict";Y();H();Pn=require("zod");I();ao=class{async execute(e,t,i){let a=L(e,t),n=C(i,t.action_data?.kwargs?.timeout_ms);if(a){await a.waitFor({state:"attached",timeout:n});let o=await a.elementHandle();if(!o)throw new Error("Unable to obtain element handle for hover action");let r=await o.boundingBox();if(!r)throw new Error("Unable to determine bounding box for hover action");let s=r.x+r.width/2,l=r.y+r.height/2;await e.mouse.move(s,l)}else throw new Error("No locator found for hover action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("hover", page, {});']:['await agent.execAction("hover", page, {',...t.map(i=>` ${i},`),"});"]}};sh=Pn.z.object({element_index:Pn.z.number().int().describe("Index of the element to hover over"),timeout_ms:Pn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function xl(e,t){e.register({name:"ai_extract",description:"Use AI to extract information from the page and save it to a variable. MCP-only tool.",schema:lh,async execute(i,a){let{element_description:n,variable_name:o}=i,{page:r,agentServices:s}=a;try{let l={action_description:`Extract ${n} to ${o}`,action_data:{action_name:"ai_extract",kwargs:{element_description:n,variable_name:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Extracted ${n} to ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Extract ${n} (failed)`,action_data:{action_name:"ai_extract",kwargs:{element_description:n,variable_name:o}},feedback:l.message}}}},availability:{openai:!1,mcp:!0}})}var Cn,yl,lh,_i=v(()=>{"use strict";Cn=require("zod"),yl=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.element_description,o=a.kwargs.variable_name;if(!n||!o)throw new Error("Missing element_description or variable_name for ai_extract");let r=`Extract ${n} and save to ${o}`,{executeStep:s}=await Promise.resolve().then(()=>(gt(),mt)),l=await s(r,e,i);if(l.status!=="success")throw new Error(l.error||"Extraction failed")}transpile(e,t){let i=e.action_data?.kwargs?.element_description,a=e.action_data?.kwargs?.variable_name;if(!i||!a)return["// Skipping ai_extract: missing element_description or variable_name"];let n=JSON.stringify(i),o=JSON.stringify(a);return[`await agent.extract(page, ${n}, ${o}, '${t||""}');`]}},lh=Cn.z.object({element_description:Cn.z.string().describe('Description of the element to extract (e.g., "the price of the product")'),variable_name:Cn.z.string().describe("Name of the variable to store the extracted value")})});async function ch(e,t,i,a,n={}){return{...await R(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function vl(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function kl(e,t){e.register({name:"clear_input",description:"Clear the contents of an input field, textarea, or other editable element.",schema:dh,usesElementIndex:!0,async execute(i,a){let{element_index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Input element with index ${n} not found`,actionEntity:vl(s||`Clear element ${n}`,"clear_input",{index:n})};let c=s||`Clear element ${n}`,d=await ch("clear_input",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Cleared element ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:vl(`Clear element ${n}`,"clear_input",{index:n})}}}})}var On,_l,dh,ki=v(()=>{"use strict";Y();H();On=require("zod");I();_l=class{async execute(e,t,i){let a=L(e,t),n=C(i,t.action_data?.kwargs?.timeout_ms);if(a)await a.click({timeout:n}),await e.keyboard.press("ControlOrMeta+a"),await e.waitForTimeout(200),await e.keyboard.press("Backspace"),await e.waitForTimeout(200);else throw new Error("No locator found for clear_input action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("clear_input", page, {});']:['await agent.execAction("clear_input", page, {',...t.map(i=>` ${i},`),"});"]}};dh=On.z.object({element_index:On.z.number().int().describe("Index of the input element to clear"),timeout_ms:On.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function uh(e,t,i,a,n={}){return{...await R(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function Sl(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function El(e,t){e.register({name:"click",description:"Click an interactive element.",schema:hh,usesElementIndex:!0,async execute(i,a){let{element_index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Element with index ${n} not found.`,actionEntity:Sl(`Click element ${n}`,"click",{index:n})};let c=s||`Click element ${n}`,d=await uh("click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Clicked element ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:Sl(`Click element ${n}`,"click",{index:n})}}}})}var Ln,Nn,hh,Si=v(()=>{"use strict";Y();H();Ln=require("zod");I();Nn=class{async execute(e,t,i){let a=L(e,t),n=C(i,t.action_data?.kwargs?.timeout_ms);if(a)await a.click({timeout:n});else throw new Error("No locator found for click action")}transpile(e){let t=We(e);if(!t)return['await agent.execAction("click", page, {});'];let i=C();return[`await ${t}.click({ timeout: ${i} });`]}};hh=Ln.z.object({element_index:Ln.z.number().int().describe("Index of the element to click (0-based). Return -1 if no element found"),timeout_ms:Ln.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Al(e,t){e.register({name:"close_tab",description:"Close a browser tab by index. If no index is specified, closes the current tab.",schema:ph,async execute(i,a){let{index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l={action_description:s||`Close tab ${n}`,action_data:{action_name:"close_tab",kwargs:{page_id:n}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Closed tab ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||"Close tab")+" (failed)",action_data:{action_name:"close_tab",kwargs:{}},feedback:l.message}}}}})}var oo,Tl,ph,Ei=v(()=>{"use strict";oo=require("zod"),Tl=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.page_id??a.kwargs.index;if(n===void 0&&(n=e.context().pages().indexOf(e)),typeof n=="number"){if(n===0)throw new Error("Cannot close the first tab (page_id 0). Skipping close_tab action.");i&&await i.closeTab(n)}else throw new Error("Missing page_id for close_tab action")}transpile(e){let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]}},ph=oo.z.object({index:oo.z.number().int().nonnegative().optional().describe("Index of the tab to close (0-based). Defaults to current tab if not specified.")})});function Ml(e,t){e.register({name:"done",description:"Mark the current task as complete. Use when you have finished all requested actions.",schema:mh,async execute(i,a){let{page:n,agentServices:o}=a;try{let r={action_description:"Task completed",action_data:{action_name:"done",kwargs:{}}};return await t.execute(n,r,o),{success:!0,actionEntity:r,message:"Task marked as complete"}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:"Task completed (failed)",action_data:{action_name:"done",kwargs:{}},feedback:r.message}}}}})}var Dn,$l,mh,Ti=v(()=>{"use strict";Dn=require("zod"),$l=class{async execute(e,t){}transpile(e){return["// Done - no action needed"]}},mh=Dn.z.object({success:Dn.z.boolean().describe("Whether the task was completed successfully"),summary:Dn.z.string().describe("Summary of what was accomplished or why it failed")})});async function gh(e,t,i,a,n={}){return{...await R(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function Il(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function Pl(e,t){e.register({name:"double_click",description:"Double-click an interactive element.",schema:fh,usesElementIndex:!0,async execute(i,a){let{element_index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Element with index ${n} not found.`,actionEntity:Il(`Double-click element ${n}`,"double_click",{index:n})};let c=s||`Double-click element ${n}`,d=await gh("double_click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Double-clicked element ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:Il(`Double-click element ${n}`,"double_click",{index:n})}}}})}var Rn,ro,fh,Ai=v(()=>{"use strict";Y();H();Rn=require("zod");I();ro=class{async execute(e,t,i){let a=L(e,t),n=C(i,t.action_data?.kwargs?.timeout_ms);if(a)await a.dblclick({timeout:n});else throw new Error("No locator found for double_click action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("double_click", page, {});']:['await agent.execAction("double_click", page, {',...t.map(i=>` ${i},`),"});"]}};fh=Rn.z.object({element_index:Rn.z.number().int().describe("Index of the element to double-click"),timeout_ms:Rn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Ol(e){if(!e.trim())return!1;try{return(0,Cl.parse)(e,{sourceType:"module",plugins:["typescript"]}),!0}catch{return!1}}var Cl,Fn=v(()=>{"use strict";Cl=require("@babel/parser")});function Ll(e,t){e.register({name:"verify",description:"Verify that a statement is true based on the current page state. Use this to check assertions about the page content, element visibility, or any condition.",schema:wh,async execute(i,a){let{statement:n}=i,{page:o,agentServices:r}=a;try{let s={action_description:`${n}`,action_data:{action_name:"verify",kwargs:{statement:n}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Assertion verified: ${n}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:`Verify: ${n} (failed)`,action_data:{action_name:"verify",kwargs:{statement:n}},feedback:s.message}}}},availability:{openai:!0,mcp:!0}})}var so,Hn,wh,$i=v(()=>{"use strict";zt();Fn();F();so=require("zod"),Hn=class{async execute(e,t,i){let a=t.action_data?.kwargs,n=typeof a?.code=="string",o=n?a?.statement||t.action_description:t.action_description||a?.statement;if(n&&o){let d=Date.now();try{await this.executeJSAssertion(e,a.code,i),u.info(`[VERIFY:JS] \u2713 ${((Date.now()-d)/1e3).toFixed(1)}s: ${o}`),i.addNote(`Assertion passed: ${o}`);return}catch(h){let m=((Date.now()-d)/1e3).toFixed(1);u.info(`[VERIFY:JS\u2192AI] JS failed ${m}s (${h instanceof Error?h.message:String(h)}), falling back to AI: ${o}`)}}else if(n){let d=Date.now();await this.executeJSAssertion(e,a.code,i),u.info(`[VERIFY:JS] \u2713 ${((Date.now()-d)/1e3).toFixed(1)}s: ${o||"js-only"}`),i.addNote(`Assertion passed: ${o||"js-only"}`);return}if(!o)throw new Error("Missing statement or code for verify action");let r=Date.now();u.info(`[VERIFY:AI] Evaluating: ${o}`);let{evaluateStatement:s}=await Promise.resolve().then(()=>(gt(),mt)),l=await s(o,e,i,{useCleanScreenshotForAssertion:!0}),c=l.explanation||l.error||(l.success?`Assertion passed: ${o}`:"Assertion failed");if(i.addNote(c),!l.success)throw u.info(`[VERIFY:AI] \u2717 ${((Date.now()-r)/1e3).toFixed(1)}s: ${o}`),new Error(l.error||l.explanation||"Assertion failed");u.info(`[VERIFY:AI] \u2713 ${((Date.now()-r)/1e3).toFixed(1)}s: ${o}`)}async executeJSAssertion(e,t,i){let a=i.agent;if(!a)throw new Error("Agent not initialized on AgentServices \u2014 ai_assert requires an agent reference");try{await new Function("page","expect","agent",`
|
|
4106
|
+
Use the exact text string in select_dropdown_option`,i.addNote(n)}else i.addNote("No options found in any frame for dropdown")}transpile(e){let t=[];return e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("get_dropdown_options", page, {});']:['await agent.execAction("get_dropdown_options", page, {',...t.map(i=>` ${i},`),"});"]}};nh=io.z.object({element_index:io.z.number().int().describe("Index of the dropdown/select element")})});function gl(e,t){e.register({name:"go_back",description:"Navigate back to the previous page in browser history.",schema:ah,async execute(i,a){let{page:n,agentServices:o,actionDescription:r}=a;try{let s={action_description:r||"Go back",action_data:{action_name:"go_back",kwargs:{}}};return await t.execute(n,s,o),{success:!0,actionEntity:s,message:"Navigated back"}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:(r||"Go back")+" (failed)",action_data:{action_name:"go_back",kwargs:{}},feedback:s.message}}}}})}var pl,ml,ah,bi=v(()=>{"use strict";H();pl=require("zod");I();ml=class{async execute(e,t){await e.goBack({timeout:ve}),await e.waitForLoadState("load",{timeout:ve}),await e.waitForTimeout(1e3)}transpile(e){return['await agent.execAction("go_back", page, {});']}},ah=pl.z.object({})});function fl(e,t){e.register({name:"go_to_url",description:"Navigate to a specific URL. Use this to visit web pages. Set new_tab=true to open in a new tab.",schema:oh,async execute(i,a){let{url:n,new_tab:o,timeout_seconds:r}=i,{page:s,agentServices:l,actionDescription:c}=a,d={url:n,new_tab:o??!1};r!==void 0&&(d.timeout_seconds=r);let h=r?` (timeout: ${r}s)`:"";try{let m=o?`Open ${n} in new tab`:`Navigate to ${n}`,g={action_description:c||m,action_data:{action_name:"go_to_url",kwargs:d}};return await t.execute(s,g,l),{success:!0,actionEntity:g,message:(o?`Opened ${n} in new tab`:`Navigated to ${n}`)+h}}catch(m){let g=o?`Open ${n} in new tab`:`Navigate to ${n}`;return{success:!1,error:m.message,actionEntity:{action_description:(c||g)+" (failed)",action_data:{action_name:"go_to_url",kwargs:d},feedback:m.message}}}}})}var yi,no,oh,xi=v(()=>{"use strict";H();yi=require("zod");I();no=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.url;if(!n)throw new Error("Missing URL for go_to_url action");let o=a.kwargs.new_tab===!0,r=i.replaceVariables(String(n));if(r.startsWith("/")){let c=e.url(),d=null;try{let h=new URL(c);h.origin&&h.origin!=="null"&&(d=h.origin)}catch{}d&&(r=d+r)}let s=a.kwargs.timeout_seconds?a.kwargs.timeout_seconds*1e3:ve,l=e;o&&(l=await e.context().newPage(),i.setPage(l)),await l.goto(r,{timeout:s})}transpile(e){let t=e.action_data?.kwargs?.url||"",i=e.action_data?.kwargs?.new_tab===!0,a=e.action_data?.kwargs?.timeout_seconds,n=[`url: ${JSON.stringify(t)}`];return i&&n.push("new_tab: true"),a&&n.push(`timeout_seconds: ${a}`),['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { ${n.join(", ")} } },`,"});"]}},oh=yi.z.object({url:yi.z.string().describe('URL to navigate to (HTTP/HTTPS URL, or a path like "/home")'),new_tab:yi.z.boolean().optional().describe("If true, open the URL in a new tab instead of the current page. Default is false."),timeout_seconds:yi.z.number().positive().optional().describe("Navigation timeout in seconds. Default is 20 seconds.")})});async function rh(e,t,i,a,n={}){return{...await R(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function wl(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function bl(e,t){e.register({name:"hover",description:"Hover over an interactive element.",schema:sh,usesElementIndex:!0,async execute(i,a){let{element_index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Element with index ${n} not found.`,actionEntity:wl(`Hover element ${n}`,"hover",{index:n})};let c=s||`Hover over element ${n}`,d=await rh("hover",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Hovered over element ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:wl(`Hover element ${n}`,"hover",{index:n})}}}})}var Pn,ao,sh,vi=v(()=>{"use strict";Y();H();Pn=require("zod");I();ao=class{async execute(e,t,i){let a=L(e,t),n=C(i,t.action_data?.kwargs?.timeout_ms);if(a){await a.waitFor({state:"attached",timeout:n});let o=await a.elementHandle();if(!o)throw new Error("Unable to obtain element handle for hover action");let r=await o.boundingBox();if(!r)throw new Error("Unable to determine bounding box for hover action");let s=r.x+r.width/2,l=r.y+r.height/2;await e.mouse.move(s,l)}else throw new Error("No locator found for hover action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("hover", page, {});']:['await agent.execAction("hover", page, {',...t.map(i=>` ${i},`),"});"]}};sh=Pn.z.object({element_index:Pn.z.number().int().describe("Index of the element to hover over"),timeout_ms:Pn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function xl(e,t){e.register({name:"ai_extract",description:"Use AI to extract information from the page and save it to a variable. MCP-only tool.",schema:lh,async execute(i,a){let{element_description:n,variable_name:o}=i,{page:r,agentServices:s}=a;try{let l={action_description:`Extract ${n} to ${o}`,action_data:{action_name:"ai_extract",kwargs:{element_description:n,variable_name:o}}};return await t.execute(r,l,s),{success:!0,actionEntity:l,message:`Extracted ${n} to ${o}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:`Extract ${n} (failed)`,action_data:{action_name:"ai_extract",kwargs:{element_description:n,variable_name:o}},feedback:l.message}}}},availability:{openai:!1,mcp:!0}})}var Cn,yl,lh,_i=v(()=>{"use strict";Cn=require("zod"),yl=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.element_description,o=a.kwargs.variable_name;if(!n||!o)throw new Error("Missing element_description or variable_name for ai_extract");let r=`Extract ${n} and save to ${o}`,{executeStep:s}=await Promise.resolve().then(()=>(gt(),mt)),l=await s(r,e,i);if(l.status!=="success")throw new Error(l.error||"Extraction failed")}transpile(e,t){let i=e.action_data?.kwargs?.element_description,a=e.action_data?.kwargs?.variable_name;if(!i||!a)return["// Skipping ai_extract: missing element_description or variable_name"];let n=JSON.stringify(i),o=JSON.stringify(a);return[`await agent.extract(page, ${n}, ${o}, '${t||""}');`]}},lh=Cn.z.object({element_description:Cn.z.string().describe('Description of the element to extract (e.g., "the price of the product")'),variable_name:Cn.z.string().describe("Name of the variable to store the extracted value")})});async function ch(e,t,i,a,n={}){return{...await R(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function vl(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function kl(e,t){e.register({name:"clear_input",description:"Clear the contents of an input field, textarea, or other editable element.",schema:dh,usesElementIndex:!0,async execute(i,a){let{element_index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Input element with index ${n} not found`,actionEntity:vl(s||`Clear element ${n}`,"clear_input",{index:n})};let c=s||`Clear element ${n}`,d=await ch("clear_input",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Cleared element ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:vl(`Clear element ${n}`,"clear_input",{index:n})}}}})}var On,_l,dh,ki=v(()=>{"use strict";Y();H();On=require("zod");I();_l=class{async execute(e,t,i){let a=L(e,t),n=C(i,t.action_data?.kwargs?.timeout_ms);if(a)await a.click({timeout:n}),await e.keyboard.press("ControlOrMeta+a"),await e.waitForTimeout(200),await e.keyboard.press("Backspace"),await e.waitForTimeout(200);else throw new Error("No locator found for clear_input action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("clear_input", page, {});']:['await agent.execAction("clear_input", page, {',...t.map(i=>` ${i},`),"});"]}};dh=On.z.object({element_index:On.z.number().int().describe("Index of the input element to clear"),timeout_ms:On.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});async function uh(e,t,i,a,n={}){return{...await R(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function Sl(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function El(e,t){e.register({name:"click",description:"Click an interactive element.",schema:hh,usesElementIndex:!0,async execute(i,a){let{element_index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Element with index ${n} not found.`,actionEntity:Sl(`Click element ${n}`,"click",{index:n})};let c=s||`Click element ${n}`,d=await uh("click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Clicked element ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:Sl(`Click element ${n}`,"click",{index:n})}}}})}var Ln,Nn,hh,Si=v(()=>{"use strict";Y();H();Ln=require("zod");I();Nn=class{async execute(e,t,i){let a=L(e,t),n=C(i,t.action_data?.kwargs?.timeout_ms);if(a)await a.click({timeout:n});else throw new Error("No locator found for click action")}transpile(e){let t=We(e);if(!t)return['await agent.execAction("click", page, {});'];let i=C();return[`await ${t}.click({ timeout: ${i} });`]}};hh=Ln.z.object({element_index:Ln.z.number().int().describe("Index of the element to click (0-based). Return -1 if no element found"),timeout_ms:Ln.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Al(e,t){e.register({name:"close_tab",description:"Close a browser tab by index. If no index is specified, closes the current tab.",schema:ph,async execute(i,a){let{index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l={action_description:s||`Close tab ${n}`,action_data:{action_name:"close_tab",kwargs:{page_id:n}}};return await t.execute(o,l,r),{success:!0,actionEntity:l,message:`Closed tab ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:{action_description:(s||"Close tab")+" (failed)",action_data:{action_name:"close_tab",kwargs:{}},feedback:l.message}}}}})}var oo,Tl,ph,Ei=v(()=>{"use strict";oo=require("zod"),Tl=class{async execute(e,t,i){let a=t.action_data;if(!a)throw new Error("Action data not found");let n=a.kwargs.page_id??a.kwargs.index;if(n===void 0&&(n=e.context().pages().indexOf(e)),typeof n=="number"){if(n===0)throw new Error("Cannot close the first tab (page_id 0). Skipping close_tab action.");i&&await i.closeTab(n)}else throw new Error("Missing page_id for close_tab action")}transpile(e){let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]}},ph=oo.z.object({index:oo.z.number().int().nonnegative().optional().describe("Index of the tab to close (0-based). Defaults to current tab if not specified.")})});function Ml(e,t){e.register({name:"done",description:"Mark the current task as complete. Use when you have finished all requested actions.",schema:mh,async execute(i,a){let{page:n,agentServices:o}=a;try{let r={action_description:"Task completed",action_data:{action_name:"done",kwargs:{}}};return await t.execute(n,r,o),{success:!0,actionEntity:r,message:"Task marked as complete"}}catch(r){return{success:!1,error:r.message,actionEntity:{action_description:"Task completed (failed)",action_data:{action_name:"done",kwargs:{}},feedback:r.message}}}}})}var Dn,$l,mh,Ti=v(()=>{"use strict";Dn=require("zod"),$l=class{async execute(e,t){}transpile(e){return["// Done - no action needed"]}},mh=Dn.z.object({success:Dn.z.boolean().describe("Whether the task was completed successfully"),summary:Dn.z.string().describe("Summary of what was accomplished or why it failed")})});async function gh(e,t,i,a,n={}){return{...await R(a,i),action_description:t,action_data:{action_name:e,kwargs:{...n}}}}function Il(e,t,i){return{action_description:`${e} (failed - element not found)`,action_data:{action_name:t,kwargs:i},feedback:"Element not found in DOM"}}function Pl(e,t){e.register({name:"double_click",description:"Double-click an interactive element.",schema:fh,usesElementIndex:!0,async execute(i,a){let{element_index:n}=i,{page:o,agentServices:r,actionDescription:s}=a;try{let l=await U(a,n);if(!l)return{success:!1,error:`Element with index ${n} not found.`,actionEntity:Il(`Double-click element ${n}`,"double_click",{index:n})};let c=s||`Double-click element ${n}`,d=await gh("double_click",c,l,o);return await t.execute(o,d,r),{success:!0,actionEntity:d,message:`Double-clicked element ${n}`}}catch(l){return{success:!1,error:l.message,actionEntity:Il(`Double-click element ${n}`,"double_click",{index:n})}}}})}var Rn,ro,fh,Ai=v(()=>{"use strict";Y();H();Rn=require("zod");I();ro=class{async execute(e,t,i){let a=L(e,t),n=C(i,t.action_data?.kwargs?.timeout_ms);if(a)await a.dblclick({timeout:n});else throw new Error("No locator found for double_click action")}transpile(e){let t=[];return e.locator?t.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("double_click", page, {});']:['await agent.execAction("double_click", page, {',...t.map(i=>` ${i},`),"});"]}};fh=Rn.z.object({element_index:Rn.z.number().int().describe("Index of the element to double-click"),timeout_ms:Rn.z.number().optional().describe("Per-action timeout in ms. Overrides the default 5s action timeout.")})});function Ol(e){if(!e.trim())return!1;try{return(0,Cl.parse)(e,{sourceType:"module",plugins:["typescript"]}),!0}catch{return!1}}var Cl,Fn=v(()=>{"use strict";Cl=require("@babel/parser")});function Ll(e,t){e.register({name:"verify",description:"Verify that a statement is true based on the current page state. Use this to check assertions about the page content, element visibility, or any condition.",schema:wh,async execute(i,a){let{statement:n}=i,{page:o,agentServices:r}=a;try{let s={action_description:`${n}`,action_data:{action_name:"verify",kwargs:{statement:n}}};return await t.execute(o,s,r),{success:!0,actionEntity:s,message:`Assertion verified: ${n}`}}catch(s){return{success:!1,error:s.message,actionEntity:{action_description:`Verify: ${n} (failed)`,action_data:{action_name:"verify",kwargs:{statement:n}},feedback:s.message}}}},availability:{openai:!0,mcp:!0}})}var so,Hn,wh,$i=v(()=>{"use strict";zt();Fn();F();so=require("zod"),Hn=class{async execute(e,t,i){let a=t.action_data?.kwargs,n=typeof a?.code=="string",o=n?a?.statement||t.action_description:t.action_description||a?.statement;if(n&&o){let d=Date.now();try{await this.executeJSAssertion(e,a.code,i),u.info(`[VERIFY:JS] \u2713 ${((Date.now()-d)/1e3).toFixed(1)}s: ${o}`),i.addNote(`Assertion passed: ${o}`);return}catch(h){let m=((Date.now()-d)/1e3).toFixed(1);u.info(`[VERIFY:JS\u2192AI] JS failed ${m}s (${h instanceof Error?h.message:String(h)}), falling back to AI: ${o}`)}}else if(n){let d=Date.now();await this.executeJSAssertion(e,a.code,i),u.info(`[VERIFY:JS] \u2713 ${((Date.now()-d)/1e3).toFixed(1)}s: ${o||"js-only"}`),i.addNote(`Assertion passed: ${o||"js-only"}`);return}if(!o)throw new Error("Missing statement or code for verify action");let r=Date.now();u.info(`[VERIFY:AI] Evaluating: ${o}`);let{evaluateStatement:s}=await Promise.resolve().then(()=>(gt(),mt)),l=await s(o,e,i,{useCleanScreenshotForAssertion:!0}),c=l.explanation||l.error||(l.success?`Assertion passed: ${o}`:"Assertion failed");if(i.addNote(c),!l.success)throw u.info(`[VERIFY:AI] \u2717 ${((Date.now()-r)/1e3).toFixed(1)}s: ${o}`),new Error(l.error||l.explanation||"Assertion failed");u.info(`[VERIFY:AI] \u2713 ${((Date.now()-r)/1e3).toFixed(1)}s: ${o}`)}async executeJSAssertion(e,t,i){let a=i.agent;if(!a)throw new Error("Agent not initialized on AgentServices \u2014 ai_assert requires an agent reference");try{await new Function("page","expect","agent",`
|
|
4107
4107
|
return (async () => {
|
|
4108
4108
|
${t}
|
|
4109
4109
|
})();
|
|
@@ -4360,12 +4360,12 @@ ${m.join(`
|
|
|
4360
4360
|
`).match(/\bawait\b/g),n=a?a.length:0;return i<=jo&&n<=Ko?null:`${i} non-blank line(s), ${n} await(s) \u2014 limits are ${jo} lines and ${Ko} awaits. The VERIFY js: field is a cache for one natural-language assertion, not a place for multi-step logic. Break this into multiple statements \u2014 one VERIFY per assertion \u2014 so each step is visible in the debugger and self-healable. For freeform setup code (mocking, storage), use the description: + js: escape hatch, which has no complexity cap.`}function oa(e,t){let i=t?.coverageThreshold??Wc,a=[],n=[],o;try{o=$e(e)}catch(m){return{valid:!1,errors:[`Invalid YAML: ${m.message}`],warnings:[],stats:{total:0,action:0,draft:0,coverage:0}}}o.goal||a.push('Missing required field: "goal"'),o.statements?.length||a.push('Missing required field: "statements"');let r=[...Ni(o.statements??[]),...o.teardown?Ni(o.teardown):[]],{action:s,draft:l}=Xo(r),c="Hint: in YAML double-quoted strings, backslashes are escape characters \u2014 use \\\\/ instead of \\/ for regex, or use single quotes.";for(let m of r){let g=m;if(g.reference_id!==void 0){let w=g.description||m.uid;a.push(`Unresolved cloud template reference on statement "${w}" (reference_id: ${g.reference_id}). Local YAML tests cannot use reference_id \u2014 inline the template statements or use the local "template:" key instead.`)}if(m.type==="ACTION"){let w=m,x=w.action_entity?.action_data?.action_name??"";if(x==="js_code"||x==="js_action"||x==="verify"||x==="ai_assert"){let b=w.action_entity?.action_data?.kwargs?.code;if(typeof b=="string"){let p=Uc(b);if(p){let y=w.description||x;a.push(`Invalid JS in "${y}": ${p}. ${c}`)}else if(x==="verify"){let y=Bc(b);if(y){let _=w.description||x;a.push(`JS cache for "${_}" is too complex: ${y}`)}}}}}if(m.type==="IF_ELSE"){let w=m;if(w.condition.type==="JS_CODE"){let x=zo(w.condition.expression);x&&a.push(`Invalid JS in IF condition "${w.condition.expression}": ${x}. ${c}`)}}if(m.type==="WHILE_LOOP"){let w=m;if(w.condition.type==="JS_CODE"){let x=zo(w.condition.expression);x&&a.push(`Invalid JS in WHILE condition "${w.condition.expression}": ${x}. ${c}`)}}}let d=s+l,h=d>0?Math.round(s/d*100):0;return d>0&&h/100<i&&n.push(`Low action coverage: ${s}/${d} statements (${h}%) are enriched with action/js. ${l} draft statement(s) still need enrichment. Use MCP tools (act, get_locators) to convert drafts to actions.`),{valid:a.length===0,errors:a,warnings:n,stats:{total:d,action:s,draft:l,coverage:h}}}var ge=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(ge||{});var ra=18e4;var Yo=112;var Kc=1080-Yo;var Jo={"Blackberry PlayBook":{name:"Blackberry PlayBook",userAgent:"Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/26.0 Safari/536.2+",screen:{width:600,height:1024},viewport:{width:600,height:1024},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"BlackBerry Z30":{name:"BlackBerry Z30",userAgent:"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/26.0 Mobile Safari/537.10+",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note 3":{name:"Galaxy Note 3",userAgent:"Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy Note II":{name:"Galaxy Note II",userAgent:"Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S III":{name:"Galaxy S III",userAgent:"Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/26.0 Mobile Safari/534.30",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Galaxy S5":{name:"Galaxy S5",userAgent:"Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S8":{name:"Galaxy S8",userAgent:"Mozilla/5.0 (Linux; Android 7.0; SM-G950U Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:740},viewport:{width:360,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S9+":{name:"Galaxy S9+",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:320,height:658},viewport:{width:320,height:658},deviceScaleFactor:4.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy S24":{name:"Galaxy S24",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-S921U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:780},viewport:{width:360,height:780},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy A55":{name:"Galaxy A55",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-A556B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:480,height:1040},viewport:{width:480,height:1040},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S4":{name:"Galaxy Tab S4",userAgent:"Mozilla/5.0 (Linux; Android 8.1.0; SM-T837A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:712,height:1138},viewport:{width:712,height:1138},deviceScaleFactor:2.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Galaxy Tab S9":{name:"Galaxy Tab S9",userAgent:"Mozilla/5.0 (Linux; Android 14; SM-X710) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:640,height:1024},viewport:{width:640,height:1024},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"iPad (gen 5)":{name:"iPad (gen 5)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 6)":{name:"iPad (gen 6)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 7)":{name:"iPad (gen 7)",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:810,height:1080},viewport:{width:810,height:1080},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad (gen 11)":{name:"iPad (gen 11)",userAgent:"Mozilla/5.0 (iPad; CPU OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/604.1",screen:{width:656,height:944},viewport:{width:656,height:944},deviceScaleFactor:2.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Mini":{name:"iPad Mini",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:768,height:1024},viewport:{width:768,height:1024},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPad Pro 11":{name:"iPad Pro 11",userAgent:"Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:834,height:1194},viewport:{width:834,height:1194},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6":{name:"iPhone 6",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 6 Plus":{name:"iPhone 6 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7":{name:"iPhone 7",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 7 Plus":{name:"iPhone 7 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8":{name:"iPhone 8",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 8 Plus":{name:"iPhone 8 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:414,height:736},viewport:{width:414,height:736},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE":{name:"iPhone SE",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/14E304 Safari/602.1",screen:{width:320,height:568},viewport:{width:320,height:568},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone SE (3rd gen)":{name:"iPhone SE (3rd gen)",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/26.0 Mobile/19E241 Safari/602.1",screen:{width:375,height:667},viewport:{width:375,height:667},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone X":{name:"iPhone X",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/26.0 Mobile/15A372 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:812},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone XR":{name:"iPhone XR",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:896},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11":{name:"iPhone 11",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro":{name:"iPhone 11 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:635},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 11 Pro Max":{name:"iPhone 11 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:414,height:896},viewport:{width:414,height:715},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12":{name:"iPhone 12",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro":{name:"iPhone 12 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Pro Max":{name:"iPhone 12 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 12 Mini":{name:"iPhone 12 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13":{name:"iPhone 13",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro":{name:"iPhone 13 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Pro Max":{name:"iPhone 13 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 13 Mini":{name:"iPhone 13 Mini",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:375,height:812},viewport:{width:375,height:629},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14":{name:"iPhone 14",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:390,height:844},viewport:{width:390,height:664},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Plus":{name:"iPhone 14 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:428,height:926},viewport:{width:428,height:746},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro":{name:"iPhone 14 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:660},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 14 Pro Max":{name:"iPhone 14 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:740},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15":{name:"iPhone 15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Plus":{name:"iPhone 15 Plus",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro":{name:"iPhone 15 Pro",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:393,height:852},viewport:{width:393,height:659},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"iPhone 15 Pro Max":{name:"iPhone 15 Pro Max",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Mobile/15E148 Safari/604.1",screen:{width:430,height:932},viewport:{width:430,height:739},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Kindle Fire HDX":{name:"Kindle Fire HDX",userAgent:"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"LG Optimus L70":{name:"LG Optimus L70",userAgent:"Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; LGMS323 Build/KOT49I.MS32310c) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:1.25,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 550":{name:"Microsoft Lumia 550",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 550) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Microsoft Lumia 950":{name:"Microsoft Lumia 950",userAgent:"Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 950) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36 Edge/14.14263",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:4,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 10":{name:"Nexus 10",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 10 Build/MOB31T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:800,height:1280},viewport:{width:800,height:1280},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 4":{name:"Nexus 4",userAgent:"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:384,height:640},viewport:{width:384,height:640},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5":{name:"Nexus 5",userAgent:"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 5X":{name:"Nexus 5X",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 5X Build/OPR4.170623.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6":{name:"Nexus 6",userAgent:"Mozilla/5.0 (Linux; Android 7.1.1; Nexus 6 Build/N6F26U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 6P":{name:"Nexus 6P",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Nexus 6P Build/OPP3.170518.006) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:732},viewport:{width:412,height:732},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nexus 7":{name:"Nexus 7",userAgent:"Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MOB30X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:600,height:960},viewport:{width:600,height:960},deviceScaleFactor:2,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia Lumia 520":{name:"Nokia Lumia 520",userAgent:"Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 520)",screen:{width:320,height:533},viewport:{width:320,height:533},deviceScaleFactor:1.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Nokia N9":{name:"Nokia N9",userAgent:"Mozilla/5.0 (MeeGo; NokiaN9) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13",screen:{width:480,height:854},viewport:{width:480,height:854},deviceScaleFactor:1,isMobile:!0,hasTouch:!0,defaultBrowserType:"webkit"},"Pixel 2":{name:"Pixel 2",userAgent:"Mozilla/5.0 (Linux; Android 8.0; Pixel 2 Build/OPD3.170816.012) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:731},viewport:{width:411,height:731},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 2 XL":{name:"Pixel 2 XL",userAgent:"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:411,height:823},viewport:{width:411,height:823},deviceScaleFactor:3.5,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 3":{name:"Pixel 3",userAgent:"Mozilla/5.0 (Linux; Android 9; Pixel 3 Build/PQ1A.181105.017.A1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:786},viewport:{width:393,height:786},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4":{name:"Pixel 4",userAgent:"Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:353,height:745},viewport:{width:353,height:745},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 4a (5G)":{name:"Pixel 4a (5G)",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:892},viewport:{width:412,height:765},deviceScaleFactor:2.63,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 5":{name:"Pixel 5",userAgent:"Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:393,height:851},viewport:{width:393,height:727},deviceScaleFactor:2.75,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Pixel 7":{name:"Pixel 7",userAgent:"Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:412,height:915},viewport:{width:412,height:839},deviceScaleFactor:2.625,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Moto G4":{name:"Moto G4",userAgent:"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Mobile Safari/537.36",screen:{width:360,height:640},viewport:{width:360,height:640},deviceScaleFactor:3,isMobile:!0,hasTouch:!0,defaultBrowserType:"chromium"},"Desktop Chrome HiDPI":{name:"Desktop Chrome HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge HiDPI":{name:"Desktop Edge HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Firefox HiDPI":{name:"Desktop Firefox HiDPI",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"},"Desktop Safari":{name:"Desktop Safari",userAgent:"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.0 Safari/605.1.15",screen:{width:1792,height:1120},viewport:{width:1280,height:720},deviceScaleFactor:2,isMobile:!1,hasTouch:!1,defaultBrowserType:"webkit"},"Desktop Chrome":{name:"Desktop Chrome",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome Medium Resolution":{name:"Desktop Chrome Medium Resolution",displayName:"Playwright Chromium",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Chrome (Branded)":{name:"Desktop Chrome (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Chrome Medium Resolution (Branded)":{name:"Desktop Chrome Medium Resolution (Branded)",displayName:"Google Chrome",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"chrome"},"Desktop Edge":{name:"Desktop Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium"},"Desktop Edge (Branded)":{name:"Desktop Edge (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1920,height:1080},viewport:{width:1920,height:1080},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Edge Medium Resolution (Branded)":{name:"Desktop Edge Medium Resolution (Branded)",displayName:"Microsoft Edge",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.16 Safari/537.36 Edg/141.0.7390.16",screen:{width:1280,height:720},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"chromium",channel:"msedge"},"Desktop Firefox":{name:"Desktop Firefox",userAgent:"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:142.0.1) Gecko/20100101 Firefox/142.0.1",screen:{width:1920,height:1080},viewport:{width:1280,height:720},deviceScaleFactor:1,isMobile:!1,hasTouch:!1,defaultBrowserType:"firefox"}};var qo={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"]},Tt=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),qo[e].map(a=>Jo[a]).filter(a=>a.defaultBrowserType&&i.includes(a.defaultBrowserType))};var zc={desktop:{label:"Desktop",type:"desktop",devices:Tt("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:Tt("mobile")}},Vc={desktop:{label:"Desktop",type:"desktop",devices:Tt("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:Tt("mobile",!0)}};var ir=require("yaml");var Fi=G(require("path"),1),rr=require("crypto"),$t=require("yaml");var Bi=require("fs"),tt=require("path"),At=require("yaml"),Mt=require("fs"),la=require("path");var ca=5e3;function be(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function V(e){return e.replace(/\r\n/g," ").replace(/\n/g," ").replace(/\r/g," ").trim()}function Xc(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function Yc(e){let t=e.xpath;return typeof t=="string"&&t.trim()?!t.startsWith("xpath=")&&!t.startsWith("/")&&!t.startsWith("//")?`xpath=//${t}`:t.startsWith("xpath=")?t:`xpath=${t}`:null}function Hi(e){let t=Xc(e),i=e.locator;if(typeof i=="string"&&i.trim())return i=i.trim(),i.endsWith("first()")?`${t}.${i}`:`${t}.${i}.first()`;let a=Yc(e);if(a){let n=JSON.stringify(a);return`${t}.locator(${n}).first()`}return null}var Jc=["ai_action","ai_step","ai_assert","ai_extract","ai_wait_until","verify","assert"],qc=["js_code","function","wait","wait_for_download_complete","wait_for_page_ready","extract_email_content","extract_activation_code"];function Zo(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:Jc.includes(t)}function Zc(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:!qc.includes(t)}var te=new Map;function $(e,t){te.set(e,t)}function Qc(e){return te.get(e)}function je(e,t,i=[]){let a=[...i];return t.locator?a.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&a.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&a.push(`frame_path: ${JSON.stringify(t.frame_path)}`),a.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...a.map(n=>` ${n},`),"});"]}$("click",e=>{let t=Hi(e);if(!t)return['await agent.execAction("click", page, {});'];let i=e.action_data?.kwargs?.timeout_ms??ca;return[`await ${t}.click({ timeout: ${i} });`]});$("click_element",te.get("click"));$("click_element_by_index",te.get("click"));$("double_click",e=>je("double_click",e));$("double_click_on_element",te.get("double_click"));$("right_click",e=>je("right_click",e));$("right_click_on_element",te.get("right_click"));$("hover",e=>je("hover",e));$("hover_element_by_index",te.get("hover"));$("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return je("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});$("fill",te.get("input_text"));$("clear_input",e=>je("clear_input",e));$("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});$("send_keys",te.get("press"));$("send_keys_on_element",e=>{let t=Hi(e),i=e.action_data?.kwargs?.keys||"";if(!t)return['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(i)} } },`,"});"];let a=e.action_data?.kwargs?.timeout_ms??ca;return[`await ${t}.press(${JSON.stringify(i)}, { timeout: ${a} });`]});$("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return je("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});$("scroll",e=>{let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]});$("scroll_down",te.get("scroll"));$("scroll_up",te.get("scroll"));$("scroll_element",te.get("scroll"));$("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});$("scroll_on_element",e=>je("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));$("go_to_url",e=>{let t=e.action_data?.kwargs?.url||"";return e.action_data?.kwargs?.new_tab===!0?['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)}, new_tab: true } },`,"});"]:['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)} } },`,"});"]});$("open_tab",te.get("go_to_url"));$("go_back",()=>['await agent.execAction("go_back", page, {});']);$("reload_page",()=>['await agent.execAction("reload_page", page, {});']);$("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);$("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);$("verify",(e,t)=>{let i=e.action_data?.kwargs,a=typeof i?.code=="string",n=a?i?.statement||e.action_description:e.action_description||i?.statement;if(a&&n){let r=i.code.split(`
|
|
4361
4361
|
`),s=JSON.stringify(n);return["{ const _t = Date.now(); try {",...r.map(l=>` ${l}`),` console.log(\`[VERIFY:JS] \u2713 \${((Date.now()-_t)/1000).toFixed(1)}s: ${s}\`);`,"} catch (_e) {",` console.log(\`[VERIFY:JS\u2192AI] JS failed \${((Date.now()-_t)/1000).toFixed(1)}s: (\${_e instanceof Error ? _e.message : String(_e)}), falling back to AI: ${s}\`);`,` await agent.assert(page, ${s}, ${JSON.stringify(t||"")});`,"} }"]}return a?i.code.split(`
|
|
4362
4362
|
`):n?[`await agent.assert(page, ${JSON.stringify(n)}, ${JSON.stringify(t||"")});`]:["// Skipping verify: missing statement or code"]});$("ai_assert",te.get("verify"));$("assert",te.get("verify"));$("ai_action",(e,t)=>{let i=e.action_data?.kwargs?.statement;if(!i)return["// Skipping ai_action: missing statement"];let a=JSON.stringify(i),n=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${a}, '${t||""}', ${n});`]});$("ai_step",(e,t)=>{let i=e.action_data?.kwargs?.statement;return i?[`await agent.run(page, ${JSON.stringify(i)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]});$("ai_extract",(e,t)=>{let i=e.action_data?.kwargs?.element_description,a=e.action_data?.kwargs?.variable_name;if(!i||!a)return["// Skipping ai_extract: missing element_description or variable_name"];let n=JSON.stringify(i),o=JSON.stringify(a);return[`await agent.extract(page, ${n}, ${o}, '${t||""}');`]});$("ai_wait_until",(e,t)=>{let i=e.action_data?.kwargs?.condition,a=e.action_data?.kwargs?.timeout_seconds||60;return i?[`await agent.waitUntilCondition(page, ${JSON.stringify(i)}, ${a}, '${t||""}');`]:["// Skipping ai_wait_until: missing condition"]});$("save_variable",e=>{let t=e.action_data?.kwargs?.name||"",i=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(i)} } },`,"});"]});$("js_code",e=>{let t=e.action_data?.kwargs?.code;if(!t)return["// Skipping js_code: missing code"];let i=["{"],a=t.split(`
|
|
4363
|
-
`);for(let n of a)i.push(` ${n}`);return i.push("}"),i});$("function",(e,t,i)=>{let a=e.action_data?.kwargs||{},n=a.functionName;if(n&&n.includes("#")){let[r,s]=n.split("#");if(r&&s){let l=r.replace(/\.(ts|js|mjs)$/,"");if(!l.startsWith(".")
|
|
4363
|
+
`);for(let n of a)i.push(` ${n}`);return i.push("}"),i});$("function",(e,t,i)=>{let a=e.action_data?.kwargs||{},n=a.functionName;if(n&&n.includes("#")){let[r,s]=n.split("#");if(r&&s){let l=r.replace(/\.(ts|js|mjs)$/,"");if(Fi.default.isAbsolute(r))return[`throw new Error(${JSON.stringify(`Absolute paths are not supported in call: references. Use a path relative to the project root (got: "${r}")`)})`];if(!l.startsWith(".")&&i?.projectRoot&&i?.yamlDir){let m=Fi.default.resolve(i.projectRoot,l),g=Fi.default.relative(i.yamlDir,m).replace(/\\/g,"/");l=g.startsWith("..")?g:"./"+g}let c=`import { ${s} } from '${l}';`;i?.imports?.add(c);let d={...a,functionName:s},h=Qo(d);return h?[h.endsWith(";")?h:`${h};`]:["// Skipping function: invalid export pattern"]}}let o=Qo(a);return o?[o.endsWith(";")?o:`${o};`]:["// Skipping function: missing functionName"]});$("generate_2fa_code",e=>{let t=e.action_data?.kwargs?.otp_secret_key||"";return['await agent.execAction("generate_2fa_code", page, {',` action_data: { kwargs: { otp_secret_key: ${JSON.stringify(t)} } },`,"});"]});$("upload_file",e=>{let t=e.action_data?.kwargs||{},i=[],a={};return t.paths?a.paths=t.paths:t.path&&(a.path=t.path),t.use_file_input&&(a.use_file_input=!0),i.push(`action_data: { kwargs: ${JSON.stringify(a)} }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...i.map(n=>` ${n},`),"});"]});$("wait_for_download_complete",e=>['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]);$("switch_tab",e=>['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]);$("close_tab",e=>{let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]});$("set_date_for_native_date_picker",e=>{let t=e.action_data?.kwargs?.date??"",i=[];return i.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?i.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&i.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&i.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...i.map(a=>` ${a},`),"});"]});$("done",()=>["// Done - no action needed"]);function da(e,t){let i=t.action_data?.kwargs||{},a=[];return typeof i.relative_x=="number"&&typeof i.relative_y=="number"?(a.push(`action_data: { kwargs: { relative_x: ${i.relative_x}, relative_y: ${i.relative_y} } }`),t.locator?a.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&a.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&a.push(`frame_path: ${JSON.stringify(t.frame_path)}`)):typeof i.x=="number"&&typeof i.y=="number"&&a.push(`action_data: { kwargs: { x: ${i.x}, y: ${i.y} } }`),[`await agent.execAction("${e}", page, {`,...a.map(n=>` ${n},`),"});"]}$("click_by_coordinates",e=>da("click_by_coordinates",e));$("right_click_by_coordinates",e=>da("right_click_by_coordinates",e));$("double_click_by_coordinates",e=>da("double_click_by_coordinates",e));$("drag_drop",e=>{let t=e.action_data?.kwargs||{},i={};typeof t.relative_x=="number"&&(i.relative_x=t.relative_x),typeof t.relative_y=="number"&&(i.relative_y=t.relative_y),typeof t.delta_x=="number"&&(i.delta_x=t.delta_x),typeof t.delta_y=="number"&&(i.delta_y=t.delta_y),typeof t.coord_source_x=="number"&&(i.coord_source_x=t.coord_source_x),typeof t.coord_source_y=="number"&&(i.coord_source_y=t.coord_source_y),typeof t.coord_target_x=="number"&&(i.coord_target_x=t.coord_target_x),typeof t.coord_target_y=="number"&&(i.coord_target_y=t.coord_target_y);let a=[`action_data: { kwargs: ${JSON.stringify(i)} }`];return e.locator?a.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&a.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&a.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("drag_drop", page, {',...a.map(n=>` ${n},`),"});"]});$("get_dropdown_options",e=>{let t=[];return e.xpath&&t.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&t.push(`frame_path: ${JSON.stringify(e.frame_path)}`),t.length===0?['await agent.execAction("get_dropdown_options", page, {});']:['await agent.execAction("get_dropdown_options", page, {',...t.map(i=>` ${i},`),"});"]});$("extract_email_content",e=>{let t=e.action_data?.kwargs||{};return['await agent.execAction("extract_email_content", page, {',` action_data: { kwargs: ${JSON.stringify(t)} },`,"});"]});$("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
|
|
4364
4364
|
`):["// Skipping js_action: missing code"]});function Qo(e){let t=e.functionName;if(!t)return null;let i=Array.isArray(e.args)?e.args.map(String):Array.isArray(e.parameterValues)?e.parameterValues.map(String):[];if(i.length===0)return`await ${t}()`;let a=["page","testContext","request","agent"],n=["undefined","null","true","false"],o=i.map(r=>a.includes(r)||n.includes(r)||/^-?\d+(\.\d+)?$/.test(r)?r:r.startsWith("$")?`agent.agentServices.readVariable('${r.substring(1)}')`:`"${r}"`);return`await ${t}(${o.join(", ")})`}function ye(e,t,i,a="main"){let n=[];for(let o=0;o<e.length;o++){let r=e[o],s=`${a}.${o}`,l=ed(r,t,s,i);l.length>0&&(n.push(...l),o<e.length-1&&n.push(""))}return n}function ed(e,t,i,a){let n=" ".repeat(t);switch(e.type){case"DRAFT":return td(e,t,i,a);case"ACTION":return id(e,t,i,a);case"STEP":return nd(e,t,i,a);case"IF_ELSE":return ad(e,t,i,a);case"WHILE_LOOP":return od(e,t,i,a);default:return[`${n}// Unknown statement type: ${e.type}`]}}function td(e,t,i,a){let n=" ".repeat(t),o=e.description?.trim()||"";if(!o)return[`${n}// ${i}: Skipping - no description`];if(a.noAgent)return[`${n}// ${i}: ${V(o)}`,`${n}// DRAFT: ${V(o)} (requires agent - skipped in hook)`];let r=JSON.stringify(o);return[`${n}// ${i}: ${V(o)}`,`${n}// \u26A0 DRAFT: AI-resolved at runtime (~5-10s). Add a locator to make this <1s.`,`${n}page = agent.agentServices.validatePage(page);`,`${n}await agent.run(page, ${r}, '${i}');`]}function id(e,t,i,a){let n=" ".repeat(t),o=e.description,r=e.uid,l=a.actionEntityStore?.entries[e.uid]?.action_entity??e.action_entity;if(!l){if(!o)return[`${n}// ${i}: Skipping - no description`];if(a.noAgent)return[`${n}// ${i}: ${V(o)}`,`${n}// DRAFT: ${V(o)} (requires agent - skipped in hook)`];let _=JSON.stringify(o),E=!!e.use_pure_vision;return[`${n}// ${i}: ${V(o)}`,`${n}// \u26A0 DRAFT: AI-resolved at runtime (~5-10s). Add a locator to make this <1s.`,`${n}page = agent.agentServices.validatePage(page);`,`${n}await agent.execute(page, ${_}, '${i}', ${E});`]}let c=e.locator?{...l,locator:e.locator}:l;o&&o!==c.action_description&&(c={...c,action_description:o});let d=c.action_data?.action_name||"",h=c.action_description||"",m=Qc(d);if(!m)return[`${n}// ${i}: Unknown action: ${d}`,`${n}throw new Error(${JSON.stringify(`Unknown action: ${d}`)});`];let g={imports:a.imports,yamlDir:a.yamlDir,projectRoot:a.projectRoot},w=m(c,i,g);if(a.noAgent){if(Zo(c))return[`${n}// ${i}: ${V(h)}`,`${n}// AI action: ${V(h)} (requires agent - skipped in hook)`];let _=rd(c,d,n,i);return _||[`${n}// ${i}: ${V(h)}`,...w.map(E=>`${n}${E}`)]}if(Zo(c))return[`${n}// ${i}: ${V(h)}`,`${n}page = agent.agentServices.validatePage(page);`,...w.map(_=>`${n}${_}`)];let x=JSON.stringify(h),b=w.map(_=>`${n} ${_}`),p=Zc(c),y=r?`'${r}'`:"undefined";return[`${n}// ${i}: ${V(h)}`,`${n}page = agent.agentServices.validatePage(page);`,`${n}await agent.step(page, async () => {`,...b,`${n}}, ${x}, '${i}', ${y}, ${p});`]}function nd(e,t,i,a){let n=" ".repeat(t),o=[];e.description&&e.description.trim()&&o.push(`${n}// Step: ${V(e.description)}`);let r=ye(e.statements,t,a,i);return o.push(...r),o}function ad(e,t,i,a){let n=" ".repeat(t),o=[];if(o.push(`${n}// ${i}: Conditional check`),e.condition.type==="JS_CODE")o.push(`${n}if (${e.condition.expression}) {`);else{o.push(`${n}// AI Condition: ${V(e.condition.expression)}`);let s=JSON.stringify(e.condition.expression);o.push(`${n}if (await agent.evaluate(page, ${s}, "${i}")) {`)}let r=ye(e.then,t+1,a,`${i}.then`);if(o.push(...r),e.else&&e.else.length>0){o.push(`${n}} else {`);let s=ye(e.else,t+1,a,`${i}.else`);o.push(...s)}return o.push(`${n}}`),o}function od(e,t,i,a){let n=" ".repeat(t),o=[];o.push(`${n}// ${i}: Loop`);let r=e.timeout_ms??ra,s=r/1e3,l=e.timeout_ms?`While loop exceeded timeout of ${s}s`:`While loop exceeded default timeout of ${s}s`,c=`loop_${i.replace(/\./g,"_")}`;if(o.push(`${n}const ${c}_start = Date.now();`),o.push(`${n}const ${c}_timeout = ${r};`),o.push(`${n}const ${c}_check = () => {`),o.push(`${n} if (Date.now() - ${c}_start > ${c}_timeout) {`),o.push(`${n} throw new Error('${l}');`),o.push(`${n} }`),o.push(`${n} return true;`),o.push(`${n}};`),e.condition.type==="JS_CODE")o.push(`${n}while (${c}_check() && (${e.condition.expression})) {`);else{o.push(`${n}// AI Loop Condition: ${V(e.condition.expression)}`);let h=JSON.stringify(e.condition.expression);o.push(`${n}while (${c}_check() && await agent.evaluate(page, ${h}, "${i}")) {`)}let d=ye(e.body,t+1,a,`${i}.body`);return o.push(...d),o.push(`${n}}`),o}function rd(e,t,i,a){let n=e.action_description||"",o=e.action_data?.kwargs||{},r=o.timeout_ms??ca;switch(t){case"go_to_url":case"open_tab":{let s=o.url||"";return[`${i}// ${a}: ${V(n)}`,`${i}await page.goto(${JSON.stringify(s)}, { waitUntil: 'domcontentloaded' });`]}case"go_back":return[`${i}// ${a}: ${V(n)}`,`${i}await page.goBack();`];case"go_forward":return[`${i}// ${a}: ${V(n)}`,`${i}await page.goForward();`];case"input_text":{let s=o.text||"",l=Hi(e);return l?[`${i}// ${a}: ${V(n)}`,`${i}await ${l}.fill(${JSON.stringify(s)}, { timeout: ${r} });`]:null}case"select_dropdown_option":{let s=o.text||o.label||"",l=Hi(e);return l?[`${i}// ${a}: ${V(n)}`,`${i}await ${l}.selectOption({ label: ${JSON.stringify(s)} }, { timeout: ${r} });`]:null}default:return null}}function sd(e,t){let i=[],a=t?.version||"unknown";i.push(`// @generated by shiplightai v${a}`),i.push(...ar()),i.push(""),t?.use&&Object.keys(t.use).length>0&&(i.push(`test.use(${JSON.stringify(t.use,null,2)});`),i.push(""));let n=new Set,o={imports:n,actionEntityStore:t?.actionEntityStore,yamlDir:t?.yamlDir,projectRoot:t?.projectRoot};t?.beforeEach&&t.beforeEach.length>0&&(i.push(...er("beforeEach",t.beforeEach,o)),i.push(""));let r=t?.timeout||t?.skip!==void 0||t?.fail!==void 0||t?.only||t?.slow?{timeout:t.timeout,skip:t.skip,fail:t.fail,only:t.only,slow:t.slow}:void 0;if(t?.parameters&&t.parameters.length>0){let s=t?.testName||e.goal||"Generated test",l=sa(t?.tags);for(let c of t.parameters)i.push(...Ui(e,`${l}${be(s)} [${be(c.name)}]`,o,0,r,c.name,c.values)),i.push("")}else{let s=t?.testName||e.goal||"Generated test",l=sa(t?.tags);i.push(...Ui(e,`${l}${be(s)}`,o,0,r))}return t?.afterEach&&t.afterEach.length>0&&(i.push(""),i.push(...er("afterEach",t.afterEach,o))),or(i,n),i.join(`
|
|
4365
4365
|
`)}function ld(e,t){let i=[],a=t?.version||"unknown";i.push(`// @generated by shiplightai v${a}`),i.push(...ar()),i.push(""),t?.use&&Object.keys(t.use).length>0&&(i.push(`test.use(${JSON.stringify(t.use,null,2)});`),i.push(""));let n=new Set,o={imports:n,actionEntityStore:t?.actionEntityStore,yamlDir:t?.yamlDir,projectRoot:t?.projectRoot},r=t?.testName||"Test Suite",s=sa(t?.tags);i.push(`test.describe.serial('${s}${be(r)}', () => {`),e.beforeAll&&e.beforeAll.length>0&&(i.push(...Ri("beforeAll",e.beforeAll,o,1)),i.push("")),e.beforeEach&&e.beforeEach.length>0&&(i.push(...Ri("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 m of d.parameters)i.push(...Ui(d.testFlow,`${be(d.name)} [${be(m.name)}]`,o,1,h,m.name,m.values)),i.push("");else i.push(...Ui(d.testFlow,be(d.name),o,1,h)),(c<e.tests.length-1||e.afterEach||e.afterAll)&&i.push("")}return e.afterEach&&e.afterEach.length>0&&(i.push(...Ri("afterEach",e.afterEach,o,1)),i.push("")),e.afterAll&&e.afterAll.length>0&&i.push(...Ri("afterAll",e.afterAll,o,1)),i.push("});"),or(i,n),i.join(`
|
|
4366
4366
|
`)}function sa(e){return e&&e.length>0?e.map(t=>`@${t}`).join(" ")+" ":""}var cd=["testContext","request"];function Wi(e){let t=new Set;function i(a){for(let n of a)switch(n.type){case ge.ACTION:{let r=n.action_entity?.action_data?.kwargs,s=[...Array.isArray(r?.args)?r.args:[],...Array.isArray(r?.parameterValues)?r.parameterValues:[]];for(let l of s)typeof l=="string"&&cd.includes(l)&&t.add(l);break}case ge.STEP:i(n.statements);break;case ge.IF_ELSE:{let o=n;i(o.then),o.else&&i(o.else);break}case ge.WHILE_LOOP:i(n.body);break}}return i(e),t}function dd(e){let t=Wi(e.statements??[]);if(e.teardown)for(let i of Wi(e.teardown))t.add(i);return t}function ua(e){return`{ ${["page","agent",...Array.from(e).sort()].join(", ")} }`}function Ui(e,t,i,a=0,n,o,r){let s=" ".repeat(a),l=[],c=dd(e),d=ua(c),h=n?.only?"test.only":"test",m=o?`, { tag: '@${be(o)}' }`:"";if(l.push(`${s}${h}('${t}'${m}, async (${d}) => {`),n?.skip===!0?l.push(`${s} test.skip();`):typeof n?.skip=="string"&&l.push(`${s} test.skip(true, '${be(n.skip)}');`),n?.fail===!0?l.push(`${s} test.fail();`):typeof n?.fail=="string"&&l.push(`${s} test.fail(true, '${be(n.fail)}');`),n?.slow&&l.push(`${s} test.slow();`),n?.timeout&&l.push(`${s} test.setTimeout(${n.timeout});`),r){for(let[x,b]of Object.entries(r))l.push(`${s} agent.agentServices.saveVariable(${JSON.stringify(x)}, ${JSON.stringify(b)});`);l.push("")}let g=e.teardown&&e.teardown.length>0,w=a+1;if(g){if(l.push(`${s} try {`),e.statements&&e.statements.length>0){l.push(`${s} // Test steps`);let b=ye(e.statements,w+1,i);l.push(...b)}l.push(`${s} } finally {`),l.push(`${s} // Teardown`);let x=ye(e.teardown,w+1,i,"teardown");l.push(...x),l.push(`${s} }`)}else if(e.statements&&e.statements.length>0){l.push(`${s} // Test steps`);let x=ye(e.statements,w,i);l.push(...x)}return l.push(`${s}});`),l}function er(e,t,i){let a=[],n=nr(t),o=Wi(n),r=ua(o);return a.push(`test.${e}(async (${r}) => {`),a.push(...ye(n,1,i,e)),a.push("});"),a}function Ri(e,t,i,a){let n=" ".repeat(a),o=[],r=nr(t);if(e==="beforeAll"||e==="afterAll"){let l={...i,noAgent:!0};o.push(`${n}test.${e}(async ({ browser }, workerInfo) => {`),o.push(`${n} const page = await browser.newPage({ baseURL: workerInfo.project.use.baseURL });`),o.push(...ye(r,a+1,l,e)),o.push(`${n} await page.close();`),o.push(`${n}});`)}else{let l=Wi(r),c=ua(l);o.push(`${n}test.${e}(async (${c}) => {`),o.push(...ye(r,a+1,i,e)),o.push(`${n}});`)}return o}function nr(e){let i=(0,ir.stringify)({goal:"_hook",statements:e});return $e(i).statements??[]}function ar(){return["import { test, expect } from 'shiplightai/fixture';"]}function or(e,t){if(t.size>0){let i=0;for(let n=0;n<e.length;n++)e[n].startsWith("import ")&&(i=n+1);let a=Array.from(t);e.splice(i,0,...a)}}var tr=5;function sr(e,t,i){let a={expandingPaths:new Set([(0,tt.resolve)(t)]),depth:0,referencedPaths:new Set,basePath:i},n={...e};Array.isArray(n.statements)&&(n.statements=Fe(n.statements,t,a)),Array.isArray(n.teardown)&&(n.teardown=Fe(n.teardown,t,a));for(let o of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(n[o])&&(n[o]=Fe(n[o],t,a));return{doc:n,referencedTemplatePaths:Array.from(a.referencedPaths)}}function Fe(e,t,i){let a=[];for(let n of e)if(ud(n)){let o=hd(n,t,i);a.push(o)}else a.push(pd(n,t,i));return a}function ud(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function hd(e,t,i){if(i.depth>=tr)throw new Error(`Template expansion exceeded maximum depth of ${tr}. Check for deeply nested or circular template references.`);let a=(0,tt.resolve)((0,tt.dirname)(t),e.template),n=!(0,Bi.existsSync)(a)&&i.basePath?(0,tt.resolve)(i.basePath,e.template):a;if(i.expandingPaths.has(n))throw new Error(`Circular template reference detected: ${n} is already being expanded. Stack: ${Array.from(i.expandingPaths).join(" \u2192 ")} \u2192 ${n}`);i.referencedPaths.add(n);let o;try{o=(0,Bi.readFileSync)(n,"utf-8")}catch(w){throw new Error(`Failed to read template file: ${n} (referenced from ${t}): ${w.message}`)}let r=(0,At.parse)(o);if(!r||typeof r!="object")throw new Error(`Invalid template file: ${n} \u2014 expected a YAML object`);let s=r.params||[],l=e.params||{};for(let w of s)if(!(w in l))throw new Error(`Template ${e.template} requires param "${w}" but it was not provided. Required params: [${s.join(", ")}]`);let c=r.statements;if(!Array.isArray(c))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(l).length>0){let x=(0,At.stringify)(c);for(let[b,p]of Object.entries(l))x=x.split(`<<${b}>>`).join(String(p));c=(0,At.parse)(x)}let d={expandingPaths:new Set([...i.expandingPaths,n]),depth:i.depth+1,referencedPaths:i.referencedPaths},h=Fe(c,n,d),g={STEP:r.name||e.template.replace(/\.yaml$/,"").split("/").pop()||e.template,template_path:e.template,statements:h};return Object.keys(l).length>0&&(g.template_params=l),g}function pd(e,t,i){if(typeof e!="object"||e===null)return e;let a={...e};return Array.isArray(a.statements)&&(a.statements=Fe(a.statements,t,i)),Array.isArray(a.THEN)&&(a.THEN=Fe(a.THEN,t,i)),Array.isArray(a.ELSE)&&(a.ELSE=Fe(a.ELSE,t,i)),Array.isArray(a.DO)&&(a.DO=Fe(a.DO,t,i)),a}var ha=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}};function pa(e,t,i){let a=(0,$t.parse)(e),n=a?.name,o=a?.tags,r=a?.use;if(a&&(a.name!==void 0||a.tags!==void 0||a.use!==void 0)&&(delete a.name,delete a.tags,delete a.use),a?.suite){if(a.goal||a.statements)throw new ha('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return gd(a,n,o,r,t,i)}return md(a,n,o,r,t,i)}function md(e,t,i,a,n,o){let r=e?.beforeEach,s=e?.afterEach,l=lr(e?.parameters),c=e?.timeout,d=e?.skip,h=e?.fail,m=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 ha(`The "url" field is not supported in local YAML tests. Use "base_url: ${e.url}" and add "- URL: /" as the first statement instead.`);e&&!e.goal&&t&&(e.goal=t);let w=[];if(n&&e&&typeof e=="object"){let p=sr(e,n,o);e=p.doc,w=p.referencedTemplatePaths}let x=(0,$t.stringify)(e),b=$e(x);return n&&(et(b.statements??[],n,"main"),b.teardown&&et(b.teardown,n,"teardown")),{testFlow:b,name:t,tags:i,use:a,beforeEach:r,afterEach:s,parameters:l,timeout:c,skip:d,fail:h,only:m,slow:g,referencedTemplatePaths:w}}function gd(e,t,i,a,n,o){let r=e.suite;if(!Array.isArray(r.tests)||r.tests.length===0)throw new Error('Suite must have a non-empty "tests" array.');let s=r.beforeAll,l=r.afterAll,c=r.beforeEach,d=r.afterEach,h=[],m=r.tests.map(x=>{if(!x.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(x.statements)||x.statements.length===0)throw new Error(`Suite test "${x.name}" must have a non-empty "statements" array.`);let b={goal:x.name,statements:x.statements};x.teardown&&(b.teardown=x.teardown);let p=[],y=b;if(n&&typeof b=="object"){let M=sr(b,n,o);y=M.doc,p=M.referencedTemplatePaths,h.push(...p)}let _=(0,$t.stringify)(y),E=$e(_),T=lr(x.parameters);return{testFlow:E,name:x.name,tags:Array.isArray(x.tags)?x.tags:void 0,parameters:T,timeout:x.timeout,skip:x.skip,fail:x.fail,only:x.only,slow:x.slow}}),g=r.base_url,w=g?{...a,baseURL:g}:a;return{suite:{beforeAll:s,afterAll:l,beforeEach:c,afterEach:d,tests:m},name:t,tags:i,use:w,referencedTemplatePaths:h}}function lr(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 et(e,t,i){for(let a=0;a<e.length;a++){let n=e[a],o=`${i}.${a}`,r=n.description||"";if(n.uid=fd(t,o,r),n.type===ge.STEP)et(n.statements,t,o);else if(n.type===ge.IF_ELSE){let s=n;et(s.then,t,`${o}.then`),s.else&&et(s.else,t,`${o}.else`)}else n.type===ge.WHILE_LOOP&&et(n.body,t,`${o}.body`)}}function fd(e,t,i){let a=(0,rr.createHash)("sha256").update(`${e}:${t}:${i}`).digest("hex");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20,32)}`}function cr(e,t,i){let a=/\btemplate:\s/.test(e),n=/^suite:/m.test(e),o=a||n?null:oa(e);if(o&&!o.valid)return{valid:!1,errors:o.errors,warnings:[],stats:o.stats};let r,s,l=[];try{let c=i?.parsed??pa(e,t,i?.basePath);l=c.referencedTemplatePaths;let d={version:i?.version,actionEntityStore:i?.actionEntityStore,yamlDir:(0,la.dirname)(t),projectRoot:i?.projectRoot??i?.basePath},h=c.testFlow?.baseURL?{...c.use,baseURL:c.testFlow.baseURL}:c.use;c.suite?r=ld(c.suite,{...d,testName:c.name,tags:c.tags,use:c.use}):r=sd(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 m=r.split(`
|
|
4367
4367
|
`).filter(g=>!g.startsWith("import ")).join(`
|
|
4368
|
-
`);new Function(m),s=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),(0,Mt.mkdirSync)((0,la.dirname)(s),{recursive:!0}),(0,Mt.writeFileSync)(s,r)}catch(c){let d=c instanceof ha?"":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 ma="0.1.
|
|
4368
|
+
`);new Function(m),s=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),(0,Mt.mkdirSync)((0,la.dirname)(s),{recursive:!0}),(0,Mt.writeFileSync)(s,r)}catch(c){let d=c instanceof ha?"":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 ma="0.1.86";function dr(e){try{return(0,He.statSync)(e).mtimeMs}catch{return 0}}var wd=`// @generated by shiplightai v${ma}`;function bd(e,t){if(!(0,He.existsSync)(e)||(0,He.readFileSync)(e,"utf-8").split(`
|
|
4369
4369
|
`,1)[0]!==wd)return!1;let a=dr(e);for(let n of t)if(dr(n)>a)return!1;return!0}function yd(e){let t=process.argv.slice(2),i=[],a=(0,it.resolve)(e);for(let n of t){if(n.startsWith("-"))continue;let o=n.endsWith(".yaml.spec.ts")?n.replace(/\.yaml\.spec\.ts$/,".test.yaml"):n;if(!o.endsWith(".test.yaml"))continue;let r=(0,it.resolve)(e,o);(0,He.existsSync)(r)&&i.push(r.startsWith(a)?r.slice(a.length+1):o)}return i.length>0?i:null}function hr(e){let t=yd(e.cwd),i=t??(0,ur.globSync)("**/*.test.yaml",{cwd:e.cwd,ignore:["**/node_modules/**"]}),a=[];for(let n of i){let o=(0,it.resolve)(e.cwd,n),r=o.replace(/\.test\.yaml$/,".yaml.spec.ts"),s=(0,He.readFileSync)(o,"utf-8");try{let l=pa(s,o,e.projectRoot??e.cwd),c=(0,it.relative)(e.cwd,o),d=e.actionEntityStores?.get(c)??e.actionEntityStores?.get("*");if(!(d&&Object.keys(d.entries).length>0)&&bd(r,[o,...l.referencedTemplatePaths]))continue;let m=cr(s,o,{version:ma,actionEntityStore:d,parsed:l,projectRoot:e.projectRoot??e.cwd});if(!m.valid)throw new Error(m.errors.join("; "))}catch(l){console.error(`[shiplight] Failed to transpile ${n}:`,l),a.push({file:n,error:l})}}if(a.length>0){let n=`[shiplight] Transpilation failed for ${a.length} file(s):
|
|
4370
4370
|
`+a.map(o=>` - ${o.file}`).join(`
|
|
4371
4371
|
`);if(t)throw new Error(n);console.warn(n+" (skipped)")}}var ce=G(require("fs"),1),It=G(require("path"),1),vr=require("glob");Ki();function _r(e){let t=ji().SHIPLIGHT_API_TOKEN;return process.env.CI&&t?new xa:new ya(e)}var Id=".shiplight/action-cache";function xr(e){return e.replace(/\//g,"__")+".json"}function Pd(e){return e.replace(/\.json$/,"").replace(/__/g,"/")}var ya=class{constructor(t){this.cwd=t;this.cacheDir=It.join(t,Id)}isCloud=!1;cacheDir;async lookup(t){let i=new Map;if(t.length===0||!ce.existsSync(this.cacheDir))return i;for(let a of t){let n=It.join(this.cacheDir,xr(a));try{if(ce.existsSync(n)){let o=ce.readFileSync(n,"utf-8");i.set(a,JSON.parse(o))}}catch{}}return i}async update(t){if(t.size===0)return 0;ce.mkdirSync(this.cacheDir,{recursive:!0});let i=0;for(let[a,n]of t)try{let o=It.join(this.cacheDir,xr(a)),r=ta();if(ce.existsSync(o))try{r=JSON.parse(ce.readFileSync(o,"utf-8"))}catch{}let s={...r,entries:{...r.entries,...n.entries}};ce.writeFileSync(o,JSON.stringify(s,null,2)),i++}catch{}return i}loadAll(){if(!ce.existsSync(this.cacheDir))return;let t=(0,vr.globSync)("*.json",{cwd:this.cacheDir});if(t.length===0)return;let i=new Map,a=0;for(let n of t)try{let o=ce.readFileSync(It.join(this.cacheDir,n),"utf-8"),r=JSON.parse(o),s=Pd(n);i.set(s,r),a+=Object.keys(r.entries??{}).length}catch{}if(i.size!==0)return console.log(`[shiplight] Cache: loaded ${a} cached action entit${a===1?"y":"ies"} for ${i.size} test file${i.size!==1?"s":""}`),i}},xa=class{isCloud=!0;async lookup(t){let{lookupActionStores:i}=await Promise.resolve().then(()=>(ba(),wa));return i(t)}async update(t){let{updateActionStores:i}=await Promise.resolve().then(()=>(ba(),wa));return i(t)}loadAll(){}};Ki();function Cd(e,t,i){let a=t.SHIPLIGHT_PROJECT_ROOT||i;return{scanDir:e.scanDir||a,projectRoot:a}}function Er(e={}){let{scanDir:t,projectRoot:i}=Cd(e,process.env,process.cwd());e.dotenv!==!1&&Ld(t);let n=_r(t).loadAll();hr({cwd:t,projectRoot:i,actionEntityStores:n});let o=process.env.SHIPLIGHT_REPORT_DIR,r=process.env.SHIPLIGHT_RUN_ID??Od();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 Od(){let e=new Date,t=(i,a=2)=>String(i).padStart(a,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}-${t(e.getMinutes())}-${t(e.getSeconds())}-${t(e.getMilliseconds(),3)}`}function Tr(e,...t){return(0,Sr.defineConfig)(e,...t)}function Ld(e){gr(e);for(let t of ga(e))kr.default.config({path:t})}F();F();Yt();lt();var mo=require("zod"),Dh=mo.z.object({instruction:mo.z.string().describe('The instruction of the operation to perform. Can only include one operation. Do not inlcude element indexes just describe the element, e.g. "select the text "Hello, world!" in "Hello, world!""')});function Gl(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:Dh,usesElementIndex:!1,async execute(t,i){let{instruction:a}=t,n={page:i.page,agentServices:i.agentServices,domService:i.domService},o=await st(a,n,{});if(o.status==="error"||!o.actionEntity)return{success:!1,actionEntity:{action_description:a,action_data:{action_name:"perform_accurate_operation",kwargs:{instruction:a}}},error:o.error||"Failed to generate action"};let{actionEntity:r}=o,s=await Vt(r,n);return{success:s.success,actionEntity:r,message:s.success?`Successfully executed action: ${r.action_data?.action_name}`:void 0,error:s.error}}})}ke();F();var jl=require("ai"),Kl=require("html-to-text");async function Rh(e,t,i){let{apiKey:a,domain:n}=e;if(!a)throw new Error("Mailgun configuration missing. Please provide apiKey and domain");let o=!!e.baseURL,r=e.baseURL||"https://api.mailgun.net",s=e.authHeader||`Basic ${Buffer.from(`api:${a}`).toString("base64")}`,l=[];try{let c=o?`${r}/events`:`${r}/v3/${n}/events`,d={event:"accepted",limit:"10",ascending:"yes",recipient:t};if(i.from_email&&(d.from=i.from_email),i.since)d.begin=Math.floor(i.since/1e3).toString();else{let g=new Date(Date.now()-6e5);d.begin=Math.floor(g.getTime()/1e3).toString()}u.info(`Mailgun params: ${JSON.stringify(d)}`);let h=await fetch(c+"?"+new URLSearchParams(d),{method:"GET",headers:{Authorization:s}});if(!h.ok){let g=await h.text();throw new Error(`Mailgun events API error: ${g}`)}let m=(await h.json()).items||[];for(let g of m.slice(0,10)){if(g.event!=="accepted")continue;let w=(g.storage||{}).url;if(u.info(`message_url: ${w}`),!w){let p=(g.message||{}).headers||{},y=p.subject||"",_=p.from||"",E=p.to||"";if(i.from_email&&!_.toLowerCase().includes(i.from_email.toLowerCase())||i.to_email&&!E.toLowerCase().includes(i.to_email.toLowerCase())||i.subject&&!y.toLowerCase().includes(i.subject.toLowerCase()))continue;l.push({subject:y,from:_,to:E,date:new Date(g.timestamp*1e3).toUTCString(),body:"Message body not available (Mailgun storage disabled)",message_id:p["message-id"]||""});continue}let x=w.split("/"),b=x[x.length-1];if(u.info(`Storage key: ${b}`),b){let p=o?`${r}/messages/${b}`:`${r}/v3/domains/${n}/messages/${b}`;try{let y=await fetch(p,{method:"GET",headers:{Authorization:s,Accept:"application/json"}});if(y.ok){let _=await y.json(),E=_.Subject||"",T=_.From||"",M=_.To||"",O=_.Date||"",N=_["Message-Id"]||"";u.info(`subject: ${E}`),u.info(`from_addr: ${T}`),u.info(`to_addr: ${M}`),u.info(`date: ${O}`),u.info(`message_id: ${N}`);let P=_["body-html"]||_["body-plain"]||"";if(P&&P.includes("<")&&(P=(0,Kl.convert)(P)),u.info(`Body: ${P.substring(0,200)}...`),i.subject&&!E.toLowerCase().includes(i.subject.toLowerCase())||i.body_contains&&!P.toLowerCase().includes(i.body_contains.toLowerCase()))continue;l.push({subject:E,from:T,to:M,date:O,body:P,message_id:N});continue}else u.warn(`Messages API returned ${y.status}`)}catch(y){u.warn(`Failed to parse JSON response: ${y}`)}}try{let p=await fetch(w,{method:"GET",headers:{Authorization:s}});if(!p.ok){u.warn(`Could not fetch stored message: ${p.status}`);continue}let y=await p.text();u.info(`Fallback: Raw email length: ${y.length}`);let _=y.split(`
|