shiplightai 0.1.36 → 0.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agentHelpers-YPJ5MC66.js → agentHelpers-NOLZIR3C.js} +1 -1
- package/dist/chunk-OR7KAD4P.js +11 -0
- package/dist/{chunk-PTSNTQWC.js → chunk-P4BBXZ3G.js} +1 -1
- package/dist/{chunk-GSIC3VVD.js → chunk-R7ATSUFU.js} +12 -12
- package/dist/{chunk-NVQUBIDY.js → chunk-UXUHCP6Q.js} +5 -5
- package/dist/{chunk-CYYG6ENT.js → chunk-Y2PSXQRK.js} +4 -4
- package/dist/cjs/debugger-pw.cjs +10 -8
- package/dist/cjs/fixture.cjs +19 -19
- package/dist/cjs/index.cjs +119 -119
- package/dist/cjs/reporter.cjs +22 -22
- package/dist/cli.js +65 -68
- package/dist/debugger-pw.d.ts +12 -10
- package/dist/debugger-pw.js +9 -5
- package/dist/{dist-KCCHXIDD.js → dist-5DXUMQPG.js} +1 -1
- package/dist/{dist-HCR36MMH.js → dist-GUSOYM4N.js} +1 -1
- package/dist/fixture.js +1 -1
- package/dist/{handler-MFCBIUIL.js → handler-SLPMHZMZ.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/reporter.js +1 -1
- package/dist/{task-2SW3VSRI.js → task-5YHIIFEV.js} +1 -1
- package/dist/{testFlow-CMH7ZZR3.js → testFlow-HMS3VHCY.js} +1 -1
- package/package.json +2 -4
- package/dist/chunk-G7KWIGKV.js +0 -11
- package/dist/copilot-7JTVJQXP.js +0 -5
- /package/dist/{chunk-GBWDXF5V.js → chunk-7MOSQQFJ.js} +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
const require = __createRequire(import.meta.url);
|
|
3
|
-
import{d as t,e as o,f as r,g as p,h as i}from"./chunk-
|
|
3
|
+
import{d as t,e as o,f as r,g as p,h as i}from"./chunk-R7ATSUFU.js";import"./chunk-7MOSQQFJ.js";import"./chunk-YU3XZJIJ.js";import"./chunk-ZI57Y3IM.js";import"./chunk-T3H4NEVX.js";import"./chunk-T2JTBHI7.js";import"./chunk-CSINHOOD.js";export{p as evaluateStatement,t as executeAction,r as executeStep,o as generateActionStep,i as runTask};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "module";
|
|
2
|
+
const require = __createRequire(import.meta.url);
|
|
3
|
+
import{B as C,G as b,J as Y,X as U}from"./chunk-P4BBXZ3G.js";import{stringify as Q}from"yaml";import{parse as de,stringify as z}from"yaml";import{readFileSync as me}from"fs";import{resolve as K,dirname as he}from"path";import{parse as V,stringify as $e}from"yaml";import{readFileSync as Ce,writeFileSync as xe,mkdirSync as be}from"fs";import{dirname as ve}from"path";var P=5e3;function k(e){return e.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function d(e){return e.replace(/\r\n/g," ").replace(/\n/g," ").replace(/\r/g," ").trim()}function Z(e){let t=e.frame_path;return!t||t.length===0?"page":`page.frameLocator('${t[0]}')`}function ee(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 O(e){let t=Z(e),a=e.locator;if(typeof a=="string"&&a.trim())return a=a.trim(),a.endsWith("first()")?`${t}.${a}`:`${t}.${a}.first()`;let s=ee(e);if(s){let n=JSON.stringify(s);return`${t}.locator(${n}).first()`}return null}var te=["ai_action","ai_step","ai_assert","ai_extract","ai_wait_until","verify","assert"],ae=["js_code","function","wait","wait_for_download_complete","wait_for_page_ready","extract_email_content","extract_activation_code"];function W(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:te.includes(t)}function ne(e){let t=e.action_data?.action_name;return!t||(t==="verify"||t==="ai_assert"||t==="assert")&&e.action_data?.kwargs?.code?!1:!ae.includes(t)}var m=new Map;function l(e,t){m.set(e,t)}function se(e){return m.get(e)}function x(e,t,a=[]){let s=[...a];return t.locator?s.push(`locator: ${JSON.stringify(t.locator)}`):t.xpath&&s.push(`xpath: ${JSON.stringify(t.xpath)}`),t.frame_path&&t.frame_path.length>0&&s.push(`frame_path: ${JSON.stringify(t.frame_path)}`),s.length===0?[`await agent.execAction("${e}", page, {});`]:[`await agent.execAction("${e}", page, {`,...s.map(n=>` ${n},`),"});"]}l("click",e=>{let t=O(e);if(!t)return['await agent.execAction("click", page, {});'];let a=e.action_data?.kwargs?.timeout_ms??P;return[`await ${t}.click({ timeout: ${a} });`]});l("click_element",m.get("click"));l("click_element_by_index",m.get("click"));l("double_click",e=>x("double_click",e));l("double_click_on_element",m.get("double_click"));l("right_click",e=>x("right_click",e));l("right_click_on_element",m.get("right_click"));l("hover",e=>x("hover",e));l("hover_element_by_index",m.get("hover"));l("input_text",e=>{let t=e.action_data?.kwargs?.text??e.action_data?.kwargs?.value??"";return x("input_text",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});l("fill",m.get("input_text"));l("clear_input",e=>x("clear_input",e));l("press",e=>{let t=e.action_data?.kwargs?.keys;return[`await page.keyboard.press(${JSON.stringify(t)});`]});l("send_keys",m.get("press"));l("send_keys_on_element",e=>{let t=O(e),a=e.action_data?.kwargs?.keys||"";if(!t)return['await agent.execAction("send_keys_on_element", page, {',` action_data: { kwargs: { keys: ${JSON.stringify(a)} } },`,"});"];let s=e.action_data?.kwargs?.timeout_ms??P;return[`await ${t}.press(${JSON.stringify(a)}, { timeout: ${s} });`]});l("select_dropdown_option",e=>{let t=e.action_data?.kwargs?.text||e.action_data?.kwargs?.option||"";return x("select_dropdown_option",e,[`action_data: { kwargs: { text: ${JSON.stringify(t)} } }`])});l("scroll",e=>{let t=e.action_data?.kwargs?.down??!0;return[`await page.evaluate('window.scrollBy(0, window.innerHeight * ${(e.action_data?.kwargs?.num_pages??1)*(t?1:-1)})');`]});l("scroll_down",m.get("scroll"));l("scroll_up",m.get("scroll"));l("scroll_element",m.get("scroll"));l("scroll_to_text",e=>{let t=e.action_data?.kwargs?.text||"";return[`await page.getByText(${JSON.stringify(t)}, { exact: false }).first().scrollIntoViewIfNeeded();`]});l("scroll_on_element",e=>x("scroll_on_element",e,[`action_data: { kwargs: ${JSON.stringify(e.action_data?.kwargs||{})} }`]));l("go_to_url",e=>{let t=e.action_data?.kwargs?.url||"";return e.action_data?.kwargs?.new_tab===!0?['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)}, new_tab: true } },`,"});"]:['await agent.execAction("go_to_url", page, {',` action_data: { kwargs: { url: ${JSON.stringify(t)} } },`,"});"]});l("open_tab",m.get("go_to_url"));l("go_back",()=>['await agent.execAction("go_back", page, {});']);l("reload_page",()=>['await agent.execAction("reload_page", page, {});']);l("wait",e=>[`await page.waitForTimeout(${(e.action_data?.kwargs?.seconds||1)*1e3});`]);l("wait_for_page_ready",()=>["await page.waitForLoadState('domcontentloaded');"]);l("verify",(e,t)=>{let a=e.action_data?.kwargs,s=typeof a?.code=="string",n=s?a?.statement||e.action_description:e.action_description||a?.statement;if(s&&n){let i=a.code.split(`
|
|
4
|
+
`),u=JSON.stringify(n);return["{ const _t = Date.now(); try {",...i.map(p=>` ${p}`),` console.log(\`[VERIFY:JS] \u2713 \${((Date.now()-_t)/1000).toFixed(1)}s: ${u}\`);`,"} catch (_e) {",` console.log(\`[VERIFY:JS\u2192AI] JS failed \${((Date.now()-_t)/1000).toFixed(1)}s: (\${_e instanceof Error ? _e.message : String(_e)}), falling back to AI: ${u}\`);`,` await agent.assert(page, ${u}, ${JSON.stringify(t||"")});`,"} }"]}return s?a.code.split(`
|
|
5
|
+
`):n?[`await agent.assert(page, ${JSON.stringify(n)}, ${JSON.stringify(t||"")});`]:["// Skipping verify: missing statement or code"]});l("ai_assert",m.get("verify"));l("assert",m.get("verify"));l("ai_action",(e,t)=>{let a=e.action_data?.kwargs?.statement;if(!a)return["// Skipping ai_action: missing statement"];let s=JSON.stringify(a),n=e.action_data?.kwargs?.use_pure_vision;return[`await agent.execute(page, ${s}, '${t||""}', ${n});`]});l("ai_step",(e,t)=>{let a=e.action_data?.kwargs?.statement;return a?[`await agent.run(page, ${JSON.stringify(a)}, '${t||""}');`]:["// Skipping ai_step: missing statement"]});l("ai_extract",(e,t)=>{let a=e.action_data?.kwargs?.element_description,s=e.action_data?.kwargs?.variable_name;if(!a||!s)return["// Skipping ai_extract: missing element_description or variable_name"];let n=JSON.stringify(a),r=JSON.stringify(s);return[`await agent.extract(page, ${n}, ${r}, '${t||""}');`]});l("ai_wait_until",(e,t)=>{let a=e.action_data?.kwargs?.condition,s=e.action_data?.kwargs?.timeout_seconds||60;return a?[`await agent.waitUntilCondition(page, ${JSON.stringify(a)}, ${s}, '${t||""}');`]:["// Skipping ai_wait_until: missing condition"]});l("save_variable",e=>{let t=e.action_data?.kwargs?.name||"",a=e.action_data?.kwargs?.value;return['await agent.execAction("save_variable", page, {',` action_data: { kwargs: { name: ${JSON.stringify(t)}, value: ${JSON.stringify(a)} } },`,"});"]});l("js_code",e=>{let t=e.action_data?.kwargs?.code;if(!t)return["// Skipping js_code: missing code"];let a=["{"],s=t.split(`
|
|
6
|
+
`);for(let n of s)a.push(` ${n}`);return a.push("}"),a});l("function",(e,t,a)=>{let s=e.action_data?.kwargs||{},n=s.functionName;if(n&&n.includes("#")){let[i,u]=n.split("#");if(i&&u){let p=i.replace(/\.(ts|js|mjs)$/,""),o=`import { ${u} } from '${p}';`;a?.imports?.add(o);let c={...s,functionName:u},f=M(c);return f?[f.endsWith(";")?f:`${f};`]:["// Skipping function: invalid export pattern"]}}let r=M(s);return r?[r.endsWith(";")?r:`${r};`]:["// Skipping function: missing functionName"]});l("generate_2fa_code",e=>{let t=e.action_data?.kwargs?.otp_secret_key||"";return['await agent.execAction("generate_2fa_code", page, {',` action_data: { kwargs: { otp_secret_key: ${JSON.stringify(t)} } },`,"});"]});l("upload_file",e=>{let t=e.action_data?.kwargs||{},a=[],s={};return t.paths?s.paths=t.paths:t.path&&(s.path=t.path),t.use_file_input&&(s.use_file_input=!0),a.push(`action_data: { kwargs: ${JSON.stringify(s)} }`),e.locator?a.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&a.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&a.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("upload_file", page, {',...a.map(n=>` ${n},`),"});"]});l("wait_for_download_complete",e=>['await agent.execAction("wait_for_download_complete", page, {',` action_data: { kwargs: { timeout_seconds: ${e.action_data?.kwargs?.timeout_seconds||10} } },`,"});"]);l("switch_tab",e=>['await agent.execAction("switch_tab", page, {',` action_data: { kwargs: { page_id: ${e.action_data?.kwargs?.page_id??e.action_data?.kwargs?.tab_index??0} } },`,"});"]);l("close_tab",e=>{let t=e.action_data?.kwargs?.page_id;return t=t??e.action_data?.kwargs?.index,['await agent.execAction("close_tab", page, {',` action_data: { kwargs: { page_id: ${t} } },`,"});"]});l("set_date_for_native_date_picker",e=>{let t=e.action_data?.kwargs?.date??"",a=[];return a.push(`action_data: { kwargs: { date: ${JSON.stringify(t)} } }`),e.locator?a.push(`locator: ${JSON.stringify(e.locator)}`):e.xpath&&a.push(`xpath: ${JSON.stringify(e.xpath)}`),e.frame_path&&e.frame_path.length>0&&a.push(`frame_path: ${JSON.stringify(e.frame_path)}`),['await agent.execAction("set_date_for_native_date_picker", page, {',...a.map(s=>` ${s},`),"});"]});l("done",()=>["// Done - no action needed"]);l("js_action",e=>{let t=e.action_data?.kwargs?.code;return t?t.split(`
|
|
7
|
+
`):["// Skipping js_action: missing code"]});function M(e){let t=e.functionName;if(!t)return null;let a=Array.isArray(e.args)?e.args.map(String):[];if(a.length===0)return`await ${t}()`;let s=["page","testContext","request","agent"],n=["undefined","null","true","false"],r=a.map(i=>s.includes(i)||n.includes(i)||/^-?\d+(\.\d+)?$/.test(i)?i:i.startsWith("$")?`agent.agentServices.readVariable('${i.substring(1)}')`:`"${i}"`);return`await ${t}(${r.join(", ")})`}function w(e,t,a,s="main"){let n=[];for(let r=0;r<e.length;r++){let i=e[r],u=`${s}.${r}`,p=re(i,t,u,a);p.length>0&&(n.push(...p),r<e.length-1&&n.push(""))}return n}function re(e,t,a,s){let n=" ".repeat(t);switch(e.type){case"DRAFT":return ie(e,t,a,s);case"ACTION":return oe(e,t,a,s);case"STEP":return ce(e,t,a,s);case"IF_ELSE":return le(e,t,a,s);case"WHILE_LOOP":return ue(e,t,a,s);default:return[`${n}// Unknown statement type: ${e.type}`]}}function ie(e,t,a,s){let n=" ".repeat(t),r=e.description?.trim()||"";if(!r)return[`${n}// ${a}: Skipping - no description`];if(s.noAgent)return[`${n}// ${a}: ${d(r)}`,`${n}// DRAFT: ${d(r)} (requires agent - skipped in hook)`];let i=JSON.stringify(r);return[`${n}// ${a}: ${d(r)}`,`${n}// \u26A0 DRAFT: AI-resolved at runtime (~5-10s). Add a locator to make this <1s.`,`${n}page = agent.agentServices.validatePage(page);`,`${n}await agent.run(page, ${i}, '${a}');`]}function oe(e,t,a,s){let n=" ".repeat(t),r=e.description,i=e.uid,p=s.actionEntityStore?.entries[e.uid]?.action_entity??e.action_entity;if(!p){if(!r)return[`${n}// ${a}: Skipping - no description`];if(s.noAgent)return[`${n}// ${a}: ${d(r)}`,`${n}// DRAFT: ${d(r)} (requires agent - skipped in hook)`];let _=JSON.stringify(r),v=!!e.use_pure_vision;return[`${n}// ${a}: ${d(r)}`,`${n}// \u26A0 DRAFT: AI-resolved at runtime (~5-10s). Add a locator to make this <1s.`,`${n}page = agent.agentServices.validatePage(page);`,`${n}await agent.execute(page, ${_}, '${a}', ${v});`]}let o=e.locator?{...p,locator:e.locator}:p;r&&r!==o.action_description&&(o={...o,action_description:r});let c=o.action_data?.action_name||"",f=o.action_description||"",h=se(c);if(!h)return[`${n}// ${a}: Unknown action: ${c}`];let $={imports:s.imports},g=h(o,a,$);if(s.noAgent){if(W(o))return[`${n}// ${a}: ${d(f)}`,`${n}// AI action: ${d(f)} (requires agent - skipped in hook)`];let _=pe(o,c,n,a);return _||[`${n}// ${a}: ${d(f)}`,...g.map(v=>`${n}${v}`)]}if(W(o))return[`${n}// ${a}: ${d(f)}`,`${n}page = agent.agentServices.validatePage(page);`,...g.map(_=>`${n}${_}`)];let S=JSON.stringify(f),A=g.map(_=>`${n} ${_}`),N=ne(o),E=i?`'${i}'`:"undefined";return[`${n}// ${a}: ${d(f)}`,`${n}page = agent.agentServices.validatePage(page);`,`${n}await agent.step(page, async () => {`,...A,`${n}}, ${S}, '${a}', ${E}, ${N});`]}function ce(e,t,a,s){let n=" ".repeat(t),r=[];e.description&&e.description.trim()&&r.push(`${n}// Step: ${d(e.description)}`);let i=w(e.statements,t,s,a);return r.push(...i),r}function le(e,t,a,s){let n=" ".repeat(t),r=[];if(r.push(`${n}// ${a}: Conditional check`),e.condition.type==="JS_CODE")r.push(`${n}if (${e.condition.expression}) {`);else{r.push(`${n}// AI Condition: ${d(e.condition.expression)}`);let u=JSON.stringify(e.condition.expression);r.push(`${n}if (await agent.evaluate(page, ${u}, "${a}")) {`)}let i=w(e.then,t+1,s,`${a}.then`);if(r.push(...i),e.else&&e.else.length>0){r.push(`${n}} else {`);let u=w(e.else,t+1,s,`${a}.else`);r.push(...u)}return r.push(`${n}}`),r}function ue(e,t,a,s){let n=" ".repeat(t),r=[];r.push(`${n}// ${a}: Loop`);let i=e.timeout_ms??U,u=i/1e3,p=e.timeout_ms?`While loop exceeded timeout of ${u}s`:`While loop exceeded default timeout of ${u}s`,o=`loop_${a.replace(/\./g,"_")}`;if(r.push(`${n}const ${o}_start = Date.now();`),r.push(`${n}const ${o}_timeout = ${i};`),r.push(`${n}const ${o}_check = () => {`),r.push(`${n} if (Date.now() - ${o}_start > ${o}_timeout) {`),r.push(`${n} throw new Error('${p}');`),r.push(`${n} }`),r.push(`${n} return true;`),r.push(`${n}};`),e.condition.type==="JS_CODE")r.push(`${n}while (${o}_check() && (${e.condition.expression})) {`);else{r.push(`${n}// AI Loop Condition: ${d(e.condition.expression)}`);let f=JSON.stringify(e.condition.expression);r.push(`${n}while (${o}_check() && await agent.evaluate(page, ${f}, "${a}")) {`)}let c=w(e.body,t+1,s,`${a}.body`);return r.push(...c),r.push(`${n}}`),r}function pe(e,t,a,s){let n=e.action_description||"",r=e.action_data?.kwargs||{},i=r.timeout_ms??P;switch(t){case"go_to_url":case"open_tab":{let u=r.url||"";return[`${a}// ${s}: ${d(n)}`,`${a}await page.goto(${JSON.stringify(u)}, { waitUntil: 'domcontentloaded' });`]}case"go_back":return[`${a}// ${s}: ${d(n)}`,`${a}await page.goBack();`];case"go_forward":return[`${a}// ${s}: ${d(n)}`,`${a}await page.goForward();`];case"input_text":{let u=r.text||"",p=O(e);return p?[`${a}// ${s}: ${d(n)}`,`${a}await ${p}.fill(${JSON.stringify(u)}, { timeout: ${i} });`]:null}case"select_dropdown_option":{let u=r.text||r.label||"",p=O(e);return p?[`${a}// ${s}: ${d(n)}`,`${a}await ${p}.selectOption({ label: ${JSON.stringify(u)} }, { timeout: ${i} });`]:null}default:return null}}function fe(e,t){let a=[],s=t?.version||"unknown";a.push(`// @generated by shiplightai v${s}`),a.push(...D()),a.push(""),t?.use&&Object.keys(t.use).length>0&&(a.push(`test.use(${JSON.stringify(t.use,null,2)});`),a.push(""));let n=new Set,r={imports:n};t?.beforeEach&&t.beforeEach.length>0&&(a.push(...H("beforeEach",t.beforeEach,r)),a.push(""));let i=t?.timeout||t?.skip!==void 0||t?.fail!==void 0||t?.only||t?.slow?{timeout:t.timeout,skip:t.skip,fail:t.fail,only:t.only,slow:t.slow}:void 0;if(t?.parameters&&t.parameters.length>0){let u=t?.testName||e.goal||"Generated test",p=j(t?.tags);for(let o of t.parameters){let c=R(e,o.values);a.push(...J(c,`${p}${k(u)} [${k(o.name)}]`,r,0,i)),a.push("")}}else{let u=t?.testName||e.goal||"Generated test",p=j(t?.tags);a.push(...J(e,`${p}${k(u)}`,r,0,i))}return t?.afterEach&&t.afterEach.length>0&&(a.push(""),a.push(...H("afterEach",t.afterEach,r))),I(a,n),a.join(`
|
|
8
|
+
`)}function ge(e,t){let a=[],s=t?.version||"unknown";a.push(`// @generated by shiplightai v${s}`),a.push(...D()),a.push(""),t?.use&&Object.keys(t.use).length>0&&(a.push(`test.use(${JSON.stringify(t.use,null,2)});`),a.push(""));let n=new Set,r={imports:n},i=t?.testName||"Test Suite",u=j(t?.tags);a.push(`test.describe.serial('${u}${k(i)}', () => {`),e.beforeAll&&e.beforeAll.length>0&&(a.push(...T("beforeAll",e.beforeAll,r,1)),a.push("")),e.beforeEach&&e.beforeEach.length>0&&(a.push(...T("beforeEach",e.beforeEach,r,1)),a.push(""));for(let o=0;o<e.tests.length;o++){let c=e.tests[o],f=c.timeout||c.skip!==void 0||c.fail!==void 0||c.only||c.slow?{timeout:c.timeout,skip:c.skip,fail:c.fail,only:c.only,slow:c.slow}:void 0;if(c.parameters&&c.parameters.length>0)for(let h of c.parameters){let $=R(c.testFlow,h.values);a.push(...J($,`${k(c.name)} [${k(h.name)}]`,r,1,f)),a.push("")}else a.push(...J(c.testFlow,k(c.name),r,1,f)),(o<e.tests.length-1||e.afterEach||e.afterAll)&&a.push("")}return e.afterEach&&e.afterEach.length>0&&(a.push(...T("afterEach",e.afterEach,r,1)),a.push("")),e.afterAll&&e.afterAll.length>0&&a.push(...T("afterAll",e.afterAll,r,1)),a.push("});"),I(a,n),a.join(`
|
|
9
|
+
`)}function j(e){return e&&e.length>0?e.map(t=>`@${t}`).join(" ")+" ":""}function J(e,t,a,s=0,n){let r=" ".repeat(s),i=[],u=n?.only?"test.only":"test";i.push(`${r}${u}('${t}', async ({ page, agent }) => {`),n?.skip===!0?i.push(`${r} test.skip();`):typeof n?.skip=="string"&&i.push(`${r} test.skip(true, '${k(n.skip)}');`),n?.fail===!0?i.push(`${r} test.fail();`):typeof n?.fail=="string"&&i.push(`${r} test.fail(true, '${k(n.fail)}');`),n?.slow&&i.push(`${r} test.slow();`),n?.timeout&&i.push(`${r} test.setTimeout(${n.timeout});`);let p=e.teardown&&e.teardown.length>0,o=s+1;if(p){if(i.push(`${r} try {`),e.statements&&e.statements.length>0){i.push(`${r} // Test steps`);let f=w(e.statements,o+1,a);i.push(...f)}i.push(`${r} } finally {`),i.push(`${r} // Teardown`);let c=w(e.teardown,o+1,a,"teardown");i.push(...c),i.push(`${r} }`)}else if(e.statements&&e.statements.length>0){i.push(`${r} // Test steps`);let c=w(e.statements,o,a);i.push(...c)}return i.push(`${r}});`),i}function H(e,t,a){let s=[],n=B(t);return s.push(`test.${e}(async ({ page, agent }) => {`),s.push(...w(n,1,a,e)),s.push("});"),s}function T(e,t,a,s){let n=" ".repeat(s),r=[],i=B(t);if(e==="beforeAll"||e==="afterAll"){let p={...a,noAgent:!0};r.push(`${n}test.${e}(async ({ browser }, workerInfo) => {`),r.push(`${n} const page = await browser.newPage({ baseURL: workerInfo.project.use.baseURL });`),r.push(...w(i,s+1,p,e)),r.push(`${n} await page.close();`),r.push(`${n}});`)}else r.push(`${n}test.${e}(async ({ page, agent }) => {`),r.push(...w(i,s+1,a,e)),r.push(`${n}});`);return r}function B(e){let a=Q({goal:"_hook",statements:e});return b(a).statements??[]}function R(e,t){let a=C(e);for(let[s,n]of Object.entries(t))a=a.split(`<<${s}>>`).join(String(n));return b(a)}function D(){return["import { test, expect } from 'shiplightai/fixture';"]}function I(e,t){if(t.size>0){let a=0;for(let n=0;n<e.length;n++)e[n].startsWith("import ")&&(a=n+1);let s=Array.from(t);e.splice(a,0,...s)}}var q=5;function G(e,t){let a={expandingPaths:new Set([K(t)]),depth:0,referencedPaths:new Set},s={...e};Array.isArray(s.statements)&&(s.statements=y(s.statements,t,a)),Array.isArray(s.teardown)&&(s.teardown=y(s.teardown,t,a));for(let n of["beforeAll","afterAll","beforeEach","afterEach"])Array.isArray(s[n])&&(s[n]=y(s[n],t,a));return{doc:s,referencedTemplatePaths:Array.from(a.referencedPaths)}}function y(e,t,a){let s=[];for(let n of e)if(_e(n)){let r=we(n,t,a);s.push(...r)}else s.push(ke(n,t,a));return s}function _e(e){return typeof e=="object"&&e!==null&&typeof e.template=="string"}function we(e,t,a){if(a.depth>=q)throw new Error(`Template expansion exceeded maximum depth of ${q}. Check for deeply nested or circular template references.`);let s=K(he(t),e.template);if(a.expandingPaths.has(s))throw new Error(`Circular template reference detected: ${s} is already being expanded. Stack: ${Array.from(a.expandingPaths).join(" \u2192 ")} \u2192 ${s}`);a.referencedPaths.add(s);let n;try{n=me(s,"utf-8")}catch(c){throw new Error(`Failed to read template file: ${s} (referenced from ${t}): ${c.message}`)}let r=V(n);if(!r||typeof r!="object")throw new Error(`Invalid template file: ${s} \u2014 expected a YAML object`);let i=r.params||[],u=e.params||{};for(let c of i)if(!(c in u))throw new Error(`Template ${e.template} requires param "${c}" but it was not provided. Required params: [${i.join(", ")}]`);let p=r.statements;if(!Array.isArray(p))throw new Error(`Template ${e.template} must have a "statements" array`);if(Object.keys(u).length>0){let f=$e(p);for(let[h,$]of Object.entries(u))f=f.split(`<<${h}>>`).join(String($));p=V(f)}let o={expandingPaths:new Set([...a.expandingPaths,s]),depth:a.depth+1,referencedPaths:a.referencedPaths};return y(p,s,o)}function ke(e,t,a){if(typeof e!="object"||e===null)return e;let s={...e};return Array.isArray(s.statements)&&(s.statements=y(s.statements,t,a)),Array.isArray(s.THEN)&&(s.THEN=y(s.THEN,t,a)),Array.isArray(s.ELSE)&&(s.ELSE=y(s.ELSE,t,a)),Array.isArray(s.DO)&&(s.DO=y(s.DO,t,a)),s}var L=class extends Error{constructor(e){super(e),this.name="YamlValidationError"}};function ye(e,t){let a=de(e),s=a?.name,n=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 L('YAML file cannot have both "suite" and top-level "goal"/"statements". Use either suite format or single-test format.');return Ae(a,s,n,r,t)}return Se(a,s,n,r,t)}function Se(e,t,a,s,n){let r=e?.beforeEach,i=e?.afterEach,u=X(e?.parameters),p=e?.timeout,o=e?.skip,c=e?.fail,f=e?.only,h=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 L(`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 $=[];if(n&&e&&typeof e=="object"){let A=G(e,n);e=A.doc,$=A.referencedTemplatePaths}let g=z(e);return{testFlow:b(g),name:t,tags:a,use:s,beforeEach:r,afterEach:i,parameters:u,timeout:p,skip:o,fail:c,only:f,slow:h,referencedTemplatePaths:$}}function Ae(e,t,a,s,n){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 i=r.beforeAll,u=r.afterAll,p=r.beforeEach,o=r.afterEach,c=[],f=r.tests.map(g=>{if(!g.name)throw new Error('Each test in a suite must have a "name" field.');if(!Array.isArray(g.statements)||g.statements.length===0)throw new Error(`Suite test "${g.name}" must have a non-empty "statements" array.`);let S={goal:g.name,statements:g.statements};g.teardown&&(S.teardown=g.teardown);let A=[],N=S;if(n&&typeof S=="object"){let F=G(S,n);N=F.doc,A=F.referencedTemplatePaths,c.push(...A)}let E=z(N),_=b(E),v=X(g.parameters);return{testFlow:_,name:g.name,parameters:v,timeout:g.timeout,skip:g.skip,fail:g.fail,only:g.only,slow:g.slow}}),h=r.base_url,$=h?{...s,baseURL:h}:s;return{suite:{beforeAll:i,afterAll:u,beforeEach:p,afterEach:o,tests:f},name:t,tags:a,use:$,referencedTemplatePaths:c}}function X(e){if(!(!Array.isArray(e)||e.length===0))return e.map((t,a)=>{if(!t.name)throw new Error(`Parameter set at index ${a} must have a "name" field.`);if(!t.values||typeof t.values!="object")throw new Error(`Parameter set "${t.name}" must have a "values" object.`);return{name:t.name,values:t.values}})}function We(e,t,a){let s=/\btemplate:\s/.test(e),n=/^suite:/m.test(e),r=s||n?null:Y(e);if(r&&!r.valid)return{valid:!1,errors:r.errors,warnings:[],stats:r.stats};let i,u,p=[];try{let o=ye(e,t);p=o.referencedTemplatePaths;let c={version:a?.version},f=o.testFlow?.baseURL?{...o.use,baseURL:o.testFlow.baseURL}:o.use;o.suite?i=ge(o.suite,{...c,testName:o.name,tags:o.tags,use:o.use}):i=fe(o.testFlow,{...c,testName:o.name,tags:o.tags,use:f,beforeEach:o.beforeEach,afterEach:o.afterEach,parameters:o.parameters,timeout:o.timeout,skip:o.skip,fail:o.fail,only:o.only,slow:o.slow});let h=i.split(`
|
|
10
|
+
`).filter($=>!$.startsWith("import ")).join(`
|
|
11
|
+
`);new Function(h),u=t.replace(/\.test\.yaml$/,".yaml.spec.ts"),be(ve(u),{recursive:!0}),xe(u,i)}catch(o){let c=o instanceof L?"":o.message.includes("Unexpected token")?" This usually means a YAML escaping issue \u2014 in double-quoted strings, use \\\\/ instead of \\/ for regex patterns, or use single quotes / block scalars.":" This may indicate a transpiler bug \u2014 please report it.";return{valid:!1,errors:[`Transpilation failed: ${o.message}.${c}`],warnings:[],stats:r?.stats??{total:0,action:0,draft:0,coverage:0},referencedTemplatePaths:p}}return{valid:!0,errors:[],warnings:r?.warnings??[],stats:r?.stats??{total:0,action:0,draft:0,coverage:0},specFile:u,referencedTemplatePaths:p}}export{ye as a,We as b};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "module";
|
|
2
2
|
const require = __createRequire(import.meta.url);
|
|
3
|
-
var k=e=>{let t=[];switch(e.type){case"STEP":e.statements&&t.push({key:"statements",statements:e.statements});break;case"IF_ELSE":e.then&&t.push({key:"then",statements:e.then}),e.else&&t.push({key:"else",statements:e.else});break;case"WHILE_LOOP":e.body&&t.push({key:"body",statements:e.body});break}return t},T=(e,t,i=void 0,r="root")=>{for(let o=0;o<e.length;o++){let n=e[o],l=n.uid;if(l===t)return{stableId:l,path:[o],statement:n,parent:i,containerKey:r,index:o};let a=k(n);for(let c of a){let u=T(c.statements,t,n,c.key);if(u)return{...u,path:[o,c.key,...u.path]}}}return null},I=(e,t,i)=>{let r=T(e,t);if(!r)return null;let{statement:o,parent:n,containerKey:l,index:a}=r,c=null;switch(o.type){case"DRAFT":case"ACTION":c=L(e,r)||x(e,r);break;case"STEP":if(o.statements&&o.statements.length>0)return o.statements[0];c=L(e,r)||x(e,r);break;case"IF_ELSE":if(i===!0&&o.then&&o.then.length>0)return o.then[0];if(i===!1&&o.else&&o.else.length>0)return o.else[0];c=L(e,r)||x(e,r);break;case"WHILE_LOOP":if(i===!0&&o.body&&o.body.length>0)return o.body[0];c=L(e,r)||x(e,r);break;default:c=L(e,r)||x(e,r);break}if(n&&n.type==="WHILE_LOOP"&&l==="body"){if(!c)return n;let u=T(e,c.uid);if(!u||u.parent!==n)return n}return c},L=(e,t)=>{if(!t.parent)return e[t.index+1]||null;let r=k(t.parent).find(o=>o.key===t.containerKey);return r&&t.index+1<r.statements.length?r.statements[t.index+1]:null},x=(e,t)=>{if(!t.parent)return null;let i=t.parent.uid,r=T(e,i);return r?L(e,r)||x(e,r):null},B=e=>{let t=[],i=r=>{for(let o of r){t.push(o);let n=k(o);for(let l of n)i(l.statements)}};return i(e),t},Ve=e=>{switch(e.type){case"DRAFT":case"ACTION":return!0;case"STEP":return!0;case"IF_ELSE":case"WHILE_LOOP":return!0;default:return!1}},Xe=(e,t,i)=>{if(!T(e,t))return null;if(i===null){let a=[],c=t;for(;c!==null&&T(e,c);)if(a.push(c),c=I(e,c)?.uid||null,a.length>1e3)return null;return a}if(!T(e,i))return null;if(t===i)return[];let n=[],l=t;for(;l&&l!==i;){let a=T(e,l);if(!a)break;if(n.push(l),a.statement.type==="IF_ELSE"){let c=Ye(a.statement,i);c?l=I(e,l,c==="then")?.uid||null:l=I(e,l)?.uid||null}else a.statement.type==="WHILE_LOOP"?je(a.statement,i)?l=I(e,l,!0)?.uid||null:l=I(e,l,!1)?.uid||null:l=I(e,l)?.uid||null;if(n.length>1e3)return null}return l===i?n:null},Ye=(e,t)=>{if(e.type!=="IF_ELSE")return null;let i=e;return i.then&&T(i.then,t)?"then":i.else&&T(i.else,t)?"else":null},je=(e,t)=>{if(e.type!=="WHILE_LOOP")return!1;let i=e;return!!(i.body&&T(i.body,t))};function te(e){for(let t of e){if(t.type==="STEP"&&t.reference_id)return!0;let i=k(t);for(let r of i)if(te(r.statements))return!0}return!1}function Je(e){let t=new Set;function i(r){for(let o of r){o.type==="STEP"&&o.reference_id&&t.add(o.reference_id);let n=k(o);for(let l of n)i(l.statements)}}return i(e),Array.from(t)}var qe=e=>e.startsWith("ai_")?!0:["js_code","function","assert","verify","wait_for_download_complete","extract_activation_code","extract_email_content"].includes(e),Ze=e=>!["js_code","function","assert","ai_assert","verify","ai_extract","ai_wait_until","upload_file","login","extract_activation_code","extract_email_content","ai_step"].includes(e),D=(e,t,i)=>{e.forEach((r,o)=>{let n=`${t}.${o}`;r.type==="DRAFT"?i[n]={description:r.description||"Draft",action_entity:void 0}:r.type==="ACTION"?i[n]={description:r.description||"Action",action_entity:r.action_entity}:r.type==="STEP"&&r.statements?D(r.statements,n,i):r.type==="IF_ELSE"?(i[n]={description:"IF "+(r.condition?.expression||""),action_entity:void 0},r.then&&D(r.then,`${n}.then`,i),r.else&&D(r.else,`${n}.else`,i)):r.type==="WHILE_LOOP"&&(i[n]={description:"WHILE "+(r.condition?.expression||""),action_entity:void 0},r.body&&D(r.body,`${n}.body`,i))})};function Qe(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return D(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&D(e.teardown,"teardown",t),t}function E(e,t,i){let r=e+".",o=t.filter(([h])=>h===e||h.startsWith(r));if(o.length===0)return[];let n=[],l=new Set;for(let[h]of o){let d=h===e?"":h.slice(r.length);if(!d)continue;let f=d.split(".")[0];l.has(f)||l.add(f)}let a=Array.from(l);a.sort((h,d)=>{let f=/^\d+$/.test(h)?parseInt(h,10):-1,m=/^\d+$/.test(d)?parseInt(d,10):-1;return f>=0&&m>=0?f-m:h==="then"&&d==="else"?-1:h==="else"&&d==="then"||h==="body"?1:d==="body"?-1:h.localeCompare(d)});function c(h){return i[h]}function u(h){let d=h.match(/^(IF|WHILE)\s+([\s\S]+)$/);return{type:"AI_MODE",expression:(d?d[2].trim():h)||"true"}}for(let h of a){let d=e?`${e}.${h}`:h,f=c(d),m=f?.description??"",S=d;if(h==="then"){let p=`${e}.then`,v=`${e}.else`,w=E(p,t,i),O=E(v,t,i),F=c(e),ze=F?u(F.description):{type:"JS_CODE",expression:"true"};n.push({uid:e,type:"IF_ELSE",condition:ze,then:w,...O.length>0?{else:O}:{}});continue}if(h==="else")continue;if(h==="body"){let p=`${e}.body`,v=E(p,t,i),w=c(e),O=w?u(w.description):{type:"JS_CODE",expression:"true"};n.push({uid:e,type:"WHILE_LOOP",condition:O,body:v});continue}let g=`${e}.${h}`,N=t.some(([p])=>p.startsWith(g+".then.")||p===g+".then"),V=t.some(([p])=>p.startsWith(g+".else.")||p===g+".else"),$e=t.some(([p])=>p.startsWith(g+".body.")||p===g+".body"),Ue=t.filter(([p])=>{if(!p.startsWith(g+"."))return!1;let w=p.slice(g.length+1).split(".")[0];return/^\d+$/.test(w)&&w!=="then"&&w!=="else"&&w!=="body"});if(N||V){let p=g+".then",v=g+".else",w=E(p,t,i),O=E(v,t,i),F=f?u(m):{type:"JS_CODE",expression:"true"};n.push({uid:d,type:"IF_ELSE",condition:F,then:w,...O.length>0?{else:O}:{}})}else if($e){let p=g+".body",v=E(p,t,i),w=f?u(m):{type:"JS_CODE",expression:"true"};n.push({uid:d,type:"WHILE_LOOP",condition:w,body:v})}else if(Ue.length>0){let p=E(g,t,i);n.push({uid:d,type:"STEP",description:m||"Group",statements:p})}else n.push({uid:d,type:"ACTION",description:m||"Action",action_entity:f?.action_entity})}return n}function et(e){let t=Object.entries(e),i=r=>{let o=r+".";return t.some(([l])=>l===r||l.startsWith(o))?E(r,t,e):[]};return{before:i("before"),main:i("main"),teardown:i("teardown"),after:i("after")}}import{z as s}from"zod";var ie=s.enum(["JS_CODE","AI_MODE"]),X=s.object({type:ie,expression:s.string()}),re=s.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),W=s.object({uid:s.string(),type:re}),oe=s.object({action_data:s.object({action_name:s.string(),kwargs:s.record(s.any()).optional(),args:s.array(s.any()).optional()}),action_description:s.string().optional(),url:s.string().optional(),xpath:s.string().nullable().optional(),locator:s.string().nullable().optional(),css_selector:s.string().nullable().optional(),unique_selector:s.string().nullable().optional(),element_index:s.number().nullable().optional(),frame_path:s.array(s.any()).optional(),artifacts:s.record(s.any()).optional(),feedback:s.string().optional(),original_browser_use_action:s.any().optional()}).passthrough(),ne=W.extend({type:s.literal("DRAFT"),description:s.string()}),ae=W.extend({type:s.literal("ACTION"),description:s.string(),action_entity:oe.optional(),locator:s.string().optional(),use_pure_vision:s.boolean().optional()}),y=s.lazy(()=>s.union([ne,ae,W.extend({type:s.literal("STEP"),description:s.string().optional().default(""),statements:s.array(y),reference_id:s.number().optional()}),W.extend({type:s.literal("IF_ELSE"),description:s.string().optional(),condition:X,then:s.array(y),else:s.array(y).optional()}),W.extend({type:s.literal("WHILE_LOOP"),description:s.string().optional(),condition:X,body:s.array(y),timeout_ms:s.number().optional()})])),se=s.object({name:s.string(),statements:s.array(y),teardown:s.array(y).optional(),skip:s.union([s.boolean(),s.string()]).optional(),timeout:s.number().optional(),fail:s.union([s.boolean(),s.string()]).optional(),only:s.boolean().optional(),slow:s.boolean().optional()}),H=s.object({tests:s.array(se).min(1),beforeAll:s.array(y).optional(),afterAll:s.array(y).optional(),beforeEach:s.array(y).optional(),afterEach:s.array(y).optional()}),Y=s.object({version:s.string().optional(),goal:s.string().optional(),url:s.string().optional(),baseURL:s.string().optional(),final_feedback:s.string().optional(),completed:s.boolean().optional(),success:s.boolean().optional(),statements:s.array(y).optional(),teardown:s.array(y).optional(),last_modified_at:s.string().optional(),testGroup:H.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"});import{stringify as R,parse as J,parseAllDocuments as tt}from"yaml";import{v4 as A}from"uuid";function he(e,t){let i={...t?.test_case_id!==void 0?{test_case_id:t.test_case_id}:{},...t?.name?{name:t.name}:{},goal:e.goal??"",url:e.url,base_url:e.baseURL,statements:(e.statements??[]).map(b)};return e.final_feedback&&(i.final_feedback=e.final_feedback),e.teardown&&e.teardown.length>0&&(i.teardown=e.teardown.map(b)),i}var $={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};function it(e,t){return e.testGroup?ue(e,t):R(he(e,t),$)}function ue(e,t){let i=e.testGroup;if(!i)throw new Error("suiteToYaml requires a TestFlow with testGroup");let r={};t?.test_case_id!==void 0&&(r.test_case_id=t.test_case_id),t?.name&&(r.name=t.name),t?.tags&&t.tags.length>0&&(r.tags=t.tags),t?.use&&Object.keys(t.use).length>0&&(r.use=t.use);let o={};return e.baseURL&&(o.base_url=e.baseURL),i.beforeAll&&i.beforeAll.length>0&&(o.beforeAll=i.beforeAll.map(b)),i.beforeEach&&i.beforeEach.length>0&&(o.beforeEach=i.beforeEach.map(b)),i.afterEach&&i.afterEach.length>0&&(o.afterEach=i.afterEach.map(b)),i.afterAll&&i.afterAll.length>0&&(o.afterAll=i.afterAll.map(b)),o.tests=i.tests.map(n=>{let l={name:n.name};return n.skip!==void 0&&(l.skip=n.skip),n.timeout!==void 0&&(l.timeout=n.timeout),n.fail!==void 0&&(l.fail=n.fail),n.only!==void 0&&(l.only=n.only),n.slow!==void 0&&(l.slow=n.slow),l.statements=n.statements.map(b),n.teardown&&n.teardown.length>0&&(l.teardown=n.teardown.map(b)),l}),r.suite=o,R(r,$)}function rt(e){return e.map(t=>R(t,$)).join(`---
|
|
3
|
+
var k=e=>{let t=[];switch(e.type){case"STEP":e.statements&&t.push({key:"statements",statements:e.statements});break;case"IF_ELSE":e.then&&t.push({key:"then",statements:e.then}),e.else&&t.push({key:"else",statements:e.else});break;case"WHILE_LOOP":e.body&&t.push({key:"body",statements:e.body});break}return t},T=(e,t,i=void 0,r="root")=>{for(let o=0;o<e.length;o++){let n=e[o],l=n.uid;if(l===t)return{stableId:l,path:[o],statement:n,parent:i,containerKey:r,index:o};let a=k(n);for(let c of a){let u=T(c.statements,t,n,c.key);if(u)return{...u,path:[o,c.key,...u.path]}}}return null},I=(e,t,i)=>{let r=T(e,t);if(!r)return null;let{statement:o,parent:n,containerKey:l,index:a}=r,c=null;switch(o.type){case"DRAFT":case"ACTION":c=L(e,r)||x(e,r);break;case"STEP":if(o.statements&&o.statements.length>0)return o.statements[0];c=L(e,r)||x(e,r);break;case"IF_ELSE":if(i===!0&&o.then&&o.then.length>0)return o.then[0];if(i===!1&&o.else&&o.else.length>0)return o.else[0];c=L(e,r)||x(e,r);break;case"WHILE_LOOP":if(i===!0&&o.body&&o.body.length>0)return o.body[0];c=L(e,r)||x(e,r);break;default:c=L(e,r)||x(e,r);break}if(n&&n.type==="WHILE_LOOP"&&l==="body"){if(!c)return n;let u=T(e,c.uid);if(!u||u.parent!==n)return n}return c},L=(e,t)=>{if(!t.parent)return e[t.index+1]||null;let r=k(t.parent).find(o=>o.key===t.containerKey);return r&&t.index+1<r.statements.length?r.statements[t.index+1]:null},x=(e,t)=>{if(!t.parent)return null;let i=t.parent.uid,r=T(e,i);return r?L(e,r)||x(e,r):null},B=e=>{let t=[],i=r=>{for(let o of r){t.push(o);let n=k(o);for(let l of n)i(l.statements)}};return i(e),t},Ve=e=>{switch(e.type){case"DRAFT":case"ACTION":return!0;case"STEP":return!0;case"IF_ELSE":case"WHILE_LOOP":return!0;default:return!1}},Xe=(e,t,i)=>{if(!T(e,t))return null;if(i===null){let a=[],c=t;for(;c!==null&&T(e,c);)if(a.push(c),c=I(e,c)?.uid||null,a.length>1e3)return null;return a}if(!T(e,i))return null;if(t===i)return[];let n=[],l=t;for(;l&&l!==i;){let a=T(e,l);if(!a)break;if(n.push(l),a.statement.type==="IF_ELSE"){let c=Ye(a.statement,i);c?l=I(e,l,c==="then")?.uid||null:l=I(e,l)?.uid||null}else a.statement.type==="WHILE_LOOP"?je(a.statement,i)?l=I(e,l,!0)?.uid||null:l=I(e,l,!1)?.uid||null:l=I(e,l)?.uid||null;if(n.length>1e3)return null}return l===i?n:null},Ye=(e,t)=>{if(e.type!=="IF_ELSE")return null;let i=e;return i.then&&T(i.then,t)?"then":i.else&&T(i.else,t)?"else":null},je=(e,t)=>{if(e.type!=="WHILE_LOOP")return!1;let i=e;return!!(i.body&&T(i.body,t))};function te(e){for(let t of e){if(t.type==="STEP"&&t.reference_id)return!0;let i=k(t);for(let r of i)if(te(r.statements))return!0}return!1}function Je(e){let t=new Set;function i(r){for(let o of r){o.type==="STEP"&&o.reference_id&&t.add(o.reference_id);let n=k(o);for(let l of n)i(l.statements)}}return i(e),Array.from(t)}var qe=e=>e.startsWith("ai_")?!0:["js_code","function","assert","verify","wait_for_download_complete","extract_activation_code","extract_email_content"].includes(e),Ze=e=>!["js_code","function","assert","ai_assert","verify","ai_extract","ai_wait_until","upload_file","login","extract_activation_code","extract_email_content","ai_step"].includes(e),D=(e,t,i)=>{e.forEach((r,o)=>{let n=`${t}.${o}`;r.type==="DRAFT"?i[n]={description:r.description||"Draft",action_entity:void 0}:r.type==="ACTION"?i[n]={description:r.description||"Action",action_entity:r.action_entity}:r.type==="STEP"&&r.statements?D(r.statements,n,i):r.type==="IF_ELSE"?(i[n]={description:"IF "+(r.condition?.expression||""),action_entity:void 0},r.then&&D(r.then,`${n}.then`,i),r.else&&D(r.else,`${n}.else`,i)):r.type==="WHILE_LOOP"&&(i[n]={description:"WHILE "+(r.condition?.expression||""),action_entity:void 0},r.body&&D(r.body,`${n}.body`,i))})};function Qe(e){if(!e?.statements||!Array.isArray(e.statements))return{};let t={};return D(e.statements,"main",t),e.teardown&&Array.isArray(e.teardown)&&D(e.teardown,"teardown",t),t}function E(e,t,i){let r=e+".",o=t.filter(([h])=>h===e||h.startsWith(r));if(o.length===0)return[];let n=[],l=new Set;for(let[h]of o){let d=h===e?"":h.slice(r.length);if(!d)continue;let f=d.split(".")[0];l.has(f)||l.add(f)}let a=Array.from(l);a.sort((h,d)=>{let f=/^\d+$/.test(h)?parseInt(h,10):-1,m=/^\d+$/.test(d)?parseInt(d,10):-1;return f>=0&&m>=0?f-m:h==="then"&&d==="else"?-1:h==="else"&&d==="then"||h==="body"?1:d==="body"?-1:h.localeCompare(d)});function c(h){return i[h]}function u(h){let d=h.match(/^(IF|WHILE)\s+([\s\S]+)$/);return{type:"JS_CODE",expression:(d?d[2].trim():h)||"true"}}for(let h of a){let d=e?`${e}.${h}`:h,f=c(d),m=f?.description??"",S=d;if(h==="then"){let p=`${e}.then`,v=`${e}.else`,w=E(p,t,i),O=E(v,t,i),F=c(e),ze=F?u(F.description):{type:"JS_CODE",expression:"true"};n.push({uid:e,type:"IF_ELSE",condition:ze,then:w,...O.length>0?{else:O}:{}});continue}if(h==="else")continue;if(h==="body"){let p=`${e}.body`,v=E(p,t,i),w=c(e),O=w?u(w.description):{type:"JS_CODE",expression:"true"};n.push({uid:e,type:"WHILE_LOOP",condition:O,body:v});continue}let g=`${e}.${h}`,N=t.some(([p])=>p.startsWith(g+".then.")||p===g+".then"),V=t.some(([p])=>p.startsWith(g+".else.")||p===g+".else"),$e=t.some(([p])=>p.startsWith(g+".body.")||p===g+".body"),Ue=t.filter(([p])=>{if(!p.startsWith(g+"."))return!1;let w=p.slice(g.length+1).split(".")[0];return/^\d+$/.test(w)&&w!=="then"&&w!=="else"&&w!=="body"});if(N||V){let p=g+".then",v=g+".else",w=E(p,t,i),O=E(v,t,i),F=f?u(m):{type:"JS_CODE",expression:"true"};n.push({uid:d,type:"IF_ELSE",condition:F,then:w,...O.length>0?{else:O}:{}})}else if($e){let p=g+".body",v=E(p,t,i),w=f?u(m):{type:"JS_CODE",expression:"true"};n.push({uid:d,type:"WHILE_LOOP",condition:w,body:v})}else if(Ue.length>0){let p=E(g,t,i);n.push({uid:d,type:"STEP",description:m||"Group",statements:p})}else n.push({uid:d,type:"ACTION",description:m||"Action",action_entity:f?.action_entity})}return n}function et(e){let t=Object.entries(e),i=r=>{let o=r+".";return t.some(([l])=>l===r||l.startsWith(o))?E(r,t,e):[]};return{before:i("before"),main:i("main"),teardown:i("teardown"),after:i("after")}}import{z as s}from"zod";var ie=s.enum(["JS_CODE","AI_MODE"]),X=s.object({type:ie,expression:s.string()}),re=s.enum(["DRAFT","STEP","ACTION","IF_ELSE","WHILE_LOOP"]),W=s.object({uid:s.string(),type:re}),oe=s.object({action_data:s.object({action_name:s.string(),kwargs:s.record(s.any()).optional(),args:s.array(s.any()).optional()}),action_description:s.string().optional(),url:s.string().optional(),xpath:s.string().nullable().optional(),locator:s.string().nullable().optional(),css_selector:s.string().nullable().optional(),unique_selector:s.string().nullable().optional(),element_index:s.number().nullable().optional(),frame_path:s.array(s.any()).optional(),artifacts:s.record(s.any()).optional(),feedback:s.string().optional(),original_browser_use_action:s.any().optional()}).passthrough(),ne=W.extend({type:s.literal("DRAFT"),description:s.string()}),ae=W.extend({type:s.literal("ACTION"),description:s.string(),action_entity:oe.optional(),locator:s.string().optional(),use_pure_vision:s.boolean().optional()}),y=s.lazy(()=>s.union([ne,ae,W.extend({type:s.literal("STEP"),description:s.string().optional().default(""),statements:s.array(y),reference_id:s.number().optional()}),W.extend({type:s.literal("IF_ELSE"),description:s.string().optional(),condition:X,then:s.array(y),else:s.array(y).optional()}),W.extend({type:s.literal("WHILE_LOOP"),description:s.string().optional(),condition:X,body:s.array(y),timeout_ms:s.number().optional()})])),se=s.object({name:s.string(),statements:s.array(y),teardown:s.array(y).optional(),skip:s.union([s.boolean(),s.string()]).optional(),timeout:s.number().optional(),fail:s.union([s.boolean(),s.string()]).optional(),only:s.boolean().optional(),slow:s.boolean().optional()}),H=s.object({tests:s.array(se).min(1),beforeAll:s.array(y).optional(),afterAll:s.array(y).optional(),beforeEach:s.array(y).optional(),afterEach:s.array(y).optional()}),Y=s.object({version:s.string().optional(),goal:s.string().optional(),url:s.string().optional(),baseURL:s.string().optional(),final_feedback:s.string().optional(),completed:s.boolean().optional(),success:s.boolean().optional(),statements:s.array(y).optional(),teardown:s.array(y).optional(),last_modified_at:s.string().optional(),testGroup:H.optional()}).refine(e=>e.testGroup!==void 0?e.goal===void 0&&(e.statements===void 0||e.statements.length===0):e.goal!==void 0,{message:"TestFlow must have either goal/statements (single test) or testGroup (suite), not both"});import{stringify as R,parse as J,parseAllDocuments as tt}from"yaml";import{v4 as A}from"uuid";function he(e,t){let i={...t?.test_case_id!==void 0?{test_case_id:t.test_case_id}:{},...t?.name?{name:t.name}:{},goal:e.goal??"",url:e.url,base_url:e.baseURL,statements:(e.statements??[]).map(b)};return e.final_feedback&&(i.final_feedback=e.final_feedback),e.teardown&&e.teardown.length>0&&(i.teardown=e.teardown.map(b)),i}var $={lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"};function it(e,t){return e.testGroup?ue(e,t):R(he(e,t),$)}function ue(e,t){let i=e.testGroup;if(!i)throw new Error("suiteToYaml requires a TestFlow with testGroup");let r={};t?.test_case_id!==void 0&&(r.test_case_id=t.test_case_id),t?.name&&(r.name=t.name),t?.tags&&t.tags.length>0&&(r.tags=t.tags),t?.use&&Object.keys(t.use).length>0&&(r.use=t.use);let o={};return e.baseURL&&(o.base_url=e.baseURL),i.beforeAll&&i.beforeAll.length>0&&(o.beforeAll=i.beforeAll.map(b)),i.beforeEach&&i.beforeEach.length>0&&(o.beforeEach=i.beforeEach.map(b)),i.afterEach&&i.afterEach.length>0&&(o.afterEach=i.afterEach.map(b)),i.afterAll&&i.afterAll.length>0&&(o.afterAll=i.afterAll.map(b)),o.tests=i.tests.map(n=>{let l={name:n.name};return n.skip!==void 0&&(l.skip=n.skip),n.timeout!==void 0&&(l.timeout=n.timeout),n.fail!==void 0&&(l.fail=n.fail),n.only!==void 0&&(l.only=n.only),n.slow!==void 0&&(l.slow=n.slow),l.statements=n.statements.map(b),n.teardown&&n.teardown.length>0&&(l.teardown=n.teardown.map(b)),l}),r.suite=o,R(r,$)}function rt(e){return e.map(t=>R(t,$)).join(`---
|
|
4
4
|
`)}function b(e){switch(e.type){case"DRAFT":return ot(e);case"ACTION":return nt(e);case"STEP":return at(e);case"IF_ELSE":return st(e);case"WHILE_LOOP":return lt(e)}}function ot(e){return{intent:e.description}}function nt(e){let t=e.action_entity?.action_data?.action_name??e.action_entity?.action?.action_name,i=e.action_entity?.action_data?.kwargs??e.action_entity?.action?.kwargs;if(t==="verify"){let a=i?.statement;if(typeof a=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let c=i?.code;return typeof c=="string"?{VERIFY:a,js:c}:{VERIFY:a}}}if(t==="go_to_url"){let a=i?.url;if(typeof a=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath){let c={URL:a};return i?.new_tab===!0&&(c.new_tab=!0),typeof i?.timeout_seconds=="number"&&(c.timeout_seconds=i.timeout_seconds),c}}if(t==="js_action"){let a=i?.code;if(typeof a=="string"&&e.description)return{intent:e.description,js:a}}if(t==="ai_wait_until"){let a=i?.condition;if(typeof a=="string"){let c={WAIT_UNTIL:a};return typeof i?.timeout_seconds=="number"&&i.timeout_seconds!==60&&(c.timeout_seconds=i.timeout_seconds),c}}if(t==="wait"){let a=i?.seconds,u={WAIT:e.description||`Wait ${a}s`};return typeof a=="number"&&(u.seconds=a),u}if(t==="js_code"){let a=i?.code;if(typeof a=="string"&&!e.action_entity?.locator&&!e.action_entity?.xpath)return{CODE:a}}if(!e.action_entity)return{intent:e.description};let r=e.action_entity.action_data??e.action_entity.action;if(!r)return{intent:e.description};let o={intent:e.description,action:r.action_name},n=e.locator??e.action_entity.locator;n&&(o.locator=n);let l=e.action_entity.xpath;if(l&&(o.xpath=l),e.use_pure_vision&&(o.use_pure_vision=!0),r.kwargs&&Object.keys(r.kwargs).length>0)for(let[a,c]of Object.entries(r.kwargs))o[a]=c;return r.args&&r.args.length>0&&(o.args=r.args),o}function at(e){let t={STEP:e.description,statements:e.statements.map(b)};return e.reference_id!==void 0&&(t.reference_id=e.reference_id),t}function st(e){let t={IF:de(e.condition),THEN:e.then.map(b)};return e.else&&e.else.length>0&&(t.ELSE=e.else.map(b)),t}function lt(e){let t={WHILE:de(e.condition),DO:e.body.map(b)};return e.timeout_ms!==void 0&&(t.timeout_ms=e.timeout_ms),t}function de(e){return e.type==="JS_CODE"?`js:${e.expression}`:e.expression}function ct(e){let t=tt(e),i;if(t.length>1||t.length===1&&!Array.isArray(t[0]?.toJSON()))i=t.map((r,o)=>r.errors.length>0?{__parseError:`Document ${o+1}: ${r.errors[0].message}`}:r.toJSON());else{let r;try{r=J(e)}catch(o){throw new Error(`Invalid YAML: ${o instanceof Error?o.message:String(o)}`)}if(!Array.isArray(r))throw new Error("Expected a YAML array or multi-document YAML (separated by ---)");i=r}return i.map((r,o)=>{try{if(r&&typeof r=="object"&&"__parseError"in r)return{error:r.__parseError};if(!r||typeof r!="object")return{error:`Item ${o+1}: expected an object`};let n=r,l=typeof n.name=="string"&&n.name.trim()||void 0,a=typeof n.goal=="string"?n.goal.trim():"";if(!a)return{error:`Item ${o+1}: missing "goal" field`};if(Array.isArray(n.statements))try{let c=R(n,$),u=C(c);return{name:l,goal:u.goal??a,testFlow:u}}catch{}return{name:l,goal:a}}catch(n){return{error:`Item ${o+1}: ${n instanceof Error?n.message:String(n)}`}}})}function ht(e){try{let t=J(e);if(!t||typeof t!="object")return{};let i={};return typeof t.test_case_id=="number"&&Number.isFinite(t.test_case_id)&&(i.test_case_id=t.test_case_id),typeof t.template_id=="number"&&Number.isFinite(t.template_id)&&(i.template_id=t.template_id),typeof t.name=="string"&&t.name.trim()&&(i.name=t.name.trim()),i}catch{return{}}}function j(e){if(e==null||typeof e!="object")return e;if(Array.isArray(e))return e.map(j);let t=e,i=Object.keys(t);if(i.length===1){let o=i[0];if(o.startsWith("{ ")&&o.endsWith(" }")&&t[o]===null)return`{{${o.slice(2,-2)}}}`}let r={};for(let[o,n]of Object.entries(t))r[o]=j(n);return r}var le=1024*1024;function C(e){if(e.length>le)throw new Error(`YAML input too large (${e.length} bytes, max ${le})`);let t=j(J(e));if(!t||typeof t!="object")throw new Error("Invalid YAML: expected an object at root level");if(t.suite)return ut(t);let i={version:"1.3.0",goal:t.goal,url:t.url,baseURL:t.base_url,statements:M(t.statements??[])};t.final_feedback&&(i.final_feedback=t.final_feedback),t.teardown&&Array.isArray(t.teardown)&&(i.teardown=M(t.teardown));let r=Y.safeParse(i);if(!r.success)throw new Error(`Invalid TestFlow after YAML conversion: ${JSON.stringify(r.error.errors)}`);return r.data}function ut(e){let t=e.suite;if(!t||typeof t!="object")throw new Error("Invalid suite: expected an object");let i=t.tests;if(!Array.isArray(i)||i.length===0)throw new Error('Suite must have a non-empty "tests" array');let o={tests:i.map(a=>{if(!a.name)throw new Error('Each test in a suite must have a "name" field');if(!Array.isArray(a.statements)||a.statements.length===0)throw new Error(`Suite test "${a.name}" must have a non-empty "statements" array`);let c={name:a.name,statements:M(a.statements)};return Array.isArray(a.teardown)&&a.teardown.length>0&&(c.teardown=M(a.teardown)),a.skip!==void 0&&(c.skip=a.skip),typeof a.timeout=="number"&&(c.timeout=a.timeout),a.fail!==void 0&&(c.fail=a.fail),a.only===!0&&(c.only=!0),a.slow===!0&&(c.slow=!0),c})};Array.isArray(t.beforeAll)&&t.beforeAll.length>0&&(o.beforeAll=M(t.beforeAll)),Array.isArray(t.afterAll)&&t.afterAll.length>0&&(o.afterAll=M(t.afterAll)),Array.isArray(t.beforeEach)&&t.beforeEach.length>0&&(o.beforeEach=M(t.beforeEach)),Array.isArray(t.afterEach)&&t.afterEach.length>0&&(o.afterEach=M(t.afterEach));let n=H.safeParse(o);if(!n.success)throw new Error(`Invalid TestGroup: ${JSON.stringify(n.error.errors)}`);return{version:"1.3.0",baseURL:t.base_url||void 0,testGroup:n.data}}function M(e){if(!Array.isArray(e))throw new Error("Expected an array of statements");return e.map(dt)}function dt(e){if(typeof e=="string")throw new Error(`Plain string statements are not supported. Use an object with a "desc" key instead. Example: { "desc": "${e}" }`);if(typeof e!="object"||e===null)throw new Error(`Invalid statement: expected object, got ${typeof e}`);let t=e;if("IF"in t)return pt(t);if("WHILE"in t)return ft(t);if("STEP"in t)return mt(t);if("VERIFY"in t){let i=t.VERIFY,r={statement:typeof i=="string"?i:String(i)};return typeof t.js=="string"&&(r.code=t.js),{uid:A(),type:"ACTION",description:`Verify: ${i}`,action_entity:{action_description:`Verify: ${i}`,action_data:{action_name:"verify",kwargs:r}}}}if("URL"in t){let i=t.URL,r=t.new_tab===!0?!0:void 0,o=typeof t.timeout_seconds=="number"?t.timeout_seconds:void 0,n={url:typeof i=="string"?i:String(i)};return r&&(n.new_tab=!0),o!==void 0&&(n.timeout_seconds=o),{uid:A(),type:"ACTION",description:`Navigate to ${i}`,action_entity:{action_description:`Navigate to ${i}`,action_data:{action_name:"go_to_url",kwargs:n}}}}if("WAIT_UNTIL"in t){let i=t.WAIT_UNTIL,r=typeof t.timeout_seconds=="number"?t.timeout_seconds:60;return{uid:A(),type:"ACTION",description:`Wait until: ${i}`,action_entity:{action_description:`Wait until: ${i}`,action_data:{action_name:"ai_wait_until",kwargs:{condition:typeof i=="string"?i:String(i),timeout_seconds:r}}}}}if("WAIT"in t){let i=t.WAIT,r=typeof t.seconds=="number"?t.seconds:3;return{uid:A(),type:"ACTION",description:typeof i=="string"?i:`Wait ${r}s`,action_entity:{action_description:typeof i=="string"?i:`Wait ${r}s`,action_data:{action_name:"wait",kwargs:{seconds:r}}}}}if("CODE"in t){let i=t.CODE;return{uid:A(),type:"ACTION",description:"Code block",action_entity:{action_description:"Code block",action_data:{action_name:"js_code",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("js"in t&&("intent"in t||"desc"in t)&&!("VERIFY"in t)){let i=t.js,r=typeof t.intent=="string"?t.intent:typeof t.desc=="string"?t.desc:"";return{uid:A(),type:"ACTION",description:r,action_entity:{action_description:r,action_data:{action_name:"js_action",kwargs:{code:typeof i=="string"?i:String(i)}}}}}if("call"in t&&typeof t.call=="string"){let{call:i,...r}=t;return ce({...r,action:"function",functionName:i})}if("action"in t)return ce(t);if("intent"in t&&typeof t.intent=="string"||"desc"in t&&typeof t.desc=="string")return{uid:A(),type:"DRAFT",description:typeof t.intent=="string"?t.intent:t.desc};throw new Error(`Cannot infer statement type from object: ${JSON.stringify(t)}`)}function pe(e){if(typeof e!="string")throw new Error(`Condition must be a string, got ${typeof e}`);return e.startsWith("js:")?{type:"JS_CODE",expression:e.slice(3)}:{type:"AI_MODE",expression:e}}function pt(e){let t=pe(e.IF),i=e.THEN;if(!Array.isArray(i))throw new Error("IF_ELSE requires a THEN array");let r={uid:A(),type:"IF_ELSE",condition:t,then:M(i)};return"ELSE"in e&&Array.isArray(e.ELSE)&&(r.else=M(e.ELSE)),r}function ft(e){let t=pe(e.WHILE),i=e.DO;if(!Array.isArray(i))throw new Error("WHILE_LOOP requires a DO array");let r={uid:A(),type:"WHILE_LOOP",condition:t,body:M(i)};return typeof e.timeout_ms=="number"&&(r.timeout_ms=e.timeout_ms),r}function mt(e){let t=typeof e.STEP=="string"?e.STEP:"";if(!Array.isArray(e.statements))throw new Error("STEP requires a statements array");let i={uid:A(),type:"STEP",description:t,statements:M(e.statements)};return typeof e.reference_id=="number"&&(i.reference_id=e.reference_id),i}var gt=new Set(["action","intent","desc","locator","xpath","use_pure_vision"]);function ce(e){let t=typeof e.action=="string"?e.action:String(e.action),i=typeof e.intent=="string"?e.intent:typeof e.desc=="string"?e.desc:"",r=typeof e.locator=="string"?e.locator:void 0,o=typeof e.xpath=="string"?e.xpath:void 0,n=typeof e.use_pure_vision=="boolean"?e.use_pure_vision:void 0,l={};for(let[u,h]of Object.entries(e))gt.has(u)||(l[u]=h);let a={action_description:i,action_data:{action_name:t,kwargs:Object.keys(l).length>0?l:{}}};r&&(a.locator=r),o&&(a.xpath=o);let c={uid:A(),type:"ACTION",description:i,action_entity:a};return n&&(c.use_pure_vision=!0),c}var wt=.5,me=new Set(["verify","ai_assert","done","go_to_url","ai_wait_until","wait","js_code"]);function ge(e){let t=0,i=0;for(let r of e)if(r.type==="DRAFT")i++;else if(r.type==="ACTION"){let o=r.action_entity?.action_data?.action_name??"";me.has(o)||t++}return{action:t,draft:i}}function yt(e){try{return new Function(`return async function() { ${e} }`),null}catch(t){return t.message}}function fe(e){try{return new Function(`return async function() { return (${e}) }`),null}catch(t){return t.message}}function St(e,t){let i=t?.coverageThreshold??wt,r=[],o=[],n;try{n=C(e)}catch(f){return{valid:!1,errors:[`Invalid YAML: ${f.message}`],warnings:[],stats:{total:0,action:0,draft:0,coverage:0}}}n.goal||r.push('Missing required field: "goal"'),n.statements?.length||r.push('Missing required field: "statements"');let l=[...B(n.statements??[]),...n.teardown?B(n.teardown):[]],{action:a,draft:c}=ge(l),u="Hint: in YAML double-quoted strings, backslashes are escape characters \u2014 use \\\\/ instead of \\/ for regex, or use single quotes.";for(let f of l){if(f.type==="ACTION"){let m=f,S=m.action_entity?.action_data?.action_name??"";if(S==="js_code"||S==="js_action"||S==="verify"||S==="ai_assert"){let g=m.action_entity?.action_data?.kwargs?.code;if(typeof g=="string"){let N=yt(g);if(N){let V=m.description||S;r.push(`Invalid JS in "${V}": ${N}. ${u}`)}}}}if(f.type==="IF_ELSE"){let m=f;if(m.condition.type==="JS_CODE"){let S=fe(m.condition.expression);S&&r.push(`Invalid JS in IF condition "${m.condition.expression}": ${S}. ${u}`)}}if(f.type==="WHILE_LOOP"){let m=f;if(m.condition.type==="JS_CODE"){let S=fe(m.condition.expression);S&&r.push(`Invalid JS in WHILE condition "${m.condition.expression}": ${S}. ${u}`)}}}let h=a+c,d=h>0?Math.round(a/h*100):0;return h>0&&d/100<i&&o.push(`Low action coverage: ${a}/${h} statements (${d}%) are enriched with action/js. ${c} draft statement(s) still need enrichment. Use MCP tools (act, get_locators) to convert drafts to actions.`),{valid:r.length===0,errors:r,warnings:o,stats:{total:h,action:a,draft:c,coverage:d}}}function Tt(){return{version:"1.0",entries:{}}}function bt(e,t){return{action_entity:e,updated_at:new Date().toISOString(),updated_by:{source:"runner",test_run_id:t}}}function Mt(e,t){let i=t?.entries[e.uid],r=i?.action_entity??e.action_entity;return e.locator&&r?{...r,locator:e.locator}:i?i.action_entity:e.action_entity?e.action_entity:null}function At(e,t,i,r){return e.entries[t]={action_entity:i,updated_at:new Date().toISOString(),updated_by:r},e}function _t(e,t){let i=e??{version:"1.0",entries:{}};for(let[r,o]of t)i.entries[r]=o;return i}function Pt(e){return e?Object.keys(e.entries).length===0:!0}function vt(e){return e?Object.keys(e.entries).length:0}function Et(e,t){if(!t||Object.keys(t.entries).length===0)return e;let i=q(e.statements??[],t),r=e.teardown?q(e.teardown,t):void 0;return{...e,statements:i,teardown:r}}function q(e,t){return e.map(i=>kt(i,t))}function kt(e,t){if(e.type==="ACTION"){let o=e,n=t.entries[o.uid];return n?{...o,action_entity:n.action_entity}:o}let i=k(e);if(i.length===0)return e;let r={};for(let o of i)r[o.key]=q(o.statements,t);return{...e,...r}}import{parse as Ot,stringify as It}from"yaml";function we(e,t){let i=[];t.version!=="1.0"&&i.push(`Unsupported patch version: ${t.version}`),(!Array.isArray(t.operations)||t.operations.length===0)&&i.push("Patch must have at least one operation");for(let r=0;r<t.operations.length;r++){let o=t.operations[r],n=`operations[${r}]`;switch(o.reason||i.push(`${n}: missing reason`),o.op){case"remove":{(typeof o.index!="number"||o.index<0||o.index>=e.length)&&i.push(`${n}: index ${o.index} out of bounds (0..${e.length-1})`);break}case"modify":{(typeof o.index!="number"||o.index<0||o.index>=e.length)&&i.push(`${n}: index ${o.index} out of bounds (0..${e.length-1})`),(o.statement===void 0||o.statement===null)&&i.push(`${n}: missing statement`);break}case"insert":{(typeof o.index!="number"||o.index<0||o.index>=e.length)&&i.push(`${n}: index ${o.index} out of bounds (0..${e.length-1})`),o.position!=="before"&&o.position!=="after"&&i.push(`${n}: position must be 'before' or 'after'`),(o.statement===void 0||o.statement===null)&&i.push(`${n}: missing statement`);break}default:i.push(`${n}: unknown operation type "${o.op}"`)}}return{valid:i.length===0,errors:i}}function ye(e,t){let i=we(e,t);if(!i.valid)throw new Error(`Invalid patch: ${i.errors.join("; ")}`);let r=[...e],o=t.operations.map((a,c)=>({...a,originalOrder:c})),n={remove:0,modify:1,insert:2},l=[...o].sort((a,c)=>a.index!==c.index?c.index-a.index:n[a.op]-n[c.op]);for(let a of l)switch(a.op){case"remove":r.splice(a.index,1);break;case"modify":r[a.index]=a.statement;break;case"insert":a.position==="before"?r.splice(a.index,0,a.statement):r.splice(a.index+1,0,a.statement);break}return r}function Lt(e,t){let i=Ot(e);if(!i||typeof i!="object")throw new Error("Invalid YAML: expected an object at root level");let r=i.statements;if(!Array.isArray(r))throw new Error('YAML must have a "statements" array');let o=ye(r,t);i.statements=o;let n=It(i,{lineWidth:120,defaultKeyType:"PLAIN",defaultStringType:"PLAIN"});return C(n),{modifiedYaml:n,modifiedStatements:o}}var Se=(e=>(e.DRAFT="DRAFT",e.STEP="STEP",e.ACTION="ACTION",e.IF_ELSE="IF_ELSE",e.WHILE_LOOP="WHILE_LOOP",e))(Se||{}),Te=(e=>(e.JS_CODE="JS_CODE",e.AI_MODE="AI_MODE",e))(Te||{}),xt=18e4;var _="android:",P="ios:";function Dt(e){return e?e.startsWith(_)?"android":e.startsWith(P)?"ios":"web":"web"}function Wt(e){return e?e.startsWith(_)||e.startsWith(P):!1}function Ct(e){return!!e&&e.startsWith(_)}function Gt(e){return!!e&&e.startsWith(P)}function Kt(e){return e.startsWith(_)?e.slice(_.length):e.startsWith(P)?e.slice(P.length):e}function Nt(e){return`${_}${e}`}function Ft(e){return`${P}${e}`}function Z(e){return e?e.startsWith("http://")||e.startsWith("https://"):!1}function Bt(e){return e?!Z(e):!1}function be(e){return e?Z(e)?["web"]:["android","ios"]:["web","android","ios"]}function Ht(e,t){if(!t)return!0;let i=be(t);return e==="desktop"||e==="mobile"?i.includes("web"):i.includes(e)}function Rt(e){return e.startsWith(P)?e:`${P}${e}`}function $t(e){let t=e.iosVersion?` (iOS ${e.iosVersion})`:"";return e.deviceType==="simulator"?`${e.name}${t} - Simulator`:`${e.name}${t}`}function Ut(e){return!!(/^[0-9a-fA-F]{40}$/.test(e)||/^[0-9a-fA-F]{8}-[0-9a-fA-F]{16}$/.test(e))}var Me="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",Q=112,Ae=1920,_e=1080,Pe=1920,ve=1080-Q,Ee=1280,ke=720,Oe=500,Ie=500,G="Desktop Chrome",Le=(e=>(e.Chromium="chromium",e.Firefox="firefox",e.Webkit="webkit",e))(Le||{}),U={"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"}},xe=(e=>(e.Desktop="desktop",e.Mobile="mobile",e))(xe||{}),De={desktop:["Desktop Chrome","Desktop Chrome Medium Resolution","Desktop Chrome (Branded)","Desktop Chrome Medium Resolution (Branded)","Desktop Edge (Branded)","Desktop Edge Medium Resolution (Branded)","Desktop Safari"],mobile:["iPhone 15 Pro Max","iPhone 15 Pro","iPhone 15 Plus","iPhone 15","iPhone 14 Pro Max","iPhone 14 Pro","iPhone 14 Plus","iPhone 14","iPhone 13 Pro Max","iPhone 13 Pro","iPhone 13","iPhone 13 Mini","iPhone 12 Pro Max","iPhone 12 Pro","iPhone 12","iPhone 12 Mini","iPhone 11 Pro Max","iPhone 11 Pro","iPhone 11","iPhone XR","iPhone X","iPhone SE (3rd gen)","iPhone SE","iPhone 8 Plus","iPhone 8","iPhone 7 Plus","iPhone 7","iPhone 6 Plus","iPhone 6","Galaxy S24","Galaxy A55","Galaxy S9+","Galaxy S8","Galaxy S5","Galaxy Note 3","Galaxy Note II","Galaxy S III","Pixel 7","Pixel 5","Pixel 4a (5G)","Pixel 4","Pixel 3","Pixel 2 XL","Pixel 2","Nexus 6P","Nexus 6","Nexus 5X","Nexus 5","Nexus 4","Moto G4","LG Optimus L70","Microsoft Lumia 950","Microsoft Lumia 550","Nokia Lumia 520","Nokia N9","BlackBerry Z30"]},K=(e,t=!1)=>{let i=["chromium"];return t&&i.push("webkit"),De[e].map(r=>U[r]).filter(r=>r.defaultBrowserType&&i.includes(r.defaultBrowserType))},zt=()=>Object.keys(U),z=e=>U[e],Vt={desktop:{label:"Desktop",type:"desktop",devices:K("desktop")},mobile:{label:"Mobile Web",type:"mobile",devices:K("mobile")}},Xt={desktop:{label:"Desktop",type:"desktop",devices:K("desktop",!0)},mobile:{label:"Mobile Web",type:"mobile",devices:K("mobile",!0)}},ee=(e,t=!1)=>{let i={userAgent:Me,viewport:{width:Pe,height:ve},isMobile:!1,hasTouch:!1};if(!e||e===G)return i;let r=z(e);if(!r)return i;let{width:o,height:n}=r.viewport,l=Math.max(Oe/o,1),a=Math.max(Ie/n,1),c=Math.max(l,a),u={width:Math.round(o*c),height:Math.round(n*c)};return{userAgent:r.userAgent,viewport:t?u:r.viewport,isMobile:r.isMobile,hasTouch:r.hasTouch}},Yt=e=>{let t={width:Ae,height:_e};if(!e||e===G)return t;let i=ee(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height+Q}:t},jt=e=>{let t={width:Ee,height:ke};if(!e||e===G)return t;let i=ee(e);return i.viewport?{width:i.viewport.width,height:i.viewport.height}:t},Jt=e=>!e||e===G?void 0:z(e)?.channel,qt=e=>!e||e===G?"chromium":z(e)?.defaultBrowserType??"chromium";var We=(e=>(e.PASSWORD="password",e.OAUTH2="oauth2",e.SSO="sso",e.API="api",e))(We||{}),Ce=(e=>(e.SMS="sms",e.EMAIL="email",e.TOTP="totp",e))(Ce||{});function Zt(e,t){if(!e||typeof e!="string")return e;let i=t instanceof Map?Object.fromEntries(t):t,r=n=>{let l=n.startsWith("$")?n.slice(1):n,a=i[l]??i[`$${l}`];return a!=null?String(a):void 0},o=e;return o=o.replace(/\{\{\s*\$?([^}]+?)\s*\}\}/g,(n,l)=>{let a=r(l.trim());return a!==void 0?a:n}),o=o.replace(/<secret>\$?([\w-]+)<\/secret>/g,(n,l)=>{let a=r(l);return a!==void 0?a:n}),o=o.replace(/\$\{([^}]+)\}/g,(n,l)=>{let a=r(l.trim());return a!==void 0?a:n}),o=o.replace(/\$([a-zA-Z_]\w*)/g,(n,l)=>{let a=r(l);return a!==void 0?a:n}),o}var Qt=class{version;goal;url;constructor(e,t){this.version=e,this.goal=t.goal,this.url=t.url}generatePrelude(){let e=`// version ${this.version}
|
|
5
5
|
`,t=this.goal,i=this.url;e+=`// Navigate to the specified URL
|
|
6
6
|
const targetUrl = process.env.PLAYWRIGHT_STARTING_URL || '${i}';
|