ripplo 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp/index.js CHANGED
@@ -1,45 +1,56 @@
1
1
  #!/usr/bin/env node
2
- import{StdioServerTransport as Ya}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as Ma}from"@modelcontextprotocol/sdk/server/mcp.js";import{z as T}from"zod";import Zi from"@anthropic-ai/sdk";import{z as ue}from"zod";import{z as fr}from"zod";async function H({page:e,runStartTime:t,targets:r}){let n=e.viewportSize();if(n==null)throw new Error("Page has no viewport set");let[o,s]=await Promise.all([e.screenshot({type:"png"}),ur(r)]),l=o.toString("base64");return{annotations:s,screenshotBase64:l,snapshotTimestamp:Math.round(performance.now()-t),url:e.url(),viewportHeight:n.height,viewportWidth:n.width}}function dr(e){return"locator"in e}async function ur(e){return(await Promise.all(e.map(r=>pr(r)))).filter(r=>r!=null)}async function pr(e){if(!dr(e))return{height:0,label:e.label,type:e.type,width:0,x:0,y:0};let t=await e.locator.boundingBox({timeout:2e3}).catch(()=>null);if(t!=null)return{height:Math.round(t.height),label:e.label,type:e.type,width:Math.round(t.width),x:Math.round(t.x),y:Math.round(t.y)}}function u({description:e,execute:t,name:r,schema:n}){let o=fr.toJSONSchema(n,{target:"draft-2020-12"});return{anthropicTool:{description:e,input_schema:{...o,type:"object"},name:r},name:r,async execute(s,l){let c=n.parse(l);return{...await Promise.resolve(t(s,c)),kind:"action"}}}}async function h(e){let t=await H({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(s=>`${s.status}: ${s.description} \u2014 ${s.detail??""}`).join(`
3
- `):`${e.status}: ${e.title}`;return{specNode:e.specNode,stepResult:n,toolOutput:o}}var mr=ue.object({expected:ue.string().describe("The expected text content"),selector:ue.string().describe("CSS selector for the element to check")}),Oe=u({description:"Assert that an element's text content matches the expected value",name:"assert_text",schema:mr,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),s=o?"passed":"failed",l=[{description:`Text contains "${t.expected}"`,detail:`Actual: "${n??"(not found)"}"`,status:s}],c=`agent-step-${String(e.stepIndex)}`,i={expected:{type:"static",value:t.expected},id:c,locator:{by:"css",value:t.selector},operator:"contains",type:"assertText"};return h({assertions:l,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:i,status:s,stepIndex:e.stepIndex,title:`Assert text: ${t.selector}`})}});import{z as Fe}from"zod";var hr=Fe.object({selector:Fe.string().describe("CSS selector for the element to check")}),Ue=u({description:"Assert that an element matching the selector is visible on the page",name:"assert_visible",schema:hr,execute:async(e,t)=>{let r=performance.now(),n=await e.page.locator(t.selector).isVisible().catch(()=>!1),o=n?"passed":"failed",s=[{description:`Element ${t.selector} is visible`,detail:n?"Element is visible":"Element is not visible",status:o}],c={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertVisible"};return h({assertions:s,detail:n?"Element is visible":"Element is not visible",duration:performance.now()-r,nodeType:"assertVisible",page:e.page,runStartTime:e.runStartTime,specNode:c,status:o,stepIndex:e.stepIndex,title:`Assert visible: ${t.selector}`})}});import{z as De}from"zod";var gr=De.object({selector:De.string().describe("CSS selector for the checkbox to check")}),We=u({description:"Check a checkbox matching the CSS selector",name:"check",schema:gr,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 h({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 qe}from"zod";var yr=qe.object({selector:qe.string().describe("CSS selector for the element to click")}),Le=u({description:"Click an element matching the CSS selector",name:"click",schema:yr,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 h({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 X}from"zod";var _e=X.object({summary:X.string().describe("A summary of your findings and why you reached this verdict"),verdict:X.enum(["pass","fail"]).describe("Whether the test passed or failed")}),Be={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:{...X.toJSONSchema(_e,{target:"draft-2020-12"}),type:"object"},name:"complete_test"},name:"complete_test",execute(e,t){let r=_e.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 Me}from"zod";var wr=Me.object({selector:Me.string().describe("CSS selector for the element to extract text from")}),Ge=u({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:wr,execute:async(e,t)=>{let r=performance.now(),o=await e.page.locator(t.selector).textContent({timeout:5e3})??"",l={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"extractText",variable:"extractedText"};return h({assertions:[],detail:`Extracted text: "${o}"`,duration:performance.now()-r,nodeType:"extractText",page:e.page,runStartTime:e.runStartTime,specNode:l,status:"passed",stepIndex:e.stepIndex,title:`Extract text from ${t.selector}`})}});import{z as pe}from"zod";var br=pe.object({selector:pe.string().describe("CSS selector for the input element"),value:pe.string().describe("The text to type into the element")}),ze=u({description:"Clear and type text into an input element matching the CSS selector",name:"fill",schema:br,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 h({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 He}from"zod";var Sr=He.object({level:He.string().describe("Filter by log level: 'error', 'warning', 'log', 'info', 'debug', or 'all'").default("all")}),Je=u({description:"Get console log messages from the browser. Optionally filter by level (error, warning, log, info, debug, all).",name:"get_console_logs",schema:Sr,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=>Rr(o)).join(`
2
+ import{StdioServerTransport as li}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as ri}from"@modelcontextprotocol/sdk/server/mcp.js";import{z as T}from"zod";function I({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)}}import xd from"@anthropic-ai/sdk";import{z as Be}from"zod";import{z as Mr}from"zod";async function Q({page:e,runStartTime:t,targets:r}){let o=e.viewportSize();if(o==null)throw new Error("Page has no viewport set");let[n,s]=await Promise.all([e.screenshot({type:"png"}),Lr(r)]),l=n.toString("base64");return{annotations:s,screenshotBase64:l,snapshotTimestamp:Math.round(performance.now()-t),url:e.url(),viewportHeight:o.height,viewportWidth:o.width}}function qr(e){return"locator"in e}async function Lr(e){return(await Promise.all(e.map(r=>_r(r)))).filter(r=>r!=null)}async function _r(e){if(!qr(e))return{height:0,label:e.label,type:e.type,width:0,x:0,y:0};let t=await e.locator.boundingBox({timeout:2e3}).catch(()=>null);if(t!=null)return{height:Math.round(t.height),label:e.label,type:e.type,width:Math.round(t.width),x:Math.round(t.x),y:Math.round(t.y)}}function he({node:e,page:t}){if(e.type==="assertUrl"||e.type==="waitForUrl")return[{label:e.type,type:"urlBar"}];if(e.type==="drag"){let n=I({locator:e.source,page:t}),s=I({locator:e.target,page:t});return[{label:"drag-source",locator:n,type:"action"},{label:"drag-target",locator:s,type:"action"}]}if(!Br(e))return[];let r=e.type.startsWith("assert")?"assertion":"action",o=I({locator:e.locator,page:t});return[{label:e.type,locator:o,type:r}]}function Br(e){return"locator"in e&&e.locator!=null}function c({description:e,execute:t,name:r,schema:o}){let n=Mr.toJSONSchema(o,{target:"draft-2020-12"});return{anthropicTool:{description:e,input_schema:{...n,type:"object"},name:r},name:r,async execute(s,l){let d=o.parse(l);return{...await Promise.resolve(t(s,d)),kind:"action"}}}}async function p(e){let t=e.specNode==null?[]:he({node:e.specNode,page:e.page}),r=await Q({page:e.page,runStartTime:e.runStartTime,targets:t}),o=[...e.assertions],n={annotations:r.annotations,assertions:o,detail:e.detail,duration:Math.round(e.duration),nodeId:`agent-step-${String(e.stepIndex)}`,nodeType:e.nodeType,screenshotBase64:r.screenshotBase64,snapshotTimestamp:r.snapshotTimestamp,status:e.status,stepIndex:e.stepIndex,title:e.title,url:r.url,viewportHeight:r.viewportHeight,viewportWidth:r.viewportWidth},s=o.length>0?o.map(l=>`${l.status}: ${l.description} \u2014 ${l.detail??""}`).join(`
3
+ `):`${e.status}: ${e.title}`;return{specNode:e.specNode,stepResult:n,toolOutput:s}}var Gr=Be.object({selector:Be.string().describe("CSS selector for the checkbox or radio button")}),Me=c({description:"Assert that a checkbox or radio button is checked",name:"assert_checked",schema:Gr,execute:async(e,t)=>{let r=performance.now(),o=await e.page.locator(t.selector).isChecked().catch(()=>!1),n=o?"passed":"failed",s=[{description:`Element ${t.selector} is checked`,detail:o?void 0:"Element is not checked",status:n}],d={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertChecked"};return p({assertions:s,detail:o?"Element is checked":"Element is not checked",duration:performance.now()-r,nodeType:"assertChecked",page:e.page,runStartTime:e.runStartTime,specNode:d,status:n,stepIndex:e.stepIndex,title:`Assert checked: ${t.selector}`})}});import{z as M}from"zod";var zr=M.object({httpOnly:M.boolean().optional().describe("Assert httpOnly flag value"),name:M.string().describe("Cookie name to check"),sameSite:M.enum(["Strict","Lax","None"]).optional().describe("Assert sameSite value"),secure:M.boolean().optional().describe("Assert secure flag value"),value:M.string().optional().describe("Expected cookie value (substring match)")}),ze=c({description:"Assert properties of a browser cookie. Check existence, value, and security flags (httpOnly, secure, sameSite).",name:"assert_cookie",schema:zr,execute:async(e,t)=>{let r=performance.now(),n=(await e.page.context().cookies()).find(h=>h.name===t.name),s=n==null?[{description:`Cookie "${t.name}" exists`,detail:"Cookie not found",status:"failed"}]:[{description:`Cookie "${t.name}" exists`,detail:void 0,status:"passed"},...Hr({cookie:n,input:t})],l=s.some(h=>h.status==="failed"),d=l?"failed":"passed",u={id:`agent-step-${String(e.stepIndex)}`,name:{type:"static",value:t.name},type:"assertCookie"};return p({assertions:s,detail:l?s.filter(h=>h.status==="failed").map(h=>h.detail).join("; "):"Cookie OK",duration:performance.now()-r,nodeType:"assertCookie",page:e.page,runStartTime:e.runStartTime,specNode:u,status:d,stepIndex:e.stepIndex,title:`Assert cookie: ${t.name}`})}});function Hr({cookie:e,input:t}){return[Jr(t.value,e.value),Ge("httpOnly",t.httpOnly,e.httpOnly),Ge("secure",t.secure,e.secure),Kr("sameSite",t.sameSite,e.sameSite)].filter(r=>r!=null)}function Jr(e,t){if(e==null)return;let r=t.includes(e);return{description:`Cookie value contains "${e}"`,detail:r?void 0:`Got: "${t}"`,status:r?"passed":"failed"}}function Ge(e,t,r){if(t!=null)return{description:`Cookie ${e} is ${String(t)}`,detail:r===t?void 0:`Got: ${String(r)}`,status:r===t?"passed":"failed"}}function Kr(e,t,r){if(t!=null)return{description:`Cookie ${e} is ${t}`,detail:r===t?void 0:`Got: ${r}`,status:r===t?"passed":"failed"}}import{z as He}from"zod";var Yr=He.object({selector:He.string().describe("CSS selector for the element to check focus on")}),Je=c({description:"Assert that an element has keyboard focus. Use for accessibility tab-order testing.",name:"assert_focused",schema:Yr,execute:async(e,t)=>{let r=performance.now(),n=!!await e.page.locator(t.selector).evaluate("(el) => document.activeElement === el").catch(()=>!1),s=n?"passed":"failed",l=[{description:`Element ${t.selector} is focused`,detail:n?void 0:"Element does not have focus",status:s}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertFocused"};return p({assertions:l,detail:n?"Element is focused":"Element does not have focus",duration:performance.now()-r,nodeType:"assertFocused",page:e.page,runStartTime:e.runStartTime,specNode:i,status:s,stepIndex:e.stepIndex,title:`Assert focused: ${t.selector}`})}});import{z as G}from"zod";var Qr=G.object({bodyContains:G.string().optional().describe("Assert response body contains this string"),headerName:G.string().optional().describe("Response header name to check"),headerValue:G.string().optional().describe("Expected value the header should contain"),status:G.number().int().optional().describe("Expected HTTP status code"),urlPattern:G.string().describe("URL substring to match the response against")}),Ke=c({description:"Wait for a network response matching the URL pattern and assert on its status, body, or headers. Useful for verifying API calls and security headers (CSP, CORS).",name:"assert_response",schema:Qr,execute:async(e,t)=>{let r=performance.now(),o=await e.page.waitForResponse(u=>u.url().includes(t.urlPattern),{timeout:1e4}),n=[Xr(t.status,o.status()),await Zr(t.bodyContains,o),eo(t.headerName,t.headerValue,o.headers())].filter(u=>u!=null),s=n.length===0?[{description:`Response matching "${t.urlPattern}" received`,detail:void 0,status:"passed"}]:n,l=s.some(u=>u.status==="failed"),i={id:`agent-step-${String(e.stepIndex)}`,type:"assertResponse",urlPattern:{type:"static",value:t.urlPattern}};return p({assertions:s,detail:l?s.filter(u=>u.status==="failed").map(u=>u.detail).join("; "):"Response OK",duration:performance.now()-r,nodeType:"assertResponse",page:e.page,runStartTime:e.runStartTime,specNode:i,status:l?"failed":"passed",stepIndex:e.stepIndex,title:`Assert response: ${t.urlPattern}`})}});function Xr(e,t){if(e!=null)return{description:`Response status equals ${String(e)}`,detail:t===e?void 0:`Got: ${String(t)}`,status:t===e?"passed":"failed"}}async function Zr(e,t){if(e==null)return;let o=(await t.text()).includes(e);return{description:`Response body contains "${e}"`,detail:o?void 0:"Not found in response body",status:o?"passed":"failed"}}function eo(e,t,r){if(e==null||t==null)return;let o=r[e.toLowerCase()],n=o!=null&&o.includes(t);return{description:`Response header "${e}" contains "${t}"`,detail:n?void 0:`Got: "${o??"(missing)"}"`,status:n?"passed":"failed"}}import{z as ge}from"zod";var to=ge.object({expected:ge.string().describe("The expected text content"),selector:ge.string().describe("CSS selector for the element to check")}),Ye=c({description:"Assert that an element's text content matches the expected value",name:"assert_text",schema:to,execute:async(e,t)=>{let r=performance.now(),o=await e.page.locator(t.selector).textContent({timeout:5e3}).catch(()=>null),n=o!=null&&o.includes(t.expected),s=n?"passed":"failed",l=[{description:`Text contains "${t.expected}"`,detail:`Actual: "${o??"(not found)"}"`,status:s}],d=`agent-step-${String(e.stepIndex)}`,i={expected:{type:"static",value:t.expected},id:d,locator:{by:"css",value:t.selector},operator:"contains",type:"assertText"};return p({assertions:l,detail:n?`Text matches: "${t.expected}"`:`Expected "${t.expected}", got "${o??"(not found)"}"`,duration:performance.now()-r,nodeType:"assertText",page:e.page,runStartTime:e.runStartTime,specNode:i,status:s,stepIndex:e.stepIndex,title:`Assert text: ${t.selector}`})}});import{z as ye}from"zod";var ro=ye.object({expected:ye.string().describe("Expected page title or substring"),operator:ye.enum(["equals","contains","startsWith","endsWith"]).describe("Comparison operator").default("contains")}),Qe=c({description:"Assert that the page title matches an expected value",name:"assert_title",schema:ro,execute:async(e,t)=>{let r=performance.now(),o=await e.page.title(),n=oo({actual:o,expected:t.expected,operator:t.operator}),s=n?"passed":"failed",l=[{description:`Title ${t.operator} "${t.expected}"`,detail:n?void 0:`Got: "${o}"`,status:s}],d=`agent-step-${String(e.stepIndex)}`,i={expected:{type:"static",value:t.expected},id:d,operator:t.operator,type:"assertTitle"};return p({assertions:l,detail:n?"Title matches":`Expected title ${t.operator} "${t.expected}", got "${o}"`,duration:performance.now()-r,nodeType:"assertTitle",page:e.page,runStartTime:e.runStartTime,specNode:i,status:s,stepIndex:e.stepIndex,title:`Assert title ${t.operator} "${t.expected}"`})}});function oo({actual:e,expected:t,operator:r}){return r==="equals"?e===t:r==="contains"?e.includes(t):r==="startsWith"?e.startsWith(t):r==="endsWith"?e.endsWith(t):!1}import{z as Xe}from"zod";var no=Xe.object({selector:Xe.string().describe("CSS selector for the element to check")}),Ze=c({description:"Assert that an element matching the selector is visible on the page",name:"assert_visible",schema:no,execute:async(e,t)=>{let r=performance.now(),o=await e.page.locator(t.selector).isVisible().catch(()=>!1),n=o?"passed":"failed",s=[{description:`Element ${t.selector} is visible`,detail:o?"Element is visible":"Element is not visible",status:n}],d={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertVisible"};return p({assertions:s,detail:o?"Element is visible":"Element is not visible",duration:performance.now()-r,nodeType:"assertVisible",page:e.page,runStartTime:e.runStartTime,specNode:d,status:n,stepIndex:e.stepIndex,title:`Assert visible: ${t.selector}`})}});import{z as et}from"zod";var ao=et.object({selector:et.string().describe("CSS selector for the checkbox to check")}),tt=c({description:"Check a checkbox matching the CSS selector",name:"check",schema:ao,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).check({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"check"};return p({assertions:[],detail:`Checked ${t.selector}`,duration:performance.now()-r,nodeType:"check",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Check ${t.selector}`})}});import{z as rt}from"zod";var so=rt.object({selector:rt.string().describe("CSS selector for the input to clear")}),ot=c({description:"Clear the contents of an input field",name:"clear",schema:so,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).clear({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"clear"};return p({assertions:[],detail:`Cleared ${t.selector}`,duration:performance.now()-r,nodeType:"clear",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Clear ${t.selector}`})}});import{z as nt}from"zod";var io=nt.object({selector:nt.string().describe("CSS selector for the element to click")}),at=c({description:"Click an element matching the CSS selector",name:"click",schema:io,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).click({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"click"};return p({assertions:[],detail:`Clicked ${t.selector}`,duration:performance.now()-r,nodeType:"click",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Click ${t.selector}`})}});import{z as we}from"zod";var lo=we.object({action:we.enum(["read","write"]).describe("Whether to read from or write to the clipboard"),value:we.string().optional().describe("Text to write (required for write action)")}),st=c({description:"Read from or write to the browser clipboard. For write, provide the text value. For read, the clipboard contents are returned.",name:"clipboard",schema:lo,execute:async(e,t)=>{let r=performance.now(),o=`agent-step-${String(e.stepIndex)}`;if(t.action==="write"){if(t.value==null)throw new Error("clipboard write requires a value");let l=JSON.stringify(t.value);await e.page.evaluate(`navigator.clipboard.writeText(${l})`);let d={action:"write",id:o,type:"clipboard",value:{type:"static",value:t.value}};return p({assertions:[],detail:`Wrote to clipboard: "${t.value}"`,duration:performance.now()-r,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:d,status:"passed",stepIndex:e.stepIndex,title:"Clipboard write"})}let n=String(await e.page.evaluate("navigator.clipboard.readText()")),s={action:"read",id:o,type:"clipboard"};return p({assertions:[],detail:`Clipboard contents: "${n}"`,duration:performance.now()-r,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:s,status:"passed",stepIndex:e.stepIndex,title:"Clipboard read"})}});import{z as re}from"zod";var it=re.object({summary:re.string().describe("This is the ONLY output the user sees. If the agent profile specifies an Output format, follow those instructions exactly. Otherwise, provide a summary of your findings."),verdict:re.enum(["pass","fail"]).describe("Whether the test passed or failed. If the agent profile defines Success Criteria, base this verdict on whether those criteria were met.")}),lt={anthropicTool:{description:"Call this tool when you have finished your evaluation. If the agent profile defines an Output section, the summary MUST follow those output instructions exactly. Otherwise, summarize your findings.",input_schema:{...re.toJSONSchema(it,{target:"draft-2020-12"}),type:"object"},name:"complete_test"},name:"complete_test",execute(e,t){let r=it.parse(t),o={kind:"verdict",summary:r.summary,toolOutput:`Verdict: ${r.verdict}
4
+ ${r.summary}`,verdict:r.verdict};return Promise.resolve(o)}};import{z as ct}from"zod";var co=ct.object({selector:ct.string().describe("CSS selector for the element to extract text from")}),dt=c({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:co,execute:async(e,t)=>{let r=performance.now(),n=await e.page.locator(t.selector).textContent({timeout:5e3})??"",l={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"extractText",variable:"extractedText"};return p({assertions:[],detail:`Extracted text: "${n}"`,duration:performance.now()-r,nodeType:"extractText",page:e.page,runStartTime:e.runStartTime,specNode:l,status:"passed",stepIndex:e.stepIndex,title:`Extract text from ${t.selector}`})}});import{z as be}from"zod";var uo=be.object({selector:be.string().describe("CSS selector for the input element"),value:be.string().describe("The text to type into the element")}),ut=c({description:"Clear and type text into an input element matching the CSS selector",name:"fill",schema:uo,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).fill(t.value,{timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"fill",value:{type:"static",value:t.value}};return p({assertions:[],detail:`Filled ${t.selector} with "${t.value}"`,duration:performance.now()-r,nodeType:"fill",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Fill ${t.selector}`})}});import{z as pt}from"zod";var po=pt.object({level:pt.string().describe("Filter by log level: 'error', 'warning', 'log', 'info', 'debug', or 'all'").default("all")}),ft=c({description:"Get console log messages from the browser. Optionally filter by level (error, warning, log, info, debug, all).",name:"get_console_logs",schema:po,execute:(e,t)=>{let r=t.level==="all"?e.monitor.consoleEntries:e.monitor.consoleEntries.filter(n=>n.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 o=r.map(n=>fo(n)).join(`
5
5
  `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(r.length)} console messages:
6
- ${n}`}}});function Rr(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as Ke}from"zod";var fe=50,kr=Ke.object({urlFilter:Ke.string().describe("Optional regex to filter network entries by URL. Omit to see all.").default("")}),Ye=u({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:kr,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(c=>r.test(c.url));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No network requests recorded."};let o=n.slice(-fe),s=o.map(c=>{let i=c.statusCode==null?"pending":String(c.statusCode),d=c.responseHeaders["content-type"]??"";return`${c.method} ${i} ${c.url} [${d}]`}).join(`
7
- `),l=n.length>fe?`
8
- (showing last ${String(fe)} of ${String(n.length)})`:"";return{specNode:void 0,stepResult:void 0,toolOutput:`${String(o.length)} network requests:${l}
9
- ${s}`}}});import{z as Qe}from"zod";var xr=Qe.object({urlPattern:Qe.string().describe("Regex pattern to match the request URL")}),Xe=u({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:xr,execute:(e,t)=>{let r=new RegExp(t.urlPattern,"i"),n=e.monitor.networkEntries.filter(i=>r.test(i.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 s=o.statusCode==null?"pending":String(o.statusCode),l=Object.entries(o.responseHeaders).map(([i,d])=>` ${i}: ${d}`).join(`
10
- `),c=o.responseBody??"(no body captured)";return{specNode:void 0,stepResult:void 0,toolOutput:`${o.method} ${s} ${o.url}
6
+ ${o}`}}});function fo(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as mt}from"zod";var Se=50,mo=mt.object({urlFilter:mt.string().describe("Optional regex to filter network entries by URL. Omit to see all.").default("")}),ht=c({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:mo,execute:(e,t)=>{let r=t.urlFilter.length>0?new RegExp(t.urlFilter,"i"):void 0,o=r==null?e.monitor.networkEntries:e.monitor.networkEntries.filter(d=>r.test(d.url));if(o.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No network requests recorded."};let n=o.slice(-Se),s=n.map(d=>{let i=d.statusCode==null?"pending":String(d.statusCode),u=d.responseHeaders["content-type"]??"";return`${d.method} ${i} ${d.url} [${u}]`}).join(`
7
+ `),l=o.length>Se?`
8
+ (showing last ${String(Se)} of ${String(o.length)})`:"";return{specNode:void 0,stepResult:void 0,toolOutput:`${String(n.length)} network requests:${l}
9
+ ${s}`}}});import{z as gt}from"zod";var ho=gt.object({urlPattern:gt.string().describe("Regex pattern to match the request URL")}),yt=c({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:ho,execute:(e,t)=>{let r=new RegExp(t.urlPattern,"i"),o=e.monitor.networkEntries.filter(i=>r.test(i.url));if(o.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let n=o.at(-1);if(n==null)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let s=n.statusCode==null?"pending":String(n.statusCode),l=Object.entries(n.responseHeaders).map(([i,u])=>` ${i}: ${u}`).join(`
10
+ `),d=n.responseBody??"(no body captured)";return{specNode:void 0,stepResult:void 0,toolOutput:`${n.method} ${s} ${n.url}
11
11
 
12
12
  Response Headers:
13
13
  ${l}
14
14
 
15
15
  Body:
16
- ${c}`}}});import{z as vr}from"zod";var Pr=vr.object({}),Ze=u({description:"Get a text representation of the current page content for inspection",name:"get_page_content",schema:Pr,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 et}from"zod";var Tr=et.object({selector:et.string().describe("CSS selector for the element to hover over")}),tt=u({description:"Hover over an element matching the CSS selector",name:"hover",schema:Tr,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 h({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 rt}from"zod";var Nr=rt.object({url:rt.string().describe("The URL to navigate to")}),ot=u({description:"Navigate the browser to a URL",name:"navigate",schema:Nr,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 h({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 nt}from"zod";var Ar=nt.object({key:nt.string().describe("Key to press, e.g. 'Enter', 'Tab', 'Escape'")}),at=u({description:"Press a keyboard key",name:"press",schema:Ar,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 h({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 me}from"zod";var Cr=me.object({height:me.number().int().positive().describe("Viewport height in pixels"),width:me.number().int().positive().describe("Viewport width in pixels")}),st=u({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:Cr,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 h({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 $r}from"zod";var Ir=$r.object({}),it=u({description:"Take a screenshot of the current page",name:"screenshot",schema:Ir,execute:async(e,t)=>{let r=performance.now(),o={id:`agent-step-${String(e.stepIndex)}`,type:"screenshot"};return h({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 lt}from"zod";var Er=lt.object({pattern:lt.string().describe("Regex pattern to search console log messages")}),ct=u({description:"Search console log messages for a regex pattern. Returns matching entries.",name:"search_console",schema:Er,execute:(e,t)=>{let r=new RegExp(t.pattern,"i"),n=e.monitor.consoleEntries.filter(s=>r.test(s.text));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console messages matching: ${t.pattern}`};let o=n.map(s=>jr(s)).join(`
20
- `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(n.length)} matching console messages:
21
- ${o}`}}});function jr(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as dt}from"zod";var Vr=dt.object({pattern:dt.string().describe("Regex pattern to search across network request URLs and response bodies")}),ut=u({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:Vr,execute:(e,t)=>{let r=new RegExp(t.pattern,"i"),n=e.monitor.networkEntries.filter(s=>r.test(s.url)||s.responseBody!=null&&r.test(s.responseBody));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network entries matching: ${t.pattern}`};let o=n.map(s=>{let l=s.statusCode==null?"pending":String(s.statusCode),c=r.test(s.url)?" [URL match]":"",i=s.responseBody!=null&&r.test(s.responseBody)?" [body match]":"";return`${s.method} ${l} ${s.url}${c}${i}`}).join(`
22
- `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(n.length)} matching network entries:
23
- ${o}`}}});import{z as pt}from"zod";var Or=20,Fr=2,Ur=pt.object({pattern:pt.string().describe("Regex pattern to search for in the page HTML")}),ft=u({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:Ur,execute:async(e,t)=>{let n=(await e.page.content()).split(`
24
- `),o=Dr({contextLines:Fr,lines:n,maxResults:Or,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(`
16
+ ${d}`}}});import{z as wt}from"zod";var go=wt.object({selector:wt.string().optional().describe("CSS selector to scope the tree to a subtree (defaults to full page)")}),bt=c({description:"Get the accessibility tree (ARIA snapshot) of the current page or a specific element. Use this to verify ARIA roles, labels, states, and the semantic structure of the page.",name:"get_accessibility_tree",schema:go,execute:async(e,t)=>{let r=t.selector==null?e.page.locator(":root"):e.page.locator(t.selector);try{return{specNode:void 0,stepResult:void 0,toolOutput:await r.ariaSnapshot()}}catch{return{specNode:void 0,stepResult:void 0,toolOutput:"(unable to capture accessibility tree)"}}}});import{z as yo}from"zod";var wo=yo.object({}),St=c({description:"Get a text representation of the current page content for inspection",name:"get_page_content",schema:wo,execute:async(e,t)=>{let r=await e.page.locator("body").textContent({timeout:5e3}),o=e.page.url(),n=await e.page.title();return{specNode:void 0,stepResult:void 0,toolOutput:`URL: ${o}
17
+ Title: ${n}
18
+
19
+ ${r??""}`}}});import{z as bo}from"zod";var So=bo.object({}),kt=c({description:"Get uncaught JavaScript exceptions (page errors) that have occurred. These are runtime errors thrown in the browser that were not caught by error handlers.",name:"get_page_errors",schema:So,execute:(e,t)=>{if(e.monitor.pageErrors.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No page errors recorded."};let r=e.monitor.pageErrors.map((o,n)=>`--- Error ${String(n+1)} ---
20
+ ${o}`).join(`
21
+
22
+ `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(e.monitor.pageErrors.length)} page errors:
23
+
24
+ ${r}`}}});import{z as Rt}from"zod";var ko=Rt.object({type:Rt.enum(["all","cookies","localStorage","sessionStorage"]).describe("Which storage to retrieve").default("all")}),xt=c({description:"Get browser storage state: cookies (with httpOnly, secure, sameSite flags), localStorage, and/or sessionStorage. Useful for verifying authentication state, security cookie flags, and stored data.",name:"get_storage",schema:ko,execute:async(e,t)=>({specNode:void 0,stepResult:void 0,toolOutput:[...t.type==="all"||t.type==="cookies"?[await Ro(e.page)]:[],...t.type==="all"||t.type==="localStorage"?[await vt(e.page,"localStorage")]:[],...t.type==="all"||t.type==="sessionStorage"?[await vt(e.page,"sessionStorage")]:[]].join(`
25
+
26
+ `)})});async function Ro(e){let t=await e.context().cookies();if(t.length===0)return`## Cookies
27
+ (none)`;let r=t.map(o=>` ${o.name}=${o.value} (domain=${o.domain}, httpOnly=${String(o.httpOnly)}, secure=${String(o.secure)}, sameSite=${o.sameSite})`);return`## Cookies (${String(t.length)})
28
+ ${r.join(`
29
+ `)}`}async function vt(e,t){let r=await e.evaluate(`JSON.stringify(Object.fromEntries(Object.entries(${t})))`);return`## ${t}
30
+ ${String(r)}`}import{z as ke}from"zod";var vo=ke.object({action:ke.enum(["accept","dismiss"]).describe("Whether to accept or dismiss the dialog"),promptText:ke.string().optional().describe("Text to enter for prompt dialogs")}),Pt=c({description:"Set up a handler for the next browser dialog (alert, confirm, prompt). Call this BEFORE the action that triggers the dialog.",name:"handle_dialog",schema:vo,execute:(e,t)=>{let r=performance.now();e.page.once("dialog",async s=>{t.action==="accept"?await s.accept(t.promptText??void 0):await s.dismiss()});let o=`agent-step-${String(e.stepIndex)}`,n={action:t.action,id:o,type:"handleDialog"};return p({assertions:[],detail:`Dialog handler set: ${t.action}`,duration:performance.now()-r,nodeType:"handleDialog",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Handle dialog: ${t.action}`})}});import{z as Tt}from"zod";var xo=Tt.object({selector:Tt.string().describe("CSS selector for the element to hover over")}),Nt=c({description:"Hover over an element matching the CSS selector",name:"hover",schema:xo,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).hover({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"hover"};return p({assertions:[],detail:`Hovered over ${t.selector}`,duration:performance.now()-r,nodeType:"hover",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Hover ${t.selector}`})}});import{z as Re}from"zod";var Po=Re.object({permission:Re.string().describe("Permission name (e.g. geolocation, notifications, camera, clipboard-read)"),state:Re.enum(["granted","prompt"]).describe("Permission state to set")}),Ct=c({description:"Set a browser permission state (geolocation, notifications, camera, etc.)",name:"set_permission",schema:Po,execute:async(e,t)=>{let r=performance.now(),o=e.page.context();t.state==="granted"?await o.grantPermissions([t.permission]):await o.clearPermissions();let s={id:`agent-step-${String(e.stepIndex)}`,permission:t.permission,state:t.state,type:"setPermission"};return p({assertions:[],detail:`Set ${t.permission} to ${t.state}`,duration:performance.now()-r,nodeType:"setPermission",page:e.page,runStartTime:e.runStartTime,specNode:s,status:"passed",stepIndex:e.stepIndex,title:`Set permission: ${t.permission} \u2192 ${t.state}`})}});import{z as At}from"zod";var To=At.object({url:At.string().describe("The URL to navigate to")}),$t=c({description:"Navigate the browser to a URL",name:"navigate",schema:To,execute:async(e,t)=>{let r=performance.now();await e.page.goto(t.url,{waitUntil:"domcontentloaded"});let n={id:`agent-step-${String(e.stepIndex)}`,type:"goto",url:{type:"static",value:t.url}};return p({assertions:[],detail:`Navigated to ${t.url}`,duration:performance.now()-r,nodeType:"goto",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Navigate to ${t.url}`})}});import{z as It}from"zod";var No=It.object({key:It.string().describe("Key to press, e.g. 'Enter', 'Tab', 'Escape'")}),Et=c({description:"Press a keyboard key",name:"press",schema:No,execute:async(e,t)=>{let r=performance.now();await e.page.keyboard.press(t.key);let n={id:`agent-step-${String(e.stepIndex)}`,key:t.key,type:"press"};return p({assertions:[],detail:`Pressed ${t.key}`,duration:performance.now()-r,nodeType:"press",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Press ${t.key}`})}});import{z as ve}from"zod";var Co=ve.object({height:ve.number().int().positive().describe("Viewport height in pixels"),width:ve.number().int().positive().describe("Viewport width in pixels")}),jt=c({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:Co,execute:async(e,t)=>{let r=performance.now();await e.page.setViewportSize({height:t.height,width:t.width});let o=`agent-step-${String(e.stepIndex)}`,n={height:t.height,id:o,type:"setViewport",width:t.width};return p({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:n,status:"passed",stepIndex:e.stepIndex,title:`Resize viewport to ${String(t.width)}x${String(t.height)}`})}});import{z as Ot}from"zod";var Ao=Ot.object({selector:Ot.string().describe("CSS selector for the element to right-click")}),Vt=c({description:"Right-click an element to open the context menu",name:"right_click",schema:Ao,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).click({button:"right",timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"rightClick"};return p({assertions:[],detail:`Right-clicked ${t.selector}`,duration:performance.now()-r,nodeType:"rightClick",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Right-click ${t.selector}`})}});import{z as oe}from"zod";var $o=oe.object({selector:oe.string().optional().describe("CSS selector to scroll within (omit to scroll the page)"),x:oe.number().int().optional().describe("Horizontal scroll offset in pixels").default(0),y:oe.number().int().optional().describe("Vertical scroll offset in pixels").default(0)}),Ft=c({description:"Scroll the page or a specific element by pixel offset. Positive y scrolls down, negative scrolls up.",name:"scroll",schema:$o,execute:async(e,t)=>{let r=performance.now();if(t.selector==null)await e.page.mouse.wheel(t.x,t.y);else{let l=await e.page.locator(t.selector).elementHandle();if(l==null)throw new Error("Scroll target element not found");await l.evaluate(`(el) => el.scrollBy(${String(t.x)}, ${String(t.y)})`)}let n={id:`agent-step-${String(e.stepIndex)}`,type:"scroll",x:t.x,y:t.y},s=t.selector??"page";return p({assertions:[],detail:`Scrolled ${s} by (${String(t.x)}, ${String(t.y)})`,duration:performance.now()-r,nodeType:"scroll",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Scroll ${s}`})}});import{z as Io}from"zod";var Eo=Io.object({}),Ut=c({description:"Take a screenshot of the current page",name:"screenshot",schema:Eo,execute:async(e,t)=>{let r=performance.now(),n={id:`agent-step-${String(e.stepIndex)}`,type:"screenshot"};return p({assertions:[],detail:"Screenshot captured",duration:performance.now()-r,nodeType:"screenshot",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:"Screenshot"})}});import{z as Dt}from"zod";var jo=Dt.object({pattern:Dt.string().describe("Regex pattern to search console log messages")}),Wt=c({description:"Search console log messages for a regex pattern. Returns matching entries.",name:"search_console",schema:jo,execute:(e,t)=>{let r=new RegExp(t.pattern,"i"),o=e.monitor.consoleEntries.filter(s=>r.test(s.text));if(o.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console messages matching: ${t.pattern}`};let n=o.map(s=>Oo(s)).join(`
31
+ `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(o.length)} matching console messages:
32
+ ${n}`}}});function Oo(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as qt}from"zod";var Vo=qt.object({pattern:qt.string().describe("Regex pattern to search across network request URLs and response bodies")}),Lt=c({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:Vo,execute:(e,t)=>{let r=new RegExp(t.pattern,"i"),o=e.monitor.networkEntries.filter(s=>r.test(s.url)||s.responseBody!=null&&r.test(s.responseBody));if(o.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network entries matching: ${t.pattern}`};let n=o.map(s=>{let l=s.statusCode==null?"pending":String(s.statusCode),d=r.test(s.url)?" [URL match]":"",i=s.responseBody!=null&&r.test(s.responseBody)?" [body match]":"";return`${s.method} ${l} ${s.url}${d}${i}`}).join(`
33
+ `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(o.length)} matching network entries:
34
+ ${n}`}}});import{z as _t}from"zod";var Fo=20,Uo=2,Do=_t.object({pattern:_t.string().describe("Regex pattern to search for in the page HTML")}),Bt=c({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:Do,execute:async(e,t)=>{let o=(await e.page.content()).split(`
35
+ `),n=Wo({contextLines:Uo,lines:o,maxResults:Fo,pattern:t.pattern});return n.length===0?{specNode:void 0,stepResult:void 0,toolOutput:`No matches found for pattern: ${t.pattern}`}:{specNode:void 0,stepResult:void 0,toolOutput:n.join(`
25
36
  ---
26
- `)}}});function Dr({contextLines:e,lines:t,maxResults:r,pattern:n}){let o=new RegExp(n,"i"),s=[];return t.forEach((l,c)=>{if(s.length>=r||!o.test(l))return;let i=Math.max(0,c-e),d=Math.min(t.length-1,c+e),m=t.slice(i,d+1).map((I,Q)=>{let cr=i+Q+1;return`${i+Q===c?">":" "} ${String(cr)}: ${I}`}).join(`
27
- `);s.push(m)}),s}import{z as he}from"zod";var Wr=he.object({selector:he.string().describe("CSS selector for the select element"),value:he.string().describe("The option value to select")}),mt=u({description:"Select an option from a dropdown/select element",name:"select",schema:Wr,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 h({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 ht}from"zod";var qr=ht.object({selector:ht.string().describe("CSS selector for the checkbox to uncheck")}),gt=u({description:"Uncheck a checkbox matching the CSS selector",name:"uncheck",schema:qr,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 h({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 yt}from"zod";var Lr=yt.object({ms:yt.number().describe("Milliseconds to wait")}),wt=u({description:"Wait for a specified duration in milliseconds",name:"wait",schema:Lr,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 h({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 ge}from"zod";var _r=ge.object({selector:ge.string().describe("CSS selector for the element to wait for"),state:ge.enum(["visible","hidden","attached","detached"]).default("visible").describe("The state to wait for (default: visible)")}),bt=u({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:_r,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 h({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}`})}});var ye=[ot,Le,ze,at,We,gt,mt,tt,wt,bt,it,Ze,ft,Ue,Oe,Je,Ye,Xe,ct,ut,st,Ge,Be],zi=new Map(ye.map(e=>[e.name,e])),Br=ye.map(e=>e.anthropicTool),Mr=ye.map(e=>`- **${e.name}**: ${e.anthropicTool.description??""}`).join(`
28
- `);import Gr from"pino";var $=Gr({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}});import{execFileSync as il}from"child_process";import{createRequire as cl}from"module";import ul from"fs";import{chromium as fl}from"playwright";import{mkdir as yl,writeFile as wl}from"fs/promises";import Sl from"path";import{readdir as El,rm as jl,stat as Vl}from"fs/promises";import Xr from"path";import{graphql as Zr}from"gql.tada";import{print as Kr}from"graphql";async function V(e){let t=Kr(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(!Yr(o))throw new Error("Invalid GraphQL response");if(Qr(o))throw new Error(o.errors.map(s=>s.message).join(", "));if(o.data==null)throw new Error("No data returned from server");return o.data}function Yr(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function Qr(e){return Array.isArray(e.errors)&&e.errors.length>0}var Wl=Xr.join(process.cwd(),".ripplo","debug"),ql=360*60*1e3,Ll=Zr(`
37
+ `)}}});function Wo({contextLines:e,lines:t,maxResults:r,pattern:o}){let n=new RegExp(o,"i"),s=[];return t.forEach((l,d)=>{if(s.length>=r||!n.test(l))return;let i=Math.max(0,d-e),u=Math.min(t.length-1,d+e),h=t.slice(i,u+1).map((E,te)=>{let Wr=i+te+1;return`${i+te===d?">":" "} ${String(Wr)}: ${E}`}).join(`
38
+ `);s.push(h)}),s}import{z as xe}from"zod";var qo=xe.object({selector:xe.string().describe("CSS selector for the select element"),value:xe.string().describe("The option value to select")}),Mt=c({description:"Select an option from a dropdown/select element",name:"select",schema:qo,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).selectOption(t.value,{timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"select",value:{type:"static",value:t.value}};return p({assertions:[],detail:`Selected "${t.value}" in ${t.selector}`,duration:performance.now()-r,nodeType:"select",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Select ${t.value}`})}});import{z as Gt}from"zod";var Lo=Gt.object({selector:Gt.string().describe("CSS selector for the checkbox to uncheck")}),zt=c({description:"Uncheck a checkbox matching the CSS selector",name:"uncheck",schema:Lo,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).uncheck({timeout:5e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"uncheck"};return p({assertions:[],detail:`Unchecked ${t.selector}`,duration:performance.now()-r,nodeType:"uncheck",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Uncheck ${t.selector}`})}});import{z as Ht}from"zod";var _o=Ht.object({ms:Ht.number().describe("Milliseconds to wait")}),Jt=c({description:"Wait for a specified duration in milliseconds",name:"wait",schema:_o,execute:async(e,t)=>{let r=performance.now();await e.page.waitForTimeout(t.ms);let o=`agent-step-${String(e.stepIndex)}`,n={duration:t.ms,id:o,type:"wait"};return p({assertions:[],detail:`Waited ${String(t.ms)}ms`,duration:performance.now()-r,nodeType:"wait",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Wait ${String(t.ms)}ms`})}});import{z as Pe}from"zod";var Bo=Pe.object({selector:Pe.string().describe("CSS selector for the element to wait for"),state:Pe.enum(["visible","hidden","attached","detached"]).default("visible").describe("The state to wait for (default: visible)")}),Kt=c({description:"Wait for an element matching the CSS selector to reach the specified state. More reliable than a blind wait \u2014 use this to wait for elements to appear, disappear, or attach/detach from the DOM.",name:"wait_for",schema:Bo,execute:async(e,t)=>{let r=performance.now();await e.page.locator(t.selector).waitFor({state:t.state,timeout:15e3});let n={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},state:t.state,type:"waitFor"};return p({assertions:[],detail:`Waited for ${t.selector} to be ${t.state}`,duration:performance.now()-r,nodeType:"waitFor",page:e.page,runStartTime:e.runStartTime,specNode:n,status:"passed",stepIndex:e.stepIndex,title:`Wait for ${t.selector} to be ${t.state}`})}});var Te=[$t,at,ut,Et,tt,zt,Mt,Nt,Jt,Kt,Ut,St,Bt,ot,Vt,Ft,Pt,st,Ct,Ze,Ye,Qe,Me,Je,ze,Ke,ft,ht,yt,kt,bt,xt,Wt,Lt,jt,dt,lt],yd=new Map(Te.map(e=>[e.name,e])),Mo=Te.map(e=>e.anthropicTool),Go=Te.map(e=>`- **${e.name}**: ${e.anthropicTool.description??""}`).join(`
39
+ `);import zo from"pino";var N=zo({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}});import{execFileSync as Ed}from"child_process";import{createRequire as Od}from"module";import Fd from"fs";import{chromium as Dd}from"playwright";import{mkdir as _d,writeFile as Bd}from"fs/promises";import Gd from"path";import{readdir as ou,rm as nu,stat as au}from"fs/promises";import Zo from"path";import{graphql as en}from"gql.tada";import{print as Yo}from"graphql";async function V(e){let t=Yo(e.document),r=JSON.stringify({query:t,variables:e.variables}),n=await(await fetch(`${e.config.ripploServerUrl}/graphql`,{body:r,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST"})).json();if(!Qo(n))throw new Error("Invalid GraphQL response");if(Xo(n))throw new Error(n.errors.map(s=>s.message).join(", "));if(n.data==null)throw new Error("No data returned from server");return n.data}function Qo(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function Xo(e){return Array.isArray(e.errors)&&e.errors.length>0}var du=Zo.join(process.cwd(),".ripplo","debug"),uu=360*60*1e3,pu=en(`
29
40
  mutation RevokeCurrentCliToken {
30
41
  revokeCurrentCliToken
31
42
  }
32
- `);import Pt from"fs";import we from"path";import{z as O}from"zod";var ro=O.object({baseUrl:O.string().optional(),cloudBaseUrl:O.string(),preconditionApiPath:O.string().optional(),projectId:O.string()}),oo=O.object({ripploServerUrl:O.string(),token:O.string()}),no=ro.extend(oo.shape),Nt=we.join(process.cwd(),".ripplo"),ao=we.join(Nt,"settings.json"),so=we.join(Nt,"settings.local.json");function Tt(e){if(!Pt.existsSync(e))return null;let t=Pt.readFileSync(e,"utf8");return JSON.parse(t)}function be(){let e=Tt(ao),t=Tt(so);if(e==null||t==null)return null;let r=no.safeParse({...e,...t});return r.success?r.data:null}import{z as a}from"zod";import{z as N}from"zod";import{z as g}from"zod";var lo=g.object({by:g.literal("css"),value:g.string().min(1)}),co=g.object({by:g.literal("testId"),value:g.string().min(1)}),uo=g.object({by:g.literal("role"),exact:g.boolean().optional(),name:g.string().optional(),role:g.string().min(1)}),po=g.object({by:g.literal("text"),exact:g.boolean().optional(),value:g.string().min(1)}),fo=g.object({by:g.literal("label"),exact:g.boolean().optional(),value:g.string().min(1)}),mo=g.object({by:g.literal("placeholder"),value:g.string().min(1)}),ho=g.object({by:g.literal("altText"),value:g.string().min(1)}),f=g.discriminatedUnion("by",[lo,co,uo,po,fo,mo,ho]);import{z as At}from"zod";var v=At.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),E=At.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]);import{z as S}from"zod";var go=S.object({type:S.literal("static"),value:S.union([S.string(),S.number(),S.boolean()])}),Se=S.object({name:S.string().min(1),type:S.literal("variable")}),F=S.discriminatedUnion("type",[go,Se]),b=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.string()}),Se]),D=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.number().int().nonnegative()}),Se]);var W=N.discriminatedUnion("type",[N.object({locator:f,type:N.literal("elementVisible")}),N.object({locator:f,type:N.literal("elementNotVisible")}),N.object({expected:b,operator:v,type:N.literal("urlMatch")}),N.object({expected:b,locator:f,operator:v,type:N.literal("textMatch")}),N.object({expected:F,operator:E,type:N.literal("variableCompare"),variable:N.string().min(1)})]);import{z as P}from"zod";var B=P.discriminatedUnion("type",[P.object({default:P.string().optional(),type:P.literal("string")}),P.object({default:P.number().optional(),type:P.literal("number")}),P.object({default:P.boolean().optional(),type:P.literal("boolean")}),P.object({key:P.string().min(1),type:P.literal("env")})]);var yo=a.string().min(1),j=a.array(yo).min(1),p={comment:a.string().optional(),id:a.string().min(1),label:a.string().optional(),next:a.string().optional(),timeout:a.number().int().positive().optional()},wo=a.object({...p,type:a.literal("goto"),url:b}),bo=a.object({...p,locator:f,type:a.literal("click")}),So=a.object({...p,locator:f,type:a.literal("fill"),value:b}),Ro=a.object({...p,locator:f,type:a.literal("select"),value:b}),ko=a.object({...p,locator:f,type:a.literal("hover")}),xo=a.object({...p,key:a.string().min(1),locator:f.optional(),type:a.literal("press")}),vo=a.object({...p,locator:f,type:a.literal("check")}),Po=a.object({...p,locator:f,type:a.literal("uncheck")}),To=a.object({...p,type:a.literal("screenshot")}),No=a.object({...p,height:a.number().int().positive(),type:a.literal("setViewport"),width:a.number().int().positive()}),Ao=a.object({...p,duration:a.number().int().positive(),type:a.literal("wait")}),Co=a.object({...p,message:a.string().min(1),type:a.literal("fail")}),$o=a.object({...p,type:a.literal("setVariable"),value:F,variable:a.string().min(1)}),Io=a.object({...p,locator:f,type:a.literal("extractText"),variable:a.string().min(1)}),Eo=a.object({...p,files:a.array(a.string()).min(1),locator:f,type:a.literal("upload")}),jo=a.object({...p,locator:f,type:a.literal("dblclick")}),Vo=a.object({...p,source:f,target:f,type:a.literal("drag")}),Oo=a.object({...p,locator:f,type:a.literal("scrollIntoView")}),Fo=a.object({...p,locator:f,type:a.literal("type"),value:b}),Uo=a.object({...p,locator:f,type:a.literal("focus")}),Do=a.object({...p,locator:f,state:a.enum(["visible","hidden","attached","detached"]).optional(),type:a.literal("waitFor")}),Wo=a.object({...p,expected:b,operator:v,type:a.literal("waitForUrl")}),qo=a.object({...p,type:a.literal("waitForResponse"),urlPattern:b}),Lo=a.object({...p,type:a.literal("waitForRequest"),urlPattern:b}),_o=a.object({...p,locator:f,type:a.literal("assertVisible")}),Bo=a.object({...p,locator:f,type:a.literal("assertNotVisible")}),Mo=a.object({...p,expected:b,locator:f,operator:v,type:a.literal("assertText")}),Go=a.object({...p,expected:b,operator:v,type:a.literal("assertUrl")}),zo=a.object({...p,expected:D,locator:f,operator:E,type:a.literal("assertCount")}),Ho=a.object({...p,expected:b,locator:f,operator:v,type:a.literal("assertValue")}),Jo=a.object({...p,attribute:a.string().min(1),expected:b,locator:f,operator:v,type:a.literal("assertAttribute")}),Ko=a.object({...p,locator:f,type:a.literal("assertEnabled")}),Yo=a.object({...p,locator:f,type:a.literal("assertDisabled")}),Qo=a.object({...p,alternate:j.optional(),condition:W,consequent:j,type:a.literal("if")}),Xo=a.object({...p,body:j,iteratorVar:a.string().min(1).optional(),times:a.number().int().positive(),type:a.literal("loop")}),Zo=a.object({...p,body:j,collection:a.union([a.array(a.record(a.string(),a.unknown())).min(1),a.object({name:a.string().min(1),type:a.literal("variable")})]),iteratorVar:a.string().min(1),type:a.literal("forEach")}),en=a.object({...p,branches:a.array(j).min(2),type:a.literal("parallel")}),tn=a.object({...p,body:j,catch:j.optional(),finally:j.optional(),type:a.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),rn=a.object({...p,nodes:j,type:a.literal("group")}),J=a.discriminatedUnion("type",[wo,bo,So,Ro,ko,xo,vo,Po,Do,Wo,qo,Lo,_o,Bo,Mo,Go,zo,Ho,Jo,Ko,Yo,To,No,Ao,Co,$o,Io,Eo,jo,Vo,Oo,Fo,Uo,Qo,Xo,Zo,en,rn]),Ct=a.union([J,tn]),q=a.object({entryNode:a.string().min(1),nodes:a.record(a.string(),Ct),variables:a.record(a.string(),B).optional(),version:a.literal(2)});function Z(e){let t=q.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(r=>({message:r.message,path:r.path.join(".")})),success:!1}}import{graphql as ne,readFragment as Id}from"gql.tada";import{z as ee}from"zod";var Re=ee.object({from:ee.string().min(1).describe("Key of the source state in the states record"),to:ee.string().min(1).describe("Key of the target state in the states record"),workflow:ee.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 U}from"zod";import{z as y}from"zod";var ke=y.object({precondition:y.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"),te=y.object({satisfied:y.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),re=y.object({data:y.record(y.string(),y.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:y.string().optional().describe("Human-readable error message if success is false"),navigateTo:y.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:y.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."),xe=y.object({preconditions:y.array(y.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."),ve=y.object({error:y.string().optional().describe("Human-readable error message if success is false"),success:y.boolean().describe("Whether teardown completed successfully")}).describe("Response from PUT {preconditionApiUrl}/teardown"),L=y.object({depends:y.array(y.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:y.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:y.array(y.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 oe}from"zod";var Pe=oe.object({preconditions:oe.array(oe.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:oe.string().min(1).describe("URL pattern with {{placeholders}} for dynamic segments, e.g. '/projects/{{projectId}}/settings'")}).describe("A distinct application state \u2014 a unique combination of location, auth context, and data conditions");var K=U.object({edges:U.array(Re).describe("Directed edges between states, each executed by a workflow"),preconditions:U.record(U.string(),L).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:U.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:U.record(U.string(),Pe).describe("States keyed by stable ID (kebab-case)"),version:U.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions");function Te(e){let t=K.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(r=>({message:r.message,path:r.path.join(".")})),success:!1}}function yn(e){let t=e.preconditions,r=new Set,n=new Set,o=[];function s(l){if(n.has(l)){o.push(`Precondition "${l}" has a circular dependency`);return}if(r.has(l))return;r.add(l),n.add(l);let c=t[l];c?.depends!=null&&c.depends.forEach(i=>{s(i)}),n.delete(l)}return Object.keys(t).forEach(l=>{s(l)}),o}function Ne(e){let t=[],r=new Set(Object.keys(e.preconditions)),n=new Set(Object.keys(e.states));e.edges.forEach((i,d)=>{n.has(i.from)||t.push({message:`References non-existent source state "${i.from}"`,path:`edges[${String(d)}].from`}),n.has(i.to)||t.push({message:`References non-existent target state "${i.to}"`,path:`edges[${String(d)}].to`})}),Object.entries(e.states).forEach(([i,d])=>{d.preconditions.forEach(m=>{r.has(m)||t.push({message:`References non-existent precondition "${m}"`,path:`states.${i}.preconditions`})})}),Object.entries(e.preconditions).forEach(([i,d])=>{d.depends!=null&&d.depends.forEach(m=>{r.has(m)||t.push({message:`Depends on non-existent precondition "${m}"`,path:`preconditions.${i}.depends`})})}),e.resetPrecondition!=null&&!r.has(e.resetPrecondition)&&t.push({message:`References non-existent precondition "${e.resetPrecondition}"`,path:"resetPrecondition"});let o=new Set(e.edges.flatMap(i=>[i.from,i.to]));Object.keys(e.states).forEach(i=>{o.has(i)||t.push({message:"State is not referenced by any edge (orphan)",path:`states.${i}`})});let s=new Set;Object.values(e.states).forEach(i=>{i.preconditions.forEach(d=>s.add(d))}),Object.values(e.preconditions).forEach(i=>{i.depends!=null&&i.depends.forEach(d=>s.add(d))}),e.resetPrecondition!=null&&s.add(e.resetPrecondition),Object.keys(e.preconditions).forEach(i=>{s.has(i)||t.push({message:"Defined but never used by any state or dependency",path:`preconditions.${i}`})});let l=new Set;return e.edges.forEach((i,d)=>{let m=`${i.from}|${i.to}|${i.workflow}`;l.has(m)&&t.push({message:`Duplicate edge from "${i.from}" to "${i.to}" with workflow "${i.workflow}"`,path:`edges[${String(d)}]`}),l.add(m)}),yn(e).forEach(i=>t.push({message:i,path:"preconditions"})),t}import{parseSetCookie as gd}from"set-cookie-parser";import{z as It}from"zod";var bd=It.record(It.string(),L);import{graphql as Ae}from"gql.tada";var vd=Ae(`
43
+ `);import tr from"fs";import Ne from"path";import{z as F}from"zod";var on=F.object({baseUrl:F.string().optional(),cloudBaseUrl:F.string(),preconditionApiPath:F.string().optional(),projectId:F.string()}),nn=F.object({ripploServerUrl:F.string(),token:F.string()}),an=on.extend(nn.shape),or=Ne.join(process.cwd(),".ripplo"),sn=Ne.join(or,"settings.json"),ln=Ne.join(or,"settings.local.json");function rr(e){if(!tr.existsSync(e))return null;let t=tr.readFileSync(e,"utf8");return JSON.parse(t)}function Ce(){let e=rr(sn),t=rr(ln);if(e==null||t==null)return null;let r=an.safeParse({...e,...t});return r.success?r.data:null}import{z as a}from"zod";import{z as C}from"zod";import{z as y}from"zod";var dn=y.object({by:y.literal("css"),value:y.string().min(1)}),un=y.object({by:y.literal("testId"),value:y.string().min(1)}),pn=y.object({by:y.literal("role"),exact:y.boolean().optional(),name:y.string().optional(),role:y.string().min(1)}),fn=y.object({by:y.literal("text"),exact:y.boolean().optional(),value:y.string().min(1)}),mn=y.object({by:y.literal("label"),exact:y.boolean().optional(),value:y.string().min(1)}),hn=y.object({by:y.literal("placeholder"),value:y.string().min(1)}),gn=y.object({by:y.literal("altText"),value:y.string().min(1)}),m=y.discriminatedUnion("by",[dn,un,pn,fn,mn,hn,gn]);import{z as nr}from"zod";var R=nr.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),j=nr.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]);import{z as S}from"zod";var yn=S.object({type:S.literal("static"),value:S.union([S.string(),S.number(),S.boolean()])}),Ae=S.object({name:S.string().min(1),type:S.literal("variable")}),U=S.discriminatedUnion("type",[yn,Ae]),g=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.string()}),Ae]),W=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.number().int().nonnegative()}),Ae]);var q=C.discriminatedUnion("type",[C.object({locator:m,type:C.literal("elementVisible")}),C.object({locator:m,type:C.literal("elementNotVisible")}),C.object({expected:g,operator:R,type:C.literal("urlMatch")}),C.object({expected:g,locator:m,operator:R,type:C.literal("textMatch")}),C.object({expected:U,operator:j,type:C.literal("variableCompare"),variable:C.string().min(1)})]);import{z as P}from"zod";var z=P.discriminatedUnion("type",[P.object({default:P.string().optional(),type:P.literal("string")}),P.object({default:P.number().optional(),type:P.literal("number")}),P.object({default:P.boolean().optional(),type:P.literal("boolean")}),P.object({key:P.string().min(1),type:P.literal("env")})]);var wn=a.string().min(1),O=a.array(wn).min(1),f={comment:a.string().optional(),id:a.string().min(1),label:a.string().optional(),next:a.string().optional(),timeout:a.number().int().positive().optional()},bn=a.object({...f,type:a.literal("goto"),url:g}),Sn=a.object({...f,locator:m,type:a.literal("click")}),kn=a.object({...f,locator:m,type:a.literal("fill"),value:g}),Rn=a.object({...f,locator:m,type:a.literal("select"),value:g}),vn=a.object({...f,locator:m,type:a.literal("hover")}),xn=a.object({...f,key:a.string().min(1),locator:m.optional(),type:a.literal("press")}),Pn=a.object({...f,locator:m,type:a.literal("check")}),Tn=a.object({...f,locator:m,type:a.literal("uncheck")}),Nn=a.object({...f,type:a.literal("screenshot")}),Cn=a.object({...f,height:a.number().int().positive(),type:a.literal("setViewport"),width:a.number().int().positive()}),An=a.object({...f,duration:a.number().int().positive(),type:a.literal("wait")}),$n=a.object({...f,message:a.string().min(1),type:a.literal("fail")}),In=a.object({...f,type:a.literal("setVariable"),value:U,variable:a.string().min(1)}),En=a.object({...f,locator:m,type:a.literal("extractText"),variable:a.string().min(1)}),jn=a.object({...f,files:a.array(a.string()).min(1),locator:m,type:a.literal("upload")}),On=a.object({...f,locator:m,type:a.literal("dblclick")}),Vn=a.object({...f,source:m,target:m,type:a.literal("drag")}),Fn=a.object({...f,locator:m,type:a.literal("scrollIntoView")}),Un=a.object({...f,locator:m,type:a.literal("type"),value:g}),Dn=a.object({...f,locator:m,type:a.literal("focus")}),Wn=a.object({...f,locator:m,type:a.literal("clear")}),qn=a.object({...f,locator:m,type:a.literal("rightClick")}),Ln=a.object({...f,action:a.enum(["accept","dismiss"]),promptText:a.string().optional(),type:a.literal("handleDialog")}),_n=a.object({...f,locator:m.optional(),type:a.literal("scroll"),x:a.number().int().optional(),y:a.number().int().optional()}),Bn=a.object({...f,action:a.enum(["read","write"]),type:a.literal("clipboard"),value:g.optional(),variable:a.string().min(1).optional()}),Mn=a.object({...f,permission:a.string().min(1),state:a.enum(["granted","prompt"]),type:a.literal("setPermission")}),Gn=a.object({...f,locator:m,state:a.enum(["visible","hidden","attached","detached"]).optional(),type:a.literal("waitFor")}),zn=a.object({...f,expected:g,operator:R,type:a.literal("waitForUrl")}),Hn=a.object({...f,type:a.literal("waitForResponse"),urlPattern:g}),Jn=a.object({...f,type:a.literal("waitForRequest"),urlPattern:g}),Kn=a.object({...f,locator:m,type:a.literal("assertVisible")}),Yn=a.object({...f,locator:m,type:a.literal("assertNotVisible")}),Qn=a.object({...f,expected:g,locator:m,operator:R,type:a.literal("assertText")}),Xn=a.object({...f,expected:g,operator:R,type:a.literal("assertUrl")}),Zn=a.object({...f,expected:W,locator:m,operator:j,type:a.literal("assertCount")}),ea=a.object({...f,expected:g,locator:m,operator:R,type:a.literal("assertValue")}),ta=a.object({...f,attribute:a.string().min(1),expected:g,locator:m,operator:R,type:a.literal("assertAttribute")}),ra=a.object({...f,locator:m,type:a.literal("assertEnabled")}),oa=a.object({...f,locator:m,type:a.literal("assertDisabled")}),na=a.object({...f,expected:g,operator:R,type:a.literal("assertTitle")}),aa=a.object({...f,locator:m,type:a.literal("assertChecked")}),sa=a.object({...f,locator:m,type:a.literal("assertNotChecked")}),ia=a.object({...f,locator:m,type:a.literal("assertFocused")}),la=a.object({...f,httpOnly:a.boolean().optional(),name:g,operator:R.optional(),sameSite:a.enum(["Strict","Lax","None"]).optional(),secure:a.boolean().optional(),type:a.literal("assertCookie"),value:g.optional()}),ca=a.object({...f,bodyContains:g.optional(),headerContains:a.object({name:a.string().min(1),value:g}).optional(),status:a.number().int().positive().optional(),type:a.literal("assertResponse"),urlPattern:g}),da=a.object({...f,alternate:O.optional(),condition:q,consequent:O,type:a.literal("if")}),ua=a.object({...f,body:O,iteratorVar:a.string().min(1).optional(),times:a.number().int().positive(),type:a.literal("loop")}),pa=a.object({...f,body:O,collection:a.union([a.array(a.record(a.string(),a.unknown())).min(1),a.object({name:a.string().min(1),type:a.literal("variable")})]),iteratorVar:a.string().min(1),type:a.literal("forEach")}),fa=a.object({...f,branches:a.array(O).min(2),type:a.literal("parallel")}),ma=a.object({...f,body:O,catch:O.optional(),finally:O.optional(),type:a.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),ha=a.object({...f,nodes:O,type:a.literal("group")}),X=a.discriminatedUnion("type",[bn,Sn,kn,Rn,vn,xn,Pn,Tn,Gn,zn,Hn,Jn,Kn,Yn,Qn,Xn,Zn,ea,ta,ra,oa,Nn,Cn,An,$n,In,En,jn,On,Vn,Fn,Un,Dn,Wn,qn,Ln,_n,Bn,Mn,na,aa,sa,ia,la,ca,da,ua,pa,fa,ha]),ar=a.union([X,ma]),L=a.object({entryNode:a.string().min(1),nodes:a.record(a.string(),ar),variables:a.record(a.string(),z).optional(),version:a.literal(2)});function ne(e){let t=L.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(r=>({message:r.message,path:r.path.join(".")})),success:!1}}import{graphql as ce,readFragment as yf}from"gql.tada";import{z as ae}from"zod";var $e=ae.object({from:ae.string().min(1).describe("Key of the source state in the states record"),to:ae.string().min(1).describe("Key of the target state in the states record"),workflow:ae.string().min(1).describe("Filename (without .json) of the workflow in .ripplo/workflows/ that executes this edge")}).describe("A directed edge between two states, executed by a workflow");import{z as D}from"zod";import{z as b}from"zod";var Ie=b.object({precondition:b.string().min(1).describe("Name of the precondition to check or execute, e.g. 'auth:admin'")}).describe("Request payload sent by Ripplo to both the check and execute endpoints"),se=b.object({satisfied:b.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),ie=b.object({data:b.record(b.string(),b.string()).optional().describe("Key-value data returned by the precondition. Values are injected as variables that can be interpolated into route patterns ({{key}}) and workflow spec variable references. For example, a data:project precondition should return { projectId: 'clx...' } so the route /projects/{{projectId}}/settings resolves correctly."),error:b.string().optional().describe("Human-readable error message if success is false"),navigateTo:b.string().optional().describe("URL to navigate the browser to after this precondition executes. Use this to set the starting page for the test \u2014 e.g. an auth token URL or the page the workflow begins on. If multiple preconditions return navigateTo, only the last one is used."),success:b.boolean().describe("Whether the precondition was successfully satisfied")}).describe("Response from PUT {preconditionApiUrl}/execute. Set-Cookie headers are automatically captured and injected into the browser context. The data field provides values for route param interpolation and workflow variables."),Ee=b.object({preconditions:b.array(b.string().min(1)).describe("Names of all preconditions that were executed during this run")}).describe("Request payload sent after a run completes. Fire-and-forget \u2014 errors are logged but don't fail the run."),je=b.object({error:b.string().optional().describe("Human-readable error message if success is false"),success:b.boolean().describe("Whether teardown completed successfully")}).describe("Response from PUT {preconditionApiUrl}/teardown"),_=b.object({depends:b.array(b.string().min(1)).optional().describe("Names of other preconditions that must be satisfied first. Resolved via topological sort; cycles are rejected at validation time."),description:b.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:b.array(b.string().min(1)).optional().describe("Keys that the execute response's data field will contain. e.g. ['projectId', 'workflowId']. These are used for route param interpolation ({{projectId}}) and workflow variables. Declared here so generated types are strongly typed per precondition.")}).describe("A named precondition declared at the graph level. States reference these by name.");import{z as le}from"zod";var Oe=le.object({preconditions:le.array(le.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:le.string().min(1).describe("URL pattern with {{placeholders}} for dynamic segments, e.g. '/projects/{{projectId}}/settings'")}).describe("A distinct application state \u2014 a unique combination of location, auth context, and data conditions");var Z=D.object({edges:D.array($e).describe("Directed edges between states, each executed by a workflow"),preconditions:D.record(D.string(),_).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:D.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:D.record(D.string(),Oe).describe("States keyed by stable ID (kebab-case)"),version:D.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions");function Ve(e){let t=Z.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(r=>({message:r.message,path:r.path.join(".")})),success:!1}}function Aa(e){let t=e.preconditions,r=new Set,o=new Set,n=[];function s(l){if(o.has(l)){n.push(`Precondition "${l}" has a circular dependency`);return}if(r.has(l))return;r.add(l),o.add(l);let d=t[l];d?.depends!=null&&d.depends.forEach(i=>{s(i)}),o.delete(l)}return Object.keys(t).forEach(l=>{s(l)}),n}function Fe(e){let t=[],r=new Set(Object.keys(e.preconditions)),o=new Set(Object.keys(e.states));e.edges.forEach((i,u)=>{o.has(i.from)||t.push({message:`References non-existent source state "${i.from}"`,path:`edges[${String(u)}].from`}),o.has(i.to)||t.push({message:`References non-existent target state "${i.to}"`,path:`edges[${String(u)}].to`})}),Object.entries(e.states).forEach(([i,u])=>{u.preconditions.forEach(h=>{r.has(h)||t.push({message:`References non-existent precondition "${h}"`,path:`states.${i}.preconditions`})})}),Object.entries(e.preconditions).forEach(([i,u])=>{u.depends!=null&&u.depends.forEach(h=>{r.has(h)||t.push({message:`Depends on non-existent precondition "${h}"`,path:`preconditions.${i}.depends`})})}),e.resetPrecondition!=null&&!r.has(e.resetPrecondition)&&t.push({message:`References non-existent precondition "${e.resetPrecondition}"`,path:"resetPrecondition"});let n=new Set(e.edges.flatMap(i=>[i.from,i.to]));Object.keys(e.states).forEach(i=>{n.has(i)||t.push({message:"State is not referenced by any edge (orphan)",path:`states.${i}`})});let s=new Set;Object.values(e.states).forEach(i=>{i.preconditions.forEach(u=>s.add(u))}),Object.values(e.preconditions).forEach(i=>{i.depends!=null&&i.depends.forEach(u=>s.add(u))}),e.resetPrecondition!=null&&s.add(e.resetPrecondition),Object.keys(e.preconditions).forEach(i=>{s.has(i)||t.push({message:"Defined but never used by any state or dependency",path:`preconditions.${i}`})});let l=new Set;return e.edges.forEach((i,u)=>{let h=`${i.from}|${i.to}|${i.workflow}`;l.has(h)&&t.push({message:`Duplicate edge from "${i.from}" to "${i.to}" with workflow "${i.workflow}"`,path:`edges[${String(u)}]`}),l.add(h)}),Aa(e).forEach(i=>t.push({message:i,path:"preconditions"})),t}import{parseSetCookie as tf}from"set-cookie-parser";import{z as ir}from"zod";var nf=ir.record(ir.string(),_);import{graphql as Ue}from"gql.tada";var df=Ue(`
33
44
  mutation StartRunCLI($runId: String!, $platform: String!, $agentProfileId: String) {
34
45
  startRun(runId: $runId, platform: $platform, agentProfileId: $agentProfileId) {
35
46
  id
36
47
  }
37
48
  }
38
- `),Pd=Ae(`
49
+ `),uf=Ue(`
39
50
  mutation SubmitRunStepsCLI($runResultId: String!, $steps: [StepInput!]!) {
40
51
  submitRunSteps(runResultId: $runResultId, steps: $steps)
41
52
  }
42
- `),Td=Ae(`
53
+ `),pf=Ue(`
43
54
  mutation CompleteRunCLI(
44
55
  $runResultId: String!
45
56
  $status: String!
@@ -62,14 +73,14 @@ ${o}`}}});import{z as pt}from"zod";var Or=20,Fr=2,Ur=pt.object({pattern:pt.strin
62
73
  status
63
74
  }
64
75
  }
65
- `);var vn=ne(`
76
+ `);var Fa=ce(`
66
77
  fragment WorkflowRun on Workflow {
67
78
  id
68
79
  slug
69
80
  name
70
81
  spec
71
82
  }
72
- `),Pn=ne(`
83
+ `),Ua=ce(`
73
84
  fragment ProjectRun on Project {
74
85
  id
75
86
  baseUrl
@@ -88,13 +99,13 @@ ${o}`}}});import{z as pt}from"zod";var Or=20,Fr=2,Ur=pt.object({pattern:pt.strin
88
99
  ...WorkflowRun
89
100
  }
90
101
  }
91
- `,[vn]),_d=ne(`
102
+ `,[Fa]),Cf=ce(`
92
103
  query ProjectRun($projectId: String!) {
93
104
  project(id: $projectId) {
94
105
  ...ProjectRun
95
106
  }
96
107
  }
97
- `,[Pn]),Bd=ne(`
108
+ `,[Ua]),Af=ce(`
98
109
  query AgentProfileRun($id: String!) {
99
110
  agentProfile(id: $id) {
100
111
  id
@@ -104,12 +115,12 @@ ${o}`}}});import{z as pt}from"zod";var Or=20,Fr=2,Ur=pt.object({pattern:pt.strin
104
115
  successCriteria
105
116
  }
106
117
  }
107
- `);function k(e){return{content:[{text:e,type:"text"}]}}async function Et(e){let t=be();return t==null?k("Not logged in. Run: ripplo login"):e(t)}import{z as x}from"zod";import Tn from"fs";import vu from"path";import{z as M}from"zod";var Y=M.object({additionalChecks:M.array(M.string()).default([]),description:M.string(),expectedOutcome:M.string(),name:M.string(),spec:q});function ae(e){let t=Tn.readFileSync(e,"utf8"),r=JSON.parse(t);return Y.parse(r)}var Nn=x.object({additionalProperties:x.unknown().optional(),properties:x.record(x.string(),x.record(x.string(),x.unknown())).optional(),required:x.array(x.string()).optional(),type:x.string().optional()}),jt=x.object({oneOf:x.array(Nn).optional()});function Vt(){let e=Vn(),t={category:"Control Flow",fields:"body, catch?, finally?",typeName:"try"},r=[...e.map(s=>On(s)),t],n=Fn(r);return`# Ripplo Workflow Spec v2
118
+ `);function v(e){return{content:[{text:e,type:"text"}]}}async function lr(e){let t=Ce();return t==null?v("Not logged in. Run: ripplo login"):e(t)}import{z as x}from"zod";import Da from"fs";import dm from"path";import{z as H}from"zod";var ee=H.object({additionalChecks:H.array(H.string()).default([]),description:H.string(),expectedOutcome:H.string(),name:H.string(),spec:L});function de(e){let t=Da.readFileSync(e,"utf8"),r=JSON.parse(t);return ee.parse(r)}var Wa=x.object({additionalProperties:x.unknown().optional(),properties:x.record(x.string(),x.record(x.string(),x.unknown())).optional(),required:x.array(x.string()).optional(),type:x.string().optional()}),cr=x.object({oneOf:x.array(Wa).optional()});function dr(){let e=za(),t={category:"Control Flow",fields:"body, catch?, finally?",typeName:"try"},r=[...e.map(s=>Ha(s)),t],o=Ja(r);return`# Ripplo Workflow Spec v2
108
119
 
109
120
  ## Node Types
110
121
 
111
- ${An.filter(s=>n.has(s)).map(s=>{let c=(n.get(s)??[]).map(i=>`- ${i.typeName} { ${i.fields} }`);return`### ${s}
112
- ${c.join(`
122
+ ${qa.filter(s=>o.has(s)).map(s=>{let d=(o.get(s)??[]).map(i=>`- ${i.typeName} { ${i.fields} }`);return`### ${s}
123
+ ${d.join(`
113
124
  `)}`}).join(`
114
125
 
115
126
  `)}
@@ -135,20 +146,20 @@ Each workflow file in \`.ripplo/workflows/\` is a JSON file with: name, descript
135
146
  The spec contains: version (2), entryNode, nodes, variables?.
136
147
 
137
148
  Use \`get_node_schema\` for full JSON Schema of specific node types.
138
- Use \`get_spec_patterns\` for locator, condition, and variable schemas + best practices.`}function Ot({nodeTypes:e}){let r=jt.parse(structuredClone(x.toJSONSchema(J))).oneOf??[],n=new Map;r.forEach(s=>{let l=Ut(s);l.length>0&&n.set(l,s)});let o=[];return e.forEach(s=>{if(s==="try"){o.push(Wn);return}let l=n.get(s);if(l==null){o.push(`## ${s}
149
+ Use \`get_spec_patterns\` for locator, condition, and variable schemas + best practices.`}function ur({nodeTypes:e}){let r=cr.parse(structuredClone(x.toJSONSchema(X))).oneOf??[],o=new Map;r.forEach(s=>{let l=fr(s);l.length>0&&o.set(l,s)});let n=[];return e.forEach(s=>{if(s==="try"){n.push(Qa);return}let l=o.get(s);if(l==null){n.push(`## ${s}
139
150
 
140
- Unknown node type "${s}".`);return}o.push(`## ${s}
151
+ Unknown node type "${s}".`);return}n.push(`## ${s}
141
152
 
142
153
  \`\`\`json
143
154
  ${JSON.stringify(l,null,2)}
144
- \`\`\``)}),o.push(Dn),o.join(`
155
+ \`\`\``)}),n.push(Ya),n.join(`
145
156
 
146
- `)}function Ft(){return`# Spec Patterns & Building Blocks
157
+ `)}function pr(){return`# Spec Patterns & Building Blocks
147
158
 
148
- ${[{label:"Locator",schema:f},{label:"Condition",schema:W},{label:"StringValueRef",schema:b},{label:"NumericValueRef",schema:D},{label:"ValueRef",schema:F},{label:"ComparisonOperator (string)",schema:v},{label:"NumericOperator",schema:E},{label:"VariableDef",schema:B},{label:"WorkflowFile (top-level)",schema:Y},{label:"WorkflowSpec (the spec field)",schema:q}].map(({label:r,schema:n})=>`### ${r}
159
+ ${[{label:"Locator",schema:m},{label:"Condition",schema:q},{label:"StringValueRef",schema:g},{label:"NumericValueRef",schema:W},{label:"ValueRef",schema:U},{label:"ComparisonOperator (string)",schema:R},{label:"NumericOperator",schema:j},{label:"VariableDef",schema:z},{label:"WorkflowFile (top-level)",schema:ee},{label:"WorkflowSpec (the spec field)",schema:L}].map(({label:r,schema:o})=>`### ${r}
149
160
 
150
161
  \`\`\`json
151
- ${JSON.stringify(x.toJSONSchema(n),null,2)}
162
+ ${JSON.stringify(x.toJSONSchema(o),null,2)}
152
163
  \`\`\``).join(`
153
164
 
154
165
  `)}
@@ -167,23 +178,23 @@ ${JSON.stringify(x.toJSONSchema(n),null,2)}
167
178
  10. **URLs in goto nodes must be relative paths** (\`/login\`), never absolute URLs \u2014 the baseUrl handles the origin
168
179
  11. **Value references use \`"type": "static"\`**, never \`"type": "literal"\`
169
180
  12. **Node IDs must match their key** in the \`nodes\` object
170
- 13. **Template variables use \`{{name}}\`**, never \`$name\` or \`\${name}\` \u2014 only double curly braces work`}var An=["Actions","Waits","Assertions","Variables","Control Flow","Other"],Cn=new Set(["if","loop","forEach","parallel","try","group"]),$n=new Set(["setVariable","extractText"]),In=new Set(["screenshot","setViewport","fail"]),En=new Set(["comment","id","label","next","timeout","type"]);function jn(e){return e.startsWith("assert")?"Assertions":e.startsWith("waitFor")||e==="wait"?"Waits":Cn.has(e)?"Control Flow":$n.has(e)?"Variables":In.has(e)?"Other":"Actions"}function Vn(){return jt.parse(structuredClone(x.toJSONSchema(J))).oneOf??[]}function Ut(e){let t=e.properties?.type;if(t==null)return"";let r=t.const;return typeof r=="string"?r:""}function On(e){let t=Ut(e),r=new Set(e.required??[]),n=Object.keys(e.properties??{}).filter(o=>!En.has(o)).map(o=>r.has(o)?o:`${o}?`).join(", ");return{category:jn(t),fields:n,typeName:t}}function Fn(e){let t=new Map;return e.forEach(r=>{let n=t.get(r.category)??[];n.push(r),t.set(r.category,n)}),t}function Un(){return`---
181
+ 13. **Template variables use \`{{name}}\`**, never \`$name\` or \`\${name}\` \u2014 only double curly braces work`}var qa=["Actions","Waits","Assertions","Variables","Control Flow","Other"],La=new Set(["if","loop","forEach","parallel","try","group"]),_a=new Set(["setVariable","extractText"]),Ba=new Set(["screenshot","setViewport","fail"]),Ma=new Set(["comment","id","label","next","timeout","type"]);function Ga(e){return e.startsWith("assert")?"Assertions":e.startsWith("waitFor")||e==="wait"?"Waits":La.has(e)?"Control Flow":_a.has(e)?"Variables":Ba.has(e)?"Other":"Actions"}function za(){return cr.parse(structuredClone(x.toJSONSchema(X))).oneOf??[]}function fr(e){let t=e.properties?.type;if(t==null)return"";let r=t.const;return typeof r=="string"?r:""}function Ha(e){let t=fr(e),r=new Set(e.required??[]),o=Object.keys(e.properties??{}).filter(n=>!Ma.has(n)).map(n=>r.has(n)?n:`${n}?`).join(", ");return{category:Ga(t),fields:o,typeName:t}}function Ja(e){let t=new Map;return e.forEach(r=>{let o=t.get(r.category)??[];o.push(r),t.set(r.category,o)}),t}function Ka(){return`---
171
182
 
172
183
  ## Referenced Schemas
173
184
 
174
- ${[G("Locator",f),G("StringValueRef",b),G("NumericValueRef",D),G("ComparisonOperator",v),G("NumericOperator",E),G("Condition",W)].join(`
185
+ ${[J("Locator",m),J("StringValueRef",g),J("NumericValueRef",W),J("ComparisonOperator",R),J("NumericOperator",j),J("Condition",q)].join(`
175
186
 
176
- `)}`}var Dn=Un();function G(e,t){return`### ${e}
187
+ `)}`}var Ya=Ka();function J(e,t){return`### ${e}
177
188
 
178
189
  \`\`\`json
179
190
  ${JSON.stringify(x.toJSONSchema(t),null,2)}
180
- \`\`\``}var Wn=["## try","","The `try` node uses a refinement: at least one of `catch` or `finally` is required.","","Fields: body (required), catch? (optional), finally? (optional)","Plus base fields: id, type, next?, timeout?, label?, comment?"].join(`
181
- `);import{graphql as se,readFragment as qn}from"gql.tada";var Wt=se(`
191
+ \`\`\``}var Qa=["## try","","The `try` node uses a refinement: at least one of `catch` or `finally` is required.","","Fields: body (required), catch? (optional), finally? (optional)","Plus base fields: id, type, next?, timeout?, label?, comment?"].join(`
192
+ `);import{graphql as ue,readFragment as Xa}from"gql.tada";var hr=ue(`
182
193
  fragment WorkflowIdMCP on Workflow {
183
194
  id
184
195
  slug
185
196
  }
186
- `),Ln=se(`
197
+ `),Za=ue(`
187
198
  query ProjectWorkflowIdsMCP($projectId: String!) {
188
199
  project(id: $projectId) {
189
200
  id
@@ -195,14 +206,14 @@ ${JSON.stringify(x.toJSONSchema(t),null,2)}
195
206
  }
196
207
  }
197
208
  }
198
- `,[Wt]),_n=se(`
209
+ `,[hr]),es=ue(`
199
210
  mutation CreateRunMCP($workflowId: String!, $platforms: [String!]!, $concurrency: Int!) {
200
211
  createRun(workflowId: $workflowId, platforms: $platforms, concurrency: $concurrency) {
201
212
  id
202
213
  status
203
214
  }
204
215
  }
205
- `),Bn=se(`
216
+ `),ts=ue(`
206
217
  query RunStatusMCP($id: String!) {
207
218
  run(id: $id) {
208
219
  id
@@ -229,20 +240,20 @@ ${JSON.stringify(x.toJSONSchema(t),null,2)}
229
240
  }
230
241
  }
231
242
  }
232
- `);async function qt({config:e,slugs:t}){let r=await Mn({config:e,slugs:t}),n=await Promise.allSettled(r.map(async({slug:i,workflowId:d})=>({runId:await zn({config:e,workflowId:d}),slug:i}))),o=[],s=[];n.forEach((i,d)=>{let m=r[d];if(m==null)return;if(i.status==="fulfilled"){o.push(i.value);return}let I=i.reason instanceof Error?i.reason.message:String(i.reason);s.push({runId:"",slug:m.slug,summary:`ERROR creating run: ${I}`})}),(await Promise.allSettled(o.map(async({runId:i,slug:d})=>{let m=await Jn({config:e,runId:i}),I=Gn({config:e,runId:i,slug:d}),Q=`.ripplo/debug/${i}/`;return{runId:i,slug:d,summary:`View run: ${I}
233
- Debug artifacts: ${Q}
243
+ `);async function gr({config:e,slugs:t}){let r=await rs({config:e,slugs:t}),o=await Promise.allSettled(r.map(async({slug:i,workflowId:u})=>({runId:await ns({config:e,workflowId:u}),slug:i}))),n=[],s=[];o.forEach((i,u)=>{let h=r[u];if(h==null)return;if(i.status==="fulfilled"){n.push(i.value);return}let E=i.reason instanceof Error?i.reason.message:String(i.reason);s.push({runId:"",slug:h.slug,summary:`ERROR creating run: ${E}`})}),(await Promise.allSettled(n.map(async({runId:i,slug:u})=>{let h=await ss({config:e,runId:i}),E=os({config:e,runId:i,slug:u}),te=`.ripplo/debug/${i}/`;return{runId:i,slug:u,summary:`View run: ${E}
244
+ Debug artifacts: ${te}
234
245
 
235
- ${m}`}}))).forEach((i,d)=>{let m=o[d];if(m==null)return;if(i.status==="fulfilled"){s.push(i.value);return}let I=i.reason instanceof Error?i.reason.message:String(i.reason);s.push({runId:m.runId,slug:m.slug,summary:`ERROR polling run ${m.runId}: ${I}`})});let c=s.map(i=>`**${i.slug}:**
246
+ ${h}`}}))).forEach((i,u)=>{let h=n[u];if(h==null)return;if(i.status==="fulfilled"){s.push(i.value);return}let E=i.reason instanceof Error?i.reason.message:String(i.reason);s.push({runId:h.runId,slug:h.slug,summary:`ERROR polling run ${h.runId}: ${E}`})});let d=s.map(i=>`**${i.slug}:**
236
247
  ${i.summary}`).join(`
237
248
 
238
249
  ---
239
250
 
240
- `);return{results:s,summary:c}}async function Mn({config:e,slugs:t}){let r=await V({config:e,document:Ln,variables:{projectId:e.projectId}});if(r.project==null)throw new Error("Project not found");if(r.project.devSession==null)throw new Error("No active dev session. Start one by running `ripplo dev` in your terminal, then try again.");let n=(r.project.workflows??[]).map(o=>qn(Wt,o));return t.map(o=>{let s=n.find(l=>l.slug===o);if(s==null)throw new Error(`Workflow "${o}" not found on server. Is the dev session running and synced?`);return{slug:o,workflowId:s.id}})}function Gn({config:e,runId:t,slug:r}){return`${e.ripploServerUrl.replace(/:3000\b/,":3001")}/projects/${e.projectId}/workflows/${r}/runs/${t}`}async function zn({config:e,workflowId:t}){let r=await V({config:e,document:_n,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});if(r.createRun==null)throw new Error("Failed to create run");return r.createRun.id}var Hn=2e3,Dt=150;async function Jn({config:e,runId:t}){let r=0;for(;r<Dt;){await Yn(Hn),r+=1;let o=(await V({config:e,document:Bn,variables:{id:t}})).run;if(o==null)throw new Error(`Run ${t} not found`);if(!(o.status==="pending"||o.status==="running"))return Kn({results:o.results??[],runId:t,status:o.status})}return`Run ${t} timed out after polling ${String(Dt)} times.`}function Kn({results:e,runId:t,status:r}){let n=[`Run ${t}: ${r.toUpperCase()}`];return e.forEach(o=>{n.push(` ${o.status}: ${String(o.passCount)} passed, ${String(o.failCount)} failed (${String(o.duration??0)}ms)`),o.summary!=null&&n.push(` Summary: ${o.summary}`),o.traceEntries.forEach(s=>{let l=s.status==="passed"?"\u2713":"\u2717",c=s.detail==null?"":` \u2014 ${s.detail}`;n.push(` ${l} ${s.title} (${String(s.duration)}ms)${c}`),s.assertions.forEach(i=>{let d=i.status==="passed"?"\u2713":"\u2717",m=i.detail==null?"":` \u2014 ${i.detail}`;n.push(` ${d} ${i.description}${m}`)})})}),n.join(`
241
- `)}function Yn(e){return new Promise(t=>{setTimeout(t,e)})}import{z as Qn}from"zod";function Lt(){return Xn()}function _t(){return Zn()}function _(e,t){let r=Qn.toJSONSchema(t);return`### ${e}
251
+ `);return{results:s,summary:d}}async function rs({config:e,slugs:t}){let r=await V({config:e,document:Za,variables:{projectId:e.projectId}});if(r.project==null)throw new Error("Project not found");if(r.project.devSession==null)throw new Error("No active dev session. Start one by running `ripplo dev` in your terminal, then try again.");let o=(r.project.workflows??[]).map(n=>Xa(hr,n));return t.map(n=>{let s=o.find(l=>l.slug===n);if(s==null)throw new Error(`Workflow "${n}" not found on server. Is the dev session running and synced?`);return{slug:n,workflowId:s.id}})}function os({config:e,runId:t,slug:r}){return`${e.ripploServerUrl.replace(/:3000\b/,":3001")}/projects/${e.projectId}/workflows/${r}/runs/${t}`}async function ns({config:e,workflowId:t}){let r=await V({config:e,document:es,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});if(r.createRun==null)throw new Error("Failed to create run");return r.createRun.id}var as=2e3,mr=150;async function ss({config:e,runId:t}){let r=0;for(;r<mr;){await ls(as),r+=1;let n=(await V({config:e,document:ts,variables:{id:t}})).run;if(n==null)throw new Error(`Run ${t} not found`);if(!(n.status==="pending"||n.status==="running"))return is({results:n.results??[],runId:t,status:n.status})}return`Run ${t} timed out after polling ${String(mr)} times.`}function is({results:e,runId:t,status:r}){let o=[`Run ${t}: ${r.toUpperCase()}`];return e.forEach(n=>{o.push(` ${n.status}: ${String(n.passCount)} passed, ${String(n.failCount)} failed (${String(n.duration??0)}ms)`),n.summary!=null&&o.push(` Summary: ${n.summary}`),n.traceEntries.forEach(s=>{let l=s.status==="passed"?"\u2713":"\u2717",d=s.detail==null?"":` \u2014 ${s.detail}`;o.push(` ${l} ${s.title} (${String(s.duration)}ms)${d}`),s.assertions.forEach(i=>{let u=i.status==="passed"?"\u2713":"\u2717",h=i.detail==null?"":` \u2014 ${i.detail}`;o.push(` ${u} ${i.description}${h}`)})})}),o.join(`
252
+ `)}function ls(e){return new Promise(t=>{setTimeout(t,e)})}import{z as cs}from"zod";function yr(){return ds()}function wr(){return us()}function B(e,t){let r=cs.toJSONSchema(t);return`### ${e}
242
253
 
243
254
  \`\`\`json
244
255
  ${JSON.stringify(r,null,2)}
245
- \`\`\``}function Xn(){return[`# Ripplo State Graph Spec
256
+ \`\`\``}function ds(){return[`# Ripplo State Graph Spec
246
257
 
247
258
  The graph schema is documented below as JSON Schema (generated from Zod at runtime \u2014 always in sync with the code).
248
259
 
@@ -250,7 +261,7 @@ The graph schema is documented below as JSON Schema (generated from Zod at runti
250
261
 
251
262
  The graph lives at \`.ripplo/graph.json\`. The top-level shape is the StateGraph schema below. One graph per project.`,`## Graph Schema
252
263
 
253
- `+_("StateGraph",K),`## Preconditions (summary)
264
+ `+B("StateGraph",Z),`## Preconditions (summary)
254
265
 
255
266
  Preconditions are named capabilities declared at the graph level and referenced by name from states. They represent what must be true before entering a state (auth, data, feature flags, etc.).
256
267
 
@@ -263,9 +274,9 @@ Dependencies (\`depends\`) are resolved via topological sort. Cycles are rejecte
263
274
 
264
275
  Use \`get_precondition_schema\` for full precondition API schemas, setup guide, and framework-specific auth examples.`].join(`
265
276
 
266
- `)}function Zn(){return["# Precondition API \u2014 Full Reference\n\nPreconditions are named capabilities declared at the graph level and referenced by name from states.\n\nRipplo does NOT run any business logic. The user's app exposes a Precondition API with three endpoints, and Ripplo sends the precondition name in the request body.\n\n### Execution flow for each precondition:\n1. **Check**: `POST {preconditionApiPath}/check` \u2014 is it already satisfied?\n2. **Execute** (if not satisfied): `PUT {preconditionApiPath}/execute` \u2014 satisfy it\n3. Set-Cookie headers from execute responses are automatically captured and injected into the browser. All cookie attributes (Domain, Path, SameSite, HttpOnly, Secure, Expires, Max-Age) are preserved. Always include `Path=/` and an appropriate `SameSite` value on auth cookies.\n4. If the execute response includes `navigateTo`, the browser navigates to that URL after all preconditions complete (sets the starting page for the test)\n5. **Teardown** (after run): `PUT {preconditionApiPath}/teardown` \u2014 clean up (fire-and-forget)\n\nDependencies (`depends`) are resolved via topological sort with deduplication. Cycles are rejected at validation time.",_("Precondition (graph-level declaration)",L),_("Precondition Check/Execute Request",ke),_("Check Response",te),_("Execute Response",re),_("Teardown Request",xe),_("Teardown Response",ve),ta()].join(`
277
+ `)}function us(){return["# Precondition API \u2014 Full Reference\n\nPreconditions are named capabilities declared at the graph level and referenced by name from states.\n\nRipplo does NOT run any business logic. The user's app exposes a Precondition API with three endpoints, and Ripplo sends the precondition name in the request body.\n\n### Execution flow for each precondition:\n1. **Check**: `POST {preconditionApiPath}/check` \u2014 is it already satisfied?\n2. **Execute** (if not satisfied): `PUT {preconditionApiPath}/execute` \u2014 satisfy it\n3. Set-Cookie headers from execute responses are automatically captured and injected into the browser. All cookie attributes (Domain, Path, SameSite, HttpOnly, Secure, Expires, Max-Age) are preserved. Always include `Path=/` and an appropriate `SameSite` value on auth cookies.\n4. If the execute response includes `navigateTo`, the browser navigates to that URL after all preconditions complete (sets the starting page for the test)\n5. **Teardown** (after run): `PUT {preconditionApiPath}/teardown` \u2014 clean up (fire-and-forget)\n\nDependencies (`depends`) are resolved via topological sort with deduplication. Cycles are rejected at validation time.",B("Precondition (graph-level declaration)",_),B("Precondition Check/Execute Request",Ie),B("Check Response",se),B("Execute Response",ie),B("Teardown Request",Ee),B("Teardown Response",je),fs()].join(`
267
278
 
268
- `)}function ea(){return`### Framework-specific auth examples
279
+ `)}function ps(){return`### Framework-specific auth examples
269
280
 
270
281
  #### Supabase (with @supabase/ssr)
271
282
 
@@ -302,7 +313,7 @@ case "auth:user": {
302
313
  - Use \`signInWithPassword()\` to get session tokens after creating the user
303
314
  - Set the cookie in Supabase's expected format: \`sb-<project-ref>-auth-token\`
304
315
  - Always include \`Path=/; SameSite=Lax\` on the Set-Cookie header
305
- - The \`navigateTo\` URL sets the browser's starting page after cookies are injected`}function ta(){return`## Precondition API Setup
316
+ - The \`navigateTo\` URL sets the browser's starting page after cookies are injected`}function fs(){return`## Precondition API Setup
306
317
 
307
318
  To enable precondition execution, the user's app must expose three REST endpoints.
308
319
 
@@ -329,7 +340,7 @@ ripplo generate-types --output apps/server/src/generated/precondition-api.ts #
329
340
 
330
341
  The generated file should be committed to the repo and the \`--output\` path should be importable from the server code without path gymnastics.
331
342
 
332
- ${ra()}
343
+ ${ms()}
333
344
 
334
345
  ### Key principles:
335
346
 
@@ -339,7 +350,7 @@ ${ra()}
339
350
  4. **All logic in your app**: Ripplo just calls your endpoints.
340
351
  5. **Parallel-safe teardown**: Multiple workflows run simultaneously. Teardown must only delete data belonging to that specific run's user \u2014 use the session cookies forwarded in the teardown request to identify the user. Never bulk-delete by prefix (e.g., \`WHERE email LIKE 'ripplo-test-%'\`) \u2014 this destroys other parallel runs' active data.
341
352
 
342
- ${ea()}
353
+ ${ps()}
343
354
 
344
355
  ## Best Practices
345
356
 
@@ -350,7 +361,7 @@ ${ea()}
350
361
  5. **Keep precondition handlers fast** \u2014 check should be a lightweight query, execute should create minimal test data
351
362
  6. **Create fresh test users** \u2014 auth preconditions should create ephemeral users, not log in as shared accounts
352
363
  7. **Validate after every edit** \u2014 call \`validate_graph\` to catch missing refs and cycles
353
- 8. **Regenerate types after editing preconditions** \u2014 run \`ripplo generate-types\` when precondition names change`}function ra(){return`### Step 3: Implement the three endpoints
364
+ 8. **Regenerate types after editing preconditions** \u2014 run \`ripplo generate-types\` when precondition names change`}function ms(){return`### Step 3: Implement the three endpoints
354
365
 
355
366
  Using the generated types (adjust import path to match your \`--output\`):
356
367
 
@@ -423,19 +434,19 @@ app.put("/api/test/preconditions/teardown", async (req, res) => {
423
434
  }
424
435
  res.json({ success: true });
425
436
  });
426
- \`\`\``}import $e from"fs";import Ie from"path";import oa from"fs";import qu from"path";import{z as R}from"zod";var Ce=R.object({edges:R.array(R.object({from:R.string(),to:R.string(),workflow:R.string()})),preconditions:R.record(R.string(),R.unknown()).optional(),resetPrecondition:R.string().optional(),states:R.record(R.string(),R.object({preconditions:R.array(R.string()),route:R.string()})),version:R.literal(3)});function Bt(e){let t=oa.readFileSync(e,"utf8"),r=JSON.parse(t);return Ce.parse(r)}function Mt(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}function Gt(e){let t=na(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let r=Ce.safeParse(t.data);if(!r.success)return{errors:r.error.issues.map(m=>({message:m.message,path:m.path.join(".")})),valid:!1};let n=Mt(r.data),o=Te(n);if(!o.success)return{errors:o.errors,valid:!1};let s=[...Ne(o.data)],l=Ie.join(Ie.dirname(e),"workflows"),c=$e.existsSync(l),i=new Set(o.data.edges.map(d=>d.workflow));return o.data.edges.forEach((d,m)=>{if(!c){s.push({message:`References workflow "${d.workflow}" but workflows directory does not exist`,path:`edges[${String(m)}].workflow`});return}let I=Ie.join(l,`${d.workflow}.json`);$e.existsSync(I)||s.push({message:`References workflow "${d.workflow}" but no file exists at workflows/${d.workflow}.json`,path:`edges[${String(m)}].workflow`})}),c&&$e.readdirSync(l).filter(d=>d.endsWith(".json")).forEach(d=>{let m=d.replace(/\.json$/,"");i.has(m)||s.push({message:`Workflow file "workflows/${d}" is not referenced by any edge`,path:`workflows/${d}`})}),{errors:s,valid:s.length===0}}function na(e){try{return{data:Bt(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}import ie from"fs";import zt from"path";import{z as A}from"zod";var aa=A.object({baseUrl:A.string().optional(),cloudBaseUrl:A.string(),preconditionApiPath:A.string().optional(),projectId:A.string()});function Ht(e){let t=zt.join(e,".ripplo","settings.json");if(!ie.existsSync(t))return{errors:[{message:".ripplo/settings.json not found",path:""}],valid:!1,warnings:[]};let r=la(t);if(!r.success)return{errors:[{message:r.error,path:"settings.json"}],valid:!1,warnings:[]};let n=aa.safeParse(r.data);if(!n.success)return{errors:n.error.issues.map(c=>({message:c.message,path:c.path.join(".")})),valid:!1,warnings:[]};let o=[],s=zt.join(e,".ripplo","graph.json");return ie.existsSync(s)&&ia(s)&&(n.data.preconditionApiPath==null||n.data.preconditionApiPath.length===0)&&o.push("Graph has preconditions but preconditionApiPath is not set in settings.json. Preconditions will not be executed. Set preconditionApiPath to the URL where your app serves precondition endpoints (can be a relative path appended to baseUrl, or an absolute URL)."),{errors:[],valid:!0,warnings:o}}var sa=A.object({states:A.record(A.string(),A.object({preconditions:A.array(A.string())}))});function ia(e){try{let t=ie.readFileSync(e,"utf8"),r=JSON.parse(t),n=sa.safeParse(r);return n.success?Object.values(n.data.states).some(o=>o.preconditions.length>0):!1}catch{return!1}}function la(e){try{let t=ie.readFileSync(e,"utf8");return{data:JSON.parse(t),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}var Jt={assertAttribute:"assertion",assertCount:"assertion",assertDisabled:"assertion",assertEnabled:"assertion",assertNotVisible:"assertion",assertText:"assertion",assertUrl:"assertion",assertValue:"assertion",assertVisible:"assertion",check:"action",click:"action",dblclick:"action",drag:"action",extractText:"other",fail:"other",fill:"action",focus:"action",forEach:"controlFlow",goto:"other",group:"controlFlow",hover:"action",if:"controlFlow",loop:"controlFlow",parallel:"controlFlow",press:"action",screenshot:"other",scrollIntoView:"action",select:"action",setVariable:"other",setViewport:"other",try:"controlFlow",type:"action",uncheck:"action",upload:"action",wait:"other",waitFor:"other",waitForRequest:"other",waitForResponse:"other",waitForUrl:"other"},le=new Set,Ee=new Set;Object.entries(Jt).forEach(([e,t])=>{t==="assertion"&&le.add(e),t==="action"&&Ee.add(e)});function Kt(e){let t=ae(e),{spec:r}=t,n=ma(r),o=ha(r),s=ca({orderedNodes:n,spec:r,terminalNodes:o}),l=Sa({flags:s,orderedNodes:n,terminalNodes:o,wf:t});return{flags:s,report:l}}function ca({orderedNodes:e,spec:t,terminalNodes:r}){let n=e.filter(c=>le.has(c.type)).length,o=e.filter(c=>Ee.has(c.type)).length,s=Object.keys(t.nodes).length,l=r.some(c=>le.has(c.type));return[...da(n),...ua(l,n),...pa(o),...fa(n,s)]}function da(e){return e===0?["NO_ASSERTIONS: The workflow has zero assertion nodes. It cannot verify its expectedOutcome."]:[]}function ua(e,t){return!e&&t>0?["NO_TERMINAL_ASSERTION: No terminal node (end of flow) is an assertion. The workflow may not verify the final state."]:[]}function pa(e){return e===0?["NO_INTERACTIONS: The workflow has zero interaction nodes (click, fill, select, etc.). It does not exercise any user action."]:[]}function fa(e,t){if(e>0&&t>3){let r=e/t;if(r<.15){let n=String(Math.round(r*100));return[`LOW_ASSERTION_RATIO: Only ${String(e)}/${String(t)} nodes are assertions (${n}%). Consider adding more verification.`]}}return[]}function ma(e){let t=new Set,r=[];function n(o){if(t.has(o))return;t.add(o);let s=e.nodes[o];s!=null&&(r.push(s),s.next!=null&&n(s.next),Yt(s).forEach(l=>{n(l)}))}return n(e.entryNode),r}function Yt(e){switch(e.type){case"if":return[...e.consequent,...e.alternate??[]];case"loop":case"forEach":return[...e.body];case"try":return[...e.body,...e.catch??[],...e.finally??[]];case"group":return[...e.nodes];case"parallel":return e.branches.flat();case"assertVisible":case"assertNotVisible":case"assertText":case"assertUrl":case"assertCount":case"assertValue":case"click":case"fill":case"select":case"check":case"uncheck":case"press":case"hover":case"goto":case"waitFor":case"screenshot":case"setViewport":case"wait":case"fail":case"setVariable":case"extractText":case"waitForUrl":case"waitForResponse":case"waitForRequest":case"upload":case"dblclick":case"drag":case"scrollIntoView":case"type":case"focus":case"assertAttribute":case"assertEnabled":case"assertDisabled":return[]}}function ha(e){return Object.values(e.nodes).filter(t=>t.next!=null?!1:Yt(t).length===0)}function w(e){return e.by==="role"?e.name==null?`role=${e.role}`:`role=${e.role}[${e.name}]`:`${e.by}=${e.value}`}function C(e){return e.type==="static"?`"${e.value}"`:`{{${e.name}}}`}function ga(e){return e.type==="static"?String(e.value):`{{${e.name}}}`}var Qt=new Set,Xt=new Set;Object.entries(Jt).forEach(([e,t])=>{t==="controlFlow"&&Qt.add(e),t==="assertion"&&Xt.add(e)});function Zt(e){let t=`[${e.type}]`;return Qt.has(e.type)?ba(e,t):Xt.has(e.type)?wa(e,t):ya(e,t)}function ya(e,t){let r=e;switch(r.type){case"goto":return`${t} Navigate to ${C(r.url)}`;case"click":return`${t} click ${w(r.locator)}`;case"hover":return`${t} hover ${w(r.locator)}`;case"check":return`${t} check ${w(r.locator)}`;case"uncheck":return`${t} uncheck ${w(r.locator)}`;case"fill":return`${t} Fill ${w(r.locator)} with ${C(r.value)}`;case"select":return`${t} Select ${C(r.value)} in ${w(r.locator)}`;case"press":return`${t} Press "${r.key}"`;case"waitFor":{let n=r.state==null?"":` to be ${r.state}`;return`${t} Wait for ${w(r.locator)}${n}`}case"waitForUrl":return`${t} Wait for URL ${r.operator} ${C(r.expected)}`;case"waitForResponse":return`${t} Wait for response matching ${C(r.urlPattern)}`;case"waitForRequest":return`${t} Wait for request matching ${C(r.urlPattern)}`;case"extractText":return`${t} Extract text from ${w(r.locator)} into $${r.variable}`;case"screenshot":return`${t} screenshot`;case"setViewport":return`${t} setViewport ${String(r.width)}x${String(r.height)}`;case"wait":return`${t} wait ${String(r.duration)}ms`;case"fail":return`${t} fail: ${r.message}`;case"setVariable":return`${t} setVariable ${r.variable}`;case"upload":return`${t} Upload files to ${w(r.locator)}`;case"dblclick":return`${t} Double-click ${w(r.locator)}`;case"drag":return`${t} Drag ${w(r.source)} to ${w(r.target)}`;case"scrollIntoView":return`${t} Scroll into view ${w(r.locator)}`;case"type":return`${t} Type ${C(r.value)} into ${w(r.locator)}`;case"focus":return`${t} Focus ${w(r.locator)}`}}function wa(e,t){let r=e;switch(r.type){case"assertVisible":return`${t} Assert visible: ${w(r.locator)}`;case"assertNotVisible":return`${t} Assert not visible: ${w(r.locator)}`;case"assertText":return`${t} Assert text of ${w(r.locator)} ${r.operator} ${C(r.expected)}`;case"assertUrl":return`${t} Assert URL ${r.operator} ${C(r.expected)}`;case"assertCount":return`${t} Assert count of ${w(r.locator)} ${r.operator} ${ga(r.expected)}`;case"assertValue":return`${t} Assert value of ${w(r.locator)} ${r.operator} ${C(r.expected)}`;case"assertAttribute":return`${t} Assert attribute "${r.attribute}" of ${w(r.locator)} ${r.operator} ${C(r.expected)}`;case"assertEnabled":return`${t} Assert enabled: ${w(r.locator)}`;case"assertDisabled":return`${t} Assert disabled: ${w(r.locator)}`}}function ba(e,t){let r=e;switch(r.type){case"if":return`${t} if (condition)`;case"loop":return`${t} loop ${String(r.times)} times`;case"forEach":return`${t} forEach ${r.iteratorVar}`;case"parallel":return`${t} parallel (${String(r.branches.length)} branches)`;case"group":return`${t} group (${String(r.nodes.length)} nodes)`;case"try":return`${t} try/catch`}}function Sa({flags:e,orderedNodes:t,terminalNodes:r,wf:n}){let o=t.filter(c=>le.has(c.type)).length,s=t.filter(c=>Ee.has(c.type)).length;return[Ra(n),ka(t),xa(r),va({actionCount:s,assertionCount:o,orderedNodes:t,terminalNodes:r}),...Pa(e),Ta].join(`
427
- `)}function Ra(e){let t=["## Declared Intent",`**Name:** ${e.name}`,`**Description:** ${e.description}`,`**Expected Outcome:** ${e.expectedOutcome}`];if(e.additionalChecks.length>0){let r=e.additionalChecks.map(n=>`- ${n}`).join(`
437
+ \`\`\``}import We from"fs";import qe from"path";import hs from"fs";import Tm from"path";import{z as k}from"zod";var De=k.object({edges:k.array(k.object({from:k.string(),to:k.string(),workflow:k.string()})),preconditions:k.record(k.string(),k.unknown()).optional(),resetPrecondition:k.string().optional(),states:k.record(k.string(),k.object({preconditions:k.array(k.string()),route:k.string()})),version:k.literal(3)});function br(e){let t=hs.readFileSync(e,"utf8"),r=JSON.parse(t);return De.parse(r)}function Sr(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}function kr(e){let t=gs(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let r=De.safeParse(t.data);if(!r.success)return{errors:r.error.issues.map(h=>({message:h.message,path:h.path.join(".")})),valid:!1};let o=Sr(r.data),n=Ve(o);if(!n.success)return{errors:n.errors,valid:!1};let s=[...Fe(n.data)],l=qe.join(qe.dirname(e),"workflows"),d=We.existsSync(l),i=new Set(n.data.edges.map(u=>u.workflow));return n.data.edges.forEach((u,h)=>{if(!d){s.push({message:`References workflow "${u.workflow}" but workflows directory does not exist`,path:`edges[${String(h)}].workflow`});return}let E=qe.join(l,`${u.workflow}.json`);We.existsSync(E)||s.push({message:`References workflow "${u.workflow}" but no file exists at workflows/${u.workflow}.json`,path:`edges[${String(h)}].workflow`})}),d&&We.readdirSync(l).filter(u=>u.endsWith(".json")).forEach(u=>{let h=u.replace(/\.json$/,"");i.has(h)||s.push({message:`Workflow file "workflows/${u}" is not referenced by any edge`,path:`workflows/${u}`})}),{errors:s,valid:s.length===0}}function gs(e){try{return{data:br(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}import pe from"fs";import Rr from"path";import{z as A}from"zod";var ys=A.object({baseUrl:A.string().optional(),cloudBaseUrl:A.string(),preconditionApiPath:A.string().optional(),projectId:A.string()});function vr(e){let t=Rr.join(e,".ripplo","settings.json");if(!pe.existsSync(t))return{errors:[{message:".ripplo/settings.json not found",path:""}],valid:!1,warnings:[]};let r=Ss(t);if(!r.success)return{errors:[{message:r.error,path:"settings.json"}],valid:!1,warnings:[]};let o=ys.safeParse(r.data);if(!o.success)return{errors:o.error.issues.map(d=>({message:d.message,path:d.path.join(".")})),valid:!1,warnings:[]};let n=[],s=Rr.join(e,".ripplo","graph.json");return pe.existsSync(s)&&bs(s)&&(o.data.preconditionApiPath==null||o.data.preconditionApiPath.length===0)&&n.push("Graph has preconditions but preconditionApiPath is not set in settings.json. Preconditions will not be executed. Set preconditionApiPath to the URL where your app serves precondition endpoints (can be a relative path appended to baseUrl, or an absolute URL)."),{errors:[],valid:!0,warnings:n}}var ws=A.object({states:A.record(A.string(),A.object({preconditions:A.array(A.string())}))});function bs(e){try{let t=pe.readFileSync(e,"utf8"),r=JSON.parse(t),o=ws.safeParse(r);return o.success?Object.values(o.data.states).some(n=>n.preconditions.length>0):!1}catch{return!1}}function Ss(e){try{let t=pe.readFileSync(e,"utf8");return{data:JSON.parse(t),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}var xr={assertAttribute:"assertion",assertChecked:"assertion",assertCookie:"assertion",assertCount:"assertion",assertDisabled:"assertion",assertEnabled:"assertion",assertFocused:"assertion",assertNotChecked:"assertion",assertNotVisible:"assertion",assertResponse:"assertion",assertText:"assertion",assertTitle:"assertion",assertUrl:"assertion",assertValue:"assertion",assertVisible:"assertion",check:"action",clear:"action",click:"action",clipboard:"other",dblclick:"action",drag:"action",extractText:"other",fail:"other",fill:"action",focus:"action",forEach:"controlFlow",goto:"other",group:"controlFlow",handleDialog:"action",hover:"action",if:"controlFlow",loop:"controlFlow",parallel:"controlFlow",press:"action",rightClick:"action",screenshot:"other",scroll:"action",scrollIntoView:"action",select:"action",setPermission:"other",setVariable:"other",setViewport:"other",try:"controlFlow",type:"action",uncheck:"action",upload:"action",wait:"other",waitFor:"other",waitForRequest:"other",waitForResponse:"other",waitForUrl:"other"},fe=new Set,Le=new Set;Object.entries(xr).forEach(([e,t])=>{t==="assertion"&&fe.add(e),t==="action"&&Le.add(e)});function Pr(e){let t=de(e),{spec:r}=t,o=Ts(r),n=Ns(r),s=ks({orderedNodes:o,spec:r,terminalNodes:n}),l=Es({flags:s,orderedNodes:o,terminalNodes:n,wf:t});return{flags:s,report:l}}function ks({orderedNodes:e,spec:t,terminalNodes:r}){let o=e.filter(d=>fe.has(d.type)).length,n=e.filter(d=>Le.has(d.type)).length,s=Object.keys(t.nodes).length,l=r.some(d=>fe.has(d.type));return[...Rs(o),...vs(l,o),...xs(n),...Ps(o,s)]}function Rs(e){return e===0?["NO_ASSERTIONS: The workflow has zero assertion nodes. It cannot verify its expectedOutcome."]:[]}function vs(e,t){return!e&&t>0?["NO_TERMINAL_ASSERTION: No terminal node (end of flow) is an assertion. The workflow may not verify the final state."]:[]}function xs(e){return e===0?["NO_INTERACTIONS: The workflow has zero interaction nodes (click, fill, select, etc.). It does not exercise any user action."]:[]}function Ps(e,t){if(e>0&&t>3){let r=e/t;if(r<.15){let o=String(Math.round(r*100));return[`LOW_ASSERTION_RATIO: Only ${String(e)}/${String(t)} nodes are assertions (${o}%). Consider adding more verification.`]}}return[]}function Ts(e){let t=new Set,r=[];function o(n){if(t.has(n))return;t.add(n);let s=e.nodes[n];s!=null&&(r.push(s),s.next!=null&&o(s.next),Tr(s).forEach(l=>{o(l)}))}return o(e.entryNode),r}function Tr(e){switch(e.type){case"if":return[...e.consequent,...e.alternate??[]];case"loop":case"forEach":return[...e.body];case"try":return[...e.body,...e.catch??[],...e.finally??[]];case"group":return[...e.nodes];case"parallel":return e.branches.flat();case"assertVisible":case"assertNotVisible":case"assertText":case"assertUrl":case"assertCount":case"assertValue":case"click":case"fill":case"select":case"check":case"uncheck":case"press":case"hover":case"goto":case"waitFor":case"screenshot":case"setViewport":case"wait":case"fail":case"setVariable":case"extractText":case"waitForUrl":case"waitForResponse":case"waitForRequest":case"upload":case"dblclick":case"drag":case"scrollIntoView":case"type":case"focus":case"assertAttribute":case"assertEnabled":case"assertDisabled":case"assertTitle":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertCookie":case"assertResponse":case"clear":case"rightClick":case"handleDialog":case"scroll":case"clipboard":case"setPermission":return[]}}function Ns(e){return Object.values(e.nodes).filter(t=>t.next!=null?!1:Tr(t).length===0)}function w(e){return e.by==="role"?e.name==null?`role=${e.role}`:`role=${e.role}[${e.name}]`:`${e.by}=${e.value}`}function $(e){return e.type==="static"?`"${e.value}"`:`{{${e.name}}}`}function Cs(e){return e.type==="static"?String(e.value):`{{${e.name}}}`}var Nr=new Set,Cr=new Set;Object.entries(xr).forEach(([e,t])=>{t==="controlFlow"&&Nr.add(e),t==="assertion"&&Cr.add(e)});function Ar(e){let t=`[${e.type}]`;return Nr.has(e.type)?Is(e,t):Cr.has(e.type)?$s(e,t):As(e,t)}function As(e,t){let r=e;switch(r.type){case"goto":return`${t} Navigate to ${$(r.url)}`;case"click":return`${t} click ${w(r.locator)}`;case"hover":return`${t} hover ${w(r.locator)}`;case"check":return`${t} check ${w(r.locator)}`;case"uncheck":return`${t} uncheck ${w(r.locator)}`;case"fill":return`${t} Fill ${w(r.locator)} with ${$(r.value)}`;case"select":return`${t} Select ${$(r.value)} in ${w(r.locator)}`;case"press":return`${t} Press "${r.key}"`;case"waitFor":{let o=r.state==null?"":` to be ${r.state}`;return`${t} Wait for ${w(r.locator)}${o}`}case"waitForUrl":return`${t} Wait for URL ${r.operator} ${$(r.expected)}`;case"waitForResponse":return`${t} Wait for response matching ${$(r.urlPattern)}`;case"waitForRequest":return`${t} Wait for request matching ${$(r.urlPattern)}`;case"extractText":return`${t} Extract text from ${w(r.locator)} into $${r.variable}`;case"screenshot":case"clipboard":return`${t} ${r.type}`;case"setViewport":return`${t} setViewport ${String(r.width)}x${String(r.height)}`;case"wait":return`${t} wait ${String(r.duration)}ms`;case"fail":return`${t} fail: ${r.message}`;case"setVariable":return`${t} setVariable ${r.variable}`;case"upload":return`${t} Upload files to ${w(r.locator)}`;case"dblclick":return`${t} Double-click ${w(r.locator)}`;case"drag":return`${t} Drag ${w(r.source)} to ${w(r.target)}`;case"scrollIntoView":return`${t} Scroll into view ${w(r.locator)}`;case"type":return`${t} Type ${$(r.value)} into ${w(r.locator)}`;case"focus":return`${t} Focus ${w(r.locator)}`;case"clear":return`${t} Clear ${w(r.locator)}`;case"rightClick":return`${t} Right-click ${w(r.locator)}`;case"handleDialog":return`${t} Handle dialog: ${r.action}`;case"scroll":return r.locator==null?`${t} Scroll page`:`${t} Scroll ${w(r.locator)}`;case"setPermission":return`${t} Set permission ${r.permission} to ${r.state}`}}function $s(e,t){let r=e;switch(r.type){case"assertVisible":return`${t} Assert visible: ${w(r.locator)}`;case"assertNotVisible":return`${t} Assert not visible: ${w(r.locator)}`;case"assertText":return`${t} Assert text of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertUrl":return`${t} Assert URL ${r.operator} ${$(r.expected)}`;case"assertCount":return`${t} Assert count of ${w(r.locator)} ${r.operator} ${Cs(r.expected)}`;case"assertValue":return`${t} Assert value of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertAttribute":return`${t} Assert attribute "${r.attribute}" of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertEnabled":return`${t} Assert enabled: ${w(r.locator)}`;case"assertDisabled":return`${t} Assert disabled: ${w(r.locator)}`}}function Is(e,t){let r=e;switch(r.type){case"if":return`${t} if (condition)`;case"loop":return`${t} loop ${String(r.times)} times`;case"forEach":return`${t} forEach ${r.iteratorVar}`;case"parallel":return`${t} parallel (${String(r.branches.length)} branches)`;case"group":return`${t} group (${String(r.nodes.length)} nodes)`;case"try":return`${t} try/catch`}}function Es({flags:e,orderedNodes:t,terminalNodes:r,wf:o}){let n=t.filter(d=>fe.has(d.type)).length,s=t.filter(d=>Le.has(d.type)).length;return[js(o),Os(t),Vs(r),Fs({actionCount:s,assertionCount:n,orderedNodes:t,terminalNodes:r}),...Us(e),Ds].join(`
438
+ `)}function js(e){let t=["## Declared Intent",`**Name:** ${e.name}`,`**Description:** ${e.description}`,`**Expected Outcome:** ${e.expectedOutcome}`];if(e.additionalChecks.length>0){let r=e.additionalChecks.map(o=>`- ${o}`).join(`
428
439
  `);t.push(`**Additional Checks:**
429
440
  ${r}`)}return t.join(`
430
- `)}function ka(e){return["","## Workflow Steps (execution order)",...e.map((r,n)=>`${String(n+1)}. ${Zt(r)}`)].join(`
431
- `)}function xa(e){return["","## Terminal Nodes (where the workflow ends)",...e.map(r=>`- ${r.id}: ${Zt(r)}`)].join(`
432
- `)}function va({actionCount:e,assertionCount:t,orderedNodes:r,terminalNodes:n}){return["","## Statistics",`- Total nodes: ${String(r.length)}`,`- Action nodes: ${String(e)}`,`- Assertion nodes: ${String(t)}`,`- Terminal nodes: ${String(n.length)}`].join(`
433
- `)}function Pa(e){return e.length===0?[]:[["","## Flags",...e.map(r=>`- ${r}`)].join(`
434
- `)]}var Ta=["","## Review Instructions","Compare the **Declared Intent** against the **Workflow Steps** and answer these questions:","","1. Does the workflow actually test the **Expected Outcome**? Look at the assertions \u2014 do they verify that the expected outcome was achieved, or do they only check intermediate states?","2. Does the workflow exercise the flow described in **Description**? Are the right forms filled, buttons clicked, and pages navigated?","3. Are there assertions after the key state-changing action (e.g., after form submission, after deletion, after creation)? The final result should be verified, not just that a button was clicked.","4. If there are **Additional Checks**, does the workflow have assertions that cover them?","5. Could this workflow pass even if the feature is broken? For example, if it only asserts a page loaded but never checks the actual outcome.","","If any answer is NO, revise the workflow to address the gap. Then call `validate_workflow` and `review_workflow` again."].join(`
435
- `);function tr(e){let t=Na(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let r=Y.safeParse(t.data);if(!r.success)return{errors:r.error.issues.map(l=>({message:l.message,path:l.path.join(".")})),valid:!1};let n=Z(r.data.spec);if(!n.success)return{errors:n.errors,valid:!1};let o=Aa(n.data);return o.length>0?{errors:o,valid:!1}:{errors:[],valid:!0}}function Na(e){try{return{data:ae(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}function Aa(e){let t=new Set(Object.keys(e.nodes)),r=[];t.has(e.entryNode)||r.push({message:`entryNode "${e.entryNode}" does not exist in nodes`,path:"entryNode"}),Object.entries(e.nodes).forEach(([l,c])=>{er(c).forEach(i=>{t.has(i.id)||r.push({message:`references non-existent node "${i.id}"`,path:`nodes.${l}.${i.field}`})})});let n=new Set,o=t.has(e.entryNode)?[e.entryNode]:[],s=0;for(;s<o.length;){let l=o[s];if(s+=1,l==null||n.has(l))continue;n.add(l);let c=e.nodes[l];c!=null&&er(c).forEach(i=>{n.has(i.id)||o.push(i.id)})}return t.forEach(l=>{n.has(l)||r.push({message:"unreachable from entryNode",path:`nodes.${l}`})}),r}function er(e){let t=[];typeof e.next=="string"&&t.push({field:"next",id:e.next}),["consequent","alternate","body","catch","finally","nodes"].forEach(o=>{let s=e[o];Array.isArray(s)&&s.forEach((l,c)=>{typeof l=="string"&&t.push({field:`${o}[${String(c)}]`,id:l})})});let n=e.branches;return Array.isArray(n)&&n.forEach((o,s)=>{Array.isArray(o)&&o.forEach((l,c)=>{typeof l=="string"&&t.push({field:`branches[${String(s)}][${String(c)}]`,id:l})})}),t}import rr from"fs";import Ca from"path";function or(e){let t=$a(),r=[`Create a Ripplo workflow spec for: ${e}`,"","1. Call get_spec_documentation to learn the workflow spec format.","2. Call get_graph_documentation to learn the state graph and precondition system."];return t?r.push("3. This is the first workflow \u2014 build a minimal graph:"," a. Create a graph with exactly 2 states (start state and end state) and 1 edge."," b. Define preconditions for whatever the source state needs (e.g. `auth:user` for logged-in pages, `data:project` for existing entities)."," c. Set `preconditionApiPath` in `.ripplo/settings.json`."," d. Write to `.ripplo/graph.json`."," e. Call validate_graph. Fix any errors."," f. Call validate_settings. Fix any warnings.","4. Read the relevant source files (routes, components, forms) to find real URLs, form fields, and button labels.","5. Set up precondition endpoints (if the source state has preconditions):"," a. Check if precondition endpoints already exist at the preconditionApiPath. If so, skip."," b. Implement the three endpoints (check, execute, teardown) \u2014 see get_precondition_schema for the API contract."," c. Read the app's auth system to understand how to create sessions programmatically (direct DB/ORM calls, not UI login)."," d. Read the data model to understand how to seed required entities."," e. Each executor should create ephemeral test data with a `ripplo-test-` prefix for easy cleanup."," f. Delegate this to a sub-agent \u2014 give it the precondition names, auth architecture, and data model summary."," g. PARALLEL SAFETY: Every execute handler must generate unique names/emails using random suffixes (e.g., `ripplo-test-${crypto.randomUUID().slice(0,8)}`). Never hardcode entity names \u2014 parallel runs will hit unique constraint violations. Return created entity IDs in the `data` response. Teardown must only delete that run's data (use session cookies to identify the user, not prefix-based bulk deletion).","6. Create .ripplo/workflows/<slug>.json with a complete spec using real locators from the code.","7. Call validate_workflow on the file. Fix any errors.","8. Call review_workflow on the file. Read the report and fix any gaps \u2014 ensure assertions verify the expectedOutcome, not just intermediate states. Re-validate after changes.","9. Call `run` with the workflow slug to run it. Report the result and include the run URL."):r.push("3. Read .ripplo/graph.json to understand existing states, edges, and preconditions.","4. Read the relevant source files (routes, components, forms) to find real URLs, form fields, and button labels.","5. Determine what preconditions this flow needs (e.g. auth, test data). If the required preconditions don't exist in graph.json:"," a. Add them to the graph's preconditions object with appropriate depends chains."," b. Add or update the state that this workflow transitions from, ensuring it lists the required preconditions."," c. Add the edge connecting the source state to the target state with the workflow slug."," d. Call validate_graph on .ripplo/graph.json. Fix any errors."," e. Call validate_settings to verify preconditionApiPath is set. Fix any warnings."," f. Check if precondition API endpoints exist at the preconditionApiPath. If not, create them following the pattern in get_precondition_schema."," g. Run ripplo generate-types to regenerate the typed schemas after adding preconditions."," h. Verify precondition executors are parallel-safe: unique data per run (random suffixes), IDs returned via `data`, teardown scoped to that run's user (not global prefix deletion).","6. Create .ripplo/workflows/<slug>.json with a complete spec using real locators from the code.","7. Call validate_workflow on the file. Fix any errors.","8. Call review_workflow on the file. Read the report and fix any gaps \u2014 ensure assertions verify the expectedOutcome, not just intermediate states. Re-validate after changes.","9. Call `run` with the workflow slug to run it. Report the result and include the run URL."),r.join(`
436
- `)}function $a(){let e=Ca.join(process.cwd(),".ripplo","workflows");return rr.existsSync(e)?!rr.readdirSync(e).some(r=>r.endsWith(".json")):!0}import ar from"fs";import Ia from"path";var z="## Iteration \u2014 run until it works\n\nYou MUST keep iterating until the workflow passes AND accomplishes the expected outcome:\n\n1. Call `run` with the workflow slug(s). Pass multiple slugs to run workflows in parallel \u2014 always preferred over calling `run` multiple times. If any fail, read the debug artifacts from `.ripplo/debug/<runId>/`.\n2. Read debug artifacts from `.ripplo/debug/<runId>/` for deeper investigation:\n - Grep `console.log` for errors/warnings around the failure timestamp.\n - Check `network.jsonl` for failed requests, unexpected status codes, or missing API responses.\n - Read `steps/<failedIndex>/dom.html` to inspect the actual DOM at the failing step.\n - Read `steps/<failedIndex>/accessibility-tree.txt` to understand page structure and find correct locators.\n - Read `steps/<failedIndex>/storage.json` to check auth state, session data, or app state.\n - Compare with `steps/<failedIndex - 1>/` to see what changed between the previous step and the failure.\n - Check `page-errors.log` for uncaught JavaScript exceptions.\n3. Identify the root cause \u2014 don't just retry. Common root causes:\n - Wrong locator (check the DOM and accessibility tree from the debug artifacts)\n - Missing waitFor before an element appears\n - Wrong URL path or missing query params\n - Missing or misconfigured precondition\n - Race condition (action fires before page transition completes)\n - Parallel-safety violation (unique constraint error, \"not authorized\" from session conflict) \u2014 precondition creates hardcoded/shared data instead of unique-per-run data, or teardown globally deletes all test data instead of only that run's data. Fix the precondition executor.\n - A bug in the user's application code (not the workflow)\n4. If the root cause is a bug in the application (not the workflow spec), report it to the user with the evidence (failed step, expected vs actual, relevant source code, debug artifact excerpts) and ask them to fix it. Do NOT work around app bugs by weakening assertions.\n5. Otherwise, fix the root cause in the workflow spec.\n6. Call `validate_workflow`, then `review_workflow`, then `run` again.\n7. When the run passes, call `review_workflow` one final time. Verify the passing run actually tests the expectedOutcome \u2014 a workflow that passes but doesn't assert the outcome is not done.\n8. If the same failure repeats after 3 targeted fixes, report the root cause to the user and ask for help. Do NOT silently give up.",nr="If the run fails, iterate:\n- Read debug artifacts from `.ripplo/debug/<runId>/` \u2014 check `console.log`, `network.jsonl`, and `steps/<failedIndex>/dom.html` for root cause clues.\n- **Bad locator**: element not found or wrong element \u2014 check `dom.html` and `accessibility-tree.txt`, re-read the component source, fix the locator in the spec, re-run.\n- **Bad assertion**: text or visibility mismatch \u2014 fix the expected value, re-run.\n- **Precondition issue**: state wasn't set up correctly \u2014 check `storage.json` for auth/session state, fix the precondition API, re-run.\n- **Parallel collision**: unique constraint error or auth failure when multiple runs execute simultaneously \u2014 precondition creates shared data or teardown nukes all test data globally. Fix executor to use unique names per run and scope teardown to that run's user/session.\n- **App-level bug**: the application itself is broken \u2014 note the failure as an app issue. Do not keep iterating on test-side fixes.\n- A workflow is done when its run **passes** or when the failure is confirmed as **app-level**.";function sr(e){return`# Debug a Failing Workflow
441
+ `)}function Os(e){return["","## Workflow Steps (execution order)",...e.map((r,o)=>`${String(o+1)}. ${Ar(r)}`)].join(`
442
+ `)}function Vs(e){return["","## Terminal Nodes (where the workflow ends)",...e.map(r=>`- ${r.id}: ${Ar(r)}`)].join(`
443
+ `)}function Fs({actionCount:e,assertionCount:t,orderedNodes:r,terminalNodes:o}){return["","## Statistics",`- Total nodes: ${String(r.length)}`,`- Action nodes: ${String(e)}`,`- Assertion nodes: ${String(t)}`,`- Terminal nodes: ${String(o.length)}`].join(`
444
+ `)}function Us(e){return e.length===0?[]:[["","## Flags",...e.map(r=>`- ${r}`)].join(`
445
+ `)]}var Ds=["","## Review Instructions","Compare the **Declared Intent** against the **Workflow Steps** and answer these questions:","","1. Does the workflow actually test the **Expected Outcome**? Look at the assertions \u2014 do they verify that the expected outcome was achieved, or do they only check intermediate states?","2. Does the workflow exercise the flow described in **Description**? Are the right forms filled, buttons clicked, and pages navigated?","3. Are there assertions after the key state-changing action (e.g., after form submission, after deletion, after creation)? The final result should be verified, not just that a button was clicked.","4. If there are **Additional Checks**, does the workflow have assertions that cover them?","5. Could this workflow pass even if the feature is broken? For example, if it only asserts a page loaded but never checks the actual outcome.","","If any answer is NO, revise the workflow to address the gap. Then call `validate_workflow` and `review_workflow` again."].join(`
446
+ `);function Ir(e){let t=Ws(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let r=ee.safeParse(t.data);if(!r.success)return{errors:r.error.issues.map(l=>({message:l.message,path:l.path.join(".")})),valid:!1};let o=ne(r.data.spec);if(!o.success)return{errors:o.errors,valid:!1};let n=qs(o.data);return n.length>0?{errors:n,valid:!1}:{errors:[],valid:!0}}function Ws(e){try{return{data:de(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}function qs(e){let t=new Set(Object.keys(e.nodes)),r=[];t.has(e.entryNode)||r.push({message:`entryNode "${e.entryNode}" does not exist in nodes`,path:"entryNode"}),Object.entries(e.nodes).forEach(([l,d])=>{$r(d).forEach(i=>{t.has(i.id)||r.push({message:`references non-existent node "${i.id}"`,path:`nodes.${l}.${i.field}`})})});let o=new Set,n=t.has(e.entryNode)?[e.entryNode]:[],s=0;for(;s<n.length;){let l=n[s];if(s+=1,l==null||o.has(l))continue;o.add(l);let d=e.nodes[l];d!=null&&$r(d).forEach(i=>{o.has(i.id)||n.push(i.id)})}return t.forEach(l=>{o.has(l)||r.push({message:"unreachable from entryNode",path:`nodes.${l}`})}),r}function $r(e){let t=[];typeof e.next=="string"&&t.push({field:"next",id:e.next}),["consequent","alternate","body","catch","finally","nodes"].forEach(n=>{let s=e[n];Array.isArray(s)&&s.forEach((l,d)=>{typeof l=="string"&&t.push({field:`${n}[${String(d)}]`,id:l})})});let o=e.branches;return Array.isArray(o)&&o.forEach((n,s)=>{Array.isArray(n)&&n.forEach((l,d)=>{typeof l=="string"&&t.push({field:`branches[${String(s)}][${String(d)}]`,id:l})})}),t}import Er from"fs";import Ls from"path";function jr(e){let t=_s(),r=[`Create a Ripplo workflow spec for: ${e}`,"","1. Call get_spec_documentation to learn the workflow spec format.","2. Call get_graph_documentation to learn the state graph and precondition system."];return t?r.push("3. This is the first workflow \u2014 build a minimal graph:"," a. Create a graph with exactly 2 states (start state and end state) and 1 edge."," b. Define preconditions for whatever the source state needs (e.g. `auth:user` for logged-in pages, `data:project` for existing entities)."," c. Set `preconditionApiPath` in `.ripplo/settings.json`."," d. Write to `.ripplo/graph.json`."," e. Call validate_graph. Fix any errors."," f. Call validate_settings. Fix any warnings.","4. Read the relevant source files (routes, components, forms) to find real URLs, form fields, and button labels.","5. Set up precondition endpoints (if the source state has preconditions):"," a. Check if precondition endpoints already exist at the preconditionApiPath. If so, skip."," b. Implement the three endpoints (check, execute, teardown) \u2014 see get_precondition_schema for the API contract."," c. Read the app's auth system to understand how to create sessions programmatically (direct DB/ORM calls, not UI login)."," d. Read the data model to understand how to seed required entities."," e. Each executor should create ephemeral test data with a `ripplo-test-` prefix for easy cleanup."," f. Delegate this to a sub-agent \u2014 give it the precondition names, auth architecture, and data model summary."," g. PARALLEL SAFETY: Every execute handler must generate unique names/emails using random suffixes (e.g., `ripplo-test-${crypto.randomUUID().slice(0,8)}`). Never hardcode entity names \u2014 parallel runs will hit unique constraint violations. Return created entity IDs in the `data` response. Teardown must only delete that run's data (use session cookies to identify the user, not prefix-based bulk deletion).","6. Create .ripplo/workflows/<slug>.json with a complete spec using real locators from the code.","7. Call validate_workflow on the file. Fix any errors.","8. Call review_workflow on the file. Read the report and fix any gaps \u2014 ensure assertions verify the expectedOutcome, not just intermediate states. Re-validate after changes.","9. Call `run` with the workflow slug to run it. Report the result and include the run URL."):r.push("3. Read .ripplo/graph.json to understand existing states, edges, and preconditions.","4. Read the relevant source files (routes, components, forms) to find real URLs, form fields, and button labels.","5. Determine what preconditions this flow needs (e.g. auth, test data). If the required preconditions don't exist in graph.json:"," a. Add them to the graph's preconditions object with appropriate depends chains."," b. Add or update the state that this workflow transitions from, ensuring it lists the required preconditions."," c. Add the edge connecting the source state to the target state with the workflow slug."," d. Call validate_graph on .ripplo/graph.json. Fix any errors."," e. Call validate_settings to verify preconditionApiPath is set. Fix any warnings."," f. Check if precondition API endpoints exist at the preconditionApiPath. If not, create them following the pattern in get_precondition_schema."," g. Run ripplo generate-types to regenerate the typed schemas after adding preconditions."," h. Verify precondition executors are parallel-safe: unique data per run (random suffixes), IDs returned via `data`, teardown scoped to that run's user (not global prefix deletion).","6. Create .ripplo/workflows/<slug>.json with a complete spec using real locators from the code.","7. Call validate_workflow on the file. Fix any errors.","8. Call review_workflow on the file. Read the report and fix any gaps \u2014 ensure assertions verify the expectedOutcome, not just intermediate states. Re-validate after changes.","9. Call `run` with the workflow slug to run it. Report the result and include the run URL."),r.join(`
447
+ `)}function _s(){let e=Ls.join(process.cwd(),".ripplo","workflows");return Er.existsSync(e)?!Er.readdirSync(e).some(r=>r.endsWith(".json")):!0}import Vr from"fs";import Bs from"path";var K="## Iteration \u2014 run until it works\n\nYou MUST keep iterating until the workflow passes AND accomplishes the expected outcome:\n\n1. Call `run` with the workflow slug(s). Pass multiple slugs to run workflows in parallel \u2014 always preferred over calling `run` multiple times. If any fail, read the debug artifacts from `.ripplo/debug/<runId>/`.\n2. Read debug artifacts from `.ripplo/debug/<runId>/` for deeper investigation:\n - Grep `console.log` for errors/warnings around the failure timestamp.\n - Check `network.jsonl` for failed requests, unexpected status codes, or missing API responses.\n - Read `steps/<failedIndex>/dom.html` to inspect the actual DOM at the failing step.\n - Read `steps/<failedIndex>/accessibility-tree.txt` to understand page structure and find correct locators.\n - Read `steps/<failedIndex>/storage.json` to check auth state, session data, or app state.\n - Compare with `steps/<failedIndex - 1>/` to see what changed between the previous step and the failure.\n - Check `page-errors.log` for uncaught JavaScript exceptions.\n3. Identify the root cause \u2014 don't just retry. Common root causes:\n - Wrong locator (check the DOM and accessibility tree from the debug artifacts)\n - Missing waitFor before an element appears\n - Wrong URL path or missing query params\n - Missing or misconfigured precondition\n - Race condition (action fires before page transition completes)\n - Parallel-safety violation (unique constraint error, \"not authorized\" from session conflict) \u2014 precondition creates hardcoded/shared data instead of unique-per-run data, or teardown globally deletes all test data instead of only that run's data. Fix the precondition executor.\n - A bug in the user's application code (not the workflow)\n4. If the root cause is a bug in the application (not the workflow spec), report it to the user with the evidence (failed step, expected vs actual, relevant source code, debug artifact excerpts) and ask them to fix it. Do NOT work around app bugs by weakening assertions.\n5. Otherwise, fix the root cause in the workflow spec.\n6. Call `validate_workflow`, then `review_workflow`, then `run` again.\n7. When the run passes, call `review_workflow` one final time. Verify the passing run actually tests the expectedOutcome \u2014 a workflow that passes but doesn't assert the outcome is not done.\n8. If the same failure repeats after 3 targeted fixes, report the root cause to the user and ask for help. Do NOT silently give up.",Or="If the run fails, iterate:\n- Read debug artifacts from `.ripplo/debug/<runId>/` \u2014 check `console.log`, `network.jsonl`, and `steps/<failedIndex>/dom.html` for root cause clues.\n- **Bad locator**: element not found or wrong element \u2014 check `dom.html` and `accessibility-tree.txt`, re-read the component source, fix the locator in the spec, re-run.\n- **Bad assertion**: text or visibility mismatch \u2014 fix the expected value, re-run.\n- **Precondition issue**: state wasn't set up correctly \u2014 check `storage.json` for auth/session state, fix the precondition API, re-run.\n- **Parallel collision**: unique constraint error or auth failure when multiple runs execute simultaneously \u2014 precondition creates shared data or teardown nukes all test data globally. Fix executor to use unique names per run and scope teardown to that run's user/session.\n- **App-level bug**: the application itself is broken \u2014 note the failure as an app issue. Do not keep iterating on test-side fixes.\n- A workflow is done when its run **passes** or when the failure is confirmed as **app-level**.";function Fr(e){return`# Debug a Failing Workflow
437
448
 
438
- ${Ea(e)}
449
+ ${Ms(e)}
439
450
 
440
451
  ## Step 1: Trigger a fresh run
441
452
 
@@ -482,7 +493,7 @@ Categorize the root cause:
482
493
 
483
494
  ## Step 4: Fix and re-run
484
495
 
485
- ${z}
496
+ ${K}
486
497
 
487
498
  ## Important rules
488
499
 
@@ -490,15 +501,15 @@ ${z}
490
501
  - **Evidence before changes.** Never modify the spec without citing specific evidence from the debug artifacts.
491
502
  - **Compare steps.** When a failure is unclear, diff the DOM/storage between the step before and the failing step.
492
503
  - **Check the network.** If the app returns unexpected API responses (check network.jsonl), this is likely an app bug, not a spec issue.
493
- - **Report app bugs clearly.** Include: the failing step, what the spec expected, what actually happened, the relevant console/network evidence, and the source code if applicable.`}function Ea(e){if(e!=null)return`Debug the workflow: **${e}**
504
+ - **Report app bugs clearly.** Include: the failing step, what the spec expected, what actually happened, the relevant console/network evidence, and the source code if applicable.`}function Ms(e){if(e!=null)return`Debug the workflow: **${e}**
494
505
 
495
- Find it in \`.ripplo/workflows/\`. If the name doesn't match exactly, look for a slug or partial match.`;let t=ja();return t.length===0?"No workflows found in `.ripplo/workflows/`. Create one first with `/create`.":`No specific workflow was provided. Available workflows:
506
+ Find it in \`.ripplo/workflows/\`. If the name doesn't match exactly, look for a slug or partial match.`;let t=Gs();return t.length===0?"No workflows found in `.ripplo/workflows/`. Create one first with `/create`.":`No specific workflow was provided. Available workflows:
496
507
  ${t.map(r=>`- ${r}`).join(`
497
508
  `)}
498
509
 
499
- Ask the user which workflow to debug, or pick the one most likely to be failing.`}function ja(){let e=Ia.join(process.cwd(),".ripplo","workflows");return ar.existsSync(e)?ar.readdirSync(e).filter(t=>t.endsWith(".json")).map(t=>t.replace(/\.json$/,"")):[]}function ir(e){let t=e.baseUrl==null?"IMPORTANT: No baseUrl was provided. Before writing any files, find the dev server URL from the project's config (package.json scripts, vite.config.ts, next.config.js, etc.) and use it as baseUrl in every graph and workflow file.":`The application base URL is: ${e.baseUrl}`;return e.scope!=null?Va({baseUrlInstruction:t,scope:e.scope}):[Fa(t),Ua(),Da(),Wa(),_a(),qa(),La(),Ba()].join(`
510
+ Ask the user which workflow to debug, or pick the one most likely to be failing.`}function Gs(){let e=Bs.join(process.cwd(),".ripplo","workflows");return Vr.existsSync(e)?Vr.readdirSync(e).filter(t=>t.endsWith(".json")).map(t=>t.replace(/\.json$/,"")):[]}function Ur(e){let t=e.baseUrl==null?"IMPORTANT: No baseUrl was provided. Before writing any files, find the dev server URL from the project's config (package.json scripts, vite.config.ts, next.config.js, etc.) and use it as baseUrl in every graph and workflow file.":`The application base URL is: ${e.baseUrl}`;return e.scope!=null?zs({baseUrlInstruction:t,scope:e.scope}):[Js(t),Ks(),Ys(),Qs(),ei(),Xs(),Zs(),ti()].join(`
500
511
 
501
- `)}function Va(e){let t=Oa(e.scope);return`# Ripplo Explore (Scoped to Changes)
512
+ `)}function zs(e){let t=Hs(e.scope);return`# Ripplo Explore (Scoped to Changes)
502
513
 
503
514
  Analyze code changes and create or update workflow specs to test the affected user flows.
504
515
 
@@ -555,7 +566,7 @@ For each confirmed flow, delegate to a sub-agent:
555
566
  6. Call \`review_workflow\` on the file. Read the report and fix any gaps \u2014 ensure assertions verify the expectedOutcome, not just intermediate states. Re-validate after changes.
556
567
  7. Call \`run\` with the workflow slug. Report the result and include the run URL.
557
568
 
558
- ${z}
569
+ ${K}
559
570
 
560
571
  ## Step 5: Report summary
561
572
 
@@ -563,7 +574,7 @@ After all workflows are processed, report:
563
574
  - Total workflows created/updated
564
575
  - Pass/fail status for each
565
576
  - Any flows that need user attention (app bugs, unresolvable failures)
566
- - Any flows that were skipped and why`}function Oa(e){return`The user provided this context: "${e}"
577
+ - Any flows that were skipped and why`}function Hs(e){return`The user provided this context: "${e}"
567
578
  - If it looks like a PR number or URL, run \`gh pr diff <number>\` and \`gh pr view <number>\` to get the changes and description.
568
579
  - If it looks like a branch name, run \`git diff main...<branch> --stat\` to see what changed.
569
580
  - If it equals "changes" or is empty, auto-detect:
@@ -571,7 +582,7 @@ After all workflows are processed, report:
571
582
  - If there are uncommitted changes, use those as the diff.
572
583
  - Otherwise, run \`git diff main...HEAD --stat\` to see what changed on this branch vs main.
573
584
  - If on main with no changes, ask the user what they'd like to create workflows for.
574
- - Otherwise, treat it as a description and run \`git diff main...HEAD --stat\` to find relevant changes.`}function Fa(e){return`# Ripplo Explore
585
+ - Otherwise, treat it as a description and run \`git diff main...HEAD --stat\` to find relevant changes.`}function Js(e){return`# Ripplo Explore
575
586
 
576
587
  Build a comprehensive state graph and workflow specs for this application.
577
588
 
@@ -607,7 +618,7 @@ This is a large task. **Aggressively delegate to sub-agents** to keep the main c
607
618
  - **Workflow generation**: Always use sub-agents for writing workflow specs. Launch them in parallel batches.
608
619
  - **Precondition API implementation**: Delegate endpoint implementation entirely to a sub-agent. Give it the graph's precondition names, the auth/data architecture summary from exploration, and let it handle reading source code, writing handlers, and wiring up the codegen. Do NOT read app source code for endpoint implementation in the main context.
609
620
  - **General rule**: If a task involves reading more than 2-3 files or writing more than one file, it should be a sub-agent.
610
- - **Recursive sub-agents**: Sub-agents should spawn their own sub-agents when they hit something that needs deeper exploration. An exploration agent that discovers a complex auth middleware layer should spawn a deeper agent to trace it fully. A workflow generation agent that needs to understand a component tree should spawn an agent to map it. There is no depth limit \u2014 go as deep as needed to get complete, accurate results. Each level returns a structured summary to its parent.`}function Ua(){return`## Understanding the application
621
+ - **Recursive sub-agents**: Sub-agents should spawn their own sub-agents when they hit something that needs deeper exploration. An exploration agent that discovers a complex auth middleware layer should spawn a deeper agent to trace it fully. A workflow generation agent that needs to understand a component tree should spawn an agent to map it. There is no depth limit \u2014 go as deep as needed to get complete, accurate results. Each level returns a structured summary to its parent.`}function Ks(){return`## Understanding the application
611
622
 
612
623
  Explore the codebase deeply enough to discover every testable surface. **Use sub-agents for all exploration** \u2014 the main context should not read source files directly during discovery. Launch exploration agents in parallel where possible, and have each return a structured summary (routes found, components found, entities found, etc.) rather than raw file contents.
613
624
 
@@ -681,7 +692,7 @@ Map every write operation to its UI trigger:
681
692
  - Which UI component triggers each mutation
682
693
  - Form actions (if using framework form actions)
683
694
  - Optimistic updates and their rollback behavior
684
- - Which mutations are restricted to which roles`}function Da(){return`## Extracting edges
695
+ - Which mutations are restricted to which roles`}function Ys(){return`## Extracting edges
685
696
 
686
697
  From everything discovered, extract EVERY meaningful user journey as an edge.
687
698
 
@@ -709,7 +720,7 @@ Before building the graph, verify completeness:
709
720
  - **Component coverage**: Is every interactive component from the inventory covered by at least one edge? If not, add an edge or note why it's excluded.
710
721
  - **Entity coverage**: For every core entity, is there a create, update, and delete edge? Missing CRUD operations are coverage gaps.
711
722
  - **Role coverage**: If the app has multiple roles, are role-specific actions covered? (e.g., "admin can invite members" vs "member cannot")
712
- - **Empty/conditional state coverage**: Are empty states and conditional branches covered? (e.g., "first project creation from empty state" vs "additional project from populated list")`}function Wa(){return"## Building the graph\n\n1. Call `get_graph_documentation` to learn the schema (includes JSON Schema generated from the Zod types).\n2. Define **preconditions** at the graph level for every auth role and data requirement discovered. Name them with category prefixes: `auth:admin`, `auth:viewer`, `data:projects`, `data:empty-state`. Use `depends` when one precondition requires another (e.g., `data:three-projects` depends on `auth:admin`).\n3. Define **states** for every unique application context. Two states at the same route are distinct if they have different available edges or different UI (e.g., empty list vs populated list, dialog open vs closed). Each state references its preconditions by name.\n4. Define **edges** connecting states \u2014 one per user journey.\n5. Set `preconditionApiPath` in `.ripplo/settings.json` to where the app's precondition endpoints will live. Can be a relative path (appended to `baseUrl`) or an absolute URL.\n6. Write to `.ripplo/graph.json`, call `validate_graph`, fix errors.\n7. Call `validate_settings` to verify `preconditionApiPath` is set. Fix any warnings."}function qa(){return`## Bootstrap: verify preconditions with one workflow
723
+ - **Empty/conditional state coverage**: Are empty states and conditional branches covered? (e.g., "first project creation from empty state" vs "additional project from populated list")`}function Qs(){return"## Building the graph\n\n1. Call `get_graph_documentation` to learn the schema (includes JSON Schema generated from the Zod types).\n2. Define **preconditions** at the graph level for every auth role and data requirement discovered. Name them with category prefixes: `auth:admin`, `auth:viewer`, `data:projects`, `data:empty-state`. Use `depends` when one precondition requires another (e.g., `data:three-projects` depends on `auth:admin`).\n3. Define **states** for every unique application context. Two states at the same route are distinct if they have different available edges or different UI (e.g., empty list vs populated list, dialog open vs closed). Each state references its preconditions by name.\n4. Define **edges** connecting states \u2014 one per user journey.\n5. Set `preconditionApiPath` in `.ripplo/settings.json` to where the app's precondition endpoints will live. Can be a relative path (appended to `baseUrl`) or an absolute URL.\n6. Write to `.ripplo/graph.json`, call `validate_graph`, fix errors.\n7. Call `validate_settings` to verify `preconditionApiPath` is set. Fix any warnings."}function Xs(){return`## Bootstrap: verify preconditions with one workflow
713
724
 
714
725
  Before generating all workflows, validate that the precondition API works end-to-end.
715
726
 
@@ -723,7 +734,7 @@ Before generating all workflows, validate that the precondition API works end-to
723
734
  - **App-level bug** (the app itself is broken): note it and move on \u2014 this is not fixable from the test side.
724
735
  6. **Iterate until this first workflow passes.** This proves auth, data seeding, and the run infrastructure all work.
725
736
 
726
- **Do NOT proceed to batch workflow generation until the bootstrap workflow passes.** Every issue you fix here prevents the same failure from hitting all subsequent workflows.`}function La(){return`## Generating workflow specs
737
+ **Do NOT proceed to batch workflow generation until the bootstrap workflow passes.** Every issue you fix here prevents the same failure from hitting all subsequent workflows.`}function Zs(){return`## Generating workflow specs
727
738
 
728
739
  Each workflow spec should be a **QA-quality test plan**, not just a happy-path click sequence. Think of it like a detailed bug report: describe exactly what happens at each step, what should be visible, what state the UI should be in. A QA engineer should be able to read the spec and know exactly what to verify.
729
740
 
@@ -767,7 +778,7 @@ For each edge, create and verify a workflow spec:
767
778
  5. Call \`validate_workflow\`, fix errors.
768
779
  6. **Call \`run\` with the workflow slug.** This is mandatory \u2014 never skip it. After generating a batch, use \`run\` with all slugs from the batch to run them simultaneously.
769
780
  7. **Inspect the result.** Read debug artifacts from \`.ripplo/debug/<runId>/\` \u2014 check \`summary.txt\`, \`console.log\`, and \`steps/<failedIndex>/\` for DOM, storage, and screenshots.
770
- 8. ${nr}
781
+ 8. ${Or}
771
782
 
772
783
  ### Parallelism
773
784
 
@@ -781,7 +792,7 @@ Each sub-agent should receive: edge details, component file paths, action sequen
781
792
 
782
793
  ### Final summary
783
794
 
784
- Report: total states, total edges, workflows generated, **pass/fail per workflow**, and any app-level bugs discovered. Group failures by cause (locator issues, precondition issues, app bugs).`}function _a(){return`## Wiring up the Precondition API
795
+ Report: total states, total edges, workflows generated, **pass/fail per workflow**, and any app-level bugs discovered. Group failures by cause (locator issues, precondition issues, app bugs).`}function ei(){return`## Wiring up the Precondition API
785
796
 
786
797
  Once the graph is complete, wire up precondition endpoints **before** generating any workflow specs. The app needs these so Ripplo can check and execute preconditions at runtime.
787
798
 
@@ -841,17 +852,17 @@ Multiple workflows run simultaneously. Every precondition executor must create *
841
852
 
842
853
  ### Step 3: Verify
843
854
 
844
- Ensure \`preconditionApiPath\` is set in \`.ripplo/settings.json\` to point to the endpoints (e.g., \`"preconditionApiPath": "http://localhost:3000/api/test/preconditions"\`). Can be a relative path (appended to \`baseUrl\`) or an absolute URL. The precondition runner will call these endpoints during test execution.`}function Ba(){return'## Rules\n\n- Value references use `"type": "static"`, never `"type": "literal"`\n- Goto node URLs must be relative paths (`/projects`), never absolute URLs\n- Graph files use `version: 3`, workflow spec files use `version: 2`\n- IDs must match their object keys (state ID = its key in the states object)\n- Call `validate_graph` / `validate_workflow` after every edit \u2014 don\'t batch without validation\n- Workflow filenames should match their edge IDs\n- Prefer locator stability: testId > role > label > text > css\n- State names should be descriptive and encode what\'s unique: `projects-list-empty`, `create-workflow-dialog-open`, `member-role-updated` \u2014 never `state-1` or `page-loaded`'}function lr(){let e=new Ma({name:"ripplo",version:"0.1.0"});return Ga(e),za(e),Ha(e),Ja(e),Ka(e),e}function Ga(e){e.registerTool("validate_workflow",{description:"Validate a workflow spec file. MUST be called after every edit to a .ripplo/workflows/*.json file. Returns validation errors if the spec is invalid.",inputSchema:{file:T.string().describe("Absolute path to the workflow JSON file")}},t=>{let r=tr(t.file);if(r.valid)return k("Valid");let n=r.errors.map(o=>`${o.path}: ${o.message}`);return k(`Invalid:
845
- ${n.join(`
846
- `)}`)}),e.registerTool("get_spec_documentation",{description:"Returns a compact summary of all node types with their fields, locator types, operators, and value ref formats. Start here before creating or editing workflow specs. Use get_node_schema for full JSON Schema of specific types."},()=>k(Vt())),e.registerTool("get_node_schema",{description:"Returns full JSON Schemas for one or more node types. Pass an array of type names (e.g. ['click', 'fill', 'assertText']). Includes referenced sub-schemas (locators, operators, value refs) automatically. Call after get_spec_documentation when you need exact node shapes.",inputSchema:{nodeTypes:T.array(T.string()).min(1).describe("Node type names to get schemas for (e.g. ['click', 'fill'])")}},t=>k(Ot({nodeTypes:t.nodeTypes}))),e.registerTool("get_spec_patterns",{description:"Returns full JSON Schemas for shared building blocks: locators, conditions, value references, operators, and variables. Plus best practices for writing specs."},()=>k(Ft())),e.registerTool("review_workflow",{description:"Review the semantic quality of a workflow spec. Call AFTER validate_workflow passes. Analyzes whether the workflow actually tests what it claims \u2014 checks assertions against expectedOutcome, verifies the flow exercises the described behavior, and flags gaps. Returns a structured report for you to review and act on.",inputSchema:{file:T.string().describe("Absolute path to the workflow JSON file")}},t=>{let r=Kt(t.file),n=r.flags.length===0?"PASS":"NEEDS REVIEW";return k(`${n}
855
+ Ensure \`preconditionApiPath\` is set in \`.ripplo/settings.json\` to point to the endpoints (e.g., \`"preconditionApiPath": "http://localhost:3000/api/test/preconditions"\`). Can be a relative path (appended to \`baseUrl\`) or an absolute URL. The precondition runner will call these endpoints during test execution.`}function ti(){return'## Rules\n\n- Value references use `"type": "static"`, never `"type": "literal"`\n- Goto node URLs must be relative paths (`/projects`), never absolute URLs\n- Graph files use `version: 3`, workflow spec files use `version: 2`\n- IDs must match their object keys (state ID = its key in the states object)\n- Call `validate_graph` / `validate_workflow` after every edit \u2014 don\'t batch without validation\n- Workflow filenames should match their edge IDs\n- Prefer locator stability: testId > role > label > text > css\n- State names should be descriptive and encode what\'s unique: `projects-list-empty`, `create-workflow-dialog-open`, `member-role-updated` \u2014 never `state-1` or `page-loaded`'}function Dr(){let e=new ri({name:"ripplo",version:"0.1.0"});return oi(e),ni(e),ai(e),si(e),ii(e),e}function oi(e){e.registerTool("validate_workflow",{description:"Validate a workflow spec file. MUST be called after every edit to a .ripplo/workflows/*.json file. Returns validation errors if the spec is invalid.",inputSchema:{file:T.string().describe("Absolute path to the workflow JSON file")}},t=>{let r=Ir(t.file);if(r.valid)return v("Valid");let o=r.errors.map(n=>`${n.path}: ${n.message}`);return v(`Invalid:
856
+ ${o.join(`
857
+ `)}`)}),e.registerTool("get_spec_documentation",{description:"Returns a compact summary of all node types with their fields, locator types, operators, and value ref formats. Start here before creating or editing workflow specs. Use get_node_schema for full JSON Schema of specific types."},()=>v(dr())),e.registerTool("get_node_schema",{description:"Returns full JSON Schemas for one or more node types. Pass an array of type names (e.g. ['click', 'fill', 'assertText']). Includes referenced sub-schemas (locators, operators, value refs) automatically. Call after get_spec_documentation when you need exact node shapes.",inputSchema:{nodeTypes:T.array(T.string()).min(1).describe("Node type names to get schemas for (e.g. ['click', 'fill'])")}},t=>v(ur({nodeTypes:t.nodeTypes}))),e.registerTool("get_spec_patterns",{description:"Returns full JSON Schemas for shared building blocks: locators, conditions, value references, operators, and variables. Plus best practices for writing specs."},()=>v(pr())),e.registerTool("review_workflow",{description:"Review the semantic quality of a workflow spec. Call AFTER validate_workflow passes. Analyzes whether the workflow actually tests what it claims \u2014 checks assertions against expectedOutcome, verifies the flow exercises the described behavior, and flags gaps. Returns a structured report for you to review and act on.",inputSchema:{file:T.string().describe("Absolute path to the workflow JSON file")}},t=>{let r=Pr(t.file),o=r.flags.length===0?"PASS":"NEEDS REVIEW";return v(`${o}
847
858
 
848
- ${r.report}`)})}function za(e){e.registerTool("get_graph_documentation",{description:"Returns the state graph schema and a summary of the precondition system. Start here before creating or editing graph files. Use get_precondition_schema for full precondition API details."},()=>k(Lt())),e.registerTool("get_precondition_schema",{description:"Returns full precondition API schemas, setup guide, framework-specific auth examples, and best practices. Call when implementing precondition endpoints."},()=>k(_t())),e.registerTool("validate_graph",{description:"Validate the state graph file. MUST be called after every edit to .ripplo/graph.json.",inputSchema:{file:T.string().describe("Absolute path to the graph JSON file")}},t=>{let r=Gt(t.file);if(r.valid)return k("Valid");let n=r.errors.map(o=>`${o.path}: ${o.message}`);return k(`Invalid:
849
- ${n.join(`
850
- `)}`)}),e.registerTool("validate_settings",{description:"Validate .ripplo/settings.json. Checks required fields and warns if preconditionApiPath is missing when the graph has preconditions. Call after editing settings or after adding preconditions to the graph.",inputSchema:{dir:T.string().optional().describe("Working directory (defaults to cwd)")}},t=>{let r=Ht(t.dir??process.cwd());if(r.valid){let o=r.warnings.length>0?`
859
+ ${r.report}`)})}function ni(e){e.registerTool("get_graph_documentation",{description:"Returns the state graph schema and a summary of the precondition system. Start here before creating or editing graph files. Use get_precondition_schema for full precondition API details."},()=>v(yr())),e.registerTool("get_precondition_schema",{description:"Returns full precondition API schemas, setup guide, framework-specific auth examples, and best practices. Call when implementing precondition endpoints."},()=>v(wr())),e.registerTool("validate_graph",{description:"Validate the state graph file. MUST be called after every edit to .ripplo/graph.json.",inputSchema:{file:T.string().describe("Absolute path to the graph JSON file")}},t=>{let r=kr(t.file);if(r.valid)return v("Valid");let o=r.errors.map(n=>`${n.path}: ${n.message}`);return v(`Invalid:
860
+ ${o.join(`
861
+ `)}`)}),e.registerTool("validate_settings",{description:"Validate .ripplo/settings.json. Checks required fields and warns if preconditionApiPath is missing when the graph has preconditions. Call after editing settings or after adding preconditions to the graph.",inputSchema:{dir:T.string().optional().describe("Working directory (defaults to cwd)")}},t=>{let r=vr(t.dir??process.cwd());if(r.valid){let n=r.warnings.length>0?`
851
862
  Warnings:
852
863
  ${r.warnings.join(`
853
- `)}`:"";return k(`Valid${o}`)}let n=r.errors.map(o=>`${o.path}: ${o.message}`);return k(`Invalid:
854
- ${n.join(`
855
- `)}`)})}function Ha(e){e.registerPrompt("explore",{argsSchema:{baseUrl:T.string().optional().describe("Base URL of the application (e.g. http://localhost:3000)"),scope:T.string().optional().describe("Narrow exploration to code changes. Pass a PR number, branch name, 'changes' for local diff, or a description. Omit for full exhaustive exploration.")},description:"Guided flow to crawl a codebase, build a state graph, and generate workflow specs. Optionally scoped to recent code changes."},t=>({messages:[{content:{text:ir({baseUrl:t.baseUrl,scope:t.scope}),type:"text"},role:"user"}]}))}function Ja(e){e.registerTool("run",{description:"Run one or more workflows in parallel. Creates runs on the server and waits for the local dev mode agent to execute them. Multiple workflows execute concurrently. Requires `ripplo dev` to be running. Workflows are defined as JSON files in `.ripplo/workflows/` \u2014 the slug is the filename without `.json`. Results include run URLs and debug artifact paths.",inputSchema:{slugs:T.array(T.string()).describe("Workflow slugs to run (supports 1 or many, all run in parallel)")}},t=>Et(async r=>{try{let n=await qt({config:r,slugs:t.slugs});return k(n.summary)}catch(n){let o=n instanceof Error?n.message:String(n);return k(`ERROR: ${o}`)}}))}function Ka(e){e.registerPrompt("run",{argsSchema:{workflow:T.string().optional().describe("Workflow name to run (optional)")},description:"Run ripplo user flows locally using Playwright"},t=>({messages:[{content:{text:t.workflow==null?["Run all workflows in parallel:","","1. Read the `.ripplo/workflows/` directory to find all workflow JSON files. The slug is the filename without `.json`.","2. Call `run` with all slugs at once to execute them in parallel.","3. Report an aggregate summary: total run, passed, failed, and failure details.","","Do not ask any questions. Do not read workflow file contents."].join(`
856
- `):`Read \`.ripplo/workflows/\` to find the workflow named "${t.workflow}" (check the "name" field in each JSON file), then call the \`run\` tool with its slug (filename without .json). Do not ask any questions or read any files.`,type:"text"},role:"user"}]})),e.registerPrompt("create",{argsSchema:{flow:T.string().optional().describe("User flow to test (e.g. login, checkout)")},description:"Create a new Ripplo workflow spec by analyzing the codebase"},t=>({messages:[{content:{text:[or(t.flow??"the most important user flow"),"",z].join(`
857
- `),type:"text"},role:"user"}]})),e.registerPrompt("debug",{argsSchema:{workflow:T.string().optional().describe("Workflow name or slug to debug (lists available if omitted)")},description:"Debug a failing workflow \u2014 identifies root cause using browser logs, DOM, network, and storage snapshots from .ripplo/debug/"},t=>({messages:[{content:{text:sr(t.workflow),type:"text"},role:"user"}]}))}async function Qa(){let e=lr(),t=new Ya;await e.connect(t)}Qa().catch(e=>{process.exit(1)});
864
+ `)}`:"";return v(`Valid${n}`)}let o=r.errors.map(n=>`${n.path}: ${n.message}`);return v(`Invalid:
865
+ ${o.join(`
866
+ `)}`)})}function ai(e){e.registerPrompt("explore",{argsSchema:{baseUrl:T.string().optional().describe("Base URL of the application (e.g. http://localhost:3000)"),scope:T.string().optional().describe("Narrow exploration to code changes. Pass a PR number, branch name, 'changes' for local diff, or a description. Omit for full exhaustive exploration.")},description:"Guided flow to crawl a codebase, build a state graph, and generate workflow specs. Optionally scoped to recent code changes."},t=>({messages:[{content:{text:Ur({baseUrl:t.baseUrl,scope:t.scope}),type:"text"},role:"user"}]}))}function si(e){e.registerTool("run",{description:"Run one or more workflows in parallel. Creates runs on the server and waits for the local dev mode agent to execute them. Multiple workflows execute concurrently. Requires `ripplo dev` to be running. Workflows are defined as JSON files in `.ripplo/workflows/` \u2014 the slug is the filename without `.json`. Results include run URLs and debug artifact paths.",inputSchema:{slugs:T.array(T.string()).describe("Workflow slugs to run (supports 1 or many, all run in parallel)")}},t=>lr(async r=>{try{let o=await gr({config:r,slugs:t.slugs});return v(o.summary)}catch(o){let n=o instanceof Error?o.message:String(o);return v(`ERROR: ${n}`)}}))}function ii(e){e.registerPrompt("run",{argsSchema:{workflow:T.string().optional().describe("Workflow name to run (optional)")},description:"Run ripplo user flows locally using Playwright"},t=>({messages:[{content:{text:t.workflow==null?["Run all workflows in parallel:","","1. Read the `.ripplo/workflows/` directory to find all workflow JSON files. The slug is the filename without `.json`.","2. Call `run` with all slugs at once to execute them in parallel.","3. Report an aggregate summary: total run, passed, failed, and failure details.","","Do not ask any questions. Do not read workflow file contents."].join(`
867
+ `):`Read \`.ripplo/workflows/\` to find the workflow named "${t.workflow}" (check the "name" field in each JSON file), then call the \`run\` tool with its slug (filename without .json). Do not ask any questions or read any files.`,type:"text"},role:"user"}]})),e.registerPrompt("create",{argsSchema:{flow:T.string().optional().describe("User flow to test (e.g. login, checkout)")},description:"Create a new Ripplo workflow spec by analyzing the codebase"},t=>({messages:[{content:{text:[jr(t.flow??"the most important user flow"),"",K].join(`
868
+ `),type:"text"},role:"user"}]})),e.registerPrompt("debug",{argsSchema:{workflow:T.string().optional().describe("Workflow name or slug to debug (lists available if omitted)")},description:"Debug a failing workflow \u2014 identifies root cause using browser logs, DOM, network, and storage snapshots from .ripplo/debug/"},t=>({messages:[{content:{text:Fr(t.workflow),type:"text"},role:"user"}]}))}async function ci(){let e=Dr(),t=new li;await e.connect(t)}ci().catch(e=>{process.exit(1)});