ripplo 0.0.1 → 0.0.2
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 +53 -53
- package/dist/mcp/index.js +37 -37
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Zn=Object.defineProperty;var m=(e,t)=>()=>(e&&(t=e(e=0)),t);var ea=(e,t)=>{for(var r in t)Zn(e,r,{get:t[r],enumerable:!0})};function
|
|
3
|
-
`):`${e.status}: ${e.title}`;return{specNode:e.specNode,stepResult:n,toolOutput:o}}var C=m(()=>{"use strict";be()});import{z as xt}from"zod";var da,Er,$r=m(()=>{"use strict";C();da=xt.object({expected:xt.string().describe("The expected text content"),selector:xt.string().describe("CSS selector for the element to check")}),Er=h({description:"Assert that an element's text content matches the expected value",name:"assert_text",schema:da,execute:async(e,t)=>{let r=performance.now(),n=await e.page.locator(t.selector).textContent({timeout:5e3}).catch(()=>null),o=n!=null&&n.includes(t.expected),a=o?"passed":"failed",s=[{description:`Text contains "${t.expected}"`,detail:`Actual: "${n??"(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 v({assertions:s,detail:o?`Text matches: "${t.expected}"`:`Expected "${t.expected}", got "${n??"(not found)"}"`,duration:performance.now()-r,nodeType:"assertText",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert text: ${t.selector}`})}})});import{z as Vr}from"zod";var ua,Ur,Dr=m(()=>{"use strict";C();ua=Vr.object({selector:Vr.string().describe("CSS selector for the element to check")}),Ur=h({description:"Assert that an element matching the selector is visible on the page",name:"assert_visible",schema:ua,execute:async(e,t)=>{let r=performance.now(),n=await e.page.locator(t.selector).isVisible().catch(()=>!1),o=n?"passed":"failed",a=[{description:`Element ${t.selector} is visible`,detail:n?"Element is visible":"Element is not visible",status:o}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertVisible"};return v({assertions:a,detail:n?"Element is visible":"Element is not visible",duration:performance.now()-r,nodeType:"assertVisible",page:e.page,runStartTime:e.runStartTime,specNode:i,status:o,stepIndex:e.stepIndex,title:`Assert visible: ${t.selector}`})}})});import{z as Fr}from"zod";var pa,Wr
|
|
4
|
-
${r.summary}`,verdict:r.verdict};return Promise.resolve(n)}}});import{z as
|
|
2
|
+
var Zn=Object.defineProperty;var m=(e,t)=>()=>(e&&(t=e(e=0)),t);var ea=(e,t)=>{for(var r in t)Zn(e,r,{get:t[r],enumerable:!0})};function P({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 we=m(()=>{"use strict"});function Se({defs:e}){return e==null?{}:Object.fromEntries(Object.entries(e).map(([t,r])=>[t,ra({def:r,name:t})]))}function ra({def:e,name:t}){if(e.type==="env"){let r=process.env[e.key];if(r==null)throw new Error(`Environment variable "${e.key}" not set for variable "${t}"`);return r}return e.default??ta[e.type]??""}function oe({ref:e,variables:t}){if(e.type==="static")return e.value;let r=t[e.name];if(r==null)throw new Error(`Variable "${e.name}" is not defined`);return r}function $({ref:e,variables:t}){let r=String(oe({ref:e,variables:t}));return oa({raw:r,variables:t})}function oa({raw:e,variables:t}){return e.replaceAll(/\{\{(\w+)\}\}/g,(r,n)=>{let o=t[n];if(o==null)throw new Error(`Template variable "{{${n}}}" is not defined`);return String(o)})}function bt({ref:e,variables:t}){let r=oe({ref:e,variables:t});if(typeof r=="number")return r;let n=Number(r);if(Number.isNaN(n))throw new TypeError(`Cannot convert "${String(r)}" to number`);return n}function ne({name:e,store:t,value:r}){return{...t,[e]:r}}var ta,K=m(()=>{"use strict";ta={boolean:!1,number:0,string:""}});async function Pt({node:e,page:t,timeout:r,variables:n}){switch(e.type){case"goto":{let o=$({ref:e.url,variables:n});return await t.goto(o,{timeout:r,waitUntil:"domcontentloaded"}),{variables:n}}case"click":return await P({locator:e.locator,page:t}).click({timeout:r}),{variables:n};case"fill":{let o=$({ref:e.value,variables:n});return await P({locator:e.locator,page:t}).fill(o,{timeout:r}),{variables:n}}case"select":{let o=$({ref:e.value,variables:n});return await P({locator:e.locator,page:t}).selectOption(o,{timeout:r}),{variables:n}}case"hover":return await P({locator:e.locator,page:t}).hover({timeout:r}),{variables:n};case"press":return await aa({node:e,page:t,timeout:r}),{variables:n};case"check":return await P({locator:e.locator,page:t}).check({timeout:r}),{variables:n};case"uncheck":return await P({locator:e.locator,page:t}).uncheck({timeout:r}),{variables:n};case"waitFor":return await P({locator:e.locator,page:t}).waitFor({state:e.state??"visible",timeout:r}),{variables:n};case"screenshot":return await t.screenshot(),{variables:n};case"setViewport":return await t.setViewportSize({height:e.height,width:e.width}),{variables:n};case"wait":return await t.waitForTimeout(e.duration),{variables:n};case"fail":throw new Error(e.message);case"setVariable":{let o=oe({ref:e.value,variables:n});return{variables:ne({name:e.variable,store:n,value:o})}}case"extractText":{let o=await P({locator:e.locator,page:t}).textContent({timeout:r});return{variables:ne({name:e.variable,store:n,value:o??""})}}case"waitForUrl":{let o=$({ref:e.expected,variables:n});return await t.waitForURL(na({expected:o,operator:e.operator}),{timeout:r}),{variables:n}}case"waitForResponse":{let o=$({ref:e.urlPattern,variables:n});return await t.waitForResponse(a=>a.url().includes(o),{timeout:r}),{variables:n}}case"waitForRequest":{let o=$({ref:e.urlPattern,variables:n});return await t.waitForRequest(a=>a.url().includes(o),{timeout:r}),{variables:n}}case"upload":return await P({locator:e.locator,page:t}).setInputFiles(e.files,{timeout:r}),{variables:n};case"dblclick":return await P({locator:e.locator,page:t}).dblclick({timeout:r}),{variables:n};case"drag":{let o=P({locator:e.source,page:t}),a=P({locator:e.target,page:t});return await o.dragTo(a,{timeout:r}),{variables:n}}case"scrollIntoView":return await P({locator:e.locator,page:t}).scrollIntoViewIfNeeded({timeout:r}),{variables:n};case"type":{let o=$({ref:e.value,variables:n});return await P({locator:e.locator,page:t}).pressSequentially(o,{timeout:r}),{variables:n}}case"focus":return await P({locator:e.locator,page:t}).focus({timeout:r}),{variables:n}}}function na({expected:e,operator:t}){return r=>{let n=r.toString();return t==="equals"?n===e:t==="notEquals"?n!==e:t==="contains"?n.includes(e):t==="startsWith"?n.startsWith(e):t==="endsWith"?n.endsWith(e):new RegExp(e).test(n)}}async function aa({node:e,page:t,timeout:r}){e.locator==null?await t.keyboard.press(e.key):await P({locator:e.locator,page:t}).press(e.key,{timeout:r})}var Rt=m(()=>{"use strict";we();K()});async function Q({page:e,runStartTime:t,targets:r}){let n=e.viewportSize();if(n==null)throw new Error("Page has no viewport set");let[o,a]=await Promise.all([e.screenshot({type:"png"}),ia(r)]),s=o.toString("base64");return{annotations:a,screenshotBase64:s,snapshotTimestamp:Math.round(performance.now()-t),url:e.url(),viewportHeight:n.height,viewportWidth:n.width}}function sa(e){return"locator"in e}async function ia(e){return(await Promise.all(e.map(r=>la(r)))).filter(r=>r!=null)}async function la(e){if(!sa(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)}}var be=m(()=>{"use strict"});import{z as ca}from"zod";function h({description:e,execute:t,name:r,schema:n}){let o=ca.toJSONSchema(n,{target:"draft-2020-12"});return{anthropicTool:{description:e,input_schema:{...o,type:"object"},name:r},name:r,async execute(a,s){let i=n.parse(s);return{...await Promise.resolve(t(a,i)),kind:"action"}}}}async function v(e){let t=await Q({page:e.page,runStartTime:e.runStartTime,targets:[]}),r=[...e.assertions],n={annotations:t.annotations,assertions:r,detail:e.detail,duration:Math.round(e.duration),nodeId:`agent-step-${String(e.stepIndex)}`,nodeType:e.nodeType,screenshotBase64:t.screenshotBase64,snapshotTimestamp:t.snapshotTimestamp,status:e.status,stepIndex:e.stepIndex,title:e.title,url:t.url,viewportHeight:t.viewportHeight,viewportWidth:t.viewportWidth},o=r.length>0?r.map(a=>`${a.status}: ${a.description} \u2014 ${a.detail??""}`).join(`
|
|
3
|
+
`):`${e.status}: ${e.title}`;return{specNode:e.specNode,stepResult:n,toolOutput:o}}var C=m(()=>{"use strict";be()});import{z as xt}from"zod";var da,Er,$r=m(()=>{"use strict";C();da=xt.object({expected:xt.string().describe("The expected text content"),selector:xt.string().describe("CSS selector for the element to check")}),Er=h({description:"Assert that an element's text content matches the expected value",name:"assert_text",schema:da,execute:async(e,t)=>{let r=performance.now(),n=await e.page.locator(t.selector).textContent({timeout:5e3}).catch(()=>null),o=n!=null&&n.includes(t.expected),a=o?"passed":"failed",s=[{description:`Text contains "${t.expected}"`,detail:`Actual: "${n??"(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 v({assertions:s,detail:o?`Text matches: "${t.expected}"`:`Expected "${t.expected}", got "${n??"(not found)"}"`,duration:performance.now()-r,nodeType:"assertText",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert text: ${t.selector}`})}})});import{z as Vr}from"zod";var ua,Ur,Dr=m(()=>{"use strict";C();ua=Vr.object({selector:Vr.string().describe("CSS selector for the element to check")}),Ur=h({description:"Assert that an element matching the selector is visible on the page",name:"assert_visible",schema:ua,execute:async(e,t)=>{let r=performance.now(),n=await e.page.locator(t.selector).isVisible().catch(()=>!1),o=n?"passed":"failed",a=[{description:`Element ${t.selector} is visible`,detail:n?"Element is visible":"Element is not visible",status:o}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertVisible"};return v({assertions:a,detail:n?"Element is visible":"Element is not visible",duration:performance.now()-r,nodeType:"assertVisible",page:e.page,runStartTime:e.runStartTime,specNode:i,status:o,stepIndex:e.stepIndex,title:`Assert visible: ${t.selector}`})}})});import{z as Fr}from"zod";var pa,Or,Wr=m(()=>{"use strict";C();pa=Fr.object({selector:Fr.string().describe("CSS selector for the checkbox to check")}),Or=h({description:"Check a checkbox matching the CSS selector",name:"check",schema:pa,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).check({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"check"};return v({assertions:[],detail:`Checked ${t.selector}`,duration:performance.now()-r,nodeType:"check",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Check ${t.selector}`})}})});import{z as Lr}from"zod";var fa,qr,Br=m(()=>{"use strict";C();fa=Lr.object({selector:Lr.string().describe("CSS selector for the element to click")}),qr=h({description:"Click an element matching the CSS selector",name:"click",schema:fa,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).click({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"click"};return v({assertions:[],detail:`Clicked ${t.selector}`,duration:performance.now()-r,nodeType:"click",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Click ${t.selector}`})}})});import{z as qe}from"zod";var zr,Mr,_r=m(()=>{"use strict";zr=qe.object({summary:qe.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:qe.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.")}),Mr={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:{...qe.toJSONSchema(zr,{target:"draft-2020-12"}),type:"object"},name:"complete_test"},name:"complete_test",execute(e,t){let r=zr.parse(t),n={kind:"verdict",summary:r.summary,toolOutput:`Verdict: ${r.verdict}
|
|
4
|
+
${r.summary}`,verdict:r.verdict};return Promise.resolve(n)}}});import{z as Gr}from"zod";var ma,Hr,Jr=m(()=>{"use strict";C();ma=Gr.object({selector:Gr.string().describe("CSS selector for the element to extract text from")}),Hr=h({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:ma,execute:async(e,t)=>{let r=performance.now(),o=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 v({assertions:[],detail:`Extracted text: "${o}"`,duration:performance.now()-r,nodeType:"extractText",page:e.page,runStartTime:e.runStartTime,specNode:s,status:"passed",stepIndex:e.stepIndex,title:`Extract text from ${t.selector}`})}})});import{z as vt}from"zod";var ga,Yr,Kr=m(()=>{"use strict";C();ga=vt.object({selector:vt.string().describe("CSS selector for the input element"),value:vt.string().describe("The text to type into the element")}),Yr=h({description:"Clear and type text into an input element matching the CSS selector",name:"fill",schema:ga,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).fill(t.value,{timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"fill",value:{type:"static",value:t.value}};return v({assertions:[],detail:`Filled ${t.selector} with "${t.value}"`,duration:performance.now()-r,nodeType:"fill",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Fill ${t.selector}`})}})});import{z as Qr}from"zod";function ha(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}var ya,Xr,Zr=m(()=>{"use strict";C();ya=Qr.object({level:Qr.string().describe("Filter by log level: 'error', 'warning', 'log', 'info', 'debug', or 'all'").default("all")}),Xr=h({description:"Get console log messages from the browser. Optionally filter by level (error, warning, log, info, debug, all).",name:"get_console_logs",schema:ya,execute:(e,t)=>{let r=t.level==="all"?e.monitor.consoleEntries:e.monitor.consoleEntries.filter(o=>o.level===t.level);if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console ${t.level==="all"?"messages":t.level+" messages"} recorded.`};let n=r.map(o=>ha(o)).join(`
|
|
5
5
|
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(r.length)} console messages:
|
|
6
6
|
${n}`}}})});import{z as eo}from"zod";var kt,wa,to,ro=m(()=>{"use strict";C();kt=50,wa=eo.object({urlFilter:eo.string().describe("Optional regex to filter network entries by URL. Omit to see all.").default("")}),to=h({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:wa,execute:(e,t)=>{let r=t.urlFilter.length>0?new RegExp(t.urlFilter,"i"):void 0,n=r==null?e.monitor.networkEntries:e.monitor.networkEntries.filter(i=>r.test(i.url));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No network requests recorded."};let o=n.slice(-kt),a=o.map(i=>{let l=i.statusCode==null?"pending":String(i.statusCode),c=i.responseHeaders["content-type"]??"";return`${i.method} ${l} ${i.url} [${c}]`}).join(`
|
|
7
7
|
`),s=n.length>kt?`
|
|
@@ -24,9 +24,9 @@ ${o}`}}})});import{z as jo}from"zod";function Va({contextLines:e,lines:t,maxResu
|
|
|
24
24
|
`);a.push(p)}),a}var Aa,Ea,$a,Io,No=m(()=>{"use strict";C();Aa=20,Ea=2,$a=jo.object({pattern:jo.string().describe("Regex pattern to search for in the page HTML")}),Io=h({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:$a,execute:async(e,t)=>{let n=(await e.page.content()).split(`
|
|
25
25
|
`),o=Va({contextLines:Ea,lines:n,maxResults:Aa,pattern:t.pattern});return o.length===0?{specNode:void 0,stepResult:void 0,toolOutput:`No matches found for pattern: ${t.pattern}`}:{specNode:void 0,stepResult:void 0,toolOutput:o.join(`
|
|
26
26
|
---
|
|
27
|
-
`)}}})});import{z as Ct}from"zod";var Ua,Ao,Eo=m(()=>{"use strict";C();Ua=Ct.object({selector:Ct.string().describe("CSS selector for the select element"),value:Ct.string().describe("The option value to select")}),Ao=h({description:"Select an option from a dropdown/select element",name:"select",schema:Ua,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).selectOption(t.value,{timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"select",value:{type:"static",value:t.value}};return v({assertions:[],detail:`Selected "${t.value}" in ${t.selector}`,duration:performance.now()-r,nodeType:"select",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Select ${t.value}`})}})});import{z as $o}from"zod";var Da,Vo,Uo=m(()=>{"use strict";C();Da=$o.object({selector:$o.string().describe("CSS selector for the checkbox to uncheck")}),Vo=h({description:"Uncheck a checkbox matching the CSS selector",name:"uncheck",schema:Da,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).uncheck({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"uncheck"};return v({assertions:[],detail:`Unchecked ${t.selector}`,duration:performance.now()-r,nodeType:"uncheck",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Uncheck ${t.selector}`})}})});import{z as Do}from"zod";var Fa,Fo,
|
|
28
|
-
${f.stack??""}`)}function c(f){let g=f.failure(),y=new Be(f);y.responseBody=`(request failed: ${g?.errorText??"unknown"})`,r.push(y)}e.on("console",a),e.on("request",s),e.on("response",i),e.on("pageerror",l),e.on("requestfailed",c);function p(){e.off("console",a),e.off("request",s),e.off("response",i),e.off("pageerror",l),e.off("requestfailed",c)}return{consoleEntries:t,detach:p,networkEntries:r,pageErrors:n}}var Be,It=m(()=>{"use strict";Be=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(r=>{this.responseBody=r.length>1e5?`${r.slice(0,1e5)}... (truncated)`:r}).catch(()=>{this.responseBody="(unable to read body)"})}}});async function zo({input:e,monitor:t,name:r,page:n,runStartTime:o,stepIndex:a}){let s=
|
|
29
|
-
`)});import
|
|
27
|
+
`)}}})});import{z as Ct}from"zod";var Ua,Ao,Eo=m(()=>{"use strict";C();Ua=Ct.object({selector:Ct.string().describe("CSS selector for the select element"),value:Ct.string().describe("The option value to select")}),Ao=h({description:"Select an option from a dropdown/select element",name:"select",schema:Ua,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).selectOption(t.value,{timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"select",value:{type:"static",value:t.value}};return v({assertions:[],detail:`Selected "${t.value}" in ${t.selector}`,duration:performance.now()-r,nodeType:"select",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Select ${t.value}`})}})});import{z as $o}from"zod";var Da,Vo,Uo=m(()=>{"use strict";C();Da=$o.object({selector:$o.string().describe("CSS selector for the checkbox to uncheck")}),Vo=h({description:"Uncheck a checkbox matching the CSS selector",name:"uncheck",schema:Da,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).uncheck({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"uncheck"};return v({assertions:[],detail:`Unchecked ${t.selector}`,duration:performance.now()-r,nodeType:"uncheck",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Uncheck ${t.selector}`})}})});import{z as Do}from"zod";var Fa,Fo,Oo=m(()=>{"use strict";C();Fa=Do.object({ms:Do.number().describe("Milliseconds to wait")}),Fo=h({description:"Wait for a specified duration in milliseconds",name:"wait",schema:Fa,execute:async(e,t)=>{let r=performance.now();await e.page.waitForTimeout(t.ms);let n=`agent-step-${String(e.stepIndex)}`,o={duration:t.ms,id:n,type:"wait"};return v({assertions:[],detail:`Waited ${String(t.ms)}ms`,duration:performance.now()-r,nodeType:"wait",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Wait ${String(t.ms)}ms`})}})});import{z as jt}from"zod";var Oa,Wo,Lo=m(()=>{"use strict";C();Oa=jt.object({selector:jt.string().describe("CSS selector for the element to wait for"),state:jt.enum(["visible","hidden","attached","detached"]).default("visible").describe("The state to wait for (default: visible)")}),Wo=h({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:Oa,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).waitFor({state:t.state,timeout:15e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},state:t.state,type:"waitFor"};return v({assertions:[],detail:`Waited for ${t.selector} to be ${t.state}`,duration:performance.now()-r,nodeType:"waitFor",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Wait for ${t.selector} to be ${t.state}`})}})});function Pe(e){let t=[],r=[],n=[],o=new Map;function a(f){t.push({level:f.type(),text:f.text(),timestamp:Date.now(),url:f.location().url})}function s(f){let g=new Be(f);o.set(f,g),r.push(g)}function i(f){let g=o.get(f.request());g!=null&&(o.delete(f.request()),g.applyResponse(f))}function l(f){n.push(`${f.message}
|
|
28
|
+
${f.stack??""}`)}function c(f){let g=f.failure(),y=new Be(f);y.responseBody=`(request failed: ${g?.errorText??"unknown"})`,r.push(y)}e.on("console",a),e.on("request",s),e.on("response",i),e.on("pageerror",l),e.on("requestfailed",c);function p(){e.off("console",a),e.off("request",s),e.off("response",i),e.off("pageerror",l),e.off("requestfailed",c)}return{consoleEntries:t,detach:p,networkEntries:r,pageErrors:n}}var Be,It=m(()=>{"use strict";Be=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(r=>{this.responseBody=r.length>1e5?`${r.slice(0,1e5)}... (truncated)`:r}).catch(()=>{this.responseBody="(unable to read body)"})}}});async function zo({input:e,monitor:t,name:r,page:n,runStartTime:o,stepIndex:a}){let s=Wa.get(r);if(s==null)throw new Error(`Unknown agent tool: ${r}`);return s.execute({monitor:t,page:n,runStartTime:o,stepIndex:a},e)}var Nt,Wa,qo,Bo,Mo=m(()=>{"use strict";$r();Dr();Wr();Br();_r();Jr();Kr();Zr();ro();ao();io();uo();mo();ho();So();Po();vo();Co();No();Eo();Uo();Oo();Lo();It();Nt=[fo,qr,Yr,yo,Or,Vo,Ao,co,Fo,Wo,bo,so,Io,Ur,Er,Xr,to,no,xo,To,wo,Hr,Mr],Wa=new Map(Nt.map(e=>[e.name,e])),qo=Nt.map(e=>e.anthropicTool),Bo=Nt.map(e=>`- **${e.name}**: ${e.anthropicTool.description??""}`).join(`
|
|
29
|
+
`)});import La from"pino";function A(e){return d.fatal(e),process.exit(1)}var d,W=m(()=>{"use strict";d=La({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}})});import qa from"@anthropic-ai/sdk";async function Re({baseUrl:e,executedPreconditions:t,extraVariables:r,onStep:n,page:o,runId:a,serverUrl:s,spec:i,systemPrompt:l,token:c,workflowContext:p}){let f=new qa({apiKey:"ripplo",baseURL:`${s}/api/proxy/anthropic`,defaultHeaders:{Authorization:`Bearer ${c}`,"x-run-id":a}}),g=performance.now(),y=Pe(o);await Ja({baseUrl:e,page:o});let x=Ma({extraVariables:r,spec:i}),b=_a({baseUrl:e,executedPreconditions:t,spec:i,systemPrompt:l,variables:x,workflowContext:p}),N=Ga({baseUrl:e,spec:i,variables:x}),I=[{content:Ha({page:o,startUrl:N}),role:"user"}],re=[],ye=[],he=0,Le="",q;for(let St=0;St<Ba;St++){d.info("Agent iteration %d",St+1);let Xn=await f.messages.create({max_tokens:za,messages:I,model:"server-controlled",system:b,tools:qo}),le=await Ya({messages:I,monitor:y,onStep:n,page:o,response:Xn,runStartTime:g,specNodes:ye,stepIndex:he,steps:re});if(he=le.nextStepIndex,le.newFindings.length>0&&(Le=le.newFindings),le.verdict!=null&&(q=le.verdict),!le.continueLoop)break}let wt=Qa(ye);return{findings:Le,generatedSpec:wt,monitor:y,steps:re,verdict:q??"fail"}}function Ma({extraVariables:e,spec:t}){return{...Se({defs:t?.variables}),...e}}function _a({baseUrl:e,executedPreconditions:t,spec:r,systemPrompt:n,variables:o,workflowContext:a}){let s=a==null?"":[`
|
|
30
30
|
|
|
31
31
|
## Workflow Under Test`,`**Name:** ${a.name}`,`**Description:** ${a.description}`,`**Expected Outcome:** ${a.expectedOutcome}`,`
|
|
32
32
|
Focus your testing ONLY on this specific workflow. Do not test unrelated parts of the application.`].join(`
|
|
@@ -42,55 +42,55 @@ ${JSON.stringify(r,null,2)}
|
|
|
42
42
|
The following setup steps have already been run before your session started:
|
|
43
43
|
${l}
|
|
44
44
|
|
|
45
|
-
Do not repeat any of these steps.`,p=Object.entries(o),f=p.map(([y,
|
|
45
|
+
Do not repeat any of these steps.`,p=Object.entries(o),f=p.map(([y,x])=>`- **${y}:** ${String(x)}`).join(`
|
|
46
46
|
`),g=p.length===0?"":`
|
|
47
47
|
|
|
48
48
|
## Resolved Variables
|
|
49
49
|
${f}`;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.",`
|
|
50
50
|
## Available Tools`,Bo,s,c,i,g,`
|
|
51
51
|
## Agent Profile (HIGHEST PRIORITY \u2014 these instructions override any defaults above)`,n].join(`
|
|
52
|
-
`)}function
|
|
53
|
-
`),nextStepIndex:i,verdict:void 0};let f=[],g=i,y;for(let
|
|
54
|
-
`),nextStepIndex:g,verdict:y}}async function Ka({block:e,monitor:t,onStep:r,page:n,runStartTime:o,specNodes:a,stepIndex:s,steps:i}){try{let l=await zo({input:e.input,monitor:t,name:e.name,page:n,runStartTime:o,stepIndex:s}),c={content:l.toolOutput,tool_use_id:e.id,type:"tool_result"};return l.kind==="verdict"?(d.info(" [%d] %s \u2014 verdict: %s",s,e.name,l.verdict),{nextStepIndex:s,toolResult:c,verdict:l.verdict}):(l.specNode!=null&&a.push(l.specNode),l.stepResult!=null?(i.push(l.stepResult),r?.(l.stepResult),d.info(" [%d] %s \u2014 %s",s,e.name,l.stepResult.status),{nextStepIndex:s+1,toolResult:c,verdict:void 0}):(d.info(" [%d] %s \u2014 info",s,e.name),{nextStepIndex:s,toolResult:c,verdict:void 0}))}catch(l){let c=l instanceof Error?l.message:"Unknown error";d.error(" [%d] %s \u2014 error: %s",s,e.name,c);let p=await Q({page:n,runStartTime:o,targets:[]}),f={annotations:p.annotations,assertions:[],detail:`Error: ${c}`,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(f),r?.(f),{nextStepIndex:s+1,toolResult:{content:`Error: ${c}`,is_error:!0,tool_use_id:e.id,type:"tool_result"},verdict:void 0}}}function Qa(e){if(e.length===0)return{entryNode:"",nodes:{},version:2};let t={};e.forEach((n,o)=>{let a=e[o+1],s=a==null?n:{...n,next:a.id};t[n.id]=s});let r=e[0];if(r==null)throw new Error("Expected at least one spec node after length check");return{entryNode:r.id,nodes:t,version:2}}var Ba,za,At=m(()=>{"use strict";Mo();
|
|
55
|
-
${e}`];
|
|
52
|
+
`)}function Ga({baseUrl:e,spec:t,variables:r}){if(t==null)return e;let n=t.nodes[t.entryNode];if(n==null||n.type!=="goto"||n.url.type!=="static")return e;let a=n.url.value.replaceAll(/\{\{(\w+)\}\}/g,(s,i)=>{let l=r[i];return l==null?`{{${i}}}`:String(l)});return a.startsWith("http")?a:`${e}${a.startsWith("/")?"":"/"}${a}`}function Ha({page:e,startUrl:t}){let r=e.url();return r!=="about:blank"&&r.length>0?`You are already on the page at ${r}. Begin testing from this page \u2014 do not navigate away unless the workflow requires it.`:`Navigate to ${t} and begin testing.`}async function Ja({baseUrl:e,page:t}){let r=new URL(e).origin;await t.route("**/*",n=>{let o=n.request();return o.isNavigationRequest()&&new URL(o.url()).origin!==r?(d.warn("Blocked navigation to off-origin URL: %s",o.url()),n.abort("blockedbyclient")):n.continue()})}async function Ya({messages:e,monitor:t,onStep:r,page:n,response:o,runStartTime:a,specNodes:s,stepIndex:i,steps:l}){let c=o.content.filter(N=>N.type==="text").map(N=>N.text),p=o.content.filter(N=>N.type==="tool_use");if(p.length===0)return{continueLoop:!1,newFindings:c.join(`
|
|
53
|
+
`),nextStepIndex:i,verdict:void 0};let f=[],g=i,y,x;for(let N of p){let w=await Ka({block:N,monitor:t,onStep:r,page:n,runStartTime:a,specNodes:s,stepIndex:g,steps:l});f.push(w.toolResult),g=w.nextStepIndex,w.verdict!=null&&(y=w.verdict,x=w.summary)}e.push({content:o.content,role:"assistant"},{content:f,role:"user"});let b=x??c.join(`
|
|
54
|
+
`);return{continueLoop:y==null&&o.stop_reason==="tool_use",newFindings:b,nextStepIndex:g,verdict:y}}async function Ka({block:e,monitor:t,onStep:r,page:n,runStartTime:o,specNodes:a,stepIndex:s,steps:i}){try{let l=await zo({input:e.input,monitor:t,name:e.name,page:n,runStartTime:o,stepIndex:s}),c={content:l.toolOutput,tool_use_id:e.id,type:"tool_result"};return l.kind==="verdict"?(d.info(" [%d] %s \u2014 verdict: %s",s,e.name,l.verdict),{nextStepIndex:s,summary:l.summary,toolResult:c,verdict:l.verdict}):(l.specNode!=null&&a.push(l.specNode),l.stepResult!=null?(i.push(l.stepResult),r?.(l.stepResult),d.info(" [%d] %s \u2014 %s",s,e.name,l.stepResult.status),{nextStepIndex:s+1,summary:void 0,toolResult:c,verdict:void 0}):(d.info(" [%d] %s \u2014 info",s,e.name),{nextStepIndex:s,summary:void 0,toolResult:c,verdict:void 0}))}catch(l){let c=l instanceof Error?l.message:"Unknown error";d.error(" [%d] %s \u2014 error: %s",s,e.name,c);let p=await Q({page:n,runStartTime:o,targets:[]}),f={annotations:p.annotations,assertions:[],detail:`Error: ${c}`,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(f),r?.(f),{nextStepIndex:s+1,summary:void 0,toolResult:{content:`Error: ${c}`,is_error:!0,tool_use_id:e.id,type:"tool_result"},verdict:void 0}}}function Qa(e){if(e.length===0)return{entryNode:"",nodes:{},version:2};let t={};e.forEach((n,o)=>{let a=e[o+1],s=a==null?n:{...n,next:a.id};t[n.id]=s});let r=e[0];if(r==null)throw new Error("Expected at least one spec node after length check");return{entryNode:r.id,nodes:t,version:2}}var Ba,za,At=m(()=>{"use strict";Mo();W();be();K();Ba=50,za=16384});function xe({description:e,output:t,successCriteria:r}){let n=[`## Agent Identity
|
|
55
|
+
${e}`];t!=null&&t.length>0&&n.push(`## Output
|
|
56
56
|
${t}`),r!=null&&r.length>0&&n.push(`## Success Criteria
|
|
57
|
-
${r}`)
|
|
57
|
+
${r}`);let o=["## 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.',Xa({hasSuccessCriteria:r!=null&&r.length>0}),Za({hasOutput:t!=null&&t.length>0})];return n.push(o.join(`
|
|
58
58
|
`)),n.join(`
|
|
59
59
|
|
|
60
|
-
`)}var Et=m(()=>{"use strict"});import{execFileSync as
|
|
60
|
+
`)}function Xa({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 Za({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 Et=m(()=>{"use strict"});import{execFileSync as es}from"child_process";import{createRequire as ts}from"module";import _o from"fs";import{chromium as $t}from"playwright";async function H({headed:e}){d.info("Browser executable: %s",$t.executablePath());try{return await $t.launch({headless:!e})}catch(t){throw rs(t)?new Error(`Playwright browsers are not installed. Run:
|
|
61
61
|
|
|
62
62
|
npx playwright install chromium
|
|
63
|
-
`):t}}function Vt(){let e=$t.executablePath();if(
|
|
63
|
+
`):t}}function Vt(){let e=$t.executablePath();if(_o.existsSync(e))return;d.info("Chromium not found. Installing via Playwright...");let r=ts(import.meta.url).resolve("playwright/cli");if(es(process.execPath,[r,"install","chromium"],{stdio:"inherit"}),!_o.existsSync(e))throw new Error(`Playwright browser installation failed. Try running manually:
|
|
64
64
|
|
|
65
65
|
npx playwright install chromium
|
|
66
|
-
`);d.info("\u2713 Chromium installed")}function
|
|
66
|
+
`);d.info("\u2713 Chromium installed")}function rs(e){return e instanceof Error?e.message.includes("Executable doesn't exist"):!1}var ze=m(()=>{"use strict";W()});import{mkdir as Ut,writeFile as M}from"fs/promises";import F from"path";async function Me({context:e,page:t,runId:r,stepIndex:n,stepResult:o}){try{let a=F.join(process.cwd(),".ripplo","debug",r,"steps",String(n));await Ut(a,{recursive:!0});let s={annotations:o.annotations,assertions:o.assertions,detail:o.detail,duration:o.duration,nodeId:o.nodeId,nodeType:o.nodeType,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth};await Promise.all([M(F.join(a,"info.json"),JSON.stringify(s,null,2)),M(F.join(a,"screenshot.png"),Buffer.from(o.screenshotBase64,"base64")),os({context:e,page:t,stepDir:a})])}catch(a){let s=a instanceof Error?a.message:String(a);d.warn("Failed to write step debug data for step %d: %s",n,s)}}async function os({context:e,page:t,stepDir:r}){let[n,o,a]=await Promise.all([t.content().catch(()=>"(unable to capture DOM)"),ns(t),as({context:e,page:t})]);await Promise.all([M(F.join(r,"dom.html"),n),M(F.join(r,"accessibility-tree.txt"),o),M(F.join(r,"storage.json"),JSON.stringify(a,null,2))])}async function ns(e){try{return await e.locator(":root").ariaSnapshot()}catch{return"(unable to capture accessibility tree)"}}async function as({context:e,page:t}){let[r,n]=await Promise.all([t.evaluate(()=>({localStorage:Object.fromEntries(Array.from({length:localStorage.length},(o,a)=>{let s=localStorage.key(a);return s==null?void 0:[s,localStorage.getItem(s)??""]}).filter(o=>o!=null)),sessionStorage:Object.fromEntries(Array.from({length:sessionStorage.length},(o,a)=>{let s=sessionStorage.key(a);return s==null?void 0:[s,sessionStorage.getItem(s)??""]}).filter(o=>o!=null))})).catch(()=>({localStorage:{},sessionStorage:{}})),e.cookies().catch(()=>[])]);return{cookies:n,localStorage:r.localStorage,sessionStorage:r.sessionStorage}}async function _e({monitor:e,runId:t,steps:r,summary:n}){try{let o=F.join(process.cwd(),".ripplo","debug",t);await Ut(o,{recursive:!0}),await Promise.all([M(F.join(o,"summary.txt"),ss({steps:r,summary:n})),M(F.join(o,"console.log"),is(e.consoleEntries)),M(F.join(o,"network.jsonl"),ls(e.networkEntries)),M(F.join(o,"page-errors.log"),e.pageErrors.join(`
|
|
67
67
|
---
|
|
68
|
-
`))]),d.info("Debug artifacts written to .ripplo/debug/%s/",t)}catch(o){let a=o instanceof Error?o.message:String(o);d.warn("Failed to write run debug summary: %s",a)}}function
|
|
69
|
-
`)}function
|
|
70
|
-
`)}function
|
|
71
|
-
`)}async function
|
|
68
|
+
`))]),d.info("Debug artifacts written to .ripplo/debug/%s/",t)}catch(o){let a=o instanceof Error?o.message:String(o);d.warn("Failed to write run debug summary: %s",a)}}function ss({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(n=>` [${String(n.stepIndex)}] ${n.status==="passed"?"\u2713":"\u2717"} ${n.title} (${String(n.duration)}ms) \u2014 ${n.detail??"ok"}`)].join(`
|
|
69
|
+
`)}function is(e){return e.map(t=>`[${new Date(t.timestamp).toISOString()}] [${t.level.toUpperCase()}] (${t.url}) ${t.text}`).join(`
|
|
70
|
+
`)}function ls(e){return e.map(t=>JSON.stringify(t)).join(`
|
|
71
|
+
`)}async function Go({error:e,runId:t,stack:r,workflowName:n}){try{let o=F.join(process.cwd(),".ripplo","debug",t);await Ut(o,{recursive:!0});let a=r==null?e:`${e}
|
|
72
72
|
|
|
73
73
|
${r}`,s=[`Run ID: ${t}`,`Workflow: ${n}`,"Status: failed","",`Error: ${e}`,"",r==null?"":`Stack trace:
|
|
74
74
|
${r}`].join(`
|
|
75
|
-
`);await Promise.all([M(
|
|
75
|
+
`);await Promise.all([M(F.join(o,"error.txt"),a),M(F.join(o,"summary.txt"),s)]),d.info("Debug error artifacts written to .ripplo/debug/%s/",t)}catch(o){let a=o instanceof Error?o.message:String(o);d.warn("Failed to write error debug artifacts: %s",a)}}var Ge=m(()=>{"use strict";W()});async function Dt({baseUrl:e,cookies:t,executedPreconditions:r,extraVariables:n,headed:o,navigateTo:a,runId:s,serverUrl:i,spec:l,streaming:c,systemPrompt:p,token:f,workflowContext:g}){let y=await H({headed:o}),x=await y.newContext({baseURL:e});t.length>0&&(await x.addCookies([...t]),d.info("Injected %d cookies from preconditions",t.length));let b=await x.newPage();a!=null&&(d.info("Navigating to precondition start page: %s",a),await b.goto(a,{waitUntil:"domcontentloaded"}));try{let w=function(q){c.enqueueStep(q),Me({context:x,page:b,runId:s,stepIndex:q.stepIndex,stepResult:q})};var N=w;let I=await Re({baseUrl:e,executedPreconditions:r,extraVariables:n,onStep:w,page:b,runId:s,serverUrl:i,spec:l,systemPrompt:p,token:f,workflowContext:g}),re=I.verdict==="pass"?"passed":"failed";await c.complete({statusOverride:re,steps:I.steps,summary:I.findings});let ye=I.steps.filter(q=>q.status==="passed").length,he=I.steps.filter(q=>q.status==="failed").length,Le={duration:I.steps.reduce((q,wt)=>q+wt.duration,0),failCount:he,passCount:ye,runId:s,status:re,workflowName:g.name};await _e({monitor:I.monitor,runId:s,steps:I.steps,summary:Le}),d.info("Agent test complete: %d passed, %d failed",ye,he),d.info(`
|
|
76
76
|
=== Agent Summary ===
|
|
77
|
-
%s`,I.findings)}finally{await y.close()}}var Ft=m(()=>{"use strict";ze();At();
|
|
77
|
+
%s`,I.findings)}finally{await y.close()}}var Ft=m(()=>{"use strict";ze();At();Ge();W()});async function Ot({expected:e,locator:t,operator:r,timeout:n}){let o=await t.textContent({timeout:n});return X({actual:o??"",expected:e,label:"Text",operator:r})}function Wt({expected:e,operator:t,url:r}){return X({actual:r,expected:e,label:"URL",operator:t})}async function Lt({expected:e,locator:t,operator:r}){let n=await t.count();return He({actual:n,expected:e,label:"Count",operator:r})}async function qt({expected:e,locator:t,operator:r,timeout:n}){let o=await t.inputValue({timeout:n});return X({actual:o,expected:e,label:"Value",operator:r})}async function ve({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 ke({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 Ho({attribute:e,expected:t,locator:r,operator:n,timeout:o}){let a=await r.getAttribute(e,{timeout:o});return X({actual:a??"",expected:t,label:`Attribute "${e}"`,operator:n})}async function Jo({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 Yo({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 X(e){let t=`${e.label} ${e.operator} "${e.expected}"`,r=cs(e),n=r?void 0:`Got: "${e.actual}"`;return{description:t,detail:n,status:r?"passed":"failed"}}function cs({actual:e,expected:t,operator:r}){return r==="equals"?e===t:r==="notEquals"?e!==t:r==="contains"?e.includes(t):r==="startsWith"?e.startsWith(t):r==="endsWith"?e.endsWith(t):new RegExp(t).test(e)}function He(e){let t=`${e.label} ${e.operator} ${String(e.expected)}`,r=ds(e),n=r?void 0:`Got: ${String(e.actual)}`;return{description:t,detail:n,status:r?"passed":"failed"}}function ds({actual:e,expected:t,operator:r}){return r==="equals"?e===t:r==="notEquals"?e!==t:r==="greaterThan"?e>t:r==="greaterThanOrEqual"?e>=t:r==="lessThan"?e<t:e<=t}var Je=m(()=>{"use strict"});import{print as us}from"graphql";async function k(e){let t=us(e.document),r=JSON.stringify({query:t,variables:e.variables}),o=await(await fetch(`${e.config.ripploServerUrl}/graphql`,{body:r,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST"})).json();if(!ps(o))throw new Error("Invalid GraphQL response");if(fs(o))throw new Error(o.errors.map(a=>a.message).join(", "));if(o.data==null)throw new Error("No data returned from server");return o.data}function ps(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function fs(e){return Array.isArray(e.errors)&&e.errors.length>0}var Te=m(()=>{"use strict"});import{readdir as ms,rm as gs,stat as ys}from"fs/promises";import Xo from"path";import{graphql as hs}from"gql.tada";async function Ce({maxRuns:e}){try{let r=(await ms(Ko,{withFileTypes:!0})).filter(c=>c.isDirectory()),n=Date.now(),o=await Promise.all(r.map(async c=>{let p=Xo.join(Ko,c.name),f=await ys(p);return{dirPath:p,mtime:f.mtimeMs}})),a=o.filter(c=>n-c.mtime>Qo),i=o.filter(c=>n-c.mtime<=Qo).toSorted((c,p)=>p.mtime-c.mtime).slice(e),l=[...a,...i];if(l.length===0)return;await Promise.allSettled(l.map(c=>gs(c.dirPath,{force:!0,recursive:!0}))),d.info("Pruned %d old debug run(s)",l.length)}catch{d.warn("Debug run pruning failed, ignoring")}}var Ko,Qo,Tp,Zo=m(()=>{"use strict";Te();W();Ko=Xo.join(process.cwd(),".ripplo","debug"),Qo=360*60*1e3,Tp=hs(`
|
|
78
78
|
mutation RevokeCurrentCliToken {
|
|
79
79
|
revokeCurrentCliToken
|
|
80
80
|
}
|
|
81
|
-
`)});async function Bt({condition:e,page:t,timeout:r,variables:n}){switch(e.type){case"elementVisible":return(await ve({locator:
|
|
81
|
+
`)});async function Bt({condition:e,page:t,timeout:r,variables:n}){switch(e.type){case"elementVisible":return(await ve({locator:P({locator:e.locator,page:t}),timeout:r})).status==="passed";case"elementNotVisible":return(await ke({locator:P({locator:e.locator,page:t}),timeout:r})).status==="passed";case"urlMatch":{let o=$({ref:e.expected,variables:n});return X({actual:t.url(),expected:o,label:"URL",operator:e.operator}).status==="passed"}case"textMatch":{let a=await P({locator:e.locator,page:t}).textContent({timeout:r}),s=$({ref:e.expected,variables:n});return X({actual:a??"",expected:s,label:"Text",operator:e.operator}).status==="passed"}case"variableCompare":{let o=n[e.variable];if(o==null)throw new Error(`Variable "${e.variable}" is not defined`);let a=typeof o=="number"?o:Number(o),s=oe({ref:e.expected,variables:n}),i=typeof s=="number"?s:Number(s);return He({actual:a,expected:i,label:e.variable,operator:e.operator}).status==="passed"}}}var zt=m(()=>{"use strict";Je();we();K()});import ce from"fs";import Mt from"path";import{z as Z}from"zod";function en(e){if(!ce.existsSync(e))return null;let t=ce.readFileSync(e,"utf8");return JSON.parse(t)}function B(){let e=en(tn),t=en(rn);if(e==null||t==null)return null;let r=bs.safeParse({...e,...t});return r.success?r.data:null}function J(e){ce.existsSync(Ye)||ce.mkdirSync(Ye,{recursive:!0});let{ripploServerUrl:t,token:r,...n}=e;ce.writeFileSync(tn,JSON.stringify(n,null,2)+`
|
|
82
82
|
`),ce.writeFileSync(rn,JSON.stringify({ripploServerUrl:t,token:r},null,2)+`
|
|
83
|
-
`)}var ys,hs,ws,Ye,tn,rn,on=m(()=>{"use strict";ys=Z.object({baseUrl:Z.string().optional(),cloudBaseUrl:Z.string(),preconditionApiPath:Z.string().optional(),projectId:Z.string()}),hs=Z.object({ripploServerUrl:Z.string(),token:Z.string()}),ws=ys.extend(hs.shape),Ye=Mt.join(process.cwd(),".ripplo"),tn=Mt.join(Ye,"settings.json"),rn=Mt.join(Ye,"settings.local.json")});async function Gt({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){let c=await Bt({condition:r.condition,page:n,timeout:s,variables:i})?r.consequent:r.alternate??[];return c.length===0?{steps:[],variables:i}:e({failFast:t,nodeIds:c,page:n,spec:o,startIndex:a,timeout:s,variables:i})}async function _t({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){let l=[],c=i;for(let p=0;p<r.times;p++){r.iteratorVar!=null&&(c=ne({name:r.iteratorVar,store:c,value:p}));let f=await e({failFast:t,nodeIds:r.body,page:n,spec:o,startIndex:a+l.length,timeout:s,variables:c});if(l.push(...f.steps),c=f.variables,t&&f.steps.some(g=>g.status==="failed"))break}return{steps:l,variables:c}}async function Ht({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){let l=bs({collection:r.collection,variables:i}),c=[],p=i;for(let f of l){p=ne({name:r.iteratorVar,store:p,value:Ss(f)});let g=await e({failFast:t,nodeIds:r.body,page:n,spec:o,startIndex:a+c.length,timeout:s,variables:p});if(c.push(...g.steps),p=g.variables,t&&g.steps.some(y=>y.status==="failed"))break}return{steps:c,variables:p}}function Ss(e){return typeof e=="object"&&e!=null?JSON.stringify(e):e==null?"":String(e)}function bs({collection:e,variables:t}){if(Array.isArray(e))return e;let r=t[e.name];if(r==null)throw new Error(`Variable "${e.name}" is not defined`);return Ps(r)}function Ps(e){if(typeof e!="string")return[e];try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return[e]}async function Jt({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){let l=await Promise.all(r.branches.map(f=>e({failFast:t,nodeIds:f,page:n,spec:o,startIndex:a,timeout:s,variables:i}))),c=l.flatMap(f=>f.steps),p=Rs({base:i,results:l});return{steps:c,variables:p}}function Rs({base:e,results:t}){let r=e;return t.forEach(n=>{r={...r,...n.variables}}),r}async function Yt({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){let l=[],c=i;try{let p=await e({failFast:t,nodeIds:r.body,page:n,spec:o,startIndex:a,timeout:s,variables:c});if(l.push(...p.steps),c=p.variables,p.steps.some(g=>g.status==="failed")&&r.catch!=null){let g=await e({failFast:t,nodeIds:r.catch,page:n,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...g.steps),c=g.variables}}catch{if(r.catch!=null){let p=await e({failFast:t,nodeIds:r.catch,page:n,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...p.steps),c=p.variables}}finally{if(r.finally!=null){let p=await e({failFast:t,nodeIds:r.finally,page:n,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...p.steps),c=p.variables}}return{steps:l,variables:c}}async function Kt({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){return e({failFast:t,nodeIds:r.nodes,page:n,spec:o,startIndex:a,timeout:s,variables:i})}var Qt=m(()=>{"use strict";zt();K()});import{z as T}from"zod";var xs,vs,ks,Ts,Cs,js,Is,x,Ke=m(()=>{"use strict";xs=T.object({by:T.literal("css"),value:T.string().min(1)}),vs=T.object({by:T.literal("testId"),value:T.string().min(1)}),ks=T.object({by:T.literal("role"),exact:T.boolean().optional(),name:T.string().optional(),role:T.string().min(1)}),Ts=T.object({by:T.literal("text"),exact:T.boolean().optional(),value:T.string().min(1)}),Cs=T.object({by:T.literal("label"),exact:T.boolean().optional(),value:T.string().min(1)}),js=T.object({by:T.literal("placeholder"),value:T.string().min(1)}),Is=T.object({by:T.literal("altText"),value:T.string().min(1)}),x=T.discriminatedUnion("by",[xs,vs,ks,Ts,Cs,js,Is])});import{z as nn}from"zod";var G,de,Qe=m(()=>{"use strict";G=nn.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),de=nn.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"])});import{z as A}from"zod";var Ns,Xt,ue,$,Xe,Ze=m(()=>{"use strict";Ns=A.object({type:A.literal("static"),value:A.union([A.string(),A.number(),A.boolean()])}),Xt=A.object({name:A.string().min(1),type:A.literal("variable")}),ue=A.discriminatedUnion("type",[Ns,Xt]),$=A.discriminatedUnion("type",[A.object({type:A.literal("static"),value:A.string()}),Xt]),Xe=A.discriminatedUnion("type",[A.object({type:A.literal("static"),value:A.number().int().nonnegative()}),Xt])});import{z as L}from"zod";var et,Zt=m(()=>{"use strict";Ke();Qe();Ze();et=L.discriminatedUnion("type",[L.object({locator:x,type:L.literal("elementVisible")}),L.object({locator:x,type:L.literal("elementNotVisible")}),L.object({expected:$,operator:G,type:L.literal("urlMatch")}),L.object({expected:$,locator:x,operator:G,type:L.literal("textMatch")}),L.object({expected:ue,operator:de,type:L.literal("variableCompare"),variable:L.string().min(1)})])});import{z as W}from"zod";var tt,er=m(()=>{"use strict";tt=W.discriminatedUnion("type",[W.object({default:W.string().optional(),type:W.literal("string")}),W.object({default:W.number().optional(),type:W.literal("number")}),W.object({default:W.boolean().optional(),type:W.literal("boolean")}),W.object({key:W.string().min(1),type:W.literal("env")})])});import{z as u}from"zod";var As,Y,w,Es,$s,Vs,Us,Ds,Fs,Ws,Os,qs,Ls,Bs,zs,Ms,Gs,_s,Hs,Js,Ys,Ks,Qs,Xs,Zs,ei,ti,ri,oi,ni,ai,si,ii,li,ci,di,ui,pi,fi,mi,gi,yi,an,sn,je,tr=m(()=>{"use strict";Zt();Ke();Qe();Ze();er();Zt();Ke();Qe();Ze();er();As=u.string().min(1),Y=u.array(As).min(1),w={comment:u.string().optional(),id:u.string().min(1),label:u.string().optional(),next:u.string().optional(),timeout:u.number().int().positive().optional()},Es=u.object({...w,type:u.literal("goto"),url:$}),$s=u.object({...w,locator:x,type:u.literal("click")}),Vs=u.object({...w,locator:x,type:u.literal("fill"),value:$}),Us=u.object({...w,locator:x,type:u.literal("select"),value:$}),Ds=u.object({...w,locator:x,type:u.literal("hover")}),Fs=u.object({...w,key:u.string().min(1),locator:x.optional(),type:u.literal("press")}),Ws=u.object({...w,locator:x,type:u.literal("check")}),Os=u.object({...w,locator:x,type:u.literal("uncheck")}),qs=u.object({...w,type:u.literal("screenshot")}),Ls=u.object({...w,height:u.number().int().positive(),type:u.literal("setViewport"),width:u.number().int().positive()}),Bs=u.object({...w,duration:u.number().int().positive(),type:u.literal("wait")}),zs=u.object({...w,message:u.string().min(1),type:u.literal("fail")}),Ms=u.object({...w,type:u.literal("setVariable"),value:ue,variable:u.string().min(1)}),Gs=u.object({...w,locator:x,type:u.literal("extractText"),variable:u.string().min(1)}),_s=u.object({...w,files:u.array(u.string()).min(1),locator:x,type:u.literal("upload")}),Hs=u.object({...w,locator:x,type:u.literal("dblclick")}),Js=u.object({...w,source:x,target:x,type:u.literal("drag")}),Ys=u.object({...w,locator:x,type:u.literal("scrollIntoView")}),Ks=u.object({...w,locator:x,type:u.literal("type"),value:$}),Qs=u.object({...w,locator:x,type:u.literal("focus")}),Xs=u.object({...w,locator:x,state:u.enum(["visible","hidden","attached","detached"]).optional(),type:u.literal("waitFor")}),Zs=u.object({...w,expected:$,operator:G,type:u.literal("waitForUrl")}),ei=u.object({...w,type:u.literal("waitForResponse"),urlPattern:$}),ti=u.object({...w,type:u.literal("waitForRequest"),urlPattern:$}),ri=u.object({...w,locator:x,type:u.literal("assertVisible")}),oi=u.object({...w,locator:x,type:u.literal("assertNotVisible")}),ni=u.object({...w,expected:$,locator:x,operator:G,type:u.literal("assertText")}),ai=u.object({...w,expected:$,operator:G,type:u.literal("assertUrl")}),si=u.object({...w,expected:Xe,locator:x,operator:de,type:u.literal("assertCount")}),ii=u.object({...w,expected:$,locator:x,operator:G,type:u.literal("assertValue")}),li=u.object({...w,attribute:u.string().min(1),expected:$,locator:x,operator:G,type:u.literal("assertAttribute")}),ci=u.object({...w,locator:x,type:u.literal("assertEnabled")}),di=u.object({...w,locator:x,type:u.literal("assertDisabled")}),ui=u.object({...w,alternate:Y.optional(),condition:et,consequent:Y,type:u.literal("if")}),pi=u.object({...w,body:Y,iteratorVar:u.string().min(1).optional(),times:u.number().int().positive(),type:u.literal("loop")}),fi=u.object({...w,body:Y,collection:u.union([u.array(u.record(u.string(),u.unknown())).min(1),u.object({name:u.string().min(1),type:u.literal("variable")})]),iteratorVar:u.string().min(1),type:u.literal("forEach")}),mi=u.object({...w,branches:u.array(Y).min(2),type:u.literal("parallel")}),gi=u.object({...w,body:Y,catch:Y.optional(),finally:Y.optional(),type:u.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),yi=u.object({...w,nodes:Y,type:u.literal("group")}),an=u.discriminatedUnion("type",[Es,$s,Vs,Us,Ds,Fs,Ws,Os,Xs,Zs,ei,ti,ri,oi,ni,ai,si,ii,li,ci,di,qs,Ls,Bs,zs,Ms,Gs,_s,Hs,Js,Ys,Ks,Qs,ui,pi,fi,mi,yi]),sn=u.union([an,gi]),je=u.object({entryNode:u.string().min(1),nodes:u.record(u.string(),sn),variables:u.record(u.string(),tt).optional(),version:u.literal(2)})});function ae(e){let t=je.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}}var ln=m(()=>{"use strict";tr()});var Ie=m(()=>{"use strict";tr();ln()});async function F({fn:e,label:t}){let r=performance.now(),n=await e();return d.info("%s: %dms",t,Math.round(performance.now()-r)),n}var rt=m(()=>{"use strict";z()});async function rr({failFast:e,onStep:t,page:r,spec:n,variables:o}){let a=performance.now();return Si({currentId:n.entryNode,failFast:e,onStep:t,page:r,runStartTime:a,spec:n,startIndex:0,variables:o})}function wi({onStep:e,steps:t,target:r}){t.forEach(n=>{r.push(n),e?.(n)})}async function Si({currentId:e,failFast:t,onStep:r,page:n,runStartTime:o,spec:a,startIndex:s,variables:i}){let l=[],c=i,p=e;for(;p!=null;){let f=a.nodes[p];if(f==null)throw new Error(`Node "${p}" not found in spec`);let y=await cn({failFast:t,node:f,nodeId:p,page:n,runStartTime:o,spec:a,startIndex:s+l.length,variables:c});if(wi({onStep:r,steps:y.steps,target:l}),c=y.variables,t&&y.steps.some(P=>P.status==="failed"))break;p=f.next}return{steps:l,variables:c}}async function cn({failFast:e,node:t,nodeId:r,page:n,runStartTime:o,spec:a,startIndex:s,variables:i}){let l=performance.now(),c=t.label??`${t.type} (${t.id})`,p=t.timeout??hi;if(bi(t))return Pi({failFast:e,node:t,page:n,spec:a,startIndex:s,timeout:p,variables:i});let f=ji({node:t,page:n});try{let g=await ki({node:t,page:n,timeout:p,variables:i}),y=Math.round(performance.now()-l),P=g.assertions.some(R=>R.status==="failed"),S=await F({label:`Snapshot [${c}]`,fn:()=>Q({page:n,runStartTime:o,targets:f})});return{steps:[{annotations:S.annotations,assertions:g.assertions,detail:void 0,duration:y,nodeId:r,nodeType:t.type,screenshotBase64:S.screenshotBase64,snapshotTimestamp:S.snapshotTimestamp,status:P?"failed":"passed",stepIndex:s,title:c,url:S.url,viewportHeight:S.viewportHeight,viewportWidth:S.viewportWidth}],variables:g.variables}}catch(g){let y=Math.round(performance.now()-l),P=g instanceof Error?g.message:String(g),S=await F({label:`Snapshot [${c}] (error)`,fn:()=>Q({page:n,runStartTime:o,targets:f})});return{steps:[{annotations:S.annotations,assertions:[],detail:P,duration:y,nodeId:r,nodeType:t.type,screenshotBase64:S.screenshotBase64,snapshotTimestamp:S.snapshotTimestamp,status:"failed",stepIndex:s,title:c,url:S.url,viewportHeight:S.viewportHeight,viewportWidth:S.viewportWidth}],variables:i}}}function bi(e){return["if","loop","forEach","parallel","try","group"].includes(e.type)}async function Pi({failFast:e,node:t,page:r,spec:n,startIndex:o,timeout:a,variables:s}){let i={executeSequence:vi,failFast:e,page:r,spec:n,startIndex:o,timeout:a,variables:s};switch(t.type){case"if":return Gt({...i,node:t});case"loop":return _t({...i,node:t});case"forEach":return Ht({...i,node:t});case"parallel":return Jt({...i,node:t});case"try":return Yt({...i,node:t});case"group":return Kt({...i,node:t})}}function Ri(e){return e.some(t=>t.status==="failed")}function xi({nodeId:e,spec:t,timeout:r}){let n=t.nodes[e];if(n==null)throw new Error(`Node "${e}" not found in spec`);return n.timeout==null?{...n,timeout:r}:n}async function vi({failFast:e,nodeIds:t,page:r,spec:n,startIndex:o,timeout:a,variables:s}){let i=[],l=s;for(let c of t){let p=xi({nodeId:c,spec:n,timeout:a}),f=await cn({failFast:e,node:p,nodeId:c,page:r,runStartTime:0,spec:n,startIndex:o+i.length,variables:l});if(i.push(...f.steps),l=f.variables,e&&Ri(f.steps))break}return{steps:i,variables:l}}async function ki({node:e,page:t,timeout:r,variables:n}){if(Ti(e)){let a=await Pt({node:e,page:t,timeout:r,variables:n});return{assertions:[],variables:a.variables}}return{assertions:await Ci({node:e,page:t,timeout:r,variables:n}),variables:n}}function Ti(e){return["goto","click","dblclick","fill","select","hover","press","check","uncheck","waitFor","waitForUrl","waitForResponse","waitForRequest","screenshot","setViewport","wait","fail","setVariable","extractText","upload","drag","scrollIntoView","type","focus"].includes(e.type)}async function Ci({node:e,page:t,timeout:r,variables:n}){let o=e;switch(o.type){case"assertVisible":return[await ve({locator:b({locator:o.locator,page:t}),timeout:r})];case"assertNotVisible":return[await ke({locator:b({locator:o.locator,page:t}),timeout:r})];case"assertText":{let a=E({ref:o.expected,variables:n});return[await Wt({expected:a,locator:b({locator:o.locator,page:t}),operator:o.operator,timeout:r})]}case"assertUrl":{let a=E({ref:o.expected,variables:n});return[Ot({expected:a,operator:o.operator,url:t.url()})]}case"assertCount":{let a=bt({ref:o.expected,variables:n});return[await qt({expected:a,locator:b({locator:o.locator,page:t}),operator:o.operator})]}case"assertValue":{let a=E({ref:o.expected,variables:n});return[await Lt({expected:a,locator:b({locator:o.locator,page:t}),operator:o.operator,timeout:r})]}case"assertAttribute":{let a=E({ref:o.expected,variables:n});return[await Ho({attribute:o.attribute,expected:a,locator:b({locator:o.locator,page:t}),operator:o.operator,timeout:r})]}case"assertEnabled":return[await Jo({locator:b({locator:o.locator,page:t}),timeout:r})];case"assertDisabled":return[await Yo({locator:b({locator:o.locator,page:t}),timeout:r})]}}function ji({node:e,page:t}){if(e.type==="assertUrl"||e.type==="waitForUrl")return[{label:e.type,type:"urlBar"}];if(e.type==="drag"){let o=b({locator:e.source,page:t}),a=b({locator:e.target,page:t});return[{label:"drag-source",locator:o,type:"action"},{label:"drag-target",locator:a,type:"action"}]}if(!Ii(e))return[];let r=e.type.startsWith("assert")?"assertion":"action",n=b({locator:e.locator,page:t});return[{label:e.type,locator:n,type:r}]}function Ii(e){return"locator"in e&&e.locator!=null}var hi,or=m(()=>{"use strict";Rt();Je();Qt();we();rt();be();K();hi=5e3});async function Ne({baseUrl:e,browser:t,cookies:r,extraVariables:n,navigateTo:o,onStep:a,runId:s,spec:i}){let l=await t.newContext({baseURL:e});r.length>0&&await l.addCookies(r);let c=await l.newPage(),p=Pe(c);o!=null&&await c.goto(o,{waitUntil:"domcontentloaded"});function f(R){a?.(R),Me({context:l,page:c,runId:s,stepIndex:R.stepIndex,stepResult:R})}let g={...Se({defs:i.variables}),...n},y=await rr({failFast:!0,onStep:f,page:c,spec:i,variables:g}),P=y.steps.filter(R=>R.status==="passed").length,S=y.steps.filter(R=>R.status==="failed").length,B={duration:y.steps.reduce((R,I)=>R+I.duration,0),failCount:S,passCount:P,runId:s,status:S>0?"failed":"passed",workflowName:""};return await Ge({monitor:p,runId:s,steps:y.steps,summary:B}),await l.close(),y.steps}var nr=m(()=>{"use strict";It();_e();or();K()});import{z as ot}from"zod";var ar,sr=m(()=>{"use strict";ar=ot.object({from:ot.string().min(1).describe("Key of the source state in the states record"),to:ot.string().min(1).describe("Key of the target state in the states record"),workflow:ot.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 Ni,ir,lr,Ai,Ei,Ae,cr=m(()=>{"use strict";Ni=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"),ir=j.object({satisfied:j.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),lr=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."),Ai=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."),Ei=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"),Ae=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 nt}from"zod";var dr,ur=m(()=>{"use strict";dr=nt.object({preconditions:nt.array(nt.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:nt.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 ee}from"zod";var at,pr=m(()=>{"use strict";sr();cr();ur();at=ee.object({edges:ee.array(ar).describe("Directed edges between states, each executed by a workflow"),preconditions:ee.record(ee.string(),Ae).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:ee.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:ee.record(ee.string(),dr).describe("States keyed by stable ID (kebab-case)"),version:ee.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions")});var dn=m(()=>{"use strict";pr()});var st=m(()=>{"use strict";sr();pr();cr();ur();dn()});import{parseSetCookie as $i}from"set-cookie-parser";import{z as un}from"zod";async function Ee({apiUrl:e,cookies:t,executed:r}){if(r.length!==0)try{let n=await fetch(`${e}/teardown`,{body:JSON.stringify({preconditions:r}),headers:{"Content-Type":"application/json",...fr({cookies:t})},method:"PUT"});n.ok||d.error("Teardown returned %s",String(n.status))}catch{d.error("Teardown request failed")}}function Vi({preconditionNames:e,preconditions:t}){let r=[],n=new Set;function o(a){if(n.has(a))return;n.add(a);let s=t[a];s?.depends!=null&&s.depends.forEach(i=>{o(i)}),r.push(a)}return e.forEach(a=>{o(a)}),r}async function Ui({apiUrl:e,cookies:t,name:r}){let n=await fetch(`${e}/check`,{body:JSON.stringify({precondition:r}),headers:{"Content-Type":"application/json",...fr({cookies:t})},method:"POST"});if(!n.ok)return!1;let o=await n.json(),a=ir.safeParse(o);if(!a.success)throw new Error(`Check response for "${r}" has invalid shape: ${a.error.message}`);return a.data.satisfied}async function Di({apiUrl:e,cookies:t,name:r}){let n=await fetch(`${e}/execute`,{body:JSON.stringify({precondition:r}),headers:{"Content-Type":"application/json",...fr({cookies:t})},method:"PUT"});if(!n.ok)throw new Error(`Execute for "${r}" returned ${String(n.status)}`);let o=await n.json(),a=lr.safeParse(o);if(!a.success)throw new Error(`Execute response for "${r}" has invalid shape: ${a.error.message}`);if(!a.data.success){let i=a.data.error??"no error detail";throw new Error(`Precondition "${r}" failed to execute: ${i}`)}return{cookies:Fi({domain:new URL(e).hostname,res:n}),data:a.data.data??{},navigateTo:a.data.navigateTo}}function fr({cookies:e}){return e.length===0?{}:{Cookie:e.map(r=>`${r.name}=${r.value}`).join("; ")}}function Fi({domain:e,res:t}){let r=t.headers.getSetCookie();return $i(r,{decodeValues:!1}).map(o=>Wi({cookie:o,domain:e}))}function Wi({cookie:e,domain:t}){let r={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&&(r.sameSite=qi({raw:e.sameSite})),e.expires!=null?r.expires=Math.floor(e.expires.getTime()/1e3):e.maxAge!=null&&(r.expires=Math.floor(Date.now()/1e3)+e.maxAge),r}function qi({raw:e}){return Oi[e.toLowerCase()]??"Lax"}async function se({baseUrl:e,project:t,workflowSlug:r}){let n={apiUrl:void 0,cookies:[],data:{},executed:[],navigateTo:void 0},o=t.stateGraph;if(o==null)return n;let a=(o.edges??[]).find(p=>p.workflowSlug===r);if(a?.sourceState==null)return n;let s=zi({baseUrl:e,preconditionApiPath:t.preconditionApiPath}),i=a.sourceState.preconditions;if(i.length===0)return{...n,apiUrl:s};if(s==null)return n;let l=Li.safeParse(o.preconditions);if(!l.success)return{...n,apiUrl:s};let c=await Bi({apiUrl:s,preconditionNames:i,preconditions:l.data});return{apiUrl:s,cookies:c.cookies,data:c.data,executed:c.executed,navigateTo:c.navigateTo}}async function Bi({apiUrl:e,preconditionNames:t,preconditions:r}){let n=Vi({preconditionNames:t,preconditions:r}),o=[],a={},s=[],i,l=Promise.resolve();return n.forEach(c=>{l=l.then(async()=>{if(await Ui({apiUrl:e,cookies:o,name:c}))return;let f=await Di({apiUrl:e,cookies:o,name:c});o.push(...f.cookies),Object.entries(f.data).forEach(([g,y])=>{a[g]=y}),s.push(c),f.navigateTo!=null&&(i=f.navigateTo)})}),await l,{cookies:o,data:a,executed:s,navigateTo:i}}function zi({baseUrl:e,preconditionApiPath:t}){if(t.length!==0)return t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`}var Oi,Li,mr=m(()=>{"use strict";st();st();z();Oi={lax:"Lax",none:"None",strict:"Strict"};Li=un.record(un.string(),Ae)});import{graphql as gr}from"gql.tada";async function $e({agentProfileId:e,config:t,runId:r}){let n=await k({config:t,document:Gi,variables:{agentProfileId:e??null,platform:"chromium",runId:r}});if(n.startRun==null)throw new Error("Failed to start run");let o=n.startRun.id,a=Promise.resolve();function s(l){a=a.then(()=>Mi({config:t,runResultId:o,steps:[l]})).catch(c=>{let p=c instanceof Error?c.message:"Unknown error";d.error("Failed to submit step %d: %s",l.stepIndex,p)})}async function i({statusOverride:l,steps:c,summary:p}){await a;let f=c.filter(S=>S.status==="passed").length,g=c.filter(S=>S.status==="failed").length,y=c.reduce((S,B)=>S+B.duration,0),P=l??(g>0?"failed":"passed");await k({config:t,document:Hi,variables:{duration:y,failCount:g,passCount:f,runResultId:o,status:P,summary:p??null,warnCount:0}})}return{complete:i,enqueueStep:s,runResultId:o}}async function Mi({config:e,runResultId:t,steps:r}){let n=r.map(o=>({annotations:o.annotations.map(a=>({height:a.height,label:a.label,type:a.type,width:a.width,x:a.x,y:a.y})),assertions:o.assertions.map(a=>({description:a.description,detail:a.detail,status:a.status})),detail:o.detail,duration:o.duration,nodeType:o.nodeType,screenshotBase64:o.screenshotBase64,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth}));await k({config:e,document:_i,variables:{runResultId:t,steps:n}})}var Gi,_i,Hi,yr=m(()=>{"use strict";Te();z();Gi=gr(`
|
|
83
|
+
`)}var ws,Ss,bs,Ye,tn,rn,on=m(()=>{"use strict";ws=Z.object({baseUrl:Z.string().optional(),cloudBaseUrl:Z.string(),preconditionApiPath:Z.string().optional(),projectId:Z.string()}),Ss=Z.object({ripploServerUrl:Z.string(),token:Z.string()}),bs=ws.extend(Ss.shape),Ye=Mt.join(process.cwd(),".ripplo"),tn=Mt.join(Ye,"settings.json"),rn=Mt.join(Ye,"settings.local.json")});async function _t({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){let c=await Bt({condition:r.condition,page:n,timeout:s,variables:i})?r.consequent:r.alternate??[];return c.length===0?{steps:[],variables:i}:e({failFast:t,nodeIds:c,page:n,spec:o,startIndex:a,timeout:s,variables:i})}async function Gt({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){let l=[],c=i;for(let p=0;p<r.times;p++){r.iteratorVar!=null&&(c=ne({name:r.iteratorVar,store:c,value:p}));let f=await e({failFast:t,nodeIds:r.body,page:n,spec:o,startIndex:a+l.length,timeout:s,variables:c});if(l.push(...f.steps),c=f.variables,t&&f.steps.some(g=>g.status==="failed"))break}return{steps:l,variables:c}}async function Ht({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){let l=Rs({collection:r.collection,variables:i}),c=[],p=i;for(let f of l){p=ne({name:r.iteratorVar,store:p,value:Ps(f)});let g=await e({failFast:t,nodeIds:r.body,page:n,spec:o,startIndex:a+c.length,timeout:s,variables:p});if(c.push(...g.steps),p=g.variables,t&&g.steps.some(y=>y.status==="failed"))break}return{steps:c,variables:p}}function Ps(e){return typeof e=="object"&&e!=null?JSON.stringify(e):e==null?"":String(e)}function Rs({collection:e,variables:t}){if(Array.isArray(e))return e;let r=t[e.name];if(r==null)throw new Error(`Variable "${e.name}" is not defined`);return xs(r)}function xs(e){if(typeof e!="string")return[e];try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return[e]}async function Jt({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){let l=await Promise.all(r.branches.map(f=>e({failFast:t,nodeIds:f,page:n,spec:o,startIndex:a,timeout:s,variables:i}))),c=l.flatMap(f=>f.steps),p=vs({base:i,results:l});return{steps:c,variables:p}}function vs({base:e,results:t}){let r=e;return t.forEach(n=>{r={...r,...n.variables}}),r}async function Yt({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){let l=[],c=i;try{let p=await e({failFast:t,nodeIds:r.body,page:n,spec:o,startIndex:a,timeout:s,variables:c});if(l.push(...p.steps),c=p.variables,p.steps.some(g=>g.status==="failed")&&r.catch!=null){let g=await e({failFast:t,nodeIds:r.catch,page:n,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...g.steps),c=g.variables}}catch{if(r.catch!=null){let p=await e({failFast:t,nodeIds:r.catch,page:n,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...p.steps),c=p.variables}}finally{if(r.finally!=null){let p=await e({failFast:t,nodeIds:r.finally,page:n,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...p.steps),c=p.variables}}return{steps:l,variables:c}}async function Kt({executeSequence:e,failFast:t,node:r,page:n,spec:o,startIndex:a,timeout:s,variables:i}){return e({failFast:t,nodeIds:r.nodes,page:n,spec:o,startIndex:a,timeout:s,variables:i})}var Qt=m(()=>{"use strict";zt();K()});import{z as T}from"zod";var ks,Ts,Cs,js,Is,Ns,As,R,Ke=m(()=>{"use strict";ks=T.object({by:T.literal("css"),value:T.string().min(1)}),Ts=T.object({by:T.literal("testId"),value:T.string().min(1)}),Cs=T.object({by:T.literal("role"),exact:T.boolean().optional(),name:T.string().optional(),role:T.string().min(1)}),js=T.object({by:T.literal("text"),exact:T.boolean().optional(),value:T.string().min(1)}),Is=T.object({by:T.literal("label"),exact:T.boolean().optional(),value:T.string().min(1)}),Ns=T.object({by:T.literal("placeholder"),value:T.string().min(1)}),As=T.object({by:T.literal("altText"),value:T.string().min(1)}),R=T.discriminatedUnion("by",[ks,Ts,Cs,js,Is,Ns,As])});import{z as nn}from"zod";var _,de,Qe=m(()=>{"use strict";_=nn.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),de=nn.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"])});import{z as E}from"zod";var Es,Xt,ue,V,Xe,Ze=m(()=>{"use strict";Es=E.object({type:E.literal("static"),value:E.union([E.string(),E.number(),E.boolean()])}),Xt=E.object({name:E.string().min(1),type:E.literal("variable")}),ue=E.discriminatedUnion("type",[Es,Xt]),V=E.discriminatedUnion("type",[E.object({type:E.literal("static"),value:E.string()}),Xt]),Xe=E.discriminatedUnion("type",[E.object({type:E.literal("static"),value:E.number().int().nonnegative()}),Xt])});import{z}from"zod";var et,Zt=m(()=>{"use strict";Ke();Qe();Ze();et=z.discriminatedUnion("type",[z.object({locator:R,type:z.literal("elementVisible")}),z.object({locator:R,type:z.literal("elementNotVisible")}),z.object({expected:V,operator:_,type:z.literal("urlMatch")}),z.object({expected:V,locator:R,operator:_,type:z.literal("textMatch")}),z.object({expected:ue,operator:de,type:z.literal("variableCompare"),variable:z.string().min(1)})])});import{z as L}from"zod";var tt,er=m(()=>{"use strict";tt=L.discriminatedUnion("type",[L.object({default:L.string().optional(),type:L.literal("string")}),L.object({default:L.number().optional(),type:L.literal("number")}),L.object({default:L.boolean().optional(),type:L.literal("boolean")}),L.object({key:L.string().min(1),type:L.literal("env")})])});import{z as u}from"zod";var $s,Y,S,Vs,Us,Ds,Fs,Os,Ws,Ls,qs,Bs,zs,Ms,_s,Gs,Hs,Js,Ys,Ks,Qs,Xs,Zs,ei,ti,ri,oi,ni,ai,si,ii,li,ci,di,ui,pi,fi,mi,gi,yi,hi,wi,an,sn,je,tr=m(()=>{"use strict";Zt();Ke();Qe();Ze();er();Zt();Ke();Qe();Ze();er();$s=u.string().min(1),Y=u.array($s).min(1),S={comment:u.string().optional(),id:u.string().min(1),label:u.string().optional(),next:u.string().optional(),timeout:u.number().int().positive().optional()},Vs=u.object({...S,type:u.literal("goto"),url:V}),Us=u.object({...S,locator:R,type:u.literal("click")}),Ds=u.object({...S,locator:R,type:u.literal("fill"),value:V}),Fs=u.object({...S,locator:R,type:u.literal("select"),value:V}),Os=u.object({...S,locator:R,type:u.literal("hover")}),Ws=u.object({...S,key:u.string().min(1),locator:R.optional(),type:u.literal("press")}),Ls=u.object({...S,locator:R,type:u.literal("check")}),qs=u.object({...S,locator:R,type:u.literal("uncheck")}),Bs=u.object({...S,type:u.literal("screenshot")}),zs=u.object({...S,height:u.number().int().positive(),type:u.literal("setViewport"),width:u.number().int().positive()}),Ms=u.object({...S,duration:u.number().int().positive(),type:u.literal("wait")}),_s=u.object({...S,message:u.string().min(1),type:u.literal("fail")}),Gs=u.object({...S,type:u.literal("setVariable"),value:ue,variable:u.string().min(1)}),Hs=u.object({...S,locator:R,type:u.literal("extractText"),variable:u.string().min(1)}),Js=u.object({...S,files:u.array(u.string()).min(1),locator:R,type:u.literal("upload")}),Ys=u.object({...S,locator:R,type:u.literal("dblclick")}),Ks=u.object({...S,source:R,target:R,type:u.literal("drag")}),Qs=u.object({...S,locator:R,type:u.literal("scrollIntoView")}),Xs=u.object({...S,locator:R,type:u.literal("type"),value:V}),Zs=u.object({...S,locator:R,type:u.literal("focus")}),ei=u.object({...S,locator:R,state:u.enum(["visible","hidden","attached","detached"]).optional(),type:u.literal("waitFor")}),ti=u.object({...S,expected:V,operator:_,type:u.literal("waitForUrl")}),ri=u.object({...S,type:u.literal("waitForResponse"),urlPattern:V}),oi=u.object({...S,type:u.literal("waitForRequest"),urlPattern:V}),ni=u.object({...S,locator:R,type:u.literal("assertVisible")}),ai=u.object({...S,locator:R,type:u.literal("assertNotVisible")}),si=u.object({...S,expected:V,locator:R,operator:_,type:u.literal("assertText")}),ii=u.object({...S,expected:V,operator:_,type:u.literal("assertUrl")}),li=u.object({...S,expected:Xe,locator:R,operator:de,type:u.literal("assertCount")}),ci=u.object({...S,expected:V,locator:R,operator:_,type:u.literal("assertValue")}),di=u.object({...S,attribute:u.string().min(1),expected:V,locator:R,operator:_,type:u.literal("assertAttribute")}),ui=u.object({...S,locator:R,type:u.literal("assertEnabled")}),pi=u.object({...S,locator:R,type:u.literal("assertDisabled")}),fi=u.object({...S,alternate:Y.optional(),condition:et,consequent:Y,type:u.literal("if")}),mi=u.object({...S,body:Y,iteratorVar:u.string().min(1).optional(),times:u.number().int().positive(),type:u.literal("loop")}),gi=u.object({...S,body:Y,collection:u.union([u.array(u.record(u.string(),u.unknown())).min(1),u.object({name:u.string().min(1),type:u.literal("variable")})]),iteratorVar:u.string().min(1),type:u.literal("forEach")}),yi=u.object({...S,branches:u.array(Y).min(2),type:u.literal("parallel")}),hi=u.object({...S,body:Y,catch:Y.optional(),finally:Y.optional(),type:u.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),wi=u.object({...S,nodes:Y,type:u.literal("group")}),an=u.discriminatedUnion("type",[Vs,Us,Ds,Fs,Os,Ws,Ls,qs,ei,ti,ri,oi,ni,ai,si,ii,li,ci,di,ui,pi,Bs,zs,Ms,_s,Gs,Hs,Js,Ys,Ks,Qs,Xs,Zs,fi,mi,gi,yi,wi]),sn=u.union([an,hi]),je=u.object({entryNode:u.string().min(1),nodes:u.record(u.string(),sn),variables:u.record(u.string(),tt).optional(),version:u.literal(2)})});function ae(e){let t=je.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}}var ln=m(()=>{"use strict";tr()});var Ie=m(()=>{"use strict";tr();ln()});async function O({fn:e,label:t}){let r=performance.now(),n=await e();return d.info("%s: %dms",t,Math.round(performance.now()-r)),n}var rt=m(()=>{"use strict";W()});async function rr({failFast:e,onStep:t,page:r,spec:n,variables:o}){let a=performance.now();return Pi({currentId:n.entryNode,failFast:e,onStep:t,page:r,runStartTime:a,spec:n,startIndex:0,variables:o})}function bi({onStep:e,steps:t,target:r}){t.forEach(n=>{r.push(n),e?.(n)})}async function Pi({currentId:e,failFast:t,onStep:r,page:n,runStartTime:o,spec:a,startIndex:s,variables:i}){let l=[],c=i,p=e;for(;p!=null;){let f=a.nodes[p];if(f==null)throw new Error(`Node "${p}" not found in spec`);let g=p,y=f.label??`${f.type} (${p})`;d.info("Executing node: %s [%s]",y,f.type);let x=await cn({failFast:t,node:f,nodeId:g,page:n,runStartTime:o,spec:a,startIndex:s+l.length,variables:c});if(bi({onStep:r,steps:x.steps,target:l}),c=x.variables,t&&x.steps.some(b=>b.status==="failed"))break;p=f.next}return{steps:l,variables:c}}async function cn({failFast:e,node:t,nodeId:r,page:n,runStartTime:o,spec:a,startIndex:s,variables:i}){let l=performance.now(),c=t.label??`${t.type} (${t.id})`,p=t.timeout??Si;if(Ri(t))return xi({failFast:e,node:t,page:n,spec:a,startIndex:s,timeout:p,variables:i});let f=Ni({node:t,page:n});try{let g=await Ci({node:t,page:n,timeout:p,variables:i}),y=Math.round(performance.now()-l),x=g.assertions.some(w=>w.status==="failed"),b=await O({label:`Snapshot [${c}]`,fn:()=>Q({page:n,runStartTime:o,targets:f})});return{steps:[{annotations:b.annotations,assertions:g.assertions,detail:void 0,duration:y,nodeId:r,nodeType:t.type,screenshotBase64:b.screenshotBase64,snapshotTimestamp:b.snapshotTimestamp,status:x?"failed":"passed",stepIndex:s,title:c,url:b.url,viewportHeight:b.viewportHeight,viewportWidth:b.viewportWidth}],variables:g.variables}}catch(g){let y=Math.round(performance.now()-l),x=g instanceof Error?g.message:String(g),b=await O({label:`Snapshot [${c}] (error)`,fn:()=>Q({page:n,runStartTime:o,targets:f})});return{steps:[{annotations:b.annotations,assertions:[],detail:x,duration:y,nodeId:r,nodeType:t.type,screenshotBase64:b.screenshotBase64,snapshotTimestamp:b.snapshotTimestamp,status:"failed",stepIndex:s,title:c,url:b.url,viewportHeight:b.viewportHeight,viewportWidth:b.viewportWidth}],variables:i}}}function Ri(e){return["if","loop","forEach","parallel","try","group"].includes(e.type)}async function xi({failFast:e,node:t,page:r,spec:n,startIndex:o,timeout:a,variables:s}){let i={executeSequence:Ti,failFast:e,page:r,spec:n,startIndex:o,timeout:a,variables:s};switch(t.type){case"if":return _t({...i,node:t});case"loop":return Gt({...i,node:t});case"forEach":return Ht({...i,node:t});case"parallel":return Jt({...i,node:t});case"try":return Yt({...i,node:t});case"group":return Kt({...i,node:t})}}function vi(e){return e.some(t=>t.status==="failed")}function ki({nodeId:e,spec:t,timeout:r}){let n=t.nodes[e];if(n==null)throw new Error(`Node "${e}" not found in spec`);return n.timeout==null?{...n,timeout:r}:n}async function Ti({failFast:e,nodeIds:t,page:r,spec:n,startIndex:o,timeout:a,variables:s}){let i=[],l=s;for(let c of t){let p=ki({nodeId:c,spec:n,timeout:a}),f=await cn({failFast:e,node:p,nodeId:c,page:r,runStartTime:0,spec:n,startIndex:o+i.length,variables:l});if(i.push(...f.steps),l=f.variables,e&&vi(f.steps))break}return{steps:i,variables:l}}async function Ci({node:e,page:t,timeout:r,variables:n}){if(ji(e)){let a=await Pt({node:e,page:t,timeout:r,variables:n});return{assertions:[],variables:a.variables}}return{assertions:await Ii({node:e,page:t,timeout:r,variables:n}),variables:n}}function ji(e){return["goto","click","dblclick","fill","select","hover","press","check","uncheck","waitFor","waitForUrl","waitForResponse","waitForRequest","screenshot","setViewport","wait","fail","setVariable","extractText","upload","drag","scrollIntoView","type","focus"].includes(e.type)}async function Ii({node:e,page:t,timeout:r,variables:n}){let o=e;switch(o.type){case"assertVisible":return[await ve({locator:P({locator:o.locator,page:t}),timeout:r})];case"assertNotVisible":return[await ke({locator:P({locator:o.locator,page:t}),timeout:r})];case"assertText":{let a=$({ref:o.expected,variables:n});return[await Ot({expected:a,locator:P({locator:o.locator,page:t}),operator:o.operator,timeout:r})]}case"assertUrl":{let a=$({ref:o.expected,variables:n});return[Wt({expected:a,operator:o.operator,url:t.url()})]}case"assertCount":{let a=bt({ref:o.expected,variables:n});return[await Lt({expected:a,locator:P({locator:o.locator,page:t}),operator:o.operator})]}case"assertValue":{let a=$({ref:o.expected,variables:n});return[await qt({expected:a,locator:P({locator:o.locator,page:t}),operator:o.operator,timeout:r})]}case"assertAttribute":{let a=$({ref:o.expected,variables:n});return[await Ho({attribute:o.attribute,expected:a,locator:P({locator:o.locator,page:t}),operator:o.operator,timeout:r})]}case"assertEnabled":return[await Jo({locator:P({locator:o.locator,page:t}),timeout:r})];case"assertDisabled":return[await Yo({locator:P({locator:o.locator,page:t}),timeout:r})]}}function Ni({node:e,page:t}){if(e.type==="assertUrl"||e.type==="waitForUrl")return[{label:e.type,type:"urlBar"}];if(e.type==="drag"){let o=P({locator:e.source,page:t}),a=P({locator:e.target,page:t});return[{label:"drag-source",locator:o,type:"action"},{label:"drag-target",locator:a,type:"action"}]}if(!Ai(e))return[];let r=e.type.startsWith("assert")?"assertion":"action",n=P({locator:e.locator,page:t});return[{label:e.type,locator:n,type:r}]}function Ai(e){return"locator"in e&&e.locator!=null}var Si,or=m(()=>{"use strict";Rt();Je();Qt();we();W();rt();be();K();Si=5e3});async function Ne({baseUrl:e,browser:t,cookies:r,extraVariables:n,navigateTo:o,onStep:a,runId:s,spec:i}){let l=await t.newContext({baseURL:e});d.info("Browser context created"),r.length>0&&await l.addCookies(r);let c=await l.newPage();d.info("Page created");let p=Pe(c);o!=null&&(d.info("Navigating to: %s",o),await c.goto(o,{waitUntil:"domcontentloaded"}),d.info("Navigation complete"));function f(w){a?.(w),Me({context:l,page:c,runId:s,stepIndex:w.stepIndex,stepResult:w})}let g={...Se({defs:i.variables}),...n};d.info("Starting graph execution (entry: %s)",i.entryNode);let y=await rr({failFast:!0,onStep:f,page:c,spec:i,variables:g}),x=y.steps.filter(w=>w.status==="passed").length,b=y.steps.filter(w=>w.status==="failed").length,N={duration:y.steps.reduce((w,I)=>w+I.duration,0),failCount:b,passCount:x,runId:s,status:b>0?"failed":"passed",workflowName:""};return await _e({monitor:p,runId:s,steps:y.steps,summary:N}),await l.close(),y.steps}var nr=m(()=>{"use strict";It();Ge();or();W();K()});import{z as ot}from"zod";var ar,sr=m(()=>{"use strict";ar=ot.object({from:ot.string().min(1).describe("Key of the source state in the states record"),to:ot.string().min(1).describe("Key of the target state in the states record"),workflow:ot.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 Ei,ir,lr,$i,Vi,Ae,cr=m(()=>{"use strict";Ei=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"),ir=j.object({satisfied:j.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),lr=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."),$i=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."),Vi=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"),Ae=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 nt}from"zod";var dr,ur=m(()=>{"use strict";dr=nt.object({preconditions:nt.array(nt.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:nt.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 ee}from"zod";var at,pr=m(()=>{"use strict";sr();cr();ur();at=ee.object({edges:ee.array(ar).describe("Directed edges between states, each executed by a workflow"),preconditions:ee.record(ee.string(),Ae).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:ee.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:ee.record(ee.string(),dr).describe("States keyed by stable ID (kebab-case)"),version:ee.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions")});var dn=m(()=>{"use strict";pr()});var st=m(()=>{"use strict";sr();pr();cr();ur();dn()});import{parseSetCookie as Ui}from"set-cookie-parser";import{z as un}from"zod";async function Ee({apiUrl:e,cookies:t,executed:r}){if(r.length!==0)try{let n=await fetch(`${e}/teardown`,{body:JSON.stringify({preconditions:r}),headers:{"Content-Type":"application/json",...fr({cookies:t})},method:"PUT"});n.ok||d.error("Teardown returned %s",String(n.status))}catch{d.error("Teardown request failed")}}function Di({preconditionNames:e,preconditions:t}){let r=[],n=new Set;function o(a){if(n.has(a))return;n.add(a);let s=t[a];s?.depends!=null&&s.depends.forEach(i=>{o(i)}),r.push(a)}return e.forEach(a=>{o(a)}),r}async function Fi({apiUrl:e,cookies:t,name:r}){let n=await fetch(`${e}/check`,{body:JSON.stringify({precondition:r}),headers:{"Content-Type":"application/json",...fr({cookies:t})},method:"POST"});if(!n.ok)return!1;let o=await n.json(),a=ir.safeParse(o);if(!a.success)throw new Error(`Check response for "${r}" has invalid shape: ${a.error.message}`);return a.data.satisfied}async function Oi({apiUrl:e,cookies:t,name:r}){let n=await fetch(`${e}/execute`,{body:JSON.stringify({precondition:r}),headers:{"Content-Type":"application/json",...fr({cookies:t})},method:"PUT"});if(!n.ok)throw new Error(`Execute for "${r}" returned ${String(n.status)}`);let o=await n.json(),a=lr.safeParse(o);if(!a.success)throw new Error(`Execute response for "${r}" has invalid shape: ${a.error.message}`);if(!a.data.success){let i=a.data.error??"no error detail";throw new Error(`Precondition "${r}" failed to execute: ${i}`)}return{cookies:Wi({domain:new URL(e).hostname,res:n}),data:a.data.data??{},navigateTo:a.data.navigateTo}}function fr({cookies:e}){return e.length===0?{}:{Cookie:e.map(r=>`${r.name}=${r.value}`).join("; ")}}function Wi({domain:e,res:t}){let r=t.headers.getSetCookie();return Ui(r,{decodeValues:!1}).map(o=>Li({cookie:o,domain:e}))}function Li({cookie:e,domain:t}){let r={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&&(r.sameSite=Bi({raw:e.sameSite})),e.expires!=null?r.expires=Math.floor(e.expires.getTime()/1e3):e.maxAge!=null&&(r.expires=Math.floor(Date.now()/1e3)+e.maxAge),r}function Bi({raw:e}){return qi[e.toLowerCase()]??"Lax"}async function se({baseUrl:e,project:t,workflowSlug:r}){let n={apiUrl:void 0,cookies:[],data:{},executed:[],navigateTo:void 0},o=t.stateGraph;if(o==null)return n;let a=(o.edges??[]).find(p=>p.workflowSlug===r);if(a?.sourceState==null)return n;let s=_i({baseUrl:e,preconditionApiPath:t.preconditionApiPath}),i=a.sourceState.preconditions;if(i.length===0)return{...n,apiUrl:s};if(s==null)return n;let l=zi.safeParse(o.preconditions);if(!l.success)return{...n,apiUrl:s};let c=await Mi({apiUrl:s,preconditionNames:i,preconditions:l.data});return{apiUrl:s,cookies:c.cookies,data:c.data,executed:c.executed,navigateTo:c.navigateTo}}async function Mi({apiUrl:e,preconditionNames:t,preconditions:r}){let n=Di({preconditionNames:t,preconditions:r}),o=[],a={},s=[],i,l=Promise.resolve();return n.forEach(c=>{l=l.then(async()=>{if(await Fi({apiUrl:e,cookies:o,name:c}))return;let f=await Oi({apiUrl:e,cookies:o,name:c});o.push(...f.cookies),Object.entries(f.data).forEach(([g,y])=>{a[g]=y}),s.push(c),f.navigateTo!=null&&(i=f.navigateTo)})}),await l,{cookies:o,data:a,executed:s,navigateTo:i}}function _i({baseUrl:e,preconditionApiPath:t}){if(t.length!==0)return t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`}var qi,zi,mr=m(()=>{"use strict";st();st();W();qi={lax:"Lax",none:"None",strict:"Strict"};zi=un.record(un.string(),Ae)});import{graphql as gr}from"gql.tada";async function $e({agentProfileId:e,config:t,runId:r}){let n=await k({config:t,document:Hi,variables:{agentProfileId:e??null,platform:"chromium",runId:r}});if(n.startRun==null)throw new Error("Failed to start run");let o=n.startRun.id,a=Promise.resolve();function s(l){a=a.then(()=>Gi({config:t,runResultId:o,steps:[l]})).catch(c=>{let p=c instanceof Error?c.message:"Unknown error";d.error("Failed to submit step %d: %s",l.stepIndex,p)})}async function i({statusOverride:l,steps:c,summary:p}){await a;let f=c.filter(b=>b.status==="passed").length,g=c.filter(b=>b.status==="failed").length,y=c.reduce((b,N)=>b+N.duration,0),x=l??(g>0?"failed":"passed");await k({config:t,document:Yi,variables:{duration:y,failCount:g,passCount:f,runResultId:o,status:x,summary:p??null,warnCount:0}})}return{complete:i,enqueueStep:s,runResultId:o}}async function Gi({config:e,runResultId:t,steps:r}){let n=r.map(o=>({annotations:o.annotations.map(a=>({height:a.height,label:a.label,type:a.type,width:a.width,x:a.x,y:a.y})),assertions:o.assertions.map(a=>({description:a.description,detail:a.detail,status:a.status})),detail:o.detail,duration:o.duration,nodeType:o.nodeType,screenshotBase64:o.screenshotBase64,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth}));await k({config:e,document:Ji,variables:{runResultId:t,steps:n}})}var Hi,Ji,Yi,yr=m(()=>{"use strict";Te();W();Hi=gr(`
|
|
84
84
|
mutation StartRunCLI($runId: String!, $platform: String!, $agentProfileId: String) {
|
|
85
85
|
startRun(runId: $runId, platform: $platform, agentProfileId: $agentProfileId) {
|
|
86
86
|
id
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
`),
|
|
89
|
+
`),Ji=gr(`
|
|
90
90
|
mutation SubmitRunStepsCLI($runResultId: String!, $steps: [StepInput!]!) {
|
|
91
91
|
submitRunSteps(runResultId: $runResultId, steps: $steps)
|
|
92
92
|
}
|
|
93
|
-
`),
|
|
93
|
+
`),Yi=gr(`
|
|
94
94
|
mutation CompleteRunCLI(
|
|
95
95
|
$runResultId: String!
|
|
96
96
|
$status: String!
|
|
@@ -113,7 +113,7 @@ ${r}`].join(`
|
|
|
113
113
|
status
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
`)});import{graphql as it,readFragment as hr}from"gql.tada";async function Sr({agentProfileDescription:e,agentProfileId:t,baseUrl:r,browser:n,config:o,headed:a,runId:s,workflowId:i}){let l="unknown",c,p,f=!1;try{f=n==null,p=
|
|
116
|
+
`)});import{graphql as it,readFragment as hr}from"gql.tada";async function Sr({agentProfileDescription:e,agentProfileId:t,baseUrl:r,browser:n,config:o,headed:a,runId:s,workflowId:i}){let l="unknown",c,p,f=!1;try{f=n==null,p=Xi({externalBrowser:n,headed:a});let{project:g,workflow:y}=await O({label:"Run context resolved",fn:()=>ol({config:o,workflowId:i})});l=y.name;let x=al(y.spec);d.info("Executing workflow: %s",y.name),c=await O({label:"Streaming run started",fn:()=>$e({agentProfileId:t,config:o,runId:s})}),await el({agentProfileDescription:e,agentProfileId:t,baseUrl:r,browserPromise:p,config:o,headed:a,ownsBrowser:f,project:g,runId:s,specData:x,streaming:c,workflow:y})}catch(g){throw await Zi({browserPromise:p,error:g,ownsBrowser:f,runId:s,streaming:c,workflowName:l}),g}}function Xi({externalBrowser:e,headed:t}){return e!=null?Promise.resolve(e):O({label:"Browser launched",fn:()=>H({headed:t})})}async function Zi({browserPromise:e,error:t,ownsBrowser:r,runId:n,streaming:o,workflowName:a}){let s=t instanceof Error?t.message:String(t),i=t instanceof Error?t.stack:void 0;await Go({error:s,runId:n,stack:i,workflowName:a}),o!=null&&await o.complete({statusOverride:"failed",steps:[],summary:s}).catch(()=>{}),r&&e!=null&&await(await e.catch(()=>{}))?.close()}async function el({agentProfileDescription:e,agentProfileId:t,baseUrl:r,browserPromise:n,config:o,headed:a,ownsBrowser:s,project:i,runId:l,specData:c,streaming:p,workflow:f}){let[g,y]=await Promise.all([O({label:"Preconditions resolved",fn:()=>se({baseUrl:r,project:i,workflowSlug:f.slug})}),n]);if(t!=null){s&&await y.close(),await tl({agentProfileDescription:e,agentProfileId:t,baseUrl:r,config:o,headed:a,preconditionResult:g,runId:l,specData:c,streaming:p,workflow:f});return}await rl({baseUrl:r,browser:y,preconditionResult:g,runId:l,specData:c,streaming:p})}async function tl({agentProfileDescription:e,agentProfileId:t,baseUrl:r,config:n,headed:o,preconditionResult:a,runId:s,specData:i,streaming:l,workflow:c}){let p=e!=null&&e.length>0?e:await nl({config:n,profileId:t});await Dt({baseUrl:r,cookies:a.cookies,executedPreconditions:a.executed,extraVariables:a.data,headed:o,navigateTo:a.navigateTo,runId:s,serverUrl:n.ripploServerUrl,spec:i,streaming:l,systemPrompt:p,token:n.token,workflowContext:{description:c.name,expectedOutcome:c.name,name:c.name}}),await fn(a)}async function rl({baseUrl:e,browser:t,preconditionResult:r,runId:n,specData:o,streaming:a}){let s=await O({label:"Spec executed",fn:()=>Ne({baseUrl:e,browser:t,cookies:r.cookies,extraVariables:r.data,navigateTo:r.navigateTo,onStep:a.enqueueStep,runId:n,spec:o})});await fn(r),await a.complete({statusOverride:void 0,steps:s,summary:void 0});let i=s.filter(c=>c.status==="passed").length,l=s.filter(c=>c.status==="failed").length;d.info("Run complete: %d passed, %d failed",i,l)}async function fn(e){e.apiUrl!=null&&await Ee({apiUrl:e.apiUrl,cookies:e.cookies,executed:e.executed})}async function ol({config:e,workflowId:t}){let r=await k({config:e,document:Ki,variables:{projectId:e.projectId}});if(r.project==null)throw new Error("Project not found");let o={...hr(pn,r.project),...e.baseUrl==null?{}:{baseUrl:e.baseUrl},...e.preconditionApiPath==null?{}:{preconditionApiPath:e.preconditionApiPath}},s=(o.workflows??[]).find(l=>hr(wr,l).id===t);if(s==null)throw new Error(`Workflow ${t} not found`);let i=hr(wr,s);return{project:o,workflow:i}}async function nl({config:e,profileId:t}){let r=await k({config:e,document:Qi,variables:{id:t}});if(r.agentProfile==null)throw new Error(`Agent profile not found: ${t}`);let n=r.agentProfile,o=n.description;if(o==null||o.length===0)throw new Error(`Agent profile "${n.name}" has no description`);return d.info("Using agent profile: %s",n.name),xe({description:o,output:n.output??void 0,successCriteria:n.successCriteria??void 0})}function al(e){if(e==null)throw new Error("Workflow has no spec");let t=ae(e);if(!t.success){let r=t.errors.map(n=>`${n.path}: ${n.message}`).join("; ");throw new Error(`Invalid spec: ${r}`)}return t.data}var wr,pn,Ki,Qi,mn=m(()=>{"use strict";Ie();Et();Ft();ze();Te();Ge();nr();W();rt();mr();yr();wr=it(`
|
|
117
117
|
fragment WorkflowRun on Workflow {
|
|
118
118
|
id
|
|
119
119
|
slug
|
|
@@ -139,13 +139,13 @@ ${r}`].join(`
|
|
|
139
139
|
...WorkflowRun
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
`,[wr]),
|
|
142
|
+
`,[wr]),Ki=it(`
|
|
143
143
|
query ProjectRun($projectId: String!) {
|
|
144
144
|
project(id: $projectId) {
|
|
145
145
|
...ProjectRun
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
`,[pn]),
|
|
148
|
+
`,[pn]),Qi=it(`
|
|
149
149
|
query AgentProfileRun($id: String!) {
|
|
150
150
|
agentProfile(id: $id) {
|
|
151
151
|
id
|
|
@@ -155,7 +155,7 @@ ${r}`].join(`
|
|
|
155
155
|
successCriteria
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
`)});var
|
|
158
|
+
`)});var D=m(()=>{"use strict";Rt();At();Et();Ft();Je();ze();Zo();Te();zt();on();Qt();mn();nr();or();we();W();rt();mr();be();yr();K()});import sl from"fs";import il from"path";import{z as U}from"zod";function gn(e){return il.join(e,".ripplo","graph.json")}function yn(e){let t=sl.readFileSync(e,"utf8"),r=JSON.parse(t);return ll.parse(r)}function hn(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}var ll,wn=m(()=>{"use strict";ll=U.object({edges:U.array(U.object({from:U.string(),to:U.string(),workflow:U.string()})),preconditions:U.record(U.string(),U.unknown()).optional(),resetPrecondition:U.string().optional(),states:U.record(U.string(),U.object({preconditions:U.array(U.string()),route:U.string()})),version:U.literal(3)})});import cl from"fs";import dl from"path";import{z as pe}from"zod";function Ve(e){return dl.join(e,".ripplo","workflows")}function br(e){let t=cl.readFileSync(e,"utf8"),r=JSON.parse(t);return ul.parse(r)}var ul,Sn=m(()=>{"use strict";Ie();ul=pe.object({additionalChecks:pe.array(pe.string()).default([]),description:pe.string(),expectedOutcome:pe.string(),name:pe.string(),spec:je})});var xr={};ea(xr,{deleteWorkflowFile:()=>yl,duplicateWorkflowFile:()=>hl,startFileWatcher:()=>Rr,syncAll:()=>Pr});import pl from"crypto";import te from"fs";import Ue from"path";import{watch as fl}from"chokidar";import{graphql as ml}from"gql.tada";async function Pr(e){let t=await Rn(e);return d.info("Synced %d workflow(s) + graph to dev session",xn(e.cwd)),t}function Rr({config:e,cwd:t,lastHash:r}){let n=Ue.join(t,".ripplo"),o=r,a,s=fl(n,{depth:2,ignoreInitial:!0,interval:1e3,persistent:!0,usePolling:!0});s.on("all",(l,c)=>{c.endsWith(".json")&&(a!=null&&clearTimeout(a),a=setTimeout(()=>{i({config:e,cwd:t})},500))});async function i(l){try{let c=bn(l.cwd),p=Pn(c);if(p===o)return;o=p,await Rn(l),d.info("Dev session synced (%d workflow(s))",xn(l.cwd))}catch(c){let p=c instanceof Error?c.message:"Unknown error";d.error("Sync failed: %s",p)}}return function(){a!=null&&clearTimeout(a),s.close()}}function bn(e){let t=gn(e),r=yn(t),n=JSON.stringify(hn(r)),o=Ve(e),s=(te.existsSync(o)?te.readdirSync(o).filter(i=>i.endsWith(".json")):[]).map(i=>{let l=Ue.join(o,i),c=br(l),p=i.replace(/\.json$/,"");return{description:c.description,expectedOutcome:c.expectedOutcome,name:c.name,slug:p,spec:JSON.stringify(c.spec)}});return{graphSpec:n,workflows:s}}function Pn(e){return pl.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Rn({config:e,cwd:t}){let r=bn(t),n=Pn(r),o=await k({config:e,document:gl,variables:{graphSpec:r.graphSpec,projectId:e.projectId,workflows:[...r.workflows]}});if(o.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:o.syncDevSession.id,hash:n}}function xn(e){let t=Ve(e);return te.existsSync(t)?te.readdirSync(t).filter(r=>r.endsWith(".json")).length:0}function yl({cwd:e,slug:t}){let r=Ue.join(Ve(e),`${t}.json`);return te.existsSync(r)?(te.unlinkSync(r),!0):!1}function hl({cwd:e,newSlug:t,sourceSlug:r}){let n=Ve(e),o=Ue.join(n,`${r}.json`);if(!te.existsSync(o))return!1;let a=br(o),s={...a,name:`${a.name} (copy)`};return te.writeFileSync(Ue.join(n,`${t}.json`),JSON.stringify(s,null,2)),!0}var gl,lt=m(()=>{"use strict";wn();Sn();D();gl=ml(`
|
|
159
159
|
mutation SyncDevSession(
|
|
160
160
|
$projectId: String!
|
|
161
161
|
$graphSpec: String!
|
|
@@ -165,13 +165,13 @@ ${r}`].join(`
|
|
|
165
165
|
id
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
`)});
|
|
168
|
+
`)});D();import{config as Kn}from"dotenv";import ht from"path";import{fileURLToPath as Wc}from"url";D();lt();import{availableParallelism as wl}from"os";import{createClient as Sl}from"graphql-sse";import{graphql as De}from"gql.tada";import{print as vr}from"graphql";import{input as bl}from"@inquirer/prompts";import Pl from"p-limit";var Rl=De(`
|
|
169
169
|
mutation EndDevSession($projectId: String!) {
|
|
170
170
|
endDevSession(projectId: $projectId) {
|
|
171
171
|
id
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
`),
|
|
174
|
+
`),xl=De(`
|
|
175
175
|
subscription RunRequestedDev {
|
|
176
176
|
runRequested {
|
|
177
177
|
agentProfileDescription
|
|
@@ -181,7 +181,7 @@ ${r}`].join(`
|
|
|
181
181
|
workflowId
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
`),
|
|
184
|
+
`),vl=De(`
|
|
185
185
|
query PendingDevRuns($devSessionId: String!) {
|
|
186
186
|
pendingDevRuns(devSessionId: $devSessionId) {
|
|
187
187
|
id
|
|
@@ -194,14 +194,14 @@ ${r}`].join(`
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
`),
|
|
197
|
+
`),kl=De(`
|
|
198
198
|
subscription DevWorkflowDeleteRequested($projectId: String!) {
|
|
199
199
|
devWorkflowDeleteRequested(projectId: $projectId) {
|
|
200
200
|
projectId
|
|
201
201
|
slug
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
`),
|
|
204
|
+
`),Tl=De(`
|
|
205
205
|
subscription DevWorkflowDuplicateRequested($projectId: String!) {
|
|
206
206
|
devWorkflowDuplicateRequested(projectId: $projectId) {
|
|
207
207
|
projectId
|
|
@@ -209,16 +209,16 @@ ${r}`].join(`
|
|
|
209
209
|
newSlug
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
`);async function ct({concurrency:e,headed:t}){let r=
|
|
212
|
+
`);async function ct({concurrency:e,headed:t}){let r=B();if(r==null)return A("Not logged in. Run: ripplo login");let n=process.cwd();d.info("Starting dev session...");let o=await Ol(r),{devSessionId:a,hash:s}=await Pr({config:r,cwd:n}),i=Rr({config:r,cwd:n,lastHash:s});d.info("Connecting to %s...",r.ripploServerUrl);let l=r,c=Sl({headers:{Authorization:`Bearer ${l.token}`},on:{connected:w=>{w&&d.info("Reconnected.")},connecting:w=>{w&&d.info("Reconnecting to server...")}},retryAttempts:1/0,url:`${l.ripploServerUrl}/graphql`,retry:async w=>{let I=Math.min(1e3*2**w,3e4);d.warn("Connection lost. Reconnecting in %dms...",I),await new Promise(re=>{setTimeout(re,I)})}});async function p(){i(),c.dispose();try{await k({config:l,document:Rl,variables:{projectId:l.projectId}}),d.info("Dev session ended.")}catch{d.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",w=>{d.error("Unexpected error: %s",w.message),p().then(()=>process.exit(1))}),process.on("unhandledRejection",w=>{let I=w instanceof Error?w.message:String(w);d.error("Unhandled rejection: %s",I),p().then(()=>process.exit(1))}),d.info("Dev mode active. Watching files + waiting for runs...");let f=new Set,g=e??wl();d.info("Max concurrent runs: %d",g);let y=Pl(g),x=c.iterate({query:vr(xl)}),b=c.iterate({query:vr(kl),variables:{projectId:r.projectId}}),N=c.iterate({query:vr(Tl),variables:{projectId:r.projectId}});await Promise.all([Cl({activeRunIds:f,baseUrl:o,config:r,headed:t,limiter:y,subscription:x}),Il({activeRunIds:f,baseUrl:o,config:r,devSessionId:a,headed:t,limiter:y}),$l({cwd:n,subscription:b}),Ul({cwd:n,subscription:N})])}async function Cl({activeRunIds:e,baseUrl:t,config:r,headed:n,limiter:o,subscription:a}){for await(let s of a){let i=Fl(s);i!=null&&(e.has(i.runId)||(d.info("Run requested: %s (workflow %s)",i.runId,i.workflowId),e.add(i.runId),o(()=>vn({agentProfileDescription:i.agentProfileDescription,agentProfileId:i.agentProfileId,baseUrl:t,config:r,headed:n,runId:i.runId,workflowId:i.workflowId}).finally(()=>{e.delete(i.runId)}))))}}var jl=5e3;async function Il({activeRunIds:e,baseUrl:t,config:r,devSessionId:n,headed:o,limiter:a}){for(;;)await new Promise(s=>{setTimeout(s,jl)}),await Nl({activeRunIds:e,baseUrl:t,config:r,devSessionId:n,headed:o,limiter:a})}async function Nl({activeRunIds:e,baseUrl:t,config:r,devSessionId:n,headed:o,limiter:a}){try{let s=await k({config:r,document:vl,variables:{devSessionId:n}});if(s.pendingDevRuns==null)throw new Error("pendingDevRuns returned null");s.pendingDevRuns.filter(l=>!e.has(l.id)).forEach(l=>{let c=l.workflow?.id;c!=null&&(d.info("Polling picked up run: %s (workflow %s)",l.id,c),e.add(l.id),a(()=>vn({agentProfileDescription:l.agentProfile?.description??void 0,agentProfileId:l.agentProfile?.id??void 0,baseUrl:t,config:r,headed:o,runId:l.id,workflowId:c}).finally(()=>{e.delete(l.id)})))})}catch(s){let i=s instanceof Error?s.message:String(s);d.warn("Polling for pending runs failed: %s",i)}}async function vn({agentProfileDescription:e,agentProfileId:t,baseUrl:r,config:n,headed:o,runId:a,workflowId:s}){try{let i=B()??n,l=i.baseUrl??r;await Ce({maxRuns:100}),await Sr({agentProfileDescription:e,agentProfileId:t,baseUrl:l,browser:void 0,config:i,headed:o,runId:a,workflowId:s})}catch(i){Al({error:i,runId:a})}}function Al({error:e,runId:t}){let r=e instanceof Error?e.message:String(e);if(r.includes("already claimed")){d.info("Run %s already claimed by another instance, skipping",t);return}d.error("Run failed: %s",r)}function El(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 $l({cwd:e,subscription:t}){let{deleteWorkflowFile:r}=await Promise.resolve().then(()=>(lt(),xr));for await(let n of t){let o=Vl(n);if(o==null)continue;r({cwd:e,slug:o})?d.info("Deleted workflow file: %s.json",o):d.warn("Workflow file not found for deletion: %s.json",o)}}function Vl(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 r=t.devWorkflowDeleteRequested;if(!(typeof r!="object"||r==null||!("slug"in r))&&typeof r.slug=="string")return r.slug}async function Ul({cwd:e,subscription:t}){let{duplicateWorkflowFile:r}=await Promise.resolve().then(()=>(lt(),xr));for await(let n of t){let o=Dl(n);if(o==null)continue;r({cwd:e,newSlug:o.newSlug,sourceSlug:o.sourceSlug})?d.info("Duplicated workflow: %s.json \u2192 %s.json",o.sourceSlug,o.newSlug):d.warn("Source workflow file not found for duplication: %s.json",o.sourceSlug)}}function Dl(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 r=t.devWorkflowDuplicateRequested;if(!(typeof r!="object"||r==null)&&!(!("sourceSlug"in r)||!("newSlug"in r)||typeof r.sourceSlug!="string"||typeof r.newSlug!="string"))return{newSlug:r.newSlug,sourceSlug:r.sourceSlug}}function Fl(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 r=t.runRequested;if(!(typeof r!="object"||r==null))return El(r)}async function Ol(e){if(e.baseUrl!=null)return e.baseUrl;let t=await bl({default:"http://localhost:3000",message:"Base URL (local dev server):"});return J({...e,baseUrl:t}),t}Ie();D();import{readFileSync as kn}from"fs";import{graphql as Fe,readFragment as kr}from"gql.tada";async function Tn(e){let t=await Ml(e);d.info("Starting agent test against %s",t.baseUrl);let r=await Ll({config:t.config,workflowId:t.workflowId});d.info("Created run: %s",r);let n=await $e({agentProfileId:t.agentProfileId,config:t.config,runId:r}),o=await H({headed:e.headed}),a=await o.newContext({baseURL:t.baseUrl});t.cookies.length>0&&(await a.addCookies([...t.cookies]),d.info("Injected %d cookies from preconditions",t.cookies.length));let s=await a.newPage();t.navigateTo!=null&&(d.info("Navigating to precondition start page: %s",t.navigateTo),await s.goto(t.navigateTo,{waitUntil:"domcontentloaded"}));try{let i=await Re({baseUrl:t.baseUrl,executedPreconditions:t.executedPreconditions,extraVariables:t.extraVariables,onStep:n.enqueueStep,page:s,runId:r,serverUrl:t.config.ripploServerUrl,spec:t.spec,systemPrompt:t.systemPrompt,token:t.config.token,workflowContext:t.workflowContext}),l=i.verdict==="pass"?"passed":"failed";await n.complete({statusOverride:l,steps:i.steps,summary:i.findings}),d.info(`
|
|
213
213
|
=== Agent Summary ===
|
|
214
|
-
%s`,i.findings),
|
|
214
|
+
%s`,i.findings),ql({result:i})}finally{await o.close()}}var Wl=Fe(`
|
|
215
215
|
mutation CreateRunAgentTest($workflowId: String!, $platforms: [String!]!, $concurrency: Int!) {
|
|
216
216
|
createRun(workflowId: $workflowId, platforms: $platforms, concurrency: $concurrency) {
|
|
217
217
|
id
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
`);async function
|
|
221
|
-
=== Summary ===`),d.info("Steps: %d",e.steps.length);let t=e.steps.filter(n=>n.status==="passed").length,r=e.steps.filter(n=>n.status==="failed").length;d.info("Passed: %d, Failed: %d",t,r),d.info("Generated spec has %d nodes",Object.keys(e.generatedSpec.nodes).length)}var
|
|
220
|
+
`);async function Ll({config:e,workflowId:t}){let r=await k({config:e,document:Wl,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});return r.createRun==null?A("Failed to create run"):r.createRun.id}function ql({result:e}){d.info(`
|
|
221
|
+
=== Summary ===`),d.info("Steps: %d",e.steps.length);let t=e.steps.filter(n=>n.status==="passed").length,r=e.steps.filter(n=>n.status==="failed").length;d.info("Passed: %d, Failed: %d",t,r),d.info("Generated spec has %d nodes",Object.keys(e.generatedSpec.nodes).length)}var Bl=Fe(`
|
|
222
222
|
query AgentProfileForCLI($id: String!) {
|
|
223
223
|
agentProfile(id: $id) {
|
|
224
224
|
id
|
|
@@ -256,14 +256,14 @@ ${r}`].join(`
|
|
|
256
256
|
...WorkflowAgentTest
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
`,[Tr]),
|
|
259
|
+
`,[Tr]),zl=Fe(`
|
|
260
260
|
query ProjectAgentTest($projectId: String!) {
|
|
261
261
|
project(id: $projectId) {
|
|
262
262
|
...ProjectAgentTest
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
`,[Cn]);async function
|
|
266
|
-
`),r=
|
|
265
|
+
`,[Cn]);async function Ml(e){let t=_l(),r=await Gl({config:t,params:e}),n=await Jl({config:t,params:e});if(n==null)return A("No workflow. Provide --workflow <id>");let o=e.url??n.baseUrl,a=n.spec??(e.specPath==null?void 0:Ql(e.specPath));return r==null?A("No system prompt. Provide --agent-profile <id> or --prompt <text|file>"):{agentProfileId:e.agentProfileId,baseUrl:o,config:t,cookies:n.cookies,executedPreconditions:n.executedPreconditions,extraVariables:n.extraVariables,navigateTo:n.navigateTo,spec:a,systemPrompt:r,workflowContext:n.workflowContext,workflowId:n.workflowId}}function _l(){let e=B();return e??A("Not logged in. Run: ripplo login")}async function Gl({config:e,params:t}){if(t.agentProfileId!=null&&e!=null)return Hl({config:e,profileId:t.agentProfileId});if(t.promptArg!=null)return Kl(t.promptArg)}async function Hl({config:e,profileId:t}){let r=await k({config:e,document:Bl,variables:{id:t}});if(r.agentProfile==null)return A(`Agent profile not found: ${t}`);let n=r.agentProfile,o=n.description;return o==null||o.length===0?A(`Agent profile "${n.name}" has no description to use as system prompt`):(d.info("Using agent profile: %s",n.name),xe({description:o,output:n.output??void 0,successCriteria:n.successCriteria??void 0}))}async function Jl({config:e,params:t}){if(t.workflowId==null||e==null)return;let r=await Yl(e),o={...kr(Cn,r),...e.baseUrl==null?{}:{baseUrl:e.baseUrl},...e.preconditionApiPath==null?{}:{preconditionApiPath:e.preconditionApiPath}},s=(o.workflows??[]).find(f=>kr(Tr,f).id===t.workflowId);if(s==null)return A(`Workflow not found: ${t.workflowId}`);let i=kr(Tr,s);d.info("Using workflow: %s",i.name);let l=await se({baseUrl:o.baseUrl,project:o,workflowSlug:i.slug}),c=i.spec==null?void 0:jn(i.spec),p={description:i.description,expectedOutcome:i.expectedOutcome,name:i.name};return{baseUrl:o.baseUrl,cookies:l.cookies,executedPreconditions:l.executed,extraVariables:l.data,navigateTo:l.navigateTo,spec:c,workflowContext:p,workflowId:i.id}}async function Yl(e){let t=await k({config:e,document:zl,variables:{projectId:e.projectId}});return t.project==null?A("Project not found. Check your config."):t.project}function Kl(e){try{return kn(e,"utf8")}catch{return e}}function Ql(e){let t=JSON.parse(kn(e,"utf8"));return jn(t)}function jn(e){let t=ae(e);if(!t.success){let r=t.errors.map(n=>`${n.path}: ${n.message}`).join("; ");return A(`Invalid spec: ${r}`)}return t.data}st();D();import Oe from"fs";import fe from"path";function Nn({graphPath:e,outputPath:t}){let r=Zl(e),n=ec(r),o=Object.entries(n.preconditions).map(([l,c])=>({name:l,returns:c.returns}));if(o.length===0){d.warn("No preconditions found in graph. Nothing to generate.");return}let a=tc(o),s=Xl({graphPath:r,outputPath:t}),i=fe.dirname(s);Oe.existsSync(i)||Oe.mkdirSync(i,{recursive:!0}),Oe.writeFileSync(s,a),d.info("Generated %s with %d precondition(s)",s,o.length)}function Xl({graphPath:e,outputPath:t}){return t!=null?fe.resolve(t):fe.join(fe.dirname(e),"..","generated","precondition-api.ts")}function Zl(e){if(e!=null)return fe.resolve(e);let t=fe.join(process.cwd(),".ripplo","graph.json");if(!Oe.existsSync(t))throw new Error("No .ripplo/graph.json found.");return t}function ec(e){let t=Oe.readFileSync(e,"utf8"),r=JSON.parse(t),n=typeof r=="object"&&r!=null&&"_meta"in r?Object.fromEntries(Object.entries(r).filter(([a])=>a!=="_meta")):r,o=at.safeParse(n);if(!o.success){let a=o.error.issues.map(s=>`${s.path.join(".")}: ${s.message}`).join("; ");throw new Error(`Invalid graph: ${a}`)}return o.data}function tc(e){let t=e.map(n=>` "${n.name}"`).join(`,
|
|
266
|
+
`),r=rc(e);return`// Generated by: ripplo generate-types
|
|
267
267
|
// Do not edit manually \u2014 regenerate when graph preconditions change.
|
|
268
268
|
|
|
269
269
|
import { z } from "zod";
|
|
@@ -312,7 +312,7 @@ export const PreconditionTeardownResponseSchema = z.object({
|
|
|
312
312
|
error: z.string().optional(),
|
|
313
313
|
});
|
|
314
314
|
export type PreconditionTeardownResponse = z.infer<typeof PreconditionTeardownResponseSchema>;
|
|
315
|
-
`}function In(e){return e.split(/[^a-zA-Z0-9]/).map(t=>{let r=t[0];return r==null?"":r.toUpperCase()+t.slice(1)}).join("")}function
|
|
315
|
+
`}function In(e){return e.split(/[^a-zA-Z0-9]/).map(t=>{let r=t[0];return r==null?"":r.toUpperCase()+t.slice(1)}).join("")}function rc(e){let t=e.filter(o=>o.returns!=null&&o.returns.length>0);if(t.length===0)return"export type PreconditionDataMap = Record<PreconditionName, Record<string, string>>;";let r=t.map(o=>{let a=In(o.name),s=o.returns.map(i=>` readonly ${i}: string;`).join(`
|
|
316
316
|
`);return`export interface ${a}Data {
|
|
317
317
|
${s}
|
|
318
318
|
}`}),n=e.map(o=>{let s=o.returns!=null&&o.returns.length>0?`${In(o.name)}Data`:"Record<string, never>";return` readonly "${o.name}": ${s};`});return[...r,"",`export interface PreconditionDataMap {
|
|
@@ -320,7 +320,7 @@ ${n.join(`
|
|
|
320
320
|
`)}
|
|
321
321
|
}`].join(`
|
|
322
322
|
|
|
323
|
-
`)}
|
|
323
|
+
`)}D();import Nr from"fs";import Ar from"path";D();import ac from"crypto";import sc from"http";import{exec as ic}from"child_process";import{z as An}from"zod";var oc="https://ripplo.ai",Cr="https://ripplo-dev.up.railway.app",nc=An.object({RIPPLO_SERVER_URL:An.string().min(1).default(oc)}),En;function $n(){return En??=nc.parse(process.env),En}var lc=`<!DOCTYPE html>
|
|
324
324
|
<html lang="en">
|
|
325
325
|
<head>
|
|
326
326
|
<meta charset="utf-8" />
|
|
@@ -357,7 +357,7 @@ ${n.join(`
|
|
|
357
357
|
</div>
|
|
358
358
|
<script>setTimeout(function(){window.close()},3000)</script>
|
|
359
359
|
</body>
|
|
360
|
-
</html>`;async function dt({url:e}){let t=e??$n().RIPPLO_SERVER_URL,r=
|
|
360
|
+
</html>`;async function dt({url:e}){let t=e??$n().RIPPLO_SERVER_URL,r=ac.randomBytes(16).toString("hex"),{port:n,tokenPromise:o}=await cc(r),a=`${t}/cli/authorize?port=${String(n)}&state=${encodeURIComponent(r)}`;d.info("Opening browser to authorize..."),d.info("If the browser doesn't open, visit: %s",a),uc(a);let s=await o;d.info("Authorized successfully.");let i={cloudBaseUrl:"",projectId:"",ripploServerUrl:t,token:s};return J(i),i}function cc(e){return new Promise(t=>{let r,n=new Promise(a=>{r=a}),o=sc.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"),c=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(c==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(lc),o.close(),r(c)});o.listen(0,()=>{let a=o.address();if(a==null||typeof a=="string")throw new Error("Failed to get server address");t({port:a.port,tokenPromise:n})})})}function dc(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function uc(e){let t=dc();ic(`${t} "${e}"`,()=>{})}D();import pt from"fs";import ie from"path";import{fileURLToPath as Vn}from"url";import{z as ut}from"zod";var pc=ut.looseObject({mcpServers:ut.record(ut.string(),ut.unknown())});function ft(){let e=ie.join(process.cwd(),".mcp.json"),t=fc()?{args:[mc()],command:"node"}:{args:["-y","--package","ripplo@latest","ripplo-mcp"],command:"npx"},r=gc(e),n={...r,mcpServers:{...r.mcpServers,ripplo:t}};pt.writeFileSync(e,JSON.stringify(n,null,2)),d.info("Wrote MCP config to %s",e)}function fc(){let e=Vn(import.meta.url),t=ie.dirname(ie.dirname(e));return pt.existsSync(ie.join(t,"tsup.config.ts"))}function mc(){let e=Vn(import.meta.url),t=ie.dirname(ie.dirname(e));return ie.join(t,"mcp","index.js")}function gc(e){if(!pt.existsSync(e))return{mcpServers:{}};let t=JSON.parse(pt.readFileSync(e,"utf8")),r=pc.safeParse(t);return r.success?r.data:{mcpServers:{}}}D();import yc from"path";import{input as jr,select as hc}from"@inquirer/prompts";import{graphql as Dn}from"gql.tada";var wc=Dn(`
|
|
361
361
|
query ProjectsCLI {
|
|
362
362
|
projects {
|
|
363
363
|
id
|
|
@@ -366,7 +366,7 @@ ${n.join(`
|
|
|
366
366
|
cloudBaseUrl
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
-
`);async function mt(e){let t=await k({config:e,document:
|
|
369
|
+
`);async function mt(e){let t=await k({config:e,document:wc,variables:void 0});if(t.projects==null)throw new Error("Failed to fetch projects");return t.projects.map(r=>({baseUrl:r.baseUrl,cloudBaseUrl:r.cloudBaseUrl,id:r.id,name:r.name}))}var Un="__create_new__",Sc=Dn(`
|
|
370
370
|
mutation CreateProjectShared(
|
|
371
371
|
$name: String!
|
|
372
372
|
$baseUrl: String!
|
|
@@ -385,8 +385,8 @@ ${n.join(`
|
|
|
385
385
|
name
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
`);async function gt({config:e,projects:t}){if(t.length===1){let o=t[0];if(o==null)throw new Error("No project found");return d.info("Auto-selected project: %s",o.name),o}let r=[...t.map(o=>({name:o.name,value:o.id})),{name:"+ Create new project",value:Un}],n=await
|
|
389
|
-
`)}
|
|
388
|
+
`);async function gt({config:e,projects:t}){if(t.length===1){let o=t[0];if(o==null)throw new Error("No project found");return d.info("Auto-selected project: %s",o.name),o}let r=[...t.map(o=>({name:o.name,value:o.id})),{name:"+ Create new project",value:Un}],n=await hc({choices:r,message:"Select a project:"});if(n!==Un){let o=t.find(a=>a.id===n);if(o==null)throw new Error("Selected project not found");return o}return Ir({config:e})}async function Ir({config:e}){let t=process.cwd(),r=yc.basename(t),n=await jr({default:r,message:"Project name:"}),o=await jr({default:"http://localhost:3000",message:"Base URL (local dev server):"}),a=await jr({message:"Deployed environment URL (staging):"}),s=await k({config:e,document:Sc,variables:{baseUrl:o,cloudBaseUrl:a,name:n,provider:"local",repoUrl:t}});if(s.createProject==null)throw new Error("Failed to create project");return d.info("Created project: %s",s.createProject.name),{baseUrl:o,cloudBaseUrl:a,id:s.createProject.id,name:s.createProject.name}}async function Fn({url:e}){let t=await bc({url:e});d.info("\u2713 Logged in");let r=await Pc({config:t});d.info("\u2713 Selected project: %s",r.name),await new Promise(a=>{process.stderr.write("",()=>{a()})});let n=t.baseUrl??r.baseUrl,o={...t,baseUrl:n,cloudBaseUrl:r.cloudBaseUrl,projectId:r.id};J(o),xc(process.cwd()),d.info("\u2713 Created .ripplo/"),ft(),d.info("\u2713 Installed MCP config into .mcp.json"),Vt(),d.info("Starting dev mode..."),await ct({concurrency:void 0,headed:!1})}async function bc({url:e}){let t=B();return t??(d.info("Not logged in. Let's authenticate first."),dt({url:e}))}async function Pc({config:e}){let t=await mt(e);return t.length===0?Ir({config:e}):gt({config:e,projects:t})}var Rc={edges:[],preconditions:{},states:{},version:3};function xc(e){let t=Ar.join(e,".ripplo"),r=Ar.join(t,"graph.json"),n=Ar.join(t,"workflows");Nr.mkdirSync(n,{recursive:!0}),Nr.existsSync(r)||Nr.writeFileSync(r,JSON.stringify(Rc,null,2)+`
|
|
389
|
+
`)}D();async function On({url:e}){let t=await dt({url:e}),r=await mt(t),n=await gt({config:t,projects:r});J({...t,projectId:n.id}),d.info("Logged in to project: %s",n.id),process.exit(0)}D();import{search as Ac}from"@inquirer/prompts";import G from"chalk";import Ec from"ora";Ie();D();import{graphql as yt,readFragment as me}from"gql.tada";D();import{graphql as vc}from"gql.tada";var kc=vc(`
|
|
390
390
|
mutation SubmitRunResultsCLI(
|
|
391
391
|
$runId: String!
|
|
392
392
|
$platform: String!
|
|
@@ -413,7 +413,7 @@ ${n.join(`
|
|
|
413
413
|
status
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
-
`);async function
|
|
416
|
+
`);async function Wn({config:e,runId:t,steps:r}){let n=r.filter(i=>i.status==="passed").length,o=r.filter(i=>i.status==="failed").length,a=r.reduce((i,l)=>i+l.duration,0),s=o>0?"failed":"passed";await k({config:e,document:kc,variables:{agentProfileId:null,duration:a,failCount:o,passCount:n,platform:"chromium",runId:t,status:s,steps:r,warnCount:0}})}var ge=yt(`
|
|
417
417
|
fragment WorkflowCore on Workflow {
|
|
418
418
|
id
|
|
419
419
|
name
|
|
@@ -421,7 +421,7 @@ ${n.join(`
|
|
|
421
421
|
source
|
|
422
422
|
spec
|
|
423
423
|
}
|
|
424
|
-
`),
|
|
424
|
+
`),Ln=yt(`
|
|
425
425
|
fragment ProjectCore on Project {
|
|
426
426
|
id
|
|
427
427
|
name
|
|
@@ -445,17 +445,17 @@ ${n.join(`
|
|
|
445
445
|
...WorkflowCore
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
|
-
`,[ge]),
|
|
448
|
+
`,[ge]),Tc=yt(`
|
|
449
449
|
query ProjectCore($projectId: String!) {
|
|
450
450
|
project(id: $projectId) {
|
|
451
451
|
...ProjectCore
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
|
-
`,[
|
|
454
|
+
`,[Ln]),Cc=yt(`
|
|
455
455
|
mutation CreateRunCore($workflowId: String!, $platforms: [String!]!, $concurrency: Int!) {
|
|
456
456
|
createRun(workflowId: $workflowId, platforms: $platforms, concurrency: $concurrency) {
|
|
457
457
|
id
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
`);async function
|
|
461
|
-
Run \`npm install -g ${Jn}\` to update`))}).catch(()=>{})}async function
|
|
460
|
+
`);async function qn({config:e,headed:t,onStep:r,workflowId:n,workflowName:o}){await Ce({maxRuns:100});let a=await zn(e),s=a.workflows??[],i=jc({workflowId:n,workflowName:o,workflows:s}),l=me(ge,i),c=Ic(l.spec),[p,f,g]=await Promise.all([O({label:"Preconditions resolved",fn:()=>se({baseUrl:a.baseUrl,project:a,workflowSlug:l.slug})}),O({label:"Browser launched",fn:()=>H({headed:t})}),Nc({config:e,workflowId:l.id})]),y=await O({label:"Spec executed",fn:()=>Ne({baseUrl:a.baseUrl,browser:f,cookies:p.cookies,extraVariables:p.data,navigateTo:p.navigateTo,onStep:r,runId:g,spec:c})});await f.close(),await Wn({config:e,runId:g,steps:y}),p.apiUrl!=null&&await Ee({apiUrl:p.apiUrl,cookies:p.cookies,executed:p.executed});let x=y.filter(w=>w.status==="passed").length,b=y.filter(w=>w.status==="failed").length;return{duration:y.reduce((w,I)=>w+I.duration,0),failed:b,passed:x,runId:g,steps:y,workflowName:l.name}}async function Bn({config:e}){return((await zn(e)).workflows??[]).map(n=>me(ge,n)).map(n=>({id:n.id,name:n.name,source:n.source}))}async function zn(e){let t=await k({config:e,document:Tc,variables:{projectId:e.projectId}});if(t.project==null)throw new Error("No project found. Check your config.");return{...me(Ln,t.project),...e.baseUrl==null?{}:{baseUrl:e.baseUrl},...e.preconditionApiPath==null?{}:{preconditionApiPath:e.preconditionApiPath}}}function jc({workflowId:e,workflowName:t,workflows:r}){if(e!=null){let n=r.find(o=>me(ge,o).id===e);if(n==null)throw new Error(`Workflow with ID "${e}" not found`);return n}if(t!=null){let n=r.find(o=>me(ge,o).name.toLowerCase()===t.toLowerCase());if(n==null){let o=r.map(a=>me(ge,a).name).join(", ");throw new Error(`Workflow "${t}" not found. Available: ${o}`)}return n}throw new Error("Either workflowId or workflowName must be provided")}function Ic(e){if(e==null)throw new Error("Workflow has no spec defined");let t=ae(e);if(!t.success){let r=t.errors.map(n=>`${n.path}: ${n.message}`).join("; ");throw new Error(`Invalid spec: ${r}`)}return t.data}async function Nc({config:e,workflowId:t}){let r=await k({config:e,document:Cc,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});if(r.createRun==null)throw new Error("Failed to create run");return r.createRun.id}async function Mn({headed:e,workflowId:t}){let r=B();if(r==null)return A("Not logged in. Run: ripplo login");let n=t??await $c(r);if(n==null)return A("No workflow selected.");let o=Ec("Running workflow...").start(),a=await qn({config:r,headed:e,onStep:void 0,workflowId:n,workflowName:void 0});o.stop(),Vc(a.steps)}async function $c(e){let r=(await Bn({config:e})).map(n=>({name:`${n.name} (${n.source})`,value:n.id}));return Ac({message:"Select a workflow:",source:n=>n==null?r:r.filter(o=>o.name.toLowerCase().includes(n.toLowerCase()))})}function Vc(e){let t=e.filter(o=>o.status==="passed").length,r=e.filter(o=>o.status==="failed").length,n=e.reduce((o,a)=>o+a.duration,0);d.info("Results:"),e.forEach(o=>{Uc(o)}),d.info("%s, %s %s",G.green(`${String(t)} passed`),G.red(`${String(r)} failed`),G.dim(`${String(n)}ms`))}function Uc(e){let t=e.status==="passed"?G.green("\u2713"):G.red("\u2717");d.info(" %s %s %s",t,e.title,G.dim(`${String(e.duration)}ms`)),e.assertions.forEach(r=>{let n=r.status==="passed"?G.green("\u2713"):G.red("\u2717"),o=r.detail==null?"":G.dim(` \u2014 ${r.detail}`);d.info(" %s %s%s",n,r.description,o)}),e.detail!=null&&d.info(" %s",G.dim(e.detail))}D();function _n(){if(B()==null)return A("Not logged in. Run: ripplo login");ft(),d.info("Restart Claude Code to pick up the new MCP server."),process.exit(0)}D();import Dc from"chalk";import{z as Gn}from"zod";var Hn="0.0.2",Jn="ripplo",Fc=Gn.object({version:Gn.string()});function Yn(){Oc().then(e=>{e==null||e===Hn||d.info(Dc.yellow(`Update available: ${Hn} \u2192 ${e}
|
|
461
|
+
Run \`npm install -g ${Jn}\` to update`))}).catch(()=>{})}async function Oc(){let e=new AbortController,t=setTimeout(()=>{e.abort()},3e3);try{let r=await fetch(`https://registry.npmjs.org/${Jn}/latest`,{headers:{accept:"application/json"},signal:e.signal});if(!r.ok)return;let n=await r.json();return Fc.parse(n).version}catch{return}finally{clearTimeout(t)}}var Qn=ht.resolve(ht.dirname(Wc(import.meta.url)),"..");Kn({path:ht.join(Qn,".env.local"),quiet:!0});Kn({path:ht.join(Qn,".env"),quiet:!0});async function Lc(){Yn();let e=process.argv[2],t=e==null?void 0:Kc[e];if(t==null){Qc();return}await t()}function qc(){let e=process.argv.slice(3),t=e.indexOf("--output"),r=t===-1?void 0:e[t+1];return{graphPath:e.find(o=>!o.startsWith("--")&&o!==r),outputPath:r}}function Bc(){if(process.argv.includes("--dev"))return Cr;let e=process.argv.indexOf("--url");if(e!==-1)return process.argv[e+1]}function zc(){return On({url:Bc()})}function Mc(){let e=process.argv.includes("--dev")?Cr:void 0;return Fn({url:e})}function _c(){let e=process.argv.includes("--headed"),t=process.argv.slice(3).find(r=>!r.startsWith("--"));return Mn({headed:e,workflowId:t})}function Gc(){let e=qc();Nn(e)}function Hc(){let e=process.argv.slice(3),t=Jc(e);return t.agentProfileId==null&&t.promptArg==null?(d.error("Usage: ripplo agent-test (--agent-profile <id> | --prompt <text|file>) [--workflow <id> | --url <url>] [--spec <file>] [--headed]"),Promise.resolve()):Tn(t)}function Jc(e){return{agentProfileId:We(e,"--agent-profile"),headed:e.includes("--headed"),promptArg:We(e,"--prompt"),specPath:We(e,"--spec"),url:We(e,"--url"),workflowId:We(e,"--workflow")}}function We(e,t){let r=e.indexOf(t);return r===-1?void 0:e[r+1]}function Yc(){let e=process.argv.slice(3),t=e.includes("--headed"),r=e.indexOf("--concurrency"),n=r===-1?void 0:Number(e[r+1]),o=n!=null&&Number.isFinite(n)&&n>0?n:void 0;return ct({concurrency:o,headed:t})}var Kc={"agent-test":Hc,dev:Yc,"generate-types":Gc,init:Mc,login:zc,run:_c,"setup-mcp":_n};function Qc(){d.info("Usage: ripplo <command>"),d.info(" login Authenticate with Ripplo"),d.info(" init Create a new project (no GitHub required)"),d.info(" run Execute a workflow spec via Playwright"),d.info(" dev Start dev mode: watch files + run workflows from the UI"),d.info(" agent-test Run an autonomous agent test locally"),d.info(" setup-mcp Configure MCP server in .mcp.json"),d.info(" generate-types Generate Zod schemas + TS types for precondition API")}Lc().catch(e=>{d.error(e,"Unexpected error"),process.exit(1)});export{Lc as main};
|