ripplo 0.0.3 → 0.0.4
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/index.js +65 -65
- package/dist/mcp/index.js +8 -8
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`):`${e.status}: ${e.title}`;return{specNode:e.specNode,stepResult:n,toolOutput:a}}var P=f(()=>{"use strict";Re()});import{z as Jo}from"zod";var Ss,Yo,Ko=f(()=>{"use strict";P();Ss=Jo.object({selector:Jo.string().describe("CSS selector for the checkbox or radio button")}),Yo=g({description:"Assert that a checkbox or radio button is checked",name:"assert_checked",schema:Ss,execute:async(e,t)=>{let o=performance.now(),r=await e.page.locator(t.selector).isChecked().catch(()=>!1),n=r?"passed":"failed",a=[{description:`Element ${t.selector} is checked`,detail:r?void 0:"Element is not checked",status:n}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertChecked"};return w({assertions:a,detail:r?"Element is checked":"Element is not checked",duration:performance.now()-o,nodeType:"assertChecked",page:e.page,runStartTime:e.runStartTime,specNode:i,status:n,stepIndex:e.stepIndex,title:`Assert checked: ${t.selector}`})}})});import{z as de}from"zod";function Ps({cookie:e,input:t}){return[Rs(t.value,e.value),Qo("httpOnly",t.httpOnly,e.httpOnly),Qo("secure",t.secure,e.secure),xs("sameSite",t.sameSite,e.sameSite)].filter(o=>o!=null)}function Rs(e,t){if(e==null)return;let o=t.includes(e);return{description:`Cookie value contains "${e}"`,detail:o?void 0:`Got: "${t}"`,status:o?"passed":"failed"}}function Qo(e,t,o){if(t!=null)return{description:`Cookie ${e} is ${String(t)}`,detail:o===t?void 0:`Got: ${String(o)}`,status:o===t?"passed":"failed"}}function xs(e,t,o){if(t!=null)return{description:`Cookie ${e} is ${t}`,detail:o===t?void 0:`Got: ${o}`,status:o===t?"passed":"failed"}}var bs,Xo,Zo=f(()=>{"use strict";P();bs=de.object({httpOnly:de.boolean().optional().describe("Assert httpOnly flag value"),name:de.string().describe("Cookie name to check"),sameSite:de.enum(["Strict","Lax","None"]).optional().describe("Assert sameSite value"),secure:de.boolean().optional().describe("Assert secure flag value"),value:de.string().optional().describe("Expected cookie value (substring match)")}),Xo=g({description:"Assert properties of a browser cookie. Check existence, value, and security flags (httpOnly, secure, sameSite).",name:"assert_cookie",schema:bs,execute:async(e,t)=>{let o=performance.now(),n=(await e.page.context().cookies()).find(p=>p.name===t.name),a=n==null?[{description:`Cookie "${t.name}" exists`,detail:"Cookie not found",status:"failed"}]:[{description:`Cookie "${t.name}" exists`,detail:void 0,status:"passed"},...Ps({cookie:n,input:t})],s=a.some(p=>p.status==="failed"),i=s?"failed":"passed",d={id:`agent-step-${String(e.stepIndex)}`,name:{type:"static",value:t.name},type:"assertCookie"};return w({assertions:a,detail:s?a.filter(p=>p.status==="failed").map(p=>p.detail).join("; "):"Cookie OK",duration:performance.now()-o,nodeType:"assertCookie",page:e.page,runStartTime:e.runStartTime,specNode:d,status:i,stepIndex:e.stepIndex,title:`Assert cookie: ${t.name}`})}})});import{z as er}from"zod";var vs,tr,or=f(()=>{"use strict";P();vs=er.object({selector:er.string().describe("CSS selector for the element to check focus on")}),tr=g({description:"Assert that an element has keyboard focus. Use for accessibility tab-order testing.",name:"assert_focused",schema:vs,execute:async(e,t)=>{let o=performance.now(),n=!!await e.page.locator(t.selector).evaluate("(el) => document.activeElement === el").catch(()=>!1),a=n?"passed":"failed",s=[{description:`Element ${t.selector} is focused`,detail:n?void 0:"Element does not have focus",status:a}],l={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertFocused"};return w({assertions:s,detail:n?"Element is focused":"Element does not have focus",duration:performance.now()-o,nodeType:"assertFocused",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert focused: ${t.selector}`})}})});import{z as ue}from"zod";function Ts(e,t){if(e!=null)return{description:`Response status equals ${String(e)}`,detail:t===e?void 0:`Got: ${String(t)}`,status:t===e?"passed":"failed"}}async function Cs(e,t){if(e==null)return;let r=(await t.text()).includes(e);return{description:`Response body contains "${e}"`,detail:r?void 0:"Not found in response body",status:r?"passed":"failed"}}function Ns(e,t,o){if(e==null||t==null)return;let r=o[e.toLowerCase()],n=r!=null&&r.includes(t);return{description:`Response header "${e}" contains "${t}"`,detail:n?void 0:`Got: "${r??"(missing)"}"`,status:n?"passed":"failed"}}var ks,rr,nr=f(()=>{"use strict";P();ks=ue.object({bodyContains:ue.string().optional().describe("Assert response body contains this string"),headerName:ue.string().optional().describe("Response header name to check"),headerValue:ue.string().optional().describe("Expected value the header should contain"),status:ue.number().int().optional().describe("Expected HTTP status code"),urlPattern:ue.string().describe("URL substring to match the response against")}),rr=g({description:"Wait for a network response matching the URL pattern and assert on its status, body, or headers. Useful for verifying API calls and security headers (CSP, CORS).",name:"assert_response",schema:ks,execute:async(e,t)=>{let o=performance.now(),r=await e.page.waitForResponse(d=>d.url().includes(t.urlPattern),{timeout:1e4}),n=[Ts(t.status,r.status()),await Cs(t.bodyContains,r),Ns(t.headerName,t.headerValue,r.headers())].filter(d=>d!=null),a=n.length===0?[{description:`Response matching "${t.urlPattern}" received`,detail:void 0,status:"passed"}]:n,s=a.some(d=>d.status==="failed"),l={id:`agent-step-${String(e.stepIndex)}`,type:"assertResponse",urlPattern:{type:"static",value:t.urlPattern}};return w({assertions:a,detail:s?a.filter(d=>d.status==="failed").map(d=>d.detail).join("; "):"Response OK",duration:performance.now()-o,nodeType:"assertResponse",page:e.page,runStartTime:e.runStartTime,specNode:l,status:s?"failed":"passed",stepIndex:e.stepIndex,title:`Assert response: ${t.urlPattern}`})}})});import{z as Ct}from"zod";var Is,ar,sr=f(()=>{"use strict";P();Is=Ct.object({expected:Ct.string().describe("The expected text content"),selector:Ct.string().describe("CSS selector for the element to check")}),ar=g({description:"Assert that an element's text content matches the expected value",name:"assert_text",schema:Is,execute:async(e,t)=>{let o=performance.now(),r=await e.page.locator(t.selector).textContent({timeout:5e3}).catch(()=>null),n=r!=null&&r.includes(t.expected),a=n?"passed":"failed",s=[{description:`Text contains "${t.expected}"`,detail:`Actual: "${r??"(not found)"}"`,status:a}],i=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:i,locator:{by:"css",value:t.selector},operator:"contains",type:"assertText"};return w({assertions:s,detail:n?`Text matches: "${t.expected}"`:`Expected "${t.expected}", got "${r??"(not found)"}"`,duration:performance.now()-o,nodeType:"assertText",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert text: ${t.selector}`})}})});import{z as Nt}from"zod";function As({actual:e,expected:t,operator:o}){return o==="equals"?e===t:o==="contains"?e.includes(t):o==="startsWith"?e.startsWith(t):o==="endsWith"?e.endsWith(t):!1}var js,ir,lr=f(()=>{"use strict";P();js=Nt.object({expected:Nt.string().describe("Expected page title or substring"),operator:Nt.enum(["equals","contains","startsWith","endsWith"]).describe("Comparison operator").default("contains")}),ir=g({description:"Assert that the page title matches an expected value",name:"assert_title",schema:js,execute:async(e,t)=>{let o=performance.now(),r=await e.page.title(),n=As({actual:r,expected:t.expected,operator:t.operator}),a=n?"passed":"failed",s=[{description:`Title ${t.operator} "${t.expected}"`,detail:n?void 0:`Got: "${r}"`,status:a}],i=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:i,operator:t.operator,type:"assertTitle"};return w({assertions:s,detail:n?"Title matches":`Expected title ${t.operator} "${t.expected}", got "${r}"`,duration:performance.now()-o,nodeType:"assertTitle",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert title ${t.operator} "${t.expected}"`})}})});import{z as cr}from"zod";var $s,dr,ur=f(()=>{"use strict";P();$s=cr.object({selector:cr.string().describe("CSS selector for the element to check")}),dr=g({description:"Assert that an element matching the selector is visible on the page",name:"assert_visible",schema:$s,execute:async(e,t)=>{let o=performance.now(),r=await e.page.locator(t.selector).isVisible().catch(()=>!1),n=r?"passed":"failed",a=[{description:`Element ${t.selector} is visible`,detail:r?"Element is visible":"Element is not visible",status:n}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertVisible"};return w({assertions:a,detail:r?"Element is visible":"Element is not visible",duration:performance.now()-o,nodeType:"assertVisible",page:e.page,runStartTime:e.runStartTime,specNode:i,status:n,stepIndex:e.stepIndex,title:`Assert visible: ${t.selector}`})}})});import{z as pr}from"zod";var Es,fr,mr=f(()=>{"use strict";P();Es=pr.object({selector:pr.string().describe("CSS selector for the checkbox to check")}),fr=g({description:"Check a checkbox matching the CSS selector",name:"check",schema:Es,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).check({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"check"};return w({assertions:[],detail:`Checked ${t.selector}`,duration:performance.now()-o,nodeType:"check",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Check ${t.selector}`})}})});import{z as gr}from"zod";var Vs,yr,hr=f(()=>{"use strict";P();Vs=gr.object({selector:gr.string().describe("CSS selector for the input to clear")}),yr=g({description:"Clear the contents of an input field",name:"clear",schema:Vs,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).clear({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"clear"};return w({assertions:[],detail:`Cleared ${t.selector}`,duration:performance.now()-o,nodeType:"clear",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Clear ${t.selector}`})}})});import{z as wr}from"zod";var Ds,Sr,br=f(()=>{"use strict";P();Ds=wr.object({selector:wr.string().describe("CSS selector for the element to click")}),Sr=g({description:"Click an element matching the CSS selector",name:"click",schema:Ds,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).click({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"click"};return w({assertions:[],detail:`Clicked ${t.selector}`,duration:performance.now()-o,nodeType:"click",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Click ${t.selector}`})}})});import{z as It}from"zod";var Os,Pr,Rr=f(()=>{"use strict";P();Os=It.object({action:It.enum(["read","write"]).describe("Whether to read from or write to the clipboard"),value:It.string().optional().describe("Text to write (required for write action)")}),Pr=g({description:"Read from or write to the browser clipboard. For write, provide the text value. For read, the clipboard contents are returned.",name:"clipboard",schema:Os,execute:async(e,t)=>{let o=performance.now(),r=`agent-step-${String(e.stepIndex)}`;if(t.action==="write"){if(t.value==null)throw new Error("clipboard write requires a value");let s=JSON.stringify(t.value);await e.page.evaluate(`navigator.clipboard.writeText(${s})`);let i={action:"write",id:r,type:"clipboard",value:{type:"static",value:t.value}};return w({assertions:[],detail:`Wrote to clipboard: "${t.value}"`,duration:performance.now()-o,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:i,status:"passed",stepIndex:e.stepIndex,title:"Clipboard write"})}let n=String(await e.page.evaluate("navigator.clipboard.readText()")),a={action:"read",id:r,type:"clipboard"};return w({assertions:[],detail:`Clipboard contents: "${n}"`,duration:performance.now()-o,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:a,status:"passed",stepIndex:e.stepIndex,title:"Clipboard read"})}})});import{z as _e}from"zod";var xr,vr,kr=f(()=>{"use strict";xr=_e.object({summary:_e.string().describe("This is the ONLY output the user sees. If the agent profile specifies an Output format, follow those instructions exactly. Otherwise, provide a summary of your findings."),verdict:_e.enum(["pass","fail"]).describe("Whether the test passed or failed. If the agent profile defines Success Criteria, base this verdict on whether those criteria were met.")}),vr={anthropicTool:{description:"Call this tool when you have finished your evaluation. If the agent profile defines an Output section, the summary MUST follow those output instructions exactly. Otherwise, summarize your findings.",input_schema:{..._e.toJSONSchema(xr,{target:"draft-2020-12"}),type:"object"},name:"complete_test"},name:"complete_test",execute(e,t){let o=xr.parse(t),r={kind:"verdict",summary:o.summary,toolOutput:`Verdict: ${o.verdict}
|
|
4
|
-
${o.summary}`,verdict:o.verdict};return Promise.resolve(r)}}});import{z as Tr}from"zod";var
|
|
2
|
+
var ss=Object.defineProperty;var f=(e,t)=>()=>(e&&(t=e(e=0)),t);var is=(e,t)=>{for(var o in t)ss(e,o,{get:t[o],enumerable:!0})};function v({locator:e,page:t}){switch(e.by){case"css":return t.locator(e.value);case"testId":return t.getByTestId(e.value);case"role":return t.getByRole(e.role,{exact:e.exact,name:e.name});case"text":return t.getByText(e.value,{exact:e.exact});case"label":return t.getByLabel(e.value,{exact:e.exact});case"placeholder":return t.getByPlaceholder(e.value);case"altText":return t.getByAltText(e.value)}}var Z=f(()=>{"use strict"});function Pe({defs:e}){return e==null?{}:Object.fromEntries(Object.entries(e).map(([t,o])=>[t,cs({def:o,name:t})]))}function cs({def:e,name:t}){if(e.type==="env"){let o=process.env[e.key];if(o==null)throw new Error(`Environment variable "${e.key}" not set for variable "${t}"`);return o}return e.default??ls[e.type]??""}function ae({ref:e,variables:t}){if(e.type==="static")return e.value;let o=t[e.name];if(o==null)throw new Error(`Variable "${e.name}" is not defined`);return o}function T({ref:e,variables:t}){let o=String(ae({ref:e,variables:t}));return ds({raw:o,variables:t})}function ds({raw:e,variables:t}){return e.replaceAll(/\{\{(\w+)\}\}/g,(o,r)=>{let n=t[r];if(n==null)throw new Error(`Template variable "{{${r}}}" is not defined`);return String(n)})}function vt({ref:e,variables:t}){let o=ae({ref:e,variables:t});if(typeof o=="number")return o;let r=Number(o);if(Number.isNaN(r))throw new TypeError(`Cannot convert "${String(o)}" to number`);return r}function Y({name:e,store:t,value:o}){return{...t,[e]:o}}var ls,G=f(()=>{"use strict";ls={boolean:!1,number:0,string:""}});async function qo({node:e,page:t,timeout:o}){await v({locator:e.source,page:t}).dragTo(v({locator:e.target,page:t}),{timeout:o})}async function zo({node:e,page:t,timeout:o}){await v({locator:e.locator,page:t}).click({button:"right",timeout:o})}function Bo({node:e,page:t,variables:o}){return t.once("dialog",async r=>{e.action==="accept"?await r.accept(e.promptText??void 0):await r.dismiss()}),{variables:o}}async function Mo({node:e,page:t}){let o=e.x??0,r=e.y??0;if(e.locator==null){await t.mouse.wheel(o,r);return}let a=await v({locator:e.locator,page:t}).elementHandle();if(a==null)throw new Error("scroll target element not found");await a.evaluate("([dx, dy]) => this.scrollBy(dx, dy)",[o,r])}async function _o({node:e,page:t,variables:o}){if(e.action==="write"){if(e.value==null)throw new Error("clipboard write requires a value");let n=T({ref:e.value,variables:o}),a=JSON.stringify(n);return await t.evaluate(`navigator.clipboard.writeText(${a})`),{variables:o}}if(e.variable==null)throw new Error("clipboard read requires a variable name to store the result");let r=String(await t.evaluate("navigator.clipboard.readText()"));return{variables:Y({name:e.variable,store:o,value:r})}}async function Go({node:e,page:t}){let o=t.context();e.state==="granted"?await o.grantPermissions([e.permission]):await o.clearPermissions()}var Ho=f(()=>{"use strict";Z();G()});async function kt({node:e,page:t,timeout:o,variables:r}){switch(e.type){case"click":case"check":case"uncheck":case"clear":case"dblclick":case"focus":case"hover":case"scrollIntoView":return ps({node:e,page:t,timeout:o,variables:r});case"rightClick":return await zo({node:e,page:t,timeout:o}),{variables:r};case"goto":{let n=T({ref:e.url,variables:r});return await t.goto(n,{timeout:o,waitUntil:"domcontentloaded"}),{variables:r}}case"fill":{let n=T({ref:e.value,variables:r});return await v({locator:e.locator,page:t}).fill(n,{timeout:o}),{variables:r}}case"select":{let n=T({ref:e.value,variables:r});return await v({locator:e.locator,page:t}).selectOption(n,{timeout:o}),{variables:r}}case"type":{let n=T({ref:e.value,variables:r});return await v({locator:e.locator,page:t}).pressSequentially(n,{timeout:o}),{variables:r}}case"press":return await ms({node:e,page:t,timeout:o}),{variables:r};case"drag":return await qo({node:e,page:t,timeout:o}),{variables:r};case"upload":return await v({locator:e.locator,page:t}).setInputFiles(e.files,{timeout:o}),{variables:r};case"extractText":{let n=await v({locator:e.locator,page:t}).textContent({timeout:o});if(n==null)throw new Error("extractText: element had no text content");return{variables:Y({name:e.variable,store:r,value:n})}}case"setVariable":{let n=ae({ref:e.value,variables:r});return{variables:Y({name:e.variable,store:r,value:n})}}case"fail":throw new Error(e.message);case"waitFor":return await v({locator:e.locator,page:t}).waitFor({state:e.state??"visible",timeout:o}),{variables:r};case"waitForUrl":{let n=T({ref:e.expected,variables:r});return await t.waitForURL(fs({expected:n,operator:e.operator}),{timeout:o}),{variables:r}}case"waitForResponse":{let n=T({ref:e.urlPattern,variables:r});return await t.waitForResponse(a=>a.url().includes(n),{timeout:o}),{variables:r}}case"waitForRequest":{let n=T({ref:e.urlPattern,variables:r});return await t.waitForRequest(a=>a.url().includes(n),{timeout:o}),{variables:r}}case"wait":return await t.waitForTimeout(e.duration),{variables:r};case"screenshot":return await t.screenshot(),{variables:r};case"setViewport":return await t.setViewportSize({height:e.height,width:e.width}),{variables:r};case"handleDialog":return Bo({node:e,page:t,variables:r});case"scroll":return await Mo({node:e,page:t}),{variables:r};case"clipboard":return _o({node:e,page:t,variables:r});case"setPermission":return await Go({node:e,page:t}),{variables:r}}}async function ps({node:e,page:t,timeout:o,variables:r}){return await v({locator:e.locator,page:t})[us[e.type]]({timeout:o}),{variables:r}}function fs({expected:e,operator:t}){return o=>{let r=o.toString();return t==="equals"?r===e:t==="notEquals"?r!==e:t==="contains"?r.includes(e):t==="startsWith"?r.startsWith(e):t==="endsWith"?r.endsWith(e):new RegExp(e).test(r)}}async function ms({node:e,page:t,timeout:o}){e.locator==null?await t.keyboard.press(e.key):await v({locator:e.locator,page:t}).press(e.key,{timeout:o})}var us,Tt=f(()=>{"use strict";Ho();Z();G();us={check:"check",clear:"clear",click:"click",dblclick:"dblclick",focus:"focus",hover:"hover",scrollIntoView:"scrollIntoViewIfNeeded",uncheck:"uncheck"}});async function ee({page:e,runStartTime:t,targets:o}){let r=e.viewportSize();if(r==null)throw new Error("Page has no viewport set");let[n,a]=await Promise.all([e.screenshot({type:"png"}),ys(o)]),s=n.toString("base64");return{annotations:a,screenshotBase64:s,snapshotTimestamp:Math.round(performance.now()-t),url:e.url(),viewportHeight:r.height,viewportWidth:r.width}}function gs(e){return"locator"in e}async function ys(e){return(await Promise.all(e.map(o=>hs(o)))).filter(o=>o!=null)}async function hs(e){if(!gs(e))return{height:0,label:e.label,type:e.type,width:0,x:0,y:0};let t=await e.locator.boundingBox({timeout:2e3}).catch(()=>null);if(t!=null)return{height:Math.round(t.height),label:e.label,type:e.type,width:Math.round(t.width),x:Math.round(t.x),y:Math.round(t.y)}}function Me({node:e,page:t}){if(e.type==="assertUrl"||e.type==="waitForUrl")return[{label:e.type,type:"urlBar"}];if(e.type==="drag"){let n=v({locator:e.source,page:t}),a=v({locator:e.target,page:t});return[{label:"drag-source",locator:n,type:"action"},{label:"drag-target",locator:a,type:"action"}]}if(!ws(e))return[];let o=e.type.startsWith("assert")?"assertion":"action",r=v({locator:e.locator,page:t});return[{label:e.type,locator:r,type:o}]}function ws(e){return"locator"in e&&e.locator!=null}var Re=f(()=>{"use strict";Z()});import{z as Ss}from"zod";function g({description:e,execute:t,name:o,schema:r}){let n=Ss.toJSONSchema(r,{target:"draft-2020-12"});return{anthropicTool:{description:e,input_schema:{...n,type:"object"},name:o},name:o,async execute(a,s){let i=r.parse(s);return{...await Promise.resolve(t(a,i)),kind:"action"}}}}async function w(e){let t=e.specNode==null?[]:Me({node:e.specNode,page:e.page}),o=await ee({page:e.page,runStartTime:e.runStartTime,targets:t}),r=[...e.assertions],n={annotations:o.annotations,assertions:r,detail:e.detail,duration:Math.round(e.duration),nodeId:`agent-step-${String(e.stepIndex)}`,nodeType:e.nodeType,screenshotBase64:o.screenshotBase64,snapshotTimestamp:o.snapshotTimestamp,status:e.status,stepIndex:e.stepIndex,title:e.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth},a=r.length>0?r.map(s=>`${s.status}: ${s.description} \u2014 ${s.detail??""}`).join(`
|
|
3
|
+
`):`${e.status}: ${e.title}`;return{specNode:e.specNode,stepResult:n,toolOutput:a}}var P=f(()=>{"use strict";Re()});import{z as Jo}from"zod";var bs,Yo,Ko=f(()=>{"use strict";P();bs=Jo.object({selector:Jo.string().describe("CSS selector for the checkbox or radio button")}),Yo=g({description:"Assert that a checkbox or radio button is checked",name:"assert_checked",schema:bs,execute:async(e,t)=>{let o=performance.now(),r=await e.page.locator(t.selector).isChecked().catch(()=>!1),n=r?"passed":"failed",a=[{description:`Element ${t.selector} is checked`,detail:r?void 0:"Element is not checked",status:n}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertChecked"};return w({assertions:a,detail:r?"Element is checked":"Element is not checked",duration:performance.now()-o,nodeType:"assertChecked",page:e.page,runStartTime:e.runStartTime,specNode:i,status:n,stepIndex:e.stepIndex,title:`Assert checked: ${t.selector}`})}})});import{z as de}from"zod";function Rs({cookie:e,input:t}){return[xs(t.value,e.value),Qo("httpOnly",t.httpOnly,e.httpOnly),Qo("secure",t.secure,e.secure),vs("sameSite",t.sameSite,e.sameSite)].filter(o=>o!=null)}function xs(e,t){if(e==null)return;let o=t.includes(e);return{description:`Cookie value contains "${e}"`,detail:o?void 0:`Got: "${t}"`,status:o?"passed":"failed"}}function Qo(e,t,o){if(t!=null)return{description:`Cookie ${e} is ${String(t)}`,detail:o===t?void 0:`Got: ${String(o)}`,status:o===t?"passed":"failed"}}function vs(e,t,o){if(t!=null)return{description:`Cookie ${e} is ${t}`,detail:o===t?void 0:`Got: ${o}`,status:o===t?"passed":"failed"}}var Ps,Xo,Zo=f(()=>{"use strict";P();Ps=de.object({httpOnly:de.boolean().optional().describe("Assert httpOnly flag value"),name:de.string().describe("Cookie name to check"),sameSite:de.enum(["Strict","Lax","None"]).optional().describe("Assert sameSite value"),secure:de.boolean().optional().describe("Assert secure flag value"),value:de.string().optional().describe("Expected cookie value (substring match)")}),Xo=g({description:"Assert properties of a browser cookie. Check existence, value, and security flags (httpOnly, secure, sameSite).",name:"assert_cookie",schema:Ps,execute:async(e,t)=>{let o=performance.now(),n=(await e.page.context().cookies()).find(p=>p.name===t.name),a=n==null?[{description:`Cookie "${t.name}" exists`,detail:"Cookie not found",status:"failed"}]:[{description:`Cookie "${t.name}" exists`,detail:void 0,status:"passed"},...Rs({cookie:n,input:t})],s=a.some(p=>p.status==="failed"),i=s?"failed":"passed",d={id:`agent-step-${String(e.stepIndex)}`,name:{type:"static",value:t.name},type:"assertCookie"};return w({assertions:a,detail:s?a.filter(p=>p.status==="failed").map(p=>p.detail).join("; "):"Cookie OK",duration:performance.now()-o,nodeType:"assertCookie",page:e.page,runStartTime:e.runStartTime,specNode:d,status:i,stepIndex:e.stepIndex,title:`Assert cookie: ${t.name}`})}})});import{z as er}from"zod";var ks,tr,or=f(()=>{"use strict";P();ks=er.object({selector:er.string().describe("CSS selector for the element to check focus on")}),tr=g({description:"Assert that an element has keyboard focus. Use for accessibility tab-order testing.",name:"assert_focused",schema:ks,execute:async(e,t)=>{let o=performance.now(),n=!!await e.page.locator(t.selector).evaluate("(el) => document.activeElement === el").catch(()=>!1),a=n?"passed":"failed",s=[{description:`Element ${t.selector} is focused`,detail:n?void 0:"Element does not have focus",status:a}],l={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertFocused"};return w({assertions:s,detail:n?"Element is focused":"Element does not have focus",duration:performance.now()-o,nodeType:"assertFocused",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert focused: ${t.selector}`})}})});import{z as ue}from"zod";function Cs(e,t){if(e!=null)return{description:`Response status equals ${String(e)}`,detail:t===e?void 0:`Got: ${String(t)}`,status:t===e?"passed":"failed"}}async function Ns(e,t){if(e==null)return;let r=(await t.text()).includes(e);return{description:`Response body contains "${e}"`,detail:r?void 0:"Not found in response body",status:r?"passed":"failed"}}function Is(e,t,o){if(e==null||t==null)return;let r=o[e.toLowerCase()],n=r!=null&&r.includes(t);return{description:`Response header "${e}" contains "${t}"`,detail:n?void 0:`Got: "${r??"(missing)"}"`,status:n?"passed":"failed"}}var Ts,rr,nr=f(()=>{"use strict";P();Ts=ue.object({bodyContains:ue.string().optional().describe("Assert response body contains this string"),headerName:ue.string().optional().describe("Response header name to check"),headerValue:ue.string().optional().describe("Expected value the header should contain"),status:ue.number().int().optional().describe("Expected HTTP status code"),urlPattern:ue.string().describe("URL substring to match the response against")}),rr=g({description:"Wait for a network response matching the URL pattern and assert on its status, body, or headers. Useful for verifying API calls and security headers (CSP, CORS).",name:"assert_response",schema:Ts,execute:async(e,t)=>{let o=performance.now(),r=await e.page.waitForResponse(d=>d.url().includes(t.urlPattern),{timeout:1e4}),n=[Cs(t.status,r.status()),await Ns(t.bodyContains,r),Is(t.headerName,t.headerValue,r.headers())].filter(d=>d!=null),a=n.length===0?[{description:`Response matching "${t.urlPattern}" received`,detail:void 0,status:"passed"}]:n,s=a.some(d=>d.status==="failed"),l={id:`agent-step-${String(e.stepIndex)}`,type:"assertResponse",urlPattern:{type:"static",value:t.urlPattern}};return w({assertions:a,detail:s?a.filter(d=>d.status==="failed").map(d=>d.detail).join("; "):"Response OK",duration:performance.now()-o,nodeType:"assertResponse",page:e.page,runStartTime:e.runStartTime,specNode:l,status:s?"failed":"passed",stepIndex:e.stepIndex,title:`Assert response: ${t.urlPattern}`})}})});import{z as Ct}from"zod";var js,ar,sr=f(()=>{"use strict";P();js=Ct.object({expected:Ct.string().describe("The expected text content"),selector:Ct.string().describe("CSS selector for the element to check")}),ar=g({description:"Assert that an element's text content matches the expected value",name:"assert_text",schema:js,execute:async(e,t)=>{let o=performance.now(),r=await e.page.locator(t.selector).textContent({timeout:5e3}).catch(()=>null),n=r!=null&&r.includes(t.expected),a=n?"passed":"failed",s=[{description:`Text contains "${t.expected}"`,detail:`Actual: "${r??"(not found)"}"`,status:a}],i=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:i,locator:{by:"css",value:t.selector},operator:"contains",type:"assertText"};return w({assertions:s,detail:n?`Text matches: "${t.expected}"`:`Expected "${t.expected}", got "${r??"(not found)"}"`,duration:performance.now()-o,nodeType:"assertText",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert text: ${t.selector}`})}})});import{z as Nt}from"zod";function $s({actual:e,expected:t,operator:o}){return o==="equals"?e===t:o==="contains"?e.includes(t):o==="startsWith"?e.startsWith(t):o==="endsWith"?e.endsWith(t):!1}var As,ir,lr=f(()=>{"use strict";P();As=Nt.object({expected:Nt.string().describe("Expected page title or substring"),operator:Nt.enum(["equals","contains","startsWith","endsWith"]).describe("Comparison operator").default("contains")}),ir=g({description:"Assert that the page title matches an expected value",name:"assert_title",schema:As,execute:async(e,t)=>{let o=performance.now(),r=await e.page.title(),n=$s({actual:r,expected:t.expected,operator:t.operator}),a=n?"passed":"failed",s=[{description:`Title ${t.operator} "${t.expected}"`,detail:n?void 0:`Got: "${r}"`,status:a}],i=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:i,operator:t.operator,type:"assertTitle"};return w({assertions:s,detail:n?"Title matches":`Expected title ${t.operator} "${t.expected}", got "${r}"`,duration:performance.now()-o,nodeType:"assertTitle",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert title ${t.operator} "${t.expected}"`})}})});import{z as cr}from"zod";var Es,dr,ur=f(()=>{"use strict";P();Es=cr.object({selector:cr.string().describe("CSS selector for the element to check")}),dr=g({description:"Assert that an element matching the selector is visible on the page",name:"assert_visible",schema:Es,execute:async(e,t)=>{let o=performance.now(),r=await e.page.locator(t.selector).isVisible().catch(()=>!1),n=r?"passed":"failed",a=[{description:`Element ${t.selector} is visible`,detail:r?"Element is visible":"Element is not visible",status:n}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertVisible"};return w({assertions:a,detail:r?"Element is visible":"Element is not visible",duration:performance.now()-o,nodeType:"assertVisible",page:e.page,runStartTime:e.runStartTime,specNode:i,status:n,stepIndex:e.stepIndex,title:`Assert visible: ${t.selector}`})}})});import{z as pr}from"zod";var Vs,fr,mr=f(()=>{"use strict";P();Vs=pr.object({selector:pr.string().describe("CSS selector for the checkbox to check")}),fr=g({description:"Check a checkbox matching the CSS selector",name:"check",schema:Vs,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).check({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"check"};return w({assertions:[],detail:`Checked ${t.selector}`,duration:performance.now()-o,nodeType:"check",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Check ${t.selector}`})}})});import{z as gr}from"zod";var Ds,yr,hr=f(()=>{"use strict";P();Ds=gr.object({selector:gr.string().describe("CSS selector for the input to clear")}),yr=g({description:"Clear the contents of an input field",name:"clear",schema:Ds,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).clear({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"clear"};return w({assertions:[],detail:`Cleared ${t.selector}`,duration:performance.now()-o,nodeType:"clear",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Clear ${t.selector}`})}})});import{z as wr}from"zod";var Os,Sr,br=f(()=>{"use strict";P();Os=wr.object({selector:wr.string().describe("CSS selector for the element to click")}),Sr=g({description:"Click an element matching the CSS selector",name:"click",schema:Os,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).click({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"click"};return w({assertions:[],detail:`Clicked ${t.selector}`,duration:performance.now()-o,nodeType:"click",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Click ${t.selector}`})}})});import{z as It}from"zod";var Fs,Pr,Rr=f(()=>{"use strict";P();Fs=It.object({action:It.enum(["read","write"]).describe("Whether to read from or write to the clipboard"),value:It.string().optional().describe("Text to write (required for write action)")}),Pr=g({description:"Read from or write to the browser clipboard. For write, provide the text value. For read, the clipboard contents are returned.",name:"clipboard",schema:Fs,execute:async(e,t)=>{let o=performance.now(),r=`agent-step-${String(e.stepIndex)}`;if(t.action==="write"){if(t.value==null)throw new Error("clipboard write requires a value");let s=JSON.stringify(t.value);await e.page.evaluate(`navigator.clipboard.writeText(${s})`);let i={action:"write",id:r,type:"clipboard",value:{type:"static",value:t.value}};return w({assertions:[],detail:`Wrote to clipboard: "${t.value}"`,duration:performance.now()-o,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:i,status:"passed",stepIndex:e.stepIndex,title:"Clipboard write"})}let n=String(await e.page.evaluate("navigator.clipboard.readText()")),a={action:"read",id:r,type:"clipboard"};return w({assertions:[],detail:`Clipboard contents: "${n}"`,duration:performance.now()-o,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:a,status:"passed",stepIndex:e.stepIndex,title:"Clipboard read"})}})});import{z as _e}from"zod";var xr,vr,kr=f(()=>{"use strict";xr=_e.object({summary:_e.string().describe("This is the ONLY output the user sees. If the agent profile specifies an Output format, follow those instructions exactly. Otherwise, provide a summary of your findings."),verdict:_e.enum(["pass","fail"]).describe("Whether the test passed or failed. If the agent profile defines Success Criteria, base this verdict on whether those criteria were met.")}),vr={anthropicTool:{description:"Call this tool when you have finished your evaluation. If the agent profile defines an Output section, the summary MUST follow those output instructions exactly. Otherwise, summarize your findings.",input_schema:{..._e.toJSONSchema(xr,{target:"draft-2020-12"}),type:"object"},name:"complete_test"},name:"complete_test",execute(e,t){let o=xr.parse(t),r={kind:"verdict",summary:o.summary,toolOutput:`Verdict: ${o.verdict}
|
|
4
|
+
${o.summary}`,verdict:o.verdict};return Promise.resolve(r)}}});import{z as Tr}from"zod";var Us,Cr,Nr=f(()=>{"use strict";P();Us=Tr.object({selector:Tr.string().describe("CSS selector for the element to extract text from")}),Cr=g({description:"Extract the text content of an element matching the CSS selector. Returns the text so you can use it in assertions or decisions.",name:"extract_text",schema:Us,execute:async(e,t)=>{let o=performance.now(),n=await e.page.locator(t.selector).textContent({timeout:5e3})??"",s={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"extractText",variable:"extractedText"};return w({assertions:[],detail:`Extracted text: "${n}"`,duration:performance.now()-o,nodeType:"extractText",page:e.page,runStartTime:e.runStartTime,specNode:s,status:"passed",stepIndex:e.stepIndex,title:`Extract text from ${t.selector}`})}})});import{z as jt}from"zod";var Ws,Ir,jr=f(()=>{"use strict";P();Ws=jt.object({selector:jt.string().describe("CSS selector for the input element"),value:jt.string().describe("The text to type into the element")}),Ir=g({description:"Clear and type text into an input element matching the CSS selector",name:"fill",schema:Ws,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).fill(t.value,{timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"fill",value:{type:"static",value:t.value}};return w({assertions:[],detail:`Filled ${t.selector} with "${t.value}"`,duration:performance.now()-o,nodeType:"fill",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Fill ${t.selector}`})}})});import{z as Ar}from"zod";function qs(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}var Ls,$r,Er=f(()=>{"use strict";P();Ls=Ar.object({level:Ar.string().describe("Filter by log level: 'error', 'warning', 'log', 'info', 'debug', or 'all'").default("all")}),$r=g({description:"Get console log messages from the browser. Optionally filter by level (error, warning, log, info, debug, all).",name:"get_console_logs",schema:Ls,execute:(e,t)=>{let o=t.level==="all"?e.monitor.consoleEntries:e.monitor.consoleEntries.filter(n=>n.level===t.level);if(o.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console ${t.level==="all"?"messages":t.level+" messages"} recorded.`};let r=o.map(n=>qs(n)).join(`
|
|
5
5
|
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(o.length)} console messages:
|
|
6
|
-
${r}`}}})});import{z as Vr}from"zod";var At,
|
|
6
|
+
${r}`}}})});import{z as Vr}from"zod";var At,zs,Dr,Or=f(()=>{"use strict";P();At=50,zs=Vr.object({urlFilter:Vr.string().describe("Optional regex to filter network entries by URL. Omit to see all.").default("")}),Dr=g({description:"Get a summary of network requests/responses. Shows method, URL, status code, and content type. Optionally filter by URL regex.",name:"get_network_log",schema:zs,execute:(e,t)=>{let o=t.urlFilter.length>0?new RegExp(t.urlFilter,"i"):void 0,r=o==null?e.monitor.networkEntries:e.monitor.networkEntries.filter(i=>o.test(i.url));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No network requests recorded."};let n=r.slice(-At),a=n.map(i=>{let l=i.statusCode==null?"pending":String(i.statusCode),d=i.responseHeaders["content-type"]??"";return`${i.method} ${l} ${i.url} [${d}]`}).join(`
|
|
7
7
|
`),s=r.length>At?`
|
|
8
8
|
(showing last ${String(At)} of ${String(r.length)})`:"";return{specNode:void 0,stepResult:void 0,toolOutput:`${String(n.length)} network requests:${s}
|
|
9
|
-
${a}`}}})});import{z as Fr}from"zod";var
|
|
9
|
+
${a}`}}})});import{z as Fr}from"zod";var Bs,Ur,Wr=f(()=>{"use strict";P();Bs=Fr.object({urlPattern:Fr.string().describe("Regex pattern to match the request URL")}),Ur=g({description:"Get the full response body for a specific network request matching the URL pattern. Returns the most recent match.",name:"get_network_response",schema:Bs,execute:(e,t)=>{let o=new RegExp(t.urlPattern,"i"),r=e.monitor.networkEntries.filter(l=>o.test(l.url));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let n=r.at(-1);if(n==null)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let a=n.statusCode==null?"pending":String(n.statusCode),s=Object.entries(n.responseHeaders).map(([l,d])=>` ${l}: ${d}`).join(`
|
|
10
10
|
`),i=n.responseBody??"(no body captured)";return{specNode:void 0,stepResult:void 0,toolOutput:`${n.method} ${a} ${n.url}
|
|
11
11
|
|
|
12
12
|
Response Headers:
|
|
13
13
|
${s}
|
|
14
14
|
|
|
15
15
|
Body:
|
|
16
|
-
${i}`}}})});import{z as Lr}from"zod";var
|
|
16
|
+
${i}`}}})});import{z as Lr}from"zod";var Ms,qr,zr=f(()=>{"use strict";P();Ms=Lr.object({selector:Lr.string().optional().describe("CSS selector to scope the tree to a subtree (defaults to full page)")}),qr=g({description:"Get the accessibility tree (ARIA snapshot) of the current page or a specific element. Use this to verify ARIA roles, labels, states, and the semantic structure of the page.",name:"get_accessibility_tree",schema:Ms,execute:async(e,t)=>{let o=t.selector==null?e.page.locator(":root"):e.page.locator(t.selector);try{return{specNode:void 0,stepResult:void 0,toolOutput:await o.ariaSnapshot()}}catch{return{specNode:void 0,stepResult:void 0,toolOutput:"(unable to capture accessibility tree)"}}}})});import{z as _s}from"zod";var Gs,Br,Mr=f(()=>{"use strict";P();Gs=_s.object({}),Br=g({description:"Get a text representation of the current page content for inspection",name:"get_page_content",schema:Gs,execute:async(e,t)=>{let o=await e.page.locator("body").textContent({timeout:5e3}),r=e.page.url(),n=await e.page.title();return{specNode:void 0,stepResult:void 0,toolOutput:`URL: ${r}
|
|
17
17
|
Title: ${n}
|
|
18
18
|
|
|
19
|
-
${o??""}`}}})});import{z as
|
|
19
|
+
${o??""}`}}})});import{z as Hs}from"zod";var Js,_r,Gr=f(()=>{"use strict";P();Js=Hs.object({}),_r=g({description:"Get uncaught JavaScript exceptions (page errors) that have occurred. These are runtime errors thrown in the browser that were not caught by error handlers.",name:"get_page_errors",schema:Js,execute:(e,t)=>{if(e.monitor.pageErrors.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No page errors recorded."};let o=e.monitor.pageErrors.map((r,n)=>`--- Error ${String(n+1)} ---
|
|
20
20
|
${r}`).join(`
|
|
21
21
|
|
|
22
22
|
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(e.monitor.pageErrors.length)} page errors:
|
|
23
23
|
|
|
24
|
-
${o}`}}})});import{z as Hr}from"zod";async function
|
|
24
|
+
${o}`}}})});import{z as Hr}from"zod";async function Ks(e){let t=await e.context().cookies();if(t.length===0)return`## Cookies
|
|
25
25
|
(none)`;let o=t.map(r=>` ${r.name}=${r.value} (domain=${r.domain}, httpOnly=${String(r.httpOnly)}, secure=${String(r.secure)}, sameSite=${r.sameSite})`);return`## Cookies (${String(t.length)})
|
|
26
26
|
${o.join(`
|
|
27
27
|
`)}`}async function Jr(e,t){let o=await e.evaluate(`JSON.stringify(Object.fromEntries(Object.entries(${t})))`);return`## ${t}
|
|
28
|
-
${String(o)}`}var
|
|
28
|
+
${String(o)}`}var Ys,Yr,Kr=f(()=>{"use strict";P();Ys=Hr.object({type:Hr.enum(["all","cookies","localStorage","sessionStorage"]).describe("Which storage to retrieve").default("all")}),Yr=g({description:"Get browser storage state: cookies (with httpOnly, secure, sameSite flags), localStorage, and/or sessionStorage. Useful for verifying authentication state, security cookie flags, and stored data.",name:"get_storage",schema:Ys,execute:async(e,t)=>({specNode:void 0,stepResult:void 0,toolOutput:[...t.type==="all"||t.type==="cookies"?[await Ks(e.page)]:[],...t.type==="all"||t.type==="localStorage"?[await Jr(e.page,"localStorage")]:[],...t.type==="all"||t.type==="sessionStorage"?[await Jr(e.page,"sessionStorage")]:[]].join(`
|
|
29
29
|
|
|
30
|
-
`)})})});import{z as $t}from"zod";var
|
|
30
|
+
`)})})});import{z as $t}from"zod";var Qs,Qr,Xr=f(()=>{"use strict";P();Qs=$t.object({action:$t.enum(["accept","dismiss"]).describe("Whether to accept or dismiss the dialog"),promptText:$t.string().optional().describe("Text to enter for prompt dialogs")}),Qr=g({description:"Set up a handler for the next browser dialog (alert, confirm, prompt). Call this BEFORE the action that triggers the dialog.",name:"handle_dialog",schema:Qs,execute:(e,t)=>{let o=performance.now();e.page.once("dialog",async a=>{t.action==="accept"?await a.accept(t.promptText??void 0):await a.dismiss()});let r=`agent-step-${String(e.stepIndex)}`,n={action:t.action,id:r,type:"handleDialog"};return w({assertions:[],detail:`Dialog handler set: ${t.action}`,duration:performance.now()-o,nodeType:"handleDialog",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Handle dialog: ${t.action}`})}})});import{z as Zr}from"zod";var Xs,en,tn=f(()=>{"use strict";P();Xs=Zr.object({selector:Zr.string().describe("CSS selector for the element to hover over")}),en=g({description:"Hover over an element matching the CSS selector",name:"hover",schema:Xs,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).hover({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"hover"};return w({assertions:[],detail:`Hovered over ${t.selector}`,duration:performance.now()-o,nodeType:"hover",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Hover ${t.selector}`})}})});import{z as Et}from"zod";var Zs,on,rn=f(()=>{"use strict";P();Zs=Et.object({permission:Et.string().describe("Permission name (e.g. geolocation, notifications, camera, clipboard-read)"),state:Et.enum(["granted","prompt"]).describe("Permission state to set")}),on=g({description:"Set a browser permission state (geolocation, notifications, camera, etc.)",name:"set_permission",schema:Zs,execute:async(e,t)=>{let o=performance.now(),r=e.page.context();t.state==="granted"?await r.grantPermissions([t.permission]):await r.clearPermissions();let a={id:`agent-step-${String(e.stepIndex)}`,permission:t.permission,state:t.state,type:"setPermission"};return w({assertions:[],detail:`Set ${t.permission} to ${t.state}`,duration:performance.now()-o,nodeType:"setPermission",page:e.page,runStartTime:e.runStartTime,specNode:a,status:"passed",stepIndex:e.stepIndex,title:`Set permission: ${t.permission} \u2192 ${t.state}`})}})});import{z as nn}from"zod";var ei,an,sn=f(()=>{"use strict";P();ei=nn.object({url:nn.string().describe("The URL to navigate to")}),an=g({description:"Navigate the browser to a URL",name:"navigate",schema:ei,execute:async(e,t)=>{let o=performance.now();await e.page.goto(t.url,{waitUntil:"domcontentloaded"});let n={id:`agent-step-${String(e.stepIndex)}`,type:"goto",url:{type:"static",value:t.url}};return w({assertions:[],detail:`Navigated to ${t.url}`,duration:performance.now()-o,nodeType:"goto",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Navigate to ${t.url}`})}})});import{z as ln}from"zod";var ti,cn,dn=f(()=>{"use strict";P();ti=ln.object({key:ln.string().describe("Key to press, e.g. 'Enter', 'Tab', 'Escape'")}),cn=g({description:"Press a keyboard key",name:"press",schema:ti,execute:async(e,t)=>{let o=performance.now();await e.page.keyboard.press(t.key);let n={id:`agent-step-${String(e.stepIndex)}`,key:t.key,type:"press"};return w({assertions:[],detail:`Pressed ${t.key}`,duration:performance.now()-o,nodeType:"press",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Press ${t.key}`})}})});import{z as Vt}from"zod";var oi,un,pn=f(()=>{"use strict";P();oi=Vt.object({height:Vt.number().int().positive().describe("Viewport height in pixels"),width:Vt.number().int().positive().describe("Viewport width in pixels")}),un=g({description:"Resize the browser viewport to the specified dimensions. Use this to test responsive layouts at different screen sizes (e.g. mobile: 375x812, tablet: 768x1024, desktop: 1440x900).",name:"resize_viewport",schema:oi,execute:async(e,t)=>{let o=performance.now();await e.page.setViewportSize({height:t.height,width:t.width});let r=`agent-step-${String(e.stepIndex)}`,n={height:t.height,id:r,type:"setViewport",width:t.width};return w({assertions:[],detail:`Resized viewport to ${String(t.width)}x${String(t.height)}`,duration:performance.now()-o,nodeType:"setViewport",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Resize viewport to ${String(t.width)}x${String(t.height)}`})}})});import{z as fn}from"zod";var ri,mn,gn=f(()=>{"use strict";P();ri=fn.object({selector:fn.string().describe("CSS selector for the element to right-click")}),mn=g({description:"Right-click an element to open the context menu",name:"right_click",schema:ri,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).click({button:"right",timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"rightClick"};return w({assertions:[],detail:`Right-clicked ${t.selector}`,duration:performance.now()-o,nodeType:"rightClick",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Right-click ${t.selector}`})}})});import{z as Ge}from"zod";var ni,yn,hn=f(()=>{"use strict";P();ni=Ge.object({selector:Ge.string().optional().describe("CSS selector to scroll within (omit to scroll the page)"),x:Ge.number().int().optional().describe("Horizontal scroll offset in pixels").default(0),y:Ge.number().int().optional().describe("Vertical scroll offset in pixels").default(0)}),yn=g({description:"Scroll the page or a specific element by pixel offset. Positive y scrolls down, negative scrolls up.",name:"scroll",schema:ni,execute:async(e,t)=>{let o=performance.now();if(t.selector==null)await e.page.mouse.wheel(t.x,t.y);else{let s=await e.page.locator(t.selector).elementHandle();if(s==null)throw new Error("Scroll target element not found");await s.evaluate(`(el) => el.scrollBy(${String(t.x)}, ${String(t.y)})`)}let n={id:`agent-step-${String(e.stepIndex)}`,type:"scroll",x:t.x,y:t.y},a=t.selector??"page";return w({assertions:[],detail:`Scrolled ${a} by (${String(t.x)}, ${String(t.y)})`,duration:performance.now()-o,nodeType:"scroll",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Scroll ${a}`})}})});import{z as ai}from"zod";var si,wn,Sn=f(()=>{"use strict";P();si=ai.object({}),wn=g({description:"Take a screenshot of the current page",name:"screenshot",schema:si,execute:async(e,t)=>{let o=performance.now(),n={id:`agent-step-${String(e.stepIndex)}`,type:"screenshot"};return w({assertions:[],detail:"Screenshot captured",duration:performance.now()-o,nodeType:"screenshot",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:"Screenshot"})}})});import{z as bn}from"zod";function li(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}var ii,Pn,Rn=f(()=>{"use strict";P();ii=bn.object({pattern:bn.string().describe("Regex pattern to search console log messages")}),Pn=g({description:"Search console log messages for a regex pattern. Returns matching entries.",name:"search_console",schema:ii,execute:(e,t)=>{let o=new RegExp(t.pattern,"i"),r=e.monitor.consoleEntries.filter(a=>o.test(a.text));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console messages matching: ${t.pattern}`};let n=r.map(a=>li(a)).join(`
|
|
31
31
|
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(r.length)} matching console messages:
|
|
32
|
-
${n}`}}})});import{z as xn}from"zod";var
|
|
32
|
+
${n}`}}})});import{z as xn}from"zod";var ci,vn,kn=f(()=>{"use strict";P();ci=xn.object({pattern:xn.string().describe("Regex pattern to search across network request URLs and response bodies")}),vn=g({description:"Search network requests and response bodies for a regex pattern. Useful for finding API calls, tokens, or specific data in responses.",name:"search_network",schema:ci,execute:(e,t)=>{let o=new RegExp(t.pattern,"i"),r=e.monitor.networkEntries.filter(a=>o.test(a.url)||a.responseBody!=null&&o.test(a.responseBody));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network entries matching: ${t.pattern}`};let n=r.map(a=>{let s=a.statusCode==null?"pending":String(a.statusCode),i=o.test(a.url)?" [URL match]":"",l=a.responseBody!=null&&o.test(a.responseBody)?" [body match]":"";return`${a.method} ${s} ${a.url}${i}${l}`}).join(`
|
|
33
33
|
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(r.length)} matching network entries:
|
|
34
|
-
${n}`}}})});import{z as Tn}from"zod";function
|
|
35
|
-
`);a.push(p)}),a}var
|
|
36
|
-
`),n=
|
|
34
|
+
${n}`}}})});import{z as Tn}from"zod";function fi({contextLines:e,lines:t,maxResults:o,pattern:r}){let n=new RegExp(r,"i"),a=[];return t.forEach((s,i)=>{if(a.length>=o||!n.test(s))return;let l=Math.max(0,i-e),d=Math.min(t.length-1,i+e),p=t.slice(l,d+1).map((m,y)=>{let h=l+y+1;return`${l+y===i?">":" "} ${String(h)}: ${m}`}).join(`
|
|
35
|
+
`);a.push(p)}),a}var di,ui,pi,Cn,Nn=f(()=>{"use strict";P();di=20,ui=2,pi=Tn.object({pattern:Tn.string().describe("Regex pattern to search for in the page HTML")}),Cn=g({description:"Search the current page's full HTML/DOM for a regex pattern. Returns matching lines with context. Useful for finding elements, attributes, text content, or hidden data without reading the entire page.",name:"search_page",schema:pi,execute:async(e,t)=>{let r=(await e.page.content()).split(`
|
|
36
|
+
`),n=fi({contextLines:ui,lines:r,maxResults:di,pattern:t.pattern});return n.length===0?{specNode:void 0,stepResult:void 0,toolOutput:`No matches found for pattern: ${t.pattern}`}:{specNode:void 0,stepResult:void 0,toolOutput:n.join(`
|
|
37
37
|
---
|
|
38
|
-
`)}}})});import{z as Dt}from"zod";var
|
|
39
|
-
${m.stack??""}`)}function d(m){let y=m.failure(),h=new He(m);h.responseBody=`(request failed: ${y?.errorText??"unknown"})`,o.push(h)}e.on("console",a),e.on("request",s),e.on("response",i),e.on("pageerror",l),e.on("requestfailed",d);function p(){e.off("console",a),e.off("request",s),e.off("response",i),e.off("pageerror",l),e.off("requestfailed",d)}return{consoleEntries:t,detach:p,networkEntries:o,pageErrors:r}}var He,Ft=f(()=>{"use strict";He=class{method;requestHeaders;requestPostData;timestamp;url;responseBody=void 0;responseHeaders={};statusCode=void 0;constructor(t){this.method=t.method(),this.requestHeaders=t.headers(),this.requestPostData=t.postData()??void 0,this.timestamp=Date.now(),this.url=t.url()}applyResponse(t){this.statusCode=t.status(),this.responseHeaders=t.headers(),t.text().then(o=>{this.responseBody=o.length>1e5?`${o.slice(0,1e5)}... (truncated)`:o}).catch(()=>{this.responseBody="(unable to read body)"})}}});async function qn({input:e,monitor:t,name:o,page:r,runStartTime:n,stepIndex:a}){let s=
|
|
40
|
-
`)});import
|
|
38
|
+
`)}}})});import{z as Dt}from"zod";var mi,In,jn=f(()=>{"use strict";P();mi=Dt.object({selector:Dt.string().describe("CSS selector for the select element"),value:Dt.string().describe("The option value to select")}),In=g({description:"Select an option from a dropdown/select element",name:"select",schema:mi,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).selectOption(t.value,{timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"select",value:{type:"static",value:t.value}};return w({assertions:[],detail:`Selected "${t.value}" in ${t.selector}`,duration:performance.now()-o,nodeType:"select",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Select ${t.value}`})}})});import{z as An}from"zod";var gi,$n,En=f(()=>{"use strict";P();gi=An.object({selector:An.string().describe("CSS selector for the checkbox to uncheck")}),$n=g({description:"Uncheck a checkbox matching the CSS selector",name:"uncheck",schema:gi,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).uncheck({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"uncheck"};return w({assertions:[],detail:`Unchecked ${t.selector}`,duration:performance.now()-o,nodeType:"uncheck",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Uncheck ${t.selector}`})}})});import{z as Vn}from"zod";var yi,Dn,On=f(()=>{"use strict";P();yi=Vn.object({ms:Vn.number().describe("Milliseconds to wait")}),Dn=g({description:"Wait for a specified duration in milliseconds",name:"wait",schema:yi,execute:async(e,t)=>{let o=performance.now();await e.page.waitForTimeout(t.ms);let r=`agent-step-${String(e.stepIndex)}`,n={duration:t.ms,id:r,type:"wait"};return w({assertions:[],detail:`Waited ${String(t.ms)}ms`,duration:performance.now()-o,nodeType:"wait",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Wait ${String(t.ms)}ms`})}})});import{z as Ot}from"zod";var hi,Fn,Un=f(()=>{"use strict";P();hi=Ot.object({selector:Ot.string().describe("CSS selector for the element to wait for"),state:Ot.enum(["visible","hidden","attached","detached"]).default("visible").describe("The state to wait for (default: visible)")}),Fn=g({description:"Wait for an element matching the CSS selector to reach the specified state. More reliable than a blind wait \u2014 use this to wait for elements to appear, disappear, or attach/detach from the DOM.",name:"wait_for",schema:hi,execute:async(e,t)=>{let o=performance.now();await e.page.locator(t.selector).waitFor({state:t.state,timeout:15e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},state:t.state,type:"waitFor"};return w({assertions:[],detail:`Waited for ${t.selector} to be ${t.state}`,duration:performance.now()-o,nodeType:"waitFor",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Wait for ${t.selector} to be ${t.state}`})}})});function xe(e){let t=[],o=[],r=[],n=new Map;function a(m){t.push({level:m.type(),text:m.text(),timestamp:Date.now(),url:m.location().url})}function s(m){let y=new He(m);n.set(m,y),o.push(y)}function i(m){let y=n.get(m.request());y!=null&&(n.delete(m.request()),y.applyResponse(m))}function l(m){r.push(`${m.message}
|
|
39
|
+
${m.stack??""}`)}function d(m){let y=m.failure(),h=new He(m);h.responseBody=`(request failed: ${y?.errorText??"unknown"})`,o.push(h)}e.on("console",a),e.on("request",s),e.on("response",i),e.on("pageerror",l),e.on("requestfailed",d);function p(){e.off("console",a),e.off("request",s),e.off("response",i),e.off("pageerror",l),e.off("requestfailed",d)}return{consoleEntries:t,detach:p,networkEntries:o,pageErrors:r}}var He,Ft=f(()=>{"use strict";He=class{method;requestHeaders;requestPostData;timestamp;url;responseBody=void 0;responseHeaders={};statusCode=void 0;constructor(t){this.method=t.method(),this.requestHeaders=t.headers(),this.requestPostData=t.postData()??void 0,this.timestamp=Date.now(),this.url=t.url()}applyResponse(t){this.statusCode=t.status(),this.responseHeaders=t.headers(),t.text().then(o=>{this.responseBody=o.length>1e5?`${o.slice(0,1e5)}... (truncated)`:o}).catch(()=>{this.responseBody="(unable to read body)"})}}});async function qn({input:e,monitor:t,name:o,page:r,runStartTime:n,stepIndex:a}){let s=wi.get(o);if(s==null)throw new Error(`Unknown agent tool: ${o}`);return s.execute({monitor:t,page:r,runStartTime:n,stepIndex:a},e)}var Ut,wi,Wn,Ln,zn=f(()=>{"use strict";Ko();Zo();or();nr();sr();lr();ur();mr();hr();br();Rr();kr();Nr();jr();Er();Or();Wr();zr();Mr();Gr();Kr();Xr();tn();rn();sn();dn();pn();gn();hn();Sn();Rn();kn();Nn();jn();En();On();Un();Ft();Ut=[an,Sr,Ir,cn,fr,$n,In,en,Dn,Fn,wn,Br,Cn,yr,mn,yn,Qr,Pr,on,dr,ar,ir,Yo,tr,Xo,rr,$r,Dr,Ur,_r,qr,Yr,Pn,vn,un,Cr,vr],wi=new Map(Ut.map(e=>[e.name,e])),Wn=Ut.map(e=>e.anthropicTool),Ln=Ut.map(e=>`- **${e.name}**: ${e.anthropicTool.description??""}`).join(`
|
|
40
|
+
`)});import Si from"pino";function E(e){return u.fatal(e),process.exit(1)}var u,W=f(()=>{"use strict";u=Si({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}})});import bi from"@anthropic-ai/sdk";async function ve({baseUrl:e,executedPreconditions:t,extraVariables:o,onStep:r,page:n,runId:a,serverUrl:s,spec:i,systemPrompt:l,token:d,workflowContext:p}){let m=new bi({apiKey:"ripplo",baseURL:`${s}/api/proxy/anthropic`,defaultHeaders:{Authorization:`Bearer ${d}`,"x-run-id":a}}),y=performance.now(),h=xe(n);await Ci({baseUrl:e,page:n});let k=xi({extraVariables:o,spec:i}),x=vi({baseUrl:e,executedPreconditions:t,spec:i,systemPrompt:l,variables:k,workflowContext:p}),$=ki({baseUrl:e,spec:i,variables:k}),A=[{content:Ti({page:n,startUrl:$}),role:"user"}],ne=[],Se=[],be=0,Be="",z;for(let xt=0;xt<Pi;xt++){u.info("Agent iteration %d",xt+1);let as=await m.messages.create({max_tokens:Ri,messages:A,model:"server-controlled",system:x,tools:Wn}),ce=await Ni({messages:A,monitor:h,onStep:r,page:n,response:as,runStartTime:y,specNodes:Se,stepIndex:be,steps:ne});if(be=ce.nextStepIndex,ce.newFindings.length>0&&(Be=ce.newFindings),ce.verdict!=null&&(z=ce.verdict),!ce.continueLoop)break}let Rt=ji(Se);return{findings:Be,generatedSpec:Rt,monitor:h,steps:ne,verdict:z??"fail"}}function xi({extraVariables:e,spec:t}){return{...Pe({defs:t?.variables}),...e}}function vi({baseUrl:e,executedPreconditions:t,spec:o,systemPrompt:r,variables:n,workflowContext:a}){let s=a==null?"":[`
|
|
41
41
|
|
|
42
42
|
## Workflow Under Test`,`**Name:** ${a.name}`,`**Description:** ${a.description}`,`**Expected Outcome:** ${a.expectedOutcome}`,`
|
|
43
43
|
Focus your testing ONLY on this specific workflow. Do not test unrelated parts of the application.`].join(`
|
|
@@ -60,48 +60,48 @@ Do not repeat any of these steps.`,p=Object.entries(n),m=p.map(([h,k])=>`- **${h
|
|
|
60
60
|
${m}`;return[`You are testing the application at: ${e}`,"Use the provided tools to navigate, interact with, and assert things about the page.","Use get_page_content to inspect the page when you need to understand what's on screen.","Follow the workflow steps to complete the task.",`
|
|
61
61
|
## Available Tools`,Ln,s,d,i,y,`
|
|
62
62
|
## Agent Profile (HIGHEST PRIORITY \u2014 these instructions override any defaults above)`,r].join(`
|
|
63
|
-
`)}function
|
|
64
|
-
`),nextStepIndex:i,verdict:void 0};let m=[],y=i,h,k;for(let $ of p){let b=await
|
|
65
|
-
`);return{continueLoop:h==null&&n.stop_reason==="tool_use",newFindings:x,nextStepIndex:y,verdict:h}}async function
|
|
63
|
+
`)}function ki({baseUrl:e,spec:t,variables:o}){if(t==null)return e;let r=t.nodes[t.entryNode];if(r==null||r.type!=="goto"||r.url.type!=="static")return e;let a=r.url.value.replaceAll(/\{\{(\w+)\}\}/g,(s,i)=>{let l=o[i];return l==null?`{{${i}}}`:String(l)});return a.startsWith("http")?a:`${e}${a.startsWith("/")?"":"/"}${a}`}function Ti({page:e,startUrl:t}){let o=e.url();return o!=="about:blank"&&o.length>0?`You are already on the page at ${o}. Begin testing from this page \u2014 do not navigate away unless the workflow requires it.`:`Navigate to ${t} and begin testing.`}async function Ci({baseUrl:e,page:t}){let o=new URL(e).origin;await t.route("**/*",r=>{let n=r.request();return n.isNavigationRequest()&&new URL(n.url()).origin!==o?(u.warn("Blocked navigation to off-origin URL: %s",n.url()),r.abort("blockedbyclient")):r.continue()})}async function Ni({messages:e,monitor:t,onStep:o,page:r,response:n,runStartTime:a,specNodes:s,stepIndex:i,steps:l}){let d=n.content.filter($=>$.type==="text").map($=>$.text),p=n.content.filter($=>$.type==="tool_use");if(p.length===0)return{continueLoop:!1,newFindings:d.join(`
|
|
64
|
+
`),nextStepIndex:i,verdict:void 0};let m=[],y=i,h,k;for(let $ of p){let b=await Ii({block:$,monitor:t,onStep:o,page:r,runStartTime:a,specNodes:s,stepIndex:y,steps:l});m.push(b.toolResult),y=b.nextStepIndex,b.verdict!=null&&(h=b.verdict,k=b.summary)}e.push({content:n.content,role:"assistant"},{content:m,role:"user"});let x=k??d.join(`
|
|
65
|
+
`);return{continueLoop:h==null&&n.stop_reason==="tool_use",newFindings:x,nextStepIndex:y,verdict:h}}async function Ii({block:e,monitor:t,onStep:o,page:r,runStartTime:n,specNodes:a,stepIndex:s,steps:i}){try{let l=await qn({input:e.input,monitor:t,name:e.name,page:r,runStartTime:n,stepIndex:s}),d={content:l.toolOutput,tool_use_id:e.id,type:"tool_result"};return l.kind==="verdict"?(u.info(" [%d] %s \u2014 verdict: %s",s,e.name,l.verdict),{nextStepIndex:s,summary:l.summary,toolResult:d,verdict:l.verdict}):(l.specNode!=null&&a.push(l.specNode),l.stepResult!=null?(i.push(l.stepResult),o?.(l.stepResult),u.info(" [%d] %s \u2014 %s",s,e.name,l.stepResult.status),{nextStepIndex:s+1,summary:void 0,toolResult:d,verdict:void 0}):(u.info(" [%d] %s \u2014 info",s,e.name),{nextStepIndex:s,summary:void 0,toolResult:d,verdict:void 0}))}catch(l){let d=l instanceof Error?l.message:"Unknown error";u.error(" [%d] %s \u2014 error: %s",s,e.name,d);let p=await ee({page:r,runStartTime:n,targets:[]}),m={annotations:p.annotations,assertions:[],detail:`Error: ${d}`,duration:0,nodeId:`agent-step-${String(s)}`,nodeType:"click",screenshotBase64:p.screenshotBase64,snapshotTimestamp:p.snapshotTimestamp,status:"failed",stepIndex:s,title:`${e.name} (error)`,url:p.url,viewportHeight:p.viewportHeight,viewportWidth:p.viewportWidth};return i.push(m),o?.(m),{nextStepIndex:s+1,summary:void 0,toolResult:{content:`Error: ${d}`,is_error:!0,tool_use_id:e.id,type:"tool_result"},verdict:void 0}}}function ji(e){if(e.length===0)return{entryNode:"",nodes:{},version:2};let t={};e.forEach((r,n)=>{let a=e[n+1],s=a==null?r:{...r,next:a.id};t[r.id]=s});let o=e[0];if(o==null)throw new Error("Expected at least one spec node after length check");return{entryNode:o.id,nodes:t,version:2}}var Pi,Ri,Wt=f(()=>{"use strict";zn();W();Re();G();Pi=50,Ri=16384});function ke({description:e,output:t,successCriteria:o}){let r=[`## Agent Identity
|
|
66
66
|
${e}`];t!=null&&t.length>0&&r.push(`## Output
|
|
67
67
|
${t}`),o!=null&&o.length>0&&r.push(`## Success Criteria
|
|
68
|
-
${o}`);let n=["## Completing Your Evaluation",'When you finish your evaluation, you MUST call the `complete_test` tool with your verdict ("pass" or "fail") and a `summary` string.',
|
|
68
|
+
${o}`);let n=["## Completing Your Evaluation",'When you finish your evaluation, you MUST call the `complete_test` tool with your verdict ("pass" or "fail") and a `summary` string.',Ai({hasSuccessCriteria:o!=null&&o.length>0}),$i({hasOutput:t!=null&&t.length>0})];return r.push(n.join(`
|
|
69
69
|
`)),r.join(`
|
|
70
70
|
|
|
71
|
-
`)}function
|
|
71
|
+
`)}function Ai({hasSuccessCriteria:e}){return e?"Base your verdict strictly on the Success Criteria defined above. A test passes ONLY if all success criteria are met, and fails if any criterion is not met. Individual step failures during exploration do not necessarily mean the test failed, but the success criteria are the ultimate authority for your verdict.":"Base your verdict on whether the workflow worked correctly. Individual step failures during exploration do not necessarily mean the test failed."}function $i({hasOutput:e}){return e?'The `summary` parameter is the ONLY output the user will see. You MUST use the `summary` field for EXACTLY the output described in the "Output" section above \u2014 nothing else. Do not describe what you did, do not list steps, do not add a test summary. The `summary` must contain ONLY what the Output section asks for, word for word if it specifies exact text.':"Include a brief summary of what you found in the `summary` parameter."}var Lt=f(()=>{"use strict"});import{execFileSync as Ei}from"child_process";import{createRequire as Vi}from"module";import Bn from"fs";import Mn from"path";import{chromium as qt}from"playwright";async function K({headed:e}){u.info("Browser executable: %s",qt.executablePath());try{return await qt.launch({headless:!e})}catch(t){throw Di(t)?new Error(`Playwright browsers are not installed. Run:
|
|
72
72
|
|
|
73
73
|
npx playwright install chromium
|
|
74
|
-
`):t}}function zt(){let e=qt.executablePath();if(Bn.existsSync(e))return;u.info("Chromium not found. Installing via Playwright...");let
|
|
74
|
+
`):t}}function zt(){let e=qt.executablePath();if(Bn.existsSync(e))return;u.info("Chromium not found. Installing via Playwright...");let t=Vi(import.meta.url),o=Mn.dirname(t.resolve("playwright/package.json")),r=Mn.join(o,"cli.js");if(Ei(process.execPath,[r,"install","chromium"],{stdio:"inherit"}),!Bn.existsSync(e))throw new Error(`Playwright browser installation failed. Try running manually:
|
|
75
75
|
|
|
76
76
|
npx playwright install chromium
|
|
77
|
-
`);u.info("\u2713 Chromium installed")}function
|
|
77
|
+
`);u.info("\u2713 Chromium installed")}function Di(e){return e instanceof Error?e.message.includes("Executable doesn't exist"):!1}var Je=f(()=>{"use strict";W()});import{mkdir as Bt,writeFile as _}from"fs/promises";import F from"path";async function Ye({context:e,page:t,runId:o,stepIndex:r,stepResult:n}){try{let a=F.join(process.cwd(),".ripplo","debug",o,"steps",String(r));await Bt(a,{recursive:!0});let s={annotations:n.annotations,assertions:n.assertions,detail:n.detail,duration:n.duration,nodeId:n.nodeId,nodeType:n.nodeType,snapshotTimestamp:n.snapshotTimestamp,status:n.status,stepIndex:n.stepIndex,title:n.title,url:n.url,viewportHeight:n.viewportHeight,viewportWidth:n.viewportWidth};await Promise.all([_(F.join(a,"info.json"),JSON.stringify(s,null,2)),_(F.join(a,"screenshot.png"),Buffer.from(n.screenshotBase64,"base64")),Oi({context:e,page:t,stepDir:a})])}catch(a){let s=a instanceof Error?a.message:String(a);u.warn("Failed to write step debug data for step %d: %s",r,s)}}async function Oi({context:e,page:t,stepDir:o}){let[r,n,a]=await Promise.all([t.content().catch(()=>"(unable to capture DOM)"),Fi(t),Ui({context:e,page:t})]);await Promise.all([_(F.join(o,"dom.html"),r),_(F.join(o,"accessibility-tree.txt"),n),_(F.join(o,"storage.json"),JSON.stringify(a,null,2))])}async function Fi(e){try{return await e.locator(":root").ariaSnapshot()}catch{return"(unable to capture accessibility tree)"}}async function Ui({context:e,page:t}){let[o,r]=await Promise.all([t.evaluate(()=>({localStorage:Object.fromEntries(Array.from({length:localStorage.length},(n,a)=>{let s=localStorage.key(a);return s==null?void 0:[s,localStorage.getItem(s)??""]}).filter(n=>n!=null)),sessionStorage:Object.fromEntries(Array.from({length:sessionStorage.length},(n,a)=>{let s=sessionStorage.key(a);return s==null?void 0:[s,sessionStorage.getItem(s)??""]}).filter(n=>n!=null))})).catch(()=>({localStorage:{},sessionStorage:{}})),e.cookies().catch(()=>[])]);return{cookies:r,localStorage:o.localStorage,sessionStorage:o.sessionStorage}}async function Ke({monitor:e,runId:t,steps:o,summary:r}){try{let n=F.join(process.cwd(),".ripplo","debug",t);await Bt(n,{recursive:!0}),await Promise.all([_(F.join(n,"summary.txt"),Wi({steps:o,summary:r})),_(F.join(n,"console.log"),Li(e.consoleEntries)),_(F.join(n,"network.jsonl"),qi(e.networkEntries)),_(F.join(n,"page-errors.log"),e.pageErrors.join(`
|
|
78
78
|
---
|
|
79
|
-
`))]),u.info("Debug artifacts written to .ripplo/debug/%s/",t)}catch(n){let a=n instanceof Error?n.message:String(n);u.warn("Failed to write run debug summary: %s",a)}}function
|
|
80
|
-
`)}function
|
|
81
|
-
`)}function
|
|
82
|
-
`)}async function
|
|
79
|
+
`))]),u.info("Debug artifacts written to .ripplo/debug/%s/",t)}catch(n){let a=n instanceof Error?n.message:String(n);u.warn("Failed to write run debug summary: %s",a)}}function Wi({steps:e,summary:t}){return[`Run ID: ${t.runId}`,`Workflow: ${t.workflowName}`,`Status: ${t.status}`,`Duration: ${String(t.duration)}ms`,`Passed: ${String(t.passCount)}`,`Failed: ${String(t.failCount)}`,"","Steps:",...e.map(r=>` [${String(r.stepIndex)}] ${r.status==="passed"?"\u2713":"\u2717"} ${r.title} (${String(r.duration)}ms) \u2014 ${r.detail??"ok"}`)].join(`
|
|
80
|
+
`)}function Li(e){return e.map(t=>`[${new Date(t.timestamp).toISOString()}] [${t.level.toUpperCase()}] (${t.url}) ${t.text}`).join(`
|
|
81
|
+
`)}function qi(e){return e.map(t=>JSON.stringify(t)).join(`
|
|
82
|
+
`)}async function _n({error:e,runId:t,stack:o,workflowName:r}){try{let n=F.join(process.cwd(),".ripplo","debug",t);await Bt(n,{recursive:!0});let a=o==null?e:`${e}
|
|
83
83
|
|
|
84
84
|
${o}`,s=[`Run ID: ${t}`,`Workflow: ${r}`,"Status: failed","",`Error: ${e}`,"",o==null?"":`Stack trace:
|
|
85
85
|
${o}`].join(`
|
|
86
86
|
`);await Promise.all([_(F.join(n,"error.txt"),a),_(F.join(n,"summary.txt"),s)]),u.info("Debug error artifacts written to .ripplo/debug/%s/",t)}catch(n){let a=n instanceof Error?n.message:String(n);u.warn("Failed to write error debug artifacts: %s",a)}}var Qe=f(()=>{"use strict";W()});async function Mt({baseUrl:e,cookies:t,executedPreconditions:o,extraVariables:r,headed:n,navigateTo:a,runId:s,serverUrl:i,spec:l,streaming:d,systemPrompt:p,token:m,workflowContext:y}){let h=await K({headed:n}),k=await h.newContext({baseURL:e});t.length>0&&(await k.addCookies([...t]),u.info("Injected %d cookies from preconditions",t.length));let x=await k.newPage();a!=null&&(u.info("Navigating to precondition start page: %s",a),await x.goto(a,{waitUntil:"domcontentloaded"}));try{let b=function(z){d.enqueueStep(z),Ye({context:k,page:x,runId:s,stepIndex:z.stepIndex,stepResult:z})};var $=b;let A=await ve({baseUrl:e,executedPreconditions:o,extraVariables:r,onStep:b,page:x,runId:s,serverUrl:i,spec:l,systemPrompt:p,token:m,workflowContext:y}),ne=A.verdict==="pass"?"passed":"failed";await d.complete({statusOverride:ne,steps:A.steps,summary:A.findings});let Se=A.steps.filter(z=>z.status==="passed").length,be=A.steps.filter(z=>z.status==="failed").length,Be={duration:A.steps.reduce((z,Rt)=>z+Rt.duration,0),failCount:be,passCount:Se,runId:s,status:ne,workflowName:y.name};await Ke({monitor:A.monitor,runId:s,steps:A.steps,summary:Be}),u.info("Agent test complete: %d passed, %d failed",Se,be),u.info(`
|
|
87
87
|
=== Agent Summary ===
|
|
88
|
-
%s`,A.findings)}finally{await h.close()}}var _t=f(()=>{"use strict";Je();Wt();Qe();W()});async function Gt({expected:e,locator:t,operator:o,timeout:r}){let n=await t.textContent({timeout:r});return H({actual:n??"",expected:e,label:"Text",operator:o})}function Ht({expected:e,operator:t,url:o}){return H({actual:o,expected:e,label:"URL",operator:t})}async function Jt({expected:e,locator:t,operator:o}){let r=await t.count();return Xe({actual:r,expected:e,label:"Count",operator:o})}async function Yt({expected:e,locator:t,operator:o,timeout:r}){let n=await t.inputValue({timeout:r});return H({actual:n,expected:e,label:"Value",operator:o})}async function Te({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),{description:"Element is visible",detail:void 0,status:"passed"}}catch{return{description:"Element is visible",detail:"Element not visible",status:"failed"}}}async function Ce({locator:e,timeout:t}){try{return await e.waitFor({state:"hidden",timeout:t}),{description:"Element is not visible",detail:void 0,status:"passed"}}catch{return{description:"Element is not visible",detail:"Element still visible",status:"failed"}}}async function
|
|
88
|
+
%s`,A.findings)}finally{await h.close()}}var _t=f(()=>{"use strict";Je();Wt();Qe();W()});async function Gt({expected:e,locator:t,operator:o,timeout:r}){let n=await t.textContent({timeout:r});return H({actual:n??"",expected:e,label:"Text",operator:o})}function Ht({expected:e,operator:t,url:o}){return H({actual:o,expected:e,label:"URL",operator:t})}async function Jt({expected:e,locator:t,operator:o}){let r=await t.count();return Xe({actual:r,expected:e,label:"Count",operator:o})}async function Yt({expected:e,locator:t,operator:o,timeout:r}){let n=await t.inputValue({timeout:r});return H({actual:n,expected:e,label:"Value",operator:o})}async function Te({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),{description:"Element is visible",detail:void 0,status:"passed"}}catch{return{description:"Element is visible",detail:"Element not visible",status:"failed"}}}async function Ce({locator:e,timeout:t}){try{return await e.waitFor({state:"hidden",timeout:t}),{description:"Element is not visible",detail:void 0,status:"passed"}}catch{return{description:"Element is not visible",detail:"Element still visible",status:"failed"}}}async function Hn({attribute:e,expected:t,locator:o,operator:r,timeout:n}){let a=await o.getAttribute(e,{timeout:n});return H({actual:a??"",expected:t,label:`Attribute "${e}"`,operator:r})}async function Jn({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),await e.isEnabled()?{description:"Element is enabled",detail:void 0,status:"passed"}:{description:"Element is enabled",detail:"Element is disabled",status:"failed"}}catch{return{description:"Element is enabled",detail:"Element not found",status:"failed"}}}async function Yn({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),await e.isDisabled()?{description:"Element is disabled",detail:void 0,status:"passed"}:{description:"Element is disabled",detail:"Element is enabled",status:"failed"}}catch{return{description:"Element is disabled",detail:"Element not found",status:"failed"}}}function Kn({expected:e,operator:t,title:o}){return H({actual:o,expected:e,label:"Title",operator:t})}async function Qn({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),await e.isChecked()?{description:"Element is checked",detail:void 0,status:"passed"}:{description:"Element is checked",detail:"Element is not checked",status:"failed"}}catch{return{description:"Element is checked",detail:"Element not found",status:"failed"}}}async function Xn({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),await e.isChecked()?{description:"Element is not checked",detail:"Element is checked",status:"failed"}:{description:"Element is not checked",detail:void 0,status:"passed"}}catch{return{description:"Element is not checked",detail:"Element not found",status:"failed"}}}async function Zn({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),!await e.evaluate("(el) => document.activeElement === el")?{description:"Element is focused",detail:"Element is not focused",status:"failed"}:{description:"Element is focused",detail:void 0,status:"passed"}}catch{return{description:"Element is focused",detail:"Element not found",status:"failed"}}}function ea({cookies:e,expected:t}){let o=e.find(n=>n.name===t.name);if(o==null)return{description:`Cookie "${t.name}" exists`,detail:"Cookie not found",status:"failed"};let r=zi({cookie:o,expected:t});return r.length>0?{description:`Cookie "${t.name}"`,detail:r.join("; "),status:"failed"}:{description:`Cookie "${t.name}"`,detail:void 0,status:"passed"}}function zi({cookie:e,expected:t}){return[Bi({cookie:e,expected:t}),Gn("httpOnly",t.httpOnly,e.httpOnly),Gn("secure",t.secure,e.secure),Mi(t.sameSite,e.sameSite)].filter(o=>o!=null)}function Bi({cookie:e,expected:t}){if(t.value==null||t.operator==null)return;let o=H({actual:e.value,expected:t.value,label:"Value",operator:t.operator});return o.status==="failed"?o.detail??"value mismatch":void 0}function Gn(e,t,o){if(!(t==null||o===t))return`${e}: expected ${String(t)}, got ${String(o)}`}function Mi(e,t){if(!(e==null||t===e))return`sameSite: expected ${e}, got ${t}`}async function ta({bodyContains:e,headerContains:t,page:o,status:r,timeout:n,urlPattern:a}){let s=await o.waitForResponse(l=>l.url().includes(a),{timeout:n}),i=[_i(r,s.status()),await Gi(e,s),Hi(t,s.headers())].filter(l=>l!=null);return i.length===0?[{description:"Response matching "+JSON.stringify(a)+" received",detail:void 0,status:"passed"}]:i}function _i(e,t){if(e!=null)return{description:`Response status equals ${String(e)}`,detail:t===e?void 0:`Got: ${String(t)}`,status:t===e?"passed":"failed"}}async function Gi(e,t){if(e==null)return;let r=(await t.text()).includes(e);return{description:`Response body contains "${e}"`,detail:r?void 0:"Not found in response body",status:r?"passed":"failed"}}function Hi(e,t){if(e==null)return;let o=t[e.name.toLowerCase()],r=o!=null&&o.includes(e.value);return{description:`Response header "${e.name}" contains "${e.value}"`,detail:r?void 0:`Got: "${o??"(missing)"}"`,status:r?"passed":"failed"}}function H(e){let t=`${e.label} ${e.operator} "${e.expected}"`,o=Ji(e),r=o?void 0:`Got: "${e.actual}"`;return{description:t,detail:r,status:o?"passed":"failed"}}function Ji({actual:e,expected:t,operator:o}){return o==="equals"?e===t:o==="notEquals"?e!==t:o==="contains"?e.includes(t):o==="startsWith"?e.startsWith(t):o==="endsWith"?e.endsWith(t):new RegExp(t).test(e)}function Xe(e){let t=`${e.label} ${e.operator} ${String(e.expected)}`,o=Yi(e),r=o?void 0:`Got: ${String(e.actual)}`;return{description:t,detail:r,status:o?"passed":"failed"}}function Yi({actual:e,expected:t,operator:o}){return o==="equals"?e===t:o==="notEquals"?e!==t:o==="greaterThan"?e>t:o==="greaterThanOrEqual"?e>=t:o==="lessThan"?e<t:e<=t}var Ne=f(()=>{"use strict"});import{print as Ki}from"graphql";async function C(e){let t=Ki(e.document),o=JSON.stringify({query:t,variables:e.variables}),n=await(await fetch(`${e.config.ripploServerUrl}/graphql`,{body:o,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST"})).json();if(!Qi(n))throw new Error("Invalid GraphQL response");if(Xi(n))throw new Error(n.errors.map(a=>a.message).join(", "));if(n.data==null)throw new Error("No data returned from server");return n.data}function Qi(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function Xi(e){return Array.isArray(e.errors)&&e.errors.length>0}var Ie=f(()=>{"use strict"});import{readdir as Zi,rm as el,stat as tl}from"fs/promises";import na from"path";import{graphql as ol}from"gql.tada";async function je({maxRuns:e}){try{let o=(await Zi(oa,{withFileTypes:!0})).filter(d=>d.isDirectory()),r=Date.now(),n=await Promise.all(o.map(async d=>{let p=na.join(oa,d.name),m=await tl(p);return{dirPath:p,mtime:m.mtimeMs}})),a=n.filter(d=>r-d.mtime>ra),i=n.filter(d=>r-d.mtime<=ra).toSorted((d,p)=>p.mtime-d.mtime).slice(e),l=[...a,...i];if(l.length===0)return;await Promise.allSettled(l.map(d=>el(d.dirPath,{force:!0,recursive:!0}))),u.info("Pruned %d old debug run(s)",l.length)}catch{u.warn("Debug run pruning failed, ignoring")}}var oa,ra,$g,aa=f(()=>{"use strict";Ie();W();oa=na.join(process.cwd(),".ripplo","debug"),ra=360*60*1e3,$g=ol(`
|
|
89
89
|
mutation RevokeCurrentCliToken {
|
|
90
90
|
revokeCurrentCliToken
|
|
91
91
|
}
|
|
92
|
-
`)});async function Kt({condition:e,page:t,timeout:o,variables:r}){switch(e.type){case"elementVisible":return(await Te({locator:v({locator:e.locator,page:t}),timeout:o})).status==="passed";case"elementNotVisible":return(await Ce({locator:v({locator:e.locator,page:t}),timeout:o})).status==="passed";case"urlMatch":{let n=T({ref:e.expected,variables:r});return H({actual:t.url(),expected:n,label:"URL",operator:e.operator}).status==="passed"}case"textMatch":{let a=await v({locator:e.locator,page:t}).textContent({timeout:o}),s=T({ref:e.expected,variables:r});return H({actual:a??"",expected:s,label:"Text",operator:e.operator}).status==="passed"}case"variableCompare":{let n=r[e.variable];if(n==null)throw new Error(`Variable "${e.variable}" is not defined`);let a=typeof n=="number"?n:Number(n),s=ae({ref:e.expected,variables:r}),i=typeof s=="number"?s:Number(s);return Xe({actual:a,expected:i,label:e.variable,operator:e.operator}).status==="passed"}}}var Qt=f(()=>{"use strict";Ne();Z();G()});import pe from"fs";import Xt from"path";import{z as te}from"zod";function
|
|
93
|
-
`),pe.writeFileSync(
|
|
94
|
-
`)}var ol,rl,nl,Ze,sa,ia,la=f(()=>{"use strict";ol=te.object({baseUrl:te.string().optional(),cloudBaseUrl:te.string(),preconditionApiPath:te.string().optional(),projectId:te.string()}),rl=te.object({ripploServerUrl:te.string(),token:te.string()}),nl=ol.extend(rl.shape),Ze=Xt.join(process.cwd(),".ripplo"),sa=Xt.join(Ze,"settings.json"),ia=Xt.join(Ze,"settings.local.json")});async function Zt({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){let d=await Kt({condition:o.condition,page:r,timeout:s,variables:i})?o.consequent:o.alternate??[];return d.length===0?{steps:[],variables:i}:e({failFast:t,nodeIds:d,page:r,spec:n,startIndex:a,timeout:s,variables:i})}async function eo({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){let l=[],d=i;for(let p=0;p<o.times;p++){o.iteratorVar!=null&&(d=Y({name:o.iteratorVar,store:d,value:p}));let m=await e({failFast:t,nodeIds:o.body,page:r,spec:n,startIndex:a+l.length,timeout:s,variables:d});if(l.push(...m.steps),d=m.variables,t&&m.steps.some(y=>y.status==="failed"))break}return{steps:l,variables:d}}async function to({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){let l=sl({collection:o.collection,variables:i}),d=[],p=i;for(let m of l){p=Y({name:o.iteratorVar,store:p,value:al(m)});let y=await e({failFast:t,nodeIds:o.body,page:r,spec:n,startIndex:a+d.length,timeout:s,variables:p});if(d.push(...y.steps),p=y.variables,t&&y.steps.some(h=>h.status==="failed"))break}return{steps:d,variables:p}}function al(e){return typeof e=="object"&&e!=null?JSON.stringify(e):e==null?"":String(e)}function sl({collection:e,variables:t}){if(Array.isArray(e))return e;let o=t[e.name];if(o==null)throw new Error(`Variable "${e.name}" is not defined`);return il(o)}function il(e){if(typeof e!="string")return[e];try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return[e]}async function oo({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){let l=await Promise.all(o.branches.map(m=>e({failFast:t,nodeIds:m,page:r,spec:n,startIndex:a,timeout:s,variables:i}))),d=l.flatMap(m=>m.steps),p=ll({base:i,results:l});return{steps:d,variables:p}}function ll({base:e,results:t}){let o=e;return t.forEach(r=>{o={...o,...r.variables}}),o}async function ro({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){let l=[],d=i;try{let p=await e({failFast:t,nodeIds:o.body,page:r,spec:n,startIndex:a,timeout:s,variables:d});if(l.push(...p.steps),d=p.variables,p.steps.some(y=>y.status==="failed")&&o.catch!=null){let y=await e({failFast:t,nodeIds:o.catch,page:r,spec:n,startIndex:a+l.length,timeout:s,variables:d});l.push(...y.steps),d=y.variables}}catch{if(o.catch!=null){let p=await e({failFast:t,nodeIds:o.catch,page:r,spec:n,startIndex:a+l.length,timeout:s,variables:d});l.push(...p.steps),d=p.variables}}finally{if(o.finally!=null){let p=await e({failFast:t,nodeIds:o.finally,page:r,spec:n,startIndex:a+l.length,timeout:s,variables:d});l.push(...p.steps),d=p.variables}}return{steps:l,variables:d}}async function no({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){return e({failFast:t,nodeIds:o.nodes,page:r,spec:n,startIndex:a,timeout:s,variables:i})}var ao=f(()=>{"use strict";Qt();G()});import{z as N}from"zod";var cl,dl,ul,pl,fl,ml,gl,R,et=f(()=>{"use strict";cl=N.object({by:N.literal("css"),value:N.string().min(1)}),dl=N.object({by:N.literal("testId"),value:N.string().min(1)}),ul=N.object({by:N.literal("role"),exact:N.boolean().optional(),name:N.string().optional(),role:N.string().min(1)}),pl=N.object({by:N.literal("text"),exact:N.boolean().optional(),value:N.string().min(1)}),fl=N.object({by:N.literal("label"),exact:N.boolean().optional(),value:N.string().min(1)}),ml=N.object({by:N.literal("placeholder"),value:N.string().min(1)}),gl=N.object({by:N.literal("altText"),value:N.string().min(1)}),R=N.discriminatedUnion("by",[cl,dl,ul,pl,fl,ml,gl])});import{z as ca}from"zod";var L,fe,tt=f(()=>{"use strict";L=ca.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),fe=ca.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"])});import{z as V}from"zod";var yl,so,me,I,ot,rt=f(()=>{"use strict";yl=V.object({type:V.literal("static"),value:V.union([V.string(),V.number(),V.boolean()])}),so=V.object({name:V.string().min(1),type:V.literal("variable")}),me=V.discriminatedUnion("type",[yl,so]),I=V.discriminatedUnion("type",[V.object({type:V.literal("static"),value:V.string()}),so]),ot=V.discriminatedUnion("type",[V.object({type:V.literal("static"),value:V.number().int().nonnegative()}),so])});import{z as M}from"zod";var nt,io=f(()=>{"use strict";et();tt();rt();nt=M.discriminatedUnion("type",[M.object({locator:R,type:M.literal("elementVisible")}),M.object({locator:R,type:M.literal("elementNotVisible")}),M.object({expected:I,operator:L,type:M.literal("urlMatch")}),M.object({expected:I,locator:R,operator:L,type:M.literal("textMatch")}),M.object({expected:me,operator:fe,type:M.literal("variableCompare"),variable:M.string().min(1)})])});import{z as q}from"zod";var at,lo=f(()=>{"use strict";at=q.discriminatedUnion("type",[q.object({default:q.string().optional(),type:q.literal("string")}),q.object({default:q.number().optional(),type:q.literal("number")}),q.object({default:q.boolean().optional(),type:q.literal("boolean")}),q.object({key:q.string().min(1),type:q.literal("env")})])});import{z as c}from"zod";var hl,X,S,wl,Sl,bl,Pl,Rl,xl,vl,kl,Tl,Cl,Nl,Il,jl,Al,$l,El,Vl,Dl,Ol,Fl,Ul,Wl,Ll,ql,zl,Bl,Ml,_l,Gl,Hl,Jl,Yl,Kl,Ql,Xl,Zl,ec,tc,oc,rc,nc,ac,sc,ic,lc,cc,dc,uc,pc,fc,mc,da,ua,Ae,co=f(()=>{"use strict";io();et();tt();rt();lo();io();et();tt();rt();lo();hl=c.string().min(1),X=c.array(hl).min(1),S={comment:c.string().optional(),id:c.string().min(1),label:c.string().optional(),next:c.string().optional(),timeout:c.number().int().positive().optional()},wl=c.object({...S,type:c.literal("goto"),url:I}),Sl=c.object({...S,locator:R,type:c.literal("click")}),bl=c.object({...S,locator:R,type:c.literal("fill"),value:I}),Pl=c.object({...S,locator:R,type:c.literal("select"),value:I}),Rl=c.object({...S,locator:R,type:c.literal("hover")}),xl=c.object({...S,key:c.string().min(1),locator:R.optional(),type:c.literal("press")}),vl=c.object({...S,locator:R,type:c.literal("check")}),kl=c.object({...S,locator:R,type:c.literal("uncheck")}),Tl=c.object({...S,type:c.literal("screenshot")}),Cl=c.object({...S,height:c.number().int().positive(),type:c.literal("setViewport"),width:c.number().int().positive()}),Nl=c.object({...S,duration:c.number().int().positive(),type:c.literal("wait")}),Il=c.object({...S,message:c.string().min(1),type:c.literal("fail")}),jl=c.object({...S,type:c.literal("setVariable"),value:me,variable:c.string().min(1)}),Al=c.object({...S,locator:R,type:c.literal("extractText"),variable:c.string().min(1)}),$l=c.object({...S,files:c.array(c.string()).min(1),locator:R,type:c.literal("upload")}),El=c.object({...S,locator:R,type:c.literal("dblclick")}),Vl=c.object({...S,source:R,target:R,type:c.literal("drag")}),Dl=c.object({...S,locator:R,type:c.literal("scrollIntoView")}),Ol=c.object({...S,locator:R,type:c.literal("type"),value:I}),Fl=c.object({...S,locator:R,type:c.literal("focus")}),Ul=c.object({...S,locator:R,type:c.literal("clear")}),Wl=c.object({...S,locator:R,type:c.literal("rightClick")}),Ll=c.object({...S,action:c.enum(["accept","dismiss"]),promptText:c.string().optional(),type:c.literal("handleDialog")}),ql=c.object({...S,locator:R.optional(),type:c.literal("scroll"),x:c.number().int().optional(),y:c.number().int().optional()}),zl=c.object({...S,action:c.enum(["read","write"]),type:c.literal("clipboard"),value:I.optional(),variable:c.string().min(1).optional()}),Bl=c.object({...S,permission:c.string().min(1),state:c.enum(["granted","prompt"]),type:c.literal("setPermission")}),Ml=c.object({...S,locator:R,state:c.enum(["visible","hidden","attached","detached"]).optional(),type:c.literal("waitFor")}),_l=c.object({...S,expected:I,operator:L,type:c.literal("waitForUrl")}),Gl=c.object({...S,type:c.literal("waitForResponse"),urlPattern:I}),Hl=c.object({...S,type:c.literal("waitForRequest"),urlPattern:I}),Jl=c.object({...S,locator:R,type:c.literal("assertVisible")}),Yl=c.object({...S,locator:R,type:c.literal("assertNotVisible")}),Kl=c.object({...S,expected:I,locator:R,operator:L,type:c.literal("assertText")}),Ql=c.object({...S,expected:I,operator:L,type:c.literal("assertUrl")}),Xl=c.object({...S,expected:ot,locator:R,operator:fe,type:c.literal("assertCount")}),Zl=c.object({...S,expected:I,locator:R,operator:L,type:c.literal("assertValue")}),ec=c.object({...S,attribute:c.string().min(1),expected:I,locator:R,operator:L,type:c.literal("assertAttribute")}),tc=c.object({...S,locator:R,type:c.literal("assertEnabled")}),oc=c.object({...S,locator:R,type:c.literal("assertDisabled")}),rc=c.object({...S,expected:I,operator:L,type:c.literal("assertTitle")}),nc=c.object({...S,locator:R,type:c.literal("assertChecked")}),ac=c.object({...S,locator:R,type:c.literal("assertNotChecked")}),sc=c.object({...S,locator:R,type:c.literal("assertFocused")}),ic=c.object({...S,httpOnly:c.boolean().optional(),name:I,operator:L.optional(),sameSite:c.enum(["Strict","Lax","None"]).optional(),secure:c.boolean().optional(),type:c.literal("assertCookie"),value:I.optional()}),lc=c.object({...S,bodyContains:I.optional(),headerContains:c.object({name:c.string().min(1),value:I}).optional(),status:c.number().int().positive().optional(),type:c.literal("assertResponse"),urlPattern:I}),cc=c.object({...S,alternate:X.optional(),condition:nt,consequent:X,type:c.literal("if")}),dc=c.object({...S,body:X,iteratorVar:c.string().min(1).optional(),times:c.number().int().positive(),type:c.literal("loop")}),uc=c.object({...S,body:X,collection:c.union([c.array(c.record(c.string(),c.unknown())).min(1),c.object({name:c.string().min(1),type:c.literal("variable")})]),iteratorVar:c.string().min(1),type:c.literal("forEach")}),pc=c.object({...S,branches:c.array(X).min(2),type:c.literal("parallel")}),fc=c.object({...S,body:X,catch:X.optional(),finally:X.optional(),type:c.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),mc=c.object({...S,nodes:X,type:c.literal("group")}),da=c.discriminatedUnion("type",[wl,Sl,bl,Pl,Rl,xl,vl,kl,Ml,_l,Gl,Hl,Jl,Yl,Kl,Ql,Xl,Zl,ec,tc,oc,Tl,Cl,Nl,Il,jl,Al,$l,El,Vl,Dl,Ol,Fl,Ul,Wl,Ll,ql,zl,Bl,rc,nc,ac,sc,ic,lc,cc,dc,uc,pc,mc]),ua=c.union([da,fc]),Ae=c.object({entryNode:c.string().min(1),nodes:c.record(c.string(),ua),variables:c.record(c.string(),at).optional(),version:c.literal(2)})});function se(e){let t=Ae.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(o=>({message:o.message,path:o.path.join(".")})),success:!1}}var pa=f(()=>{"use strict";co()});var $e=f(()=>{"use strict";co();pa()});async function fa({node:e,page:t,timeout:o,variables:r}){switch(e.type){case"assertTitle":{let n=T({ref:e.expected,variables:r});return[Yn({expected:n,operator:e.operator,title:await t.title()})]}case"assertChecked":return[await Kn({locator:v({locator:e.locator,page:t}),timeout:o})];case"assertNotChecked":return[await Qn({locator:v({locator:e.locator,page:t}),timeout:o})];case"assertFocused":return[await Xn({locator:v({locator:e.locator,page:t}),timeout:o})];case"assertCookie":return gc({node:e,page:t,variables:r});case"assertResponse":return yc({node:e,page:t,timeout:o,variables:r})}}async function gc({node:e,page:t,variables:o}){let r=T({ref:e.name,variables:o}),n=e.value==null?void 0:T({ref:e.value,variables:o}),a=await t.context().cookies();return[Zn({cookies:a,expected:{httpOnly:e.httpOnly,name:r,operator:e.operator,sameSite:e.sameSite,secure:e.secure,value:n}})]}async function yc({node:e,page:t,timeout:o,variables:r}){let n=T({ref:e.urlPattern,variables:r}),a=e.bodyContains==null?void 0:T({ref:e.bodyContains,variables:r}),s=e.headerContains==null?void 0:{name:e.headerContains.name,value:T({ref:e.headerContains.value,variables:r})};return ea({bodyContains:a,headerContains:s,page:t,status:e.status,timeout:o,urlPattern:n})}var ma=f(()=>{"use strict";Ne();Z();G()});async function U({fn:e,label:t}){let o=performance.now(),r=await e();return u.info("%s: %dms",t,Math.round(performance.now()-o)),r}var st=f(()=>{"use strict";W()});async function uo({failFast:e,onStep:t,page:o,spec:r,variables:n}){let a=performance.now();return Sc({currentId:r.entryNode,failFast:e,onStep:t,page:o,runStartTime:a,spec:r,startIndex:0,variables:n})}function wc({onStep:e,steps:t,target:o}){t.forEach(r=>{o.push(r),e?.(r)})}async function Sc({currentId:e,failFast:t,onStep:o,page:r,runStartTime:n,spec:a,startIndex:s,variables:i}){let l=[],d=i,p=e;for(;p!=null;){let m=a.nodes[p];if(m==null)throw new Error(`Node "${p}" not found in spec`);let y=p,h=m.label??`${m.type} (${p})`;u.info("Executing node: %s [%s]",h,m.type);let k=await ga({failFast:t,node:m,nodeId:y,page:r,runStartTime:n,spec:a,startIndex:s+l.length,variables:d});if(wc({onStep:o,steps:k.steps,target:l}),d=k.variables,t&&k.steps.some(x=>x.status==="failed"))break;p=m.next}return{steps:l,variables:d}}async function ga({failFast:e,node:t,nodeId:o,page:r,runStartTime:n,spec:a,startIndex:s,variables:i}){let l=performance.now(),d=t.label??`${t.type} (${t.id})`,p=t.timeout??hc;if(bc(t))return Pc({failFast:e,node:t,page:r,spec:a,startIndex:s,timeout:p,variables:i});let m=Me({node:t,page:r});try{let y=await kc({node:t,page:r,timeout:p,variables:i}),h=Math.round(performance.now()-l),k=y.assertions.some(b=>b.status==="failed"),x=await U({label:`Snapshot [${d}]`,fn:()=>ee({page:r,runStartTime:n,targets:m})});return{steps:[{annotations:x.annotations,assertions:y.assertions,detail:void 0,duration:h,nodeId:o,nodeType:t.type,screenshotBase64:x.screenshotBase64,snapshotTimestamp:x.snapshotTimestamp,status:k?"failed":"passed",stepIndex:s,title:d,url:x.url,viewportHeight:x.viewportHeight,viewportWidth:x.viewportWidth}],variables:y.variables}}catch(y){let h=Math.round(performance.now()-l),k=y instanceof Error?y.message:String(y),x=await U({label:`Snapshot [${d}] (error)`,fn:()=>ee({page:r,runStartTime:n,targets:m})});return{steps:[{annotations:x.annotations,assertions:[],detail:k,duration:h,nodeId:o,nodeType:t.type,screenshotBase64:x.screenshotBase64,snapshotTimestamp:x.snapshotTimestamp,status:"failed",stepIndex:s,title:d,url:x.url,viewportHeight:x.viewportHeight,viewportWidth:x.viewportWidth}],variables:i}}}function bc(e){return["if","loop","forEach","parallel","try","group"].includes(e.type)}async function Pc({failFast:e,node:t,page:o,spec:r,startIndex:n,timeout:a,variables:s}){let i={executeSequence:vc,failFast:e,page:o,spec:r,startIndex:n,timeout:a,variables:s};switch(t.type){case"if":return Zt({...i,node:t});case"loop":return eo({...i,node:t});case"forEach":return to({...i,node:t});case"parallel":return oo({...i,node:t});case"try":return ro({...i,node:t});case"group":return no({...i,node:t})}}function Rc(e){return e.some(t=>t.status==="failed")}function xc({nodeId:e,spec:t,timeout:o}){let r=t.nodes[e];if(r==null)throw new Error(`Node "${e}" not found in spec`);return r.timeout==null?{...r,timeout:o}:r}async function vc({failFast:e,nodeIds:t,page:o,spec:r,startIndex:n,timeout:a,variables:s}){let i=[],l=s;for(let d of t){let p=xc({nodeId:d,spec:r,timeout:a}),m=await ga({failFast:e,node:p,nodeId:d,page:o,runStartTime:0,spec:r,startIndex:n+i.length,variables:l});if(i.push(...m.steps),l=m.variables,e&&Rc(m.steps))break}return{steps:i,variables:l}}async function kc({node:e,page:t,timeout:o,variables:r}){if(Tc(e)){let a=await kt({node:e,page:t,timeout:o,variables:r});return{assertions:[],variables:a.variables}}return{assertions:await Cc({node:e,page:t,timeout:o,variables:r}),variables:r}}function Tc(e){return["goto","click","dblclick","fill","select","hover","press","check","uncheck","clear","rightClick","handleDialog","scroll","clipboard","setPermission","waitFor","waitForUrl","waitForResponse","waitForRequest","screenshot","setViewport","wait","fail","setVariable","extractText","upload","drag","scrollIntoView","type","focus"].includes(e.type)}async function Cc({node:e,page:t,timeout:o,variables:r}){let n=e;switch(n.type){case"assertVisible":return[await Te({locator:v({locator:n.locator,page:t}),timeout:o})];case"assertNotVisible":return[await Ce({locator:v({locator:n.locator,page:t}),timeout:o})];case"assertText":{let a=T({ref:n.expected,variables:r});return[await Gt({expected:a,locator:v({locator:n.locator,page:t}),operator:n.operator,timeout:o})]}case"assertUrl":{let a=T({ref:n.expected,variables:r});return[Ht({expected:a,operator:n.operator,url:t.url()})]}case"assertCount":{let a=vt({ref:n.expected,variables:r});return[await Jt({expected:a,locator:v({locator:n.locator,page:t}),operator:n.operator})]}case"assertValue":{let a=T({ref:n.expected,variables:r});return[await Yt({expected:a,locator:v({locator:n.locator,page:t}),operator:n.operator,timeout:o})]}case"assertAttribute":{let a=T({ref:n.expected,variables:r});return[await Gn({attribute:n.attribute,expected:a,locator:v({locator:n.locator,page:t}),operator:n.operator,timeout:o})]}case"assertEnabled":return[await Hn({locator:v({locator:n.locator,page:t}),timeout:o})];case"assertDisabled":return[await Jn({locator:v({locator:n.locator,page:t}),timeout:o})];case"assertTitle":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertCookie":case"assertResponse":return fa({node:n,page:t,timeout:o,variables:r})}}var hc,po=f(()=>{"use strict";Tt();Ne();ma();ao();Z();W();st();Re();G();hc=5e3});async function Ee({baseUrl:e,browser:t,cookies:o,extraVariables:r,navigateTo:n,onStep:a,runId:s,spec:i}){let l=await t.newContext({baseURL:e});u.info("Browser context created"),o.length>0&&await l.addCookies(o);let d=await l.newPage();u.info("Page created");let p=xe(d);n!=null&&(u.info("Navigating to: %s",n),await d.goto(n,{waitUntil:"domcontentloaded"}),u.info("Navigation complete"));function m(b){a?.(b),Ye({context:l,page:d,runId:s,stepIndex:b.stepIndex,stepResult:b})}let y={...Pe({defs:i.variables}),...r};u.info("Starting graph execution (entry: %s)",i.entryNode);let h=await uo({failFast:!0,onStep:m,page:d,spec:i,variables:y}),k=h.steps.filter(b=>b.status==="passed").length,x=h.steps.filter(b=>b.status==="failed").length,$={duration:h.steps.reduce((b,A)=>b+A.duration,0),failCount:x,passCount:k,runId:s,status:x>0?"failed":"passed",workflowName:""};return await Ke({monitor:p,runId:s,steps:h.steps,summary:$}),await l.close(),h.steps}var fo=f(()=>{"use strict";Ft();Qe();po();W();G()});import{z as it}from"zod";var mo,go=f(()=>{"use strict";mo=it.object({from:it.string().min(1).describe("Key of the source state in the states record"),to:it.string().min(1).describe("Key of the target state in the states record"),workflow:it.string().min(1).describe("Filename (without .json) of the workflow in .ripplo/workflows/ that executes this edge")}).describe("A directed edge between two states, executed by a workflow")});import{z as j}from"zod";var Nc,yo,ho,Ic,jc,Ve,wo=f(()=>{"use strict";Nc=j.object({precondition:j.string().min(1).describe("Name of the precondition to check or execute, e.g. 'auth:admin'")}).describe("Request payload sent by Ripplo to both the check and execute endpoints"),yo=j.object({satisfied:j.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),ho=j.object({data:j.record(j.string(),j.string()).optional().describe("Key-value data returned by the precondition. Values are injected as variables that can be interpolated into route patterns ({{key}}) and workflow spec variable references. For example, a data:project precondition should return { projectId: 'clx...' } so the route /projects/{{projectId}}/settings resolves correctly."),error:j.string().optional().describe("Human-readable error message if success is false"),navigateTo:j.string().optional().describe("URL to navigate the browser to after this precondition executes. Use this to set the starting page for the test \u2014 e.g. an auth token URL or the page the workflow begins on. If multiple preconditions return navigateTo, only the last one is used."),success:j.boolean().describe("Whether the precondition was successfully satisfied")}).describe("Response from PUT {preconditionApiUrl}/execute. Set-Cookie headers are automatically captured and injected into the browser context. The data field provides values for route param interpolation and workflow variables."),Ic=j.object({preconditions:j.array(j.string().min(1)).describe("Names of all preconditions that were executed during this run")}).describe("Request payload sent after a run completes. Fire-and-forget \u2014 errors are logged but don't fail the run."),jc=j.object({error:j.string().optional().describe("Human-readable error message if success is false"),success:j.boolean().describe("Whether teardown completed successfully")}).describe("Response from PUT {preconditionApiUrl}/teardown"),Ve=j.object({depends:j.array(j.string().min(1)).optional().describe("Names of other preconditions that must be satisfied first. Resolved via topological sort; cycles are rejected at validation time."),description:j.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:j.array(j.string().min(1)).optional().describe("Keys that the execute response's data field will contain. e.g. ['projectId', 'workflowId']. These are used for route param interpolation ({{projectId}}) and workflow variables. Declared here so generated types are strongly typed per precondition.")}).describe("A named precondition declared at the graph level. States reference these by name.")});import{z as lt}from"zod";var So,bo=f(()=>{"use strict";So=lt.object({preconditions:lt.array(lt.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:lt.string().min(1).describe("URL pattern with {{placeholders}} for dynamic segments, e.g. '/projects/{{projectId}}/settings'")}).describe("A distinct application state \u2014 a unique combination of location, auth context, and data conditions")});import{z as oe}from"zod";var ct,Po=f(()=>{"use strict";go();wo();bo();ct=oe.object({edges:oe.array(mo).describe("Directed edges between states, each executed by a workflow"),preconditions:oe.record(oe.string(),Ve).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:oe.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:oe.record(oe.string(),So).describe("States keyed by stable ID (kebab-case)"),version:oe.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions")});var ya=f(()=>{"use strict";Po()});var dt=f(()=>{"use strict";go();Po();wo();bo();ya()});import{parseSetCookie as Ac}from"set-cookie-parser";import{z as ha}from"zod";async function De({apiUrl:e,cookies:t,executed:o}){if(o.length!==0)try{let r=await fetch(`${e}/teardown`,{body:JSON.stringify({preconditions:o}),headers:{"Content-Type":"application/json",...Ro({cookies:t})},method:"PUT"});r.ok||u.error("Teardown returned %s",String(r.status))}catch{u.error("Teardown request failed")}}function $c({preconditionNames:e,preconditions:t}){let o=[],r=new Set;function n(a){if(r.has(a))return;r.add(a);let s=t[a];s?.depends!=null&&s.depends.forEach(i=>{n(i)}),o.push(a)}return e.forEach(a=>{n(a)}),o}async function Ec({apiUrl:e,cookies:t,name:o}){let r=await fetch(`${e}/check`,{body:JSON.stringify({precondition:o}),headers:{"Content-Type":"application/json",...Ro({cookies:t})},method:"POST"});if(!r.ok)return!1;let n=await r.json(),a=yo.safeParse(n);if(!a.success)throw new Error(`Check response for "${o}" has invalid shape: ${a.error.message}`);return a.data.satisfied}async function Vc({apiUrl:e,cookies:t,name:o}){let r=await fetch(`${e}/execute`,{body:JSON.stringify({precondition:o}),headers:{"Content-Type":"application/json",...Ro({cookies:t})},method:"PUT"});if(!r.ok)throw new Error(`Execute for "${o}" returned ${String(r.status)}`);let n=await r.json(),a=ho.safeParse(n);if(!a.success)throw new Error(`Execute response for "${o}" has invalid shape: ${a.error.message}`);if(!a.data.success){let i=a.data.error??"no error detail";throw new Error(`Precondition "${o}" failed to execute: ${i}`)}return{cookies:Dc({domain:new URL(e).hostname,res:r}),data:a.data.data??{},navigateTo:a.data.navigateTo}}function Ro({cookies:e}){return e.length===0?{}:{Cookie:e.map(o=>`${o.name}=${o.value}`).join("; ")}}function Dc({domain:e,res:t}){let o=t.headers.getSetCookie();return Ac(o,{decodeValues:!1}).map(n=>Oc({cookie:n,domain:e}))}function Oc({cookie:e,domain:t}){let o={domain:e.domain??t,httpOnly:e.httpOnly??!1,name:e.name,path:e.path??"/",secure:e.secure??!1,value:e.value};return e.sameSite!=null&&(o.sameSite=Uc({raw:e.sameSite})),e.expires!=null?o.expires=Math.floor(e.expires.getTime()/1e3):e.maxAge!=null&&(o.expires=Math.floor(Date.now()/1e3)+e.maxAge),o}function Uc({raw:e}){return Fc[e.toLowerCase()]??"Lax"}async function ie({baseUrl:e,project:t,workflowSlug:o}){let r={apiUrl:void 0,cookies:[],data:{},executed:[],navigateTo:void 0},n=t.stateGraph;if(n==null)return r;let a=(n.edges??[]).find(p=>p.workflowSlug===o);if(a?.sourceState==null)return r;let s=qc({baseUrl:e,preconditionApiPath:t.preconditionApiPath}),i=a.sourceState.preconditions;if(i.length===0)return{...r,apiUrl:s};if(s==null)return r;let l=Wc.safeParse(n.preconditions);if(!l.success)return{...r,apiUrl:s};let d=await Lc({apiUrl:s,preconditionNames:i,preconditions:l.data});return{apiUrl:s,cookies:d.cookies,data:d.data,executed:d.executed,navigateTo:d.navigateTo}}async function Lc({apiUrl:e,preconditionNames:t,preconditions:o}){let r=$c({preconditionNames:t,preconditions:o}),n=[],a={},s=[],i,l=Promise.resolve();return r.forEach(d=>{l=l.then(async()=>{if(await Ec({apiUrl:e,cookies:n,name:d}))return;let m=await Vc({apiUrl:e,cookies:n,name:d});n.push(...m.cookies),Object.entries(m.data).forEach(([y,h])=>{a[y]=h}),s.push(d),m.navigateTo!=null&&(i=m.navigateTo)})}),await l,{cookies:n,data:a,executed:s,navigateTo:i}}function qc({baseUrl:e,preconditionApiPath:t}){if(t.length!==0)return t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`}var Fc,Wc,xo=f(()=>{"use strict";dt();dt();W();Fc={lax:"Lax",none:"None",strict:"Strict"};Wc=ha.record(ha.string(),Ve)});import{graphql as vo}from"gql.tada";async function Oe({agentProfileId:e,config:t,runId:o}){let r=await C({config:t,document:Bc,variables:{agentProfileId:e??null,platform:"chromium",runId:o}});if(r.startRun==null)throw new Error("Failed to start run");let n=r.startRun.id,a=Promise.resolve();function s(l){a=a.then(()=>zc({config:t,runResultId:n,steps:[l]})).catch(d=>{let p=d instanceof Error?d.message:"Unknown error";u.error("Failed to submit step %d: %s",l.stepIndex,p)})}async function i({statusOverride:l,steps:d,summary:p}){await a;let m=d.filter(x=>x.status==="passed").length,y=d.filter(x=>x.status==="failed").length,h=d.reduce((x,$)=>x+$.duration,0),k=l??(y>0?"failed":"passed");await C({config:t,document:_c,variables:{duration:h,failCount:y,passCount:m,runResultId:n,status:k,summary:p??null,warnCount:0}})}return{complete:i,enqueueStep:s,runResultId:n}}async function zc({config:e,runResultId:t,steps:o}){let r=o.map(n=>({annotations:n.annotations.map(a=>({height:a.height,label:a.label,type:a.type,width:a.width,x:a.x,y:a.y})),assertions:n.assertions.map(a=>({description:a.description,detail:a.detail,status:a.status})),detail:n.detail,duration:n.duration,nodeType:n.nodeType,screenshotBase64:n.screenshotBase64,snapshotTimestamp:n.snapshotTimestamp,status:n.status,stepIndex:n.stepIndex,title:n.title,url:n.url,viewportHeight:n.viewportHeight,viewportWidth:n.viewportWidth}));await C({config:e,document:Mc,variables:{runResultId:t,steps:r}})}var Bc,Mc,_c,ko=f(()=>{"use strict";Ie();W();Bc=vo(`
|
|
92
|
+
`)});async function Kt({condition:e,page:t,timeout:o,variables:r}){switch(e.type){case"elementVisible":return(await Te({locator:v({locator:e.locator,page:t}),timeout:o})).status==="passed";case"elementNotVisible":return(await Ce({locator:v({locator:e.locator,page:t}),timeout:o})).status==="passed";case"urlMatch":{let n=T({ref:e.expected,variables:r});return H({actual:t.url(),expected:n,label:"URL",operator:e.operator}).status==="passed"}case"textMatch":{let a=await v({locator:e.locator,page:t}).textContent({timeout:o}),s=T({ref:e.expected,variables:r});return H({actual:a??"",expected:s,label:"Text",operator:e.operator}).status==="passed"}case"variableCompare":{let n=r[e.variable];if(n==null)throw new Error(`Variable "${e.variable}" is not defined`);let a=typeof n=="number"?n:Number(n),s=ae({ref:e.expected,variables:r}),i=typeof s=="number"?s:Number(s);return Xe({actual:a,expected:i,label:e.variable,operator:e.operator}).status==="passed"}}}var Qt=f(()=>{"use strict";Ne();Z();G()});import pe from"fs";import Xt from"path";import{z as te}from"zod";function sa(e){if(!pe.existsSync(e))return null;let t=pe.readFileSync(e,"utf8");return JSON.parse(t)}function B(){let e=sa(ia),t=sa(la);if(e==null||t==null)return null;let o=al.safeParse({...e,...t});return o.success?o.data:null}function Q(e){pe.existsSync(Ze)||pe.mkdirSync(Ze,{recursive:!0});let{ripploServerUrl:t,token:o,...r}=e;pe.writeFileSync(ia,JSON.stringify(r,null,2)+`
|
|
93
|
+
`),pe.writeFileSync(la,JSON.stringify({ripploServerUrl:t,token:o},null,2)+`
|
|
94
|
+
`)}var rl,nl,al,Ze,ia,la,ca=f(()=>{"use strict";rl=te.object({baseUrl:te.string().optional(),cloudBaseUrl:te.string(),preconditionApiPath:te.string().optional(),projectId:te.string()}),nl=te.object({ripploServerUrl:te.string(),token:te.string()}),al=rl.extend(nl.shape),Ze=Xt.join(process.cwd(),".ripplo"),ia=Xt.join(Ze,"settings.json"),la=Xt.join(Ze,"settings.local.json")});async function Zt({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){let d=await Kt({condition:o.condition,page:r,timeout:s,variables:i})?o.consequent:o.alternate??[];return d.length===0?{steps:[],variables:i}:e({failFast:t,nodeIds:d,page:r,spec:n,startIndex:a,timeout:s,variables:i})}async function eo({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){let l=[],d=i;for(let p=0;p<o.times;p++){o.iteratorVar!=null&&(d=Y({name:o.iteratorVar,store:d,value:p}));let m=await e({failFast:t,nodeIds:o.body,page:r,spec:n,startIndex:a+l.length,timeout:s,variables:d});if(l.push(...m.steps),d=m.variables,t&&m.steps.some(y=>y.status==="failed"))break}return{steps:l,variables:d}}async function to({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){let l=il({collection:o.collection,variables:i}),d=[],p=i;for(let m of l){p=Y({name:o.iteratorVar,store:p,value:sl(m)});let y=await e({failFast:t,nodeIds:o.body,page:r,spec:n,startIndex:a+d.length,timeout:s,variables:p});if(d.push(...y.steps),p=y.variables,t&&y.steps.some(h=>h.status==="failed"))break}return{steps:d,variables:p}}function sl(e){return typeof e=="object"&&e!=null?JSON.stringify(e):e==null?"":String(e)}function il({collection:e,variables:t}){if(Array.isArray(e))return e;let o=t[e.name];if(o==null)throw new Error(`Variable "${e.name}" is not defined`);return ll(o)}function ll(e){if(typeof e!="string")return[e];try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return[e]}async function oo({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){let l=await Promise.all(o.branches.map(m=>e({failFast:t,nodeIds:m,page:r,spec:n,startIndex:a,timeout:s,variables:i}))),d=l.flatMap(m=>m.steps),p=cl({base:i,results:l});return{steps:d,variables:p}}function cl({base:e,results:t}){let o=e;return t.forEach(r=>{o={...o,...r.variables}}),o}async function ro({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){let l=[],d=i;try{let p=await e({failFast:t,nodeIds:o.body,page:r,spec:n,startIndex:a,timeout:s,variables:d});if(l.push(...p.steps),d=p.variables,p.steps.some(y=>y.status==="failed")&&o.catch!=null){let y=await e({failFast:t,nodeIds:o.catch,page:r,spec:n,startIndex:a+l.length,timeout:s,variables:d});l.push(...y.steps),d=y.variables}}catch{if(o.catch!=null){let p=await e({failFast:t,nodeIds:o.catch,page:r,spec:n,startIndex:a+l.length,timeout:s,variables:d});l.push(...p.steps),d=p.variables}}finally{if(o.finally!=null){let p=await e({failFast:t,nodeIds:o.finally,page:r,spec:n,startIndex:a+l.length,timeout:s,variables:d});l.push(...p.steps),d=p.variables}}return{steps:l,variables:d}}async function no({executeSequence:e,failFast:t,node:o,page:r,spec:n,startIndex:a,timeout:s,variables:i}){return e({failFast:t,nodeIds:o.nodes,page:r,spec:n,startIndex:a,timeout:s,variables:i})}var ao=f(()=>{"use strict";Qt();G()});import{z as N}from"zod";var dl,ul,pl,fl,ml,gl,yl,R,et=f(()=>{"use strict";dl=N.object({by:N.literal("css"),value:N.string().min(1)}),ul=N.object({by:N.literal("testId"),value:N.string().min(1)}),pl=N.object({by:N.literal("role"),exact:N.boolean().optional(),name:N.string().optional(),role:N.string().min(1)}),fl=N.object({by:N.literal("text"),exact:N.boolean().optional(),value:N.string().min(1)}),ml=N.object({by:N.literal("label"),exact:N.boolean().optional(),value:N.string().min(1)}),gl=N.object({by:N.literal("placeholder"),value:N.string().min(1)}),yl=N.object({by:N.literal("altText"),value:N.string().min(1)}),R=N.discriminatedUnion("by",[dl,ul,pl,fl,ml,gl,yl])});import{z as da}from"zod";var L,fe,tt=f(()=>{"use strict";L=da.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),fe=da.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"])});import{z as V}from"zod";var hl,so,me,I,ot,rt=f(()=>{"use strict";hl=V.object({type:V.literal("static"),value:V.union([V.string(),V.number(),V.boolean()])}),so=V.object({name:V.string().min(1),type:V.literal("variable")}),me=V.discriminatedUnion("type",[hl,so]),I=V.discriminatedUnion("type",[V.object({type:V.literal("static"),value:V.string()}),so]),ot=V.discriminatedUnion("type",[V.object({type:V.literal("static"),value:V.number().int().nonnegative()}),so])});import{z as M}from"zod";var nt,io=f(()=>{"use strict";et();tt();rt();nt=M.discriminatedUnion("type",[M.object({locator:R,type:M.literal("elementVisible")}),M.object({locator:R,type:M.literal("elementNotVisible")}),M.object({expected:I,operator:L,type:M.literal("urlMatch")}),M.object({expected:I,locator:R,operator:L,type:M.literal("textMatch")}),M.object({expected:me,operator:fe,type:M.literal("variableCompare"),variable:M.string().min(1)})])});import{z as q}from"zod";var at,lo=f(()=>{"use strict";at=q.discriminatedUnion("type",[q.object({default:q.string().optional(),type:q.literal("string")}),q.object({default:q.number().optional(),type:q.literal("number")}),q.object({default:q.boolean().optional(),type:q.literal("boolean")}),q.object({key:q.string().min(1),type:q.literal("env")})])});import{z as c}from"zod";var wl,X,S,Sl,bl,Pl,Rl,xl,vl,kl,Tl,Cl,Nl,Il,jl,Al,$l,El,Vl,Dl,Ol,Fl,Ul,Wl,Ll,ql,zl,Bl,Ml,_l,Gl,Hl,Jl,Yl,Kl,Ql,Xl,Zl,ec,tc,oc,rc,nc,ac,sc,ic,lc,cc,dc,uc,pc,fc,mc,gc,ua,pa,Ae,co=f(()=>{"use strict";io();et();tt();rt();lo();io();et();tt();rt();lo();wl=c.string().min(1),X=c.array(wl).min(1),S={comment:c.string().optional(),id:c.string().min(1),label:c.string().optional(),next:c.string().optional(),timeout:c.number().int().positive().optional()},Sl=c.object({...S,type:c.literal("goto"),url:I}),bl=c.object({...S,locator:R,type:c.literal("click")}),Pl=c.object({...S,locator:R,type:c.literal("fill"),value:I}),Rl=c.object({...S,locator:R,type:c.literal("select"),value:I}),xl=c.object({...S,locator:R,type:c.literal("hover")}),vl=c.object({...S,key:c.string().min(1),locator:R.optional(),type:c.literal("press")}),kl=c.object({...S,locator:R,type:c.literal("check")}),Tl=c.object({...S,locator:R,type:c.literal("uncheck")}),Cl=c.object({...S,type:c.literal("screenshot")}),Nl=c.object({...S,height:c.number().int().positive(),type:c.literal("setViewport"),width:c.number().int().positive()}),Il=c.object({...S,duration:c.number().int().positive(),type:c.literal("wait")}),jl=c.object({...S,message:c.string().min(1),type:c.literal("fail")}),Al=c.object({...S,type:c.literal("setVariable"),value:me,variable:c.string().min(1)}),$l=c.object({...S,locator:R,type:c.literal("extractText"),variable:c.string().min(1)}),El=c.object({...S,files:c.array(c.string()).min(1),locator:R,type:c.literal("upload")}),Vl=c.object({...S,locator:R,type:c.literal("dblclick")}),Dl=c.object({...S,source:R,target:R,type:c.literal("drag")}),Ol=c.object({...S,locator:R,type:c.literal("scrollIntoView")}),Fl=c.object({...S,locator:R,type:c.literal("type"),value:I}),Ul=c.object({...S,locator:R,type:c.literal("focus")}),Wl=c.object({...S,locator:R,type:c.literal("clear")}),Ll=c.object({...S,locator:R,type:c.literal("rightClick")}),ql=c.object({...S,action:c.enum(["accept","dismiss"]),promptText:c.string().optional(),type:c.literal("handleDialog")}),zl=c.object({...S,locator:R.optional(),type:c.literal("scroll"),x:c.number().int().optional(),y:c.number().int().optional()}),Bl=c.object({...S,action:c.enum(["read","write"]),type:c.literal("clipboard"),value:I.optional(),variable:c.string().min(1).optional()}),Ml=c.object({...S,permission:c.string().min(1),state:c.enum(["granted","prompt"]),type:c.literal("setPermission")}),_l=c.object({...S,locator:R,state:c.enum(["visible","hidden","attached","detached"]).optional(),type:c.literal("waitFor")}),Gl=c.object({...S,expected:I,operator:L,type:c.literal("waitForUrl")}),Hl=c.object({...S,type:c.literal("waitForResponse"),urlPattern:I}),Jl=c.object({...S,type:c.literal("waitForRequest"),urlPattern:I}),Yl=c.object({...S,locator:R,type:c.literal("assertVisible")}),Kl=c.object({...S,locator:R,type:c.literal("assertNotVisible")}),Ql=c.object({...S,expected:I,locator:R,operator:L,type:c.literal("assertText")}),Xl=c.object({...S,expected:I,operator:L,type:c.literal("assertUrl")}),Zl=c.object({...S,expected:ot,locator:R,operator:fe,type:c.literal("assertCount")}),ec=c.object({...S,expected:I,locator:R,operator:L,type:c.literal("assertValue")}),tc=c.object({...S,attribute:c.string().min(1),expected:I,locator:R,operator:L,type:c.literal("assertAttribute")}),oc=c.object({...S,locator:R,type:c.literal("assertEnabled")}),rc=c.object({...S,locator:R,type:c.literal("assertDisabled")}),nc=c.object({...S,expected:I,operator:L,type:c.literal("assertTitle")}),ac=c.object({...S,locator:R,type:c.literal("assertChecked")}),sc=c.object({...S,locator:R,type:c.literal("assertNotChecked")}),ic=c.object({...S,locator:R,type:c.literal("assertFocused")}),lc=c.object({...S,httpOnly:c.boolean().optional(),name:I,operator:L.optional(),sameSite:c.enum(["Strict","Lax","None"]).optional(),secure:c.boolean().optional(),type:c.literal("assertCookie"),value:I.optional()}),cc=c.object({...S,bodyContains:I.optional(),headerContains:c.object({name:c.string().min(1),value:I}).optional(),status:c.number().int().positive().optional(),type:c.literal("assertResponse"),urlPattern:I}),dc=c.object({...S,alternate:X.optional(),condition:nt,consequent:X,type:c.literal("if")}),uc=c.object({...S,body:X,iteratorVar:c.string().min(1).optional(),times:c.number().int().positive(),type:c.literal("loop")}),pc=c.object({...S,body:X,collection:c.union([c.array(c.record(c.string(),c.unknown())).min(1),c.object({name:c.string().min(1),type:c.literal("variable")})]),iteratorVar:c.string().min(1),type:c.literal("forEach")}),fc=c.object({...S,branches:c.array(X).min(2),type:c.literal("parallel")}),mc=c.object({...S,body:X,catch:X.optional(),finally:X.optional(),type:c.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),gc=c.object({...S,nodes:X,type:c.literal("group")}),ua=c.discriminatedUnion("type",[Sl,bl,Pl,Rl,xl,vl,kl,Tl,_l,Gl,Hl,Jl,Yl,Kl,Ql,Xl,Zl,ec,tc,oc,rc,Cl,Nl,Il,jl,Al,$l,El,Vl,Dl,Ol,Fl,Ul,Wl,Ll,ql,zl,Bl,Ml,nc,ac,sc,ic,lc,cc,dc,uc,pc,fc,gc]),pa=c.union([ua,mc]),Ae=c.object({entryNode:c.string().min(1),nodes:c.record(c.string(),pa),variables:c.record(c.string(),at).optional(),version:c.literal(2)})});function se(e){let t=Ae.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(o=>({message:o.message,path:o.path.join(".")})),success:!1}}var fa=f(()=>{"use strict";co()});var $e=f(()=>{"use strict";co();fa()});async function ma({node:e,page:t,timeout:o,variables:r}){switch(e.type){case"assertTitle":{let n=T({ref:e.expected,variables:r});return[Kn({expected:n,operator:e.operator,title:await t.title()})]}case"assertChecked":return[await Qn({locator:v({locator:e.locator,page:t}),timeout:o})];case"assertNotChecked":return[await Xn({locator:v({locator:e.locator,page:t}),timeout:o})];case"assertFocused":return[await Zn({locator:v({locator:e.locator,page:t}),timeout:o})];case"assertCookie":return yc({node:e,page:t,variables:r});case"assertResponse":return hc({node:e,page:t,timeout:o,variables:r})}}async function yc({node:e,page:t,variables:o}){let r=T({ref:e.name,variables:o}),n=e.value==null?void 0:T({ref:e.value,variables:o}),a=await t.context().cookies();return[ea({cookies:a,expected:{httpOnly:e.httpOnly,name:r,operator:e.operator,sameSite:e.sameSite,secure:e.secure,value:n}})]}async function hc({node:e,page:t,timeout:o,variables:r}){let n=T({ref:e.urlPattern,variables:r}),a=e.bodyContains==null?void 0:T({ref:e.bodyContains,variables:r}),s=e.headerContains==null?void 0:{name:e.headerContains.name,value:T({ref:e.headerContains.value,variables:r})};return ta({bodyContains:a,headerContains:s,page:t,status:e.status,timeout:o,urlPattern:n})}var ga=f(()=>{"use strict";Ne();Z();G()});async function U({fn:e,label:t}){let o=performance.now(),r=await e();return u.info("%s: %dms",t,Math.round(performance.now()-o)),r}var st=f(()=>{"use strict";W()});async function uo({failFast:e,onStep:t,page:o,spec:r,variables:n}){let a=performance.now();return bc({currentId:r.entryNode,failFast:e,onStep:t,page:o,runStartTime:a,spec:r,startIndex:0,variables:n})}function Sc({onStep:e,steps:t,target:o}){t.forEach(r=>{o.push(r),e?.(r)})}async function bc({currentId:e,failFast:t,onStep:o,page:r,runStartTime:n,spec:a,startIndex:s,variables:i}){let l=[],d=i,p=e;for(;p!=null;){let m=a.nodes[p];if(m==null)throw new Error(`Node "${p}" not found in spec`);let y=p,h=m.label??`${m.type} (${p})`;u.info("Executing node: %s [%s]",h,m.type);let k=await ya({failFast:t,node:m,nodeId:y,page:r,runStartTime:n,spec:a,startIndex:s+l.length,variables:d});if(Sc({onStep:o,steps:k.steps,target:l}),d=k.variables,t&&k.steps.some(x=>x.status==="failed"))break;p=m.next}return{steps:l,variables:d}}async function ya({failFast:e,node:t,nodeId:o,page:r,runStartTime:n,spec:a,startIndex:s,variables:i}){let l=performance.now(),d=t.label??`${t.type} (${t.id})`,p=t.timeout??wc;if(Pc(t))return Rc({failFast:e,node:t,page:r,spec:a,startIndex:s,timeout:p,variables:i});let m=Me({node:t,page:r});try{let y=await Tc({node:t,page:r,timeout:p,variables:i}),h=Math.round(performance.now()-l),k=y.assertions.some(b=>b.status==="failed"),x=await U({label:`Snapshot [${d}]`,fn:()=>ee({page:r,runStartTime:n,targets:m})});return{steps:[{annotations:x.annotations,assertions:y.assertions,detail:void 0,duration:h,nodeId:o,nodeType:t.type,screenshotBase64:x.screenshotBase64,snapshotTimestamp:x.snapshotTimestamp,status:k?"failed":"passed",stepIndex:s,title:d,url:x.url,viewportHeight:x.viewportHeight,viewportWidth:x.viewportWidth}],variables:y.variables}}catch(y){let h=Math.round(performance.now()-l),k=y instanceof Error?y.message:String(y),x=await U({label:`Snapshot [${d}] (error)`,fn:()=>ee({page:r,runStartTime:n,targets:m})});return{steps:[{annotations:x.annotations,assertions:[],detail:k,duration:h,nodeId:o,nodeType:t.type,screenshotBase64:x.screenshotBase64,snapshotTimestamp:x.snapshotTimestamp,status:"failed",stepIndex:s,title:d,url:x.url,viewportHeight:x.viewportHeight,viewportWidth:x.viewportWidth}],variables:i}}}function Pc(e){return["if","loop","forEach","parallel","try","group"].includes(e.type)}async function Rc({failFast:e,node:t,page:o,spec:r,startIndex:n,timeout:a,variables:s}){let i={executeSequence:kc,failFast:e,page:o,spec:r,startIndex:n,timeout:a,variables:s};switch(t.type){case"if":return Zt({...i,node:t});case"loop":return eo({...i,node:t});case"forEach":return to({...i,node:t});case"parallel":return oo({...i,node:t});case"try":return ro({...i,node:t});case"group":return no({...i,node:t})}}function xc(e){return e.some(t=>t.status==="failed")}function vc({nodeId:e,spec:t,timeout:o}){let r=t.nodes[e];if(r==null)throw new Error(`Node "${e}" not found in spec`);return r.timeout==null?{...r,timeout:o}:r}async function kc({failFast:e,nodeIds:t,page:o,spec:r,startIndex:n,timeout:a,variables:s}){let i=[],l=s;for(let d of t){let p=vc({nodeId:d,spec:r,timeout:a}),m=await ya({failFast:e,node:p,nodeId:d,page:o,runStartTime:0,spec:r,startIndex:n+i.length,variables:l});if(i.push(...m.steps),l=m.variables,e&&xc(m.steps))break}return{steps:i,variables:l}}async function Tc({node:e,page:t,timeout:o,variables:r}){if(Cc(e)){let a=await kt({node:e,page:t,timeout:o,variables:r});return{assertions:[],variables:a.variables}}return{assertions:await Nc({node:e,page:t,timeout:o,variables:r}),variables:r}}function Cc(e){return["goto","click","dblclick","fill","select","hover","press","check","uncheck","clear","rightClick","handleDialog","scroll","clipboard","setPermission","waitFor","waitForUrl","waitForResponse","waitForRequest","screenshot","setViewport","wait","fail","setVariable","extractText","upload","drag","scrollIntoView","type","focus"].includes(e.type)}async function Nc({node:e,page:t,timeout:o,variables:r}){let n=e;switch(n.type){case"assertVisible":return[await Te({locator:v({locator:n.locator,page:t}),timeout:o})];case"assertNotVisible":return[await Ce({locator:v({locator:n.locator,page:t}),timeout:o})];case"assertText":{let a=T({ref:n.expected,variables:r});return[await Gt({expected:a,locator:v({locator:n.locator,page:t}),operator:n.operator,timeout:o})]}case"assertUrl":{let a=T({ref:n.expected,variables:r});return[Ht({expected:a,operator:n.operator,url:t.url()})]}case"assertCount":{let a=vt({ref:n.expected,variables:r});return[await Jt({expected:a,locator:v({locator:n.locator,page:t}),operator:n.operator})]}case"assertValue":{let a=T({ref:n.expected,variables:r});return[await Yt({expected:a,locator:v({locator:n.locator,page:t}),operator:n.operator,timeout:o})]}case"assertAttribute":{let a=T({ref:n.expected,variables:r});return[await Hn({attribute:n.attribute,expected:a,locator:v({locator:n.locator,page:t}),operator:n.operator,timeout:o})]}case"assertEnabled":return[await Jn({locator:v({locator:n.locator,page:t}),timeout:o})];case"assertDisabled":return[await Yn({locator:v({locator:n.locator,page:t}),timeout:o})];case"assertTitle":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertCookie":case"assertResponse":return ma({node:n,page:t,timeout:o,variables:r})}}var wc,po=f(()=>{"use strict";Tt();Ne();ga();ao();Z();W();st();Re();G();wc=5e3});async function Ee({baseUrl:e,browser:t,cookies:o,extraVariables:r,navigateTo:n,onStep:a,runId:s,spec:i}){let l=await t.newContext({baseURL:e});u.info("Browser context created"),o.length>0&&await l.addCookies(o);let d=await l.newPage();u.info("Page created");let p=xe(d);n!=null&&(u.info("Navigating to: %s",n),await d.goto(n,{waitUntil:"domcontentloaded"}),u.info("Navigation complete"));function m(b){a?.(b),Ye({context:l,page:d,runId:s,stepIndex:b.stepIndex,stepResult:b})}let y={...Pe({defs:i.variables}),...r};u.info("Starting graph execution (entry: %s)",i.entryNode);let h=await uo({failFast:!0,onStep:m,page:d,spec:i,variables:y}),k=h.steps.filter(b=>b.status==="passed").length,x=h.steps.filter(b=>b.status==="failed").length,$={duration:h.steps.reduce((b,A)=>b+A.duration,0),failCount:x,passCount:k,runId:s,status:x>0?"failed":"passed",workflowName:""};return await Ke({monitor:p,runId:s,steps:h.steps,summary:$}),await l.close(),h.steps}var fo=f(()=>{"use strict";Ft();Qe();po();W();G()});import{z as it}from"zod";var mo,go=f(()=>{"use strict";mo=it.object({from:it.string().min(1).describe("Key of the source state in the states record"),to:it.string().min(1).describe("Key of the target state in the states record"),workflow:it.string().min(1).describe("Filename (without .json) of the workflow in .ripplo/workflows/ that executes this edge")}).describe("A directed edge between two states, executed by a workflow")});import{z as j}from"zod";var Ic,yo,ho,jc,Ac,Ve,wo=f(()=>{"use strict";Ic=j.object({precondition:j.string().min(1).describe("Name of the precondition to check or execute, e.g. 'auth:admin'")}).describe("Request payload sent by Ripplo to both the check and execute endpoints"),yo=j.object({satisfied:j.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),ho=j.object({data:j.record(j.string(),j.string()).optional().describe("Key-value data returned by the precondition. Values are injected as variables that can be interpolated into route patterns ({{key}}) and workflow spec variable references. For example, a data:project precondition should return { projectId: 'clx...' } so the route /projects/{{projectId}}/settings resolves correctly."),error:j.string().optional().describe("Human-readable error message if success is false"),navigateTo:j.string().optional().describe("URL to navigate the browser to after this precondition executes. Use this to set the starting page for the test \u2014 e.g. an auth token URL or the page the workflow begins on. If multiple preconditions return navigateTo, only the last one is used."),success:j.boolean().describe("Whether the precondition was successfully satisfied")}).describe("Response from PUT {preconditionApiUrl}/execute. Set-Cookie headers are automatically captured and injected into the browser context. The data field provides values for route param interpolation and workflow variables."),jc=j.object({preconditions:j.array(j.string().min(1)).describe("Names of all preconditions that were executed during this run")}).describe("Request payload sent after a run completes. Fire-and-forget \u2014 errors are logged but don't fail the run."),Ac=j.object({error:j.string().optional().describe("Human-readable error message if success is false"),success:j.boolean().describe("Whether teardown completed successfully")}).describe("Response from PUT {preconditionApiUrl}/teardown"),Ve=j.object({depends:j.array(j.string().min(1)).optional().describe("Names of other preconditions that must be satisfied first. Resolved via topological sort; cycles are rejected at validation time."),description:j.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:j.array(j.string().min(1)).optional().describe("Keys that the execute response's data field will contain. e.g. ['projectId', 'workflowId']. These are used for route param interpolation ({{projectId}}) and workflow variables. Declared here so generated types are strongly typed per precondition.")}).describe("A named precondition declared at the graph level. States reference these by name.")});import{z as lt}from"zod";var So,bo=f(()=>{"use strict";So=lt.object({preconditions:lt.array(lt.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:lt.string().min(1).describe("URL pattern with {{placeholders}} for dynamic segments, e.g. '/projects/{{projectId}}/settings'")}).describe("A distinct application state \u2014 a unique combination of location, auth context, and data conditions")});import{z as oe}from"zod";var ct,Po=f(()=>{"use strict";go();wo();bo();ct=oe.object({edges:oe.array(mo).describe("Directed edges between states, each executed by a workflow"),preconditions:oe.record(oe.string(),Ve).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:oe.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:oe.record(oe.string(),So).describe("States keyed by stable ID (kebab-case)"),version:oe.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions")});var ha=f(()=>{"use strict";Po()});var dt=f(()=>{"use strict";go();Po();wo();bo();ha()});import{parseSetCookie as $c}from"set-cookie-parser";import{z as wa}from"zod";async function De({apiUrl:e,cookies:t,executed:o}){if(o.length!==0)try{let r=await fetch(`${e}/teardown`,{body:JSON.stringify({preconditions:o}),headers:{"Content-Type":"application/json",...Ro({cookies:t})},method:"PUT"});r.ok||u.error("Teardown returned %s",String(r.status))}catch{u.error("Teardown request failed")}}function Ec({preconditionNames:e,preconditions:t}){let o=[],r=new Set;function n(a){if(r.has(a))return;r.add(a);let s=t[a];s?.depends!=null&&s.depends.forEach(i=>{n(i)}),o.push(a)}return e.forEach(a=>{n(a)}),o}async function Vc({apiUrl:e,cookies:t,name:o}){let r=await fetch(`${e}/check`,{body:JSON.stringify({precondition:o}),headers:{"Content-Type":"application/json",...Ro({cookies:t})},method:"POST"});if(!r.ok)return!1;let n=await r.json(),a=yo.safeParse(n);if(!a.success)throw new Error(`Check response for "${o}" has invalid shape: ${a.error.message}`);return a.data.satisfied}async function Dc({apiUrl:e,cookies:t,name:o}){let r=await fetch(`${e}/execute`,{body:JSON.stringify({precondition:o}),headers:{"Content-Type":"application/json",...Ro({cookies:t})},method:"PUT"});if(!r.ok)throw new Error(`Execute for "${o}" returned ${String(r.status)}`);let n=await r.json(),a=ho.safeParse(n);if(!a.success)throw new Error(`Execute response for "${o}" has invalid shape: ${a.error.message}`);if(!a.data.success){let i=a.data.error??"no error detail";throw new Error(`Precondition "${o}" failed to execute: ${i}`)}return{cookies:Oc({domain:new URL(e).hostname,res:r}),data:a.data.data??{},navigateTo:a.data.navigateTo}}function Ro({cookies:e}){return e.length===0?{}:{Cookie:e.map(o=>`${o.name}=${o.value}`).join("; ")}}function Oc({domain:e,res:t}){let o=t.headers.getSetCookie();return $c(o,{decodeValues:!1}).map(n=>Fc({cookie:n,domain:e}))}function Fc({cookie:e,domain:t}){let o={domain:e.domain??t,httpOnly:e.httpOnly??!1,name:e.name,path:e.path??"/",secure:e.secure??!1,value:e.value};return e.sameSite!=null&&(o.sameSite=Wc({raw:e.sameSite})),e.expires!=null?o.expires=Math.floor(e.expires.getTime()/1e3):e.maxAge!=null&&(o.expires=Math.floor(Date.now()/1e3)+e.maxAge),o}function Wc({raw:e}){return Uc[e.toLowerCase()]??"Lax"}async function ie({baseUrl:e,project:t,workflowSlug:o}){let r={apiUrl:void 0,cookies:[],data:{},executed:[],navigateTo:void 0},n=t.stateGraph;if(n==null)return r;let a=(n.edges??[]).find(p=>p.workflowSlug===o);if(a?.sourceState==null)return r;let s=zc({baseUrl:e,preconditionApiPath:t.preconditionApiPath}),i=a.sourceState.preconditions;if(i.length===0)return{...r,apiUrl:s};if(s==null)return r;let l=Lc.safeParse(n.preconditions);if(!l.success)return{...r,apiUrl:s};let d=await qc({apiUrl:s,preconditionNames:i,preconditions:l.data});return{apiUrl:s,cookies:d.cookies,data:d.data,executed:d.executed,navigateTo:d.navigateTo}}async function qc({apiUrl:e,preconditionNames:t,preconditions:o}){let r=Ec({preconditionNames:t,preconditions:o}),n=[],a={},s=[],i,l=Promise.resolve();return r.forEach(d=>{l=l.then(async()=>{if(await Vc({apiUrl:e,cookies:n,name:d}))return;let m=await Dc({apiUrl:e,cookies:n,name:d});n.push(...m.cookies),Object.entries(m.data).forEach(([y,h])=>{a[y]=h}),s.push(d),m.navigateTo!=null&&(i=m.navigateTo)})}),await l,{cookies:n,data:a,executed:s,navigateTo:i}}function zc({baseUrl:e,preconditionApiPath:t}){if(t.length!==0)return t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`}var Uc,Lc,xo=f(()=>{"use strict";dt();dt();W();Uc={lax:"Lax",none:"None",strict:"Strict"};Lc=wa.record(wa.string(),Ve)});import{graphql as vo}from"gql.tada";async function Oe({agentProfileId:e,config:t,runId:o}){let r=await C({config:t,document:Mc,variables:{agentProfileId:e??null,platform:"chromium",runId:o}});if(r.startRun==null)throw new Error("Failed to start run");let n=r.startRun.id,a=Promise.resolve();function s(l){a=a.then(()=>Bc({config:t,runResultId:n,steps:[l]})).catch(d=>{let p=d instanceof Error?d.message:"Unknown error";u.error("Failed to submit step %d: %s",l.stepIndex,p)})}async function i({statusOverride:l,steps:d,summary:p}){await a;let m=d.filter(x=>x.status==="passed").length,y=d.filter(x=>x.status==="failed").length,h=d.reduce((x,$)=>x+$.duration,0),k=l??(y>0?"failed":"passed");await C({config:t,document:Gc,variables:{duration:h,failCount:y,passCount:m,runResultId:n,status:k,summary:p??null,warnCount:0}})}return{complete:i,enqueueStep:s,runResultId:n}}async function Bc({config:e,runResultId:t,steps:o}){let r=o.map(n=>({annotations:n.annotations.map(a=>({height:a.height,label:a.label,type:a.type,width:a.width,x:a.x,y:a.y})),assertions:n.assertions.map(a=>({description:a.description,detail:a.detail,status:a.status})),detail:n.detail,duration:n.duration,nodeType:n.nodeType,screenshotBase64:n.screenshotBase64,snapshotTimestamp:n.snapshotTimestamp,status:n.status,stepIndex:n.stepIndex,title:n.title,url:n.url,viewportHeight:n.viewportHeight,viewportWidth:n.viewportWidth}));await C({config:e,document:_c,variables:{runResultId:t,steps:r}})}var Mc,_c,Gc,ko=f(()=>{"use strict";Ie();W();Mc=vo(`
|
|
95
95
|
mutation StartRunCLI($runId: String!, $platform: String!, $agentProfileId: String) {
|
|
96
96
|
startRun(runId: $runId, platform: $platform, agentProfileId: $agentProfileId) {
|
|
97
97
|
id
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
`),
|
|
100
|
+
`),_c=vo(`
|
|
101
101
|
mutation SubmitRunStepsCLI($runResultId: String!, $steps: [StepInput!]!) {
|
|
102
102
|
submitRunSteps(runResultId: $runResultId, steps: $steps)
|
|
103
103
|
}
|
|
104
|
-
`),
|
|
104
|
+
`),Gc=vo(`
|
|
105
105
|
mutation CompleteRunCLI(
|
|
106
106
|
$runResultId: String!
|
|
107
107
|
$status: String!
|
|
@@ -124,14 +124,14 @@ ${o}`].join(`
|
|
|
124
124
|
status
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
`)});import{graphql as ut,readFragment as To}from"gql.tada";async function No({agentProfileDescription:e,agentProfileId:t,baseUrl:o,browser:r,config:n,headed:a,runId:s,workflowId:i}){let l="unknown",d,p,m=!1;try{m=r==null,p=
|
|
127
|
+
`)});import{graphql as ut,readFragment as To}from"gql.tada";async function No({agentProfileDescription:e,agentProfileId:t,baseUrl:o,browser:r,config:n,headed:a,runId:s,workflowId:i}){let l="unknown",d,p,m=!1;try{m=r==null,p=Yc({externalBrowser:r,headed:a});let{project:y,workflow:h}=await U({label:"Run context resolved",fn:()=>ed({config:n,workflowId:i})});l=h.name;let k=od(h.spec);u.info("Executing workflow: %s",h.name),d=await U({label:"Streaming run started",fn:()=>Oe({agentProfileId:t,config:n,runId:s})}),await Qc({agentProfileDescription:e,agentProfileId:t,baseUrl:o,browserPromise:p,config:n,headed:a,ownsBrowser:m,project:y,runId:s,specData:k,streaming:d,workflow:h})}catch(y){throw await Kc({browserPromise:p,error:y,ownsBrowser:m,runId:s,streaming:d,workflowName:l}),y}}function Yc({externalBrowser:e,headed:t}){return e!=null?Promise.resolve(e):U({label:"Browser launched",fn:()=>K({headed:t})})}async function Kc({browserPromise:e,error:t,ownsBrowser:o,runId:r,streaming:n,workflowName:a}){let s=t instanceof Error?t.message:String(t),i=t instanceof Error?t.stack:void 0;await _n({error:s,runId:r,stack:i,workflowName:a}),n!=null&&await n.complete({statusOverride:"failed",steps:[],summary:s}).catch(()=>{}),o&&e!=null&&await(await e.catch(()=>{}))?.close()}async function Qc({agentProfileDescription:e,agentProfileId:t,baseUrl:o,browserPromise:r,config:n,headed:a,ownsBrowser:s,project:i,runId:l,specData:d,streaming:p,workflow:m}){let[y,h]=await Promise.all([U({label:"Preconditions resolved",fn:()=>ie({baseUrl:o,project:i,workflowSlug:m.slug})}),r]);if(t!=null){s&&await h.close(),await Xc({agentProfileDescription:e,agentProfileId:t,baseUrl:o,config:n,headed:a,preconditionResult:y,runId:l,specData:d,streaming:p,workflow:m});return}await Zc({baseUrl:o,browser:h,preconditionResult:y,runId:l,specData:d,streaming:p})}async function Xc({agentProfileDescription:e,agentProfileId:t,baseUrl:o,config:r,headed:n,preconditionResult:a,runId:s,specData:i,streaming:l,workflow:d}){let p=e!=null&&e.length>0?e:await td({config:r,profileId:t});await Mt({baseUrl:o,cookies:a.cookies,executedPreconditions:a.executed,extraVariables:a.data,headed:n,navigateTo:a.navigateTo,runId:s,serverUrl:r.ripploServerUrl,spec:i,streaming:l,systemPrompt:p,token:r.token,workflowContext:{description:d.name,expectedOutcome:d.name,name:d.name}}),await ba(a)}async function Zc({baseUrl:e,browser:t,preconditionResult:o,runId:r,specData:n,streaming:a}){let s=await U({label:"Spec executed",fn:()=>Ee({baseUrl:e,browser:t,cookies:o.cookies,extraVariables:o.data,navigateTo:o.navigateTo,onStep:a.enqueueStep,runId:r,spec:n})});await ba(o),await a.complete({statusOverride:void 0,steps:s,summary:void 0});let i=s.filter(d=>d.status==="passed").length,l=s.filter(d=>d.status==="failed").length;u.info("Run complete: %d passed, %d failed",i,l)}async function ba(e){e.apiUrl!=null&&await De({apiUrl:e.apiUrl,cookies:e.cookies,executed:e.executed})}async function ed({config:e,workflowId:t}){let o=await C({config:e,document:Hc,variables:{projectId:e.projectId}});if(o.project==null)throw new Error("Project not found");let n={...To(Sa,o.project),...e.baseUrl==null?{}:{baseUrl:e.baseUrl},...e.preconditionApiPath==null?{}:{preconditionApiPath:e.preconditionApiPath}},s=(n.workflows??[]).find(l=>To(Co,l).id===t);if(s==null)throw new Error(`Workflow ${t} not found`);let i=To(Co,s);return{project:n,workflow:i}}async function td({config:e,profileId:t}){let o=await C({config:e,document:Jc,variables:{id:t}});if(o.agentProfile==null)throw new Error(`Agent profile not found: ${t}`);let r=o.agentProfile,n=r.description;if(n==null||n.length===0)throw new Error(`Agent profile "${r.name}" has no description`);return u.info("Using agent profile: %s",r.name),ke({description:n,output:r.output??void 0,successCriteria:r.successCriteria??void 0})}function od(e){if(e==null)throw new Error("Workflow has no spec");let t=se(e);if(!t.success){let o=t.errors.map(r=>`${r.path}: ${r.message}`).join("; ");throw new Error(`Invalid spec: ${o}`)}return t.data}var Co,Sa,Hc,Jc,Pa=f(()=>{"use strict";$e();Lt();_t();Je();Ie();Qe();fo();W();st();xo();ko();Co=ut(`
|
|
128
128
|
fragment WorkflowRun on Workflow {
|
|
129
129
|
id
|
|
130
130
|
slug
|
|
131
131
|
name
|
|
132
132
|
spec
|
|
133
133
|
}
|
|
134
|
-
`),
|
|
134
|
+
`),Sa=ut(`
|
|
135
135
|
fragment ProjectRun on Project {
|
|
136
136
|
id
|
|
137
137
|
baseUrl
|
|
@@ -150,13 +150,13 @@ ${o}`].join(`
|
|
|
150
150
|
...WorkflowRun
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
`,[Co]),
|
|
153
|
+
`,[Co]),Hc=ut(`
|
|
154
154
|
query ProjectRun($projectId: String!) {
|
|
155
155
|
project(id: $projectId) {
|
|
156
156
|
...ProjectRun
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
`,[
|
|
159
|
+
`,[Sa]),Jc=ut(`
|
|
160
160
|
query AgentProfileRun($id: String!) {
|
|
161
161
|
agentProfile(id: $id) {
|
|
162
162
|
id
|
|
@@ -166,7 +166,7 @@ ${o}`].join(`
|
|
|
166
166
|
successCriteria
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
`)});var O=f(()=>{"use strict";Tt();Wt();Lt();_t();Ne();Je();
|
|
169
|
+
`)});var O=f(()=>{"use strict";Tt();Wt();Lt();_t();Ne();Je();aa();Ie();Qt();ca();ao();Pa();fo();po();Z();W();st();xo();Re();ko();G()});import rd from"fs";import nd from"path";import{z as D}from"zod";function Ra(e){return nd.join(e,".ripplo","graph.json")}function xa(e){let t=rd.readFileSync(e,"utf8"),o=JSON.parse(t);return ad.parse(o)}function va(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}var ad,ka=f(()=>{"use strict";ad=D.object({edges:D.array(D.object({from:D.string(),to:D.string(),workflow:D.string()})),preconditions:D.record(D.string(),D.unknown()).optional(),resetPrecondition:D.string().optional(),states:D.record(D.string(),D.object({preconditions:D.array(D.string()),route:D.string()})),version:D.literal(3)})});import sd from"fs";import id from"path";import{z as ge}from"zod";function Fe(e){return id.join(e,".ripplo","workflows")}function Io(e){let t=sd.readFileSync(e,"utf8"),o=JSON.parse(t);return ld.parse(o)}var ld,Ta=f(()=>{"use strict";$e();ld=ge.object({additionalChecks:ge.array(ge.string()).default([]),description:ge.string(),expectedOutcome:ge.string(),name:ge.string(),spec:Ae})});var $o={};is($o,{deleteWorkflowFile:()=>fd,duplicateWorkflowFile:()=>md,startFileWatcher:()=>Ao,syncAll:()=>jo});import cd from"crypto";import re from"fs";import Ue from"path";import{watch as dd}from"chokidar";import{graphql as ud}from"gql.tada";async function jo(e){let t=await Ia(e);return u.info("Synced %d workflow(s) + graph to dev session",ja(e.cwd)),t}function Ao({config:e,cwd:t,lastHash:o}){let r=Ue.join(t,".ripplo"),n=o,a,s=dd(r,{depth:2,ignoreInitial:!0,interval:1e3,persistent:!0,usePolling:!0});s.on("all",(l,d)=>{d.endsWith(".json")&&(a!=null&&clearTimeout(a),a=setTimeout(()=>{i({config:e,cwd:t})},500))});async function i(l){try{let d=Ca(l.cwd),p=Na(d);if(p===n)return;n=p,await Ia(l),u.info("Dev session synced (%d workflow(s))",ja(l.cwd))}catch(d){let p=d instanceof Error?d.message:"Unknown error";u.error("Sync failed: %s",p)}}return function(){a!=null&&clearTimeout(a),s.close()}}function Ca(e){let t=Ra(e),o=xa(t),r=JSON.stringify(va(o)),n=Fe(e),s=(re.existsSync(n)?re.readdirSync(n).filter(i=>i.endsWith(".json")):[]).map(i=>{let l=Ue.join(n,i),d=Io(l),p=i.replace(/\.json$/,"");return{description:d.description,expectedOutcome:d.expectedOutcome,name:d.name,slug:p,spec:JSON.stringify(d.spec)}});return{graphSpec:r,workflows:s}}function Na(e){return cd.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Ia({config:e,cwd:t}){let o=Ca(t),r=Na(o),n=await C({config:e,document:pd,variables:{graphSpec:o.graphSpec,projectId:e.projectId,workflows:[...o.workflows]}});if(n.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:n.syncDevSession.id,hash:r}}function ja(e){let t=Fe(e);return re.existsSync(t)?re.readdirSync(t).filter(o=>o.endsWith(".json")).length:0}function fd({cwd:e,slug:t}){let o=Ue.join(Fe(e),`${t}.json`);return re.existsSync(o)?(re.unlinkSync(o),!0):!1}function md({cwd:e,newSlug:t,sourceSlug:o}){let r=Fe(e),n=Ue.join(r,`${o}.json`);if(!re.existsSync(n))return!1;let a=Io(n),s={...a,name:`${a.name} (copy)`};return re.writeFileSync(Ue.join(r,`${t}.json`),JSON.stringify(s,null,2)),!0}var pd,pt=f(()=>{"use strict";ka();Ta();O();pd=ud(`
|
|
170
170
|
mutation SyncDevSession(
|
|
171
171
|
$projectId: String!
|
|
172
172
|
$graphSpec: String!
|
|
@@ -176,13 +176,13 @@ ${o}`].join(`
|
|
|
176
176
|
id
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
`)});O();import{config as
|
|
179
|
+
`)});O();import{config as rs}from"dotenv";import Pt from"path";import{fileURLToPath as Ou}from"url";O();pt();import{availableParallelism as gd}from"os";import{createClient as yd}from"graphql-sse";import{graphql as We}from"gql.tada";import{print as Eo}from"graphql";import{input as hd}from"@inquirer/prompts";import wd from"p-limit";var Sd=We(`
|
|
180
180
|
mutation EndDevSession($projectId: String!) {
|
|
181
181
|
endDevSession(projectId: $projectId) {
|
|
182
182
|
id
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
`),
|
|
185
|
+
`),bd=We(`
|
|
186
186
|
subscription RunRequestedDev {
|
|
187
187
|
runRequested {
|
|
188
188
|
agentProfileDescription
|
|
@@ -192,7 +192,7 @@ ${o}`].join(`
|
|
|
192
192
|
workflowId
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
`),
|
|
195
|
+
`),Pd=We(`
|
|
196
196
|
query PendingDevRuns($devSessionId: String!) {
|
|
197
197
|
pendingDevRuns(devSessionId: $devSessionId) {
|
|
198
198
|
id
|
|
@@ -205,14 +205,14 @@ ${o}`].join(`
|
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
`),
|
|
208
|
+
`),Rd=We(`
|
|
209
209
|
subscription DevWorkflowDeleteRequested($projectId: String!) {
|
|
210
210
|
devWorkflowDeleteRequested(projectId: $projectId) {
|
|
211
211
|
projectId
|
|
212
212
|
slug
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
`),
|
|
215
|
+
`),xd=We(`
|
|
216
216
|
subscription DevWorkflowDuplicateRequested($projectId: String!) {
|
|
217
217
|
devWorkflowDuplicateRequested(projectId: $projectId) {
|
|
218
218
|
projectId
|
|
@@ -220,16 +220,16 @@ ${o}`].join(`
|
|
|
220
220
|
newSlug
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
`);async function ft({concurrency:e,headed:t}){let o=B();if(o==null)return E("Not logged in. Run: ripplo login");let r=process.cwd();u.info("Starting dev session...");let n=await
|
|
223
|
+
`);async function ft({concurrency:e,headed:t}){let o=B();if(o==null)return E("Not logged in. Run: ripplo login");let r=process.cwd();u.info("Starting dev session...");let n=await Dd(o),{devSessionId:a,hash:s}=await jo({config:o,cwd:r}),i=Ao({config:o,cwd:r,lastHash:s});u.info("Connecting to %s...",o.ripploServerUrl);let l=o,d=yd({headers:{Authorization:`Bearer ${l.token}`},on:{connected:b=>{b&&u.info("Reconnected.")},connecting:b=>{b&&u.info("Reconnecting to server...")}},retryAttempts:1/0,url:`${l.ripploServerUrl}/graphql`,retry:async b=>{let A=Math.min(1e3*2**b,3e4);u.warn("Connection lost. Reconnecting in %dms...",A),await new Promise(ne=>{setTimeout(ne,A)})}});async function p(){i(),d.dispose();try{await C({config:l,document:Sd,variables:{projectId:l.projectId}}),u.info("Dev session ended.")}catch{u.warn("Failed to clean up dev session.")}}process.on("SIGINT",()=>{p().then(()=>process.exit(0))}),process.on("SIGTERM",()=>{p().then(()=>process.exit(0))}),process.on("uncaughtException",b=>{u.error("Unexpected error: %s",b.message),p().then(()=>process.exit(1))}),process.on("unhandledRejection",b=>{let A=b instanceof Error?b.message:String(b);u.error("Unhandled rejection: %s",A),p().then(()=>process.exit(1))}),u.info("Dev mode active. Watching files + waiting for runs...");let m=new Set,y=e??gd();u.info("Max concurrent runs: %d",y);let h=wd(y),k=d.iterate({query:Eo(bd)}),x=d.iterate({query:Eo(Rd),variables:{projectId:o.projectId}}),$=d.iterate({query:Eo(xd),variables:{projectId:o.projectId}});await Promise.all([vd({activeRunIds:m,baseUrl:n,config:o,headed:t,limiter:h,subscription:k}),Td({activeRunIds:m,baseUrl:n,config:o,devSessionId:a,headed:t,limiter:h}),jd({cwd:r,subscription:x}),$d({cwd:r,subscription:$})])}async function vd({activeRunIds:e,baseUrl:t,config:o,headed:r,limiter:n,subscription:a}){for await(let s of a){let i=Vd(s);i!=null&&(e.has(i.runId)||(u.info("Run requested: %s (workflow %s)",i.runId,i.workflowId),e.add(i.runId),n(()=>Aa({agentProfileDescription:i.agentProfileDescription,agentProfileId:i.agentProfileId,baseUrl:t,config:o,headed:r,runId:i.runId,workflowId:i.workflowId}).finally(()=>{e.delete(i.runId)}))))}}var kd=5e3;async function Td({activeRunIds:e,baseUrl:t,config:o,devSessionId:r,headed:n,limiter:a}){for(;;)await new Promise(s=>{setTimeout(s,kd)}),await Cd({activeRunIds:e,baseUrl:t,config:o,devSessionId:r,headed:n,limiter:a})}async function Cd({activeRunIds:e,baseUrl:t,config:o,devSessionId:r,headed:n,limiter:a}){try{let s=await C({config:o,document:Pd,variables:{devSessionId:r}});if(s.pendingDevRuns==null)throw new Error("pendingDevRuns returned null");s.pendingDevRuns.filter(l=>!e.has(l.id)).forEach(l=>{let d=l.workflow?.id;d!=null&&(u.info("Polling picked up run: %s (workflow %s)",l.id,d),e.add(l.id),a(()=>Aa({agentProfileDescription:l.agentProfile?.description??void 0,agentProfileId:l.agentProfile?.id??void 0,baseUrl:t,config:o,headed:n,runId:l.id,workflowId:d}).finally(()=>{e.delete(l.id)})))})}catch(s){let i=s instanceof Error?s.message:String(s);u.warn("Polling for pending runs failed: %s",i)}}async function Aa({agentProfileDescription:e,agentProfileId:t,baseUrl:o,config:r,headed:n,runId:a,workflowId:s}){try{let i=B()??r,l=i.baseUrl??o;await je({maxRuns:100}),await No({agentProfileDescription:e,agentProfileId:t,baseUrl:l,browser:void 0,config:i,headed:n,runId:a,workflowId:s})}catch(i){Nd({error:i,runId:a})}}function Nd({error:e,runId:t}){let o=e instanceof Error?e.message:String(e);if(o.includes("already claimed")){u.info("Run %s already claimed by another instance, skipping",t);return}u.error("Run failed: %s",o)}function Id(e){if(!("runId"in e)||!("workflowId"in e)||!("executor"in e)||typeof e.runId!="string"||typeof e.workflowId!="string"||typeof e.executor!="string")return;let t="agentProfileId"in e&&typeof e.agentProfileId=="string"?e.agentProfileId:void 0;return{agentProfileDescription:"agentProfileDescription"in e&&typeof e.agentProfileDescription=="string"?e.agentProfileDescription:void 0,agentProfileId:t,executor:e.executor,runId:e.runId,workflowId:e.workflowId}}async function jd({cwd:e,subscription:t}){let{deleteWorkflowFile:o}=await Promise.resolve().then(()=>(pt(),$o));for await(let r of t){let n=Ad(r);if(n==null)continue;o({cwd:e,slug:n})?u.info("Deleted workflow file: %s.json",n):u.warn("Workflow file not found for deletion: %s.json",n)}}function Ad(e){if(typeof e!="object"||e==null||!("data"in e))return;let t=e.data;if(typeof t!="object"||t==null||!("devWorkflowDeleteRequested"in t))return;let o=t.devWorkflowDeleteRequested;if(!(typeof o!="object"||o==null||!("slug"in o))&&typeof o.slug=="string")return o.slug}async function $d({cwd:e,subscription:t}){let{duplicateWorkflowFile:o}=await Promise.resolve().then(()=>(pt(),$o));for await(let r of t){let n=Ed(r);if(n==null)continue;o({cwd:e,newSlug:n.newSlug,sourceSlug:n.sourceSlug})?u.info("Duplicated workflow: %s.json \u2192 %s.json",n.sourceSlug,n.newSlug):u.warn("Source workflow file not found for duplication: %s.json",n.sourceSlug)}}function Ed(e){if(typeof e!="object"||e==null||!("data"in e))return;let t=e.data;if(typeof t!="object"||t==null||!("devWorkflowDuplicateRequested"in t))return;let o=t.devWorkflowDuplicateRequested;if(!(typeof o!="object"||o==null)&&!(!("sourceSlug"in o)||!("newSlug"in o)||typeof o.sourceSlug!="string"||typeof o.newSlug!="string"))return{newSlug:o.newSlug,sourceSlug:o.sourceSlug}}function Vd(e){if(typeof e!="object"||e==null||!("data"in e))return;let t=e.data;if(typeof t!="object"||t==null||!("runRequested"in t))return;let o=t.runRequested;if(!(typeof o!="object"||o==null))return Id(o)}async function Dd(e){if(e.baseUrl!=null)return e.baseUrl;let t=await hd({default:"http://localhost:3000",message:"Base URL (local dev server):"});return Q({...e,baseUrl:t}),t}$e();O();import{readFileSync as $a}from"fs";import{graphql as Le,readFragment as Vo}from"gql.tada";async function Ea(e){let t=await qd(e);u.info("Starting agent test against %s",t.baseUrl);let o=await Fd({config:t.config,workflowId:t.workflowId});u.info("Created run: %s",o);let r=await Oe({agentProfileId:t.agentProfileId,config:t.config,runId:o}),n=await K({headed:e.headed}),a=await n.newContext({baseURL:t.baseUrl});t.cookies.length>0&&(await a.addCookies([...t.cookies]),u.info("Injected %d cookies from preconditions",t.cookies.length));let s=await a.newPage();t.navigateTo!=null&&(u.info("Navigating to precondition start page: %s",t.navigateTo),await s.goto(t.navigateTo,{waitUntil:"domcontentloaded"}));try{let i=await ve({baseUrl:t.baseUrl,executedPreconditions:t.executedPreconditions,extraVariables:t.extraVariables,onStep:r.enqueueStep,page:s,runId:o,serverUrl:t.config.ripploServerUrl,spec:t.spec,systemPrompt:t.systemPrompt,token:t.config.token,workflowContext:t.workflowContext}),l=i.verdict==="pass"?"passed":"failed";await r.complete({statusOverride:l,steps:i.steps,summary:i.findings}),u.info(`
|
|
224
224
|
=== Agent Summary ===
|
|
225
|
-
%s`,i.findings),
|
|
225
|
+
%s`,i.findings),Ud({result:i})}finally{await n.close()}}var Od=Le(`
|
|
226
226
|
mutation CreateRunAgentTest($workflowId: String!, $platforms: [String!]!, $concurrency: Int!) {
|
|
227
227
|
createRun(workflowId: $workflowId, platforms: $platforms, concurrency: $concurrency) {
|
|
228
228
|
id
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
`);async function
|
|
232
|
-
=== Summary ===`),u.info("Steps: %d",e.steps.length);let t=e.steps.filter(r=>r.status==="passed").length,o=e.steps.filter(r=>r.status==="failed").length;u.info("Passed: %d, Failed: %d",t,o),u.info("Generated spec has %d nodes",Object.keys(e.generatedSpec.nodes).length)}var
|
|
231
|
+
`);async function Fd({config:e,workflowId:t}){let o=await C({config:e,document:Od,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});return o.createRun==null?E("Failed to create run"):o.createRun.id}function Ud({result:e}){u.info(`
|
|
232
|
+
=== Summary ===`),u.info("Steps: %d",e.steps.length);let t=e.steps.filter(r=>r.status==="passed").length,o=e.steps.filter(r=>r.status==="failed").length;u.info("Passed: %d, Failed: %d",t,o),u.info("Generated spec has %d nodes",Object.keys(e.generatedSpec.nodes).length)}var Wd=Le(`
|
|
233
233
|
query AgentProfileForCLI($id: String!) {
|
|
234
234
|
agentProfile(id: $id) {
|
|
235
235
|
id
|
|
@@ -248,7 +248,7 @@ ${o}`].join(`
|
|
|
248
248
|
expectedOutcome
|
|
249
249
|
spec
|
|
250
250
|
}
|
|
251
|
-
`),
|
|
251
|
+
`),Va=Le(`
|
|
252
252
|
fragment ProjectAgentTest on Project {
|
|
253
253
|
id
|
|
254
254
|
baseUrl
|
|
@@ -267,14 +267,14 @@ ${o}`].join(`
|
|
|
267
267
|
...WorkflowAgentTest
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
`,[Do]),
|
|
270
|
+
`,[Do]),Ld=Le(`
|
|
271
271
|
query ProjectAgentTest($projectId: String!) {
|
|
272
272
|
project(id: $projectId) {
|
|
273
273
|
...ProjectAgentTest
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
|
-
`,[
|
|
277
|
-
`),o=
|
|
276
|
+
`,[Va]);async function qd(e){let t=zd(),o=await Bd({config:t,params:e}),r=await _d({config:t,params:e});if(r==null)return E("No workflow. Provide --workflow <id>");let n=e.url??r.baseUrl,a=r.spec??(e.specPath==null?void 0:Jd(e.specPath));return o==null?E("No system prompt. Provide --agent-profile <id> or --prompt <text|file>"):{agentProfileId:e.agentProfileId,baseUrl:n,config:t,cookies:r.cookies,executedPreconditions:r.executedPreconditions,extraVariables:r.extraVariables,navigateTo:r.navigateTo,spec:a,systemPrompt:o,workflowContext:r.workflowContext,workflowId:r.workflowId}}function zd(){let e=B();return e??E("Not logged in. Run: ripplo login")}async function Bd({config:e,params:t}){if(t.agentProfileId!=null&&e!=null)return Md({config:e,profileId:t.agentProfileId});if(t.promptArg!=null)return Hd(t.promptArg)}async function Md({config:e,profileId:t}){let o=await C({config:e,document:Wd,variables:{id:t}});if(o.agentProfile==null)return E(`Agent profile not found: ${t}`);let r=o.agentProfile,n=r.description;return n==null||n.length===0?E(`Agent profile "${r.name}" has no description to use as system prompt`):(u.info("Using agent profile: %s",r.name),ke({description:n,output:r.output??void 0,successCriteria:r.successCriteria??void 0}))}async function _d({config:e,params:t}){if(t.workflowId==null||e==null)return;let o=await Gd(e),n={...Vo(Va,o),...e.baseUrl==null?{}:{baseUrl:e.baseUrl},...e.preconditionApiPath==null?{}:{preconditionApiPath:e.preconditionApiPath}},s=(n.workflows??[]).find(m=>Vo(Do,m).id===t.workflowId);if(s==null)return E(`Workflow not found: ${t.workflowId}`);let i=Vo(Do,s);u.info("Using workflow: %s",i.name);let l=await ie({baseUrl:n.baseUrl,project:n,workflowSlug:i.slug}),d=i.spec==null?void 0:Da(i.spec),p={description:i.description,expectedOutcome:i.expectedOutcome,name:i.name};return{baseUrl:n.baseUrl,cookies:l.cookies,executedPreconditions:l.executed,extraVariables:l.data,navigateTo:l.navigateTo,spec:d,workflowContext:p,workflowId:i.id}}async function Gd(e){let t=await C({config:e,document:Ld,variables:{projectId:e.projectId}});return t.project==null?E("Project not found. Check your config."):t.project}function Hd(e){try{return $a(e,"utf8")}catch{return e}}function Jd(e){let t=JSON.parse($a(e,"utf8"));return Da(t)}function Da(e){let t=se(e);if(!t.success){let o=t.errors.map(r=>`${r.path}: ${r.message}`).join("; ");return E(`Invalid spec: ${o}`)}return t.data}dt();O();import qe from"fs";import ye from"path";function Fa({graphPath:e,outputPath:t}){let o=Kd(e),r=Qd(o),n=Object.entries(r.preconditions).map(([l,d])=>({name:l,returns:d.returns}));if(n.length===0){u.warn("No preconditions found in graph. Nothing to generate.");return}let a=Xd(n),s=Yd({graphPath:o,outputPath:t}),i=ye.dirname(s);qe.existsSync(i)||qe.mkdirSync(i,{recursive:!0}),qe.writeFileSync(s,a),u.info("Generated %s with %d precondition(s)",s,n.length)}function Yd({graphPath:e,outputPath:t}){return t!=null?ye.resolve(t):ye.join(ye.dirname(e),"..","generated","precondition-api.ts")}function Kd(e){if(e!=null)return ye.resolve(e);let t=ye.join(process.cwd(),".ripplo","graph.json");if(!qe.existsSync(t))throw new Error("No .ripplo/graph.json found.");return t}function Qd(e){let t=qe.readFileSync(e,"utf8"),o=JSON.parse(t),r=typeof o=="object"&&o!=null&&"_meta"in o?Object.fromEntries(Object.entries(o).filter(([a])=>a!=="_meta")):o,n=ct.safeParse(r);if(!n.success){let a=n.error.issues.map(s=>`${s.path.join(".")}: ${s.message}`).join("; ");throw new Error(`Invalid graph: ${a}`)}return n.data}function Xd(e){let t=e.map(r=>` "${r.name}"`).join(`,
|
|
277
|
+
`),o=Zd(e);return`// Generated by: ripplo generate-types
|
|
278
278
|
// Do not edit manually \u2014 regenerate when graph preconditions change.
|
|
279
279
|
|
|
280
280
|
import { z } from "zod";
|
|
@@ -323,15 +323,15 @@ export const PreconditionTeardownResponseSchema = z.object({
|
|
|
323
323
|
error: z.string().optional(),
|
|
324
324
|
});
|
|
325
325
|
export type PreconditionTeardownResponse = z.infer<typeof PreconditionTeardownResponseSchema>;
|
|
326
|
-
`}function
|
|
326
|
+
`}function Oa(e){return e.split(/[^a-zA-Z0-9]/).map(t=>{let o=t[0];return o==null?"":o.toUpperCase()+t.slice(1)}).join("")}function Zd(e){let t=e.filter(n=>n.returns!=null&&n.returns.length>0);if(t.length===0)return"export type PreconditionDataMap = Record<PreconditionName, Record<string, string>>;";let o=t.map(n=>{let a=Oa(n.name),s=n.returns.map(i=>` readonly ${i}: string;`).join(`
|
|
327
327
|
`);return`export interface ${a}Data {
|
|
328
328
|
${s}
|
|
329
|
-
}`}),r=e.map(n=>{let s=n.returns!=null&&n.returns.length>0?`${
|
|
329
|
+
}`}),r=e.map(n=>{let s=n.returns!=null&&n.returns.length>0?`${Oa(n.name)}Data`:"Record<string, never>";return` readonly "${n.name}": ${s};`});return[...o,"",`export interface PreconditionDataMap {
|
|
330
330
|
${r.join(`
|
|
331
331
|
`)}
|
|
332
332
|
}`].join(`
|
|
333
333
|
|
|
334
|
-
`)}O();import Wo from"fs";import Lo from"path";O();import
|
|
334
|
+
`)}O();import Wo from"fs";import Lo from"path";O();import ou from"crypto";import ru from"http";import{exec as nu}from"child_process";import{z as Ua}from"zod";var eu="https://ripplo.ai",Oo="https://ripplo-dev.up.railway.app",tu=Ua.object({RIPPLO_SERVER_URL:Ua.string().min(1).default(eu)}),Wa;function La(){return Wa??=tu.parse(process.env),Wa}var au=`<!DOCTYPE html>
|
|
335
335
|
<html lang="en">
|
|
336
336
|
<head>
|
|
337
337
|
<meta charset="utf-8" />
|
|
@@ -368,7 +368,7 @@ ${r.join(`
|
|
|
368
368
|
</div>
|
|
369
369
|
<script>setTimeout(function(){window.close()},3000)</script>
|
|
370
370
|
</body>
|
|
371
|
-
</html>`;async function mt({url:e}){let t=e??
|
|
371
|
+
</html>`;async function mt({url:e}){let t=e??La().RIPPLO_SERVER_URL,o=ou.randomBytes(16).toString("hex"),{port:r,tokenPromise:n}=await su(o),a=`${t}/cli/authorize?port=${String(r)}&state=${encodeURIComponent(o)}`;u.info("Opening browser to authorize..."),u.info("If the browser doesn't open, visit: %s",a),lu(a);let s=await n;u.info("Authorized successfully.");let i={cloudBaseUrl:"",projectId:"",ripploServerUrl:t,token:s};return Q(i),i}function su(e){return new Promise(t=>{let o,r=new Promise(a=>{o=a}),n=ru.createServer((a,s)=>{let i=new URL(a.url??"","http://localhost");if(i.pathname!=="/callback"){s.writeHead(404),s.end();return}let l=i.searchParams.get("state"),d=i.searchParams.get("token");if(l!==e){s.writeHead(400,{"Content-Type":"text/html"}),s.end("<html><body><h1>Invalid state parameter</h1></body></html>");return}if(d==null){s.writeHead(400,{"Content-Type":"text/html"}),s.end("<html><body><h1>Missing token</h1></body></html>");return}s.writeHead(200,{"Content-Type":"text/html"}),s.end(au),n.close(),o(d)});n.listen(0,()=>{let a=n.address();if(a==null||typeof a=="string")throw new Error("Failed to get server address");t({port:a.port,tokenPromise:r})})})}function iu(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function lu(e){let t=iu();nu(`${t} "${e}"`,()=>{})}O();import yt from"fs";import le from"path";import{fileURLToPath as qa}from"url";import{z as gt}from"zod";var cu=gt.looseObject({mcpServers:gt.record(gt.string(),gt.unknown())});function ht(){let e=le.join(process.cwd(),".mcp.json"),t=du()?{args:[uu()],command:"node"}:{args:["-y","--package","ripplo@latest","ripplo-mcp"],command:"npx"},o=pu(e),r={...o,mcpServers:{...o.mcpServers,ripplo:t}};yt.writeFileSync(e,JSON.stringify(r,null,2)),u.info("Wrote MCP config to %s",e)}function du(){let e=qa(import.meta.url),t=le.dirname(le.dirname(e));return yt.existsSync(le.join(t,"tsup.config.ts"))}function uu(){let e=qa(import.meta.url),t=le.dirname(le.dirname(e));return le.join(t,"mcp","index.js")}function pu(e){if(!yt.existsSync(e))return{mcpServers:{}};let t=JSON.parse(yt.readFileSync(e,"utf8")),o=cu.safeParse(t);return o.success?o.data:{mcpServers:{}}}O();import fu from"path";import{input as Fo,select as mu}from"@inquirer/prompts";import{graphql as Ba}from"gql.tada";var gu=Ba(`
|
|
372
372
|
query ProjectsCLI {
|
|
373
373
|
projects {
|
|
374
374
|
id
|
|
@@ -377,7 +377,7 @@ ${r.join(`
|
|
|
377
377
|
cloudBaseUrl
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
|
-
`);async function wt(e){let t=await C({config:e,document:
|
|
380
|
+
`);async function wt(e){let t=await C({config:e,document:gu,variables:void 0});if(t.projects==null)throw new Error("Failed to fetch projects");return t.projects.map(o=>({baseUrl:o.baseUrl,cloudBaseUrl:o.cloudBaseUrl,id:o.id,name:o.name}))}var za="__create_new__",yu=Ba(`
|
|
381
381
|
mutation CreateProjectShared(
|
|
382
382
|
$name: String!
|
|
383
383
|
$baseUrl: String!
|
|
@@ -396,8 +396,8 @@ ${r.join(`
|
|
|
396
396
|
name
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
-
`);async function St({config:e,projects:t}){if(t.length===1){let n=t[0];if(n==null)throw new Error("No project found");return u.info("Auto-selected project: %s",n.name),n}let o=[...t.map(n=>({name:n.name,value:n.id})),{name:"+ Create new project",value:
|
|
400
|
-
`)}O();async function
|
|
399
|
+
`);async function St({config:e,projects:t}){if(t.length===1){let n=t[0];if(n==null)throw new Error("No project found");return u.info("Auto-selected project: %s",n.name),n}let o=[...t.map(n=>({name:n.name,value:n.id})),{name:"+ Create new project",value:za}],r=await mu({choices:o,message:"Select a project:"});if(r!==za){let n=t.find(a=>a.id===r);if(n==null)throw new Error("Selected project not found");return n}return Uo({config:e})}async function Uo({config:e}){let t=process.cwd(),o=fu.basename(t),r=await Fo({default:o,message:"Project name:"}),n=await Fo({default:"http://localhost:3000",message:"Base URL (local dev server):"}),a=await Fo({message:"Deployed environment URL (staging):"}),s=await C({config:e,document:yu,variables:{baseUrl:n,cloudBaseUrl:a,name:r,provider:"local",repoUrl:t}});if(s.createProject==null)throw new Error("Failed to create project");return u.info("Created project: %s",s.createProject.name),{baseUrl:n,cloudBaseUrl:a,id:s.createProject.id,name:s.createProject.name}}async function Ma({url:e}){let t=await hu({url:e});u.info("\u2713 Logged in");let o=await wu({config:t});u.info("\u2713 Selected project: %s",o.name),await new Promise(a=>{process.stderr.write("",()=>{a()})});let r=t.baseUrl??o.baseUrl,n={...t,baseUrl:r,cloudBaseUrl:o.cloudBaseUrl,projectId:o.id};Q(n),bu(process.cwd()),u.info("\u2713 Created .ripplo/"),ht(),u.info("\u2713 Installed MCP config into .mcp.json"),zt(),u.info("Starting dev mode..."),await ft({concurrency:void 0,headed:!1})}async function hu({url:e}){let t=B();return t??(u.info("Not logged in. Let's authenticate first."),mt({url:e}))}async function wu({config:e}){let t=await wt(e);return t.length===0?Uo({config:e}):St({config:e,projects:t})}var Su={edges:[],preconditions:{},states:{},version:3};function bu(e){let t=Lo.join(e,".ripplo"),o=Lo.join(t,"graph.json"),r=Lo.join(t,"workflows");Wo.mkdirSync(r,{recursive:!0}),Wo.existsSync(o)||Wo.writeFileSync(o,JSON.stringify(Su,null,2)+`
|
|
400
|
+
`)}O();async function _a({url:e}){let t=await mt({url:e}),o=await wt(t),r=await St({config:t,projects:o});Q({...t,projectId:r.id}),u.info("Logged in to project: %s",r.id),process.exit(0)}O();import{search as Nu}from"@inquirer/prompts";import J from"chalk";import Iu from"ora";$e();O();import{graphql as bt,readFragment as he}from"gql.tada";O();import{graphql as Pu}from"gql.tada";var Ru=Pu(`
|
|
401
401
|
mutation SubmitRunResultsCLI(
|
|
402
402
|
$runId: String!
|
|
403
403
|
$platform: String!
|
|
@@ -424,7 +424,7 @@ ${r.join(`
|
|
|
424
424
|
status
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
`);async function
|
|
427
|
+
`);async function Ga({config:e,runId:t,steps:o}){let r=o.filter(i=>i.status==="passed").length,n=o.filter(i=>i.status==="failed").length,a=o.reduce((i,l)=>i+l.duration,0),s=n>0?"failed":"passed";await C({config:e,document:Ru,variables:{agentProfileId:null,duration:a,failCount:n,passCount:r,platform:"chromium",runId:t,status:s,steps:o,warnCount:0}})}var we=bt(`
|
|
428
428
|
fragment WorkflowCore on Workflow {
|
|
429
429
|
id
|
|
430
430
|
name
|
|
@@ -432,7 +432,7 @@ ${r.join(`
|
|
|
432
432
|
source
|
|
433
433
|
spec
|
|
434
434
|
}
|
|
435
|
-
`),
|
|
435
|
+
`),Ha=bt(`
|
|
436
436
|
fragment ProjectCore on Project {
|
|
437
437
|
id
|
|
438
438
|
name
|
|
@@ -456,17 +456,17 @@ ${r.join(`
|
|
|
456
456
|
...WorkflowCore
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
|
-
`,[we]),
|
|
459
|
+
`,[we]),xu=bt(`
|
|
460
460
|
query ProjectCore($projectId: String!) {
|
|
461
461
|
project(id: $projectId) {
|
|
462
462
|
...ProjectCore
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
|
-
`,[
|
|
465
|
+
`,[Ha]),vu=bt(`
|
|
466
466
|
mutation CreateRunCore($workflowId: String!, $platforms: [String!]!, $concurrency: Int!) {
|
|
467
467
|
createRun(workflowId: $workflowId, platforms: $platforms, concurrency: $concurrency) {
|
|
468
468
|
id
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
|
-
`);async function
|
|
472
|
-
Run \`npm install -g ${
|
|
471
|
+
`);async function Ja({config:e,headed:t,onStep:o,workflowId:r,workflowName:n}){await je({maxRuns:100});let a=await Ka(e),s=a.workflows??[],i=ku({workflowId:r,workflowName:n,workflows:s}),l=he(we,i),d=Tu(l.spec),[p,m,y]=await Promise.all([U({label:"Preconditions resolved",fn:()=>ie({baseUrl:a.baseUrl,project:a,workflowSlug:l.slug})}),U({label:"Browser launched",fn:()=>K({headed:t})}),Cu({config:e,workflowId:l.id})]),h=await U({label:"Spec executed",fn:()=>Ee({baseUrl:a.baseUrl,browser:m,cookies:p.cookies,extraVariables:p.data,navigateTo:p.navigateTo,onStep:o,runId:y,spec:d})});await m.close(),await Ga({config:e,runId:y,steps:h}),p.apiUrl!=null&&await De({apiUrl:p.apiUrl,cookies:p.cookies,executed:p.executed});let k=h.filter(b=>b.status==="passed").length,x=h.filter(b=>b.status==="failed").length;return{duration:h.reduce((b,A)=>b+A.duration,0),failed:x,passed:k,runId:y,steps:h,workflowName:l.name}}async function Ya({config:e}){return((await Ka(e)).workflows??[]).map(r=>he(we,r)).map(r=>({id:r.id,name:r.name,source:r.source}))}async function Ka(e){let t=await C({config:e,document:xu,variables:{projectId:e.projectId}});if(t.project==null)throw new Error("No project found. Check your config.");return{...he(Ha,t.project),...e.baseUrl==null?{}:{baseUrl:e.baseUrl},...e.preconditionApiPath==null?{}:{preconditionApiPath:e.preconditionApiPath}}}function ku({workflowId:e,workflowName:t,workflows:o}){if(e!=null){let r=o.find(n=>he(we,n).id===e);if(r==null)throw new Error(`Workflow with ID "${e}" not found`);return r}if(t!=null){let r=o.find(n=>he(we,n).name.toLowerCase()===t.toLowerCase());if(r==null){let n=o.map(a=>he(we,a).name).join(", ");throw new Error(`Workflow "${t}" not found. Available: ${n}`)}return r}throw new Error("Either workflowId or workflowName must be provided")}function Tu(e){if(e==null)throw new Error("Workflow has no spec defined");let t=se(e);if(!t.success){let o=t.errors.map(r=>`${r.path}: ${r.message}`).join("; ");throw new Error(`Invalid spec: ${o}`)}return t.data}async function Cu({config:e,workflowId:t}){let o=await C({config:e,document:vu,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});if(o.createRun==null)throw new Error("Failed to create run");return o.createRun.id}async function Qa({headed:e,workflowId:t}){let o=B();if(o==null)return E("Not logged in. Run: ripplo login");let r=t??await ju(o);if(r==null)return E("No workflow selected.");let n=Iu("Running workflow...").start(),a=await Ja({config:o,headed:e,onStep:void 0,workflowId:r,workflowName:void 0});n.stop(),Au(a.steps)}async function ju(e){let o=(await Ya({config:e})).map(r=>({name:`${r.name} (${r.source})`,value:r.id}));return Nu({message:"Select a workflow:",source:r=>r==null?o:o.filter(n=>n.name.toLowerCase().includes(r.toLowerCase()))})}function Au(e){let t=e.filter(n=>n.status==="passed").length,o=e.filter(n=>n.status==="failed").length,r=e.reduce((n,a)=>n+a.duration,0);u.info("Results:"),e.forEach(n=>{$u(n)}),u.info("%s, %s %s",J.green(`${String(t)} passed`),J.red(`${String(o)} failed`),J.dim(`${String(r)}ms`))}function $u(e){let t=e.status==="passed"?J.green("\u2713"):J.red("\u2717");u.info(" %s %s %s",t,e.title,J.dim(`${String(e.duration)}ms`)),e.assertions.forEach(o=>{let r=o.status==="passed"?J.green("\u2713"):J.red("\u2717"),n=o.detail==null?"":J.dim(` \u2014 ${o.detail}`);u.info(" %s %s%s",r,o.description,n)}),e.detail!=null&&u.info(" %s",J.dim(e.detail))}O();function Xa(){if(B()==null)return E("Not logged in. Run: ripplo login");ht(),u.info("Restart Claude Code to pick up the new MCP server."),process.exit(0)}O();import Eu from"chalk";import{z as Za}from"zod";var es="0.0.4",ts="ripplo",Vu=Za.object({version:Za.string()});function os(){Du().then(e=>{e==null||e===es||u.info(Eu.yellow(`Update available: ${es} \u2192 ${e}
|
|
472
|
+
Run \`npm install -g ${ts}\` to update`))}).catch(()=>{})}async function Du(){let e=new AbortController,t=setTimeout(()=>{e.abort()},3e3);try{let o=await fetch(`https://registry.npmjs.org/${ts}/latest`,{headers:{accept:"application/json"},signal:e.signal});if(!o.ok)return;let r=await o.json();return Vu.parse(r).version}catch{return}finally{clearTimeout(t)}}var ns=Pt.resolve(Pt.dirname(Ou(import.meta.url)),"..");rs({path:Pt.join(ns,".env.local"),quiet:!0});rs({path:Pt.join(ns,".env"),quiet:!0});async function Fu(){os();let e=process.argv[2],t=e==null?void 0:Hu[e];if(t==null){Ju();return}await t()}function Uu(){let e=process.argv.slice(3),t=e.indexOf("--output"),o=t===-1?void 0:e[t+1];return{graphPath:e.find(n=>!n.startsWith("--")&&n!==o),outputPath:o}}function Wu(){if(process.argv.includes("--dev"))return Oo;let e=process.argv.indexOf("--url");if(e!==-1)return process.argv[e+1]}function Lu(){return _a({url:Wu()})}function qu(){let e=process.argv.includes("--dev")?Oo:void 0;return Ma({url:e})}function zu(){let e=process.argv.includes("--headed"),t=process.argv.slice(3).find(o=>!o.startsWith("--"));return Qa({headed:e,workflowId:t})}function Bu(){let e=Uu();Fa(e)}function Mu(){let e=process.argv.slice(3),t=_u(e);return t.agentProfileId==null&&t.promptArg==null?(u.error("Usage: ripplo agent-test (--agent-profile <id> | --prompt <text|file>) [--workflow <id> | --url <url>] [--spec <file>] [--headed]"),Promise.resolve()):Ea(t)}function _u(e){return{agentProfileId:ze(e,"--agent-profile"),headed:e.includes("--headed"),promptArg:ze(e,"--prompt"),specPath:ze(e,"--spec"),url:ze(e,"--url"),workflowId:ze(e,"--workflow")}}function ze(e,t){let o=e.indexOf(t);return o===-1?void 0:e[o+1]}function Gu(){let e=process.argv.slice(3),t=e.includes("--headed"),o=e.indexOf("--concurrency"),r=o===-1?void 0:Number(e[o+1]),n=r!=null&&Number.isFinite(r)&&r>0?r:void 0;return ft({concurrency:n,headed:t})}var Hu={"agent-test":Mu,dev:Gu,"generate-types":Bu,init:qu,login:Lu,run:zu,"setup-mcp":Xa};function Ju(){u.info("Usage: ripplo <command>"),u.info(" login Authenticate with Ripplo"),u.info(" init Create a new project (no GitHub required)"),u.info(" run Execute a workflow spec via Playwright"),u.info(" dev Start dev mode: watch files + run workflows from the UI"),u.info(" agent-test Run an autonomous agent test locally"),u.info(" setup-mcp Configure MCP server in .mcp.json"),u.info(" generate-types Generate Zod schemas + TS types for precondition API")}Fu().catch(e=>{u.error(e,"Unexpected error"),process.exit(1)});export{Fu as main};
|
package/dist/mcp/index.js
CHANGED
|
@@ -36,21 +36,21 @@ ${n}`}}});import{z as _t}from"zod";var Fo=20,Uo=2,Do=_t.object({pattern:_t.strin
|
|
|
36
36
|
---
|
|
37
37
|
`)}}});function Wo({contextLines:e,lines:t,maxResults:r,pattern:o}){let n=new RegExp(o,"i"),s=[];return t.forEach((l,d)=>{if(s.length>=r||!n.test(l))return;let i=Math.max(0,d-e),u=Math.min(t.length-1,d+e),h=t.slice(i,u+1).map((E,te)=>{let Wr=i+te+1;return`${i+te===d?">":" "} ${String(Wr)}: ${E}`}).join(`
|
|
38
38
|
`);s.push(h)}),s}import{z as xe}from"zod";var qo=xe.object({selector:xe.string().describe("CSS selector for the select element"),value:xe.string().describe("The option value to select")}),Mt=c({description:"Select an option from a dropdown/select element",name:"select",schema:qo,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).selectOption(t.value,{timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"select",value:{type:"static",value:t.value}};return p({assertions:[],detail:`Selected "${t.value}" in ${t.selector}`,duration:performance.now()-r,nodeType:"select",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Select ${t.value}`})}});import{z as Gt}from"zod";var Lo=Gt.object({selector:Gt.string().describe("CSS selector for the checkbox to uncheck")}),zt=c({description:"Uncheck a checkbox matching the CSS selector",name:"uncheck",schema:Lo,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).uncheck({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"uncheck"};return p({assertions:[],detail:`Unchecked ${t.selector}`,duration:performance.now()-r,nodeType:"uncheck",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Uncheck ${t.selector}`})}});import{z as Ht}from"zod";var _o=Ht.object({ms:Ht.number().describe("Milliseconds to wait")}),Jt=c({description:"Wait for a specified duration in milliseconds",name:"wait",schema:_o,execute:async(e,t)=>{let r=performance.now();await e.page.waitForTimeout(t.ms);let o=`agent-step-${String(e.stepIndex)}`,n={duration:t.ms,id:o,type:"wait"};return p({assertions:[],detail:`Waited ${String(t.ms)}ms`,duration:performance.now()-r,nodeType:"wait",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Wait ${String(t.ms)}ms`})}});import{z as Pe}from"zod";var Bo=Pe.object({selector:Pe.string().describe("CSS selector for the element to wait for"),state:Pe.enum(["visible","hidden","attached","detached"]).default("visible").describe("The state to wait for (default: visible)")}),Kt=c({description:"Wait for an element matching the CSS selector to reach the specified state. More reliable than a blind wait \u2014 use this to wait for elements to appear, disappear, or attach/detach from the DOM.",name:"wait_for",schema:Bo,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).waitFor({state:t.state,timeout:15e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},state:t.state,type:"waitFor"};return p({assertions:[],detail:`Waited for ${t.selector} to be ${t.state}`,duration:performance.now()-r,nodeType:"waitFor",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Wait for ${t.selector} to be ${t.state}`})}});var Te=[$t,at,ut,Et,tt,zt,Mt,Nt,Jt,Kt,Ut,St,Bt,ot,Vt,Ft,Pt,st,Ct,Ze,Ye,Qe,Me,Je,ze,Ke,ft,ht,yt,kt,bt,xt,Wt,Lt,jt,dt,lt],yd=new Map(Te.map(e=>[e.name,e])),Mo=Te.map(e=>e.anthropicTool),Go=Te.map(e=>`- **${e.name}**: ${e.anthropicTool.description??""}`).join(`
|
|
39
|
-
`);import zo from"pino";var N=zo({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}});import{execFileSync as Ed}from"child_process";import{createRequire as Od}from"module";import Fd from"fs";import{chromium as
|
|
39
|
+
`);import zo from"pino";var N=zo({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}});import{execFileSync as Ed}from"child_process";import{createRequire as Od}from"module";import Fd from"fs";import Dd from"path";import{chromium as qd}from"playwright";import{mkdir as Md,writeFile as Gd}from"fs/promises";import Hd from"path";import{readdir as au,rm as su,stat as iu}from"fs/promises";import Zo from"path";import{graphql as en}from"gql.tada";import{print as Yo}from"graphql";async function V(e){let t=Yo(e.document),r=JSON.stringify({query:t,variables:e.variables}),n=await(await fetch(`${e.config.ripploServerUrl}/graphql`,{body:r,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST"})).json();if(!Qo(n))throw new Error("Invalid GraphQL response");if(Xo(n))throw new Error(n.errors.map(s=>s.message).join(", "));if(n.data==null)throw new Error("No data returned from server");return n.data}function Qo(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function Xo(e){return Array.isArray(e.errors)&&e.errors.length>0}var pu=Zo.join(process.cwd(),".ripplo","debug"),fu=360*60*1e3,mu=en(`
|
|
40
40
|
mutation RevokeCurrentCliToken {
|
|
41
41
|
revokeCurrentCliToken
|
|
42
42
|
}
|
|
43
|
-
`);import tr from"fs";import Ne from"path";import{z as F}from"zod";var on=F.object({baseUrl:F.string().optional(),cloudBaseUrl:F.string(),preconditionApiPath:F.string().optional(),projectId:F.string()}),nn=F.object({ripploServerUrl:F.string(),token:F.string()}),an=on.extend(nn.shape),or=Ne.join(process.cwd(),".ripplo"),sn=Ne.join(or,"settings.json"),ln=Ne.join(or,"settings.local.json");function rr(e){if(!tr.existsSync(e))return null;let t=tr.readFileSync(e,"utf8");return JSON.parse(t)}function Ce(){let e=rr(sn),t=rr(ln);if(e==null||t==null)return null;let r=an.safeParse({...e,...t});return r.success?r.data:null}import{z as a}from"zod";import{z as C}from"zod";import{z as y}from"zod";var dn=y.object({by:y.literal("css"),value:y.string().min(1)}),un=y.object({by:y.literal("testId"),value:y.string().min(1)}),pn=y.object({by:y.literal("role"),exact:y.boolean().optional(),name:y.string().optional(),role:y.string().min(1)}),fn=y.object({by:y.literal("text"),exact:y.boolean().optional(),value:y.string().min(1)}),mn=y.object({by:y.literal("label"),exact:y.boolean().optional(),value:y.string().min(1)}),hn=y.object({by:y.literal("placeholder"),value:y.string().min(1)}),gn=y.object({by:y.literal("altText"),value:y.string().min(1)}),m=y.discriminatedUnion("by",[dn,un,pn,fn,mn,hn,gn]);import{z as nr}from"zod";var R=nr.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),j=nr.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]);import{z as S}from"zod";var yn=S.object({type:S.literal("static"),value:S.union([S.string(),S.number(),S.boolean()])}),Ae=S.object({name:S.string().min(1),type:S.literal("variable")}),U=S.discriminatedUnion("type",[yn,Ae]),g=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.string()}),Ae]),W=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.number().int().nonnegative()}),Ae]);var q=C.discriminatedUnion("type",[C.object({locator:m,type:C.literal("elementVisible")}),C.object({locator:m,type:C.literal("elementNotVisible")}),C.object({expected:g,operator:R,type:C.literal("urlMatch")}),C.object({expected:g,locator:m,operator:R,type:C.literal("textMatch")}),C.object({expected:U,operator:j,type:C.literal("variableCompare"),variable:C.string().min(1)})]);import{z as P}from"zod";var z=P.discriminatedUnion("type",[P.object({default:P.string().optional(),type:P.literal("string")}),P.object({default:P.number().optional(),type:P.literal("number")}),P.object({default:P.boolean().optional(),type:P.literal("boolean")}),P.object({key:P.string().min(1),type:P.literal("env")})]);var wn=a.string().min(1),O=a.array(wn).min(1),f={comment:a.string().optional(),id:a.string().min(1),label:a.string().optional(),next:a.string().optional(),timeout:a.number().int().positive().optional()},bn=a.object({...f,type:a.literal("goto"),url:g}),Sn=a.object({...f,locator:m,type:a.literal("click")}),kn=a.object({...f,locator:m,type:a.literal("fill"),value:g}),Rn=a.object({...f,locator:m,type:a.literal("select"),value:g}),vn=a.object({...f,locator:m,type:a.literal("hover")}),xn=a.object({...f,key:a.string().min(1),locator:m.optional(),type:a.literal("press")}),Pn=a.object({...f,locator:m,type:a.literal("check")}),Tn=a.object({...f,locator:m,type:a.literal("uncheck")}),Nn=a.object({...f,type:a.literal("screenshot")}),Cn=a.object({...f,height:a.number().int().positive(),type:a.literal("setViewport"),width:a.number().int().positive()}),An=a.object({...f,duration:a.number().int().positive(),type:a.literal("wait")}),$n=a.object({...f,message:a.string().min(1),type:a.literal("fail")}),In=a.object({...f,type:a.literal("setVariable"),value:U,variable:a.string().min(1)}),En=a.object({...f,locator:m,type:a.literal("extractText"),variable:a.string().min(1)}),jn=a.object({...f,files:a.array(a.string()).min(1),locator:m,type:a.literal("upload")}),On=a.object({...f,locator:m,type:a.literal("dblclick")}),Vn=a.object({...f,source:m,target:m,type:a.literal("drag")}),Fn=a.object({...f,locator:m,type:a.literal("scrollIntoView")}),Un=a.object({...f,locator:m,type:a.literal("type"),value:g}),Dn=a.object({...f,locator:m,type:a.literal("focus")}),Wn=a.object({...f,locator:m,type:a.literal("clear")}),qn=a.object({...f,locator:m,type:a.literal("rightClick")}),Ln=a.object({...f,action:a.enum(["accept","dismiss"]),promptText:a.string().optional(),type:a.literal("handleDialog")}),_n=a.object({...f,locator:m.optional(),type:a.literal("scroll"),x:a.number().int().optional(),y:a.number().int().optional()}),Bn=a.object({...f,action:a.enum(["read","write"]),type:a.literal("clipboard"),value:g.optional(),variable:a.string().min(1).optional()}),Mn=a.object({...f,permission:a.string().min(1),state:a.enum(["granted","prompt"]),type:a.literal("setPermission")}),Gn=a.object({...f,locator:m,state:a.enum(["visible","hidden","attached","detached"]).optional(),type:a.literal("waitFor")}),zn=a.object({...f,expected:g,operator:R,type:a.literal("waitForUrl")}),Hn=a.object({...f,type:a.literal("waitForResponse"),urlPattern:g}),Jn=a.object({...f,type:a.literal("waitForRequest"),urlPattern:g}),Kn=a.object({...f,locator:m,type:a.literal("assertVisible")}),Yn=a.object({...f,locator:m,type:a.literal("assertNotVisible")}),Qn=a.object({...f,expected:g,locator:m,operator:R,type:a.literal("assertText")}),Xn=a.object({...f,expected:g,operator:R,type:a.literal("assertUrl")}),Zn=a.object({...f,expected:W,locator:m,operator:j,type:a.literal("assertCount")}),ea=a.object({...f,expected:g,locator:m,operator:R,type:a.literal("assertValue")}),ta=a.object({...f,attribute:a.string().min(1),expected:g,locator:m,operator:R,type:a.literal("assertAttribute")}),ra=a.object({...f,locator:m,type:a.literal("assertEnabled")}),oa=a.object({...f,locator:m,type:a.literal("assertDisabled")}),na=a.object({...f,expected:g,operator:R,type:a.literal("assertTitle")}),aa=a.object({...f,locator:m,type:a.literal("assertChecked")}),sa=a.object({...f,locator:m,type:a.literal("assertNotChecked")}),ia=a.object({...f,locator:m,type:a.literal("assertFocused")}),la=a.object({...f,httpOnly:a.boolean().optional(),name:g,operator:R.optional(),sameSite:a.enum(["Strict","Lax","None"]).optional(),secure:a.boolean().optional(),type:a.literal("assertCookie"),value:g.optional()}),ca=a.object({...f,bodyContains:g.optional(),headerContains:a.object({name:a.string().min(1),value:g}).optional(),status:a.number().int().positive().optional(),type:a.literal("assertResponse"),urlPattern:g}),da=a.object({...f,alternate:O.optional(),condition:q,consequent:O,type:a.literal("if")}),ua=a.object({...f,body:O,iteratorVar:a.string().min(1).optional(),times:a.number().int().positive(),type:a.literal("loop")}),pa=a.object({...f,body:O,collection:a.union([a.array(a.record(a.string(),a.unknown())).min(1),a.object({name:a.string().min(1),type:a.literal("variable")})]),iteratorVar:a.string().min(1),type:a.literal("forEach")}),fa=a.object({...f,branches:a.array(O).min(2),type:a.literal("parallel")}),ma=a.object({...f,body:O,catch:O.optional(),finally:O.optional(),type:a.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),ha=a.object({...f,nodes:O,type:a.literal("group")}),X=a.discriminatedUnion("type",[bn,Sn,kn,Rn,vn,xn,Pn,Tn,Gn,zn,Hn,Jn,Kn,Yn,Qn,Xn,Zn,ea,ta,ra,oa,Nn,Cn,An,$n,In,En,jn,On,Vn,Fn,Un,Dn,Wn,qn,Ln,_n,Bn,Mn,na,aa,sa,ia,la,ca,da,ua,pa,fa,ha]),ar=a.union([X,ma]),L=a.object({entryNode:a.string().min(1),nodes:a.record(a.string(),ar),variables:a.record(a.string(),z).optional(),version:a.literal(2)});function ne(e){let t=L.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(r=>({message:r.message,path:r.path.join(".")})),success:!1}}import{graphql as ce,readFragment as yf}from"gql.tada";import{z as ae}from"zod";var $e=ae.object({from:ae.string().min(1).describe("Key of the source state in the states record"),to:ae.string().min(1).describe("Key of the target state in the states record"),workflow:ae.string().min(1).describe("Filename (without .json) of the workflow in .ripplo/workflows/ that executes this edge")}).describe("A directed edge between two states, executed by a workflow");import{z as D}from"zod";import{z as b}from"zod";var Ie=b.object({precondition:b.string().min(1).describe("Name of the precondition to check or execute, e.g. 'auth:admin'")}).describe("Request payload sent by Ripplo to both the check and execute endpoints"),se=b.object({satisfied:b.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),ie=b.object({data:b.record(b.string(),b.string()).optional().describe("Key-value data returned by the precondition. Values are injected as variables that can be interpolated into route patterns ({{key}}) and workflow spec variable references. For example, a data:project precondition should return { projectId: 'clx...' } so the route /projects/{{projectId}}/settings resolves correctly."),error:b.string().optional().describe("Human-readable error message if success is false"),navigateTo:b.string().optional().describe("URL to navigate the browser to after this precondition executes. Use this to set the starting page for the test \u2014 e.g. an auth token URL or the page the workflow begins on. If multiple preconditions return navigateTo, only the last one is used."),success:b.boolean().describe("Whether the precondition was successfully satisfied")}).describe("Response from PUT {preconditionApiUrl}/execute. Set-Cookie headers are automatically captured and injected into the browser context. The data field provides values for route param interpolation and workflow variables."),Ee=b.object({preconditions:b.array(b.string().min(1)).describe("Names of all preconditions that were executed during this run")}).describe("Request payload sent after a run completes. Fire-and-forget \u2014 errors are logged but don't fail the run."),je=b.object({error:b.string().optional().describe("Human-readable error message if success is false"),success:b.boolean().describe("Whether teardown completed successfully")}).describe("Response from PUT {preconditionApiUrl}/teardown"),_=b.object({depends:b.array(b.string().min(1)).optional().describe("Names of other preconditions that must be satisfied first. Resolved via topological sort; cycles are rejected at validation time."),description:b.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:b.array(b.string().min(1)).optional().describe("Keys that the execute response's data field will contain. e.g. ['projectId', 'workflowId']. These are used for route param interpolation ({{projectId}}) and workflow variables. Declared here so generated types are strongly typed per precondition.")}).describe("A named precondition declared at the graph level. States reference these by name.");import{z as le}from"zod";var Oe=le.object({preconditions:le.array(le.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:le.string().min(1).describe("URL pattern with {{placeholders}} for dynamic segments, e.g. '/projects/{{projectId}}/settings'")}).describe("A distinct application state \u2014 a unique combination of location, auth context, and data conditions");var Z=D.object({edges:D.array($e).describe("Directed edges between states, each executed by a workflow"),preconditions:D.record(D.string(),_).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:D.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:D.record(D.string(),Oe).describe("States keyed by stable ID (kebab-case)"),version:D.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions");function Ve(e){let t=Z.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(r=>({message:r.message,path:r.path.join(".")})),success:!1}}function Aa(e){let t=e.preconditions,r=new Set,o=new Set,n=[];function s(l){if(o.has(l)){n.push(`Precondition "${l}" has a circular dependency`);return}if(r.has(l))return;r.add(l),o.add(l);let d=t[l];d?.depends!=null&&d.depends.forEach(i=>{s(i)}),o.delete(l)}return Object.keys(t).forEach(l=>{s(l)}),n}function Fe(e){let t=[],r=new Set(Object.keys(e.preconditions)),o=new Set(Object.keys(e.states));e.edges.forEach((i,u)=>{o.has(i.from)||t.push({message:`References non-existent source state "${i.from}"`,path:`edges[${String(u)}].from`}),o.has(i.to)||t.push({message:`References non-existent target state "${i.to}"`,path:`edges[${String(u)}].to`})}),Object.entries(e.states).forEach(([i,u])=>{u.preconditions.forEach(h=>{r.has(h)||t.push({message:`References non-existent precondition "${h}"`,path:`states.${i}.preconditions`})})}),Object.entries(e.preconditions).forEach(([i,u])=>{u.depends!=null&&u.depends.forEach(h=>{r.has(h)||t.push({message:`Depends on non-existent precondition "${h}"`,path:`preconditions.${i}.depends`})})}),e.resetPrecondition!=null&&!r.has(e.resetPrecondition)&&t.push({message:`References non-existent precondition "${e.resetPrecondition}"`,path:"resetPrecondition"});let n=new Set(e.edges.flatMap(i=>[i.from,i.to]));Object.keys(e.states).forEach(i=>{n.has(i)||t.push({message:"State is not referenced by any edge (orphan)",path:`states.${i}`})});let s=new Set;Object.values(e.states).forEach(i=>{i.preconditions.forEach(u=>s.add(u))}),Object.values(e.preconditions).forEach(i=>{i.depends!=null&&i.depends.forEach(u=>s.add(u))}),e.resetPrecondition!=null&&s.add(e.resetPrecondition),Object.keys(e.preconditions).forEach(i=>{s.has(i)||t.push({message:"Defined but never used by any state or dependency",path:`preconditions.${i}`})});let l=new Set;return e.edges.forEach((i,u)=>{let h=`${i.from}|${i.to}|${i.workflow}`;l.has(h)&&t.push({message:`Duplicate edge from "${i.from}" to "${i.to}" with workflow "${i.workflow}"`,path:`edges[${String(u)}]`}),l.add(h)}),Aa(e).forEach(i=>t.push({message:i,path:"preconditions"})),t}import{parseSetCookie as tf}from"set-cookie-parser";import{z as ir}from"zod";var nf=ir.record(ir.string(),_);import{graphql as Ue}from"gql.tada";var df=Ue(`
|
|
43
|
+
`);import tr from"fs";import Ne from"path";import{z as F}from"zod";var on=F.object({baseUrl:F.string().optional(),cloudBaseUrl:F.string(),preconditionApiPath:F.string().optional(),projectId:F.string()}),nn=F.object({ripploServerUrl:F.string(),token:F.string()}),an=on.extend(nn.shape),or=Ne.join(process.cwd(),".ripplo"),sn=Ne.join(or,"settings.json"),ln=Ne.join(or,"settings.local.json");function rr(e){if(!tr.existsSync(e))return null;let t=tr.readFileSync(e,"utf8");return JSON.parse(t)}function Ce(){let e=rr(sn),t=rr(ln);if(e==null||t==null)return null;let r=an.safeParse({...e,...t});return r.success?r.data:null}import{z as a}from"zod";import{z as C}from"zod";import{z as y}from"zod";var dn=y.object({by:y.literal("css"),value:y.string().min(1)}),un=y.object({by:y.literal("testId"),value:y.string().min(1)}),pn=y.object({by:y.literal("role"),exact:y.boolean().optional(),name:y.string().optional(),role:y.string().min(1)}),fn=y.object({by:y.literal("text"),exact:y.boolean().optional(),value:y.string().min(1)}),mn=y.object({by:y.literal("label"),exact:y.boolean().optional(),value:y.string().min(1)}),hn=y.object({by:y.literal("placeholder"),value:y.string().min(1)}),gn=y.object({by:y.literal("altText"),value:y.string().min(1)}),m=y.discriminatedUnion("by",[dn,un,pn,fn,mn,hn,gn]);import{z as nr}from"zod";var R=nr.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),j=nr.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]);import{z as S}from"zod";var yn=S.object({type:S.literal("static"),value:S.union([S.string(),S.number(),S.boolean()])}),Ae=S.object({name:S.string().min(1),type:S.literal("variable")}),U=S.discriminatedUnion("type",[yn,Ae]),g=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.string()}),Ae]),W=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.number().int().nonnegative()}),Ae]);var q=C.discriminatedUnion("type",[C.object({locator:m,type:C.literal("elementVisible")}),C.object({locator:m,type:C.literal("elementNotVisible")}),C.object({expected:g,operator:R,type:C.literal("urlMatch")}),C.object({expected:g,locator:m,operator:R,type:C.literal("textMatch")}),C.object({expected:U,operator:j,type:C.literal("variableCompare"),variable:C.string().min(1)})]);import{z as P}from"zod";var z=P.discriminatedUnion("type",[P.object({default:P.string().optional(),type:P.literal("string")}),P.object({default:P.number().optional(),type:P.literal("number")}),P.object({default:P.boolean().optional(),type:P.literal("boolean")}),P.object({key:P.string().min(1),type:P.literal("env")})]);var wn=a.string().min(1),O=a.array(wn).min(1),f={comment:a.string().optional(),id:a.string().min(1),label:a.string().optional(),next:a.string().optional(),timeout:a.number().int().positive().optional()},bn=a.object({...f,type:a.literal("goto"),url:g}),Sn=a.object({...f,locator:m,type:a.literal("click")}),kn=a.object({...f,locator:m,type:a.literal("fill"),value:g}),Rn=a.object({...f,locator:m,type:a.literal("select"),value:g}),vn=a.object({...f,locator:m,type:a.literal("hover")}),xn=a.object({...f,key:a.string().min(1),locator:m.optional(),type:a.literal("press")}),Pn=a.object({...f,locator:m,type:a.literal("check")}),Tn=a.object({...f,locator:m,type:a.literal("uncheck")}),Nn=a.object({...f,type:a.literal("screenshot")}),Cn=a.object({...f,height:a.number().int().positive(),type:a.literal("setViewport"),width:a.number().int().positive()}),An=a.object({...f,duration:a.number().int().positive(),type:a.literal("wait")}),$n=a.object({...f,message:a.string().min(1),type:a.literal("fail")}),In=a.object({...f,type:a.literal("setVariable"),value:U,variable:a.string().min(1)}),En=a.object({...f,locator:m,type:a.literal("extractText"),variable:a.string().min(1)}),jn=a.object({...f,files:a.array(a.string()).min(1),locator:m,type:a.literal("upload")}),On=a.object({...f,locator:m,type:a.literal("dblclick")}),Vn=a.object({...f,source:m,target:m,type:a.literal("drag")}),Fn=a.object({...f,locator:m,type:a.literal("scrollIntoView")}),Un=a.object({...f,locator:m,type:a.literal("type"),value:g}),Dn=a.object({...f,locator:m,type:a.literal("focus")}),Wn=a.object({...f,locator:m,type:a.literal("clear")}),qn=a.object({...f,locator:m,type:a.literal("rightClick")}),Ln=a.object({...f,action:a.enum(["accept","dismiss"]),promptText:a.string().optional(),type:a.literal("handleDialog")}),_n=a.object({...f,locator:m.optional(),type:a.literal("scroll"),x:a.number().int().optional(),y:a.number().int().optional()}),Bn=a.object({...f,action:a.enum(["read","write"]),type:a.literal("clipboard"),value:g.optional(),variable:a.string().min(1).optional()}),Mn=a.object({...f,permission:a.string().min(1),state:a.enum(["granted","prompt"]),type:a.literal("setPermission")}),Gn=a.object({...f,locator:m,state:a.enum(["visible","hidden","attached","detached"]).optional(),type:a.literal("waitFor")}),zn=a.object({...f,expected:g,operator:R,type:a.literal("waitForUrl")}),Hn=a.object({...f,type:a.literal("waitForResponse"),urlPattern:g}),Jn=a.object({...f,type:a.literal("waitForRequest"),urlPattern:g}),Kn=a.object({...f,locator:m,type:a.literal("assertVisible")}),Yn=a.object({...f,locator:m,type:a.literal("assertNotVisible")}),Qn=a.object({...f,expected:g,locator:m,operator:R,type:a.literal("assertText")}),Xn=a.object({...f,expected:g,operator:R,type:a.literal("assertUrl")}),Zn=a.object({...f,expected:W,locator:m,operator:j,type:a.literal("assertCount")}),ea=a.object({...f,expected:g,locator:m,operator:R,type:a.literal("assertValue")}),ta=a.object({...f,attribute:a.string().min(1),expected:g,locator:m,operator:R,type:a.literal("assertAttribute")}),ra=a.object({...f,locator:m,type:a.literal("assertEnabled")}),oa=a.object({...f,locator:m,type:a.literal("assertDisabled")}),na=a.object({...f,expected:g,operator:R,type:a.literal("assertTitle")}),aa=a.object({...f,locator:m,type:a.literal("assertChecked")}),sa=a.object({...f,locator:m,type:a.literal("assertNotChecked")}),ia=a.object({...f,locator:m,type:a.literal("assertFocused")}),la=a.object({...f,httpOnly:a.boolean().optional(),name:g,operator:R.optional(),sameSite:a.enum(["Strict","Lax","None"]).optional(),secure:a.boolean().optional(),type:a.literal("assertCookie"),value:g.optional()}),ca=a.object({...f,bodyContains:g.optional(),headerContains:a.object({name:a.string().min(1),value:g}).optional(),status:a.number().int().positive().optional(),type:a.literal("assertResponse"),urlPattern:g}),da=a.object({...f,alternate:O.optional(),condition:q,consequent:O,type:a.literal("if")}),ua=a.object({...f,body:O,iteratorVar:a.string().min(1).optional(),times:a.number().int().positive(),type:a.literal("loop")}),pa=a.object({...f,body:O,collection:a.union([a.array(a.record(a.string(),a.unknown())).min(1),a.object({name:a.string().min(1),type:a.literal("variable")})]),iteratorVar:a.string().min(1),type:a.literal("forEach")}),fa=a.object({...f,branches:a.array(O).min(2),type:a.literal("parallel")}),ma=a.object({...f,body:O,catch:O.optional(),finally:O.optional(),type:a.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),ha=a.object({...f,nodes:O,type:a.literal("group")}),X=a.discriminatedUnion("type",[bn,Sn,kn,Rn,vn,xn,Pn,Tn,Gn,zn,Hn,Jn,Kn,Yn,Qn,Xn,Zn,ea,ta,ra,oa,Nn,Cn,An,$n,In,En,jn,On,Vn,Fn,Un,Dn,Wn,qn,Ln,_n,Bn,Mn,na,aa,sa,ia,la,ca,da,ua,pa,fa,ha]),ar=a.union([X,ma]),L=a.object({entryNode:a.string().min(1),nodes:a.record(a.string(),ar),variables:a.record(a.string(),z).optional(),version:a.literal(2)});function ne(e){let t=L.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(r=>({message:r.message,path:r.path.join(".")})),success:!1}}import{graphql as ce,readFragment as bf}from"gql.tada";import{z as ae}from"zod";var $e=ae.object({from:ae.string().min(1).describe("Key of the source state in the states record"),to:ae.string().min(1).describe("Key of the target state in the states record"),workflow:ae.string().min(1).describe("Filename (without .json) of the workflow in .ripplo/workflows/ that executes this edge")}).describe("A directed edge between two states, executed by a workflow");import{z as D}from"zod";import{z as b}from"zod";var Ie=b.object({precondition:b.string().min(1).describe("Name of the precondition to check or execute, e.g. 'auth:admin'")}).describe("Request payload sent by Ripplo to both the check and execute endpoints"),se=b.object({satisfied:b.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),ie=b.object({data:b.record(b.string(),b.string()).optional().describe("Key-value data returned by the precondition. Values are injected as variables that can be interpolated into route patterns ({{key}}) and workflow spec variable references. For example, a data:project precondition should return { projectId: 'clx...' } so the route /projects/{{projectId}}/settings resolves correctly."),error:b.string().optional().describe("Human-readable error message if success is false"),navigateTo:b.string().optional().describe("URL to navigate the browser to after this precondition executes. Use this to set the starting page for the test \u2014 e.g. an auth token URL or the page the workflow begins on. If multiple preconditions return navigateTo, only the last one is used."),success:b.boolean().describe("Whether the precondition was successfully satisfied")}).describe("Response from PUT {preconditionApiUrl}/execute. Set-Cookie headers are automatically captured and injected into the browser context. The data field provides values for route param interpolation and workflow variables."),Ee=b.object({preconditions:b.array(b.string().min(1)).describe("Names of all preconditions that were executed during this run")}).describe("Request payload sent after a run completes. Fire-and-forget \u2014 errors are logged but don't fail the run."),je=b.object({error:b.string().optional().describe("Human-readable error message if success is false"),success:b.boolean().describe("Whether teardown completed successfully")}).describe("Response from PUT {preconditionApiUrl}/teardown"),_=b.object({depends:b.array(b.string().min(1)).optional().describe("Names of other preconditions that must be satisfied first. Resolved via topological sort; cycles are rejected at validation time."),description:b.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:b.array(b.string().min(1)).optional().describe("Keys that the execute response's data field will contain. e.g. ['projectId', 'workflowId']. These are used for route param interpolation ({{projectId}}) and workflow variables. Declared here so generated types are strongly typed per precondition.")}).describe("A named precondition declared at the graph level. States reference these by name.");import{z as le}from"zod";var Oe=le.object({preconditions:le.array(le.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:le.string().min(1).describe("URL pattern with {{placeholders}} for dynamic segments, e.g. '/projects/{{projectId}}/settings'")}).describe("A distinct application state \u2014 a unique combination of location, auth context, and data conditions");var Z=D.object({edges:D.array($e).describe("Directed edges between states, each executed by a workflow"),preconditions:D.record(D.string(),_).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:D.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:D.record(D.string(),Oe).describe("States keyed by stable ID (kebab-case)"),version:D.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions");function Ve(e){let t=Z.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(r=>({message:r.message,path:r.path.join(".")})),success:!1}}function Aa(e){let t=e.preconditions,r=new Set,o=new Set,n=[];function s(l){if(o.has(l)){n.push(`Precondition "${l}" has a circular dependency`);return}if(r.has(l))return;r.add(l),o.add(l);let d=t[l];d?.depends!=null&&d.depends.forEach(i=>{s(i)}),o.delete(l)}return Object.keys(t).forEach(l=>{s(l)}),n}function Fe(e){let t=[],r=new Set(Object.keys(e.preconditions)),o=new Set(Object.keys(e.states));e.edges.forEach((i,u)=>{o.has(i.from)||t.push({message:`References non-existent source state "${i.from}"`,path:`edges[${String(u)}].from`}),o.has(i.to)||t.push({message:`References non-existent target state "${i.to}"`,path:`edges[${String(u)}].to`})}),Object.entries(e.states).forEach(([i,u])=>{u.preconditions.forEach(h=>{r.has(h)||t.push({message:`References non-existent precondition "${h}"`,path:`states.${i}.preconditions`})})}),Object.entries(e.preconditions).forEach(([i,u])=>{u.depends!=null&&u.depends.forEach(h=>{r.has(h)||t.push({message:`Depends on non-existent precondition "${h}"`,path:`preconditions.${i}.depends`})})}),e.resetPrecondition!=null&&!r.has(e.resetPrecondition)&&t.push({message:`References non-existent precondition "${e.resetPrecondition}"`,path:"resetPrecondition"});let n=new Set(e.edges.flatMap(i=>[i.from,i.to]));Object.keys(e.states).forEach(i=>{n.has(i)||t.push({message:"State is not referenced by any edge (orphan)",path:`states.${i}`})});let s=new Set;Object.values(e.states).forEach(i=>{i.preconditions.forEach(u=>s.add(u))}),Object.values(e.preconditions).forEach(i=>{i.depends!=null&&i.depends.forEach(u=>s.add(u))}),e.resetPrecondition!=null&&s.add(e.resetPrecondition),Object.keys(e.preconditions).forEach(i=>{s.has(i)||t.push({message:"Defined but never used by any state or dependency",path:`preconditions.${i}`})});let l=new Set;return e.edges.forEach((i,u)=>{let h=`${i.from}|${i.to}|${i.workflow}`;l.has(h)&&t.push({message:`Duplicate edge from "${i.from}" to "${i.to}" with workflow "${i.workflow}"`,path:`edges[${String(u)}]`}),l.add(h)}),Aa(e).forEach(i=>t.push({message:i,path:"preconditions"})),t}import{parseSetCookie as of}from"set-cookie-parser";import{z as ir}from"zod";var sf=ir.record(ir.string(),_);import{graphql as Ue}from"gql.tada";var pf=Ue(`
|
|
44
44
|
mutation StartRunCLI($runId: String!, $platform: String!, $agentProfileId: String) {
|
|
45
45
|
startRun(runId: $runId, platform: $platform, agentProfileId: $agentProfileId) {
|
|
46
46
|
id
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
`),
|
|
49
|
+
`),ff=Ue(`
|
|
50
50
|
mutation SubmitRunStepsCLI($runResultId: String!, $steps: [StepInput!]!) {
|
|
51
51
|
submitRunSteps(runResultId: $runResultId, steps: $steps)
|
|
52
52
|
}
|
|
53
|
-
`),
|
|
53
|
+
`),mf=Ue(`
|
|
54
54
|
mutation CompleteRunCLI(
|
|
55
55
|
$runResultId: String!
|
|
56
56
|
$status: String!
|
|
@@ -99,13 +99,13 @@ ${n}`}}});import{z as _t}from"zod";var Fo=20,Uo=2,Do=_t.object({pattern:_t.strin
|
|
|
99
99
|
...WorkflowRun
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
`,[Fa])
|
|
102
|
+
`,[Fa]),$f=ce(`
|
|
103
103
|
query ProjectRun($projectId: String!) {
|
|
104
104
|
project(id: $projectId) {
|
|
105
105
|
...ProjectRun
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
`,[Ua]),
|
|
108
|
+
`,[Ua]),If=ce(`
|
|
109
109
|
query AgentProfileRun($id: String!) {
|
|
110
110
|
agentProfile(id: $id) {
|
|
111
111
|
id
|
|
@@ -115,7 +115,7 @@ ${n}`}}});import{z as _t}from"zod";var Fo=20,Uo=2,Do=_t.object({pattern:_t.strin
|
|
|
115
115
|
successCriteria
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
`);function v(e){return{content:[{text:e,type:"text"}]}}async function lr(e){let t=Ce();return t==null?v("Not logged in. Run: ripplo login"):e(t)}import{z as x}from"zod";import Da from"fs";import
|
|
118
|
+
`);function v(e){return{content:[{text:e,type:"text"}]}}async function lr(e){let t=Ce();return t==null?v("Not logged in. Run: ripplo login"):e(t)}import{z as x}from"zod";import Da from"fs";import pm from"path";import{z as H}from"zod";var ee=H.object({additionalChecks:H.array(H.string()).default([]),description:H.string(),expectedOutcome:H.string(),name:H.string(),spec:L});function de(e){let t=Da.readFileSync(e,"utf8"),r=JSON.parse(t);return ee.parse(r)}var Wa=x.object({additionalProperties:x.unknown().optional(),properties:x.record(x.string(),x.record(x.string(),x.unknown())).optional(),required:x.array(x.string()).optional(),type:x.string().optional()}),cr=x.object({oneOf:x.array(Wa).optional()});function dr(){let e=za(),t={category:"Control Flow",fields:"body, catch?, finally?",typeName:"try"},r=[...e.map(s=>Ha(s)),t],o=Ja(r);return`# Ripplo Workflow Spec v2
|
|
119
119
|
|
|
120
120
|
## Node Types
|
|
121
121
|
|
|
@@ -434,7 +434,7 @@ app.put("/api/test/preconditions/teardown", async (req, res) => {
|
|
|
434
434
|
}
|
|
435
435
|
res.json({ success: true });
|
|
436
436
|
});
|
|
437
|
-
\`\`\``}import We from"fs";import qe from"path";import hs from"fs";import Tm from"path";import{z as k}from"zod";var De=k.object({edges:k.array(k.object({from:k.string(),to:k.string(),workflow:k.string()})),preconditions:k.record(k.string(),k.unknown()).optional(),resetPrecondition:k.string().optional(),states:k.record(k.string(),k.object({preconditions:k.array(k.string()),route:k.string()})),version:k.literal(3)});function br(e){let t=hs.readFileSync(e,"utf8"),r=JSON.parse(t);return De.parse(r)}function Sr(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}function kr(e){let t=gs(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let r=De.safeParse(t.data);if(!r.success)return{errors:r.error.issues.map(h=>({message:h.message,path:h.path.join(".")})),valid:!1};let o=Sr(r.data),n=Ve(o);if(!n.success)return{errors:n.errors,valid:!1};let s=[...Fe(n.data)],l=qe.join(qe.dirname(e),"workflows"),d=We.existsSync(l),i=new Set(n.data.edges.map(u=>u.workflow));return n.data.edges.forEach((u,h)=>{if(!d){s.push({message:`References workflow "${u.workflow}" but workflows directory does not exist`,path:`edges[${String(h)}].workflow`});return}let E=qe.join(l,`${u.workflow}.json`);We.existsSync(E)||s.push({message:`References workflow "${u.workflow}" but no file exists at workflows/${u.workflow}.json`,path:`edges[${String(h)}].workflow`})}),d&&We.readdirSync(l).filter(u=>u.endsWith(".json")).forEach(u=>{let h=u.replace(/\.json$/,"");i.has(h)||s.push({message:`Workflow file "workflows/${u}" is not referenced by any edge`,path:`workflows/${u}`})}),{errors:s,valid:s.length===0}}function gs(e){try{return{data:br(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}import pe from"fs";import Rr from"path";import{z as A}from"zod";var ys=A.object({baseUrl:A.string().optional(),cloudBaseUrl:A.string(),preconditionApiPath:A.string().optional(),projectId:A.string()});function vr(e){let t=Rr.join(e,".ripplo","settings.json");if(!pe.existsSync(t))return{errors:[{message:".ripplo/settings.json not found",path:""}],valid:!1,warnings:[]};let r=Ss(t);if(!r.success)return{errors:[{message:r.error,path:"settings.json"}],valid:!1,warnings:[]};let o=ys.safeParse(r.data);if(!o.success)return{errors:o.error.issues.map(d=>({message:d.message,path:d.path.join(".")})),valid:!1,warnings:[]};let n=[],s=Rr.join(e,".ripplo","graph.json");return pe.existsSync(s)&&bs(s)&&(o.data.preconditionApiPath==null||o.data.preconditionApiPath.length===0)&&n.push("Graph has preconditions but preconditionApiPath is not set in settings.json. Preconditions will not be executed. Set preconditionApiPath to the URL where your app serves precondition endpoints (can be a relative path appended to baseUrl, or an absolute URL)."),{errors:[],valid:!0,warnings:n}}var ws=A.object({states:A.record(A.string(),A.object({preconditions:A.array(A.string())}))});function bs(e){try{let t=pe.readFileSync(e,"utf8"),r=JSON.parse(t),o=ws.safeParse(r);return o.success?Object.values(o.data.states).some(n=>n.preconditions.length>0):!1}catch{return!1}}function Ss(e){try{let t=pe.readFileSync(e,"utf8");return{data:JSON.parse(t),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}var xr={assertAttribute:"assertion",assertChecked:"assertion",assertCookie:"assertion",assertCount:"assertion",assertDisabled:"assertion",assertEnabled:"assertion",assertFocused:"assertion",assertNotChecked:"assertion",assertNotVisible:"assertion",assertResponse:"assertion",assertText:"assertion",assertTitle:"assertion",assertUrl:"assertion",assertValue:"assertion",assertVisible:"assertion",check:"action",clear:"action",click:"action",clipboard:"other",dblclick:"action",drag:"action",extractText:"other",fail:"other",fill:"action",focus:"action",forEach:"controlFlow",goto:"other",group:"controlFlow",handleDialog:"action",hover:"action",if:"controlFlow",loop:"controlFlow",parallel:"controlFlow",press:"action",rightClick:"action",screenshot:"other",scroll:"action",scrollIntoView:"action",select:"action",setPermission:"other",setVariable:"other",setViewport:"other",try:"controlFlow",type:"action",uncheck:"action",upload:"action",wait:"other",waitFor:"other",waitForRequest:"other",waitForResponse:"other",waitForUrl:"other"},fe=new Set,Le=new Set;Object.entries(xr).forEach(([e,t])=>{t==="assertion"&&fe.add(e),t==="action"&&Le.add(e)});function Pr(e){let t=de(e),{spec:r}=t,o=Ts(r),n=Ns(r),s=ks({orderedNodes:o,spec:r,terminalNodes:n}),l=Es({flags:s,orderedNodes:o,terminalNodes:n,wf:t});return{flags:s,report:l}}function ks({orderedNodes:e,spec:t,terminalNodes:r}){let o=e.filter(d=>fe.has(d.type)).length,n=e.filter(d=>Le.has(d.type)).length,s=Object.keys(t.nodes).length,l=r.some(d=>fe.has(d.type));return[...Rs(o),...vs(l,o),...xs(n),...Ps(o,s)]}function Rs(e){return e===0?["NO_ASSERTIONS: The workflow has zero assertion nodes. It cannot verify its expectedOutcome."]:[]}function vs(e,t){return!e&&t>0?["NO_TERMINAL_ASSERTION: No terminal node (end of flow) is an assertion. The workflow may not verify the final state."]:[]}function xs(e){return e===0?["NO_INTERACTIONS: The workflow has zero interaction nodes (click, fill, select, etc.). It does not exercise any user action."]:[]}function Ps(e,t){if(e>0&&t>3){let r=e/t;if(r<.15){let o=String(Math.round(r*100));return[`LOW_ASSERTION_RATIO: Only ${String(e)}/${String(t)} nodes are assertions (${o}%). Consider adding more verification.`]}}return[]}function Ts(e){let t=new Set,r=[];function o(n){if(t.has(n))return;t.add(n);let s=e.nodes[n];s!=null&&(r.push(s),s.next!=null&&o(s.next),Tr(s).forEach(l=>{o(l)}))}return o(e.entryNode),r}function Tr(e){switch(e.type){case"if":return[...e.consequent,...e.alternate??[]];case"loop":case"forEach":return[...e.body];case"try":return[...e.body,...e.catch??[],...e.finally??[]];case"group":return[...e.nodes];case"parallel":return e.branches.flat();case"assertVisible":case"assertNotVisible":case"assertText":case"assertUrl":case"assertCount":case"assertValue":case"click":case"fill":case"select":case"check":case"uncheck":case"press":case"hover":case"goto":case"waitFor":case"screenshot":case"setViewport":case"wait":case"fail":case"setVariable":case"extractText":case"waitForUrl":case"waitForResponse":case"waitForRequest":case"upload":case"dblclick":case"drag":case"scrollIntoView":case"type":case"focus":case"assertAttribute":case"assertEnabled":case"assertDisabled":case"assertTitle":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertCookie":case"assertResponse":case"clear":case"rightClick":case"handleDialog":case"scroll":case"clipboard":case"setPermission":return[]}}function Ns(e){return Object.values(e.nodes).filter(t=>t.next!=null?!1:Tr(t).length===0)}function w(e){return e.by==="role"?e.name==null?`role=${e.role}`:`role=${e.role}[${e.name}]`:`${e.by}=${e.value}`}function $(e){return e.type==="static"?`"${e.value}"`:`{{${e.name}}}`}function Cs(e){return e.type==="static"?String(e.value):`{{${e.name}}}`}var Nr=new Set,Cr=new Set;Object.entries(xr).forEach(([e,t])=>{t==="controlFlow"&&Nr.add(e),t==="assertion"&&Cr.add(e)});function Ar(e){let t=`[${e.type}]`;return Nr.has(e.type)?Is(e,t):Cr.has(e.type)?$s(e,t):As(e,t)}function As(e,t){let r=e;switch(r.type){case"goto":return`${t} Navigate to ${$(r.url)}`;case"click":return`${t} click ${w(r.locator)}`;case"hover":return`${t} hover ${w(r.locator)}`;case"check":return`${t} check ${w(r.locator)}`;case"uncheck":return`${t} uncheck ${w(r.locator)}`;case"fill":return`${t} Fill ${w(r.locator)} with ${$(r.value)}`;case"select":return`${t} Select ${$(r.value)} in ${w(r.locator)}`;case"press":return`${t} Press "${r.key}"`;case"waitFor":{let o=r.state==null?"":` to be ${r.state}`;return`${t} Wait for ${w(r.locator)}${o}`}case"waitForUrl":return`${t} Wait for URL ${r.operator} ${$(r.expected)}`;case"waitForResponse":return`${t} Wait for response matching ${$(r.urlPattern)}`;case"waitForRequest":return`${t} Wait for request matching ${$(r.urlPattern)}`;case"extractText":return`${t} Extract text from ${w(r.locator)} into $${r.variable}`;case"screenshot":case"clipboard":return`${t} ${r.type}`;case"setViewport":return`${t} setViewport ${String(r.width)}x${String(r.height)}`;case"wait":return`${t} wait ${String(r.duration)}ms`;case"fail":return`${t} fail: ${r.message}`;case"setVariable":return`${t} setVariable ${r.variable}`;case"upload":return`${t} Upload files to ${w(r.locator)}`;case"dblclick":return`${t} Double-click ${w(r.locator)}`;case"drag":return`${t} Drag ${w(r.source)} to ${w(r.target)}`;case"scrollIntoView":return`${t} Scroll into view ${w(r.locator)}`;case"type":return`${t} Type ${$(r.value)} into ${w(r.locator)}`;case"focus":return`${t} Focus ${w(r.locator)}`;case"clear":return`${t} Clear ${w(r.locator)}`;case"rightClick":return`${t} Right-click ${w(r.locator)}`;case"handleDialog":return`${t} Handle dialog: ${r.action}`;case"scroll":return r.locator==null?`${t} Scroll page`:`${t} Scroll ${w(r.locator)}`;case"setPermission":return`${t} Set permission ${r.permission} to ${r.state}`}}function $s(e,t){let r=e;switch(r.type){case"assertVisible":return`${t} Assert visible: ${w(r.locator)}`;case"assertNotVisible":return`${t} Assert not visible: ${w(r.locator)}`;case"assertText":return`${t} Assert text of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertUrl":return`${t} Assert URL ${r.operator} ${$(r.expected)}`;case"assertCount":return`${t} Assert count of ${w(r.locator)} ${r.operator} ${Cs(r.expected)}`;case"assertValue":return`${t} Assert value of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertAttribute":return`${t} Assert attribute "${r.attribute}" of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertEnabled":return`${t} Assert enabled: ${w(r.locator)}`;case"assertDisabled":return`${t} Assert disabled: ${w(r.locator)}`}}function Is(e,t){let r=e;switch(r.type){case"if":return`${t} if (condition)`;case"loop":return`${t} loop ${String(r.times)} times`;case"forEach":return`${t} forEach ${r.iteratorVar}`;case"parallel":return`${t} parallel (${String(r.branches.length)} branches)`;case"group":return`${t} group (${String(r.nodes.length)} nodes)`;case"try":return`${t} try/catch`}}function Es({flags:e,orderedNodes:t,terminalNodes:r,wf:o}){let n=t.filter(d=>fe.has(d.type)).length,s=t.filter(d=>Le.has(d.type)).length;return[js(o),Os(t),Vs(r),Fs({actionCount:s,assertionCount:n,orderedNodes:t,terminalNodes:r}),...Us(e),Ds].join(`
|
|
437
|
+
\`\`\``}import We from"fs";import qe from"path";import hs from"fs";import Cm from"path";import{z as k}from"zod";var De=k.object({edges:k.array(k.object({from:k.string(),to:k.string(),workflow:k.string()})),preconditions:k.record(k.string(),k.unknown()).optional(),resetPrecondition:k.string().optional(),states:k.record(k.string(),k.object({preconditions:k.array(k.string()),route:k.string()})),version:k.literal(3)});function br(e){let t=hs.readFileSync(e,"utf8"),r=JSON.parse(t);return De.parse(r)}function Sr(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}function kr(e){let t=gs(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let r=De.safeParse(t.data);if(!r.success)return{errors:r.error.issues.map(h=>({message:h.message,path:h.path.join(".")})),valid:!1};let o=Sr(r.data),n=Ve(o);if(!n.success)return{errors:n.errors,valid:!1};let s=[...Fe(n.data)],l=qe.join(qe.dirname(e),"workflows"),d=We.existsSync(l),i=new Set(n.data.edges.map(u=>u.workflow));return n.data.edges.forEach((u,h)=>{if(!d){s.push({message:`References workflow "${u.workflow}" but workflows directory does not exist`,path:`edges[${String(h)}].workflow`});return}let E=qe.join(l,`${u.workflow}.json`);We.existsSync(E)||s.push({message:`References workflow "${u.workflow}" but no file exists at workflows/${u.workflow}.json`,path:`edges[${String(h)}].workflow`})}),d&&We.readdirSync(l).filter(u=>u.endsWith(".json")).forEach(u=>{let h=u.replace(/\.json$/,"");i.has(h)||s.push({message:`Workflow file "workflows/${u}" is not referenced by any edge`,path:`workflows/${u}`})}),{errors:s,valid:s.length===0}}function gs(e){try{return{data:br(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}import pe from"fs";import Rr from"path";import{z as A}from"zod";var ys=A.object({baseUrl:A.string().optional(),cloudBaseUrl:A.string(),preconditionApiPath:A.string().optional(),projectId:A.string()});function vr(e){let t=Rr.join(e,".ripplo","settings.json");if(!pe.existsSync(t))return{errors:[{message:".ripplo/settings.json not found",path:""}],valid:!1,warnings:[]};let r=Ss(t);if(!r.success)return{errors:[{message:r.error,path:"settings.json"}],valid:!1,warnings:[]};let o=ys.safeParse(r.data);if(!o.success)return{errors:o.error.issues.map(d=>({message:d.message,path:d.path.join(".")})),valid:!1,warnings:[]};let n=[],s=Rr.join(e,".ripplo","graph.json");return pe.existsSync(s)&&bs(s)&&(o.data.preconditionApiPath==null||o.data.preconditionApiPath.length===0)&&n.push("Graph has preconditions but preconditionApiPath is not set in settings.json. Preconditions will not be executed. Set preconditionApiPath to the URL where your app serves precondition endpoints (can be a relative path appended to baseUrl, or an absolute URL)."),{errors:[],valid:!0,warnings:n}}var ws=A.object({states:A.record(A.string(),A.object({preconditions:A.array(A.string())}))});function bs(e){try{let t=pe.readFileSync(e,"utf8"),r=JSON.parse(t),o=ws.safeParse(r);return o.success?Object.values(o.data.states).some(n=>n.preconditions.length>0):!1}catch{return!1}}function Ss(e){try{let t=pe.readFileSync(e,"utf8");return{data:JSON.parse(t),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}var xr={assertAttribute:"assertion",assertChecked:"assertion",assertCookie:"assertion",assertCount:"assertion",assertDisabled:"assertion",assertEnabled:"assertion",assertFocused:"assertion",assertNotChecked:"assertion",assertNotVisible:"assertion",assertResponse:"assertion",assertText:"assertion",assertTitle:"assertion",assertUrl:"assertion",assertValue:"assertion",assertVisible:"assertion",check:"action",clear:"action",click:"action",clipboard:"other",dblclick:"action",drag:"action",extractText:"other",fail:"other",fill:"action",focus:"action",forEach:"controlFlow",goto:"other",group:"controlFlow",handleDialog:"action",hover:"action",if:"controlFlow",loop:"controlFlow",parallel:"controlFlow",press:"action",rightClick:"action",screenshot:"other",scroll:"action",scrollIntoView:"action",select:"action",setPermission:"other",setVariable:"other",setViewport:"other",try:"controlFlow",type:"action",uncheck:"action",upload:"action",wait:"other",waitFor:"other",waitForRequest:"other",waitForResponse:"other",waitForUrl:"other"},fe=new Set,Le=new Set;Object.entries(xr).forEach(([e,t])=>{t==="assertion"&&fe.add(e),t==="action"&&Le.add(e)});function Pr(e){let t=de(e),{spec:r}=t,o=Ts(r),n=Ns(r),s=ks({orderedNodes:o,spec:r,terminalNodes:n}),l=Es({flags:s,orderedNodes:o,terminalNodes:n,wf:t});return{flags:s,report:l}}function ks({orderedNodes:e,spec:t,terminalNodes:r}){let o=e.filter(d=>fe.has(d.type)).length,n=e.filter(d=>Le.has(d.type)).length,s=Object.keys(t.nodes).length,l=r.some(d=>fe.has(d.type));return[...Rs(o),...vs(l,o),...xs(n),...Ps(o,s)]}function Rs(e){return e===0?["NO_ASSERTIONS: The workflow has zero assertion nodes. It cannot verify its expectedOutcome."]:[]}function vs(e,t){return!e&&t>0?["NO_TERMINAL_ASSERTION: No terminal node (end of flow) is an assertion. The workflow may not verify the final state."]:[]}function xs(e){return e===0?["NO_INTERACTIONS: The workflow has zero interaction nodes (click, fill, select, etc.). It does not exercise any user action."]:[]}function Ps(e,t){if(e>0&&t>3){let r=e/t;if(r<.15){let o=String(Math.round(r*100));return[`LOW_ASSERTION_RATIO: Only ${String(e)}/${String(t)} nodes are assertions (${o}%). Consider adding more verification.`]}}return[]}function Ts(e){let t=new Set,r=[];function o(n){if(t.has(n))return;t.add(n);let s=e.nodes[n];s!=null&&(r.push(s),s.next!=null&&o(s.next),Tr(s).forEach(l=>{o(l)}))}return o(e.entryNode),r}function Tr(e){switch(e.type){case"if":return[...e.consequent,...e.alternate??[]];case"loop":case"forEach":return[...e.body];case"try":return[...e.body,...e.catch??[],...e.finally??[]];case"group":return[...e.nodes];case"parallel":return e.branches.flat();case"assertVisible":case"assertNotVisible":case"assertText":case"assertUrl":case"assertCount":case"assertValue":case"click":case"fill":case"select":case"check":case"uncheck":case"press":case"hover":case"goto":case"waitFor":case"screenshot":case"setViewport":case"wait":case"fail":case"setVariable":case"extractText":case"waitForUrl":case"waitForResponse":case"waitForRequest":case"upload":case"dblclick":case"drag":case"scrollIntoView":case"type":case"focus":case"assertAttribute":case"assertEnabled":case"assertDisabled":case"assertTitle":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertCookie":case"assertResponse":case"clear":case"rightClick":case"handleDialog":case"scroll":case"clipboard":case"setPermission":return[]}}function Ns(e){return Object.values(e.nodes).filter(t=>t.next!=null?!1:Tr(t).length===0)}function w(e){return e.by==="role"?e.name==null?`role=${e.role}`:`role=${e.role}[${e.name}]`:`${e.by}=${e.value}`}function $(e){return e.type==="static"?`"${e.value}"`:`{{${e.name}}}`}function Cs(e){return e.type==="static"?String(e.value):`{{${e.name}}}`}var Nr=new Set,Cr=new Set;Object.entries(xr).forEach(([e,t])=>{t==="controlFlow"&&Nr.add(e),t==="assertion"&&Cr.add(e)});function Ar(e){let t=`[${e.type}]`;return Nr.has(e.type)?Is(e,t):Cr.has(e.type)?$s(e,t):As(e,t)}function As(e,t){let r=e;switch(r.type){case"goto":return`${t} Navigate to ${$(r.url)}`;case"click":return`${t} click ${w(r.locator)}`;case"hover":return`${t} hover ${w(r.locator)}`;case"check":return`${t} check ${w(r.locator)}`;case"uncheck":return`${t} uncheck ${w(r.locator)}`;case"fill":return`${t} Fill ${w(r.locator)} with ${$(r.value)}`;case"select":return`${t} Select ${$(r.value)} in ${w(r.locator)}`;case"press":return`${t} Press "${r.key}"`;case"waitFor":{let o=r.state==null?"":` to be ${r.state}`;return`${t} Wait for ${w(r.locator)}${o}`}case"waitForUrl":return`${t} Wait for URL ${r.operator} ${$(r.expected)}`;case"waitForResponse":return`${t} Wait for response matching ${$(r.urlPattern)}`;case"waitForRequest":return`${t} Wait for request matching ${$(r.urlPattern)}`;case"extractText":return`${t} Extract text from ${w(r.locator)} into $${r.variable}`;case"screenshot":case"clipboard":return`${t} ${r.type}`;case"setViewport":return`${t} setViewport ${String(r.width)}x${String(r.height)}`;case"wait":return`${t} wait ${String(r.duration)}ms`;case"fail":return`${t} fail: ${r.message}`;case"setVariable":return`${t} setVariable ${r.variable}`;case"upload":return`${t} Upload files to ${w(r.locator)}`;case"dblclick":return`${t} Double-click ${w(r.locator)}`;case"drag":return`${t} Drag ${w(r.source)} to ${w(r.target)}`;case"scrollIntoView":return`${t} Scroll into view ${w(r.locator)}`;case"type":return`${t} Type ${$(r.value)} into ${w(r.locator)}`;case"focus":return`${t} Focus ${w(r.locator)}`;case"clear":return`${t} Clear ${w(r.locator)}`;case"rightClick":return`${t} Right-click ${w(r.locator)}`;case"handleDialog":return`${t} Handle dialog: ${r.action}`;case"scroll":return r.locator==null?`${t} Scroll page`:`${t} Scroll ${w(r.locator)}`;case"setPermission":return`${t} Set permission ${r.permission} to ${r.state}`}}function $s(e,t){let r=e;switch(r.type){case"assertVisible":return`${t} Assert visible: ${w(r.locator)}`;case"assertNotVisible":return`${t} Assert not visible: ${w(r.locator)}`;case"assertText":return`${t} Assert text of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertUrl":return`${t} Assert URL ${r.operator} ${$(r.expected)}`;case"assertCount":return`${t} Assert count of ${w(r.locator)} ${r.operator} ${Cs(r.expected)}`;case"assertValue":return`${t} Assert value of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertAttribute":return`${t} Assert attribute "${r.attribute}" of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertEnabled":return`${t} Assert enabled: ${w(r.locator)}`;case"assertDisabled":return`${t} Assert disabled: ${w(r.locator)}`}}function Is(e,t){let r=e;switch(r.type){case"if":return`${t} if (condition)`;case"loop":return`${t} loop ${String(r.times)} times`;case"forEach":return`${t} forEach ${r.iteratorVar}`;case"parallel":return`${t} parallel (${String(r.branches.length)} branches)`;case"group":return`${t} group (${String(r.nodes.length)} nodes)`;case"try":return`${t} try/catch`}}function Es({flags:e,orderedNodes:t,terminalNodes:r,wf:o}){let n=t.filter(d=>fe.has(d.type)).length,s=t.filter(d=>Le.has(d.type)).length;return[js(o),Os(t),Vs(r),Fs({actionCount:s,assertionCount:n,orderedNodes:t,terminalNodes:r}),...Us(e),Ds].join(`
|
|
438
438
|
`)}function js(e){let t=["## Declared Intent",`**Name:** ${e.name}`,`**Description:** ${e.description}`,`**Expected Outcome:** ${e.expectedOutcome}`];if(e.additionalChecks.length>0){let r=e.additionalChecks.map(o=>`- ${o}`).join(`
|
|
439
439
|
`);t.push(`**Additional Checks:**
|
|
440
440
|
${r}`)}return t.join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ripplo",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "CLI for Ripplo — AI-powered end-to-end testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://ripplo.ai",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"tsup": "^8.5.1",
|
|
42
42
|
"tsx": "^4.21.0",
|
|
43
43
|
"typescript": "^5.9.3",
|
|
44
|
-
"@ripplo/runtime": "^0.0.0",
|
|
45
|
-
"@ripplo/graph": "^0.0.0",
|
|
46
44
|
"@ripplo/eslint-config": "0.0.0",
|
|
47
|
-
"@ripplo/
|
|
45
|
+
"@ripplo/runtime": "^0.0.0",
|
|
46
|
+
"@ripplo/spec": "^0.0.0",
|
|
47
|
+
"@ripplo/graph": "^0.0.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"dev": "tsx src/index.ts",
|