ripplo 0.0.4 → 0.0.6

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,56 +1,56 @@
1
1
  #!/usr/bin/env node
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(`
2
+ import{StdioServerTransport as pi}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as si}from"@modelcontextprotocol/sdk/server/mcp.js";import{z as N}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 Cd from"@anthropic-ai/sdk";import{z as Me}from"zod";import{z as Hr}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"}),Mr(r)]),i=n.toString("base64");return{annotations:s,screenshotBase64:i,snapshotTimestamp:Math.round(performance.now()-t),url:e.url(),viewportHeight:o.height,viewportWidth:o.width}}function Br(e){return"locator"in e}async function Mr(e){return(await Promise.all(e.map(r=>Gr(r)))).filter(r=>r!=null)}async function Gr(e){if(!Br(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 ge({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(!zr(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 zr(e){return"locator"in e&&e.locator!=null}function c({description:e,execute:t,name:r,schema:o}){let n=Hr.toJSONSchema(o,{target:"draft-2020-12"});return{anthropicTool:{description:e,input_schema:{...n,type:"object"},name:r},name:r,async execute(s,i){let d=o.parse(i);return{...await Promise.resolve(t(s,d)),kind:"action"}}}}async function p(e){let t=e.specNode==null?[]:ge({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(i=>`${i.status}: ${i.description} \u2014 ${i.detail??""}`).join(`
3
+ `):`${e.status}: ${e.title}`;return{specNode:e.specNode,stepResult:n,toolOutput:s}}var Jr=Me.object({selector:Me.string().describe("CSS selector for the checkbox or radio button")}),Ge=c({description:"Assert that a checkbox or radio button is checked",name:"assert_checked",schema:Jr,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 Yr=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)")}),He=c({description:"Assert properties of a browser cookie. Check existence, value, and security flags (httpOnly, secure, sameSite).",name:"assert_cookie",schema:Yr,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"},...Kr({cookie:n,input:t})],i=s.some(h=>h.status==="failed"),d=i?"failed":"passed",u={id:`agent-step-${String(e.stepIndex)}`,name:{type:"static",value:t.name},type:"assertCookie"};return p({assertions:s,detail:i?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 Kr({cookie:e,input:t}){return[Qr(t.value,e.value),ze("httpOnly",t.httpOnly,e.httpOnly),ze("secure",t.secure,e.secure),Xr("sameSite",t.sameSite,e.sameSite)].filter(r=>r!=null)}function Qr(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 ze(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 Xr(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 Je}from"zod";var Zr=Je.object({selector:Je.string().describe("CSS selector for the element to check focus on")}),Ye=c({description:"Assert that an element has keyboard focus. Use for accessibility tab-order testing.",name:"assert_focused",schema:Zr,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",i=[{description:`Element ${t.selector} is focused`,detail:n?void 0:"Element does not have focus",status:s}],l={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertFocused"};return p({assertions:i,detail:n?"Element is focused":"Element does not have focus",duration:performance.now()-r,nodeType:"assertFocused",page:e.page,runStartTime:e.runStartTime,specNode:l,status:s,stepIndex:e.stepIndex,title:`Assert focused: ${t.selector}`})}});import{z as G}from"zod";var eo=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:eo,execute:async(e,t)=>{let r=performance.now(),o=await e.page.waitForResponse(u=>u.url().includes(t.urlPattern),{timeout:1e4}),n=[to(t.status,o.status()),await ro(t.bodyContains,o),oo(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,i=s.some(u=>u.status==="failed"),l={id:`agent-step-${String(e.stepIndex)}`,type:"assertResponse",urlPattern:{type:"static",value:t.urlPattern}};return p({assertions:s,detail:i?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:l,status:i?"failed":"passed",stepIndex:e.stepIndex,title:`Assert response: ${t.urlPattern}`})}});function to(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 ro(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 oo(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 ye}from"zod";var no=ye.object({expected:ye.string().describe("The expected text content"),selector:ye.string().describe("CSS selector for the element to check")}),Qe=c({description:"Assert that an element's text content matches the expected value",name:"assert_text",schema:no,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",i=[{description:`Text contains "${t.expected}"`,detail:`Actual: "${o??"(not found)"}"`,status:s}],d=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:d,locator:{by:"css",value:t.selector},operator:"contains",type:"assertText"};return p({assertions:i,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:l,status:s,stepIndex:e.stepIndex,title:`Assert text: ${t.selector}`})}});import{z as we}from"zod";var ao=we.object({expected:we.string().describe("Expected page title or substring"),operator:we.enum(["equals","contains","startsWith","endsWith"]).describe("Comparison operator").default("contains")}),Xe=c({description:"Assert that the page title matches an expected value",name:"assert_title",schema:ao,execute:async(e,t)=>{let r=performance.now(),o=await e.page.title(),n=so({actual:o,expected:t.expected,operator:t.operator}),s=n?"passed":"failed",i=[{description:`Title ${t.operator} "${t.expected}"`,detail:n?void 0:`Got: "${o}"`,status:s}],d=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:d,operator:t.operator,type:"assertTitle"};return p({assertions:i,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:l,status:s,stepIndex:e.stepIndex,title:`Assert title ${t.operator} "${t.expected}"`})}});function so({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 Ze}from"zod";var io=Ze.object({selector:Ze.string().describe("CSS selector for the element to check")}),et=c({description:"Assert that an element matching the selector is visible on the page",name:"assert_visible",schema:io,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 tt}from"zod";var lo=tt.object({selector:tt.string().describe("CSS selector for the checkbox to check")}),rt=c({description:"Check a checkbox matching the CSS selector",name:"check",schema:lo,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 ot}from"zod";var co=ot.object({selector:ot.string().describe("CSS selector for the input to clear")}),nt=c({description:"Clear the contents of an input field",name:"clear",schema:co,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 at}from"zod";var uo=at.object({selector:at.string().describe("CSS selector for the element to click")}),st=c({description:"Click an element matching the CSS selector",name:"click",schema:uo,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 be}from"zod";var po=be.object({action:be.enum(["read","write"]).describe("Whether to read from or write to the clipboard"),value:be.string().optional().describe("Text to write (required for write action)")}),it=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:po,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 i=JSON.stringify(t.value);await e.page.evaluate(`navigator.clipboard.writeText(${i})`);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 oe}from"zod";var lt=oe.object({summary:oe.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:oe.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.")}),ct={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:{...oe.toJSONSchema(lt,{target:"draft-2020-12"}),type:"object"},name:"complete_test"},name:"complete_test",execute(e,t){let r=lt.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 dt}from"zod";var fo=dt.object({selector:dt.string().describe("CSS selector for the element to extract text from")}),ut=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:fo,execute:async(e,t)=>{let r=performance.now(),n=await e.page.locator(t.selector).textContent({timeout:5e3})??"",i={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:i,status:"passed",stepIndex:e.stepIndex,title:`Extract text from ${t.selector}`})}});import{z as Se}from"zod";var mo=Se.object({selector:Se.string().describe("CSS selector for the input element"),value:Se.string().describe("The text to type into the element")}),pt=c({description:"Clear and type text into an input element matching the CSS selector",name:"fill",schema:mo,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 ft}from"zod";var ho=ft.object({level:ft.string().describe("Filter by log level: 'error', 'warning', 'log', 'info', 'debug', or 'all'").default("all")}),mt=c({description:"Get console log messages from the browser. Optionally filter by level (error, warning, log, info, debug, all).",name:"get_console_logs",schema:ho,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=>go(n)).join(`
5
5
  `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(r.length)} console messages:
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(`
6
+ ${o}`}}});function go(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as ht}from"zod";var ke=50,yo=ht.object({urlFilter:ht.string().describe("Optional regex to filter network entries by URL. Omit to see all.").default("")}),gt=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:yo,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(-ke),s=n.map(d=>{let l=d.statusCode==null?"pending":String(d.statusCode),u=d.responseHeaders["content-type"]??"";return`${d.method} ${l} ${d.url} [${u}]`}).join(`
7
+ `),i=o.length>ke?`
8
+ (showing last ${String(ke)} of ${String(o.length)})`:"";return{specNode:void 0,stepResult:void 0,toolOutput:`${String(n.length)} network requests:${i}
9
+ ${s}`}}});import{z as yt}from"zod";var wo=yt.object({urlPattern:yt.string().describe("Regex pattern to match the request URL")}),wt=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:wo,execute:(e,t)=>{let r=new RegExp(t.urlPattern,"i"),o=e.monitor.networkEntries.filter(l=>r.test(l.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),i=Object.entries(n.responseHeaders).map(([l,u])=>` ${l}: ${u}`).join(`
10
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
- ${l}
13
+ ${i}
14
14
 
15
15
  Body:
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}
16
+ ${d}`}}});import{z as bt}from"zod";var bo=bt.object({selector:bt.string().optional().describe("CSS selector to scope the tree to a subtree (defaults to full page)")}),St=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:bo,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 So}from"zod";var ko=So.object({}),kt=c({description:"Get a text representation of the current page content for inspection",name:"get_page_content",schema:ko,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
17
  Title: ${n}
18
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)} ---
19
+ ${r??""}`}}});import{z as Ro}from"zod";var vo=Ro.object({}),Rt=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:vo,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
20
  ${o}`).join(`
21
21
 
22
22
  `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(e.monitor.pageErrors.length)} page errors:
23
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(`
24
+ ${r}`}}});import{z as vt}from"zod";var xo=vt.object({type:vt.enum(["all","cookies","localStorage","sessionStorage"]).describe("Which storage to retrieve").default("all")}),Pt=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:xo,execute:async(e,t)=>({specNode:void 0,stepResult:void 0,toolOutput:[...t.type==="all"||t.type==="cookies"?[await Po(e.page)]:[],...t.type==="all"||t.type==="localStorage"?[await xt(e.page,"localStorage")]:[],...t.type==="all"||t.type==="sessionStorage"?[await xt(e.page,"sessionStorage")]:[]].join(`
25
25
 
26
- `)})});async function Ro(e){let t=await e.context().cookies();if(t.length===0)return`## Cookies
26
+ `)})});async function Po(e){let t=await e.context().cookies();if(t.length===0)return`## Cookies
27
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
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(`
29
+ `)}`}async function xt(e,t){let r=await e.evaluate(`JSON.stringify(Object.fromEntries(Object.entries(${t})))`);return`## ${t}
30
+ ${String(r)}`}import{z as Re}from"zod";var To=Re.object({action:Re.enum(["accept","dismiss"]).describe("Whether to accept or dismiss the dialog"),promptText:Re.string().optional().describe("Text to enter for prompt dialogs")}),Tt=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:To,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 Nt}from"zod";var No=Nt.object({selector:Nt.string().describe("CSS selector for the element to hover over")}),Ct=c({description:"Hover over an element matching the CSS selector",name:"hover",schema:No,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 ve}from"zod";var Co=ve.object({permission:ve.string().describe("Permission name (e.g. geolocation, notifications, camera, clipboard-read)"),state:ve.enum(["granted","prompt"]).describe("Permission state to set")}),At=c({description:"Set a browser permission state (geolocation, notifications, camera, etc.)",name:"set_permission",schema:Co,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 $t}from"zod";var Ao=$t.object({url:$t.string().describe("The URL to navigate to")}),It=c({description:"Navigate the browser to a URL",name:"navigate",schema:Ao,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 Et}from"zod";var $o=Et.object({key:Et.string().describe("Key to press, e.g. 'Enter', 'Tab', 'Escape'")}),jt=c({description:"Press a keyboard key",name:"press",schema:$o,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 xe}from"zod";var Io=xe.object({height:xe.number().int().positive().describe("Viewport height in pixels"),width:xe.number().int().positive().describe("Viewport width in pixels")}),Ot=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:Io,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 Vt}from"zod";var Eo=Vt.object({selector:Vt.string().describe("CSS selector for the element to right-click")}),Ft=c({description:"Right-click an element to open the context menu",name:"right_click",schema:Eo,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 ne}from"zod";var jo=ne.object({selector:ne.string().optional().describe("CSS selector to scroll within (omit to scroll the page)"),x:ne.number().int().optional().describe("Horizontal scroll offset in pixels").default(0),y:ne.number().int().optional().describe("Vertical scroll offset in pixels").default(0)}),Ut=c({description:"Scroll the page or a specific element by pixel offset. Positive y scrolls down, negative scrolls up.",name:"scroll",schema:jo,execute:async(e,t)=>{let r=performance.now();if(t.selector==null)await e.page.mouse.wheel(t.x,t.y);else{let i=await e.page.locator(t.selector).elementHandle();if(i==null)throw new Error("Scroll target element not found");await i.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 Oo}from"zod";var Vo=Oo.object({}),Dt=c({description:"Take a screenshot of the current page",name:"screenshot",schema:Vo,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 Lt}from"zod";var Fo=Lt.object({pattern:Lt.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:Fo,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=>Uo(s)).join(`
31
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(`
32
+ ${n}`}}});function Uo(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as _t}from"zod";var Do=_t.object({pattern:_t.string().describe("Regex pattern to search across network request URLs and response bodies")}),qt=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:Do,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 i=s.statusCode==null?"pending":String(s.statusCode),d=r.test(s.url)?" [URL match]":"",l=s.responseBody!=null&&r.test(s.responseBody)?" [body match]":"";return`${s.method} ${i} ${s.url}${d}${l}`}).join(`
33
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(`
34
+ ${n}`}}});import{z as Bt}from"zod";var Lo=20,Wo=2,_o=Bt.object({pattern:Bt.string().describe("Regex pattern to search for in the page HTML")}),Mt=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:_o,execute:async(e,t)=>{let o=(await e.page.content()).split(`
35
+ `),n=qo({contextLines:Wo,lines:o,maxResults:Lo,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(`
36
36
  ---
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 Dd from"path";import{chromium as qd}from"playwright";import{mkdir as Md,writeFile as Gd}from"fs/promises";import Hd from"path";import{readdir as au,rm as su,stat as iu}from"fs/promises";import Zo from"path";import{graphql as en}from"gql.tada";import{print as Yo}from"graphql";async function V(e){let t=Yo(e.document),r=JSON.stringify({query:t,variables:e.variables}),n=await(await fetch(`${e.config.ripploServerUrl}/graphql`,{body:r,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST"})).json();if(!Qo(n))throw new Error("Invalid GraphQL response");if(Xo(n))throw new Error(n.errors.map(s=>s.message).join(", "));if(n.data==null)throw new Error("No data returned from server");return n.data}function Qo(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function Xo(e){return Array.isArray(e.errors)&&e.errors.length>0}var pu=Zo.join(process.cwd(),".ripplo","debug"),fu=360*60*1e3,mu=en(`
37
+ `)}}});function qo({contextLines:e,lines:t,maxResults:r,pattern:o}){let n=new RegExp(o,"i"),s=[];return t.forEach((i,d)=>{if(s.length>=r||!n.test(i))return;let l=Math.max(0,d-e),u=Math.min(t.length-1,d+e),h=t.slice(l,u+1).map((E,re)=>{let qr=l+re+1;return`${l+re===d?">":" "} ${String(qr)}: ${E}`}).join(`
38
+ `);s.push(h)}),s}import{z as Pe}from"zod";var Bo=Pe.object({selector:Pe.string().describe("CSS selector for the select element"),value:Pe.string().describe("The option value to select")}),Gt=c({description:"Select an option from a dropdown/select element",name:"select",schema:Bo,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 zt}from"zod";var Mo=zt.object({selector:zt.string().describe("CSS selector for the checkbox to uncheck")}),Ht=c({description:"Uncheck a checkbox matching the CSS selector",name:"uncheck",schema:Mo,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 Jt}from"zod";var Go=Jt.object({ms:Jt.number().describe("Milliseconds to wait")}),Yt=c({description:"Wait for a specified duration in milliseconds",name:"wait",schema:Go,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 Te}from"zod";var zo=Te.object({selector:Te.string().describe("CSS selector for the element to wait for"),state:Te.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:zo,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 Ne=[It,st,pt,jt,rt,Ht,Gt,Ct,Yt,Kt,Dt,kt,Mt,nt,Ft,Ut,Tt,it,At,et,Qe,Xe,Ge,Ye,He,Ke,mt,gt,wt,Rt,St,Pt,Wt,qt,Ot,ut,ct],kd=new Map(Ne.map(e=>[e.name,e])),Ho=Ne.map(e=>e.anthropicTool),Jo=Ne.map(e=>`- **${e.name}**: ${e.anthropicTool.description??""}`).join(`
39
+ `);import Yo from"pino";var P=Yo({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}});import{execFileSync as Fd}from"child_process";import{createRequire as Dd}from"module";import Wd from"fs";import qd from"path";import{chromium as Md}from"playwright";import{mkdir as Jd,writeFile as Yd}from"fs/promises";import Qd from"path";import{readdir as cu,rm as du,stat as uu}from"fs/promises";import fu from"os";import rn from"path";import{graphql as on}from"gql.tada";import{print as Zo}from"graphql";async function V(e){let t=Zo(e.document),r=JSON.stringify({query:t,variables:e.variables}),o=`${e.config.ripploServerUrl}/graphql`,n;try{n=await fetch(o,{body:r,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST"})}catch(i){let d=i instanceof Error?i.message:String(i);throw new Error(`Failed to connect to Ripplo server at ${e.config.ripploServerUrl}. Make sure \`ripplo dev\` is running and your internet connection is active. Details: ${d}`)}let s=await n.json();if(!en(s))throw new Error("Invalid GraphQL response");if(tn(s))throw new Error(s.errors.map(i=>i.message).join(", "));if(s.data==null)throw new Error("No data returned from server");return s.data}function en(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function tn(e){return Array.isArray(e.errors)&&e.errors.length>0}var wu=rn.join(process.cwd(),".ripplo","debug"),bu=360*60*1e3,Su=on(`
40
40
  mutation RevokeCurrentCliToken {
41
41
  revokeCurrentCliToken
42
42
  }
43
- `);import tr from"fs";import Ne from"path";import{z as F}from"zod";var on=F.object({baseUrl:F.string().optional(),cloudBaseUrl:F.string(),preconditionApiPath:F.string().optional(),projectId:F.string()}),nn=F.object({ripploServerUrl:F.string(),token:F.string()}),an=on.extend(nn.shape),or=Ne.join(process.cwd(),".ripplo"),sn=Ne.join(or,"settings.json"),ln=Ne.join(or,"settings.local.json");function rr(e){if(!tr.existsSync(e))return null;let t=tr.readFileSync(e,"utf8");return JSON.parse(t)}function Ce(){let e=rr(sn),t=rr(ln);if(e==null||t==null)return null;let r=an.safeParse({...e,...t});return r.success?r.data:null}import{z as a}from"zod";import{z as C}from"zod";import{z as y}from"zod";var dn=y.object({by:y.literal("css"),value:y.string().min(1)}),un=y.object({by:y.literal("testId"),value:y.string().min(1)}),pn=y.object({by:y.literal("role"),exact:y.boolean().optional(),name:y.string().optional(),role:y.string().min(1)}),fn=y.object({by:y.literal("text"),exact:y.boolean().optional(),value:y.string().min(1)}),mn=y.object({by:y.literal("label"),exact:y.boolean().optional(),value:y.string().min(1)}),hn=y.object({by:y.literal("placeholder"),value:y.string().min(1)}),gn=y.object({by:y.literal("altText"),value:y.string().min(1)}),m=y.discriminatedUnion("by",[dn,un,pn,fn,mn,hn,gn]);import{z as nr}from"zod";var R=nr.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),j=nr.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]);import{z as S}from"zod";var yn=S.object({type:S.literal("static"),value:S.union([S.string(),S.number(),S.boolean()])}),Ae=S.object({name:S.string().min(1),type:S.literal("variable")}),U=S.discriminatedUnion("type",[yn,Ae]),g=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.string()}),Ae]),W=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.number().int().nonnegative()}),Ae]);var q=C.discriminatedUnion("type",[C.object({locator:m,type:C.literal("elementVisible")}),C.object({locator:m,type:C.literal("elementNotVisible")}),C.object({expected:g,operator:R,type:C.literal("urlMatch")}),C.object({expected:g,locator:m,operator:R,type:C.literal("textMatch")}),C.object({expected:U,operator:j,type:C.literal("variableCompare"),variable:C.string().min(1)})]);import{z as P}from"zod";var z=P.discriminatedUnion("type",[P.object({default:P.string().optional(),type:P.literal("string")}),P.object({default:P.number().optional(),type:P.literal("number")}),P.object({default:P.boolean().optional(),type:P.literal("boolean")}),P.object({key:P.string().min(1),type:P.literal("env")})]);var wn=a.string().min(1),O=a.array(wn).min(1),f={comment:a.string().optional(),id:a.string().min(1),label:a.string().optional(),next:a.string().optional(),timeout:a.number().int().positive().optional()},bn=a.object({...f,type:a.literal("goto"),url:g}),Sn=a.object({...f,locator:m,type:a.literal("click")}),kn=a.object({...f,locator:m,type:a.literal("fill"),value:g}),Rn=a.object({...f,locator:m,type:a.literal("select"),value:g}),vn=a.object({...f,locator:m,type:a.literal("hover")}),xn=a.object({...f,key:a.string().min(1),locator:m.optional(),type:a.literal("press")}),Pn=a.object({...f,locator:m,type:a.literal("check")}),Tn=a.object({...f,locator:m,type:a.literal("uncheck")}),Nn=a.object({...f,type:a.literal("screenshot")}),Cn=a.object({...f,height:a.number().int().positive(),type:a.literal("setViewport"),width:a.number().int().positive()}),An=a.object({...f,duration:a.number().int().positive(),type:a.literal("wait")}),$n=a.object({...f,message:a.string().min(1),type:a.literal("fail")}),In=a.object({...f,type:a.literal("setVariable"),value:U,variable:a.string().min(1)}),En=a.object({...f,locator:m,type:a.literal("extractText"),variable:a.string().min(1)}),jn=a.object({...f,files:a.array(a.string()).min(1),locator:m,type:a.literal("upload")}),On=a.object({...f,locator:m,type:a.literal("dblclick")}),Vn=a.object({...f,source:m,target:m,type:a.literal("drag")}),Fn=a.object({...f,locator:m,type:a.literal("scrollIntoView")}),Un=a.object({...f,locator:m,type:a.literal("type"),value:g}),Dn=a.object({...f,locator:m,type:a.literal("focus")}),Wn=a.object({...f,locator:m,type:a.literal("clear")}),qn=a.object({...f,locator:m,type:a.literal("rightClick")}),Ln=a.object({...f,action:a.enum(["accept","dismiss"]),promptText:a.string().optional(),type:a.literal("handleDialog")}),_n=a.object({...f,locator:m.optional(),type:a.literal("scroll"),x:a.number().int().optional(),y:a.number().int().optional()}),Bn=a.object({...f,action:a.enum(["read","write"]),type:a.literal("clipboard"),value:g.optional(),variable:a.string().min(1).optional()}),Mn=a.object({...f,permission:a.string().min(1),state:a.enum(["granted","prompt"]),type:a.literal("setPermission")}),Gn=a.object({...f,locator:m,state:a.enum(["visible","hidden","attached","detached"]).optional(),type:a.literal("waitFor")}),zn=a.object({...f,expected:g,operator:R,type:a.literal("waitForUrl")}),Hn=a.object({...f,type:a.literal("waitForResponse"),urlPattern:g}),Jn=a.object({...f,type:a.literal("waitForRequest"),urlPattern:g}),Kn=a.object({...f,locator:m,type:a.literal("assertVisible")}),Yn=a.object({...f,locator:m,type:a.literal("assertNotVisible")}),Qn=a.object({...f,expected:g,locator:m,operator:R,type:a.literal("assertText")}),Xn=a.object({...f,expected:g,operator:R,type:a.literal("assertUrl")}),Zn=a.object({...f,expected:W,locator:m,operator:j,type:a.literal("assertCount")}),ea=a.object({...f,expected:g,locator:m,operator:R,type:a.literal("assertValue")}),ta=a.object({...f,attribute:a.string().min(1),expected:g,locator:m,operator:R,type:a.literal("assertAttribute")}),ra=a.object({...f,locator:m,type:a.literal("assertEnabled")}),oa=a.object({...f,locator:m,type:a.literal("assertDisabled")}),na=a.object({...f,expected:g,operator:R,type:a.literal("assertTitle")}),aa=a.object({...f,locator:m,type:a.literal("assertChecked")}),sa=a.object({...f,locator:m,type:a.literal("assertNotChecked")}),ia=a.object({...f,locator:m,type:a.literal("assertFocused")}),la=a.object({...f,httpOnly:a.boolean().optional(),name:g,operator:R.optional(),sameSite:a.enum(["Strict","Lax","None"]).optional(),secure:a.boolean().optional(),type:a.literal("assertCookie"),value:g.optional()}),ca=a.object({...f,bodyContains:g.optional(),headerContains:a.object({name:a.string().min(1),value:g}).optional(),status:a.number().int().positive().optional(),type:a.literal("assertResponse"),urlPattern:g}),da=a.object({...f,alternate:O.optional(),condition:q,consequent:O,type:a.literal("if")}),ua=a.object({...f,body:O,iteratorVar:a.string().min(1).optional(),times:a.number().int().positive(),type:a.literal("loop")}),pa=a.object({...f,body:O,collection:a.union([a.array(a.record(a.string(),a.unknown())).min(1),a.object({name:a.string().min(1),type:a.literal("variable")})]),iteratorVar:a.string().min(1),type:a.literal("forEach")}),fa=a.object({...f,branches:a.array(O).min(2),type:a.literal("parallel")}),ma=a.object({...f,body:O,catch:O.optional(),finally:O.optional(),type:a.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),ha=a.object({...f,nodes:O,type:a.literal("group")}),X=a.discriminatedUnion("type",[bn,Sn,kn,Rn,vn,xn,Pn,Tn,Gn,zn,Hn,Jn,Kn,Yn,Qn,Xn,Zn,ea,ta,ra,oa,Nn,Cn,An,$n,In,En,jn,On,Vn,Fn,Un,Dn,Wn,qn,Ln,_n,Bn,Mn,na,aa,sa,ia,la,ca,da,ua,pa,fa,ha]),ar=a.union([X,ma]),L=a.object({entryNode:a.string().min(1),nodes:a.record(a.string(),ar),variables:a.record(a.string(),z).optional(),version:a.literal(2)});function ne(e){let t=L.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(r=>({message:r.message,path:r.path.join(".")})),success:!1}}import{graphql as ce,readFragment as bf}from"gql.tada";import{z as ae}from"zod";var $e=ae.object({from:ae.string().min(1).describe("Key of the source state in the states record"),to:ae.string().min(1).describe("Key of the target state in the states record"),workflow:ae.string().min(1).describe("Filename (without .json) of the workflow in .ripplo/workflows/ that executes this edge")}).describe("A directed edge between two states, executed by a workflow");import{z as D}from"zod";import{z as b}from"zod";var Ie=b.object({precondition:b.string().min(1).describe("Name of the precondition to check or execute, e.g. 'auth:admin'")}).describe("Request payload sent by Ripplo to both the check and execute endpoints"),se=b.object({satisfied:b.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),ie=b.object({data:b.record(b.string(),b.string()).optional().describe("Key-value data returned by the precondition. Values are injected as variables that can be interpolated into route patterns ({{key}}) and workflow spec variable references. For example, a data:project precondition should return { projectId: 'clx...' } so the route /projects/{{projectId}}/settings resolves correctly."),error:b.string().optional().describe("Human-readable error message if success is false"),navigateTo:b.string().optional().describe("URL to navigate the browser to after this precondition executes. Use this to set the starting page for the test \u2014 e.g. an auth token URL or the page the workflow begins on. If multiple preconditions return navigateTo, only the last one is used."),success:b.boolean().describe("Whether the precondition was successfully satisfied")}).describe("Response from PUT {preconditionApiUrl}/execute. Set-Cookie headers are automatically captured and injected into the browser context. The data field provides values for route param interpolation and workflow variables."),Ee=b.object({preconditions:b.array(b.string().min(1)).describe("Names of all preconditions that were executed during this run")}).describe("Request payload sent after a run completes. Fire-and-forget \u2014 errors are logged but don't fail the run."),je=b.object({error:b.string().optional().describe("Human-readable error message if success is false"),success:b.boolean().describe("Whether teardown completed successfully")}).describe("Response from PUT {preconditionApiUrl}/teardown"),_=b.object({depends:b.array(b.string().min(1)).optional().describe("Names of other preconditions that must be satisfied first. Resolved via topological sort; cycles are rejected at validation time."),description:b.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:b.array(b.string().min(1)).optional().describe("Keys that the execute response's data field will contain. e.g. ['projectId', 'workflowId']. These are used for route param interpolation ({{projectId}}) and workflow variables. Declared here so generated types are strongly typed per precondition.")}).describe("A named precondition declared at the graph level. States reference these by name.");import{z as le}from"zod";var Oe=le.object({preconditions:le.array(le.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:le.string().min(1).describe("URL pattern with {{placeholders}} for dynamic segments, e.g. '/projects/{{projectId}}/settings'")}).describe("A distinct application state \u2014 a unique combination of location, auth context, and data conditions");var Z=D.object({edges:D.array($e).describe("Directed edges between states, each executed by a workflow"),preconditions:D.record(D.string(),_).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:D.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:D.record(D.string(),Oe).describe("States keyed by stable ID (kebab-case)"),version:D.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions");function Ve(e){let t=Z.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(r=>({message:r.message,path:r.path.join(".")})),success:!1}}function Aa(e){let t=e.preconditions,r=new Set,o=new Set,n=[];function s(l){if(o.has(l)){n.push(`Precondition "${l}" has a circular dependency`);return}if(r.has(l))return;r.add(l),o.add(l);let d=t[l];d?.depends!=null&&d.depends.forEach(i=>{s(i)}),o.delete(l)}return Object.keys(t).forEach(l=>{s(l)}),n}function Fe(e){let t=[],r=new Set(Object.keys(e.preconditions)),o=new Set(Object.keys(e.states));e.edges.forEach((i,u)=>{o.has(i.from)||t.push({message:`References non-existent source state "${i.from}"`,path:`edges[${String(u)}].from`}),o.has(i.to)||t.push({message:`References non-existent target state "${i.to}"`,path:`edges[${String(u)}].to`})}),Object.entries(e.states).forEach(([i,u])=>{u.preconditions.forEach(h=>{r.has(h)||t.push({message:`References non-existent precondition "${h}"`,path:`states.${i}.preconditions`})})}),Object.entries(e.preconditions).forEach(([i,u])=>{u.depends!=null&&u.depends.forEach(h=>{r.has(h)||t.push({message:`Depends on non-existent precondition "${h}"`,path:`preconditions.${i}.depends`})})}),e.resetPrecondition!=null&&!r.has(e.resetPrecondition)&&t.push({message:`References non-existent precondition "${e.resetPrecondition}"`,path:"resetPrecondition"});let n=new Set(e.edges.flatMap(i=>[i.from,i.to]));Object.keys(e.states).forEach(i=>{n.has(i)||t.push({message:"State is not referenced by any edge (orphan)",path:`states.${i}`})});let s=new Set;Object.values(e.states).forEach(i=>{i.preconditions.forEach(u=>s.add(u))}),Object.values(e.preconditions).forEach(i=>{i.depends!=null&&i.depends.forEach(u=>s.add(u))}),e.resetPrecondition!=null&&s.add(e.resetPrecondition),Object.keys(e.preconditions).forEach(i=>{s.has(i)||t.push({message:"Defined but never used by any state or dependency",path:`preconditions.${i}`})});let l=new Set;return e.edges.forEach((i,u)=>{let h=`${i.from}|${i.to}|${i.workflow}`;l.has(h)&&t.push({message:`Duplicate edge from "${i.from}" to "${i.to}" with workflow "${i.workflow}"`,path:`edges[${String(u)}]`}),l.add(h)}),Aa(e).forEach(i=>t.push({message:i,path:"preconditions"})),t}import{parseSetCookie as of}from"set-cookie-parser";import{z as ir}from"zod";var sf=ir.record(ir.string(),_);import{graphql as Ue}from"gql.tada";var pf=Ue(`
43
+ `);import rr from"fs";import Ce from"path";import{z as F}from"zod";var sn=F.object({baseUrl:F.string().optional(),cloudBaseUrl:F.string(),preconditionApiPath:F.string().optional(),projectId:F.string()}),ln=F.object({ripploServerUrl:F.string(),token:F.string()}),cn=sn.extend(ln.shape),nr=Ce.join(process.cwd(),".ripplo"),dn=Ce.join(nr,"settings.json"),un=Ce.join(nr,"settings.local.json");function or(e){if(!rr.existsSync(e))return null;let t=rr.readFileSync(e,"utf8");return JSON.parse(t)}function Ae(){let e=or(dn),t=or(un);if(e==null||t==null)return null;let r=cn.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 fn=y.object({by:y.literal("css"),value:y.string().min(1)}),mn=y.object({by:y.literal("testId"),value:y.string().min(1)}),hn=y.object({by:y.literal("role"),exact:y.boolean().optional(),name:y.string().optional(),role:y.string().min(1)}),gn=y.object({by:y.literal("text"),exact:y.boolean().optional(),value:y.string().min(1)}),yn=y.object({by:y.literal("label"),exact:y.boolean().optional(),value:y.string().min(1)}),wn=y.object({by:y.literal("placeholder"),value:y.string().min(1)}),bn=y.object({by:y.literal("altText"),value:y.string().min(1)}),m=y.discriminatedUnion("by",[fn,mn,hn,gn,yn,wn,bn]);import{z as ar}from"zod";var R=ar.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),j=ar.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]);import{z as S}from"zod";var Sn=S.object({type:S.literal("static"),value:S.union([S.string(),S.number(),S.boolean()])}),$e=S.object({name:S.string().min(1),type:S.literal("variable")}),U=S.discriminatedUnion("type",[Sn,$e]),g=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.string()}),$e]),L=S.discriminatedUnion("type",[S.object({type:S.literal("static"),value:S.number().int().nonnegative()}),$e]);var W=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 T}from"zod";var z=T.discriminatedUnion("type",[T.object({default:T.string().optional(),type:T.literal("string")}),T.object({default:T.number().optional(),type:T.literal("number")}),T.object({default:T.boolean().optional(),type:T.literal("boolean")}),T.object({key:T.string().min(1),type:T.literal("env")})]);var kn=a.string().min(1),O=a.array(kn).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()},Rn=a.object({...f,type:a.literal("goto"),url:g}),vn=a.object({...f,locator:m,type:a.literal("click")}),xn=a.object({...f,locator:m,type:a.literal("fill"),value:g}),Pn=a.object({...f,locator:m,type:a.literal("select"),value:g}),Tn=a.object({...f,locator:m,type:a.literal("hover")}),Nn=a.object({...f,key:a.string().min(1),locator:m.optional(),type:a.literal("press")}),Cn=a.object({...f,locator:m,type:a.literal("check")}),An=a.object({...f,locator:m,type:a.literal("uncheck")}),$n=a.object({...f,type:a.literal("screenshot")}),In=a.object({...f,height:a.number().int().positive(),type:a.literal("setViewport"),width:a.number().int().positive()}),En=a.object({...f,duration:a.number().int().positive(),type:a.literal("wait")}),jn=a.object({...f,message:a.string().min(1),type:a.literal("fail")}),On=a.object({...f,type:a.literal("setVariable"),value:U,variable:a.string().min(1)}),Vn=a.object({...f,locator:m,type:a.literal("extractText"),variable:a.string().min(1)}),Fn=a.object({...f,files:a.array(a.string()).min(1),locator:m,type:a.literal("upload")}),Un=a.object({...f,locator:m,type:a.literal("dblclick")}),Dn=a.object({...f,source:m,target:m,type:a.literal("drag")}),Ln=a.object({...f,locator:m,type:a.literal("scrollIntoView")}),Wn=a.object({...f,locator:m,type:a.literal("type"),value:g}),_n=a.object({...f,locator:m,type:a.literal("focus")}),qn=a.object({...f,locator:m,type:a.literal("clear")}),Bn=a.object({...f,locator:m,type:a.literal("rightClick")}),Mn=a.object({...f,action:a.enum(["accept","dismiss"]),promptText:a.string().optional(),type:a.literal("handleDialog")}),Gn=a.object({...f,locator:m.optional(),type:a.literal("scroll"),x:a.number().int().optional(),y:a.number().int().optional()}),zn=a.object({...f,action:a.enum(["read","write"]),type:a.literal("clipboard"),value:g.optional(),variable:a.string().min(1).optional()}),Hn=a.object({...f,permission:a.string().min(1),state:a.enum(["granted","prompt"]),type:a.literal("setPermission")}),Jn=a.object({...f,locator:m,state:a.enum(["visible","hidden","attached","detached"]).optional(),type:a.literal("waitFor")}),Yn=a.object({...f,expected:g,operator:R,type:a.literal("waitForUrl")}),Kn=a.object({...f,type:a.literal("waitForResponse"),urlPattern:g}),Qn=a.object({...f,type:a.literal("waitForRequest"),urlPattern:g}),Xn=a.object({...f,locator:m,type:a.literal("assertVisible")}),Zn=a.object({...f,locator:m,type:a.literal("assertNotVisible")}),ea=a.object({...f,expected:g,locator:m,operator:R,type:a.literal("assertText")}),ta=a.object({...f,expected:g,operator:R,type:a.literal("assertUrl")}),ra=a.object({...f,expected:L,locator:m,operator:j,type:a.literal("assertCount")}),oa=a.object({...f,expected:g,locator:m,operator:R,type:a.literal("assertValue")}),na=a.object({...f,attribute:a.string().min(1),expected:g,locator:m,operator:R,type:a.literal("assertAttribute")}),aa=a.object({...f,locator:m,type:a.literal("assertEnabled")}),sa=a.object({...f,locator:m,type:a.literal("assertDisabled")}),ia=a.object({...f,expected:g,operator:R,type:a.literal("assertTitle")}),la=a.object({...f,locator:m,type:a.literal("assertChecked")}),ca=a.object({...f,locator:m,type:a.literal("assertNotChecked")}),da=a.object({...f,locator:m,type:a.literal("assertFocused")}),ua=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()}),pa=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}),fa=a.object({...f,alternate:O.optional(),condition:W,consequent:O,type:a.literal("if")}),ma=a.object({...f,body:O,iteratorVar:a.string().min(1).optional(),times:a.number().int().positive(),type:a.literal("loop")}),ha=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")}),ga=a.object({...f,branches:a.array(O).min(2),type:a.literal("parallel")}),ya=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'"}),wa=a.object({...f,nodes:O,type:a.literal("group")}),X=a.discriminatedUnion("type",[Rn,vn,xn,Pn,Tn,Nn,Cn,An,Jn,Yn,Kn,Qn,Xn,Zn,ea,ta,ra,oa,na,aa,sa,$n,In,En,jn,On,Vn,Fn,Un,Dn,Ln,Wn,_n,qn,Bn,Mn,Gn,zn,Hn,ia,la,ca,da,ua,pa,fa,ma,ha,ga,wa]),sr=a.union([X,ya]),_=a.object({entryNode:a.string().min(1),nodes:a.record(a.string(),sr),variables:a.record(a.string(),z).optional(),version:a.literal(2)});function ae(e){let t=_.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 de,readFragment as Nf}from"gql.tada";import{z as se}from"zod";var Ie=se.object({from:se.string().min(1).describe("Key of the source state in the states record"),to:se.string().min(1).describe("Key of the target state in the states record"),workflow:se.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 Ee=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"),ie=b.object({satisfied:b.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),le=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."),je=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."),Oe=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"),q=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 ce}from"zod";var Ve=ce.object({preconditions:ce.array(ce.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:ce.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(Ie).describe("Directed edges between states, each executed by a workflow"),preconditions:D.record(D.string(),q).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(),Ve).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 Fe(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 Ea(e){let t=e.preconditions,r=new Set,o=new Set,n=[];function s(i){if(o.has(i)){n.push(`Precondition "${i}" has a circular dependency`);return}if(r.has(i))return;r.add(i),o.add(i);let d=t[i];d?.depends!=null&&d.depends.forEach(l=>{s(l)}),o.delete(i)}return Object.keys(t).forEach(i=>{s(i)}),n}function Ue(e){let t=[],r=new Set(Object.keys(e.preconditions)),o=new Set(Object.keys(e.states));e.edges.forEach((l,u)=>{o.has(l.from)||t.push({message:`References non-existent source state "${l.from}"`,path:`edges[${String(u)}].from`}),o.has(l.to)||t.push({message:`References non-existent target state "${l.to}"`,path:`edges[${String(u)}].to`})}),Object.entries(e.states).forEach(([l,u])=>{u.preconditions.forEach(h=>{r.has(h)||t.push({message:`References non-existent precondition "${h}"`,path:`states.${l}.preconditions`})})}),Object.entries(e.preconditions).forEach(([l,u])=>{u.depends!=null&&u.depends.forEach(h=>{r.has(h)||t.push({message:`Depends on non-existent precondition "${h}"`,path:`preconditions.${l}.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(l=>[l.from,l.to]));Object.keys(e.states).forEach(l=>{n.has(l)||t.push({message:"State is not referenced by any edge (orphan)",path:`states.${l}`})});let s=new Set;Object.values(e.states).forEach(l=>{l.preconditions.forEach(u=>s.add(u))}),Object.values(e.preconditions).forEach(l=>{l.depends!=null&&l.depends.forEach(u=>s.add(u))}),e.resetPrecondition!=null&&s.add(e.resetPrecondition),Object.keys(e.preconditions).forEach(l=>{s.has(l)||t.push({message:"Defined but never used by any state or dependency",path:`preconditions.${l}`})});let i=new Set;return e.edges.forEach((l,u)=>{let h=`${l.from}|${l.to}|${l.workflow}`;i.has(h)&&t.push({message:`Duplicate edge from "${l.from}" to "${l.to}" with workflow "${l.workflow}"`,path:`edges[${String(u)}]`}),i.add(h)}),Ea(e).forEach(l=>t.push({message:l,path:"preconditions"})),t}import{parseSetCookie as pf}from"set-cookie-parser";import{z as lr}from"zod";var hf=lr.record(lr.string(),q);import{graphql as De}from"gql.tada";var Sf=De(`
44
44
  mutation StartRunCLI($runId: String!, $platform: String!, $agentProfileId: String) {
45
45
  startRun(runId: $runId, platform: $platform, agentProfileId: $agentProfileId) {
46
46
  id
47
47
  }
48
48
  }
49
- `),ff=Ue(`
49
+ `),kf=De(`
50
50
  mutation SubmitRunStepsCLI($runResultId: String!, $steps: [StepInput!]!) {
51
51
  submitRunSteps(runResultId: $runResultId, steps: $steps)
52
52
  }
53
- `),mf=Ue(`
53
+ `),Rf=De(`
54
54
  mutation CompleteRunCLI(
55
55
  $runResultId: String!
56
56
  $status: String!
@@ -73,14 +73,14 @@ ${n}`}}});import{z as _t}from"zod";var Fo=20,Uo=2,Do=_t.object({pattern:_t.strin
73
73
  status
74
74
  }
75
75
  }
76
- `);var Fa=ce(`
76
+ `);var Wa=de(`
77
77
  fragment WorkflowRun on Workflow {
78
78
  id
79
79
  slug
80
80
  name
81
81
  spec
82
82
  }
83
- `),Ua=ce(`
83
+ `),_a=de(`
84
84
  fragment ProjectRun on Project {
85
85
  id
86
86
  baseUrl
@@ -99,13 +99,13 @@ ${n}`}}});import{z as _t}from"zod";var Fo=20,Uo=2,Do=_t.object({pattern:_t.strin
99
99
  ...WorkflowRun
100
100
  }
101
101
  }
102
- `,[Fa]),$f=ce(`
102
+ `,[Wa]),Lf=de(`
103
103
  query ProjectRun($projectId: String!) {
104
104
  project(id: $projectId) {
105
105
  ...ProjectRun
106
106
  }
107
107
  }
108
- `,[Ua]),If=ce(`
108
+ `,[_a]),Wf=de(`
109
109
  query AgentProfileRun($id: String!) {
110
110
  agentProfile(id: $id) {
111
111
  id
@@ -115,11 +115,11 @@ ${n}`}}});import{z as _t}from"zod";var Fo=20,Uo=2,Do=_t.object({pattern:_t.strin
115
115
  successCriteria
116
116
  }
117
117
  }
118
- `);function v(e){return{content:[{text:e,type:"text"}]}}async function lr(e){let t=Ce();return t==null?v("Not logged in. Run: ripplo login"):e(t)}import{z as x}from"zod";import Da from"fs";import pm from"path";import{z as H}from"zod";var ee=H.object({additionalChecks:H.array(H.string()).default([]),description:H.string(),expectedOutcome:H.string(),name:H.string(),spec:L});function de(e){let t=Da.readFileSync(e,"utf8"),r=JSON.parse(t);return ee.parse(r)}var Wa=x.object({additionalProperties:x.unknown().optional(),properties:x.record(x.string(),x.record(x.string(),x.unknown())).optional(),required:x.array(x.string()).optional(),type:x.string().optional()}),cr=x.object({oneOf:x.array(Wa).optional()});function dr(){let e=za(),t={category:"Control Flow",fields:"body, catch?, finally?",typeName:"try"},r=[...e.map(s=>Ha(s)),t],o=Ja(r);return`# Ripplo Workflow Spec v2
118
+ `);function v(e){return{content:[{text:e,type:"text"}]}}async function cr(e){let t=Ae();return t==null?v("Not logged in. Run: ripplo login"):e(t)}import{z as x}from"zod";import qa from"fs";import Rm 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:_});function ue(e){let t=qa.readFileSync(e,"utf8"),r=JSON.parse(t);return ee.parse(r)}var Ba=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()}),dr=x.object({oneOf:x.array(Ba).optional()});function ur(){let e=Ka(),t={category:"Control Flow",fields:"body, catch?, finally?",typeName:"try"},r=[...e.map(s=>Qa(s)),t],o=Xa(r);return`# Ripplo Workflow Spec v2
119
119
 
120
120
  ## Node Types
121
121
 
122
- ${qa.filter(s=>o.has(s)).map(s=>{let d=(o.get(s)??[]).map(i=>`- ${i.typeName} { ${i.fields} }`);return`### ${s}
122
+ ${Ma.filter(s=>o.has(s)).map(s=>{let d=(o.get(s)??[]).map(l=>`- ${l.typeName} { ${l.fields} }`);return`### ${s}
123
123
  ${d.join(`
124
124
  `)}`}).join(`
125
125
 
@@ -146,17 +146,17 @@ Each workflow file in \`.ripplo/workflows/\` is a JSON file with: name, descript
146
146
  The spec contains: version (2), entryNode, nodes, variables?.
147
147
 
148
148
  Use \`get_node_schema\` for full JSON Schema of specific node types.
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}
149
+ Use \`get_spec_patterns\` for locator, condition, and variable schemas + best practices.`}function pr({nodeTypes:e}){let r=dr.parse(structuredClone(x.toJSONSchema(X))).oneOf??[],o=new Map;r.forEach(s=>{let i=mr(s);i.length>0&&o.set(i,s)});let n=[];return e.forEach(s=>{if(s==="try"){n.push(ts);return}let i=o.get(s);if(i==null){n.push(`## ${s}
150
150
 
151
151
  Unknown node type "${s}".`);return}n.push(`## ${s}
152
152
 
153
153
  \`\`\`json
154
- ${JSON.stringify(l,null,2)}
155
- \`\`\``)}),n.push(Ya),n.join(`
154
+ ${JSON.stringify(i,null,2)}
155
+ \`\`\``)}),n.push(es),n.join(`
156
156
 
157
- `)}function pr(){return`# Spec Patterns & Building Blocks
157
+ `)}function fr(){return`# Spec Patterns & Building Blocks
158
158
 
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}
159
+ ${[{label:"Locator",schema:m},{label:"Condition",schema:W},{label:"StringValueRef",schema:g},{label:"NumericValueRef",schema:L},{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:_}].map(({label:r,schema:o})=>`### ${r}
160
160
 
161
161
  \`\`\`json
162
162
  ${JSON.stringify(x.toJSONSchema(o),null,2)}
@@ -178,23 +178,23 @@ ${JSON.stringify(x.toJSONSchema(o),null,2)}
178
178
  10. **URLs in goto nodes must be relative paths** (\`/login\`), never absolute URLs \u2014 the baseUrl handles the origin
179
179
  11. **Value references use \`"type": "static"\`**, never \`"type": "literal"\`
180
180
  12. **Node IDs must match their key** in the \`nodes\` object
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`---
181
+ 13. **Template variables use \`{{name}}\`**, never \`$name\` or \`\${name}\` \u2014 only double curly braces work`}var Ma=["Actions","Waits","Assertions","Variables","Control Flow","Other"],Ga=new Set(["if","loop","forEach","parallel","try","group"]),za=new Set(["setVariable","extractText"]),Ha=new Set(["screenshot","setViewport","fail"]),Ja=new Set(["comment","id","label","next","timeout","type"]);function Ya(e){return e.startsWith("assert")?"Assertions":e.startsWith("waitFor")||e==="wait"?"Waits":Ga.has(e)?"Control Flow":za.has(e)?"Variables":Ha.has(e)?"Other":"Actions"}function Ka(){return dr.parse(structuredClone(x.toJSONSchema(X))).oneOf??[]}function mr(e){let t=e.properties?.type;if(t==null)return"";let r=t.const;return typeof r=="string"?r:""}function Qa(e){let t=mr(e),r=new Set(e.required??[]),o=Object.keys(e.properties??{}).filter(n=>!Ja.has(n)).map(n=>r.has(n)?n:`${n}?`).join(", ");return{category:Ya(t),fields:o,typeName:t}}function Xa(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 Za(){return`---
182
182
 
183
183
  ## Referenced Schemas
184
184
 
185
- ${[J("Locator",m),J("StringValueRef",g),J("NumericValueRef",W),J("ComparisonOperator",R),J("NumericOperator",j),J("Condition",q)].join(`
185
+ ${[J("Locator",m),J("StringValueRef",g),J("NumericValueRef",L),J("ComparisonOperator",R),J("NumericOperator",j),J("Condition",W)].join(`
186
186
 
187
- `)}`}var Ya=Ka();function J(e,t){return`### ${e}
187
+ `)}`}var es=Za();function J(e,t){return`### ${e}
188
188
 
189
189
  \`\`\`json
190
190
  ${JSON.stringify(x.toJSONSchema(t),null,2)}
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(`
191
+ \`\`\``}var ts=["## 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 pe,readFragment as rs}from"gql.tada";import hr from"figures";var te={cross:hr.cross,tick:hr.tick};var yr=pe(`
193
193
  fragment WorkflowIdMCP on Workflow {
194
194
  id
195
195
  slug
196
196
  }
197
- `),Za=ue(`
197
+ `),os=pe(`
198
198
  query ProjectWorkflowIdsMCP($projectId: String!) {
199
199
  project(id: $projectId) {
200
200
  id
@@ -206,14 +206,14 @@ ${JSON.stringify(x.toJSONSchema(t),null,2)}
206
206
  }
207
207
  }
208
208
  }
209
- `,[hr]),es=ue(`
209
+ `,[yr]),ns=pe(`
210
210
  mutation CreateRunMCP($workflowId: String!, $platforms: [String!]!, $concurrency: Int!) {
211
211
  createRun(workflowId: $workflowId, platforms: $platforms, concurrency: $concurrency) {
212
212
  id
213
213
  status
214
214
  }
215
215
  }
216
- `),ts=ue(`
216
+ `),as=pe(`
217
217
  query RunStatusMCP($id: String!) {
218
218
  run(id: $id) {
219
219
  id
@@ -240,20 +240,20 @@ ${JSON.stringify(x.toJSONSchema(t),null,2)}
240
240
  }
241
241
  }
242
242
  }
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}
243
+ `);async function wr({config:e,slugs:t}){let r=await ss({config:e,slugs:t}),o=await Promise.allSettled(r.map(async({slug:l,workflowId:u})=>({runId:await ls({config:e,workflowId:u}),slug:l}))),n=[],s=[];o.forEach((l,u)=>{let h=r[u];if(h==null)return;if(l.status==="fulfilled"){n.push(l.value);return}let E=l.reason instanceof Error?l.reason.message:String(l.reason);s.push({runId:"",slug:h.slug,summary:`ERROR creating run: ${E}`})}),(await Promise.allSettled(n.map(async({runId:l,slug:u})=>{let h=await ds({config:e,runId:l}),E=is({config:e,runId:l,slug:u}),re=`.ripplo/debug/${l}/`;return{runId:l,slug:u,summary:`View run: ${E}
244
+ Debug artifacts: ${re}
245
245
 
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}:**
247
- ${i.summary}`).join(`
246
+ ${h}`}}))).forEach((l,u)=>{let h=n[u];if(h==null)return;if(l.status==="fulfilled"){s.push(l.value);return}let E=l.reason instanceof Error?l.reason.message:String(l.reason);s.push({runId:h.runId,slug:h.slug,summary:`ERROR polling run ${h.runId}: ${E}`})});let d=s.map(l=>`**${l.slug}:**
247
+ ${l.summary}`).join(`
248
248
 
249
249
  ---
250
250
 
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}
251
+ `);return{results:s,summary:d}}async function ss({config:e,slugs:t}){let r=await V({config:e,document:os,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=>rs(yr,n));return t.map(n=>{let s=o.find(i=>i.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 is({config:e,runId:t,slug:r}){return`${e.ripploServerUrl.replace(/:3000\b/,":3001")}/projects/${e.projectId}/workflows/${r}/runs/${t}`}async function ls({config:e,workflowId:t}){let r=await V({config:e,document:ns,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});if(r.createRun==null)throw new Error("Failed to create run");return r.createRun.id}var cs=2e3,gr=150;async function ds({config:e,runId:t}){let r=0;for(;r<gr;){await ps(cs),r+=1;let n=(await V({config:e,document:as,variables:{id:t}})).run;if(n==null)throw new Error(`Run ${t} not found`);if(!(n.status==="pending"||n.status==="running"))return us({results:n.results??[],runId:t,status:n.status})}return`Run ${t} timed out after polling ${String(gr)} times.`}function us({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 i=s.status==="passed"?te.tick:te.cross,d=s.detail==null?"":` \u2014 ${s.detail}`;o.push(` ${i} ${s.title} (${String(s.duration)}ms)${d}`),s.assertions.forEach(l=>{let u=l.status==="passed"?te.tick:te.cross,h=l.detail==null?"":` \u2014 ${l.detail}`;o.push(` ${u} ${l.description}${h}`)})})}),o.join(`
252
+ `)}function ps(e){return new Promise(t=>{setTimeout(t,e)})}import{z as fs}from"zod";function br(){return ms()}function Sr(){return hs()}function B(e,t){let r=fs.toJSONSchema(t);return`### ${e}
253
253
 
254
254
  \`\`\`json
255
255
  ${JSON.stringify(r,null,2)}
256
- \`\`\``}function ds(){return[`# Ripplo State Graph Spec
256
+ \`\`\``}function ms(){return[`# Ripplo State Graph Spec
257
257
 
258
258
  The graph schema is documented below as JSON Schema (generated from Zod at runtime \u2014 always in sync with the code).
259
259
 
@@ -274,9 +274,9 @@ Dependencies (\`depends\`) are resolved via topological sort. Cycles are rejecte
274
274
 
275
275
  Use \`get_precondition_schema\` for full precondition API schemas, setup guide, and framework-specific auth examples.`].join(`
276
276
 
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(`
277
+ `)}function hs(){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)",q),B("Precondition Check/Execute Request",Ee),B("Check Response",ie),B("Execute Response",le),B("Teardown Request",je),B("Teardown Response",Oe),ys()].join(`
278
278
 
279
- `)}function ps(){return`### Framework-specific auth examples
279
+ `)}function gs(){return`### Framework-specific auth examples
280
280
 
281
281
  #### Supabase (with @supabase/ssr)
282
282
 
@@ -313,7 +313,7 @@ case "auth:user": {
313
313
  - Use \`signInWithPassword()\` to get session tokens after creating the user
314
314
  - Set the cookie in Supabase's expected format: \`sb-<project-ref>-auth-token\`
315
315
  - Always include \`Path=/; SameSite=Lax\` on the Set-Cookie header
316
- - The \`navigateTo\` URL sets the browser's starting page after cookies are injected`}function fs(){return`## Precondition API Setup
316
+ - The \`navigateTo\` URL sets the browser's starting page after cookies are injected`}function ys(){return`## Precondition API Setup
317
317
 
318
318
  To enable precondition execution, the user's app must expose three REST endpoints.
319
319
 
@@ -340,17 +340,18 @@ ripplo generate-types --output apps/server/src/generated/precondition-api.ts #
340
340
 
341
341
  The generated file should be committed to the repo and the \`--output\` path should be importable from the server code without path gymnastics.
342
342
 
343
- ${ms()}
343
+ ${ws()}
344
344
 
345
345
  ### Key principles:
346
346
 
347
- 1. **Fresh, isolated context per run**: Auth preconditions must create a new ephemeral test user/session with unique identifiers (e.g., \`ripplo-test-\${crypto.randomUUID().slice(0,8)}@example.com\`). Data preconditions must create uniquely-named entities. Every run gets a fresh browser context with no shared state.
348
- 2. **Idempotency via check**: The check endpoint prevents double-execution.
349
- 3. **Teardown for cleanup**: Called after each run with all executed precondition names.
350
- 4. **All logic in your app**: Ripplo just calls your endpoints.
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.
347
+ 1. **Guard with environment variable**: Wrap all precondition route registration behind an environment variable check (e.g., \`process.env.ENABLE_RIPPLO_TESTING === "true"\`). These endpoints create users, seed data, and delete records \u2014 they must never be accessible in production. Set \`ENABLE_RIPPLO_TESTING=true\` in local development, CI, and dedicated testing/staging environments \u2014 anywhere you run Ripplo tests.
348
+ 2. **Fresh, isolated context per run**: Auth preconditions must create a new ephemeral test user/session with unique identifiers (e.g., \`ripplo-test-\${crypto.randomUUID().slice(0,8)}@example.com\`). Data preconditions must create uniquely-named entities. Every run gets a fresh browser context with no shared state.
349
+ 3. **Idempotency via check**: The check endpoint prevents double-execution.
350
+ 4. **Teardown for cleanup**: Called after each run with all executed precondition names.
351
+ 5. **All logic in your app**: Ripplo just calls your endpoints.
352
+ 6. **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.
352
353
 
353
- ${ps()}
354
+ ${gs()}
354
355
 
355
356
  ## Best Practices
356
357
 
@@ -361,9 +362,12 @@ ${ps()}
361
362
  5. **Keep precondition handlers fast** \u2014 check should be a lightweight query, execute should create minimal test data
362
363
  6. **Create fresh test users** \u2014 auth preconditions should create ephemeral users, not log in as shared accounts
363
364
  7. **Validate after every edit** \u2014 call \`validate_graph\` to catch missing refs and cycles
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
365
+ 8. **Regenerate types after editing preconditions** \u2014 run \`ripplo generate-types\` when precondition names change
366
+ 9. **Set \`ENABLE_RIPPLO_TESTING=true\` in dev, CI, and staging** \u2014 enable it anywhere you run Ripplo tests, but never in production deployments. Add it to \`.env.local\`, CI config, or your staging environment \u2014 not \`.env.production\``}function ws(){return`### Step 3: Implement the three endpoints
365
367
 
366
- Using the generated types (adjust import path to match your \`--output\`):
368
+ Using the generated types (adjust import path to match your \`--output\`).
369
+
370
+ **Important: Guard these routes behind an environment variable.** These endpoints create users, seed data, and delete records \u2014 they should be enabled in development and dedicated testing/staging environments, but must never be accessible in production. Only register them when \`ENABLE_RIPPLO_TESTING\` is explicitly set.
367
371
 
368
372
  \`\`\`typescript
369
373
  import {
@@ -372,6 +376,11 @@ import {
372
376
  PreconditionTeardownRequestSchema,
373
377
  } from "@/generated/precondition-api";
374
378
 
379
+ // Only register precondition routes when explicitly enabled
380
+ if (process.env.ENABLE_RIPPLO_TESTING !== "true") {
381
+ throw new Error("Precondition routes require ENABLE_RIPPLO_TESTING=true");
382
+ }
383
+
375
384
  // POST /api/test/preconditions/check
376
385
  app.post("/api/test/preconditions/check", async (req, res) => {
377
386
  const { precondition } = PreconditionCheckRequestSchema.parse(req.body);
@@ -434,19 +443,19 @@ app.put("/api/test/preconditions/teardown", async (req, res) => {
434
443
  }
435
444
  res.json({ success: true });
436
445
  });
437
- \`\`\``}import We from"fs";import qe from"path";import hs from"fs";import Cm from"path";import{z as k}from"zod";var De=k.object({edges:k.array(k.object({from:k.string(),to:k.string(),workflow:k.string()})),preconditions:k.record(k.string(),k.unknown()).optional(),resetPrecondition:k.string().optional(),states:k.record(k.string(),k.object({preconditions:k.array(k.string()),route:k.string()})),version:k.literal(3)});function br(e){let t=hs.readFileSync(e,"utf8"),r=JSON.parse(t);return De.parse(r)}function Sr(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}function kr(e){let t=gs(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let r=De.safeParse(t.data);if(!r.success)return{errors:r.error.issues.map(h=>({message:h.message,path:h.path.join(".")})),valid:!1};let o=Sr(r.data),n=Ve(o);if(!n.success)return{errors:n.errors,valid:!1};let s=[...Fe(n.data)],l=qe.join(qe.dirname(e),"workflows"),d=We.existsSync(l),i=new Set(n.data.edges.map(u=>u.workflow));return n.data.edges.forEach((u,h)=>{if(!d){s.push({message:`References workflow "${u.workflow}" but workflows directory does not exist`,path:`edges[${String(h)}].workflow`});return}let E=qe.join(l,`${u.workflow}.json`);We.existsSync(E)||s.push({message:`References workflow "${u.workflow}" but no file exists at workflows/${u.workflow}.json`,path:`edges[${String(h)}].workflow`})}),d&&We.readdirSync(l).filter(u=>u.endsWith(".json")).forEach(u=>{let h=u.replace(/\.json$/,"");i.has(h)||s.push({message:`Workflow file "workflows/${u}" is not referenced by any edge`,path:`workflows/${u}`})}),{errors:s,valid:s.length===0}}function gs(e){try{return{data:br(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}import pe from"fs";import Rr from"path";import{z as A}from"zod";var ys=A.object({baseUrl:A.string().optional(),cloudBaseUrl:A.string(),preconditionApiPath:A.string().optional(),projectId:A.string()});function vr(e){let t=Rr.join(e,".ripplo","settings.json");if(!pe.existsSync(t))return{errors:[{message:".ripplo/settings.json not found",path:""}],valid:!1,warnings:[]};let r=Ss(t);if(!r.success)return{errors:[{message:r.error,path:"settings.json"}],valid:!1,warnings:[]};let o=ys.safeParse(r.data);if(!o.success)return{errors:o.error.issues.map(d=>({message:d.message,path:d.path.join(".")})),valid:!1,warnings:[]};let n=[],s=Rr.join(e,".ripplo","graph.json");return pe.existsSync(s)&&bs(s)&&(o.data.preconditionApiPath==null||o.data.preconditionApiPath.length===0)&&n.push("Graph has preconditions but preconditionApiPath is not set in settings.json. Preconditions will not be executed. Set preconditionApiPath to the URL where your app serves precondition endpoints (can be a relative path appended to baseUrl, or an absolute URL)."),{errors:[],valid:!0,warnings:n}}var ws=A.object({states:A.record(A.string(),A.object({preconditions:A.array(A.string())}))});function bs(e){try{let t=pe.readFileSync(e,"utf8"),r=JSON.parse(t),o=ws.safeParse(r);return o.success?Object.values(o.data.states).some(n=>n.preconditions.length>0):!1}catch{return!1}}function Ss(e){try{let t=pe.readFileSync(e,"utf8");return{data:JSON.parse(t),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}var xr={assertAttribute:"assertion",assertChecked:"assertion",assertCookie:"assertion",assertCount:"assertion",assertDisabled:"assertion",assertEnabled:"assertion",assertFocused:"assertion",assertNotChecked:"assertion",assertNotVisible:"assertion",assertResponse:"assertion",assertText:"assertion",assertTitle:"assertion",assertUrl:"assertion",assertValue:"assertion",assertVisible:"assertion",check:"action",clear:"action",click:"action",clipboard:"other",dblclick:"action",drag:"action",extractText:"other",fail:"other",fill:"action",focus:"action",forEach:"controlFlow",goto:"other",group:"controlFlow",handleDialog:"action",hover:"action",if:"controlFlow",loop:"controlFlow",parallel:"controlFlow",press:"action",rightClick:"action",screenshot:"other",scroll:"action",scrollIntoView:"action",select:"action",setPermission:"other",setVariable:"other",setViewport:"other",try:"controlFlow",type:"action",uncheck:"action",upload:"action",wait:"other",waitFor:"other",waitForRequest:"other",waitForResponse:"other",waitForUrl:"other"},fe=new Set,Le=new Set;Object.entries(xr).forEach(([e,t])=>{t==="assertion"&&fe.add(e),t==="action"&&Le.add(e)});function Pr(e){let t=de(e),{spec:r}=t,o=Ts(r),n=Ns(r),s=ks({orderedNodes:o,spec:r,terminalNodes:n}),l=Es({flags:s,orderedNodes:o,terminalNodes:n,wf:t});return{flags:s,report:l}}function ks({orderedNodes:e,spec:t,terminalNodes:r}){let o=e.filter(d=>fe.has(d.type)).length,n=e.filter(d=>Le.has(d.type)).length,s=Object.keys(t.nodes).length,l=r.some(d=>fe.has(d.type));return[...Rs(o),...vs(l,o),...xs(n),...Ps(o,s)]}function Rs(e){return e===0?["NO_ASSERTIONS: The workflow has zero assertion nodes. It cannot verify its expectedOutcome."]:[]}function vs(e,t){return!e&&t>0?["NO_TERMINAL_ASSERTION: No terminal node (end of flow) is an assertion. The workflow may not verify the final state."]:[]}function xs(e){return e===0?["NO_INTERACTIONS: The workflow has zero interaction nodes (click, fill, select, etc.). It does not exercise any user action."]:[]}function Ps(e,t){if(e>0&&t>3){let r=e/t;if(r<.15){let o=String(Math.round(r*100));return[`LOW_ASSERTION_RATIO: Only ${String(e)}/${String(t)} nodes are assertions (${o}%). Consider adding more verification.`]}}return[]}function Ts(e){let t=new Set,r=[];function o(n){if(t.has(n))return;t.add(n);let s=e.nodes[n];s!=null&&(r.push(s),s.next!=null&&o(s.next),Tr(s).forEach(l=>{o(l)}))}return o(e.entryNode),r}function Tr(e){switch(e.type){case"if":return[...e.consequent,...e.alternate??[]];case"loop":case"forEach":return[...e.body];case"try":return[...e.body,...e.catch??[],...e.finally??[]];case"group":return[...e.nodes];case"parallel":return e.branches.flat();case"assertVisible":case"assertNotVisible":case"assertText":case"assertUrl":case"assertCount":case"assertValue":case"click":case"fill":case"select":case"check":case"uncheck":case"press":case"hover":case"goto":case"waitFor":case"screenshot":case"setViewport":case"wait":case"fail":case"setVariable":case"extractText":case"waitForUrl":case"waitForResponse":case"waitForRequest":case"upload":case"dblclick":case"drag":case"scrollIntoView":case"type":case"focus":case"assertAttribute":case"assertEnabled":case"assertDisabled":case"assertTitle":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertCookie":case"assertResponse":case"clear":case"rightClick":case"handleDialog":case"scroll":case"clipboard":case"setPermission":return[]}}function Ns(e){return Object.values(e.nodes).filter(t=>t.next!=null?!1:Tr(t).length===0)}function w(e){return e.by==="role"?e.name==null?`role=${e.role}`:`role=${e.role}[${e.name}]`:`${e.by}=${e.value}`}function $(e){return e.type==="static"?`"${e.value}"`:`{{${e.name}}}`}function Cs(e){return e.type==="static"?String(e.value):`{{${e.name}}}`}var Nr=new Set,Cr=new Set;Object.entries(xr).forEach(([e,t])=>{t==="controlFlow"&&Nr.add(e),t==="assertion"&&Cr.add(e)});function Ar(e){let t=`[${e.type}]`;return Nr.has(e.type)?Is(e,t):Cr.has(e.type)?$s(e,t):As(e,t)}function As(e,t){let r=e;switch(r.type){case"goto":return`${t} Navigate to ${$(r.url)}`;case"click":return`${t} click ${w(r.locator)}`;case"hover":return`${t} hover ${w(r.locator)}`;case"check":return`${t} check ${w(r.locator)}`;case"uncheck":return`${t} uncheck ${w(r.locator)}`;case"fill":return`${t} Fill ${w(r.locator)} with ${$(r.value)}`;case"select":return`${t} Select ${$(r.value)} in ${w(r.locator)}`;case"press":return`${t} Press "${r.key}"`;case"waitFor":{let o=r.state==null?"":` to be ${r.state}`;return`${t} Wait for ${w(r.locator)}${o}`}case"waitForUrl":return`${t} Wait for URL ${r.operator} ${$(r.expected)}`;case"waitForResponse":return`${t} Wait for response matching ${$(r.urlPattern)}`;case"waitForRequest":return`${t} Wait for request matching ${$(r.urlPattern)}`;case"extractText":return`${t} Extract text from ${w(r.locator)} into $${r.variable}`;case"screenshot":case"clipboard":return`${t} ${r.type}`;case"setViewport":return`${t} setViewport ${String(r.width)}x${String(r.height)}`;case"wait":return`${t} wait ${String(r.duration)}ms`;case"fail":return`${t} fail: ${r.message}`;case"setVariable":return`${t} setVariable ${r.variable}`;case"upload":return`${t} Upload files to ${w(r.locator)}`;case"dblclick":return`${t} Double-click ${w(r.locator)}`;case"drag":return`${t} Drag ${w(r.source)} to ${w(r.target)}`;case"scrollIntoView":return`${t} Scroll into view ${w(r.locator)}`;case"type":return`${t} Type ${$(r.value)} into ${w(r.locator)}`;case"focus":return`${t} Focus ${w(r.locator)}`;case"clear":return`${t} Clear ${w(r.locator)}`;case"rightClick":return`${t} Right-click ${w(r.locator)}`;case"handleDialog":return`${t} Handle dialog: ${r.action}`;case"scroll":return r.locator==null?`${t} Scroll page`:`${t} Scroll ${w(r.locator)}`;case"setPermission":return`${t} Set permission ${r.permission} to ${r.state}`}}function $s(e,t){let r=e;switch(r.type){case"assertVisible":return`${t} Assert visible: ${w(r.locator)}`;case"assertNotVisible":return`${t} Assert not visible: ${w(r.locator)}`;case"assertText":return`${t} Assert text of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertUrl":return`${t} Assert URL ${r.operator} ${$(r.expected)}`;case"assertCount":return`${t} Assert count of ${w(r.locator)} ${r.operator} ${Cs(r.expected)}`;case"assertValue":return`${t} Assert value of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertAttribute":return`${t} Assert attribute "${r.attribute}" of ${w(r.locator)} ${r.operator} ${$(r.expected)}`;case"assertEnabled":return`${t} Assert enabled: ${w(r.locator)}`;case"assertDisabled":return`${t} Assert disabled: ${w(r.locator)}`}}function Is(e,t){let r=e;switch(r.type){case"if":return`${t} if (condition)`;case"loop":return`${t} loop ${String(r.times)} times`;case"forEach":return`${t} forEach ${r.iteratorVar}`;case"parallel":return`${t} parallel (${String(r.branches.length)} branches)`;case"group":return`${t} group (${String(r.nodes.length)} nodes)`;case"try":return`${t} try/catch`}}function Es({flags:e,orderedNodes:t,terminalNodes:r,wf:o}){let n=t.filter(d=>fe.has(d.type)).length,s=t.filter(d=>Le.has(d.type)).length;return[js(o),Os(t),Vs(r),Fs({actionCount:s,assertionCount:n,orderedNodes:t,terminalNodes:r}),...Us(e),Ds].join(`
438
- `)}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(`
446
+ \`\`\``}import We from"fs";import _e from"path";import bs from"fs";import _m from"path";import{z as k}from"zod";var Le=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 kr(e){let t=bs.readFileSync(e,"utf8"),r=JSON.parse(t);return Le.parse(r)}function Rr(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}function vr(e){let t=Ss(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let r=Le.safeParse(t.data);if(!r.success)return{errors:r.error.issues.map(h=>({message:h.message,path:h.path.join(".")})),valid:!1};let o=Rr(r.data),n=Fe(o);if(!n.success)return{errors:n.errors,valid:!1};let s=[...Ue(n.data)],i=_e.join(_e.dirname(e),"workflows"),d=We.existsSync(i),l=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=_e.join(i,`${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(i).filter(u=>u.endsWith(".json")).forEach(u=>{let h=u.replace(/\.json$/,"");l.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 Ss(e){try{return{data:kr(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}import fe from"fs";import xr from"path";import{z as A}from"zod";var ks=A.object({baseUrl:A.string().optional(),cloudBaseUrl:A.string(),preconditionApiPath:A.string().optional(),projectId:A.string()});function Pr(e){let t=xr.join(e,".ripplo","settings.json");if(!fe.existsSync(t))return{baseUrl:void 0,errors:[{message:".ripplo/settings.json not found",path:""}],valid:!1,warnings:[]};let r=xs(t);if(!r.success)return{baseUrl:void 0,errors:[{message:r.error,path:"settings.json"}],valid:!1,warnings:[]};let o=ks.safeParse(r.data);if(!o.success)return{baseUrl:void 0,errors:o.error.issues.map(d=>({message:d.message,path:d.path.join(".")})),valid:!1,warnings:[]};let n=[],s=xr.join(e,".ripplo","graph.json");return fe.existsSync(s)&&vs(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)."),{baseUrl:o.data.baseUrl,errors:[],valid:!0,warnings:n}}async function Tr(e){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return}catch{return`baseUrl (${e}) is not responding. Make sure your dev server is running on that port.`}}var Rs=A.object({states:A.record(A.string(),A.object({preconditions:A.array(A.string())}))});function vs(e){try{let t=fe.readFileSync(e,"utf8"),r=JSON.parse(t),o=Rs.safeParse(r);return o.success?Object.values(o.data.states).some(n=>n.preconditions.length>0):!1}catch{return!1}}function xs(e){try{let t=fe.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 Nr={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"},me=new Set,qe=new Set;Object.entries(Nr).forEach(([e,t])=>{t==="assertion"&&me.add(e),t==="action"&&qe.add(e)});function Cr(e){let t=ue(e),{spec:r}=t,o=$s(r),n=Is(r),s=Ps({orderedNodes:o,spec:r,terminalNodes:n}),i=Fs({flags:s,orderedNodes:o,terminalNodes:n,wf:t});return{flags:s,report:i}}function Ps({orderedNodes:e,spec:t,terminalNodes:r}){let o=e.filter(d=>me.has(d.type)).length,n=e.filter(d=>qe.has(d.type)).length,s=Object.keys(t.nodes).length,i=r.some(d=>me.has(d.type));return[...Ts(o),...Ns(i,o),...Cs(n),...As(o,s)]}function Ts(e){return e===0?["NO_ASSERTIONS: The workflow has zero assertion nodes. It cannot verify its expectedOutcome."]:[]}function Ns(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 Cs(e){return e===0?["NO_INTERACTIONS: The workflow has zero interaction nodes (click, fill, select, etc.). It does not exercise any user action."]:[]}function As(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 $s(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),Ar(s).forEach(i=>{o(i)}))}return o(e.entryNode),r}function Ar(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 Is(e){return Object.values(e.nodes).filter(t=>t.next!=null?!1:Ar(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 Es(e){return e.type==="static"?String(e.value):`{{${e.name}}}`}var $r=new Set,Ir=new Set;Object.entries(Nr).forEach(([e,t])=>{t==="controlFlow"&&$r.add(e),t==="assertion"&&Ir.add(e)});function Er(e){let t=`[${e.type}]`;return $r.has(e.type)?Vs(e,t):Ir.has(e.type)?Os(e,t):js(e,t)}function js(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 Os(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} ${Es(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 Vs(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 Fs({flags:e,orderedNodes:t,terminalNodes:r,wf:o}){let n=t.filter(d=>me.has(d.type)).length,s=t.filter(d=>qe.has(d.type)).length;return[Us(o),Ds(t),Ls(r),Ws({actionCount:s,assertionCount:n,orderedNodes:t,terminalNodes:r}),..._s(e),qs].join(`
447
+ `)}function Us(e){let t=["## Declared Intent",`**Name:** ${e.name}`,`**Description:** ${e.description}`,`**Expected Outcome:** ${e.expectedOutcome}`];if(e.additionalChecks.length>0){let r=e.additionalChecks.map(o=>`- ${o}`).join(`
439
448
  `);t.push(`**Additional Checks:**
440
449
  ${r}`)}return t.join(`
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
450
+ `)}function Ds(e){return["","## Workflow Steps (execution order)",...e.map((r,o)=>`${String(o+1)}. ${Er(r)}`)].join(`
451
+ `)}function Ls(e){return["","## Terminal Nodes (where the workflow ends)",...e.map(r=>`- ${r.id}: ${Er(r)}`)].join(`
452
+ `)}function Ws({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(`
453
+ `)}function _s(e){return e.length===0?[]:[["","## Flags",...e.map(r=>`- ${r}`)].join(`
454
+ `)]}var qs=["","## 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(`
455
+ `);function Or(e){let t=Bs(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(i=>({message:i.message,path:i.path.join(".")})),valid:!1};let o=ae(r.data.spec);if(!o.success)return{errors:o.errors,valid:!1};let n=Ms(o.data);return n.length>0?{errors:n,valid:!1}:{errors:[],valid:!0}}function Bs(e){try{return{data:ue(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}function Ms(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(([i,d])=>{jr(d).forEach(l=>{t.has(l.id)||r.push({message:`references non-existent node "${l.id}"`,path:`nodes.${i}.${l.field}`})})});let o=new Set,n=t.has(e.entryNode)?[e.entryNode]:[],s=0;for(;s<n.length;){let i=n[s];if(s+=1,i==null||o.has(i))continue;o.add(i);let d=e.nodes[i];d!=null&&jr(d).forEach(l=>{o.has(l.id)||n.push(l.id)})}return t.forEach(i=>{o.has(i)||r.push({message:"unreachable from entryNode",path:`nodes.${i}`})}),r}function jr(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((i,d)=>{typeof i=="string"&&t.push({field:`${n}[${String(d)}]`,id:i})})});let o=e.branches;return Array.isArray(o)&&o.forEach((n,s)=>{Array.isArray(n)&&n.forEach((i,d)=>{typeof i=="string"&&t.push({field:`branches[${String(s)}][${String(d)}]`,id:i})})}),t}import Vr from"fs";import Gs from"path";function Fr(e){let t=zs(),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. IMPORTANT: Wrap all precondition routes behind `ENABLE_RIPPLO_TESTING=true` env var \u2014 enable in dev/staging/CI but never in production."," 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. Verify they are guarded behind `ENABLE_RIPPLO_TESTING=true` env var \u2014 if the guard is missing, add it."," 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(`
456
+ `)}function zs(){let e=Gs.join(process.cwd(),".ripplo","workflows");return Vr.existsSync(e)?!Vr.readdirSync(e).some(r=>r.endsWith(".json")):!0}import Dr from"fs";import Hs from"path";var Y="## 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.",Ur="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 Lr(e){return`# Debug a Failing Workflow
448
457
 
449
- ${Ms(e)}
458
+ ${Js(e)}
450
459
 
451
460
  ## Step 1: Trigger a fresh run
452
461
 
@@ -493,7 +502,7 @@ Categorize the root cause:
493
502
 
494
503
  ## Step 4: Fix and re-run
495
504
 
496
- ${K}
505
+ ${Y}
497
506
 
498
507
  ## Important rules
499
508
 
@@ -501,15 +510,15 @@ ${K}
501
510
  - **Evidence before changes.** Never modify the spec without citing specific evidence from the debug artifacts.
502
511
  - **Compare steps.** When a failure is unclear, diff the DOM/storage between the step before and the failing step.
503
512
  - **Check the network.** If the app returns unexpected API responses (check network.jsonl), this is likely an app bug, not a spec issue.
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}**
513
+ - **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 Js(e){if(e!=null)return`Debug the workflow: **${e}**
505
514
 
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:
515
+ Find it in \`.ripplo/workflows/\`. If the name doesn't match exactly, look for a slug or partial match.`;let t=Ys();return t.length===0?"No workflows found in `.ripplo/workflows/`. Create one first with `/create`.":`No specific workflow was provided. Available workflows:
507
516
  ${t.map(r=>`- ${r}`).join(`
508
517
  `)}
509
518
 
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(`
519
+ Ask the user which workflow to debug, or pick the one most likely to be failing.`}function Ys(){let e=Hs.join(process.cwd(),".ripplo","workflows");return Dr.existsSync(e)?Dr.readdirSync(e).filter(t=>t.endsWith(".json")).map(t=>t.replace(/\.json$/,"")):[]}function Wr(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?Ks({baseUrlInstruction:t,scope:e.scope}):[Xs(t),Zs(),ei(),ti(),ni(),ri(),oi(),ai()].join(`
511
520
 
512
- `)}function zs(e){let t=Hs(e.scope);return`# Ripplo Explore (Scoped to Changes)
521
+ `)}function Ks(e){let t=Qs(e.scope);return`# Ripplo Explore (Scoped to Changes)
513
522
 
514
523
  Analyze code changes and create or update workflow specs to test the affected user flows.
515
524
 
@@ -566,7 +575,7 @@ For each confirmed flow, delegate to a sub-agent:
566
575
  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.
567
576
  7. Call \`run\` with the workflow slug. Report the result and include the run URL.
568
577
 
569
- ${K}
578
+ ${Y}
570
579
 
571
580
  ## Step 5: Report summary
572
581
 
@@ -574,7 +583,7 @@ After all workflows are processed, report:
574
583
  - Total workflows created/updated
575
584
  - Pass/fail status for each
576
585
  - Any flows that need user attention (app bugs, unresolvable failures)
577
- - Any flows that were skipped and why`}function Hs(e){return`The user provided this context: "${e}"
586
+ - Any flows that were skipped and why`}function Qs(e){return`The user provided this context: "${e}"
578
587
  - 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.
579
588
  - If it looks like a branch name, run \`git diff main...<branch> --stat\` to see what changed.
580
589
  - If it equals "changes" or is empty, auto-detect:
@@ -582,7 +591,7 @@ After all workflows are processed, report:
582
591
  - If there are uncommitted changes, use those as the diff.
583
592
  - Otherwise, run \`git diff main...HEAD --stat\` to see what changed on this branch vs main.
584
593
  - If on main with no changes, ask the user what they'd like to create workflows for.
585
- - Otherwise, treat it as a description and run \`git diff main...HEAD --stat\` to find relevant changes.`}function Js(e){return`# Ripplo Explore
594
+ - Otherwise, treat it as a description and run \`git diff main...HEAD --stat\` to find relevant changes.`}function Xs(e){return`# Ripplo Explore
586
595
 
587
596
  Build a comprehensive state graph and workflow specs for this application.
588
597
 
@@ -618,7 +627,7 @@ This is a large task. **Aggressively delegate to sub-agents** to keep the main c
618
627
  - **Workflow generation**: Always use sub-agents for writing workflow specs. Launch them in parallel batches.
619
628
  - **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.
620
629
  - **General rule**: If a task involves reading more than 2-3 files or writing more than one file, it should be a sub-agent.
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
630
+ - **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 Zs(){return`## Understanding the application
622
631
 
623
632
  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.
624
633
 
@@ -692,7 +701,7 @@ Map every write operation to its UI trigger:
692
701
  - Which UI component triggers each mutation
693
702
  - Form actions (if using framework form actions)
694
703
  - Optimistic updates and their rollback behavior
695
- - Which mutations are restricted to which roles`}function Ys(){return`## Extracting edges
704
+ - Which mutations are restricted to which roles`}function ei(){return`## Extracting edges
696
705
 
697
706
  From everything discovered, extract EVERY meaningful user journey as an edge.
698
707
 
@@ -720,7 +729,7 @@ Before building the graph, verify completeness:
720
729
  - **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.
721
730
  - **Entity coverage**: For every core entity, is there a create, update, and delete edge? Missing CRUD operations are coverage gaps.
722
731
  - **Role coverage**: If the app has multiple roles, are role-specific actions covered? (e.g., "admin can invite members" vs "member cannot")
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
732
+ - **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 ti(){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 ri(){return`## Bootstrap: verify preconditions with one workflow
724
733
 
725
734
  Before generating all workflows, validate that the precondition API works end-to-end.
726
735
 
@@ -734,7 +743,7 @@ Before generating all workflows, validate that the precondition API works end-to
734
743
  - **App-level bug** (the app itself is broken): note it and move on \u2014 this is not fixable from the test side.
735
744
  6. **Iterate until this first workflow passes.** This proves auth, data seeding, and the run infrastructure all work.
736
745
 
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
746
+ **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 oi(){return`## Generating workflow specs
738
747
 
739
748
  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.
740
749
 
@@ -778,7 +787,7 @@ For each edge, create and verify a workflow spec:
778
787
  5. Call \`validate_workflow\`, fix errors.
779
788
  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.
780
789
  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.
781
- 8. ${Or}
790
+ 8. ${Ur}
782
791
 
783
792
  ### Parallelism
784
793
 
@@ -792,77 +801,17 @@ Each sub-agent should receive: edge details, component file paths, action sequen
792
801
 
793
802
  ### Final summary
794
803
 
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
796
-
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.
798
-
799
- **Delegate this entire section to a sub-agent.** Pass it: the list of precondition names from the graph, the auth architecture summary (how sessions work, how users are created), the data model summary (how to seed entities), and the \`preconditionApiPath\`. The sub-agent handles everything below \u2014 reading source code, generating types, writing endpoint handlers, and wiring into the dev workflow. It should spawn its own sub-agents if it needs to dig deeper into the auth system, trace session creation logic, or understand how to seed specific entity types.
800
-
801
- ### Step 1: Generate types
802
-
803
- Run \`ripplo generate-types --output <path>\` to generate Zod schemas and TypeScript types from the graph's precondition names. Pick an output path that's natural for the project's server code (e.g., \`src/generated/precondition-api.ts\` or \`apps/server/src/generated/precondition-api.ts\`).
804
-
805
- Wire this command into the project's existing codegen workflow \u2014 look for how the project already runs generators (Prisma, GraphQL codegen, etc.) and add \`ripplo generate-types\` alongside it in a package.json script, turbo pipeline, or similar.
806
-
807
- ### Step 2: Implement the endpoints
808
-
809
- Create three endpoints in the app's server. Use the generated types for request validation. Refer to \`get_precondition_schema\` for the full API contract and example code.
810
-
811
- For each precondition in the graph, implement the business logic:
812
-
813
- **Check endpoint** (\`POST {preconditionApiPath}/check\`):
814
- - Receives \`{ "precondition": "auth:admin" }\`
815
- - Returns \`{ "satisfied": true/false }\`
816
- - Should be a lightweight query \u2014 check session cookies, count entities, etc.
817
-
818
- **Execute endpoint** (\`PUT {preconditionApiPath}/execute\`):
819
- - Receives \`{ "precondition": "auth:admin" }\`
820
- - Returns \`{ "success": true/false, "error"?: "..." }\`
821
- - Creates test users, seeds data, etc. Set-Cookie headers are captured automatically by Ripplo.
822
- - **Create fresh ephemeral test users** for auth preconditions \u2014 don't reuse shared accounts.
823
-
824
- **Teardown endpoint** (\`PUT {preconditionApiPath}/teardown\`):
825
- - Receives \`{ "preconditions": ["auth:admin", "data:projects"] }\`
826
- - Returns \`{ "success": true/false }\`
827
- - Cleans up test data created during the run. Fire-and-forget \u2014 errors don't fail the run.
828
-
829
- ### Implementation approach
830
-
831
- - Read the app's existing auth system to understand how sessions are created programmatically (not via UI login)
832
- - Read the data model to understand how to seed entities via direct DB access or internal API calls
833
- - Use the app's existing test utilities, factories, or seed scripts if they exist
834
- - Create a new router/controller for the precondition endpoints \u2014 keep test infrastructure separate from production routes
835
- - Import the generated schemas from the output path for type-safe request parsing
836
- - **Common auth pitfalls to avoid:**
837
- - Do NOT guess auth API methods \u2014 read the actual SDK types/docs (e.g., Supabase has no \`admin.createSession()\`)
838
- - Always include \`Path=/\` and \`SameSite=Lax\` on auth cookies in Set-Cookie headers
839
- - For Supabase: use \`admin.createUser({ email_confirm: true })\` + \`signInWithPassword()\` to get session tokens, then set the \`sb-<ref>-auth-token\` cookie
840
- - For NextAuth: use the adapter's \`createSession()\` method and set the \`next-auth.session-token\` cookie
841
- - Call \`get_precondition_schema\` for framework-specific examples
842
- - Test the precondition API manually (curl) before triggering a full workflow run
843
-
844
- ### Parallel safety
845
-
846
- Multiple workflows run simultaneously. Every precondition executor must create **isolated, non-conflicting data per run**:
847
-
848
- - **Unique identifiers**: Generate unique names/emails/slugs per run using \`crypto.randomUUID()\` or \`Date.now()\` suffixes. Never hardcode entity names like \`"Test Project"\` \u2014 two parallel runs will collide on unique constraints.
849
- - **Return dynamic IDs via \`data\`**: The execute response's \`data\` field passes values to the workflow. Return created entity IDs so workflows reference them dynamically (e.g., \`{ "projectId": "cuid-abc123" }\`).
850
- - **Scoped teardown**: Teardown must only delete entities created by that specific run. The teardown request includes cookies from the run's session \u2014 use them to identify which user/data to clean up. Never use \`deleteMany\` with a prefix match or \`TRUNCATE\` \u2014 it destroys other parallel runs' data.
851
- - **Independent sessions**: Each run creates its own auth session. Never assume a singleton test user or shared session exists.
852
-
853
- ### Step 3: Verify
854
-
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:
804
+ 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 ni(){return'## Wiring up the Precondition API\n\nOnce 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.\n\n**Delegate this entire section to a sub-agent.** Pass it: the list of precondition names from the graph, the auth architecture summary (how sessions work, how users are created), the data model summary (how to seed entities), and the `preconditionApiPath`. The sub-agent handles everything below \u2014 reading source code, generating types, writing endpoint handlers, and wiring into the dev workflow. It should spawn its own sub-agents if it needs to dig deeper into the auth system, trace session creation logic, or understand how to seed specific entity types.\n\n### Step 1: Generate types\n\nRun `ripplo generate-types --output <path>` to generate Zod schemas and TypeScript types from the graph\'s precondition names. Pick an output path that\'s natural for the project\'s server code (e.g., `src/generated/precondition-api.ts` or `apps/server/src/generated/precondition-api.ts`).\n\nWire this command into the project\'s existing codegen workflow \u2014 look for how the project already runs generators (Prisma, GraphQL codegen, etc.) and add `ripplo generate-types` alongside it in a package.json script, turbo pipeline, or similar.\n\n### Step 2: Implement the endpoints\n\nCreate three endpoints in the app\'s server. Use the generated types for request validation. Refer to `get_precondition_schema` for the full API contract and example code.\n\nFor each precondition in the graph, implement the business logic:\n\n**Check endpoint** (`POST {preconditionApiPath}/check`):\n- Receives `{ "precondition": "auth:admin" }`\n- Returns `{ "satisfied": true/false }`\n- Should be a lightweight query \u2014 check session cookies, count entities, etc.\n\n**Execute endpoint** (`PUT {preconditionApiPath}/execute`):\n- Receives `{ "precondition": "auth:admin" }`\n- Returns `{ "success": true/false, "error"?: "..." }`\n- Creates test users, seeds data, etc. Set-Cookie headers are captured automatically by Ripplo.\n- **Create fresh ephemeral test users** for auth preconditions \u2014 don\'t reuse shared accounts.\n\n**Teardown endpoint** (`PUT {preconditionApiPath}/teardown`):\n- Receives `{ "preconditions": ["auth:admin", "data:projects"] }`\n- Returns `{ "success": true/false }`\n- Cleans up test data created during the run. Fire-and-forget \u2014 errors don\'t fail the run.\n\n### Implementation approach\n\n- Read the app\'s existing auth system to understand how sessions are created programmatically (not via UI login)\n- Read the data model to understand how to seed entities via direct DB access or internal API calls\n- Use the app\'s existing test utilities, factories, or seed scripts if they exist\n- Create a new router/controller for the precondition endpoints \u2014 keep test infrastructure separate from production routes\n- **Wrap all precondition routes behind an environment variable guard** (e.g., `ENABLE_RIPPLO_TESTING`). Only register the routes when this variable is explicitly set to `"true"`. These endpoints create users, seed data, and delete records \u2014 they should be enabled in development and dedicated testing/staging environments, but must never be accessible in production. Add the env var to `.env.local`, CI config, or staging environment config \u2014 not `.env.production`\n- Import the generated schemas from the output path for type-safe request parsing\n- **Common auth pitfalls to avoid:**\n - Do NOT guess auth API methods \u2014 read the actual SDK types/docs (e.g., Supabase has no `admin.createSession()`)\n - Always include `Path=/` and `SameSite=Lax` on auth cookies in Set-Cookie headers\n - For Supabase: use `admin.createUser({ email_confirm: true })` + `signInWithPassword()` to get session tokens, then set the `sb-<ref>-auth-token` cookie\n - For NextAuth: use the adapter\'s `createSession()` method and set the `next-auth.session-token` cookie\n - Call `get_precondition_schema` for framework-specific examples\n - Test the precondition API manually (curl) before triggering a full workflow run\n\n### Parallel safety\n\nMultiple workflows run simultaneously. Every precondition executor must create **isolated, non-conflicting data per run**:\n\n- **Unique identifiers**: Generate unique names/emails/slugs per run using `crypto.randomUUID()` or `Date.now()` suffixes. Never hardcode entity names like `"Test Project"` \u2014 two parallel runs will collide on unique constraints.\n- **Return dynamic IDs via `data`**: The execute response\'s `data` field passes values to the workflow. Return created entity IDs so workflows reference them dynamically (e.g., `{ "projectId": "cuid-abc123" }`).\n- **Scoped teardown**: Teardown must only delete entities created by that specific run. The teardown request includes cookies from the run\'s session \u2014 use them to identify which user/data to clean up. Never use `deleteMany` with a prefix match or `TRUNCATE` \u2014 it destroys other parallel runs\' data.\n- **Independent sessions**: Each run creates its own auth session. Never assume a singleton test user or shared session exists.\n\n### Step 3: Verify\n\nEnsure `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 ai(){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 _r(){let e=new si({name:"ripplo",version:"0.1.0"});return ii(e),li(e),ci(e),di(e),ui(e),e}function ii(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:N.string().describe("Absolute path to the workflow JSON file")}},t=>{let r=Or(t.file);if(r.valid)return v("Valid");let o=r.errors.map(n=>`${n.path}: ${n.message}`);return v(`Invalid:
856
805
  ${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}
806
+ `)}`)}),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(ur())),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:N.array(N.string()).min(1).describe("Node type names to get schemas for (e.g. ['click', 'fill'])")}},t=>v(pr({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(fr())),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:N.string().describe("Absolute path to the workflow JSON file")}},t=>{let r=Cr(t.file),o=r.flags.length===0?"PASS":"NEEDS REVIEW";return v(`${o}
858
807
 
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:
808
+ ${r.report}`)})}function li(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(br())),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(Sr())),e.registerTool("validate_graph",{description:"Validate the state graph file. MUST be called after every edit to .ripplo/graph.json.",inputSchema:{file:N.string().describe("Absolute path to the graph JSON file")}},t=>{let r=vr(t.file);if(r.valid)return v("Valid");let o=r.errors.map(n=>`${n.path}: ${n.message}`);return v(`Invalid:
860
809
  ${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?`
810
+ `)}`)}),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:N.string().optional().describe("Working directory (defaults to cwd)")}},async t=>{let r=Pr(t.dir??process.cwd());if(!r.valid){let s=r.errors.map(i=>`${i.path}: ${i.message}`);return v(`Invalid:
811
+ ${s.join(`
812
+ `)}`)}let o=[...r.warnings];if(r.baseUrl!=null){let s=await Tr(r.baseUrl);s!=null&&o.push(s)}let n=o.length>0?`
862
813
  Warnings:
863
- ${r.warnings.join(`
864
- `)}`:"";return v(`Valid${n}`)}let o=r.errors.map(n=>`${n.path}: ${n.message}`);return v(`Invalid:
865
814
  ${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)});
815
+ `)}`:"";return v(`Valid${n}`)})}function ci(e){e.registerPrompt("explore",{argsSchema:{baseUrl:N.string().optional().describe("Base URL of the application (e.g. http://localhost:3000)"),scope:N.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:Wr({baseUrl:t.baseUrl,scope:t.scope}),type:"text"},role:"user"}]}))}function di(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:N.array(N.string()).describe("Workflow slugs to run (supports 1 or many, all run in parallel)")}},t=>cr(async r=>{try{let o=await wr({config:r,slugs:t.slugs});return v(o.summary)}catch(o){let n=o instanceof Error?o.message:String(o),i=n.includes("fetch failed")||n.includes("Failed to connect")||n.includes("Could not reach")||n.includes("ECONNREFUSED")?"\n\nSetup checklist:\n1. Is `ripplo dev` running in a terminal?\n2. Is the dev server running? Check `baseUrl` in `.ripplo/settings.json` \u2014 is the port correct?\n3. Run the `validate_settings` tool to check for configuration issues.":"";return v(`ERROR: ${n}${i}`)}}))}function ui(e){e.registerPrompt("run",{argsSchema:{workflow:N.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(`
816
+ `):`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:N.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:[Fr(t.flow??"the most important user flow"),"",Y].join(`
817
+ `),type:"text"},role:"user"}]})),e.registerPrompt("debug",{argsSchema:{workflow:N.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:Lr(t.workflow),type:"text"},role:"user"}]}))}async function fi(){let e=_r(),t=new pi;await e.connect(t)}fi().catch(e=>{process.exit(1)});