ripplo 0.0.1
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/README.md +31 -0
- package/dist/index.js +461 -0
- package/dist/mcp/index.js +857 -0
- package/package.json +57 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
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 b({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 E({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=E({ref:e.url,variables:n});return await t.goto(o,{timeout:r,waitUntil:"domcontentloaded"}),{variables:n}}case"click":return await b({locator:e.locator,page:t}).click({timeout:r}),{variables:n};case"fill":{let o=E({ref:e.value,variables:n});return await b({locator:e.locator,page:t}).fill(o,{timeout:r}),{variables:n}}case"select":{let o=E({ref:e.value,variables:n});return await b({locator:e.locator,page:t}).selectOption(o,{timeout:r}),{variables:n}}case"hover":return await b({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 b({locator:e.locator,page:t}).check({timeout:r}),{variables:n};case"uncheck":return await b({locator:e.locator,page:t}).uncheck({timeout:r}),{variables:n};case"waitFor":return await b({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 b({locator:e.locator,page:t}).textContent({timeout:r});return{variables:ne({name:e.variable,store:n,value:o??""})}}case"waitForUrl":{let o=E({ref:e.expected,variables:n});return await t.waitForURL(na({expected:o,operator:e.operator}),{timeout:r}),{variables:n}}case"waitForResponse":{let o=E({ref:e.urlPattern,variables:n});return await t.waitForResponse(a=>a.url().includes(o),{timeout:r}),{variables:n}}case"waitForRequest":{let o=E({ref:e.urlPattern,variables:n});return await t.waitForRequest(a=>a.url().includes(o),{timeout:r}),{variables:n}}case"upload":return await b({locator:e.locator,page:t}).setInputFiles(e.files,{timeout:r}),{variables:n};case"dblclick":return await b({locator:e.locator,page:t}).dblclick({timeout:r}),{variables:n};case"drag":{let o=b({locator:e.source,page:t}),a=b({locator:e.target,page:t});return await o.dragTo(a,{timeout:r}),{variables:n}}case"scrollIntoView":return await b({locator:e.locator,page:t}).scrollIntoViewIfNeeded({timeout:r}),{variables:n};case"type":{let o=E({ref:e.value,variables:n});return await b({locator:e.locator,page:t}).pressSequentially(o,{timeout:r}),{variables:n}}case"focus":return await b({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 b({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,Wr,Or=m(()=>{"use strict";C();pa=Fr.object({selector:Fr.string().describe("CSS selector for the checkbox to check")}),Wr=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 qr}from"zod";var fa,Lr,Br=m(()=>{"use strict";C();fa=qr.object({selector:qr.string().describe("CSS selector for the element to click")}),Lr=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 Le}from"zod";var zr,Mr,Gr=m(()=>{"use strict";zr=Le.object({summary:Le.string().describe("A summary of your findings and why you reached this verdict"),verdict:Le.enum(["pass","fail"]).describe("Whether the test passed or failed")}),Mr={anthropicTool:{description:"Call this tool when you have finished your evaluation to report your final verdict. Your verdict should reflect whether the workflow worked correctly based on the success criteria (if provided) or your overall assessment.",input_schema:{...Le.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 _r}from"zod";var ma,Hr,Jr=m(()=>{"use strict";C();ma=_r.object({selector:_r.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
|
+
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(r.length)} console messages:
|
|
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
|
+
`),s=n.length>kt?`
|
|
8
|
+
(showing last ${String(kt)} of ${String(n.length)})`:"";return{specNode:void 0,stepResult:void 0,toolOutput:`${String(o.length)} network requests:${s}
|
|
9
|
+
${a}`}}})});import{z as oo}from"zod";var Sa,no,ao=m(()=>{"use strict";C();Sa=oo.object({urlPattern:oo.string().describe("Regex pattern to match the request URL")}),no=h({description:"Get the full response body for a specific network request matching the URL pattern. Returns the most recent match.",name:"get_network_response",schema:Sa,execute:(e,t)=>{let r=new RegExp(t.urlPattern,"i"),n=e.monitor.networkEntries.filter(l=>r.test(l.url));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let o=n.at(-1);if(o==null)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let a=o.statusCode==null?"pending":String(o.statusCode),s=Object.entries(o.responseHeaders).map(([l,c])=>` ${l}: ${c}`).join(`
|
|
10
|
+
`),i=o.responseBody??"(no body captured)";return{specNode:void 0,stepResult:void 0,toolOutput:`${o.method} ${a} ${o.url}
|
|
11
|
+
|
|
12
|
+
Response Headers:
|
|
13
|
+
${s}
|
|
14
|
+
|
|
15
|
+
Body:
|
|
16
|
+
${i}`}}})});import{z as ba}from"zod";var Pa,so,io=m(()=>{"use strict";C();Pa=ba.object({}),so=h({description:"Get a text representation of the current page content for inspection",name:"get_page_content",schema:Pa,execute:async(e,t)=>{let r=await e.page.locator("body").textContent({timeout:5e3}),n=e.page.url(),o=await e.page.title();return{specNode:void 0,stepResult:void 0,toolOutput:`URL: ${n}
|
|
17
|
+
Title: ${o}
|
|
18
|
+
|
|
19
|
+
${r??""}`}}})});import{z as lo}from"zod";var Ra,co,uo=m(()=>{"use strict";C();Ra=lo.object({selector:lo.string().describe("CSS selector for the element to hover over")}),co=h({description:"Hover over an element matching the CSS selector",name:"hover",schema:Ra,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).hover({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"hover"};return v({assertions:[],detail:`Hovered over ${t.selector}`,duration:performance.now()-r,nodeType:"hover",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Hover ${t.selector}`})}})});import{z as po}from"zod";var xa,fo,mo=m(()=>{"use strict";C();xa=po.object({url:po.string().describe("The URL to navigate to")}),fo=h({description:"Navigate the browser to a URL",name:"navigate",schema:xa,execute:async(e,t)=>{let r=performance.now();await e.page.goto(t.url,{waitUntil:"domcontentloaded"});let o={id:`agent-step-${String(e.stepIndex)}`,type:"goto",url:{type:"static",value:t.url}};return v({assertions:[],detail:`Navigated to ${t.url}`,duration:performance.now()-r,nodeType:"goto",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Navigate to ${t.url}`})}})});import{z as go}from"zod";var va,yo,ho=m(()=>{"use strict";C();va=go.object({key:go.string().describe("Key to press, e.g. 'Enter', 'Tab', 'Escape'")}),yo=h({description:"Press a keyboard key",name:"press",schema:va,execute:async(e,t)=>{let r=performance.now();await e.page.keyboard.press(t.key);let o={id:`agent-step-${String(e.stepIndex)}`,key:t.key,type:"press"};return v({assertions:[],detail:`Pressed ${t.key}`,duration:performance.now()-r,nodeType:"press",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Press ${t.key}`})}})});import{z as Tt}from"zod";var ka,wo,So=m(()=>{"use strict";C();ka=Tt.object({height:Tt.number().int().positive().describe("Viewport height in pixels"),width:Tt.number().int().positive().describe("Viewport width in pixels")}),wo=h({description:"Resize the browser viewport to the specified dimensions. Use this to test responsive layouts at different screen sizes (e.g. mobile: 375x812, tablet: 768x1024, desktop: 1440x900).",name:"resize_viewport",schema:ka,execute:async(e,t)=>{let r=performance.now();await e.page.setViewportSize({height:t.height,width:t.width});let n=`agent-step-${String(e.stepIndex)}`,o={height:t.height,id:n,type:"setViewport",width:t.width};return v({assertions:[],detail:`Resized viewport to ${String(t.width)}x${String(t.height)}`,duration:performance.now()-r,nodeType:"setViewport",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Resize viewport to ${String(t.width)}x${String(t.height)}`})}})});import{z as Ta}from"zod";var Ca,bo,Po=m(()=>{"use strict";C();Ca=Ta.object({}),bo=h({description:"Take a screenshot of the current page",name:"screenshot",schema:Ca,execute:async(e,t)=>{let r=performance.now(),o={id:`agent-step-${String(e.stepIndex)}`,type:"screenshot"};return v({assertions:[],detail:"Screenshot captured",duration:performance.now()-r,nodeType:"screenshot",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:"Screenshot"})}})});import{z as Ro}from"zod";function Ia(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}var ja,xo,vo=m(()=>{"use strict";C();ja=Ro.object({pattern:Ro.string().describe("Regex pattern to search console log messages")}),xo=h({description:"Search console log messages for a regex pattern. Returns matching entries.",name:"search_console",schema:ja,execute:(e,t)=>{let r=new RegExp(t.pattern,"i"),n=e.monitor.consoleEntries.filter(a=>r.test(a.text));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console messages matching: ${t.pattern}`};let o=n.map(a=>Ia(a)).join(`
|
|
20
|
+
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(n.length)} matching console messages:
|
|
21
|
+
${o}`}}})});import{z as ko}from"zod";var Na,To,Co=m(()=>{"use strict";C();Na=ko.object({pattern:ko.string().describe("Regex pattern to search across network request URLs and response bodies")}),To=h({description:"Search network requests and response bodies for a regex pattern. Useful for finding API calls, tokens, or specific data in responses.",name:"search_network",schema:Na,execute:(e,t)=>{let r=new RegExp(t.pattern,"i"),n=e.monitor.networkEntries.filter(a=>r.test(a.url)||a.responseBody!=null&&r.test(a.responseBody));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network entries matching: ${t.pattern}`};let o=n.map(a=>{let s=a.statusCode==null?"pending":String(a.statusCode),i=r.test(a.url)?" [URL match]":"",l=a.responseBody!=null&&r.test(a.responseBody)?" [body match]":"";return`${a.method} ${s} ${a.url}${i}${l}`}).join(`
|
|
22
|
+
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(n.length)} matching network entries:
|
|
23
|
+
${o}`}}})});import{z as jo}from"zod";function Va({contextLines:e,lines:t,maxResults:r,pattern:n}){let o=new RegExp(n,"i"),a=[];return t.forEach((s,i)=>{if(a.length>=r||!o.test(s))return;let l=Math.max(0,i-e),c=Math.min(t.length-1,i+e),p=t.slice(l,c+1).map((f,g)=>{let y=l+g+1;return`${l+g===i?">":" "} ${String(y)}: ${f}`}).join(`
|
|
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
|
+
`),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
|
+
---
|
|
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,Wo=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 Wa,Oo,qo=m(()=>{"use strict";C();Wa=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)")}),Oo=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:Wa,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=Oa.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,Oa,Lo,Bo,Mo=m(()=>{"use strict";$r();Dr();Or();Br();Gr();Jr();Kr();Zr();ro();ao();io();uo();mo();ho();So();Po();vo();Co();No();Eo();Uo();Wo();qo();It();Nt=[fo,Lr,Yr,yo,Wr,Vo,Ao,co,Fo,Oo,bo,so,Io,Ur,Er,Xr,to,no,xo,To,wo,Hr,Mr],Oa=new Map(Nt.map(e=>[e.name,e])),Lo=Nt.map(e=>e.anthropicTool),Bo=Nt.map(e=>`- **${e.name}**: ${e.anthropicTool.description??""}`).join(`
|
|
29
|
+
`)});import qa from"pino";function N(e){return d.fatal(e),process.exit(1)}var d,z=m(()=>{"use strict";d=qa({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}})});import La 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 La({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 P=Ma({extraVariables:r,spec:i}),S=Ga({baseUrl:e,executedPreconditions:t,spec:i,systemPrompt:l,variables:P,workflowContext:p}),B=_a({baseUrl:e,spec:i,variables:P}),I=[{content:Ha({page:o,startUrl:B}),role:"user"}],re=[],ye=[],he=0,qe="",O;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:S,tools:Lo}),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&&(qe=le.newFindings),le.verdict!=null&&(O=le.verdict),!le.continueLoop)break}let wt=Qa(ye);return{findings:qe,generatedSpec:wt,monitor:y,steps:re,verdict:O??"fail"}}function Ma({extraVariables:e,spec:t}){return{...Se({defs:t?.variables}),...e}}function Ga({baseUrl:e,executedPreconditions:t,spec:r,systemPrompt:n,variables:o,workflowContext:a}){let s=a==null?"":[`
|
|
30
|
+
|
|
31
|
+
## Workflow Under Test`,`**Name:** ${a.name}`,`**Description:** ${a.description}`,`**Expected Outcome:** ${a.expectedOutcome}`,`
|
|
32
|
+
Focus your testing ONLY on this specific workflow. Do not test unrelated parts of the application.`].join(`
|
|
33
|
+
`),i=r==null?"":`
|
|
34
|
+
|
|
35
|
+
Reference workflow spec (the steps a user would follow):
|
|
36
|
+
\`\`\`json
|
|
37
|
+
${JSON.stringify(r,null,2)}
|
|
38
|
+
\`\`\``,l=t.map(y=>`- ${y}`).join(`
|
|
39
|
+
`),c=t.length===0?"":`
|
|
40
|
+
|
|
41
|
+
## Setup Already Completed
|
|
42
|
+
The following setup steps have already been run before your session started:
|
|
43
|
+
${l}
|
|
44
|
+
|
|
45
|
+
Do not repeat any of these steps.`,p=Object.entries(o),f=p.map(([y,P])=>`- **${y}:** ${String(P)}`).join(`
|
|
46
|
+
`),g=p.length===0?"":`
|
|
47
|
+
|
|
48
|
+
## Resolved Variables
|
|
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
|
+
## Available Tools`,Bo,s,c,i,g,`
|
|
51
|
+
## Agent Profile (HIGHEST PRIORITY \u2014 these instructions override any defaults above)`,n].join(`
|
|
52
|
+
`)}function _a({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(P=>P.type==="text").map(P=>P.text),p=o.content.filter(P=>P.type==="tool_use");if(p.length===0)return{continueLoop:!1,newFindings:c.join(`
|
|
53
|
+
`),nextStepIndex:i,verdict:void 0};let f=[],g=i,y;for(let P of p){let S=await Ka({block:P,monitor:t,onStep:r,page:n,runStartTime:a,specNodes:s,stepIndex:g,steps:l});f.push(S.toolResult),g=S.nextStepIndex,S.verdict!=null&&(y=S.verdict)}return e.push({content:o.content,role:"assistant"},{content:f,role:"user"}),{continueLoop:y==null&&o.stop_reason==="tool_use",newFindings:c.join(`
|
|
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();z();be();K();Ba=50,za=16384});function xe({description:e,output:t,successCriteria:r}){let n=[`## Agent Identity
|
|
55
|
+
${e}`];return t!=null&&t.length>0&&n.push(`## Output
|
|
56
|
+
${t}`),r!=null&&r.length>0&&n.push(`## Success Criteria
|
|
57
|
+
${r}`),n.push(["## Completing Your Evaluation",'When you finish your evaluation, you MUST call the `complete_test` tool with your verdict ("pass" or "fail") and a summary.',"Base your verdict on whether the workflow worked correctly. Individual step failures during exploration do not necessarily mean the test failed."].join(`
|
|
58
|
+
`)),n.join(`
|
|
59
|
+
|
|
60
|
+
`)}var Et=m(()=>{"use strict"});import{execFileSync as Xa}from"child_process";import{createRequire as Za}from"module";import Go 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 es(t)?new Error(`Playwright browsers are not installed. Run:
|
|
61
|
+
|
|
62
|
+
npx playwright install chromium
|
|
63
|
+
`):t}}function Vt(){let e=$t.executablePath();if(Go.existsSync(e))return;d.info("Chromium not found. Installing via Playwright...");let r=Za(import.meta.url).resolve("playwright/cli");if(Xa(process.execPath,[r,"install","chromium"],{stdio:"inherit"}),!Go.existsSync(e))throw new Error(`Playwright browser installation failed. Try running manually:
|
|
64
|
+
|
|
65
|
+
npx playwright install chromium
|
|
66
|
+
`);d.info("\u2713 Chromium installed")}function es(e){return e instanceof Error?e.message.includes("Executable doesn't exist"):!1}var ze=m(()=>{"use strict";z()});import{mkdir as Ut,writeFile as M}from"fs/promises";import D from"path";async function Me({context:e,page:t,runId:r,stepIndex:n,stepResult:o}){try{let a=D.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(D.join(a,"info.json"),JSON.stringify(s,null,2)),M(D.join(a,"screenshot.png"),Buffer.from(o.screenshotBase64,"base64")),ts({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 ts({context:e,page:t,stepDir:r}){let[n,o,a]=await Promise.all([t.content().catch(()=>"(unable to capture DOM)"),rs(t),os({context:e,page:t})]);await Promise.all([M(D.join(r,"dom.html"),n),M(D.join(r,"accessibility-tree.txt"),o),M(D.join(r,"storage.json"),JSON.stringify(a,null,2))])}async function rs(e){try{return await e.locator(":root").ariaSnapshot()}catch{return"(unable to capture accessibility tree)"}}async function os({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 Ge({monitor:e,runId:t,steps:r,summary:n}){try{let o=D.join(process.cwd(),".ripplo","debug",t);await Ut(o,{recursive:!0}),await Promise.all([M(D.join(o,"summary.txt"),ns({steps:r,summary:n})),M(D.join(o,"console.log"),as(e.consoleEntries)),M(D.join(o,"network.jsonl"),ss(e.networkEntries)),M(D.join(o,"page-errors.log"),e.pageErrors.join(`
|
|
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 ns({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 as(e){return e.map(t=>`[${new Date(t.timestamp).toISOString()}] [${t.level.toUpperCase()}] (${t.url}) ${t.text}`).join(`
|
|
70
|
+
`)}function ss(e){return e.map(t=>JSON.stringify(t)).join(`
|
|
71
|
+
`)}async function _o({error:e,runId:t,stack:r,workflowName:n}){try{let o=D.join(process.cwd(),".ripplo","debug",t);await Ut(o,{recursive:!0});let a=r==null?e:`${e}
|
|
72
|
+
|
|
73
|
+
${r}`,s=[`Run ID: ${t}`,`Workflow: ${n}`,"Status: failed","",`Error: ${e}`,"",r==null?"":`Stack trace:
|
|
74
|
+
${r}`].join(`
|
|
75
|
+
`);await Promise.all([M(D.join(o,"error.txt"),a),M(D.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 _e=m(()=>{"use strict";z()});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}),P=await y.newContext({baseURL:e});t.length>0&&(await P.addCookies([...t]),d.info("Injected %d cookies from preconditions",t.length));let S=await P.newPage();a!=null&&(d.info("Navigating to precondition start page: %s",a),await S.goto(a,{waitUntil:"domcontentloaded"}));try{let R=function(O){c.enqueueStep(O),Me({context:P,page:S,runId:s,stepIndex:O.stepIndex,stepResult:O})};var B=R;let I=await Re({baseUrl:e,executedPreconditions:r,extraVariables:n,onStep:R,page:S,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(O=>O.status==="passed").length,he=I.steps.filter(O=>O.status==="failed").length,qe={duration:I.steps.reduce((O,wt)=>O+wt.duration,0),failCount:he,passCount:ye,runId:s,status:re,workflowName:g.name};await Ge({monitor:I.monitor,runId:s,steps:I.steps,summary:qe}),d.info("Agent test complete: %d passed, %d failed",ye,he),d.info(`
|
|
76
|
+
=== Agent Summary ===
|
|
77
|
+
%s`,I.findings)}finally{await y.close()}}var Ft=m(()=>{"use strict";ze();At();_e();z()});async function Wt({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 Ot({expected:e,operator:t,url:r}){return X({actual:r,expected:e,label:"URL",operator:t})}async function qt({expected:e,locator:t,operator:r}){let n=await t.count();return He({actual:n,expected:e,label:"Count",operator:r})}async function Lt({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=is(e),n=r?void 0:`Got: "${e.actual}"`;return{description:t,detail:n,status:r?"passed":"failed"}}function is({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=ls(e),n=r?void 0:`Got: ${String(e.actual)}`;return{description:t,detail:n,status:r?"passed":"failed"}}function ls({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 cs}from"graphql";async function k(e){let t=cs(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(!ds(o))throw new Error("Invalid GraphQL response");if(us(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 ds(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function us(e){return Array.isArray(e.errors)&&e.errors.length>0}var Te=m(()=>{"use strict"});import{readdir as ps,rm as fs,stat as ms}from"fs/promises";import Xo from"path";import{graphql as gs}from"gql.tada";async function Ce({maxRuns:e}){try{let r=(await ps(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 ms(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=>fs(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,vp,Zo=m(()=>{"use strict";Te();z();Ko=Xo.join(process.cwd(),".ripplo","debug"),Qo=360*60*1e3,vp=gs(`
|
|
78
|
+
mutation RevokeCurrentCliToken {
|
|
79
|
+
revokeCurrentCliToken
|
|
80
|
+
}
|
|
81
|
+
`)});async function Bt({condition:e,page:t,timeout:r,variables:n}){switch(e.type){case"elementVisible":return(await ve({locator:b({locator:e.locator,page:t}),timeout:r})).status==="passed";case"elementNotVisible":return(await ke({locator:b({locator:e.locator,page:t}),timeout:r})).status==="passed";case"urlMatch":{let o=E({ref:e.expected,variables:n});return X({actual:t.url(),expected:o,label:"URL",operator:e.operator}).status==="passed"}case"textMatch":{let a=await b({locator:e.locator,page:t}).textContent({timeout:r}),s=E({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 q(){let e=en(tn),t=en(rn);if(e==null||t==null)return null;let r=ws.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
|
+
`),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(`
|
|
84
|
+
mutation StartRunCLI($runId: String!, $platform: String!, $agentProfileId: String) {
|
|
85
|
+
startRun(runId: $runId, platform: $platform, agentProfileId: $agentProfileId) {
|
|
86
|
+
id
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`),_i=gr(`
|
|
90
|
+
mutation SubmitRunStepsCLI($runResultId: String!, $steps: [StepInput!]!) {
|
|
91
|
+
submitRunSteps(runResultId: $runResultId, steps: $steps)
|
|
92
|
+
}
|
|
93
|
+
`),Hi=gr(`
|
|
94
|
+
mutation CompleteRunCLI(
|
|
95
|
+
$runResultId: String!
|
|
96
|
+
$status: String!
|
|
97
|
+
$duration: Int!
|
|
98
|
+
$passCount: Int!
|
|
99
|
+
$failCount: Int!
|
|
100
|
+
$warnCount: Int!
|
|
101
|
+
$summary: String
|
|
102
|
+
) {
|
|
103
|
+
completeRun(
|
|
104
|
+
runResultId: $runResultId
|
|
105
|
+
status: $status
|
|
106
|
+
duration: $duration
|
|
107
|
+
passCount: $passCount
|
|
108
|
+
failCount: $failCount
|
|
109
|
+
warnCount: $warnCount
|
|
110
|
+
summary: $summary
|
|
111
|
+
) {
|
|
112
|
+
id
|
|
113
|
+
status
|
|
114
|
+
}
|
|
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=Ki({externalBrowser:n,headed:a});let{project:g,workflow:y}=await F({label:"Run context resolved",fn:()=>tl({config:o,workflowId:i})});l=y.name;let P=ol(y.spec);d.info("Executing workflow: %s",y.name),c=await F({label:"Streaming run started",fn:()=>$e({agentProfileId:t,config:o,runId:s})}),await Xi({agentProfileDescription:e,agentProfileId:t,baseUrl:r,browserPromise:p,config:o,headed:a,ownsBrowser:f,project:g,runId:s,specData:P,streaming:c,workflow:y})}catch(g){throw await Qi({browserPromise:p,error:g,ownsBrowser:f,runId:s,streaming:c,workflowName:l}),g}}function Ki({externalBrowser:e,headed:t}){return e!=null?Promise.resolve(e):F({label:"Browser launched",fn:()=>H({headed:t})})}async function Qi({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 _o({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 Xi({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([F({label:"Preconditions resolved",fn:()=>se({baseUrl:r,project:i,workflowSlug:f.slug})}),n]);if(t!=null){s&&await y.close(),await Zi({agentProfileDescription:e,agentProfileId:t,baseUrl:r,config:o,headed:a,preconditionResult:g,runId:l,specData:c,streaming:p,workflow:f});return}await el({baseUrl:r,browser:y,preconditionResult:g,runId:l,specData:c,streaming:p})}async function Zi({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 rl({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 el({baseUrl:e,browser:t,preconditionResult:r,runId:n,specData:o,streaming:a}){let s=await F({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 tl({config:e,workflowId:t}){let r=await k({config:e,document:Ji,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 rl({config:e,profileId:t}){let r=await k({config:e,document:Yi,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 ol(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,Ji,Yi,mn=m(()=>{"use strict";Ie();Et();Ft();ze();Te();_e();nr();z();rt();mr();yr();wr=it(`
|
|
117
|
+
fragment WorkflowRun on Workflow {
|
|
118
|
+
id
|
|
119
|
+
slug
|
|
120
|
+
name
|
|
121
|
+
spec
|
|
122
|
+
}
|
|
123
|
+
`),pn=it(`
|
|
124
|
+
fragment ProjectRun on Project {
|
|
125
|
+
id
|
|
126
|
+
baseUrl
|
|
127
|
+
preconditionApiPath
|
|
128
|
+
stateGraph {
|
|
129
|
+
preconditions
|
|
130
|
+
edges {
|
|
131
|
+
sourceState {
|
|
132
|
+
stableId
|
|
133
|
+
preconditions
|
|
134
|
+
}
|
|
135
|
+
workflowSlug
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
workflows {
|
|
139
|
+
...WorkflowRun
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
`,[wr]),Ji=it(`
|
|
143
|
+
query ProjectRun($projectId: String!) {
|
|
144
|
+
project(id: $projectId) {
|
|
145
|
+
...ProjectRun
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
`,[pn]),Yi=it(`
|
|
149
|
+
query AgentProfileRun($id: String!) {
|
|
150
|
+
agentProfile(id: $id) {
|
|
151
|
+
id
|
|
152
|
+
name
|
|
153
|
+
description
|
|
154
|
+
output
|
|
155
|
+
successCriteria
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
`)});var U=m(()=>{"use strict";Rt();At();Et();Ft();Je();ze();Zo();Te();zt();on();Qt();mn();nr();or();we();z();rt();mr();be();yr();K()});import nl from"fs";import al from"path";import{z as V}from"zod";function gn(e){return al.join(e,".ripplo","graph.json")}function yn(e){let t=nl.readFileSync(e,"utf8"),r=JSON.parse(t);return sl.parse(r)}function hn(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}var sl,wn=m(()=>{"use strict";sl=V.object({edges:V.array(V.object({from:V.string(),to:V.string(),workflow:V.string()})),preconditions:V.record(V.string(),V.unknown()).optional(),resetPrecondition:V.string().optional(),states:V.record(V.string(),V.object({preconditions:V.array(V.string()),route:V.string()})),version:V.literal(3)})});import il from"fs";import ll from"path";import{z as pe}from"zod";function Ve(e){return ll.join(e,".ripplo","workflows")}function br(e){let t=il.readFileSync(e,"utf8"),r=JSON.parse(t);return cl.parse(r)}var cl,Sn=m(()=>{"use strict";Ie();cl=pe.object({additionalChecks:pe.array(pe.string()).default([]),description:pe.string(),expectedOutcome:pe.string(),name:pe.string(),spec:je})});var xr={};ea(xr,{deleteWorkflowFile:()=>ml,duplicateWorkflowFile:()=>gl,startFileWatcher:()=>Rr,syncAll:()=>Pr});import dl from"crypto";import te from"fs";import Ue from"path";import{watch as ul}from"chokidar";import{graphql as pl}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=ul(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 dl.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:fl,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 ml({cwd:e,slug:t}){let r=Ue.join(Ve(e),`${t}.json`);return te.existsSync(r)?(te.unlinkSync(r),!0):!1}function gl({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 fl,lt=m(()=>{"use strict";wn();Sn();U();fl=pl(`
|
|
159
|
+
mutation SyncDevSession(
|
|
160
|
+
$projectId: String!
|
|
161
|
+
$graphSpec: String!
|
|
162
|
+
$workflows: [SyncDevWorkflowInput!]!
|
|
163
|
+
) {
|
|
164
|
+
syncDevSession(projectId: $projectId, graphSpec: $graphSpec, workflows: $workflows) {
|
|
165
|
+
id
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
`)});U();import{config as Kn}from"dotenv";import ht from"path";import{fileURLToPath as Fc}from"url";U();lt();import{availableParallelism as yl}from"os";import{createClient as hl}from"graphql-sse";import{graphql as De}from"gql.tada";import{print as vr}from"graphql";import{input as wl}from"@inquirer/prompts";import Sl from"p-limit";var bl=De(`
|
|
169
|
+
mutation EndDevSession($projectId: String!) {
|
|
170
|
+
endDevSession(projectId: $projectId) {
|
|
171
|
+
id
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
`),Pl=De(`
|
|
175
|
+
subscription RunRequestedDev {
|
|
176
|
+
runRequested {
|
|
177
|
+
agentProfileDescription
|
|
178
|
+
agentProfileId
|
|
179
|
+
executor
|
|
180
|
+
runId
|
|
181
|
+
workflowId
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
`),Rl=De(`
|
|
185
|
+
query PendingDevRuns($devSessionId: String!) {
|
|
186
|
+
pendingDevRuns(devSessionId: $devSessionId) {
|
|
187
|
+
id
|
|
188
|
+
workflow {
|
|
189
|
+
id
|
|
190
|
+
}
|
|
191
|
+
agentProfile {
|
|
192
|
+
id
|
|
193
|
+
description
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
`),xl=De(`
|
|
198
|
+
subscription DevWorkflowDeleteRequested($projectId: String!) {
|
|
199
|
+
devWorkflowDeleteRequested(projectId: $projectId) {
|
|
200
|
+
projectId
|
|
201
|
+
slug
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
`),vl=De(`
|
|
205
|
+
subscription DevWorkflowDuplicateRequested($projectId: String!) {
|
|
206
|
+
devWorkflowDuplicateRequested(projectId: $projectId) {
|
|
207
|
+
projectId
|
|
208
|
+
sourceSlug
|
|
209
|
+
newSlug
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
`);async function ct({concurrency:e,headed:t}){let r=q();if(r==null)return N("Not logged in. Run: ripplo login");let n=process.cwd();d.info("Starting dev session...");let o=await Dl(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=hl({headers:{Authorization:`Bearer ${l.token}`},on:{connected:R=>{R&&d.info("Reconnected.")},connecting:R=>{R&&d.info("Reconnecting to server...")}},retryAttempts:1/0,url:`${l.ripploServerUrl}/graphql`,retry:async R=>{let I=Math.min(1e3*2**R,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:bl,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",R=>{d.error("Unexpected error: %s",R.message),p().then(()=>process.exit(1))}),process.on("unhandledRejection",R=>{let I=R instanceof Error?R.message:String(R);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??yl();d.info("Max concurrent runs: %d",g);let y=Sl(g),P=c.iterate({query:vr(Pl)}),S=c.iterate({query:vr(xl),variables:{projectId:r.projectId}}),B=c.iterate({query:vr(vl),variables:{projectId:r.projectId}});await Promise.all([kl({activeRunIds:f,baseUrl:o,config:r,headed:t,limiter:y,subscription:P}),Cl({activeRunIds:f,baseUrl:o,config:r,devSessionId:a,headed:t,limiter:y}),Al({cwd:n,subscription:S}),$l({cwd:n,subscription:B})])}async function kl({activeRunIds:e,baseUrl:t,config:r,headed:n,limiter:o,subscription:a}){for await(let s of a){let i=Ul(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 Tl=5e3;async function Cl({activeRunIds:e,baseUrl:t,config:r,devSessionId:n,headed:o,limiter:a}){for(;;)await new Promise(s=>{setTimeout(s,Tl)}),await jl({activeRunIds:e,baseUrl:t,config:r,devSessionId:n,headed:o,limiter:a})}async function jl({activeRunIds:e,baseUrl:t,config:r,devSessionId:n,headed:o,limiter:a}){try{let s=await k({config:r,document:Rl,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=q()??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){Il({error:i,runId:a})}}function Il({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 Nl(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 Al({cwd:e,subscription:t}){let{deleteWorkflowFile:r}=await Promise.resolve().then(()=>(lt(),xr));for await(let n of t){let o=El(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 El(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 $l({cwd:e,subscription:t}){let{duplicateWorkflowFile:r}=await Promise.resolve().then(()=>(lt(),xr));for await(let n of t){let o=Vl(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 Vl(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 Ul(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 Nl(r)}async function Dl(e){if(e.baseUrl!=null)return e.baseUrl;let t=await wl({default:"http://localhost:3000",message:"Base URL (local dev server):"});return J({...e,baseUrl:t}),t}Ie();U();import{readFileSync as kn}from"fs";import{graphql as Fe,readFragment as kr}from"gql.tada";async function Tn(e){let t=await Bl(e);d.info("Starting agent test against %s",t.baseUrl);let r=await Wl({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
|
+
=== Agent Summary ===
|
|
214
|
+
%s`,i.findings),Ol({result:i})}finally{await o.close()}}var Fl=Fe(`
|
|
215
|
+
mutation CreateRunAgentTest($workflowId: String!, $platforms: [String!]!, $concurrency: Int!) {
|
|
216
|
+
createRun(workflowId: $workflowId, platforms: $platforms, concurrency: $concurrency) {
|
|
217
|
+
id
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
`);async function Wl({config:e,workflowId:t}){let r=await k({config:e,document:Fl,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});return r.createRun==null?N("Failed to create run"):r.createRun.id}function Ol({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 ql=Fe(`
|
|
222
|
+
query AgentProfileForCLI($id: String!) {
|
|
223
|
+
agentProfile(id: $id) {
|
|
224
|
+
id
|
|
225
|
+
name
|
|
226
|
+
description
|
|
227
|
+
output
|
|
228
|
+
successCriteria
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
`),Tr=Fe(`
|
|
232
|
+
fragment WorkflowAgentTest on Workflow {
|
|
233
|
+
id
|
|
234
|
+
name
|
|
235
|
+
slug
|
|
236
|
+
description
|
|
237
|
+
expectedOutcome
|
|
238
|
+
spec
|
|
239
|
+
}
|
|
240
|
+
`),Cn=Fe(`
|
|
241
|
+
fragment ProjectAgentTest on Project {
|
|
242
|
+
id
|
|
243
|
+
baseUrl
|
|
244
|
+
preconditionApiPath
|
|
245
|
+
stateGraph {
|
|
246
|
+
preconditions
|
|
247
|
+
edges {
|
|
248
|
+
sourceState {
|
|
249
|
+
stableId
|
|
250
|
+
preconditions
|
|
251
|
+
}
|
|
252
|
+
workflowSlug
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
workflows {
|
|
256
|
+
...WorkflowAgentTest
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
`,[Tr]),Ll=Fe(`
|
|
260
|
+
query ProjectAgentTest($projectId: String!) {
|
|
261
|
+
project(id: $projectId) {
|
|
262
|
+
...ProjectAgentTest
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
`,[Cn]);async function Bl(e){let t=zl(),r=await Ml({config:t,params:e}),n=await _l({config:t,params:e});if(n==null)return N("No workflow. Provide --workflow <id>");let o=e.url??n.baseUrl,a=n.spec??(e.specPath==null?void 0:Yl(e.specPath));return r==null?N("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 zl(){let e=q();return e??N("Not logged in. Run: ripplo login")}async function Ml({config:e,params:t}){if(t.agentProfileId!=null&&e!=null)return Gl({config:e,profileId:t.agentProfileId});if(t.promptArg!=null)return Jl(t.promptArg)}async function Gl({config:e,profileId:t}){let r=await k({config:e,document:ql,variables:{id:t}});if(r.agentProfile==null)return N(`Agent profile not found: ${t}`);let n=r.agentProfile,o=n.description;return o==null||o.length===0?N(`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 _l({config:e,params:t}){if(t.workflowId==null||e==null)return;let r=await Hl(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 N(`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 Hl(e){let t=await k({config:e,document:Ll,variables:{projectId:e.projectId}});return t.project==null?N("Project not found. Check your config."):t.project}function Jl(e){try{return kn(e,"utf8")}catch{return e}}function Yl(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 N(`Invalid spec: ${r}`)}return t.data}st();U();import We from"fs";import fe from"path";function Nn({graphPath:e,outputPath:t}){let r=Ql(e),n=Xl(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=Zl(o),s=Kl({graphPath:r,outputPath:t}),i=fe.dirname(s);We.existsSync(i)||We.mkdirSync(i,{recursive:!0}),We.writeFileSync(s,a),d.info("Generated %s with %d precondition(s)",s,o.length)}function Kl({graphPath:e,outputPath:t}){return t!=null?fe.resolve(t):fe.join(fe.dirname(e),"..","generated","precondition-api.ts")}function Ql(e){if(e!=null)return fe.resolve(e);let t=fe.join(process.cwd(),".ripplo","graph.json");if(!We.existsSync(t))throw new Error("No .ripplo/graph.json found.");return t}function Xl(e){let t=We.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 Zl(e){let t=e.map(n=>` "${n.name}"`).join(`,
|
|
266
|
+
`),r=ec(e);return`// Generated by: ripplo generate-types
|
|
267
|
+
// Do not edit manually \u2014 regenerate when graph preconditions change.
|
|
268
|
+
|
|
269
|
+
import { z } from "zod";
|
|
270
|
+
|
|
271
|
+
export const preconditionNames = [
|
|
272
|
+
${t},
|
|
273
|
+
] as const;
|
|
274
|
+
|
|
275
|
+
export type PreconditionName = (typeof preconditionNames)[number];
|
|
276
|
+
|
|
277
|
+
// Strongly typed data returned by each precondition's execute response
|
|
278
|
+
${r}
|
|
279
|
+
|
|
280
|
+
// POST {preconditionApiPath}/check
|
|
281
|
+
export const PreconditionCheckRequestSchema = z.object({
|
|
282
|
+
precondition: z.enum(preconditionNames),
|
|
283
|
+
});
|
|
284
|
+
export type PreconditionCheckRequest = z.infer<typeof PreconditionCheckRequestSchema>;
|
|
285
|
+
|
|
286
|
+
export const PreconditionCheckResponseSchema = z.object({
|
|
287
|
+
satisfied: z.boolean(),
|
|
288
|
+
});
|
|
289
|
+
export type PreconditionCheckResponse = z.infer<typeof PreconditionCheckResponseSchema>;
|
|
290
|
+
|
|
291
|
+
// PUT {preconditionApiPath}/execute
|
|
292
|
+
export const PreconditionExecuteRequestSchema = z.object({
|
|
293
|
+
precondition: z.enum(preconditionNames),
|
|
294
|
+
});
|
|
295
|
+
export type PreconditionExecuteRequest = z.infer<typeof PreconditionExecuteRequestSchema>;
|
|
296
|
+
|
|
297
|
+
export const PreconditionExecuteResponseSchema = z.object({
|
|
298
|
+
data: z.record(z.string(), z.string()).optional(),
|
|
299
|
+
success: z.boolean(),
|
|
300
|
+
error: z.string().optional(),
|
|
301
|
+
});
|
|
302
|
+
export type PreconditionExecuteResponse = z.infer<typeof PreconditionExecuteResponseSchema>;
|
|
303
|
+
|
|
304
|
+
// PUT {preconditionApiPath}/teardown
|
|
305
|
+
export const PreconditionTeardownRequestSchema = z.object({
|
|
306
|
+
preconditions: z.array(z.enum(preconditionNames)),
|
|
307
|
+
});
|
|
308
|
+
export type PreconditionTeardownRequest = z.infer<typeof PreconditionTeardownRequestSchema>;
|
|
309
|
+
|
|
310
|
+
export const PreconditionTeardownResponseSchema = z.object({
|
|
311
|
+
success: z.boolean(),
|
|
312
|
+
error: z.string().optional(),
|
|
313
|
+
});
|
|
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 ec(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
|
+
`);return`export interface ${a}Data {
|
|
317
|
+
${s}
|
|
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 {
|
|
319
|
+
${n.join(`
|
|
320
|
+
`)}
|
|
321
|
+
}`].join(`
|
|
322
|
+
|
|
323
|
+
`)}U();import Nr from"fs";import Ar from"path";U();import oc from"crypto";import nc from"http";import{exec as ac}from"child_process";import{z as An}from"zod";var tc="https://ripplo.ai",Cr="https://ripplo-dev.up.railway.app",rc=An.object({RIPPLO_SERVER_URL:An.string().min(1).default(tc)}),En;function $n(){return En??=rc.parse(process.env),En}var sc=`<!DOCTYPE html>
|
|
324
|
+
<html lang="en">
|
|
325
|
+
<head>
|
|
326
|
+
<meta charset="utf-8" />
|
|
327
|
+
<title>CLI Authorized</title>
|
|
328
|
+
<style>
|
|
329
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
330
|
+
body {
|
|
331
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
332
|
+
background: #0a0a0b;
|
|
333
|
+
color: #fafafa;
|
|
334
|
+
display: flex;
|
|
335
|
+
align-items: center;
|
|
336
|
+
justify-content: center;
|
|
337
|
+
min-height: 100vh;
|
|
338
|
+
}
|
|
339
|
+
.card {
|
|
340
|
+
text-align: center;
|
|
341
|
+
padding: 3rem 2.5rem;
|
|
342
|
+
border: 1px solid #27272a;
|
|
343
|
+
border-radius: 1rem;
|
|
344
|
+
background: #18181b;
|
|
345
|
+
max-width: 24rem;
|
|
346
|
+
}
|
|
347
|
+
.icon { font-size: 2.5rem; margin-bottom: 1rem; }
|
|
348
|
+
h1 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
|
|
349
|
+
p { font-size: 0.875rem; color: #a1a1aa; }
|
|
350
|
+
</style>
|
|
351
|
+
</head>
|
|
352
|
+
<body>
|
|
353
|
+
<div class="card">
|
|
354
|
+
<div class="icon">\u2705</div>
|
|
355
|
+
<h1>CLI Authorized</h1>
|
|
356
|
+
<p>You can close this tab and return to your terminal.</p>
|
|
357
|
+
</div>
|
|
358
|
+
<script>setTimeout(function(){window.close()},3000)</script>
|
|
359
|
+
</body>
|
|
360
|
+
</html>`;async function dt({url:e}){let t=e??$n().RIPPLO_SERVER_URL,r=oc.randomBytes(16).toString("hex"),{port:n,tokenPromise:o}=await ic(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),cc(a);let s=await o;d.info("Authorized successfully.");let i={cloudBaseUrl:"",projectId:"",ripploServerUrl:t,token:s};return J(i),i}function ic(e){return new Promise(t=>{let r,n=new Promise(a=>{r=a}),o=nc.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(sc),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 lc(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function cc(e){let t=lc();ac(`${t} "${e}"`,()=>{})}U();import pt from"fs";import ie from"path";import{fileURLToPath as Vn}from"url";import{z as ut}from"zod";var dc=ut.looseObject({mcpServers:ut.record(ut.string(),ut.unknown())});function ft(){let e=ie.join(process.cwd(),".mcp.json"),t=uc()?{args:[pc()],command:"node"}:{args:["-y","--package","ripplo@latest","ripplo-mcp"],command:"npx"},r=fc(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 uc(){let e=Vn(import.meta.url),t=ie.dirname(ie.dirname(e));return pt.existsSync(ie.join(t,"tsup.config.ts"))}function pc(){let e=Vn(import.meta.url),t=ie.dirname(ie.dirname(e));return ie.join(t,"mcp","index.js")}function fc(e){if(!pt.existsSync(e))return{mcpServers:{}};let t=JSON.parse(pt.readFileSync(e,"utf8")),r=dc.safeParse(t);return r.success?r.data:{mcpServers:{}}}U();import mc from"path";import{input as jr,select as gc}from"@inquirer/prompts";import{graphql as Dn}from"gql.tada";var yc=Dn(`
|
|
361
|
+
query ProjectsCLI {
|
|
362
|
+
projects {
|
|
363
|
+
id
|
|
364
|
+
name
|
|
365
|
+
baseUrl
|
|
366
|
+
cloudBaseUrl
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
`);async function mt(e){let t=await k({config:e,document:yc,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__",hc=Dn(`
|
|
370
|
+
mutation CreateProjectShared(
|
|
371
|
+
$name: String!
|
|
372
|
+
$baseUrl: String!
|
|
373
|
+
$cloudBaseUrl: String!
|
|
374
|
+
$repoUrl: String!
|
|
375
|
+
$provider: String!
|
|
376
|
+
) {
|
|
377
|
+
createProject(
|
|
378
|
+
name: $name
|
|
379
|
+
baseUrl: $baseUrl
|
|
380
|
+
cloudBaseUrl: $cloudBaseUrl
|
|
381
|
+
repoUrl: $repoUrl
|
|
382
|
+
provider: $provider
|
|
383
|
+
) {
|
|
384
|
+
id
|
|
385
|
+
name
|
|
386
|
+
}
|
|
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 gc({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=mc.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:hc,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 wc({url:e});d.info("\u2713 Logged in");let r=await Sc({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),Pc(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 wc({url:e}){let t=q();return t??(d.info("Not logged in. Let's authenticate first."),dt({url:e}))}async function Sc({config:e}){let t=await mt(e);return t.length===0?Ir({config:e}):gt({config:e,projects:t})}var bc={edges:[],preconditions:{},states:{},version:3};function Pc(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(bc,null,2)+`
|
|
389
|
+
`)}U();async function Wn({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)}U();import{search as Ic}from"@inquirer/prompts";import _ from"chalk";import Nc from"ora";Ie();U();import{graphql as yt,readFragment as me}from"gql.tada";U();import{graphql as Rc}from"gql.tada";var xc=Rc(`
|
|
390
|
+
mutation SubmitRunResultsCLI(
|
|
391
|
+
$runId: String!
|
|
392
|
+
$platform: String!
|
|
393
|
+
$agentProfileId: String
|
|
394
|
+
$status: String!
|
|
395
|
+
$duration: Int!
|
|
396
|
+
$passCount: Int!
|
|
397
|
+
$failCount: Int!
|
|
398
|
+
$warnCount: Int!
|
|
399
|
+
$steps: JSON!
|
|
400
|
+
) {
|
|
401
|
+
submitRunResults(
|
|
402
|
+
runId: $runId
|
|
403
|
+
platform: $platform
|
|
404
|
+
agentProfileId: $agentProfileId
|
|
405
|
+
status: $status
|
|
406
|
+
duration: $duration
|
|
407
|
+
passCount: $passCount
|
|
408
|
+
failCount: $failCount
|
|
409
|
+
warnCount: $warnCount
|
|
410
|
+
steps: $steps
|
|
411
|
+
) {
|
|
412
|
+
id
|
|
413
|
+
status
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
`);async function On({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:xc,variables:{agentProfileId:null,duration:a,failCount:o,passCount:n,platform:"chromium",runId:t,status:s,steps:r,warnCount:0}})}var ge=yt(`
|
|
417
|
+
fragment WorkflowCore on Workflow {
|
|
418
|
+
id
|
|
419
|
+
name
|
|
420
|
+
slug
|
|
421
|
+
source
|
|
422
|
+
spec
|
|
423
|
+
}
|
|
424
|
+
`),qn=yt(`
|
|
425
|
+
fragment ProjectCore on Project {
|
|
426
|
+
id
|
|
427
|
+
name
|
|
428
|
+
baseUrl
|
|
429
|
+
preconditionApiPath
|
|
430
|
+
stateGraph {
|
|
431
|
+
preconditions
|
|
432
|
+
states {
|
|
433
|
+
stableId
|
|
434
|
+
preconditions
|
|
435
|
+
}
|
|
436
|
+
edges {
|
|
437
|
+
sourceState {
|
|
438
|
+
stableId
|
|
439
|
+
preconditions
|
|
440
|
+
}
|
|
441
|
+
workflowSlug
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
workflows {
|
|
445
|
+
...WorkflowCore
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
`,[ge]),vc=yt(`
|
|
449
|
+
query ProjectCore($projectId: String!) {
|
|
450
|
+
project(id: $projectId) {
|
|
451
|
+
...ProjectCore
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
`,[qn]),kc=yt(`
|
|
455
|
+
mutation CreateRunCore($workflowId: String!, $platforms: [String!]!, $concurrency: Int!) {
|
|
456
|
+
createRun(workflowId: $workflowId, platforms: $platforms, concurrency: $concurrency) {
|
|
457
|
+
id
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
`);async function Ln({config:e,headed:t,onStep:r,workflowId:n,workflowName:o}){await Ce({maxRuns:100});let a=await zn(e),s=a.workflows??[],i=Tc({workflowId:n,workflowName:o,workflows:s}),l=me(ge,i),c=Cc(l.spec),[p,f,g]=await Promise.all([F({label:"Preconditions resolved",fn:()=>se({baseUrl:a.baseUrl,project:a,workflowSlug:l.slug})}),F({label:"Browser launched",fn:()=>H({headed:t})}),jc({config:e,workflowId:l.id})]),y=await F({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 On({config:e,runId:g,steps:y}),p.apiUrl!=null&&await Ee({apiUrl:p.apiUrl,cookies:p.cookies,executed:p.executed});let P=y.filter(R=>R.status==="passed").length,S=y.filter(R=>R.status==="failed").length;return{duration:y.reduce((R,I)=>R+I.duration,0),failed:S,passed:P,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:vc,variables:{projectId:e.projectId}});if(t.project==null)throw new Error("No project found. Check your config.");return{...me(qn,t.project),...e.baseUrl==null?{}:{baseUrl:e.baseUrl},...e.preconditionApiPath==null?{}:{preconditionApiPath:e.preconditionApiPath}}}function Tc({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 Cc(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 jc({config:e,workflowId:t}){let r=await k({config:e,document:kc,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=q();if(r==null)return N("Not logged in. Run: ripplo login");let n=t??await Ac(r);if(n==null)return N("No workflow selected.");let o=Nc("Running workflow...").start(),a=await Ln({config:r,headed:e,onStep:void 0,workflowId:n,workflowName:void 0});o.stop(),Ec(a.steps)}async function Ac(e){let r=(await Bn({config:e})).map(n=>({name:`${n.name} (${n.source})`,value:n.id}));return Ic({message:"Select a workflow:",source:n=>n==null?r:r.filter(o=>o.name.toLowerCase().includes(n.toLowerCase()))})}function Ec(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=>{$c(o)}),d.info("%s, %s %s",_.green(`${String(t)} passed`),_.red(`${String(r)} failed`),_.dim(`${String(n)}ms`))}function $c(e){let t=e.status==="passed"?_.green("\u2713"):_.red("\u2717");d.info(" %s %s %s",t,e.title,_.dim(`${String(e.duration)}ms`)),e.assertions.forEach(r=>{let n=r.status==="passed"?_.green("\u2713"):_.red("\u2717"),o=r.detail==null?"":_.dim(` \u2014 ${r.detail}`);d.info(" %s %s%s",n,r.description,o)}),e.detail!=null&&d.info(" %s",_.dim(e.detail))}U();function Gn(){if(q()==null)return N("Not logged in. Run: ripplo login");ft(),d.info("Restart Claude Code to pick up the new MCP server."),process.exit(0)}U();import Vc from"chalk";import{z as _n}from"zod";var Hn="0.0.1",Jn="ripplo",Uc=_n.object({version:_n.string()});function Yn(){Dc().then(e=>{e==null||e===Hn||d.info(Vc.yellow(`Update available: ${Hn} \u2192 ${e}
|
|
461
|
+
Run \`npm install -g ${Jn}\` to update`))}).catch(()=>{})}async function Dc(){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 Uc.parse(n).version}catch{return}finally{clearTimeout(t)}}var Qn=ht.resolve(ht.dirname(Fc(import.meta.url)),"..");Kn({path:ht.join(Qn,".env.local"),quiet:!0});Kn({path:ht.join(Qn,".env"),quiet:!0});async function Wc(){Yn();let e=process.argv[2],t=e==null?void 0:Jc[e];if(t==null){Yc();return}await t()}function Oc(){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 qc(){if(process.argv.includes("--dev"))return Cr;let e=process.argv.indexOf("--url");if(e!==-1)return process.argv[e+1]}function Lc(){return Wn({url:qc()})}function Bc(){let e=process.argv.includes("--dev")?Cr:void 0;return Fn({url:e})}function zc(){let e=process.argv.includes("--headed"),t=process.argv.slice(3).find(r=>!r.startsWith("--"));return Mn({headed:e,workflowId:t})}function Mc(){let e=Oc();Nn(e)}function Gc(){let e=process.argv.slice(3),t=_c(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 _c(e){return{agentProfileId:Oe(e,"--agent-profile"),headed:e.includes("--headed"),promptArg:Oe(e,"--prompt"),specPath:Oe(e,"--spec"),url:Oe(e,"--url"),workflowId:Oe(e,"--workflow")}}function Oe(e,t){let r=e.indexOf(t);return r===-1?void 0:e[r+1]}function Hc(){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 Jc={"agent-test":Gc,dev:Hc,"generate-types":Mc,init:Bc,login:Lc,run:zc,"setup-mcp":Gn};function Yc(){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")}Wc().catch(e=>{d.error(e,"Unexpected error"),process.exit(1)});export{Wc as main};
|