ripplo 0.3.16 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -91
- package/dist/index.js +364 -457
- package/package.json +6 -17
package/dist/index.js
CHANGED
|
@@ -1,119 +1,131 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
`}async function Bt({cwd:e}){let t=zn.join(e,be),n=await Qp(t);return n==null?null:Jc(di,n)}async function me({cwd:e,result:t}){let n=ci(t),r=zn.join(e,be);await Jn.mkdir(zn.dirname(r),{recursive:!0}),await Jn.writeFile(r,Gn(n),"utf8")}function Vt({compiled:e,existing:t}){if(t==null)return"missing";let n=Gn(ci(e)),r=Gn(t);return n===r?"match":"stale"}async function Qp(e){try{return await Jn.readFile(e,"utf8")}catch(t){if(Yp(t)&&t.code==="ENOENT")return null;throw t}}function Yp(e){return e instanceof Error&&"code"in e}function Zp(e){return function(n,r){return r===e||!eu(r)?r:Object.fromEntries(Object.entries(r).toSorted(([o],[i])=>o.localeCompare(i)))}}function eu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Mc,Hc,qc,ai,Kc,Qc,I,St,Yc,Zc,Qn,ep,he,tp,np,v,ri,rp,op,ip,ap,sp,lp,dp,cp,pp,up,mp,fp,yp,gp,hp,kp,Sp,bp,wp,Ap,Rp,Tp,Np,vp,Cp,Lp,xp,Pp,Ep,Op,Ip,_p,jp,Up,$p,Dp,Bp,Vp,Wp,li,Fp,Mp,Hp,XA,GA,qp,Jp,be,zp,Xp,Gp,Kp,di,$e=p(()=>{"use strict";$t();Mc=Dt.object({__codec:Dt.string().min(1),data:Dt.unknown(),version:Dt.number().int().positive()}),Hc=class extends Error{codec;currentVersion;gotVersion;constructor(e){super(`Unsupported ${e.codec} version ${String(e.gotVersion)} (current ${String(e.currentVersion)}). Upgrade Ripplo or rebuild with a compatible CLI.`),this.name="CodecVersionError",this.codec=e.codec,this.currentVersion=e.currentVersion,this.gotVersion=e.gotVersion}},qc=class extends Error{constructor(e){super(`Codec mismatch: expected "${e.expected}", got "${e.got}"`),this.name="CodecMismatchError"}};ai=rt.object({depends:rt.array(rt.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:rt.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:rt.array(rt.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."),Kc=Ue.object({by:Ue.literal("testId"),value:Ue.string().min(1)}),Qc=Ue.object({by:Ue.literal("role"),name:Ue.string().optional(),role:Ue.string().min(1)}),I=Ue.discriminatedUnion("by",[Kc,Qc]),St=si.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),Yc=si.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]),Zc=J.object({type:J.literal("static"),value:J.union([J.string(),J.number(),J.boolean()])}),Qn=J.object({name:J.string().min(1),type:J.literal("variable")}),ep=J.discriminatedUnion("type",[Zc,Qn]),he=J.discriminatedUnion("type",[J.object({type:J.literal("static"),value:J.string()}),Qn]),tp=J.discriminatedUnion("type",[J.object({type:J.literal("static"),value:J.number().int().nonnegative()}),Qn]),np=le.discriminatedUnion("type",[le.object({default:le.string().optional(),type:le.literal("string")}),le.object({default:le.number().optional(),type:le.literal("number")}),le.object({default:le.boolean().optional(),type:le.literal("boolean")}),le.object({key:le.string().min(1),type:le.literal("env")})]),v={id:m.string().min(1).max(200),label:m.string().max(500).optional(),next:m.string().max(200).optional(),uiOnly:m.boolean().optional()},ri=500,rp=m.object({...v,type:m.literal("goto"),url:he}),op=m.object({...v,locator:I,type:m.literal("click")}),ip=m.object({...v,locator:I,type:m.literal("fill"),value:he}),ap=m.object({...v,locator:I,type:m.literal("select"),value:he}),sp=m.object({...v,locator:I,type:m.literal("hover")}),lp=m.object({...v,key:m.string().min(1),locator:I.optional(),type:m.literal("press")}),dp=m.object({...v,locator:I,type:m.literal("check")}),cp=m.object({...v,locator:I,type:m.literal("uncheck")}),pp=m.object({...v,height:m.number().int().positive(),type:m.literal("setViewport"),width:m.number().int().positive()}),up=m.object({...v,message:m.string().min(1),type:m.literal("fail")}),mp=m.object({...v,type:m.literal("setVariable"),value:ep,variable:m.string().min(1)}),fp=m.object({...v,locator:I,type:m.literal("extractText"),variable:m.string().min(1)}),yp=m.object({...v,files:m.array(m.string()).min(1),locator:I,type:m.literal("upload")}),gp=m.object({...v,locator:I,type:m.literal("dblclick")}),hp=m.object({...v,source:I,target:I,type:m.literal("drag")}),kp=m.object({...v,locator:I,type:m.literal("scrollIntoView")}),Sp=m.object({...v,locator:I,type:m.literal("type"),value:he}),bp=m.object({...v,locator:I,type:m.literal("focus")}),wp=m.object({...v,locator:I,type:m.literal("clear")}),Ap=m.object({...v,locator:I,type:m.literal("rightClick")}),Rp=m.object({...v,action:m.enum(["accept","dismiss"]),promptText:m.string().optional(),type:m.literal("handleDialog")}),Tp=m.object({...v,action:m.enum(["read","write"]),type:m.literal("clipboard"),value:he.optional(),variable:m.string().min(1).optional()}),Np=m.object({...v,permission:m.string().min(1),state:m.enum(["granted","prompt"]),type:m.literal("setPermission")}),vp=m.object({...v,locator:I,type:m.literal("assertVisible")}),Cp=m.object({...v,locator:I,type:m.literal("assertNotVisible")}),Lp=m.object({...v,expected:he,locator:I,operator:St,type:m.literal("assertText")}),xp=m.object({...v,expected:he,operator:St,type:m.literal("assertUrl")}),Pp=m.object({...v,expected:tp,locator:I,operator:Yc,type:m.literal("assertCount")}),Ep=m.object({...v,expected:he,locator:I,operator:St,type:m.literal("assertValue")}),Op=m.object({...v,attribute:m.string().min(1),expected:he,locator:I,operator:St,type:m.literal("assertAttribute")}),Ip=m.object({...v,locator:I,type:m.literal("assertEnabled")}),_p=m.object({...v,locator:I,type:m.literal("assertDisabled")}),jp=m.object({...v,expected:he,operator:St,type:m.literal("assertTitle")}),Up=m.object({...v,locator:I,type:m.literal("assertChecked")}),$p=m.object({...v,locator:I,type:m.literal("assertNotChecked")}),Dp=m.object({...v,locator:I,type:m.literal("assertFocused")}),Bp=m.object({...v,locator:I,type:m.literal("assertNotFocused")}),Vp=m.object({...v,budget:m.enum(["fast","slow","async"]),observer:m.string().min(1).max(200),params:m.record(m.string().max(200),he),type:m.literal("assertObserver")}),Wp=m.discriminatedUnion("type",[rp,op,ip,ap,sp,lp,dp,cp,vp,Cp,Lp,xp,Pp,Ep,Op,Ip,_p,pp,up,mp,fp,yp,gp,hp,kp,Sp,bp,wp,Ap,Rp,Tp,Np,jp,Up,$p,Dp,Bp,Vp]),li=m.object({entryNode:m.string().min(1).max(200),nodes:m.record(m.string().max(200),Wp).refine(e=>Object.keys(e).length<=ri,`Workflow has more than ${String(ri)} nodes`),uiOnly:m.boolean().optional(),variableNamespaces:m.record(m.string().max(200),m.string().max(500)).optional(),variables:m.record(m.string().max(200),np).optional()}),Fp=ni.record(ni.string().max(200),ai),Mp={assumedVersion:1,detect:e=>typeof e=="object"&&e!==null&&"entryNode"in e&&"nodes"in e},Hp={assumedVersion:1,detect:e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&!("__codec"in e)},XA=Kn("workflow-spec").legacy(Mp).initial(li).build(),GA=Kn("precondition-map").legacy(Hp).initial(Fp).build(),qp=["fast","slow","async"],Jp=qn.object({budget:qn.enum(qp).describe("Polling budget tier: fast | slow | async"),description:qn.string().min(1).describe("Human-readable description of what this observer checks")}).describe("A named backend state observer. Tests assert against it with assert.backend(observer, params). Implementation lives on the user's server."),be=".ripplo/ripplo.lock",zp=5e3,Xp=K.record(K.string().max(200),K.string().max(200)),Gp=K.object({coverage:K.array(K.string().max(500)).max(2e3).default([]),expectedOutcome:K.string().max(2e3),name:K.string().max(200),preconditions:K.array(K.string().max(200)).max(1e3),requiresKeys:Xp,slug:K.string().max(200),spec:li}),Kp=K.object({observers:K.record(K.string().max(200),Jp),preconditions:K.record(K.string().max(200),ai),tests:K.array(Gp).max(zp)}),di=Kn("ripplo-lockfile").initial(Kp).build()});function pi(e){return e.data}function ui(e){return{as(t){return{data:{label:t,node:e}}}}}var Wt=p(()=>{"use strict"});function Ft(e){let t=e.getPreconditions(),n=e.getObservers(),r=e.getTests();ru(r);let o={};t.forEach(l=>{o[l.name]={depends:[...l.dependsOn],description:l.description,returns:[...l.returns]}});let i={};n.forEach(l=>{i[l.name]={budget:l.budget,description:l.description}});let a=r.map(l=>ou(l,t));return{config:e.getConfig(),observers:i,preconditions:o,tests:a}}function ru(e){let t=new Map;e.forEach(n=>{let r=t.get(n.id);if(r!=null)throw new Error(`Duplicate test id "${n.id}" used by "${r}" and "${n.name}"`);t.set(n.id,n.name)})}function ou(e,t){let n=e.id,{accessedKeys:r,vars:o}=au(e.requiresKeys),i=e.startsAtFn==null?void 0:e.startsAtFn(o),a=e.stepsFn==null?[]:e.stepsFn(o),l=i==null?a:[iu(i),...a],s=su(l,r,e.requiresKeys,e.uiOnly),d=[];Object.keys(e.requiresKeys).length>0&&r.size===0&&e.implemented&&d.push("Test requires preconditions but never references their data \u2014 destructure and use precondition data in steps()");let u=du(e.requires,t);return{additionalChecks:[],coverage:e.coverage,description:e.description,expectedOutcome:e.expectedOutcome,implemented:e.implemented,name:e.name,preconditions:u,requiresKeys:{...e.requiresKeys},slug:n,spec:s,warnings:d}}function iu(e){return ui({type:"goto",url:{type:"static",value:e}}).as(`navigate to ${e}`)}function au(e){let t=new Set,n={};return Object.keys(e).forEach(r=>{n[r]=new Proxy({},{get(o,i){if(typeof i=="string"){let a=`${r}.${i}`;return t.add(a),`{{${a}}}`}}})}),{accessedKeys:t,vars:n}}function su(e,t,n,r){let o={};e.forEach((l,s)=>{let d=`step-${String(s)}`,c=s<e.length-1?`step-${String(s+1)}`:void 0;o[d]=lu(l,d,c)});let i={};t.forEach(l=>{i[l]={default:`test-${l}`,type:"string"}});let a={...n};return{entryNode:"step-0",nodes:o,uiOnly:r,variableNamespaces:a,variables:i}}function lu(e,t,n){let{label:r,node:o}=pi(e);return{...o,id:t,label:r,next:n}}function du(e,t){let n=new Map(t.map(a=>[a.name,a])),r=[],o=new Set;function i(a){o.has(a)||(o.add(a),n.get(a)?.dependsOn.forEach(l=>{i(l)}),r.push(a))}return e.forEach(a=>{i(a)}),r}var Zn=p(()=>{"use strict";Wt()});var Ti=p(()=>{"use strict";Zn();Wt();$t()});import cm from"fs";import Ni from"path";import{config as pm}from"dotenv";import{createJiti as um}from"jiti";function fm(e){return e==null||typeof e!="object"?!1:mm.every(t=>typeof Reflect.get(e,t)=="function")}function ym(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function gm(e){let t=Ni.join(e,".ripplo",".env");cm.existsSync(t)&&pm({override:!0,path:t,quiet:!0})}async function L(e){gm(e);let t=Ni.join(e,".ripplo","index.ts");try{let r=await um(import.meta.url,{moduleCache:!1}).import(t),o=r!=null&&typeof r=="object"&&"default"in r?Reflect.get(r,"default"):r;if(!fm(o))return{error:`${t} must default-export a RipploBuilder (got ${ym(o)})`,ok:!1};let i=Ft(o);return{builder:o,ok:!0,result:i}}catch(n){return{error:n instanceof Error?n.message:String(n),ok:!1}}}var mm,z=p(()=>{"use strict";Ti();mm=["getConfig","getObservers","getPreconditions","getTests","getUnimplemented"]});import Tm from"mustache";function bt({defs:e}){return e==null?{}:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,vm({def:n,name:t})]))}function vm({def:e,name:t}){if(e.type==="env"){let n=process.env[e.key];if(n==null)throw new Error(`Environment variable "${e.key}" not set for variable "${t}"`);return n}return e.default??Nm[e.type]??""}function wt({ref:e,variables:t}){if(e.type==="static")return e.value;let n=t[e.name];if(n==null||typeof n=="object")throw new Error(`Variable "${e.name}" is not defined`);return n}function te({ref:e,variables:t}){let n=String(wt({ref:e,variables:t}));return or({raw:n,variables:t})}function or({raw:e,variables:t}){return Tm.render(e,t,{},{escape:n=>n})}function ir({ref:e,variables:t}){let n=wt({ref:e,variables:t});if(typeof n=="number")return n;let r=Number(n);if(Number.isNaN(r))throw new TypeError(`Cannot convert "${String(n)}" to number`);return r}function lt({name:e,store:t,value:n}){return{...t,[e]:n}}var Nm,De=p(()=>{"use strict";Nm={boolean:!1,number:0,string:""}});function V({locator:e,page:t,variables:n}){switch(e.by){case"testId":return t.getByTestId(Oi(e.value,n));case"role":return t.getByRole(e.role,{exact:!0,name:e.name==null?void 0:Oi(e.name,n)})}}function Oi(e,t){return t==null?e:or({raw:e,variables:t})}var dt=p(()=>{"use strict";De()});async function Ii({node:e,page:t,timeout:n}){await V({locator:e.source,page:t,variables:void 0}).dragTo(V({locator:e.target,page:t,variables:void 0}),{timeout:n})}async function _i({node:e,page:t,timeout:n}){await V({locator:e.locator,page:t,variables:void 0}).click({button:"right",timeout:n})}function ji({node:e,page:t,variables:n}){return t.once("dialog",async r=>{e.action==="accept"?await r.accept(e.promptText??void 0):await r.dismiss()}),{variables:n}}async function Ui({node:e,page:t,variables:n}){if(e.action==="write"){if(e.value==null)throw new Error("clipboard write requires a value");let o=te({ref:e.value,variables:n}),i=JSON.stringify(o);return await t.evaluate(`navigator.clipboard.writeText(${i})`),{variables:n}}if(e.variable==null)throw new Error("clipboard read requires a variable name to store the result");let r=String(await t.evaluate("navigator.clipboard.readText()"));return{variables:lt({name:e.variable,store:n,value:r})}}async function $i({node:e,page:t}){let n=t.context();e.state==="granted"?await n.grantPermissions([e.permission]):await n.clearPermissions()}var Di=p(()=>{"use strict";dt();De()});async function ar({node:e,page:t,timeout:n,variables:r}){switch(e.type){case"click":case"check":case"uncheck":case"clear":case"dblclick":case"focus":case"hover":case"scrollIntoView":return Lm({node:e,page:t,timeout:n,variables:r});case"rightClick":return await _i({node:e,page:t,timeout:n}),{variables:r};case"goto":{let o=te({ref:e.url,variables:r});return await t.goto(o,{timeout:n,waitUntil:"domcontentloaded"}),await t.waitForLoadState("load",{timeout:n}),await t.waitForFunction("document.body != null && document.body.childElementCount > 0 && (document.body.textContent?.trim().length ?? 0) > 0",void 0,{timeout:n}),await t.evaluate("new Promise((resolve) => { requestAnimationFrame(() => requestAnimationFrame(() => resolve(undefined))); })"),{variables:r}}case"fill":return Pm({node:e,page:t,timeout:n,variables:r});case"select":return Em({node:e,page:t,timeout:n,variables:r});case"type":return Om({node:e,page:t,timeout:n,variables:r});case"press":return await xm({node:e,page:t,timeout:n}),{variables:r};case"drag":return await Ii({node:e,page:t,timeout:n}),{variables:r};case"upload":return Im({node:e,page:t,timeout:n,variables:r});case"extractText":return _m({node:e,page:t,timeout:n,variables:r});case"setVariable":{let o=wt({ref:e.value,variables:r});return{variables:lt({name:e.variable,store:r,value:o})}}case"fail":throw new Error(e.message);case"setViewport":return await t.setViewportSize({height:e.height,width:e.width}),{variables:r};case"handleDialog":return ji({node:e,page:t,variables:r});case"clipboard":return Ui({node:e,page:t,variables:r});case"setPermission":return await $i({node:e,page:t}),{variables:r}}}async function Lm({node:e,page:t,timeout:n,variables:r}){return await V({locator:e.locator,page:t,variables:r})[Cm[e.type]]({timeout:n}),{variables:r}}async function xm({node:e,page:t,timeout:n}){e.locator==null?await t.keyboard.press(e.key):await V({locator:e.locator,page:t,variables:void 0}).press(e.key,{timeout:n})}async function Pm({node:e,page:t,timeout:n,variables:r}){let o=te({ref:e.value,variables:r});return await V({locator:e.locator,page:t,variables:r}).fill(o,{timeout:n}),{variables:r}}async function Em({node:e,page:t,timeout:n,variables:r}){let o=te({ref:e.value,variables:r});return await V({locator:e.locator,page:t,variables:r}).selectOption(o,{timeout:n}),{variables:r}}async function Om({node:e,page:t,timeout:n,variables:r}){let o=te({ref:e.value,variables:r});return await V({locator:e.locator,page:t,variables:r}).pressSequentially(o,{timeout:n}),{variables:r}}async function Im({node:e,page:t,timeout:n,variables:r}){return await V({locator:e.locator,page:t,variables:r}).setInputFiles(e.files,{timeout:n}),{variables:r}}async function _m({node:e,page:t,timeout:n,variables:r}){let o=await V({locator:e.locator,page:t,variables:r}).textContent({timeout:n});if(o==null)throw new Error("extractText: element had no text content");return{variables:lt({name:e.variable,store:r,value:o})}}var Cm,sr=p(()=>{"use strict";Di();dt();De();Cm={check:"check",clear:"clear",click:"click",dblclick:"dblclick",focus:"focus",hover:"hover",scrollIntoView:"scrollIntoViewIfNeeded",uncheck:"uncheck"}});async function Be({page:e,runStartTime:t,targets:n}){let r=e.viewportSize();if(r==null)throw new Error("Page has no viewport set");return{annotations:await $m(n),snapshotTimestamp:Math.round(performance.now()-t),url:e.url(),viewportHeight:r.height,viewportWidth:r.width}}function jm(e){return"locator"in e}function Um(e){let t=globalThis.__ripploRrwebMirror?.getId(e);return t!=null&&t>0?t:void 0}async function $m(e){return(await Promise.all(e.map(n=>Dm(n)))).filter(n=>n!=null)}async function Dm(e){if(!jm(e))return{height:0,label:e.label,rrwebNodeId:void 0,type:e.type,width:0,x:0,y:0};if(!await e.locator.isVisible().catch(()=>!1))return;let n=await e.locator.boundingBox().catch(()=>null);if(n==null)return;let r=await e.locator.evaluate(Um).catch(()=>{})??void 0;return{height:Math.round(n.height),label:e.label,rrwebNodeId:r,type:e.type,width:Math.round(n.width),x:Math.round(n.x),y:Math.round(n.y)}}function qt({node:e,page:t}){if(e.type==="assertUrl")return[{label:e.type,type:"urlBar"}];if(e.type==="drag"){let o=V({locator:e.source,page:t,variables:void 0}),i=V({locator:e.target,page:t,variables:void 0});return[{label:"drag-source",locator:o,type:"action"},{label:"drag-target",locator:i,type:"action"}]}if(!Bm(e))return[];let n=e.type.startsWith("assert")?"assertion":"action",r=V({locator:e.locator,page:t,variables:void 0});return[{label:e.type,locator:r,type:n}]}function Bm(e){return"locator"in e&&e.locator!=null}var At=p(()=>{"use strict";dt()});import{z as Vm}from"zod";function h({description:e,execute:t,name:n,schema:r}){let o=Vm.toJSONSchema(r,{target:"draft-2020-12"});return{anthropicTool:{description:e,input_schema:{...o,type:"object"},name:n},name:n,async execute(i,a){let l=r.parse(a);return{...await Promise.resolve(t(i,l)),kind:"action"}}}}async function A(e){let t=e.specNode==null?[]:qt({node:e.specNode,page:e.page}),n=await Be({page:e.page,runStartTime:e.runStartTime,targets:t}),r=[...e.assertions],o={annotations:n.annotations,assertions:r,detail:e.detail,duration:Math.round(e.duration),nodeId:`agent-step-${String(e.stepIndex)}`,nodeType:e.nodeType,recordingEndMs:void 0,recordingStartMs:void 0,snapshotTimestamp:n.snapshotTimestamp,status:e.status,stepIndex:e.stepIndex,title:e.title,url:n.url,viewportHeight:n.viewportHeight,viewportWidth:n.viewportWidth},i=r.length>0?r.map(a=>`${a.status}: ${a.description} \u2014 ${a.detail??""}`).join(`
|
|
4
|
-
`)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
${
|
|
11
|
-
|
|
2
|
+
import{execFileSync as la}from"child_process";import ca from"fs";import dt from"path";function Kt(e){let t=ua(e);return t??bn(e)}function bn(e){let t=dt.dirname(e);return da(dt.join(e,".ripplo"))?e:t===e?null:bn(t)}function da(e){try{return ca.statSync(e).isDirectory()}catch{return!1}}function ua(e){let t=pa(["rev-parse","--show-toplevel"],e);if(t==null)return null;let r=t.trim();return r.length===0?null:dt.isAbsolute(r)?r:dt.resolve(e,r)}function pa(e,t){try{return la("git",e,{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"]})}catch{return null}}import kn from"fs";import mt from"path";import{config as ga}from"dotenv";import{z as pt}from"zod";import Be from"fs";import Yt from"path";import{z as ut}from"zod";var Sn=Yt.join(".ripplo","project.json"),Jt=[".env",".env.local"],ma=ut.object({envFiles:ut.array(ut.string().min(1)).optional(),projectId:ut.string().min(1)});function Xt(e){return Yt.join(e,Sn)}function Qt(e){let t=Xt(e);if(!Be.existsSync(t))throw new Error(`ripplo: missing ${Sn}. Run \`ripplo init\` to create it.`);let r=JSON.parse(Be.readFileSync(t,"utf8")),n=ma.parse(r);return{envFiles:n.envFiles??Jt,projectId:n.projectId}}function Zt(e){let t=Xt(e);if(Be.existsSync(t))try{return Qt(e)}catch{return}}function vn({cwd:e,envFiles:t,projectId:r}){let n=Xt(e);Be.mkdirSync(Yt.dirname(n),{recursive:!0});let o={projectId:r};t!=null&&!fa(t)&&(o.envFiles=[...t]),Be.writeFileSync(n,JSON.stringify(o,null,2)+`
|
|
3
|
+
`)}function fa(e){return e.length!==Jt.length?!1:e.every((t,r)=>t===Jt[r])}function Rn(e){let r=Zt(e)?.envFiles??[".env",".env.local"],n=mt.join(e,".ripplo");r.forEach(o=>{let i=mt.resolve(n,o);kn.existsSync(i)&&ga({override:!0,path:i,quiet:!0})}),er=void 0}var ya=pt.object({RIPPLO_APP_URL:pt.url(),RIPPLO_ENGINE_URL:pt.url(),RIPPLO_WEBHOOK_SECRET:pt.string().min(1)}),er;function Ae(){return er??=ha(),er}function ha(){let e=ya.safeParse(process.env);if(!e.success){let r=e.error.issues.map(s=>` ${s.path.join(".")}: ${s.message}`).join(`
|
|
4
|
+
`),n=tr(process.cwd()),o=n.map(s=>` ${s}`).join(`
|
|
5
|
+
`),i=n.length>0?`
|
|
6
|
+
|
|
7
|
+
Declared env file(s) not found at this path:
|
|
8
|
+
${o}
|
|
9
|
+
If you're in a git worktree, the env file may not have been copied from the main checkout \u2014 recreate it (or symlink to a shared file outside the working tree).`:"";throw new Error(`ripplo: env config invalid:
|
|
10
|
+
${r}
|
|
11
|
+
|
|
12
|
+
Add missing values to the env file(s) declared in .ripplo/project.json.${i}`)}let t=e.data;return{appUrl:t.RIPPLO_APP_URL,engineUrl:t.RIPPLO_ENGINE_URL,webhookSecret:t.RIPPLO_WEBHOOK_SECRET}}function tr(e){let r=Zt(e)?.envFiles??[],n=mt.join(e,".ripplo");return r.map(o=>mt.resolve(n,o)).filter(o=>!kn.existsSync(o))}import jh from"yargs";import{hideBin as Nh}from"yargs/helpers";import{graphql as Mu}from"gql.tada";var wa=Object.prototype.toString,Ie=Array.isArray||function(t){return wa.call(t)==="[object Array]"};function nr(e){return typeof e=="function"}function ba(e){return Ie(e)?"array":typeof e}function rr(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function xn(e,t){return e!=null&&typeof e=="object"&&t in e}function Sa(e,t){return e!=null&&typeof e!="object"&&e.hasOwnProperty&&e.hasOwnProperty(t)}var va=RegExp.prototype.test;function ka(e,t){return va.call(e,t)}var Ra=/\S/;function xa(e){return!ka(Ra,e)}var Pa={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function Ea(e){return String(e).replace(/[&<>"'`=\/]/g,function(r){return Pa[r]})}var Ca=/\s*/,Ta=/\s+/,Pn=/\s*=/,Aa=/\s*\}/,$a=/#|\^|\/|>|\{|&|=|!/;function Ia(e,t){if(!e)return[];var r=!1,n=[],o=[],i=[],s=!1,a=!1,l="",c=0;function d(){if(s&&!a)for(;i.length;)delete o[i.pop()];else i=[];s=!1,a=!1}var u,f,b;function w(N){if(typeof N=="string"&&(N=N.split(Ta,2)),!Ie(N)||N.length!==2)throw new Error("Invalid tags: "+N);u=new RegExp(rr(N[0])+"\\s*"),f=new RegExp("\\s*"+rr(N[1])),b=new RegExp("\\s*"+rr("}"+N[1]))}w(t||te.tags);for(var h=new Ge(e),S,C,D,q,j,U;!h.eos();){if(S=h.pos,D=h.scanUntil(u),D)for(var oe=0,Te=D.length;oe<Te;++oe)q=D.charAt(oe),xa(q)?(i.push(o.length),l+=q):(a=!0,r=!0,l+=" "),o.push(["text",q,S,S+1]),S+=1,q===`
|
|
13
|
+
`&&(d(),l="",c=0,r=!1);if(!h.scan(u))break;if(s=!0,C=h.scan($a)||"name",h.scan(Ca),C==="="?(D=h.scanUntil(Pn),h.scan(Pn),h.scanUntil(f)):C==="{"?(D=h.scanUntil(b),h.scan(Aa),h.scanUntil(f),C="&"):D=h.scanUntil(f),!h.scan(f))throw new Error("Unclosed tag at "+h.pos);if(C==">"?j=[C,D,S,h.pos,l,c,r]:j=[C,D,S,h.pos],c++,o.push(j),C==="#"||C==="^")n.push(j);else if(C==="/"){if(U=n.pop(),!U)throw new Error('Unopened section "'+D+'" at '+S);if(U[1]!==D)throw new Error('Unclosed section "'+U[1]+'" at '+S)}else C==="name"||C==="{"||C==="&"?a=!0:C==="="&&w(D)}if(d(),U=n.pop(),U)throw new Error('Unclosed section "'+U[1]+'" at '+h.pos);return Na(ja(o))}function ja(e){for(var t=[],r,n,o=0,i=e.length;o<i;++o)r=e[o],r&&(r[0]==="text"&&n&&n[0]==="text"?(n[1]+=r[1],n[3]=r[3]):(t.push(r),n=r));return t}function Na(e){for(var t=[],r=t,n=[],o,i,s=0,a=e.length;s<a;++s)switch(o=e[s],o[0]){case"#":case"^":r.push(o),n.push(o),r=o[4]=[];break;case"/":i=n.pop(),i[5]=o[2],r=n.length>0?n[n.length-1][4]:t;break;default:r.push(o)}return t}function Ge(e){this.string=e,this.tail=e,this.pos=0}Ge.prototype.eos=function(){return this.tail===""};Ge.prototype.scan=function(t){var r=this.tail.match(t);if(!r||r.index!==0)return"";var n=r[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n};Ge.prototype.scanUntil=function(t){var r=this.tail.search(t),n;switch(r){case-1:n=this.tail,this.tail="";break;case 0:n="";break;default:n=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=n.length,n};function $e(e,t){this.view=e,this.cache={".":this.view},this.parent=t}$e.prototype.push=function(t){return new $e(t,this)};$e.prototype.lookup=function(t){var r=this.cache,n;if(r.hasOwnProperty(t))n=r[t];else{for(var o=this,i,s,a,l=!1;o;){if(t.indexOf(".")>0)for(i=o.view,s=t.split("."),a=0;i!=null&&a<s.length;)a===s.length-1&&(l=xn(i,s[a])||Sa(i,s[a])),i=i[s[a++]];else i=o.view[t],l=xn(o.view,t);if(l){n=i;break}o=o.parent}r[t]=n}return nr(n)&&(n=n.call(this.view)),n};function z(){this.templateCache={_cache:{},set:function(t,r){this._cache[t]=r},get:function(t){return this._cache[t]},clear:function(){this._cache={}}}}z.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};z.prototype.parse=function(t,r){var n=this.templateCache,o=t+":"+(r||te.tags).join(":"),i=typeof n<"u",s=i?n.get(o):void 0;return s==null&&(s=Ia(t,r),i&&n.set(o,s)),s};z.prototype.render=function(t,r,n,o){var i=this.getConfigTags(o),s=this.parse(t,i),a=r instanceof $e?r:new $e(r,void 0);return this.renderTokens(s,a,n,t,o)};z.prototype.renderTokens=function(t,r,n,o,i){for(var s="",a,l,c,d=0,u=t.length;d<u;++d)c=void 0,a=t[d],l=a[0],l==="#"?c=this.renderSection(a,r,n,o,i):l==="^"?c=this.renderInverted(a,r,n,o,i):l===">"?c=this.renderPartial(a,r,n,i):l==="&"?c=this.unescapedValue(a,r):l==="name"?c=this.escapedValue(a,r,i):l==="text"&&(c=this.rawValue(a)),c!==void 0&&(s+=c);return s};z.prototype.renderSection=function(t,r,n,o,i){var s=this,a="",l=r.lookup(t[1]);function c(f){return s.render(f,r,n,i)}if(l){if(Ie(l))for(var d=0,u=l.length;d<u;++d)a+=this.renderTokens(t[4],r.push(l[d]),n,o,i);else if(typeof l=="object"||typeof l=="string"||typeof l=="number")a+=this.renderTokens(t[4],r.push(l),n,o,i);else if(nr(l)){if(typeof o!="string")throw new Error("Cannot use higher-order sections without the original template");l=l.call(r.view,o.slice(t[3],t[5]),c),l!=null&&(a+=l)}else a+=this.renderTokens(t[4],r,n,o,i);return a}};z.prototype.renderInverted=function(t,r,n,o,i){var s=r.lookup(t[1]);if(!s||Ie(s)&&s.length===0)return this.renderTokens(t[4],r,n,o,i)};z.prototype.indentPartial=function(t,r,n){for(var o=r.replace(/[^ \t]/g,""),i=t.split(`
|
|
14
|
+
`),s=0;s<i.length;s++)i[s].length&&(s>0||!n)&&(i[s]=o+i[s]);return i.join(`
|
|
15
|
+
`)};z.prototype.renderPartial=function(t,r,n,o){if(n){var i=this.getConfigTags(o),s=nr(n)?n(t[1]):n[t[1]];if(s!=null){var a=t[6],l=t[5],c=t[4],d=s;l==0&&c&&(d=this.indentPartial(s,c,a));var u=this.parse(d,i);return this.renderTokens(u,r,n,d,o)}}};z.prototype.unescapedValue=function(t,r){var n=r.lookup(t[1]);if(n!=null)return n};z.prototype.escapedValue=function(t,r,n){var o=this.getConfigEscape(n)||te.escape,i=r.lookup(t[1]);if(i!=null)return typeof i=="number"&&o===te.escape?String(i):o(i)};z.prototype.rawValue=function(t){return t[1]};z.prototype.getConfigTags=function(t){return Ie(t)?t:t&&typeof t=="object"?t.tags:void 0};z.prototype.getConfigEscape=function(t){if(t&&typeof t=="object"&&!Ie(t))return t.escape};var te={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){ze.templateCache=e},get templateCache(){return ze.templateCache}},ze=new z;te.clearCache=function(){return ze.clearCache()};te.parse=function(t,r){return ze.parse(t,r)};te.render=function(t,r,n,o){if(typeof t!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+ba(t)+'" was given as the first argument for mustache#render(template, view, partials)');return ze.render(t,r,n,o)};te.escape=Ea;te.Scanner=Ge;te.Context=$e;te.Writer=z;var En=te;function Ke({defs:e}){return e==null?{}:Object.fromEntries(Object.entries(e).map(([t,r])=>[t,La({def:r,name:t})]))}var Oa={boolean:!1,number:0,string:""};function La({def:e,name:t}){if(e.type==="env"){let r=process.env[e.key];if(r==null)throw new Error(`Environment variable "${e.key}" not set for variable "${t}"`);return r}return e.default??Oa[e.type]??""}function Je({ref:e,variables:t}){if(e.type==="static")return e.value;let r=t[e.name];if(r==null||typeof r=="object")throw new Error(`Variable "${e.name}" is not defined`);return r}function G({ref:e,variables:t}){let r=String(Je({ref:e,variables:t}));return or({raw:r,variables:t})}function or({raw:e,variables:t}){return En.render(e,t,{},{escape:r=>r})}function ir({ref:e,variables:t}){let r=Je({ref:e,variables:t});if(typeof r=="number")return r;let n=Number(r);if(Number.isNaN(n))throw new TypeError(`Cannot convert "${String(r)}" to number`);return n}function je({name:e,store:t,value:r}){return{...t,[e]:r}}function L({locator:e,page:t,variables:r}){switch(e.by){case"testId":return t.getByTestId(Cn(e.value,r));case"role":return t.getByRole(e.role,{exact:!0,name:e.name==null?void 0:Cn(e.name,r)})}}function Cn(e,t){return t==null?e:or({raw:e,variables:t})}async function Tn({node:e,page:t,timeout:r}){await L({locator:e.source,page:t,variables:void 0}).dragTo(L({locator:e.target,page:t,variables:void 0}),{timeout:r})}async function An({node:e,page:t,timeout:r}){await L({locator:e.locator,page:t,variables:void 0}).click({button:"right",timeout:r})}function $n({node:e,page:t,variables:r}){return t.once("dialog",async n=>{e.action==="accept"?await n.accept(e.promptText??void 0):await n.dismiss()}),{variables:r}}async function In({node:e,page:t,variables:r}){if(e.action==="write"){if(e.value==null)throw new Error("clipboard write requires a value");let o=G({ref:e.value,variables:r}),i=JSON.stringify(o);return await t.evaluate(`navigator.clipboard.writeText(${i})`),{variables:r}}if(e.variable==null)throw new Error("clipboard read requires a variable name to store the result");let n=String(await t.evaluate("navigator.clipboard.readText()"));return{variables:je({name:e.variable,store:r,value:n})}}async function jn({node:e,page:t}){let r=t.context();e.state==="granted"?await r.grantPermissions([e.permission]):await r.clearPermissions()}async function sr({node:e,page:t,timeout:r,variables:n}){switch(e.type){case"click":case"check":case"uncheck":case"clear":case"dblclick":case"focus":case"hover":case"scrollIntoView":return _a({node:e,page:t,timeout:r,variables:n});case"rightClick":return await An({node:e,page:t,timeout:r}),{variables:n};case"goto":{let o=G({ref:e.url,variables:n});return await t.goto(o,{timeout:r,waitUntil:"domcontentloaded"}),await t.waitForLoadState("load",{timeout:r}),await t.waitForFunction("document.body != null && document.body.childElementCount > 0 && (document.body.textContent?.trim().length ?? 0) > 0",void 0,{timeout:r}),await t.evaluate("new Promise((resolve) => { requestAnimationFrame(() => requestAnimationFrame(() => resolve(undefined))); })"),{variables:n}}case"fill":return Va({node:e,page:t,timeout:r,variables:n});case"select":return Fa({node:e,page:t,timeout:r,variables:n});case"type":return Ma({node:e,page:t,timeout:r,variables:n});case"press":return await Ua({node:e,page:t,timeout:r}),{variables:n};case"drag":return await Tn({node:e,page:t,timeout:r}),{variables:n};case"upload":return Wa({node:e,page:t,timeout:r,variables:n});case"extractText":return Ha({node:e,page:t,timeout:r,variables:n});case"setVariable":{let o=Je({ref:e.value,variables:n});return{variables:je({name:e.variable,store:n,value:o})}}case"fail":throw new Error(e.message);case"setViewport":return await t.setViewportSize({height:e.height,width:e.width}),{variables:n};case"handleDialog":return $n({node:e,page:t,variables:n});case"clipboard":return In({node:e,page:t,variables:n});case"setPermission":return await jn({node:e,page:t}),{variables:n}}}var Da={check:"check",clear:"clear",click:"click",dblclick:"dblclick",focus:"focus",hover:"hover",scrollIntoView:"scrollIntoViewIfNeeded",uncheck:"uncheck"};async function _a({node:e,page:t,timeout:r,variables:n}){return await L({locator:e.locator,page:t,variables:n})[Da[e.type]]({timeout:r}),{variables:n}}async function Ua({node:e,page:t,timeout:r}){e.locator==null?await t.keyboard.press(e.key):await L({locator:e.locator,page:t,variables:void 0}).press(e.key,{timeout:r})}async function Va({node:e,page:t,timeout:r,variables:n}){let o=G({ref:e.value,variables:n});return await L({locator:e.locator,page:t,variables:n}).fill(o,{timeout:r}),{variables:n}}async function Fa({node:e,page:t,timeout:r,variables:n}){let o=G({ref:e.value,variables:n});return await L({locator:e.locator,page:t,variables:n}).selectOption(o,{timeout:r}),{variables:n}}async function Ma({node:e,page:t,timeout:r,variables:n}){let o=G({ref:e.value,variables:n});return await L({locator:e.locator,page:t,variables:n}).pressSequentially(o,{timeout:r}),{variables:n}}async function Wa({node:e,page:t,timeout:r,variables:n}){return await L({locator:e.locator,page:t,variables:n}).setInputFiles(e.files,{timeout:r}),{variables:n}}async function Ha({node:e,page:t,timeout:r,variables:n}){let o=await L({locator:e.locator,page:t,variables:n}).textContent({timeout:r});if(o==null)throw new Error("extractText: element had no text content");return{variables:je({name:e.variable,store:n,value:o})}}import _l from"@anthropic-ai/sdk";import{z as Nn}from"zod";import{z as Ja}from"zod";async function ye({page:e,runStartTime:t,targets:r}){let n=e.viewportSize();if(n==null)throw new Error("Page has no viewport set");return{annotations:await za(r),snapshotTimestamp:Math.round(performance.now()-t),url:e.url(),viewportHeight:n.height,viewportWidth:n.width}}function qa(e){return"locator"in e}function Ba(e){let t=globalThis.__ripploRrwebMirror?.getId(e);return t!=null&&t>0?t:void 0}async function za(e){return(await Promise.all(e.map(r=>Ga(r)))).filter(r=>r!=null)}async function Ga(e){if(!qa(e))return{height:0,label:e.label,rrwebNodeId:void 0,type:e.type,width:0,x:0,y:0};if(!await e.locator.isVisible().catch(()=>!1))return;let r=await e.locator.boundingBox().catch(()=>null);if(r==null)return;let n=await e.locator.evaluate(Ba).catch(()=>{})??void 0;return{height:Math.round(r.height),label:e.label,rrwebNodeId:n,type:e.type,width:Math.round(r.width),x:Math.round(r.x),y:Math.round(r.y)}}function ft({node:e,page:t}){if(e.type==="assertUrl")return[{label:e.type,type:"urlBar"}];if(e.type==="drag"){let o=L({locator:e.source,page:t,variables:void 0}),i=L({locator:e.target,page:t,variables:void 0});return[{label:"drag-source",locator:o,type:"action"},{label:"drag-target",locator:i,type:"action"}]}if(!Ka(e))return[];let r=e.type.startsWith("assert")?"assertion":"action",n=L({locator:e.locator,page:t,variables:void 0});return[{label:e.type,locator:n,type:r}]}function Ka(e){return"locator"in e&&e.locator!=null}function y({description:e,execute:t,name:r,schema:n}){let o=Ja.toJSONSchema(n,{target:"draft-2020-12"});return{anthropicTool:{description:e,input_schema:{...o,type:"object"},name:r},name:r,async execute(i,s){let a=n.parse(s);return{...await Promise.resolve(t(i,a)),kind:"action"}}}}async function v(e){let t=e.specNode==null?[]:ft({node:e.specNode,page:e.page}),r=await ye({page:e.page,runStartTime:e.runStartTime,targets:t}),n=[...e.assertions],o={annotations:r.annotations,assertions:n,detail:e.detail,duration:Math.round(e.duration),nodeId:`agent-step-${String(e.stepIndex)}`,nodeType:e.nodeType,recordingEndMs:void 0,recordingStartMs:void 0,snapshotTimestamp:r.snapshotTimestamp,status:e.status,stepIndex:e.stepIndex,title:e.title,url:r.url,viewportHeight:r.viewportHeight,viewportWidth:r.viewportWidth},i=n.length>0?n.map(s=>`${s.status}: ${s.description} \u2014 ${s.detail??""}`).join(`
|
|
16
|
+
`):`${e.status}: ${e.title}`;return{specNode:e.specNode,stepResult:o,toolOutput:i}}var Ya=Nn.object({selector:Nn.string().describe("CSS selector for the checkbox or radio button")}),On=y({description:"Assert that a checkbox or radio button is checked",name:"assert_checked",schema:Ya,execute:async(e,t)=>{let r=performance.now(),n=await e.page.locator(t.selector).isChecked().catch(()=>!1),o=n?"passed":"failed",i=[{description:`Element ${t.selector} is checked`,detail:n?void 0:"Element is not checked",status:o}];return v({assertions:i,detail:n?"Element is checked":"Element is not checked",duration:performance.now()-r,nodeType:"assertChecked",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:o,stepIndex:e.stepIndex,title:`Assert checked: ${t.selector}`})}});import{z as Ln}from"zod";var Xa=Ln.object({selector:Ln.string().describe("CSS selector for the element to check focus on")}),Dn=y({description:"Assert that an element has keyboard focus. Use for accessibility tab-order testing.",name:"assert_focused",schema:Xa,execute:async(e,t)=>{let r=performance.now(),o=!!await e.page.locator(t.selector).evaluate("(el) => document.activeElement === el").catch(()=>!1),i=o?"passed":"failed",s=[{description:`Element ${t.selector} is focused`,detail:o?void 0:"Element does not have focus",status:i}];return v({assertions:s,detail:o?"Element is focused":"Element does not have focus",duration:performance.now()-r,nodeType:"assertFocused",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:i,stepIndex:e.stepIndex,title:`Assert focused: ${t.selector}`})}});import{z as ar}from"zod";var Qa=ar.object({expected:ar.string().describe("The expected text content"),selector:ar.string().describe("CSS selector for the element to check")}),_n=y({description:"Assert that an element's text content matches the expected value",name:"assert_text",schema:Qa,execute:async(e,t)=>{let r=performance.now(),n=await e.page.locator(t.selector).textContent({timeout:5e3}).catch(()=>null),o=n!=null&&n.includes(t.expected),i=o?"passed":"failed",s=[{description:`Text contains "${t.expected}"`,detail:`Actual: "${n??"(not found)"}"`,status:i}];return v({assertions:s,detail:o?`Text matches: "${t.expected}"`:`Expected "${t.expected}", got "${n??"(not found)"}"`,duration:performance.now()-r,nodeType:"assertText",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:i,stepIndex:e.stepIndex,title:`Assert text: ${t.selector}`})}});import{z as lr}from"zod";var Za=lr.object({expected:lr.string().describe("Expected page title or substring"),operator:lr.enum(["equals","contains","startsWith","endsWith"]).describe("Comparison operator").default("contains")}),Un=y({description:"Assert that the page title matches an expected value",name:"assert_title",schema:Za,execute:async(e,t)=>{let r=performance.now(),n=await e.page.title(),o=el({actual:n,expected:t.expected,operator:t.operator}),i=o?"passed":"failed",s=[{description:`Title ${t.operator} "${t.expected}"`,detail:o?void 0:`Got: "${n}"`,status:i}],a=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:a,operator:t.operator,type:"assertTitle"};return v({assertions:s,detail:o?"Title matches":`Expected title ${t.operator} "${t.expected}", got "${n}"`,duration:performance.now()-r,nodeType:"assertTitle",page:e.page,runStartTime:e.runStartTime,specNode:l,status:i,stepIndex:e.stepIndex,title:`Assert title ${t.operator} "${t.expected}"`})}});function el({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 Vn}from"zod";var tl=Vn.object({selector:Vn.string().describe("CSS selector for the element to check")}),Fn=y({description:"Assert that an element matching the selector is visible on the page",name:"assert_visible",schema:tl,execute:async(e,t)=>{let r=performance.now(),n=await e.page.locator(t.selector).isVisible().catch(()=>!1),o=n?"passed":"failed",i=[{description:`Element ${t.selector} is visible`,detail:n?"Element is visible":"Element is not visible",status:o}];return v({assertions:i,detail:n?"Element is visible":"Element is not visible",duration:performance.now()-r,nodeType:"assertVisible",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:o,stepIndex:e.stepIndex,title:`Assert visible: ${t.selector}`})}});import{z as Mn}from"zod";var rl=Mn.object({selector:Mn.string().describe("CSS selector for the checkbox to check")}),Wn=y({description:"Check a checkbox matching the CSS selector",name:"check",schema:rl,execute:async(e,t)=>{let r=performance.now();return await e.page.locator(t.selector).check({timeout:5e3}),v({assertions:[],detail:`Checked ${t.selector}`,duration:performance.now()-r,nodeType:"check",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:"passed",stepIndex:e.stepIndex,title:`Check ${t.selector}`})}});import{z as Hn}from"zod";var nl=Hn.object({selector:Hn.string().describe("CSS selector for the input to clear")}),qn=y({description:"Clear the contents of an input field",name:"clear",schema:nl,execute:async(e,t)=>{let r=performance.now();return await e.page.locator(t.selector).clear({timeout:5e3}),v({assertions:[],detail:`Cleared ${t.selector}`,duration:performance.now()-r,nodeType:"clear",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:"passed",stepIndex:e.stepIndex,title:`Clear ${t.selector}`})}});import{z as Bn}from"zod";var ol=Bn.object({selector:Bn.string().describe("CSS selector for the element to click")}),zn=y({description:"Click an element matching the CSS selector",name:"click",schema:ol,execute:async(e,t)=>{let r=performance.now();return await e.page.locator(t.selector).click({timeout:5e3}),v({assertions:[],detail:`Clicked ${t.selector}`,duration:performance.now()-r,nodeType:"click",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:"passed",stepIndex:e.stepIndex,title:`Click ${t.selector}`})}});import{z as cr}from"zod";var il=cr.object({action:cr.enum(["read","write"]).describe("Whether to read from or write to the clipboard"),value:cr.string().optional().describe("Text to write (required for write action)")}),Gn=y({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:il,execute:async(e,t)=>{let r=performance.now(),n=`agent-step-${String(e.stepIndex)}`;if(t.action==="write"){if(t.value==null)throw new Error("clipboard write requires a value");let s=JSON.stringify(t.value);await e.page.evaluate(`navigator.clipboard.writeText(${s})`);let a={action:"write",id:n,type:"clipboard",value:{type:"static",value:t.value}};return v({assertions:[],detail:`Wrote to clipboard: "${t.value}"`,duration:performance.now()-r,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:a,status:"passed",stepIndex:e.stepIndex,title:"Clipboard write"})}let o=String(await e.page.evaluate("navigator.clipboard.readText()")),i={action:"read",id:n,type:"clipboard"};return v({assertions:[],detail:`Clipboard contents: "${o}"`,duration:performance.now()-r,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:i,status:"passed",stepIndex:e.stepIndex,title:"Clipboard read"})}});import{z as gt}from"zod";var Kn=gt.object({summary:gt.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:gt.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.")}),Jn={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:{...gt.toJSONSchema(Kn,{target:"draft-2020-12"}),type:"object"},name:"complete_test"},name:"complete_test",execute(e,t){let r=Kn.parse(t),n={kind:"verdict",summary:r.summary,toolOutput:`Verdict: ${r.verdict}
|
|
17
|
+
${r.summary}`,verdict:r.verdict};return Promise.resolve(n)}};import{z as Yn}from"zod";var sl=Yn.object({selector:Yn.string().describe("CSS selector for the element to extract text from")}),Xn=y({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:sl,execute:async(e,t)=>{let r=performance.now(),o=await e.page.locator(t.selector).textContent({timeout:5e3})??"";return v({assertions:[],detail:`Extracted text: "${o}"`,duration:performance.now()-r,nodeType:"extractText",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:"passed",stepIndex:e.stepIndex,title:`Extract text from ${t.selector}`})}});import{z as dr}from"zod";var al=dr.object({selector:dr.string().describe("CSS selector for the input element"),value:dr.string().describe("The text to type into the element")}),Qn=y({description:"Clear and type text into an input element matching the CSS selector",name:"fill",schema:al,execute:async(e,t)=>{let r=performance.now();return await e.page.locator(t.selector).fill(t.value,{timeout:5e3}),v({assertions:[],detail:`Filled ${t.selector} with "${t.value}"`,duration:performance.now()-r,nodeType:"fill",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:"passed",stepIndex:e.stepIndex,title:`Fill ${t.selector}`})}});import{z as Zn}from"zod";var ll=Zn.object({level:Zn.string().describe("Filter by log level: 'error', 'warning', 'log', 'info', 'debug', or 'all'").default("all")}),eo=y({description:"Get console log messages from the browser. Optionally filter by level (error, warning, log, info, debug, all).",name:"get_console_logs",schema:ll,execute:(e,t)=>{let r=t.level==="all"?e.monitor.consoleEntries:e.monitor.consoleEntries.filter(o=>o.level===t.level);if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console ${t.level==="all"?"messages":t.level+" messages"} recorded.`};let n=r.map(o=>cl(o)).join(`
|
|
18
|
+
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(r.length)} console messages:
|
|
19
|
+
${n}`}}});function cl(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as to}from"zod";var ur=50,dl=to.object({urlFilter:to.string().describe("Optional regex to filter network entries by URL. Omit to see all.").default("")}),ro=y({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:dl,execute:(e,t)=>{let r=t.urlFilter.length>0?new RegExp(t.urlFilter,"i"):void 0,n=r==null?e.monitor.networkEntries:e.monitor.networkEntries.filter(a=>r.test(a.url));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No network requests recorded."};let o=n.slice(-ur),i=o.map(a=>{let l=a.statusCode==null?"pending":String(a.statusCode),c=a.responseHeaders["content-type"]??"";return`${a.method} ${l} ${a.url} [${c}]`}).join(`
|
|
20
|
+
`),s=n.length>ur?`
|
|
21
|
+
(showing last ${String(ur)} of ${String(n.length)})`:"";return{specNode:void 0,stepResult:void 0,toolOutput:`${String(o.length)} network requests:${s}
|
|
22
|
+
${i}`}}});import{z as no}from"zod";var ul=no.object({urlPattern:no.string().describe("Regex pattern to match the request URL")}),oo=y({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:ul,execute:(e,t)=>{let r=new RegExp(t.urlPattern,"i"),n=e.monitor.networkEntries.filter(l=>r.test(l.url));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let o=n.at(-1);if(o==null)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let i=o.statusCode==null?"pending":String(o.statusCode),s=Object.entries(o.responseHeaders).map(([l,c])=>` ${l}: ${c}`).join(`
|
|
23
|
+
`),a=o.responseBody??"(no body captured)";return{specNode:void 0,stepResult:void 0,toolOutput:`${o.method} ${i} ${o.url}
|
|
12
24
|
|
|
13
25
|
Response Headers:
|
|
14
|
-
${
|
|
26
|
+
${s}
|
|
15
27
|
|
|
16
28
|
Body:
|
|
17
|
-
${
|
|
29
|
+
${a}`}}});import{z as io}from"zod";var pl=io.object({selector:io.string().optional().describe("CSS selector to scope the tree to a subtree (defaults to full page)")}),so=y({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:pl,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 ml}from"zod";var fl=ml.object({}),ao=y({description:"Get a text representation of the current page content for inspection",name:"get_page_content",schema:fl,execute:async(e,t)=>{let r=await e.page.locator("body").textContent({timeout:5e3}),n=e.page.url(),o=await e.page.title();return{specNode:void 0,stepResult:void 0,toolOutput:`URL: ${n}
|
|
18
30
|
Title: ${o}
|
|
19
31
|
|
|
20
|
-
${
|
|
21
|
-
${
|
|
32
|
+
${r??""}`}}});import{z as gl}from"zod";var yl=gl.object({}),lo=y({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:yl,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((n,o)=>`--- Error ${String(o+1)} ---
|
|
33
|
+
${n}`).join(`
|
|
22
34
|
|
|
23
35
|
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(e.monitor.pageErrors.length)} page errors:
|
|
24
36
|
|
|
25
|
-
${
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
${
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(
|
|
33
|
-
${o}`}}})});import{z as
|
|
34
|
-
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(
|
|
35
|
-
${o}`}}})
|
|
36
|
-
`)
|
|
37
|
-
`),o=Tf({contextLines:Af,lines:r,maxResults:wf,pattern:t.pattern});return o.length===0?{specNode:void 0,stepResult:void 0,toolOutput:`No matches found for pattern: ${t.pattern}`}:{specNode:void 0,stepResult:void 0,toolOutput:o.join(`
|
|
37
|
+
${r}`}}});import{z as co}from"zod";var hl=co.object({type:co.enum(["all","cookies","localStorage","sessionStorage"]).describe("Which storage to retrieve").default("all")}),po=y({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:hl,execute:async(e,t)=>({specNode:void 0,stepResult:void 0,toolOutput:[...t.type==="all"||t.type==="cookies"?[await wl(e.page)]:[],...t.type==="all"||t.type==="localStorage"?[await uo(e.page,"localStorage")]:[],...t.type==="all"||t.type==="sessionStorage"?[await uo(e.page,"sessionStorage")]:[]].join(`
|
|
38
|
+
|
|
39
|
+
`)})});async function wl(e){let t=await e.context().cookies();if(t.length===0)return`## Cookies
|
|
40
|
+
(none)`;let r=t.map(n=>` ${n.name}=${n.value} (domain=${n.domain}, httpOnly=${String(n.httpOnly)}, secure=${String(n.secure)}, sameSite=${n.sameSite})`);return`## Cookies (${String(t.length)})
|
|
41
|
+
${r.join(`
|
|
42
|
+
`)}`}async function uo(e,t){let r=await e.evaluate(`JSON.stringify(Object.fromEntries(Object.entries(${t})))`);return`## ${t}
|
|
43
|
+
${String(r)}`}import{z as pr}from"zod";var bl=pr.object({action:pr.enum(["accept","dismiss"]).describe("Whether to accept or dismiss the dialog"),promptText:pr.string().optional().describe("Text to enter for prompt dialogs")}),mo=y({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:bl,execute:(e,t)=>{let r=performance.now();e.page.once("dialog",async i=>{t.action==="accept"?await i.accept(t.promptText??void 0):await i.dismiss()});let n=`agent-step-${String(e.stepIndex)}`,o={action:t.action,id:n,type:"handleDialog"};return v({assertions:[],detail:`Dialog handler set: ${t.action}`,duration:performance.now()-r,nodeType:"handleDialog",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Handle dialog: ${t.action}`})}});import{z as fo}from"zod";var Sl=fo.object({selector:fo.string().describe("CSS selector for the element to hover over")}),go=y({description:"Hover over an element matching the CSS selector",name:"hover",schema:Sl,execute:async(e,t)=>{let r=performance.now();return await e.page.locator(t.selector).hover({timeout:5e3}),v({assertions:[],detail:`Hovered over ${t.selector}`,duration:performance.now()-r,nodeType:"hover",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:"passed",stepIndex:e.stepIndex,title:`Hover ${t.selector}`})}});import{z as mr}from"zod";var vl=mr.object({permission:mr.string().describe("Permission name (e.g. geolocation, notifications, camera, clipboard-read)"),state:mr.enum(["granted","prompt"]).describe("Permission state to set")}),yo=y({description:"Set a browser permission state (geolocation, notifications, camera, etc.)",name:"set_permission",schema:vl,execute:async(e,t)=>{let r=performance.now(),n=e.page.context();t.state==="granted"?await n.grantPermissions([t.permission]):await n.clearPermissions();let i={id:`agent-step-${String(e.stepIndex)}`,permission:t.permission,state:t.state,type:"setPermission"};return v({assertions:[],detail:`Set ${t.permission} to ${t.state}`,duration:performance.now()-r,nodeType:"setPermission",page:e.page,runStartTime:e.runStartTime,specNode:i,status:"passed",stepIndex:e.stepIndex,title:`Set permission: ${t.permission} \u2192 ${t.state}`})}});import{z as ho}from"zod";var kl=ho.object({url:ho.string().describe("The URL to navigate to")}),wo=y({description:"Navigate the browser to a URL",name:"navigate",schema:kl,execute:async(e,t)=>{let r=performance.now();await e.page.goto(t.url,{waitUntil:"domcontentloaded"});let o={id:`agent-step-${String(e.stepIndex)}`,type:"goto",url:{type:"static",value:t.url}};return v({assertions:[],detail:`Navigated to ${t.url}`,duration:performance.now()-r,nodeType:"goto",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Navigate to ${t.url}`})}});import{z as bo}from"zod";var Rl=bo.object({key:bo.string().describe("Key to press, e.g. 'Enter', 'Tab', 'Escape'")}),So=y({description:"Press a keyboard key",name:"press",schema:Rl,execute:async(e,t)=>{let r=performance.now();await e.page.keyboard.press(t.key);let o={id:`agent-step-${String(e.stepIndex)}`,key:t.key,type:"press"};return v({assertions:[],detail:`Pressed ${t.key}`,duration:performance.now()-r,nodeType:"press",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Press ${t.key}`})}});import{z as fr}from"zod";var xl=fr.object({height:fr.number().int().positive().describe("Viewport height in pixels"),width:fr.number().int().positive().describe("Viewport width in pixels")}),vo=y({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:xl,execute:async(e,t)=>{let r=performance.now();await e.page.setViewportSize({height:t.height,width:t.width});let n=`agent-step-${String(e.stepIndex)}`,o={height:t.height,id:n,type:"setViewport",width:t.width};return v({assertions:[],detail:`Resized viewport to ${String(t.width)}x${String(t.height)}`,duration:performance.now()-r,nodeType:"setViewport",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Resize viewport to ${String(t.width)}x${String(t.height)}`})}});import{z as ko}from"zod";var Pl=ko.object({selector:ko.string().describe("CSS selector for the element to right-click")}),Ro=y({description:"Right-click an element to open the context menu",name:"right_click",schema:Pl,execute:async(e,t)=>{let r=performance.now();return await e.page.locator(t.selector).click({button:"right",timeout:5e3}),v({assertions:[],detail:`Right-clicked ${t.selector}`,duration:performance.now()-r,nodeType:"rightClick",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:"passed",stepIndex:e.stepIndex,title:`Right-click ${t.selector}`})}});import{z as xo}from"zod";var El=xo.object({pattern:xo.string().describe("Regex pattern to search console log messages")}),Po=y({description:"Search console log messages for a regex pattern. Returns matching entries.",name:"search_console",schema:El,execute:(e,t)=>{let r=new RegExp(t.pattern,"i"),n=e.monitor.consoleEntries.filter(i=>r.test(i.text));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console messages matching: ${t.pattern}`};let o=n.map(i=>Cl(i)).join(`
|
|
44
|
+
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(n.length)} matching console messages:
|
|
45
|
+
${o}`}}});function Cl(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as Eo}from"zod";var Tl=Eo.object({pattern:Eo.string().describe("Regex pattern to search across network request URLs and response bodies")}),Co=y({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:Tl,execute:(e,t)=>{let r=new RegExp(t.pattern,"i"),n=e.monitor.networkEntries.filter(i=>r.test(i.url)||i.responseBody!=null&&r.test(i.responseBody));if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network entries matching: ${t.pattern}`};let o=n.map(i=>{let s=i.statusCode==null?"pending":String(i.statusCode),a=r.test(i.url)?" [URL match]":"",l=i.responseBody!=null&&r.test(i.responseBody)?" [body match]":"";return`${i.method} ${s} ${i.url}${a}${l}`}).join(`
|
|
46
|
+
`);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(n.length)} matching network entries:
|
|
47
|
+
${o}`}}});import{z as To}from"zod";var Al=20,$l=2,Il=To.object({pattern:To.string().describe("Regex pattern to search for in the page HTML")}),Ao=y({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:Il,execute:async(e,t)=>{let n=(await e.page.content()).split(`
|
|
48
|
+
`),o=jl({contextLines:$l,lines:n,maxResults:Al,pattern:t.pattern});return o.length===0?{specNode:void 0,stepResult:void 0,toolOutput:`No matches found for pattern: ${t.pattern}`}:{specNode:void 0,stepResult:void 0,toolOutput:o.join(`
|
|
38
49
|
---
|
|
39
|
-
`)}}})
|
|
40
|
-
|
|
41
|
-
`)}
|
|
50
|
+
`)}}});function jl({contextLines:e,lines:t,maxResults:r,pattern:n}){let o=new RegExp(n,"i"),i=[];return t.forEach((s,a)=>{if(i.length>=r||!o.test(s))return;let l=Math.max(0,a-e),c=Math.min(t.length-1,a+e),d=t.slice(l,c+1).map((u,f)=>{let b=l+f+1;return`${l+f===a?">":" "} ${String(b)}: ${u}`}).join(`
|
|
51
|
+
`);i.push(d)}),i}import{z as gr}from"zod";var Nl=gr.object({selector:gr.string().describe("CSS selector for the select element"),value:gr.string().describe("The option value to select")}),$o=y({description:"Select an option from a dropdown/select element",name:"select",schema:Nl,execute:async(e,t)=>{let r=performance.now();return await e.page.locator(t.selector).selectOption(t.value,{timeout:5e3}),v({assertions:[],detail:`Selected "${t.value}" in ${t.selector}`,duration:performance.now()-r,nodeType:"select",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:"passed",stepIndex:e.stepIndex,title:`Select ${t.value}`})}});import{z as Io}from"zod";var Ol=Io.object({selector:Io.string().describe("CSS selector for the checkbox to uncheck")}),jo=y({description:"Uncheck a checkbox matching the CSS selector",name:"uncheck",schema:Ol,execute:async(e,t)=>{let r=performance.now();return await e.page.locator(t.selector).uncheck({timeout:5e3}),v({assertions:[],detail:`Unchecked ${t.selector}`,duration:performance.now()-r,nodeType:"uncheck",page:e.page,runStartTime:e.runStartTime,specNode:void 0,status:"passed",stepIndex:e.stepIndex,title:`Uncheck ${t.selector}`})}});var yt=class{method;requestHeaders;requestPostData;timestamp;url;responseBody=void 0;responseHeaders={};statusCode=void 0;constructor(t){this.method=t.method(),this.requestHeaders=t.headers(),this.requestPostData=t.postData()??void 0,this.timestamp=Date.now(),this.url=t.url()}applyResponse(t){this.statusCode=t.status(),this.responseHeaders=t.headers(),t.text().then(r=>{this.responseBody=r.length>1e5?`${r.slice(0,1e5)}... (truncated)`:r}).catch(()=>{this.responseBody="(unable to read body)"})}};function Ye(e){let t=[],r=[],n=[],o=new Map;function i(u){t.push({level:u.type(),text:u.text(),timestamp:Date.now(),url:u.location().url})}function s(u){let f=new yt(u);o.set(u,f),r.push(f)}function a(u){let f=o.get(u.request());f!=null&&(o.delete(u.request()),f.applyResponse(u))}function l(u){n.push(`${u.message}
|
|
52
|
+
${u.stack??""}`)}function c(u){let f=u.failure(),b=new yt(u);b.responseBody=`(request failed: ${f?.errorText??"unknown"})`,r.push(b)}e.on("console",i),e.on("request",s),e.on("response",a),e.on("pageerror",l),e.on("requestfailed",c);function d(){e.off("console",i),e.off("request",s),e.off("response",a),e.off("pageerror",l),e.off("requestfailed",c)}return{consoleEntries:t,detach:d,networkEntries:r,pageErrors:n}}var yr=[wo,zn,Qn,So,Wn,jo,$o,go,ao,Ao,qn,Ro,mo,Gn,yo,Fn,_n,Un,On,Dn,eo,ro,oo,lo,so,po,Po,Co,vo,Xn,Jn],Ll=new Map(yr.map(e=>[e.name,e])),hr=yr.map(e=>e.anthropicTool),No=yr.map(e=>`- **${e.name}**: ${e.anthropicTool.description??""}`).join(`
|
|
53
|
+
`);async function Oo({input:e,monitor:t,name:r,page:n,runStartTime:o,stepIndex:i}){let s=Ll.get(r);if(s==null)throw new Error(`Unknown agent tool: ${r}`);return s.execute({monitor:t,page:n,runStartTime:o,stepIndex:i},e)}import DS from"fs";import US from"path";import Dl from"pino";var g=Dl({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}});var Ul=50,Lo=16384;async function wr({baseUrl:e,executedPreconditions:t,extraVariables:r,onStep:n,page:o,runId:i,serverUrl:s,spec:a,systemPrompt:l,token:c,workflowContext:d}){let u=new _l({apiKey:"ripplo",baseURL:`${s}/api/proxy/anthropic`,defaultHeaders:{Authorization:`Bearer ${c}`,"x-run-id":i}}),f=performance.now(),b=Ye(o);await zl({baseUrl:e,page:o});let w=Ml({extraVariables:r,spec:a}),h=Hl({baseUrl:e,executedPreconditions:t,spec:a,systemPrompt:l,variables:w,workflowContext:d}),S=ql({baseUrl:e,spec:a,variables:w}),D=[{content:Bl({page:o,startUrl:S}),role:"user"}],q=[],j=[],U={findings:"",stepIndex:0,verdict:void 0};U=await Vl({client:u,messages:D,monitor:b,onStep:n,page:o,runStartTime:f,specNodes:j,state:U,steps:q,system:h}),U.verdict==null&&(U=await Fl({client:u,messages:D,monitor:b,onStep:n,page:o,runStartTime:f,specNodes:j,state:U,steps:q,system:h}));let oe=Kl(j);return{findings:U.findings,generatedSpec:oe,monitor:b,steps:q,verdict:U.verdict??"fail"}}function Do({result:e,state:t}){return{findings:e.newFindings.length>0?e.newFindings:t.findings,stepIndex:e.nextStepIndex,verdict:e.verdict??t.verdict}}async function Vl({client:e,messages:t,monitor:r,onStep:n,page:o,runStartTime:i,specNodes:s,state:a,steps:l,system:c}){let d=a;for(let u=0;u<Ul;u++){g.info("Agent iteration %d",u+1);let f=await e.messages.create({max_tokens:Lo,messages:t,model:"server-controlled",system:c,tools:hr}),b=await _o({messages:t,monitor:r,onStep:n,page:o,response:f,runStartTime:i,specNodes:s,stepIndex:d.stepIndex,steps:l});if(d=Do({result:b,state:d}),!b.continueLoop)break}return d}async function Fl({client:e,messages:t,monitor:r,onStep:n,page:o,runStartTime:i,specNodes:s,state:a,steps:l,system:c}){g.warn("Agent exited without calling complete_test \u2014 forcing completion"),t.push({content:"You must call the complete_test tool now with your verdict and summary. Do not perform any more actions \u2014 just call complete_test.",role:"user"});let d=await e.messages.create({max_tokens:Lo,messages:t,model:"server-controlled",system:c,tool_choice:{name:"complete_test",type:"tool"},tools:hr}),u=await _o({messages:t,monitor:r,onStep:n,page:o,response:d,runStartTime:i,specNodes:s,stepIndex:a.stepIndex,steps:l});return Do({result:u,state:a})}function Ml({extraVariables:e,spec:t}){let r=Wl(e,t?.variableNamespaces);return{...Ke({defs:t?.variables}),...r}}function Wl(e,t){if(e==null||t==null)return{};let r=new Map;Object.entries(t).forEach(([o,i])=>{r.set(i,o)});let n={};return Object.entries(e).forEach(([o,i])=>{let s=r.get(o);Object.entries(i).forEach(([a,l])=>{n[s==null?a:`${s}.${a}`]=l})}),n}function Hl({baseUrl:e,executedPreconditions:t,spec:r,systemPrompt:n,variables:o,workflowContext:i}){let s=i==null?"":[`
|
|
42
54
|
|
|
43
55
|
## Workflow Under Test`,`**Name:** ${i.name}`,`**Description:** ${i.description}`,`**Expected Outcome:** ${i.expectedOutcome}`,`
|
|
44
56
|
Focus your testing ONLY on this specific workflow. Do not test unrelated parts of the application.`].join(`
|
|
45
|
-
`),
|
|
57
|
+
`),a=r==null?"":`
|
|
46
58
|
|
|
47
59
|
Reference workflow spec (the steps a user would follow):
|
|
48
60
|
\`\`\`json
|
|
49
|
-
${JSON.stringify(
|
|
50
|
-
\`\`\``,
|
|
51
|
-
`),
|
|
61
|
+
${JSON.stringify(r,null,2)}
|
|
62
|
+
\`\`\``,l=t.map(b=>`- ${b}`).join(`
|
|
63
|
+
`),c=t.length===0?"":`
|
|
52
64
|
|
|
53
65
|
## Setup Already Completed
|
|
54
66
|
The following setup steps have already been run before your session started:
|
|
55
|
-
${
|
|
67
|
+
${l}
|
|
56
68
|
|
|
57
|
-
Do not repeat any of these steps.`,
|
|
58
|
-
`),
|
|
69
|
+
Do not repeat any of these steps.`,d=Object.entries(o),u=d.map(([b,w])=>`- **${b}:** ${typeof w=="object"?JSON.stringify(w):String(w)}`).join(`
|
|
70
|
+
`),f=d.length===0?"":`
|
|
59
71
|
|
|
60
72
|
## Resolved Variables
|
|
61
73
|
${u}`;return[`You are testing the application at: ${e}`,"Use the provided tools to navigate, interact with, and assert things about the page.","Use get_page_content to inspect the page when you need to understand what's on screen.","Follow the workflow steps to complete the task.",`
|
|
62
|
-
## Available Tools`,
|
|
63
|
-
## Agent Profile (HIGHEST PRIORITY \u2014 these instructions override any defaults above)`,
|
|
64
|
-
`)}function
|
|
65
|
-
`),nextStepIndex:
|
|
66
|
-
`);return{continueLoop:
|
|
67
|
-
${e}`];t!=null&&t.length>0&&
|
|
68
|
-
${t}`),
|
|
69
|
-
${
|
|
70
|
-
`)),
|
|
71
|
-
|
|
72
|
-
`)}function
|
|
74
|
+
## Available Tools`,No,s,c,a,f,`
|
|
75
|
+
## Agent Profile (HIGHEST PRIORITY \u2014 these instructions override any defaults above)`,n].join(`
|
|
76
|
+
`)}function ql({baseUrl:e,spec:t,variables:r}){if(t==null)return e;let n=t.nodes[t.entryNode];if(n==null||n.type!=="goto"||n.url.type!=="static")return e;let i=n.url.value.replaceAll(/\{\{(\w+)\}\}/g,(s,a)=>{let l=r[a];return l==null?`{{${a}}}`:typeof l=="object"?JSON.stringify(l):String(l)});return i.startsWith("http")?i:`${e}${i.startsWith("/")?"":"/"}${i}`}function Bl({page:e,startUrl:t}){let r=e.url();return r!=="about:blank"&&r.length>0?`You are already on the page at ${r}. Begin testing from this page \u2014 do not navigate away unless the workflow requires it.`:`Navigate to ${t} and begin testing.`}async function zl({baseUrl:e,page:t}){let r=new URL(e).origin;await t.route("**/*",n=>{let o=n.request();return o.isNavigationRequest()&&new URL(o.url()).origin!==r?(g.warn("Blocked navigation to off-origin URL: %s",o.url()),n.abort("blockedbyclient")):n.continue()})}async function _o({messages:e,monitor:t,onStep:r,page:n,response:o,runStartTime:i,specNodes:s,stepIndex:a,steps:l}){let c=o.content.filter(S=>S.type==="text").map(S=>S.text),d=o.content.filter(S=>S.type==="tool_use");if(d.length===0)return{continueLoop:!1,newFindings:c.join(`
|
|
77
|
+
`),nextStepIndex:a,verdict:void 0};let u=[],f=a,b,w;for(let S of d){let C=await Gl({block:S,monitor:t,onStep:r,page:n,runStartTime:i,specNodes:s,stepIndex:f,steps:l});u.push(C.toolResult),f=C.nextStepIndex,C.verdict!=null&&(b=C.verdict,w=C.summary)}e.push({content:o.content,role:"assistant"},{content:u,role:"user"});let h=w??c.join(`
|
|
78
|
+
`);return{continueLoop:b==null&&o.stop_reason==="tool_use",newFindings:h,nextStepIndex:f,verdict:b}}async function Gl({block:e,monitor:t,onStep:r,page:n,runStartTime:o,specNodes:i,stepIndex:s,steps:a}){try{let l=await Oo({input:e.input,monitor:t,name:e.name,page:n,runStartTime:o,stepIndex:s}),c={content:l.toolOutput,tool_use_id:e.id,type:"tool_result"};return l.kind==="verdict"?(g.info(" [%d] %s \u2014 verdict: %s",s,e.name,l.verdict),{nextStepIndex:s,summary:l.summary,toolResult:c,verdict:l.verdict}):(l.specNode!=null&&i.push(l.specNode),l.stepResult!=null?(a.push(l.stepResult),r?.(l.stepResult),g.info(" [%d] %s \u2014 %s",s,e.name,l.stepResult.status),{nextStepIndex:s+1,summary:void 0,toolResult:c,verdict:void 0}):(g.info(" [%d] %s \u2014 info",s,e.name),{nextStepIndex:s,summary:void 0,toolResult:c,verdict:void 0}))}catch(l){let c=l instanceof Error?l.message:"Unknown error";g.error(" [%d] %s \u2014 error: %s",s,e.name,c);let d=await ye({page:n,runStartTime:o,targets:[]}),u={annotations:d.annotations,assertions:[],detail:`Error: ${c}`,duration:0,nodeId:`agent-step-${String(s)}`,nodeType:"click",recordingEndMs:void 0,recordingStartMs:void 0,snapshotTimestamp:d.snapshotTimestamp,status:"failed",stepIndex:s,title:`${e.name} (error)`,url:d.url,viewportHeight:d.viewportHeight,viewportWidth:d.viewportWidth};return a.push(u),r?.(u),{nextStepIndex:s+1,summary:void 0,toolResult:{content:`Error: ${c}`,is_error:!0,tool_use_id:e.id,type:"tool_result"},verdict:void 0}}}function Kl(e){if(e.length===0)return{entryNode:"",nodes:{}};let t={};e.forEach((n,o)=>{let i=e[o+1],s=i==null?n:{...n,next:i.id};t[n.id]=s});let r=e[0];if(r==null)throw new Error("Expected at least one spec node after length check");return{entryNode:r.id,nodes:t}}function br({description:e,output:t,successCriteria:r}){let n=[`## Agent Identity
|
|
79
|
+
${e}`];t!=null&&t.length>0&&n.push(`## Output
|
|
80
|
+
${t}`),r!=null&&r.length>0&&n.push(`## Success Criteria
|
|
81
|
+
${r}`);let o=["## Completing Your Evaluation",'When you finish your evaluation, you MUST call the `complete_test` tool with your verdict ("pass" or "fail") and a `summary` string.',Jl({hasSuccessCriteria:r!=null&&r.length>0}),Yl({hasOutput:t!=null&&t.length>0})];return n.push(o.join(`
|
|
82
|
+
`)),n.join(`
|
|
83
|
+
|
|
84
|
+
`)}function Jl({hasSuccessCriteria:e}){return e?"Base your verdict strictly on the Success Criteria defined above. A test passes ONLY if all success criteria are met, and fails if any criterion is not met. Individual step failures during exploration do not necessarily mean the test failed, but the success criteria are the ultimate authority for your verdict.":"Base your verdict on whether the workflow worked correctly. Individual step failures during exploration do not necessarily mean the test failed."}function Yl({hasOutput:e}){return e?'The `summary` parameter is the ONLY output the user will see. You MUST use the `summary` field for EXACTLY the output described in the "Output" section above \u2014 nothing else. Do not describe what you did, do not list steps, do not add a test summary. The `summary` must contain ONLY what the Output section asks for, word for word if it specifies exact text.':"Include a brief summary of what you found in the `summary` parameter."}import{execFile as Xl}from"child_process";import{createRequire as Ql}from"module";import Uo from"fs";import Vo from"path";import{chromium as Fo}from"playwright";async function xe({headed:e}){process.env.PW_TEST_SCREENSHOT_NO_FONTS_READY="1";try{return await Fo.launch({headless:!e})}catch(t){throw Zl(t)?new Error(`Playwright browsers are not installed. Run:
|
|
73
85
|
|
|
74
86
|
npx playwright install chromium
|
|
75
|
-
`):t}}async function
|
|
87
|
+
`):t}}async function Sr(){let e=Fo.executablePath();if(Uo.existsSync(e))return;g.info("Chromium not found. Installing via Playwright...");let t=Ql(import.meta.url),r=Vo.dirname(t.resolve("playwright/package.json")),n=Vo.join(r,"cli.js");if(await new Promise((o,i)=>{Xl(process.execPath,[n,"install","chromium"],s=>{if(s!=null){i(new Error(`Playwright install failed: ${s.message}`));return}o()})}),!Uo.existsSync(e))throw new Error(`Playwright browser installation failed. Try running manually:
|
|
76
88
|
|
|
77
89
|
npx playwright install chromium
|
|
78
|
-
`);g.info("\u2713 Chromium installed")}function
|
|
90
|
+
`);g.info("\u2713 Chromium installed")}function Zl(e){return e instanceof Error?e.message.includes("Executable doesn't exist"):!1}import{mkdir as vr,writeFile as ie}from"fs/promises";import K from"path";async function ht({context:e,page:t,runId:r,stepIndex:n,stepResult:o}){try{let i=K.join(process.cwd(),".ripplo","debug",r,"steps",String(n));await vr(i,{recursive:!0});let s={annotations:o.annotations,assertions:o.assertions,detail:o.detail,duration:o.duration,nodeId:o.nodeId,nodeType:o.nodeType,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth};await Promise.all([ie(K.join(i,"info.json"),JSON.stringify(s,null,2)),ec({context:e,page:t,stepDir:i})])}catch(i){let s=i instanceof Error?i.message:String(i);g.warn("Failed to write step debug data for step %d: %s",n,s)}}async function ec({context:e,page:t,stepDir:r}){let[n,o,i,s]=await Promise.all([t.content().catch(()=>"(unable to capture DOM)"),tc(t),rc({context:e,page:t}),t.screenshot({fullPage:!1}).catch(()=>{})]);await Promise.all([ie(K.join(r,"dom.html"),n),ie(K.join(r,"accessibility-tree.txt"),o),ie(K.join(r,"storage.json"),JSON.stringify(i,null,2)),s==null?Promise.resolve():ie(K.join(r,"screenshot.png"),s)])}async function tc(e){try{return await e.locator(":root").ariaSnapshot()}catch{return"(unable to capture accessibility tree)"}}async function rc({context:e,page:t}){let[r,n]=await Promise.all([t.evaluate(()=>({localStorage:Object.fromEntries(Array.from({length:localStorage.length},(o,i)=>{let s=localStorage.key(i);return s==null?void 0:[s,localStorage.getItem(s)??""]}).filter(o=>o!=null)),sessionStorage:Object.fromEntries(Array.from({length:sessionStorage.length},(o,i)=>{let s=sessionStorage.key(i);return s==null?void 0:[s,sessionStorage.getItem(s)??""]}).filter(o=>o!=null))})).catch(()=>({localStorage:{},sessionStorage:{}})),e.cookies().catch(()=>[])]);return{cookies:n,localStorage:r.localStorage,sessionStorage:r.sessionStorage}}async function wt({monitor:e,runId:t,steps:r,summary:n}){try{let o=K.join(process.cwd(),".ripplo","debug",t);await vr(o,{recursive:!0}),await Promise.all([ie(K.join(o,"summary.txt"),nc({steps:r,summary:n})),ie(K.join(o,"console.log"),oc(e.consoleEntries)),ie(K.join(o,"network.jsonl"),ic(e.networkEntries)),ie(K.join(o,"page-errors.log"),e.pageErrors.join(`
|
|
79
91
|
---
|
|
80
|
-
`))]),g.info("Debug artifacts written to .ripplo/debug/%s/",t)}catch(o){let i=o instanceof Error?o.message:String(o);g.warn("Failed to write run debug summary: %s",i)}}function
|
|
81
|
-
`)}function
|
|
82
|
-
`)}function
|
|
83
|
-
`)}async function
|
|
84
|
-
|
|
85
|
-
${
|
|
86
|
-
${
|
|
87
|
-
`);await Promise.all([
|
|
88
|
-
`),
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
`))]),g.info("Debug artifacts written to .ripplo/debug/%s/",t)}catch(o){let i=o instanceof Error?o.message:String(o);g.warn("Failed to write run debug summary: %s",i)}}function nc({steps:e,summary:t}){return[`Run ID: ${t.runId}`,`Workflow: ${t.workflowName}`,`Status: ${t.status}`,`Duration: ${String(t.duration)}ms`,`Passed: ${String(t.passCount)}`,`Failed: ${String(t.failCount)}`,"","Steps:",...e.map(n=>` [${String(n.stepIndex)}] ${n.status==="passed"?"\u2713":"\u2717"} ${n.title} (${String(n.duration)}ms) \u2014 ${n.detail??"ok"}`)].join(`
|
|
93
|
+
`)}function oc(e){return e.map(t=>`[${new Date(t.timestamp).toISOString()}] [${t.level.toUpperCase()}] (${t.url}) ${t.text}`).join(`
|
|
94
|
+
`)}function ic(e){return e.map(t=>JSON.stringify(t)).join(`
|
|
95
|
+
`)}async function Mo({error:e,runId:t,stack:r,workflowName:n}){try{let o=K.join(process.cwd(),".ripplo","debug",t);await vr(o,{recursive:!0});let i=r==null?e:`${e}
|
|
96
|
+
|
|
97
|
+
${r}`,s=[`Run ID: ${t}`,`Workflow: ${n}`,"Status: failed","",`Error: ${e}`,"",r==null?"":`Stack trace:
|
|
98
|
+
${r}`].join(`
|
|
99
|
+
`);await Promise.all([ie(K.join(o,"error.txt"),i),ie(K.join(o,"summary.txt"),s)]),g.info("Debug error artifacts written to .ripplo/debug/%s/",t)}catch(o){let i=o instanceof Error?o.message:String(o);g.warn("Failed to write error debug artifacts: %s",i)}}import{readFileSync as sc}from"fs";import{createRequire as ac}from"module";import Wo from"path";import{gzipSync as lc}from"zlib";var cc=ac(import.meta.url),dc=cc.resolve("rrweb"),uc=Wo.join(Wo.dirname(dc),"rrweb.umd.min.cjs"),pc=sc(uc,"utf8"),mc=[";(function() {"," try {"," if (window.__ripploRrwebLoaded) return;"," window.__ripploRrwebLoaded = true;"," window.__ripploRrwebBuffer = [];"," window.__ripploRrwebDrain = function() {"," var out = window.__ripploRrwebBuffer;"," window.__ripploRrwebBuffer = [];"," return out;"," };"," var r = window.rrweb;"," if (r == null || r.record == null) {"," console.warn('[ripplo] rrweb global not found');"," return;"," }"," function startRecording() {"," if (window.__ripploRrwebStartedAt != null) return;"," window.__ripploRrwebStartedAt = Date.now();"," var stop = r.record({"," emit: function(event) { window.__ripploRrwebBuffer.push(event); },"," recordCanvas: false,"," recordCrossOriginIframes: false,"," });"," if (r.record.mirror) window.__ripploRrwebMirror = r.record.mirror;"," window.__ripploRrwebStop = stop;"," }"," window.__ripploRrwebStart = startRecording;"," // Auto-start on every bootstrap run so agent-driven tests (which don't"," // emit a 'first step' signal before navigating) capture from the start."," startRecording();"," } catch (err) {"," console.error('[ripplo] rrweb bootstrap failed', err && err.message ? err.message : err);"," }","})();"].join(`
|
|
100
|
+
`),fc=pc+`
|
|
101
|
+
`+mc;function gc(){return globalThis.__ripploRrwebStartedAt}function yc(){globalThis.__ripploRrwebStart?.()}function hc(){globalThis.__ripploRrwebStop?.()}function wc(){return globalThis.__ripploRrwebDrain?.()??[]}async function bt(e){let t,r=0;async function n(){await e.addScriptTag({content:fc}).catch(()=>{})}await n(),e.on("load",()=>{n()});async function o(){await e.evaluate(yc).catch(()=>{});let l=await e.evaluate(gc).catch(()=>{});typeof l=="number"&&(t??=l)}function i(){if(t!=null)return Date.now()-t}async function s(){let l=await e.evaluate(wc).catch(()=>[]),c=l[0],d=l.at(-1);if(c==null||d==null)return;t??=c.timestamp;let u=t,f=l.map(h=>JSON.stringify(h)).join(`
|
|
102
|
+
`),w={body:lc(Buffer.from(f,"utf8")),chunkIndex:r,endTimestamp:d.timestamp-u,eventCount:l.length,startTimestamp:c.timestamp-u};return r+=1,w}async function a(){await e.evaluate(hc).catch(()=>{})}return{currentOffsetMs:i,detach:a,start:o,takeChunk:s}}async function kr({baseUrl:e,cookies:t,executedPreconditions:r,extraVariables:n,headed:o,runId:i,serverUrl:s,spec:a,streaming:l,systemPrompt:c,token:d,workflowContext:u}){let f=await xe({headed:o}),b=await f.newContext({baseURL:e});t.length>0&&(await b.addCookies([...t]),g.info("Injected %d cookies from preconditions",t.length));let w=await b.newPage(),h=await bt(w);async function S(){let q=await h.takeChunk();q!=null&&l.enqueueRecordingChunk(q)}let C=setInterval(()=>{S()},2e3);await h.start();try{let q=function(ae){let qe={...ae,recordingEndMs:h.currentOffsetMs(),recordingStartMs:ae.recordingStartMs??h.currentOffsetMs()};l.enqueueStep(qe),l.flushSteps(),ht({context:b,page:w,runId:i,stepIndex:qe.stepIndex,stepResult:qe})};var D=q;let j=await wr({baseUrl:e,executedPreconditions:r,extraVariables:n,onStep:q,page:w,runId:i,serverUrl:s,spec:a,systemPrompt:c,token:d,workflowContext:u}),U=j.verdict==="pass"?"passed":"failed";await l.complete({statusOverride:U,steps:j.steps,summary:j.findings});let oe=j.steps.filter(ae=>ae.status==="passed").length,Te=j.steps.filter(ae=>ae.status==="failed").length,N={duration:j.steps.reduce((ae,qe)=>ae+qe.duration,0),failCount:Te,passCount:oe,runId:i,status:U,workflowName:u.name};await wt({monitor:j.monitor,runId:i,steps:j.steps,summary:N}),g.info("Agent test complete: %d passed, %d failed",oe,Te),g.info(`
|
|
91
103
|
=== Agent Summary ===
|
|
92
|
-
%s`,
|
|
104
|
+
%s`,j.findings)}finally{clearInterval(C),await h.detach(),await S(),await f.close()}}async function Rr({expected:e,locator:t,operator:r,timeout:n}){let o=await t.textContent({timeout:n});return Xe({actual:o??"",expected:e,label:"Text",operator:r})}function St({expected:e,operator:t,url:r}){return Xe({actual:r,expected:e,label:"URL",operator:t})}async function xr({expected:e,locator:t,operator:r}){let n=await t.count();return Yo({actual:n,expected:e,label:"Count",operator:r})}async function Pr({expected:e,locator:t,operator:r,timeout:n}){let o=await t.inputValue({timeout:n});return Xe({actual:o,expected:e,label:"Value",operator:r})}async function Er({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),{description:"Element is visible",detail:void 0,status:"passed"}}catch{return{description:"Element is visible",detail:"Element not visible",status:"failed"}}}async function Cr({locator:e,timeout:t}){try{return await e.waitFor({state:"hidden",timeout:t}),{description:"Element is not visible",detail:void 0,status:"passed"}}catch{return{description:"Element is not visible",detail:"Element still visible",status:"failed"}}}async function Ho({attribute:e,expected:t,locator:r,operator:n,timeout:o}){let i=await r.getAttribute(e,{timeout:o});return Xe({actual:i??"",expected:t,label:`Attribute "${e}"`,operator:n})}async function qo({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),await e.isEnabled()?{description:"Element is enabled",detail:void 0,status:"passed"}:{description:"Element is enabled",detail:"Element is disabled",status:"failed"}}catch{return{description:"Element is enabled",detail:"Element not found",status:"failed"}}}async function Bo({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),await e.isDisabled()?{description:"Element is disabled",detail:void 0,status:"passed"}:{description:"Element is disabled",detail:"Element is enabled",status:"failed"}}catch{return{description:"Element is disabled",detail:"Element not found",status:"failed"}}}async function zo({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),await e.isChecked()?{description:"Element is checked",detail:void 0,status:"passed"}:{description:"Element is checked",detail:"Element is not checked",status:"failed"}}catch{return{description:"Element is checked",detail:"Element not found",status:"failed"}}}async function Go({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),await e.isChecked()?{description:"Element is not checked",detail:"Element is checked",status:"failed"}:{description:"Element is not checked",detail:void 0,status:"passed"}}catch{return{description:"Element is not checked",detail:"Element not found",status:"failed"}}}async function Ko({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),!await e.evaluate("(el) => document.activeElement === el")?{description:"Element is focused",detail:"Element is not focused",status:"failed"}:{description:"Element is focused",detail:void 0,status:"passed"}}catch{return{description:"Element is focused",detail:"Element not found",status:"failed"}}}async function Jo({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),!!await e.evaluate("(el) => document.activeElement === el")?{description:"Element is not focused",detail:"Element is focused",status:"failed"}:{description:"Element is not focused",detail:void 0,status:"passed"}}catch{return{description:"Element is not focused",detail:"Element not found",status:"failed"}}}function Xe(e){let t=`${e.label} ${e.operator} "${e.expected}"`,r=bc(e),n=r?void 0:`Got: "${e.actual}"`;return{description:t,detail:n,status:r?"passed":"failed"}}function bc({actual:e,expected:t,operator:r}){return r==="equals"?e===t:r==="notEquals"?e!==t:r==="contains"?e.includes(t):r==="startsWith"?e.startsWith(t):r==="endsWith"?e.endsWith(t):new RegExp(t).test(e)}function Yo(e){let t=`${e.label} ${e.operator} ${String(e.expected)}`,r=Sc(e),n=r?void 0:`Got: ${String(e.actual)}`;return{description:t,detail:n,status:r?"passed":"failed"}}function Sc({actual:e,expected:t,operator:r}){return r==="equals"?e===t:r==="notEquals"?e!==t:r==="greaterThan"?e>t:r==="greaterThanOrEqual"?e>=t:r==="lessThan"?e<t:e<=t}import{readdir as Ec,rm as Cc,stat as Tc}from"fs/promises";import vv from"os";import Zo from"path";import{graphql as Ac}from"gql.tada";import{print as vc}from"graphql";var kc=15e3;async function k(e){let t=vc(e.document),r=JSON.stringify({query:t,variables:e.variables}),n=`${e.config.ripploServerUrl}/graphql`,o;try{o=await fetch(n,{body:r,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(kc)})}catch(s){let a=s instanceof Error?s.message:String(s);throw new Error(`Failed to connect to Ripplo server at ${e.config.ripploServerUrl}. Make sure \`npx ripplo\` is running and your internet connection is active. Details: ${a}`)}let i=await Rc({res:o,url:n});if(!xc(i))throw new Error("Invalid GraphQL response");if(Pc(i))throw new Error(i.errors.map(s=>s.message).join(", "));if(i.data==null)throw new Error("No data returned from server");return i.data}async function Rc({res:e,url:t}){let r=await e.text();if(r.length===0)throw new Error(`Empty response from Ripplo server at ${t} (status ${String(e.status)}). The server may have restarted or the request was rejected before a body was sent.`);try{return JSON.parse(r)}catch{throw new Error(`Non-JSON response from Ripplo server at ${t} (status ${String(e.status)}): ${r.slice(0,200)}`)}}function xc(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function Pc(e){return Array.isArray(e.errors)&&e.errors.length>0}var Xo=Zo.join(process.cwd(),".ripplo","debug"),Qo=360*60*1e3,Ev=Ac(`
|
|
93
105
|
mutation RevokeCurrentCliToken {
|
|
94
106
|
revokeCurrentCliToken
|
|
95
107
|
}
|
|
96
|
-
`)});async function
|
|
97
|
-
`))}}
|
|
98
|
-
`),t}function
|
|
99
|
-
|
|
100
|
-
\u2192 /ripplo:debug \u2014 check .ripplo/debug/<runId>/ artifacts`,status:"failed"}}function
|
|
101
|
-
|
|
102
|
-
\u2192 /ripplo:create`,status:"failed"}:(r.lastReason=t.reason,null)}async function vg({apiUrl:e,observer:t,params:n,webhookSecret:r}){let o=JSON.stringify({observer:t,params:n});try{let i=await fetch(`${e}/execute-observer`,{body:o,headers:{"Content-Type":"application/json",...Fe({body:o,secret:r})},method:"PUT",signal:AbortSignal.timeout(wg)});if(!i.ok){let s=await i.text().catch(()=>"");return{kind:"transport-error",reason:`status ${String(i.status)}: ${s.slice(0,200)}`}}let a=await i.json(),l=Tg.safeParse(a);return l.success?!l.data.success||l.data.outcome==null?{kind:"transport-error",reason:l.data.error??"engine reported failure without outcome"}:l.data.outcome:{kind:"transport-error",reason:`invalid response shape: ${l.error.message}`}}catch(i){let a=i instanceof Error?i.message:String(i);return g.error("observer request failed: %s",a),{kind:"transport-error",reason:a}}}function Cg({backoff:e,pollCount:t}){let n=Math.min(t-1,e.length-1);return e[n]??1e3}function Zs(e){return`${String(Math.round(performance.now()-e))}ms`}async function Lg(e){return new Promise(t=>setTimeout(t,e))}var wg,Ag,Rg,Tg,el=p(()=>{"use strict";ne();un();wg=15e4,Ag={async:{backoffMs:[500,1e3,2e3,5e3],timeoutMs:12e4},fast:{backoffMs:[100,250,500,1e3],timeoutMs:5e3},slow:{backoffMs:[250,500,1e3,2e3],timeoutMs:3e4}},Rg=ye.discriminatedUnion("kind",[ye.object({kind:ye.literal("pass")}),ye.object({kind:ye.literal("retry"),reason:ye.string()}),ye.object({kind:ye.literal("fail"),reason:ye.string()})]),Tg=ye.object({error:ye.string().optional(),outcome:Rg.optional(),success:ye.boolean()})});async function ie({fn:e,label:t}){let n=performance.now(),r=await e();return g.info("%s: %dms",t,Math.round(performance.now()-n)),r}var vt=p(()=>{"use strict";ne()});async function ro({failFast:e,getRecordingOffsetMs:t,observerTransport:n,onStep:r,page:o,spec:i,variables:a}){let l=performance.now();return Eg({currentId:i.entryNode,failFast:e,getRecordingOffsetMs:t,observerTransport:n,onStep:r,page:o,runStartTime:l,spec:i,variables:a})}function Pg({onStep:e,steps:t,target:n}){t.forEach(r=>{let o={...r,stepIndex:n.length};n.push(o),e?.(o)})}async function Eg({currentId:e,failFast:t,getRecordingOffsetMs:n,observerTransport:r,onStep:o,page:i,runStartTime:a,spec:l,variables:s}){let d=[],c=s,u=e;for(;u!=null;){let y=l.nodes[u];if(y==null)throw new Error(`Node "${u}" not found in spec`);let S=u,b=y.label??`${y.type} (${u})`;g.info("Executing node: %s [%s]",b,y.type);let k=await Og({getRecordingOffsetMs:n,node:y,nodeId:S,observerTransport:r,page:i,runStartTime:a,variables:c});if(Pg({onStep:o,steps:[k],target:d}),c=k.variables,t&&k.status==="failed")break;u=y.next}return{steps:d,variables:c}}async function Og({getRecordingOffsetMs:e,node:t,nodeId:n,observerTransport:r,page:o,runStartTime:i,variables:a}){let l=performance.now(),s=e?.(),d=t.label??`${t.type} (${t.id})`,c=xg,u=qt({node:t,page:o});try{let y=await Ig({node:t,observerTransport:r,page:o,timeout:c,variables:a}),S=Math.round(performance.now()-l),b=y.assertions.some(R=>R.status==="failed"),k=await ie({label:`Snapshot [${d}]`,fn:()=>Be({page:o,runStartTime:i,targets:u})}),N=e?.();return{annotations:k.annotations,assertions:y.assertions,detail:void 0,duration:S,nodeId:n,nodeType:t.type,recordingEndMs:N,recordingStartMs:s,snapshotTimestamp:k.snapshotTimestamp,status:b?"failed":"passed",stepIndex:0,title:d,url:k.url,variables:y.variables,viewportHeight:k.viewportHeight,viewportWidth:k.viewportWidth}}catch(y){let S=Math.round(performance.now()-l),b=y instanceof Error?y.message:String(y),k=await ie({label:`Snapshot [${d}] (error)`,fn:()=>Be({page:o,runStartTime:i,targets:u})}),N=e?.();return{annotations:k.annotations,assertions:[],detail:b,duration:S,nodeId:n,nodeType:t.type,recordingEndMs:N,recordingStartMs:s,snapshotTimestamp:k.snapshotTimestamp,status:"failed",stepIndex:0,title:d,url:k.url,variables:a,viewportHeight:k.viewportHeight,viewportWidth:k.viewportWidth}}}async function Ig({node:e,observerTransport:t,page:n,timeout:r,variables:o}){if(_g(e)){let a=await ar({node:e,page:n,timeout:r,variables:o});return{assertions:[],variables:a.variables}}return{assertions:await Ug({node:e,observerTransport:t,page:n,timeout:r,variables:o}),variables:o}}function _g(e){return["goto","click","dblclick","fill","select","hover","press","check","uncheck","clear","rightClick","handleDialog","clipboard","setPermission","setViewport","fail","setVariable","extractText","upload","drag","scrollIntoView","type","focus"].includes(e.type)}function jg(e){return e.type.startsWith("assert")}async function Ug({node:e,observerTransport:t,page:n,timeout:r,variables:o}){if(!jg(e))throw new Error(`Unknown node type: ${e.type}`);let i=e;switch(i.type){case"assertVisible":case"assertNotVisible":case"assertEnabled":case"assertDisabled":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertNotFocused":return Dg({assertNode:i,page:n,timeout:r,variables:o});case"assertText":{let a=te({ref:i.expected,variables:o});return[await Er({expected:a,locator:V({locator:i.locator,page:n,variables:o}),operator:i.operator,timeout:r})]}case"assertUrl":{let a=te({ref:i.expected,variables:o});return[Zt({expected:a,operator:i.operator,url:n.url()})]}case"assertTitle":{let a=te({ref:i.expected,variables:o});return[Zt({expected:a,operator:i.operator,url:await n.title()})]}case"assertCount":{let a=ir({ref:i.expected,variables:o});return[await Or({expected:a,locator:V({locator:i.locator,page:n,variables:o}),operator:i.operator})]}case"assertValue":{let a=te({ref:i.expected,variables:o});return[await Ir({expected:a,locator:V({locator:i.locator,page:n,variables:o}),operator:i.operator,timeout:r})]}case"assertAttribute":{let a=te({ref:i.expected,variables:o});return[await Cs({attribute:i.attribute,expected:a,locator:V({locator:i.locator,page:n,variables:o}),operator:i.operator,timeout:r})]}case"assertObserver":{if(t==null)return[{description:`observer "${i.observer}"`,detail:"observer transport not configured \u2014 set engineUrl + webhookSecret in ripplo.config",status:"failed"}];let a={};return Object.entries(i.params).forEach(([l,s])=>{a[l]=te({ref:s,variables:o})}),[await Ys({apiUrl:t.apiUrl,budget:i.budget,observer:i.observer,params:a,webhookSecret:t.webhookSecret})]}}}async function Dg({assertNode:e,page:t,timeout:n,variables:r}){let o=$g[e.type];return[await o({locator:V({locator:e.locator,page:t,variables:r}),timeout:n})]}var xg,$g,oo=p(()=>{"use strict";sr();el();Ur();dt();ne();vt();At();De();xg=1e4;$g={assertChecked:Ps,assertDisabled:xs,assertEnabled:Ls,assertFocused:Os,assertNotChecked:Es,assertNotFocused:Is,assertNotVisible:jr,assertVisible:_r}});async function io({baseUrl:e,browser:t,cookies:n,extraVariables:r,observerTransport:o,onRecordingChunk:i,onStep:a,runId:l,spec:s}){let d=await t.newContext({baseURL:e});g.info("Browser context created"),n.length>0&&await d.addCookies(n);let c=await d.newPage();g.info("Page created");let u=Rt(c),y=await Yt(c);async function S(){let j=await y.takeChunk();j!=null&&i?.(j)}let b=setInterval(()=>{S()},2e3),k=[],N=!1;function R(j){a?.(j),N||(N=!0,y.start()),k.push(Gt({context:d,page:c,runId:l,stepIndex:j.stepIndex,stepResult:j}))}let O=Bg(r,s.variableNamespaces),F={...bt({defs:s.variables}),...O};g.info("Starting graph execution (entry: %s)",s.entryNode);let U=await ro({failFast:!0,getRecordingOffsetMs:y.currentOffsetMs,observerTransport:o,onStep:R,page:c,spec:s,variables:F});await Promise.allSettled(k);let $=U.steps.filter(j=>j.status==="passed").length,se=U.steps.filter(j=>j.status==="failed").length,q={duration:U.steps.reduce((j,G)=>j+G.duration,0),failCount:se,passCount:$,runId:l,status:se>0?"failed":"passed",workflowName:""};return await Kt({monitor:u,runId:l,steps:U.steps,summary:q}),clearInterval(b),await y.detach(),await S(),await d.close(),U.steps}function Bg(e,t){if(e==null||t==null)return{};let n=new Map;Object.entries(t).forEach(([o,i])=>{n.set(i,o)});let r={};return Object.entries(e).forEach(([o,i])=>{let a=n.get(o);a!=null&&(r[a]={...r[a],...i})}),r}var ao=p(()=>{"use strict";hr();Lr();Qt();oo();ne();De()});import{parseSetCookie as Vg}from"set-cookie-parser";import{z as pe}from"zod";async function so({project:e,webhookSecret:t,workflowSlug:n}){let r={apiUrl:void 0,cookies:[],data:{},executed:[]},o=e.workflows.find(l=>l.slug===n);if(o==null)return r;let i=e.engineBaseUrl.length===0?void 0:e.engineBaseUrl,a=o.preconditions;return a.length===0?{...r,apiUrl:i}:i==null?r:nl({apiUrl:i,preconditionNames:a,webhookSecret:t})}async function lo({apiUrl:e,cookies:t,data:n,executed:r,webhookSecret:o}){if(r.length!==0)try{let i=JSON.stringify({data:n,preconditions:r}),a=await fetch(`${e}/teardown-preconditions`,{body:i,headers:{"Content-Type":"application/json",...qg({cookies:t}),...Fe({body:i,secret:o})},method:"PUT",signal:AbortSignal.timeout(tl)});a.ok||g.error("Teardown returned %s",String(a.status))}catch{g.error("Teardown request failed")}}async function nl({apiUrl:e,preconditionNames:t,webhookSecret:n}){let r=performance.now(),o=JSON.stringify({preconditions:t}),i=await fetch(`${e}/execute-preconditions`,{body:o,headers:{"Content-Type":"application/json",...Fe({body:o,secret:n})},method:"PUT",signal:AbortSignal.timeout(tl)});if(!i.ok){let d=await Mg(i);throw new Error(`execute-preconditions returned ${String(i.status)}: ${d}`)}let a=await i.json(),l=Wg.safeParse(a);if(!l.success)throw new Error(`execute-preconditions response has invalid shape: ${l.error.message}`);if(!l.data.success){let d=l.data.error??"no error detail";throw new Error(`Precondition batch failed: ${d}`)}let s=Jg({domain:new URL(e).hostname,res:i});return g.info("Preconditions resolved: %s (%dms)",l.data.executed.join(", "),Math.round(performance.now()-r)),{apiUrl:e,cookies:s,data:l.data.data,executed:l.data.executed}}async function Mg(e){let t=await e.text().catch(()=>"");if(t.length===0)return"no body";let n=Hg(t),r=n==null?null:Fg.safeParse(n);return r!=null&&r.success?r.data.error:t.slice(0,500)}function Hg(e){try{return JSON.parse(e)}catch{return null}}function qg({cookies:e}){return e.length===0?{}:{Cookie:e.map(n=>`${n.name}=${n.value}`).join("; ")}}function Jg({domain:e,res:t}){let n=t.headers.getSetCookie();return Vg(n,{decodeValues:!1}).map(o=>zg({cookie:o,domain:e}))}function zg({cookie:e,domain:t}){let n={domain:e.domain??t,httpOnly:e.httpOnly??!1,name:e.name,path:e.path??"/",secure:e.secure??!1,value:e.value};return e.sameSite!=null&&(n.sameSite=Gg({raw:e.sameSite})),e.expires!=null?n.expires=Math.floor(e.expires.getTime()/1e3):e.maxAge!=null&&(n.expires=Math.floor(Date.now()/1e3)+e.maxAge),n}function Gg({raw:e}){return Xg[e.toLowerCase()]??"Lax"}async function co({engineBaseUrl:e,preconditionNames:t,webhookSecret:n}){let r=e.length===0?void 0:e;return r==null||t.length===0?{apiUrl:r,cookies:[],data:{},executed:[]}:nl({apiUrl:r,preconditionNames:t,webhookSecret:n})}var tl,Wg,Fg,Xg,po=p(()=>{"use strict";ne();un();tl=3e4,Wg=pe.object({data:pe.record(pe.string(),pe.record(pe.string(),pe.string())),error:pe.string().optional(),executed:pe.array(pe.string()),runId:pe.string(),success:pe.boolean()});Fg=pe.object({error:pe.string()});Xg={lax:"Lax",none:"None",strict:"Strict"}});import{graphql as mn}from"gql.tada";async function uo({agentProfileId:e,config:t,runId:n}){let r=await x({config:t,document:Yg,variables:{agentProfileId:e??null,platform:"chromium",runId:n}});if(r.startRun==null)throw new Error("Failed to start run");let o=r.startRun.id,i=[];function a(c){let u=Qg({config:t,runResultId:o,steps:[c]}).catch(y=>{g.error(y,"Failed to submit step %d",c.stepIndex)});i.push(u)}function l(c){let u=Kg({chunk:c,config:t,runResultId:o}).catch(y=>{g.error(y,"Failed to submit recording chunk %d",c.chunkIndex)});i.push(u)}async function s(){await Promise.all(i)}async function d({statusOverride:c,steps:u,summary:y}){await ie({label:`flushSteps (${String(i.length)} steps)`,fn:()=>Promise.all(i)});let S=u.filter(R=>R.status==="passed").length,b=u.filter(R=>R.status==="failed").length,k=u.reduce((R,O)=>R+O.duration,0),N=c??(b>0?"failed":"passed");await ie({label:"completeRun",fn:()=>x({config:t,document:th,variables:{duration:k,failCount:b,passCount:S,runResultId:o,status:N,summary:y??null,warnCount:0}})})}return{complete:d,enqueueRecordingChunk:l,enqueueStep:a,flushSteps:s,runResultId:o}}async function Kg({chunk:e,config:t,runResultId:n}){await x({config:t,document:eh,variables:{input:{bodyBase64:e.body.toString("base64"),chunkIndex:e.chunkIndex,endTimestamp:e.endTimestamp,eventCount:e.eventCount,runResultId:n,startTimestamp:e.startTimestamp}}})}async function Qg({config:e,runResultId:t,steps:n}){let r=n.map(o=>({annotations:o.annotations.map(i=>({height:i.height,label:i.label,rrwebNodeId:i.rrwebNodeId??null,type:i.type,width:i.width,x:i.x,y:i.y})),assertions:o.assertions.map(i=>({description:i.description,detail:i.detail,status:i.status})),detail:o.detail,duration:o.duration,nodeType:o.nodeType,recordingEndMs:o.recordingEndMs??null,recordingStartMs:o.recordingStartMs??null,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth}));await x({config:e,document:Zg,variables:{runResultId:t,steps:r}})}var Yg,Zg,eh,th,mo=p(()=>{"use strict";Nt();ne();vt();Yg=mn(`
|
|
108
|
+
`);async function Tr({maxRuns:e}){try{let r=(await Ec(Xo,{withFileTypes:!0})).filter(c=>c.isDirectory()),n=Date.now(),o=await Promise.all(r.map(async c=>{let d=Zo.join(Xo,c.name),u=await Tc(d);return{dirPath:d,mtime:u.mtimeMs}})),i=o.filter(c=>n-c.mtime>Qo),a=o.filter(c=>n-c.mtime<=Qo).toSorted((c,d)=>d.mtime-c.mtime).slice(e),l=[...i,...a];if(l.length===0)return;await Promise.allSettled(l.map(c=>Cc(c.dirPath,{force:!0,recursive:!0}))),g.info("Pruned %d old debug run(s)",l.length)}catch{g.warn("Debug run pruning failed, ignoring")}}var $c=5e3;async function Ar({appUrl:e}){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout($c)})}catch(t){let r=t instanceof Error?t.message:String(t);throw g.debug("App URL reachability check failed: %s",r),new Error([`Could not reach your dev server at ${e}.`,"","Troubleshooting:",` 1. Make sure your app is running at ${e}`," 2. Check RIPPLO_APP_URL in the env file declared in .ripplo/project.json"," 3. If you're in a git worktree, RIPPLO_APP_URL and RIPPLO_ENGINE_URL must point at this worktree's dev server port (not main's)"].join(`
|
|
109
|
+
`))}}import et from"fs";import Pe from"fs";import Ic from"os";import Qe from"path";var jc=".local",Nc=".ripplo";function $r(e){return Qe.join(e,".ripplo",jc)}function Ir(e){let t=$r(e);Pe.existsSync(t)||Pe.mkdirSync(t,{recursive:!0});let r=Qe.join(t,".gitignore");return Pe.existsSync(r)||Pe.writeFileSync(r,`*
|
|
110
|
+
`),t}function Ze(e,t){return Qe.join($r(e),t)}function jr(){return Qe.join(Ic.homedir(),Nc)}function Nr(){let e=jr();return Pe.existsSync(e)?Pe.chmodSync(e,448):Pe.mkdirSync(e,{mode:448,recursive:!0}),e}function he(e){return Qe.join(jr(),e)}function le(){let e=process.env.RIPPLO_TOKEN;if(e!=null&&e.trim().length>0)return e.trim();let t=he("token");if(!et.existsSync(t))return null;let r=et.readFileSync(t,"utf8").trim();return r.length===0?null:r}function Or(e){Nr(),et.writeFileSync(he("token"),e+`
|
|
111
|
+
`,{mode:384})}function Lr(){let e=he("token");return et.existsSync(e)?(et.unlinkSync(e),!0):!1}import{z as pe}from"zod";import{z as vt}from"zod";var Oc=vt.object({__codec:vt.string().min(1),data:vt.unknown(),version:vt.number().int().positive()}),kt=class extends Error{codec;currentVersion;gotVersion;constructor(t){super(`Unsupported ${t.codec} version ${String(t.gotVersion)} (current ${String(t.currentVersion)}). Upgrade Ripplo or rebuild with a compatible CLI.`),this.name="CodecVersionError",this.codec=t.codec,this.currentVersion=t.currentVersion,this.gotVersion=t.gotVersion}},Rt=class extends Error{constructor(t){super(`Codec mismatch: expected "${t.expected}", got "${t.got}"`),this.name="CodecMismatchError"}};function xt(e){return ei({legacy:void 0,migrators:[],name:e,schemas:[]})}function ei(e){return{initial:t=>Dr(t,{...e,schemas:[t]}),legacy:t=>ei({...e,legacy:t})}}function Dr(e,t){return{build:()=>Lc(e,t),legacy:r=>Dr(e,{...t,legacy:r}),upgrade:(r,n)=>{let o=n;return Dr(r,{...t,migrators:[...t.migrators,o],schemas:[...t.schemas,r]})}}}function Lc(e,t){let r=t.schemas.length;return{currentVersion:r,name:t.name,decode:n=>Dc(e,t,n),encode:n=>({__codec:t.name,data:n,version:r})}}function Dc(e,t,r){let{data:n,version:o}=_c(t,r),i=ti(t,n,o);return e.parse(i)}function _c(e,t){let r=Oc.safeParse(t);if(r.success){if(r.data.__codec!==e.name)throw new Rt({expected:e.name,got:r.data.__codec});return{data:r.data.data,version:r.data.version}}if(e.legacy!=null&&e.legacy.detect(t))return{data:t,version:e.legacy.assumedVersion};throw new Error(`Cannot decode "${e.name}": value is not a codec envelope and no legacy detector matched.`)}function ti(e,t,r){let n=e.schemas.length;if(r>n)throw new kt({codec:e.name,currentVersion:n,gotVersion:r});if(r===n)return t;let o=e.schemas[r-1];if(o==null)throw new Error(`Codec "${e.name}" missing schema for v${String(r)}; cannot migrate.`);let i=o.parse(t),s=e.migrators[r-1];if(s==null)throw new Error(`Codec "${e.name}" missing migrator v${String(r)} \u2192 v${String(r+1)}.`);return ti(e,s(i),r+1)}import{z as ii}from"zod";import{z as Ne}from"zod";var _r=Ne.object({depends:Ne.array(Ne.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:Ne.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:Ne.array(Ne.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 p}from"zod";import{z as we}from"zod";var Uc=we.object({by:we.literal("testId"),value:we.string().min(1)}),Vc=we.object({by:we.literal("role"),name:we.string().optional(),role:we.string().min(1)}),T=we.discriminatedUnion("by",[Uc,Vc]);import{z as ri}from"zod";var be=ri.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),Pt=ri.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]);import{z as M}from"zod";var Fc=M.object({type:M.literal("static"),value:M.union([M.string(),M.number(),M.boolean()])}),Ur=M.object({name:M.string().min(1),type:M.literal("variable")}),Et=M.discriminatedUnion("type",[Fc,Ur]),J=M.discriminatedUnion("type",[M.object({type:M.literal("static"),value:M.string()}),Ur]),Ct=M.discriminatedUnion("type",[M.object({type:M.literal("static"),value:M.number().int().nonnegative()}),Ur]);import{z as Q}from"zod";var Tt=Q.discriminatedUnion("type",[Q.object({default:Q.string().optional(),type:Q.literal("string")}),Q.object({default:Q.number().optional(),type:Q.literal("number")}),Q.object({default:Q.boolean().optional(),type:Q.literal("boolean")}),Q.object({key:Q.string().min(1),type:Q.literal("env")})]);var x={id:p.string().min(1).max(200),label:p.string().max(500).optional(),next:p.string().max(200).optional(),uiOnly:p.boolean().optional()},ni=500,Mc=p.object({...x,type:p.literal("goto"),url:J}),Wc=p.object({...x,locator:T,type:p.literal("click")}),Hc=p.object({...x,locator:T,type:p.literal("fill"),value:J}),qc=p.object({...x,locator:T,type:p.literal("select"),value:J}),Bc=p.object({...x,locator:T,type:p.literal("hover")}),zc=p.object({...x,key:p.string().min(1),locator:T.optional(),type:p.literal("press")}),Gc=p.object({...x,locator:T,type:p.literal("check")}),Kc=p.object({...x,locator:T,type:p.literal("uncheck")}),Jc=p.object({...x,height:p.number().int().positive(),type:p.literal("setViewport"),width:p.number().int().positive()}),Yc=p.object({...x,message:p.string().min(1),type:p.literal("fail")}),Xc=p.object({...x,type:p.literal("setVariable"),value:Et,variable:p.string().min(1)}),Qc=p.object({...x,locator:T,type:p.literal("extractText"),variable:p.string().min(1)}),Zc=p.object({...x,files:p.array(p.string()).min(1),locator:T,type:p.literal("upload")}),ed=p.object({...x,locator:T,type:p.literal("dblclick")}),td=p.object({...x,source:T,target:T,type:p.literal("drag")}),rd=p.object({...x,locator:T,type:p.literal("scrollIntoView")}),nd=p.object({...x,locator:T,type:p.literal("type"),value:J}),od=p.object({...x,locator:T,type:p.literal("focus")}),id=p.object({...x,locator:T,type:p.literal("clear")}),sd=p.object({...x,locator:T,type:p.literal("rightClick")}),ad=p.object({...x,action:p.enum(["accept","dismiss"]),promptText:p.string().optional(),type:p.literal("handleDialog")}),ld=p.object({...x,action:p.enum(["read","write"]),type:p.literal("clipboard"),value:J.optional(),variable:p.string().min(1).optional()}),cd=p.object({...x,permission:p.string().min(1),state:p.enum(["granted","prompt"]),type:p.literal("setPermission")}),dd=p.object({...x,locator:T,type:p.literal("assertVisible")}),ud=p.object({...x,locator:T,type:p.literal("assertNotVisible")}),pd=p.object({...x,expected:J,locator:T,operator:be,type:p.literal("assertText")}),md=p.object({...x,expected:J,operator:be,type:p.literal("assertUrl")}),fd=p.object({...x,expected:Ct,locator:T,operator:Pt,type:p.literal("assertCount")}),gd=p.object({...x,expected:J,locator:T,operator:be,type:p.literal("assertValue")}),yd=p.object({...x,attribute:p.string().min(1),expected:J,locator:T,operator:be,type:p.literal("assertAttribute")}),hd=p.object({...x,locator:T,type:p.literal("assertEnabled")}),wd=p.object({...x,locator:T,type:p.literal("assertDisabled")}),bd=p.object({...x,expected:J,operator:be,type:p.literal("assertTitle")}),Sd=p.object({...x,locator:T,type:p.literal("assertChecked")}),vd=p.object({...x,locator:T,type:p.literal("assertNotChecked")}),kd=p.object({...x,locator:T,type:p.literal("assertFocused")}),Rd=p.object({...x,locator:T,type:p.literal("assertNotFocused")}),xd=p.object({...x,budget:p.enum(["fast","slow","async"]),observer:p.string().min(1).max(200),params:p.record(p.string().max(200),J),type:p.literal("assertObserver")}),oi=p.discriminatedUnion("type",[Mc,Wc,Hc,qc,Bc,zc,Gc,Kc,dd,ud,pd,md,fd,gd,yd,hd,wd,Jc,Yc,Xc,Qc,Zc,ed,td,rd,nd,od,id,sd,ad,ld,cd,bd,Sd,vd,kd,Rd,xd]),At=p.object({entryNode:p.string().min(1).max(200),nodes:p.record(p.string().max(200),oi).refine(e=>Object.keys(e).length<=ni,`Workflow has more than ${String(ni)} nodes`),uiOnly:p.boolean().optional(),variableNamespaces:p.record(p.string().max(200),p.string().max(500)).optional(),variables:p.record(p.string().max(200),Tt).optional()});var Pd=ii.record(ii.string().max(200),_r),Ed={assumedVersion:1,detect:e=>typeof e=="object"&&e!==null&&"entryNode"in e&&"nodes"in e},Cd={assumedVersion:1,detect:e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&!("__codec"in e)},Vr=xt("workflow-spec").legacy(Ed).initial(At).build(),Td=xt("precondition-map").legacy(Cd).initial(Pd).build();import{z as Fr}from"zod";var si=["fast","slow","async"],Ad=Fr.object({budget:Fr.enum(si).describe("Polling budget tier: fast | slow | async"),description:Fr.string().min(1).describe("Human-readable description of what this observer checks")}).describe("A named backend state observer. Tests assert against it with assert.backend(observer, params). Implementation lives on the user's server.");import{graphql as Nt,readFragment as It}from"gql.tada";import{z as re}from"zod";import ai from"crypto";import{Webhook as $d}from"standardwebhooks";function Se({body:e,secret:t}){let r=new $d(t),n=`msg_${ai.randomUUID()}`,o=new Date,i=r.sign(n,o,e),s=Math.floor(o.getTime()/1e3);return{"webhook-id":n,"webhook-signature":i,"webhook-timestamp":String(s)}}function Mr(){return`whsec_${ai.randomBytes(24).toString("base64")}`}var Id=15e4,jd={async:{backoffMs:[500,1e3,2e3,5e3],timeoutMs:12e4},fast:{backoffMs:[100,250,500,1e3],timeoutMs:5e3},slow:{backoffMs:[250,500,1e3,2e3],timeoutMs:3e4}},Nd=re.discriminatedUnion("kind",[re.object({kind:re.literal("pass")}),re.object({kind:re.literal("retry"),reason:re.string()}),re.object({kind:re.literal("fail"),reason:re.string()})]),Od=re.object({error:re.string().optional(),outcome:Nd.optional(),success:re.boolean()});async function li({apiUrl:e,budget:t,observer:r,params:n,webhookSecret:o}){let i=jd[t],s=performance.now(),a={lastReason:void 0,pollCount:0};for(;performance.now()-s<i.timeoutMs;){a.pollCount+=1;let l=await Dd({apiUrl:e,observer:r,params:n,webhookSecret:o}),c=Ld({observer:r,outcome:l,start:s,state:a});if(c!=null)return c;let d=i.timeoutMs-(performance.now()-s);if(d<=0)break;let u=Math.min(_d({backoff:i.backoffMs,pollCount:a.pollCount}),d);await Ud(u)}return{description:`observer "${r}"`,detail:`budget "${t}" exhausted after ${String(a.pollCount)} poll(s) (${ci(s)}); last: ${a.lastReason??"no retry reason"}
|
|
112
|
+
\u2192 /ripplo:debug \u2014 check .ripplo/debug/<runId>/ artifacts`,status:"failed"}}function Ld({observer:e,outcome:t,start:r,state:n}){return t.kind==="transport-error"?{description:`observer "${e}"`,detail:`transport error after ${String(n.pollCount)} poll(s): ${t.reason}
|
|
113
|
+
Load \`/ripplo:setup\` skill for instructions on engine endpoint + webhook secret wiring.`,status:"failed"}:t.kind==="pass"?{description:`observer "${e}"`,detail:n.pollCount>1?`passed after ${String(n.pollCount)} polls (${ci(r)})`:void 0,status:"passed"}:t.kind==="fail"?{description:`observer "${e}"`,detail:`failed (invariant): ${t.reason} (after ${String(n.pollCount)} poll(s)) \u2014 ctx.fail stops polling immediately and is reserved for invariant violations (wrong shape, contradictory/forbidden state). For transient conditions like "not yet committed", "status not yet X", or "row not found", use ctx.retry(reason) so the runtime keeps polling until the budget expires.
|
|
114
|
+
Load \`/ripplo:create\` skill for instructions.`,status:"failed"}:(n.lastReason=t.reason,null)}async function Dd({apiUrl:e,observer:t,params:r,webhookSecret:n}){let o=JSON.stringify({observer:t,params:r});try{let i=await fetch(`${e}/execute-observer`,{body:o,headers:{"Content-Type":"application/json",...Se({body:o,secret:n})},method:"PUT",signal:AbortSignal.timeout(Id)});if(!i.ok){let l=await i.text().catch(()=>"");return{kind:"transport-error",reason:`status ${String(i.status)}: ${l.slice(0,200)}`}}let s=await i.json(),a=Od.safeParse(s);return a.success?!a.data.success||a.data.outcome==null?{kind:"transport-error",reason:a.data.error??"engine reported failure without outcome"}:a.data.outcome:{kind:"transport-error",reason:`invalid response shape: ${a.error.message}`}}catch(i){let s=i instanceof Error?i.message:String(i);return g.error("observer request failed: %s",s),{kind:"transport-error",reason:s}}}function _d({backoff:e,pollCount:t}){let r=Math.min(t-1,e.length-1);return e[r]??1e3}function ci(e){return`${String(Math.round(performance.now()-e))}ms`}async function Ud(e){return new Promise(t=>setTimeout(t,e))}async function Y({fn:e,label:t}){let r=performance.now(),n=await e();return g.info("%s: %dms",t,Math.round(performance.now()-r)),n}var Vd=1e4;async function Wr({failFast:e,getRecordingOffsetMs:t,observerTransport:r,onStep:n,page:o,spec:i,variables:s}){let a=performance.now();return Md({currentId:i.entryNode,failFast:e,getRecordingOffsetMs:t,observerTransport:r,onStep:n,page:o,runStartTime:a,spec:i,variables:s})}function Fd({onStep:e,steps:t,target:r}){t.forEach(n=>{let o={...n,stepIndex:r.length};r.push(o),e?.(o)})}async function Md({currentId:e,failFast:t,getRecordingOffsetMs:r,observerTransport:n,onStep:o,page:i,runStartTime:s,spec:a,variables:l}){let c=[],d=l,u=e;for(;u!=null;){let f=a.nodes[u];if(f==null)throw new Error(`Node "${u}" not found in spec`);let b=u,w=f.label??`${f.type} (${u})`;g.info("Executing node: %s [%s]",w,f.type);let h=await Wd({getRecordingOffsetMs:r,node:f,nodeId:b,observerTransport:n,page:i,runStartTime:s,variables:d});if(Fd({onStep:o,steps:[h],target:c}),d=h.variables,t&&h.status==="failed")break;u=f.next}return{steps:c,variables:d}}async function Wd({getRecordingOffsetMs:e,node:t,nodeId:r,observerTransport:n,page:o,runStartTime:i,variables:s}){let a=performance.now(),l=e?.(),c=t.label??`${t.type} (${t.id})`,d=Vd,u=ft({node:t,page:o});try{let f=await Hd({node:t,observerTransport:n,page:o,timeout:d,variables:s}),b=Math.round(performance.now()-a),w=f.assertions.some(C=>C.status==="failed"),h=await Y({label:`Snapshot [${c}]`,fn:()=>ye({page:o,runStartTime:i,targets:u})}),S=e?.();return{annotations:h.annotations,assertions:f.assertions,detail:void 0,duration:b,nodeId:r,nodeType:t.type,recordingEndMs:S,recordingStartMs:l,snapshotTimestamp:h.snapshotTimestamp,status:w?"failed":"passed",stepIndex:0,title:c,url:h.url,variables:f.variables,viewportHeight:h.viewportHeight,viewportWidth:h.viewportWidth}}catch(f){let b=Math.round(performance.now()-a),w=f instanceof Error?f.message:String(f),h=await Y({label:`Snapshot [${c}] (error)`,fn:()=>ye({page:o,runStartTime:i,targets:u})}),S=e?.();return{annotations:h.annotations,assertions:[],detail:w,duration:b,nodeId:r,nodeType:t.type,recordingEndMs:S,recordingStartMs:l,snapshotTimestamp:h.snapshotTimestamp,status:"failed",stepIndex:0,title:c,url:h.url,variables:s,viewportHeight:h.viewportHeight,viewportWidth:h.viewportWidth}}}async function Hd({node:e,observerTransport:t,page:r,timeout:n,variables:o}){if(qd(e)){let s=await sr({node:e,page:r,timeout:n,variables:o});return{assertions:[],variables:s.variables}}return{assertions:await zd({node:e,observerTransport:t,page:r,timeout:n,variables:o}),variables:o}}function qd(e){return["goto","click","dblclick","fill","select","hover","press","check","uncheck","clear","rightClick","handleDialog","clipboard","setPermission","setViewport","fail","setVariable","extractText","upload","drag","scrollIntoView","type","focus"].includes(e.type)}function Bd(e){return e.type.startsWith("assert")}async function zd({node:e,observerTransport:t,page:r,timeout:n,variables:o}){if(!Bd(e))throw new Error(`Unknown node type: ${e.type}`);let i=e;switch(i.type){case"assertVisible":case"assertNotVisible":case"assertEnabled":case"assertDisabled":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertNotFocused":return Kd({assertNode:i,page:r,timeout:n,variables:o});case"assertText":{let s=G({ref:i.expected,variables:o});return[await Rr({expected:s,locator:L({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertUrl":{let s=G({ref:i.expected,variables:o});return[St({expected:s,operator:i.operator,url:r.url()})]}case"assertTitle":{let s=G({ref:i.expected,variables:o});return[St({expected:s,operator:i.operator,url:await r.title()})]}case"assertCount":{let s=ir({ref:i.expected,variables:o});return[await xr({expected:s,locator:L({locator:i.locator,page:r,variables:o}),operator:i.operator})]}case"assertValue":{let s=G({ref:i.expected,variables:o});return[await Pr({expected:s,locator:L({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertAttribute":{let s=G({ref:i.expected,variables:o});return[await Ho({attribute:i.attribute,expected:s,locator:L({locator:i.locator,page:r,variables:o}),operator:i.operator,timeout:n})]}case"assertObserver":{if(t==null)return[{description:`observer "${i.observer}"`,detail:"observer transport not configured \u2014 set engineUrl + webhookSecret in ripplo.config",status:"failed"}];let s={};return Object.entries(i.params).forEach(([a,l])=>{s[a]=G({ref:l,variables:o})}),[await li({apiUrl:t.apiUrl,budget:i.budget,observer:i.observer,params:s,webhookSecret:t.webhookSecret})]}}}var Gd={assertChecked:zo,assertDisabled:Bo,assertEnabled:qo,assertFocused:Ko,assertNotChecked:Go,assertNotFocused:Jo,assertNotVisible:Cr,assertVisible:Er};async function Kd({assertNode:e,page:t,timeout:r,variables:n}){let o=Gd[e.type];return[await o({locator:L({locator:e.locator,page:t,variables:n}),timeout:r})]}async function Hr({baseUrl:e,browser:t,cookies:r,extraVariables:n,observerTransport:o,onRecordingChunk:i,onStep:s,runId:a,spec:l}){let c=await t.newContext({baseURL:e});g.info("Browser context created"),r.length>0&&await c.addCookies(r);let d=await c.newPage();g.info("Page created");let u=Ye(d),f=await bt(d);async function b(){let N=await f.takeChunk();N!=null&&i?.(N)}let w=setInterval(()=>{b()},2e3),h=[],S=!1;function C(N){s?.(N),S||(S=!0,f.start()),h.push(ht({context:c,page:d,runId:a,stepIndex:N.stepIndex,stepResult:N}))}let D=Jd(n,l.variableNamespaces),q={...Ke({defs:l.variables}),...D};g.info("Starting graph execution (entry: %s)",l.entryNode);let j=await Wr({failFast:!0,getRecordingOffsetMs:f.currentOffsetMs,observerTransport:o,onStep:C,page:d,spec:l,variables:q});await Promise.allSettled(h);let U=j.steps.filter(N=>N.status==="passed").length,oe=j.steps.filter(N=>N.status==="failed").length,Te={duration:j.steps.reduce((N,ae)=>N+ae.duration,0),failCount:oe,passCount:U,runId:a,status:oe>0?"failed":"passed",workflowName:""};return await wt({monitor:u,runId:a,steps:j.steps,summary:Te}),clearInterval(w),await f.detach(),await b(),await c.close(),j.steps}function Jd(e,t){if(e==null||t==null)return{};let r=new Map;Object.entries(t).forEach(([o,i])=>{r.set(i,o)});let n={};return Object.entries(e).forEach(([o,i])=>{let s=r.get(o);s!=null&&(n[s]={...n[s],...i})}),n}import{parseSetCookie as Yd}from"set-cookie-parser";import{z as Z}from"zod";var di=3e4,Xd=Z.object({data:Z.record(Z.string(),Z.record(Z.string(),Z.string())),error:Z.string().optional(),executed:Z.array(Z.string()),runId:Z.string(),success:Z.boolean()});async function qr({project:e,webhookSecret:t,workflowSlug:r}){let n={apiUrl:void 0,cookies:[],data:{},executed:[]},o=e.workflows.find(a=>a.slug===r);if(o==null)return n;let i=e.engineBaseUrl.length===0?void 0:e.engineBaseUrl,s=o.preconditions;return s.length===0?{...n,apiUrl:i}:i==null?n:ui({apiUrl:i,preconditionNames:s,webhookSecret:t})}async function Br({apiUrl:e,cookies:t,data:r,executed:n,webhookSecret:o}){if(n.length!==0)try{let i=JSON.stringify({data:r,preconditions:n}),s=await fetch(`${e}/teardown-preconditions`,{body:i,headers:{"Content-Type":"application/json",...tu({cookies:t}),...Se({body:i,secret:o})},method:"PUT",signal:AbortSignal.timeout(di)});s.ok||g.error("Teardown returned %s",String(s.status))}catch{g.error("Teardown request failed")}}async function ui({apiUrl:e,preconditionNames:t,webhookSecret:r}){let n=performance.now(),o=JSON.stringify({preconditions:t}),i=await fetch(`${e}/execute-preconditions`,{body:o,headers:{"Content-Type":"application/json",...Se({body:o,secret:r})},method:"PUT",signal:AbortSignal.timeout(di)});if(!i.ok){let c=await Zd(i);throw new Error(`execute-preconditions returned ${String(i.status)}: ${c}`)}let s=await i.json(),a=Xd.safeParse(s);if(!a.success)throw new Error(`execute-preconditions response has invalid shape: ${a.error.message}`);if(!a.data.success){let c=a.data.error??"no error detail";throw new Error(`Precondition batch failed: ${c}`)}let l=ru({domain:new URL(e).hostname,res:i});return g.info("Preconditions resolved: %s (%dms)",a.data.executed.join(", "),Math.round(performance.now()-n)),{apiUrl:e,cookies:l,data:a.data.data,executed:a.data.executed}}var Qd=Z.object({error:Z.string()});async function Zd(e){let t=await e.text().catch(()=>"");if(t.length===0)return"no body";let r=eu(t),n=r==null?null:Qd.safeParse(r);return n!=null&&n.success?n.data.error:t.slice(0,500)}function eu(e){try{return JSON.parse(e)}catch{return null}}function tu({cookies:e}){return e.length===0?{}:{Cookie:e.map(r=>`${r.name}=${r.value}`).join("; ")}}function ru({domain:e,res:t}){let r=t.headers.getSetCookie();return Yd(r,{decodeValues:!1}).map(o=>nu({cookie:o,domain:e}))}function nu({cookie:e,domain:t}){let r={domain:e.domain??t,httpOnly:e.httpOnly??!1,name:e.name,path:e.path??"/",secure:e.secure??!1,value:e.value};return e.sameSite!=null&&(r.sameSite=iu({raw:e.sameSite})),e.expires!=null?r.expires=Math.floor(e.expires.getTime()/1e3):e.maxAge!=null&&(r.expires=Math.floor(Date.now()/1e3)+e.maxAge),r}var ou={lax:"Lax",none:"None",strict:"Strict"};function iu({raw:e}){return ou[e.toLowerCase()]??"Lax"}async function zr({engineBaseUrl:e,preconditionNames:t,webhookSecret:r}){let n=e.length===0?void 0:e;return n==null||t.length===0?{apiUrl:n,cookies:[],data:{},executed:[]}:ui({apiUrl:n,preconditionNames:t,webhookSecret:r})}import{graphql as $t}from"gql.tada";async function Gr({agentProfileId:e,config:t,runId:r}){let n=await k({config:t,document:lu,variables:{agentProfileId:e??null,platform:"chromium",runId:r}});if(n.startRun==null)throw new Error("Failed to start run");let o=n.startRun.id,i=[];function s(d){let u=au({config:t,runResultId:o,steps:[d]}).catch(f=>{g.error(f,"Failed to submit step %d",d.stepIndex)});i.push(u)}function a(d){let u=su({chunk:d,config:t,runResultId:o}).catch(f=>{g.error(f,"Failed to submit recording chunk %d",d.chunkIndex)});i.push(u)}async function l(){await Promise.all(i)}async function c({statusOverride:d,steps:u,summary:f}){await Y({label:`flushSteps (${String(i.length)} steps)`,fn:()=>Promise.all(i)});let b=u.filter(C=>C.status==="passed").length,w=u.filter(C=>C.status==="failed").length,h=u.reduce((C,D)=>C+D.duration,0),S=d??(w>0?"failed":"passed");await Y({label:"completeRun",fn:()=>k({config:t,document:uu,variables:{duration:h,failCount:w,passCount:b,runResultId:o,status:S,summary:f??null,warnCount:0}})})}return{complete:c,enqueueRecordingChunk:a,enqueueStep:s,flushSteps:l,runResultId:o}}async function su({chunk:e,config:t,runResultId:r}){await k({config:t,document:du,variables:{input:{bodyBase64:e.body.toString("base64"),chunkIndex:e.chunkIndex,endTimestamp:e.endTimestamp,eventCount:e.eventCount,runResultId:r,startTimestamp:e.startTimestamp}}})}async function au({config:e,runResultId:t,steps:r}){let n=r.map(o=>({annotations:o.annotations.map(i=>({height:i.height,label:i.label,rrwebNodeId:i.rrwebNodeId??null,type:i.type,width:i.width,x:i.x,y:i.y})),assertions:o.assertions.map(i=>({description:i.description,detail:i.detail,status:i.status})),detail:o.detail,duration:o.duration,nodeType:o.nodeType,recordingEndMs:o.recordingEndMs??null,recordingStartMs:o.recordingStartMs??null,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth}));await k({config:e,document:cu,variables:{runResultId:t,steps:n}})}var lu=$t(`
|
|
103
115
|
mutation StartRunCLI($runId: String!, $platform: String!, $agentProfileId: String) {
|
|
104
116
|
startRun(runId: $runId, platform: $platform, agentProfileId: $agentProfileId) {
|
|
105
117
|
id
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
|
-
`),
|
|
120
|
+
`),cu=$t(`
|
|
109
121
|
mutation SubmitRunStepsCLI($runResultId: String!, $steps: [StepInput!]!) {
|
|
110
122
|
submitRunSteps(runResultId: $runResultId, steps: $steps)
|
|
111
123
|
}
|
|
112
|
-
`),
|
|
124
|
+
`),du=$t(`
|
|
113
125
|
mutation SubmitRunRecordingChunkCLI($input: SubmitRunRecordingChunkInput!) {
|
|
114
126
|
submitRunRecordingChunk(input: $input)
|
|
115
127
|
}
|
|
116
|
-
`),
|
|
128
|
+
`),uu=$t(`
|
|
117
129
|
mutation CompleteRunCLI(
|
|
118
130
|
$runResultId: String!
|
|
119
131
|
$status: String!
|
|
@@ -136,7 +148,7 @@ ${n}`].join(`
|
|
|
136
148
|
status
|
|
137
149
|
}
|
|
138
150
|
}
|
|
139
|
-
`)
|
|
151
|
+
`);var pu=12e4,jt=Nt(`
|
|
140
152
|
fragment WorkflowRun on Workflow {
|
|
141
153
|
id
|
|
142
154
|
slug
|
|
@@ -148,7 +160,7 @@ ${n}`].join(`
|
|
|
148
160
|
preconditionName
|
|
149
161
|
}
|
|
150
162
|
}
|
|
151
|
-
`),
|
|
163
|
+
`),pi=Nt(`
|
|
152
164
|
fragment ProjectRun on Project {
|
|
153
165
|
id
|
|
154
166
|
cloudBaseUrl
|
|
@@ -157,13 +169,13 @@ ${n}`].join(`
|
|
|
157
169
|
...WorkflowRun
|
|
158
170
|
}
|
|
159
171
|
}
|
|
160
|
-
`,[
|
|
172
|
+
`,[jt]),mu=Nt(`
|
|
161
173
|
query ProjectRun($projectId: String!) {
|
|
162
174
|
project(id: $projectId) {
|
|
163
175
|
...ProjectRun
|
|
164
176
|
}
|
|
165
177
|
}
|
|
166
|
-
`,[
|
|
178
|
+
`,[pi]),fu=Nt(`
|
|
167
179
|
query AgentProfileRun($id: String!) {
|
|
168
180
|
agentProfile(id: $id) {
|
|
169
181
|
id
|
|
@@ -173,182 +185,171 @@ ${n}`].join(`
|
|
|
173
185
|
successCriteria
|
|
174
186
|
}
|
|
175
187
|
}
|
|
176
|
-
`);
|
|
188
|
+
`);async function Kr({agentProfileDescription:e,agentProfileId:t,baseUrl:r,browser:n,config:o,headed:i,preconditionNames:s,runId:a,webhookSecret:l,workflowId:c}){let d="unknown",u,f,b=!1;try{b=n==null,f=gu({externalBrowser:n,headed:i});let w=s==null?void 0:Y({label:"Preconditions resolved",fn:()=>zr({engineBaseUrl:o.engineUrl,preconditionNames:s,webhookSecret:l})}),[{project:h,workflow:S},C]=await Promise.all([Y({label:"Run context resolved",fn:()=>ku({config:o,workflowId:c})}),Y({label:"Streaming run started",fn:()=>Gr({agentProfileId:t,config:o,runId:a})}),Ar({appUrl:r})]);d=S.name,u=C;let D=xu(S.spec);g.info("Executing workflow: %s",S.name),await Cu(hu({agentProfileDescription:e,agentProfileId:t,baseUrl:r,browserPromise:f,config:o,headed:i,ownsBrowser:b,preconditionPromise:w,project:h,runId:a,specData:D,streaming:u,webhookSecret:l,workflow:S}),Eu())}catch(w){throw await yu({browserPromise:f,error:w,ownsBrowser:b,runId:a,streaming:u,workflowName:d}),w}}function gu({externalBrowser:e,headed:t}){return e!=null?Promise.resolve(e):Y({label:"Browser launched",fn:()=>xe({headed:t})})}async function yu({browserPromise:e,error:t,ownsBrowser:r,runId:n,streaming:o,workflowName:i}){let s=t instanceof Error?t.message:String(t),a=t instanceof Error?t.stack:void 0;await Mo({error:s,runId:n,stack:a,workflowName:i}),o!=null&&await o.complete({statusOverride:"failed",steps:[],summary:s}).catch(()=>{}),r&&e!=null&&await(await e.catch(()=>{}))?.close()}async function hu({agentProfileDescription:e,agentProfileId:t,baseUrl:r,browserPromise:n,config:o,headed:i,ownsBrowser:s,preconditionPromise:a,project:l,runId:c,specData:d,streaming:u,webhookSecret:f,workflow:b}){let w=a??Y({label:"Preconditions resolved",fn:()=>qr({project:Su(l),webhookSecret:f,workflowSlug:b.slug})}),[h,S]=await Promise.all([w,n]);if(t!=null){s&&await S.close(),await wu({agentProfileDescription:e,agentProfileId:t,baseUrl:r,config:o,headed:i,preconditionResult:h,runId:c,specData:d,streaming:u,webhookSecret:f,workflow:b});return}await vu({baseUrl:r,browser:S,preconditionResult:h,runId:c,specData:d,streaming:u,webhookSecret:f})}async function wu({agentProfileDescription:e,agentProfileId:t,baseUrl:r,config:n,headed:o,preconditionResult:i,runId:s,specData:a,streaming:l,webhookSecret:c,workflow:d}){let u=e!=null&&e.length>0?e:await Ru({config:n,profileId:t});await kr({baseUrl:r,cookies:i.cookies,executedPreconditions:i.executed,extraVariables:i.data,headed:o,runId:s,serverUrl:n.ripploServerUrl,spec:a,streaming:l,systemPrompt:u,token:n.token,workflowContext:{description:d.name,expectedOutcome:d.name,name:d.name}}),await mi({preconditionResult:i,webhookSecret:c})}var bu=pe.object({preconditions:pe.array(pe.string()),requiresKeys:pe.array(pe.object({namespace:pe.string(),preconditionName:pe.string()})),slug:pe.string()});function Su(e){let t=(e.workflows??[]).map(r=>{let n=It(jt,r);return bu.parse(n)});return{engineBaseUrl:e.engineBaseUrl,workflows:t}}async function vu({baseUrl:e,browser:t,preconditionResult:r,runId:n,specData:o,streaming:i,webhookSecret:s}){let a=await Y({label:"Spec executed",fn:()=>Hr({baseUrl:e,browser:t,cookies:r.cookies,extraVariables:r.data,observerTransport:r.apiUrl==null?void 0:{apiUrl:r.apiUrl,webhookSecret:s},onRecordingChunk:i.enqueueRecordingChunk,onStep:i.enqueueStep,runId:n,spec:o})});await mi({preconditionResult:r,webhookSecret:s}),await i.complete({statusOverride:void 0,steps:a,summary:void 0});let l=a.filter(d=>d.status==="passed").length,c=a.filter(d=>d.status==="failed").length;g.info("Run complete: %d passed, %d failed",l,c)}async function mi({preconditionResult:e,webhookSecret:t}){e.apiUrl!=null&&await Br({apiUrl:e.apiUrl,cookies:e.cookies,data:e.data,executed:e.executed,webhookSecret:t})}async function ku({config:e,workflowId:t}){let r=await k({config:e,document:mu,variables:{projectId:e.projectId}});if(r.project==null)throw new Error("Project not found");let o={...It(pi,r.project),...e.engineUrl.length>0?{engineBaseUrl:e.engineUrl}:{}},s=(o.workflows??[]).find(l=>It(jt,l).id===t);if(s==null)throw new Error(`Workflow ${t} not found`);let a=It(jt,s);return{project:o,workflow:a}}async function Ru({config:e,profileId:t}){let r=await k({config:e,document:fu,variables:{id:t}});if(r.agentProfile==null)throw new Error(`Agent profile not found: ${t}`);let n=r.agentProfile,o=n.description;if(o==null||o.length===0)throw new Error(`Agent profile "${n.name}" has no description`);return g.info("Using agent profile: %s",n.name),br({description:o,output:n.output??void 0,successCriteria:n.successCriteria??void 0})}function xu(e){if(e==null)throw new Error("Workflow has no spec");return Vr.decode(e)}var Pu=pe.coerce.number().int().positive().catch(pu);function Eu(){return Pu.parse(process.env.RIPPLO_RUN_TIMEOUT_MS)}async function Cu(e,t){let r,n=new Promise((o,i)=>{r=setTimeout(()=>{i(new Error(`Run timed out after ${String(t)}ms`))},t)});try{await Promise.race([e,n])}finally{r!=null&&clearTimeout(r)}}import{exec as Nu}from"child_process";import{createAuthClient as Tu}from"better-auth/client";import{deviceAuthorizationClient as Au}from"better-auth/client/plugins";function fi({baseURL:e}){return Tu({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[Au()]})}import{z as gi}from"zod";var $u="https://ripplo.ai",Iu={dev:"https://ripplo-dev.up.railway.app"};function Ee(){let e=process.argv.findIndex(o=>o.startsWith("--env"));if(e===-1)return tt().RIPPLO_SERVER_URL;let t=process.argv[e];if(t==null)return tt().RIPPLO_SERVER_URL;let r=t.includes("=")?t.split("=")[1]:process.argv[e+1];if(r==null)return tt().RIPPLO_SERVER_URL;let n=Iu[r];if(n==null)throw new Error(`Unknown env "${r}". Use "dev" \u2014 or set RIPPLO_SERVER_URL.`);return n}var ju=gi.object({RIPPLO_SERVER_URL:gi.string().min(1).default($u)}),yi;function tt(){return yi??=ju.parse(process.env),yi}var Ou=5e3,hi="ripplo-cli";async function wi({onDeviceCode:e,url:t}){let r=t??tt().RIPPLO_SERVER_URL,n=fi({baseURL:r}),o=await n.device.code({client_id:hi});if(o.error!=null)throw new Error(`Failed to request device code: ${o.error.error_description}`);let{device_code:i,user_code:s,verification_uri_complete:a}=o.data;e({userCode:s,verificationUrl:a}),Fu(a);let l=await Lu({authClient:n,deviceCode:i});return Or(l),l}async function Lu({authClient:e,deviceCode:t}){for(;;){await Uu(Ou);let r=await e.device.token({client_id:hi,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(r.data?.access_token!=null)return r.data.access_token;if(r.error==null)continue;if(!_u(r.error.error))throw new Error(`Authorization failed: ${r.error.error_description}`)}}var Du=new Set(["authorization_pending","slow_down"]);function _u(e){return Du.has(e)}function Uu(e){return new Promise(t=>{setTimeout(t,e)})}function Vu(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function Fu(e){let t=Vu();Nu(`${t} "${e}"`,()=>{})}function rt({serverUrl:e,token:t}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:t,webhookSecret:""}}var bi=Mu(`
|
|
189
|
+
query AuthStatusMe {
|
|
190
|
+
me
|
|
191
|
+
}
|
|
192
|
+
`);async function Si(){let e=Ee(),t=le();if(t!=null){let r=await Wu({serverUrl:e,token:t});if(r!=null){process.stdout.write(`Already authenticated as ${r}. Logout first to switch.
|
|
193
|
+
`);return}process.stdout.write(`Existing token invalid; re-authenticating.
|
|
194
|
+
`)}await wi({url:e,onDeviceCode:r=>{process.stdout.write(`Code ${r.userCode} \u2014 open ${r.verificationUrl}
|
|
195
|
+
`)}}),process.stdout.write(`Authenticated. Token: ${he("token")}
|
|
196
|
+
`)}async function Wu({serverUrl:e,token:t}){try{return(await k({config:rt({serverUrl:e,token:t}),document:bi,variables:void 0})).me}catch{return null}}async function vi(){let e=le();e==null&&(process.stdout.write("Not authenticated. Run `ripplo auth login`.\n"),process.exit(1));let t=Ee(),r=rt({serverUrl:t,token:e});try{let n=await k({config:r,document:bi,variables:void 0});n.me==null&&(process.stdout.write("Token rejected. Run `ripplo auth login` to re-authenticate.\n"),process.exit(1)),process.stdout.write(`Authenticated as ${n.me} (${t})
|
|
197
|
+
`)}catch(n){let o=n instanceof Error?n.message:String(n);process.stdout.write(`Token check failed: ${o}
|
|
198
|
+
`),process.exit(1)}}function ki(){if(!Lr()){process.stdout.write(`No token to remove.
|
|
199
|
+
`);return}process.stdout.write(`Removed ${he("token")}
|
|
200
|
+
`)}import Yr from"fs/promises";import Xr from"path";import{z as Ot}from"zod";import{z as Ri}from"zod";import{z as Oe}from"zod";import{z as m}from"zod";import{z as ve}from"zod";import{z as Ti}from"zod";import{z as W}from"zod";import{z as ee}from"zod";import{z as Jr}from"zod";import{z as B}from"zod";var Hu=Ot.object({__codec:Ot.string().min(1),data:Ot.unknown(),version:Ot.number().int().positive()}),qu=class extends Error{codec;currentVersion;gotVersion;constructor(e){super(`Unsupported ${e.codec} version ${String(e.gotVersion)} (current ${String(e.currentVersion)}). Upgrade Ripplo or rebuild with a compatible CLI.`),this.name="CodecVersionError",this.codec=e.codec,this.currentVersion=e.currentVersion,this.gotVersion=e.gotVersion}},Bu=class extends Error{constructor(e){super(`Codec mismatch: expected "${e.expected}", got "${e.got}"`),this.name="CodecMismatchError"}};function en(e){return Pi({legacy:void 0,migrators:[],name:e,schemas:[]})}function zu(e,t){let r=JSON.parse(t);return e.decode(r)}function Pi(e){return{initial:t=>Qr(t,{...e,schemas:[t]}),legacy:t=>Pi({...e,legacy:t})}}function Qr(e,t){return{build:()=>Gu(e,t),legacy:r=>Qr(e,{...t,legacy:r}),upgrade:(r,n)=>{let o=n;return Qr(r,{...t,migrators:[...t.migrators,o],schemas:[...t.schemas,r]})}}}function Gu(e,t){let r=t.schemas.length;return{currentVersion:r,name:t.name,decode:n=>Ku(e,t,n),encode:n=>({__codec:t.name,data:n,version:r})}}function Ku(e,t,r){let{data:n,version:o}=Ju(t,r),i=Ei(t,n,o);return e.parse(i)}function Ju(e,t){let r=Hu.safeParse(t);if(r.success){if(r.data.__codec!==e.name)throw new Bu({expected:e.name,got:r.data.__codec});return{data:r.data.data,version:r.data.version}}if(e.legacy!=null&&e.legacy.detect(t))return{data:t,version:e.legacy.assumedVersion};throw new Error(`Cannot decode "${e.name}": value is not a codec envelope and no legacy detector matched.`)}function Ei(e,t,r){let n=e.schemas.length;if(r>n)throw new qu({codec:e.name,currentVersion:n,gotVersion:r});if(r===n)return t;let o=e.schemas[r-1];if(o==null)throw new Error(`Codec "${e.name}" missing schema for v${String(r)}; cannot migrate.`);let i=o.parse(t),s=e.migrators[r-1];if(s==null)throw new Error(`Codec "${e.name}" missing migrator v${String(r)} \u2192 v${String(r+1)}.`);return Ei(e,s(i),r+1)}var Ci=Oe.object({depends:Oe.array(Oe.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:Oe.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:Oe.array(Oe.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."),Yu=ve.object({by:ve.literal("testId"),value:ve.string().min(1)}),Xu=ve.object({by:ve.literal("role"),name:ve.string().optional(),role:ve.string().min(1)}),A=ve.discriminatedUnion("by",[Yu,Xu]),nt=Ti.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),Qu=Ti.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]),Zu=W.object({type:W.literal("static"),value:W.union([W.string(),W.number(),W.boolean()])}),tn=W.object({name:W.string().min(1),type:W.literal("variable")}),ep=W.discriminatedUnion("type",[Zu,tn]),se=W.discriminatedUnion("type",[W.object({type:W.literal("static"),value:W.string()}),tn]),tp=W.discriminatedUnion("type",[W.object({type:W.literal("static"),value:W.number().int().nonnegative()}),tn]),rp=ee.discriminatedUnion("type",[ee.object({default:ee.string().optional(),type:ee.literal("string")}),ee.object({default:ee.number().optional(),type:ee.literal("number")}),ee.object({default:ee.boolean().optional(),type:ee.literal("boolean")}),ee.object({key:ee.string().min(1),type:ee.literal("env")})]),P={id:m.string().min(1).max(200),label:m.string().max(500).optional(),next:m.string().max(200).optional(),uiOnly:m.boolean().optional()},xi=500,np=m.object({...P,type:m.literal("goto"),url:se}),op=m.object({...P,locator:A,type:m.literal("click")}),ip=m.object({...P,locator:A,type:m.literal("fill"),value:se}),sp=m.object({...P,locator:A,type:m.literal("select"),value:se}),ap=m.object({...P,locator:A,type:m.literal("hover")}),lp=m.object({...P,key:m.string().min(1),locator:A.optional(),type:m.literal("press")}),cp=m.object({...P,locator:A,type:m.literal("check")}),dp=m.object({...P,locator:A,type:m.literal("uncheck")}),up=m.object({...P,height:m.number().int().positive(),type:m.literal("setViewport"),width:m.number().int().positive()}),pp=m.object({...P,message:m.string().min(1),type:m.literal("fail")}),mp=m.object({...P,type:m.literal("setVariable"),value:ep,variable:m.string().min(1)}),fp=m.object({...P,locator:A,type:m.literal("extractText"),variable:m.string().min(1)}),gp=m.object({...P,files:m.array(m.string()).min(1),locator:A,type:m.literal("upload")}),yp=m.object({...P,locator:A,type:m.literal("dblclick")}),hp=m.object({...P,source:A,target:A,type:m.literal("drag")}),wp=m.object({...P,locator:A,type:m.literal("scrollIntoView")}),bp=m.object({...P,locator:A,type:m.literal("type"),value:se}),Sp=m.object({...P,locator:A,type:m.literal("focus")}),vp=m.object({...P,locator:A,type:m.literal("clear")}),kp=m.object({...P,locator:A,type:m.literal("rightClick")}),Rp=m.object({...P,action:m.enum(["accept","dismiss"]),promptText:m.string().optional(),type:m.literal("handleDialog")}),xp=m.object({...P,action:m.enum(["read","write"]),type:m.literal("clipboard"),value:se.optional(),variable:m.string().min(1).optional()}),Pp=m.object({...P,permission:m.string().min(1),state:m.enum(["granted","prompt"]),type:m.literal("setPermission")}),Ep=m.object({...P,locator:A,type:m.literal("assertVisible")}),Cp=m.object({...P,locator:A,type:m.literal("assertNotVisible")}),Tp=m.object({...P,expected:se,locator:A,operator:nt,type:m.literal("assertText")}),Ap=m.object({...P,expected:se,operator:nt,type:m.literal("assertUrl")}),$p=m.object({...P,expected:tp,locator:A,operator:Qu,type:m.literal("assertCount")}),Ip=m.object({...P,expected:se,locator:A,operator:nt,type:m.literal("assertValue")}),jp=m.object({...P,attribute:m.string().min(1),expected:se,locator:A,operator:nt,type:m.literal("assertAttribute")}),Np=m.object({...P,locator:A,type:m.literal("assertEnabled")}),Op=m.object({...P,locator:A,type:m.literal("assertDisabled")}),Lp=m.object({...P,expected:se,operator:nt,type:m.literal("assertTitle")}),Dp=m.object({...P,locator:A,type:m.literal("assertChecked")}),_p=m.object({...P,locator:A,type:m.literal("assertNotChecked")}),Up=m.object({...P,locator:A,type:m.literal("assertFocused")}),Vp=m.object({...P,locator:A,type:m.literal("assertNotFocused")}),Fp=m.object({...P,budget:m.enum(["fast","slow","async"]),observer:m.string().min(1).max(200),params:m.record(m.string().max(200),se),type:m.literal("assertObserver")}),Mp=m.discriminatedUnion("type",[np,op,ip,sp,ap,lp,cp,dp,Ep,Cp,Tp,Ap,$p,Ip,jp,Np,Op,up,pp,mp,fp,gp,yp,hp,wp,bp,Sp,vp,kp,Rp,xp,Pp,Lp,Dp,_p,Up,Vp,Fp]),Ai=m.object({entryNode:m.string().min(1).max(200),nodes:m.record(m.string().max(200),Mp).refine(e=>Object.keys(e).length<=xi,`Workflow has more than ${String(xi)} nodes`),uiOnly:m.boolean().optional(),variableNamespaces:m.record(m.string().max(200),m.string().max(500)).optional(),variables:m.record(m.string().max(200),rp).optional()}),Wp=Ri.record(Ri.string().max(200),Ci),Hp={assumedVersion:1,detect:e=>typeof e=="object"&&e!==null&&"entryNode"in e&&"nodes"in e},qp={assumedVersion:1,detect:e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&!("__codec"in e)},xx=en("workflow-spec").legacy(Hp).initial(Ai).build(),Px=en("precondition-map").legacy(qp).initial(Wp).build(),Bp=["fast","slow","async"],zp=Jr.object({budget:Jr.enum(Bp).describe("Polling budget tier: fast | slow | async"),description:Jr.string().min(1).describe("Human-readable description of what this observer checks")}).describe("A named backend state observer. Tests assert against it with assert.backend(observer, params). Implementation lives on the user's server."),ce=".ripplo/ripplo.lock",Gp=5e3,Kp=B.record(B.string().max(200),B.string().max(200)),Jp=B.object({coverage:B.array(B.string().max(500)).max(2e3).default([]),expectedOutcome:B.string().max(2e3),name:B.string().max(200),preconditions:B.array(B.string().max(200)).max(1e3),requiresKeys:Kp,slug:B.string().max(200),spec:Ai}),Yp=B.object({observers:B.record(B.string().max(200),zp),preconditions:B.record(B.string().max(200),Ci),tests:B.array(Jp).max(Gp)}),$i=en("ripplo-lockfile").initial(Yp).build();function Ii(e){return{observers:e.observers,preconditions:e.preconditions,tests:e.tests.filter(t=>t.implemented).map(t=>({coverage:[...t.coverage],expectedOutcome:t.expectedOutcome,name:t.name,preconditions:[...t.preconditions],requiresKeys:{...t.requiresKeys},slug:t.slug,spec:t.spec}))}}function Zr(e){let t=$i.encode(e);return`${JSON.stringify(t,Zp(t),2)}
|
|
201
|
+
`}async function Lt({cwd:e}){let t=Xr.join(e,ce),r=await Xp(t);return r==null?null:zu($i,r)}async function de({cwd:e,result:t}){let r=Ii(t),n=Xr.join(e,ce);await Yr.mkdir(Xr.dirname(n),{recursive:!0}),await Yr.writeFile(n,Zr(r),"utf8")}function Dt({compiled:e,existing:t}){if(t==null)return"missing";let r=Zr(Ii(e)),n=Zr(t);return r===n?"match":"stale"}async function Xp(e){try{return await Yr.readFile(e,"utf8")}catch(t){if(Qp(t)&&t.code==="ENOENT")return null;throw t}}function Qp(e){return e instanceof Error&&"code"in e}function Zp(e){return function(r,n){return n===e||!em(n)?n:Object.fromEntries(Object.entries(n).toSorted(([o],[i])=>o.localeCompare(i)))}}function em(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import Vt from"fs";import sn from"path";var rn=["**/src/**","**/app/**","**/apps/**","**/pages/**","**/routes/**","**/components/**","**/server/**","**/api/**","**/backend/**","**/features/**","**/modules/**","**/views/**","**/ui/**","**/hooks/**","**/contexts/**","**/providers/**","**/controllers/**","**/handlers/**","**/resolvers/**","**/services/**","**/middleware/**","**/lib/**"],ke=["**/*.gen.*","**/generated/**","**/*.d.ts","**/*.test.*","**/*.spec.*","**/node_modules/**","**/dist/**","**/build/**",".ripplo/**","**/*.md","**/.next/**","**/.turbo/**","**/.vercel/**","**/.svelte-kit/**","**/.nuxt/**","**/.astro/**","**/coverage/**","**/storybook-static/**","**/*.stories.*","**/*.story.*","**/cli/**","**/scripts/**","**/tools/**","**/__tests__/**","**/__mocks__/**","**/__fixtures__/**","**/*.config.*","**/*.setup.*","**/public/**","**/static/**","**/assets/**","**/migrations/**","**/prisma/migrations/**","**/scripts/**"];function ji(e){return e.data}function Ni(e){return{as(t){return{data:{label:t,node:e}}}}}function _t(e){let t=e.getPreconditions(),r=e.getObservers(),n=e.getTests();tm(n);let o={};t.forEach(a=>{o[a.name]={depends:[...a.dependsOn],description:a.description,returns:[...a.returns]}});let i={};r.forEach(a=>{i[a.name]={budget:a.budget,description:a.description}});let s=n.map(a=>rm(a,t));return{observers:i,preconditions:o,tests:s}}function tm(e){let t=new Map;e.forEach(r=>{let n=t.get(r.id);if(n!=null)throw new Error(`Duplicate test id "${r.id}" used by "${n}" and "${r.name}"`);t.set(r.id,r.name)})}function rm(e,t){let r=e.id,{accessedKeys:n,vars:o}=om(e.requiresKeys),i=e.startsAtFn==null?void 0:e.startsAtFn(o),s=e.stepsFn==null?[]:e.stepsFn(o),a=i==null?s:[nm(i),...s],l=im(a,n,e.requiresKeys,e.uiOnly),c=[];Object.keys(e.requiresKeys).length>0&&n.size===0&&e.implemented&&c.push("Test requires preconditions but never references their data \u2014 destructure and use precondition data in steps()");let u=am(e.requires,t);return{additionalChecks:[],coverage:e.coverage,description:e.description,expectedOutcome:e.expectedOutcome,implemented:e.implemented,name:e.name,preconditions:u,requiresKeys:{...e.requiresKeys},slug:r,spec:l,warnings:c}}function nm(e){return Ni({type:"goto",url:{type:"static",value:e}}).as(`navigate to ${e}`)}function om(e){let t=new Set,r={};return Object.keys(e).forEach(n=>{r[n]=new Proxy({},{get(o,i){if(typeof i=="string"){let s=`${n}.${i}`;return t.add(s),`{{${s}}}`}}})}),{accessedKeys:t,vars:r}}function im(e,t,r,n){let o={};e.forEach((a,l)=>{let c=`step-${String(l)}`,d=l<e.length-1?`step-${String(l+1)}`:void 0;o[c]=sm(a,c,d)});let i={};t.forEach(a=>{i[a]={default:`test-${a}`,type:"string"}});let s={...r};return{entryNode:"step-0",nodes:o,uiOnly:n,variableNamespaces:s,variables:i}}function sm(e,t,r){let{label:n,node:o}=ji(e);return{...o,id:t,label:n,next:r}}function am(e,t){let r=new Map(t.map(s=>[s.name,s])),n=[],o=new Set;function i(s){o.has(s)||(o.add(s),r.get(s)?.dependsOn.forEach(a=>{i(a)}),n.push(s))}return e.forEach(s=>{i(s)}),n}import{Webhook as Dx,WebhookVerificationError as _x}from"standardwebhooks";import{z as $}from"zod";var Vx=$.object({preconditions:$.array($.string().min(1))}),Fx=$.object({data:$.record($.string(),$.record($.string(),$.string())),preconditions:$.array($.string().min(1))}),Mx=$.object({observer:$.string().min(1).max(200),params:$.record($.string().max(200),$.string())}),lm=$.discriminatedUnion("kind",[$.object({kind:$.literal("pass")}),$.object({kind:$.literal("retry"),reason:$.string()}),$.object({kind:$.literal("fail"),reason:$.string()})]),Wx=$.object({error:$.string().optional(),outcome:lm.optional(),success:$.boolean()});function Le(e){let t=[];return e.tests.forEach(r=>{let n=cm(r),o=i=>{t.push({...i,test:r.slug})};Im.forEach(i=>{i(n,r,o)})}),{diagnostics:t}}function cm(e){let t=[],r=e.spec.entryNode,n=new Set;for(;r!=null&&!n.has(r);){n.add(r);let o=e.spec.nodes[r];if(o==null)break;t.push(o),r=o.next}return t}function dm(e,t,r){e.forEach(n=>{n.type==="assertText"&&"operator"in n&&n.operator!=="equals"&&r({message:`${n.type} uses operator "${n.operator}" \u2014 only "equals" is allowed for determinism`,rule:"exact-text-match",step:n.label??n.id})})}function um(e,t,r){Object.keys(t.spec.variables??{}).length>0&&e.forEach(o=>{if(o.type==="fill"&&Li(o.value)){let i=o.value.value;!Di(i)&&wm(i)&&r({message:`fill() uses hardcoded value "${i}" \u2014 consider using precondition data via {{namespace.key}}`,rule:"no-hardcoded-data",step:o.label??o.id})}})}function pm(e,t,r){if(Object.keys(t.spec.variables??{}).length===0)return;e.some(i=>JSON.stringify(i).includes("{{"))||r({message:"Test requires preconditions but steps() never references precondition data \u2014 destructure and use it",rule:"prefer-precondition-data",step:void 0})}function mm(e,t,r){e.forEach(n=>{(n.label==null||n.label.length===0)&&r({message:`Step "${n.id}" lacks .as("...") label \u2014 every step must be labeled`,rule:"missing-label",step:n.id})})}function fm(e,t,r){let n=new Map;e.forEach(o=>{if(o.label==null)return;let i=n.get(o.label);i==null?n.set(o.label,o.id):r({message:`Duplicate label "${o.label}" \u2014 also used by ${i}`,rule:"no-duplicate-labels",step:o.label})})}function gm(e,t,r){let n=0;e.forEach(o=>{De(o)?n=0:(n++,n===3&&r({message:"3+ consecutive actions without an assertion \u2014 add verification between actions",rule:"assert-after-action",step:o.label??o.id}))})}function ym(e,t,r){if(e.length===0)return;let n=e.at(-1);n!=null&&!De(n)&&r({message:"Last step is an action, not an assertion \u2014 expectedOutcome should be verified by assertions at the end",rule:"assert-matches-outcome",step:n.label??n.id})}function hm(e,t,r){t.implemented&&e.length===0&&r({message:"Test has zero steps",rule:"no-empty-steps",step:void 0})}function Li(e){return!(typeof e!="object"||e==null||!("type"in e)||e.type!=="static"||!("value"in e)||typeof e.value!="string")}function Di(e){return e.includes("{{")}function wm(e){return e.includes("@")||/\b[a-f0-9]{8,}\b/.test(e)||/^(test|ripplo|example|sample|demo)/i.test(e)}function De(e){return e.type.startsWith("assert")}var bm=new Set(["assertText","assertValue","assertCount","assertUrl","assertNotVisible","assertChecked","assertNotChecked","assertAttribute","assertDisabled","assertEnabled"]);function Sm(e){return bm.has(e.type)}function vm(e,t,r){!t.implemented||e.length===0||e.some(n=>De(n))||r({message:"Test has zero assertion steps \u2014 cannot verify expectedOutcome. Add assert.* steps.",rule:"no-assertions",step:void 0})}function km(e,t,r){if(!t.implemented||e.length<=3)return;let n=e.filter(i=>De(i)).length;if(n===0)return;let o=n/e.length;if(o<.15){let i=Math.round(o*100);r({message:`Only ${String(n)}/${String(e.length)} steps are assertions (${String(i)}%) \u2014 add more verification between actions`,rule:"low-assertion-ratio",step:void 0})}}function nn(e){if(!("locator"in e)||e.locator==null)return;let t=e.locator;return t.by==="role"?`role:${t.role}:${t.name??""}`:`testId:${t.value}`}function Rm(e,t,r){e.forEach((n,o)=>{if(n.type!=="click")return;let i=nn(n);if(i==null)return;let s=e.slice(o+1,o+4);s.find(c=>c.type==="assertVisible"&&nn(c)===i)==null||s.some(c=>Sm(c)||De(c)&&nn(c)!==i)||r({message:`click "${n.label??n.id}" is followed only by assert.visible on the same locator \u2014 verifies nothing about the click's effect`,rule:"tautological-post-click-assert",step:n.label??n.id})})}var xm=new Set(["the","is","a","an","and","or","of","to","in","on","at","for","that","this","with","be","are","was","were","it","its","as","by","from","after","before","should","will","can","still","but","not","no","so","if","then","than","user","users","page","view","shows","show","see","click","clicks","clicked","clickable","visible","appears","appear","displayed","stays","remains"]);function on(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>=3&&!xm.has(t))}function Pm(e){let t=e.label==null?[]:on(e.label);if(!("locator"in e)||e.locator==null)return t;let r=e.locator,n=r.by==="role"?r.name??"":r.value;return[...t,...on(n)]}function Em(e,t,r){if(!t.implemented||e.length===0)return;let n=new Set(on(t.expectedOutcome));if(n.size===0)return;let o=e.filter(s=>De(s));if(o.length===0)return;o.some(s=>Pm(s).some(a=>n.has(a)))||r({message:`No assertion references any keyword from expectedOutcome (${[...n].join(", ")}) \u2014 the outcome may not actually be verified`,rule:"expected-outcome-keyword-coverage",step:void 0})}var Cm=/save|submit|create|delete|remove|send|invite|update|confirm|publish|apply|pay|subscribe|upgrade|cancel|archive|rename/i;function Oi(e){if(e.type==="upload"||e.type==="handleDialog"&&e.action==="accept")return!0;if(e.type!=="click")return!1;let t=e.locator,r=t.by==="role"?t.name??"":t.value;return Cm.test(r)}function Tm(e,t,r){!t.implemented||t.spec.uiOnly===!0||e.forEach((n,o)=>{if(!Oi(n)||"uiOnly"in n&&n.uiOnly===!0)return;let i=e.slice(o+1),s=i.findIndex(d=>Oi(d)),a=s===-1?i.length:s;i.slice(0,a).some(d=>d.type==="assertObserver")||r({message:`"${n.label??n.id}" looks like it mutates backend state but no assert.backend(...) observer verifies it \u2014 the test can pass while the server is broken. You need to add an observer that checks the persisted result (see .ripplo/observers/ for examples). Only if this action truly does NOT change any server state (pure client-side interaction, presentation toggle, etc.) should you fall back to marking the step { uiOnly: true } to silence this rule.`,rule:"mutation-without-observer-coverage",step:n.label??n.id})})}function Am(e,t,r){Object.keys(t.spec.variables??{}).length!==0&&e.forEach(o=>{if(o.type!=="assertObserver")return;let i=Object.entries(o.params);i.length===0||i.some(([,a])=>Li(a)&&Di(a.value))||r({message:`assert.backend "${o.label??o.id}" passes only hardcoded params while the test defines precondition variables \u2014 observer assertions should reference {{namespace.key}} so they match the actual precondition data`,rule:"observer-params-reference-variables",step:o.label??o.id})})}function $m(e,t,r){let n=new Set(Object.keys(t.spec.variables??{})),o=/\{\{([^{}]+?)\}\}/g;e.forEach(i=>{let a=[...JSON.stringify(i).matchAll(o)],l=[...new Set(a.map(u=>u[1]).filter(u=>u!=null&&!n.has(u)))];if(l.length===0)return;let c=l.map(u=>`{{${u}}}`).join(", "),d=[...new Set(l.map(u=>u.split(".")[0]??u))].join(", ");r({message:`"${i.label??i.id}" contains literal template string(s) ${c} \u2014 destructure the proxy in .steps(({ ${d} }) => \u2026) and pass the proxy value (e.g. \`${l[0]??""}\`) directly. Writing the template as a string bypasses type-checking and silently accepts typos.`,rule:"no-literal-template-strings",step:i.label??i.id})})}var Im=[dm,um,$m,pm,mm,fm,gm,ym,hm,vm,km,Rm,Em,Tm,Am];import rf from"picomatch";import{execFileSync as jm,spawnSync as Nm}from"child_process";function ne(e,t){return jm("git",[...e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}function _i(e,t){let r=Nm("git",["show",e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]});if(r.status===0)return r.stdout;if(r.status===128)return null;throw new Error(`git show ${e} failed (${String(r.status)}): ${r.stderr}`)}import R from"typescript";import*as Ui from"remeda";var Vi=[["onClick","click"],["onContextMenu","click"],["onKeyDown","click"],["onKeyPress","click"],["onKeyUp","click"],["onSelect","click"],["onOpenChange","click"],["onPress","click"],["onActivate","click"],["onToggle","click"],["onOpen","click"],["onClose","click"],["onDismiss","click"],["onConfirm","click"],["onCancel","click"],["onApply","click"],["onClear","click"],["onSubmit","submit"],["onReset","submit"],["onDrop","drag"],["onDragEnd","drag"],["onDragEnter","drag"],["onDragLeave","drag"],["onDragOver","drag"],["onDragStart","drag"],["onValueChange","select"],["onSelectionChange","select"],["onChange","input"],["onCheckedChange","input"],["onInput","input"]],Om=new Map([["button","click"],["link","navigate"],["textbox","input"],["searchbox","input"],["combobox","select"],["listbox","select"]]),Lm=[[/(?:^|[a-z])Button$/,"click"],[/(?:^|[a-z])(?:Link|NavLink|Anchor)$/,"navigate"],[/(?:^|[a-z])(?:Textarea|TextArea|Input|Field|SearchBox)$/,"input"],[/(?:^|[a-z])(?:Select|Combobox|ComboBox|Dropdown)$/,"select"],[/(?:^|[a-z])Form$/,"submit"]];function Ut({filePath:e,source:t}){let r=R.createSourceFile(e,t,R.ScriptTarget.Latest,!0,R.ScriptKind.TSX);return r.statements.flatMap(n=>Dm({filePath:e,sf:r,stmt:n}))}function Dm({filePath:e,sf:t,stmt:r}){let n=Um(r);if(n==null||_m(n))return[];let o=Fi(r,t).map(i=>({id:`${e}#${n}.${i.kind}[${i.label}]`,line:i.line}));return Ui.uniqueBy(o,i=>i.id)}function _m(e){return e.endsWith("Fragment")||e.endsWith("Skeleton")||/^use[A-Z]/.test(e)||/^[A-Z][A-Z0-9_]*$/.test(e)}function Um(e){if(R.isExportAssignment(e))return Vm(e.expression);if(!Fm(e))return null;if(R.isFunctionDeclaration(e)||R.isClassDeclaration(e))return e.name?.text??null;if(R.isVariableStatement(e)){let t=e.declarationList.declarations[0];return t!=null&&R.isIdentifier(t.name)?t.name.text:null}return null}function Vm(e){return R.isIdentifier(e)?e.text:(R.isFunctionExpression(e)||R.isClassExpression(e))&&e.name!=null?e.name.text:"default"}function Fm(e){if(!R.canHaveModifiers(e))return!1;let t=R.getModifiers(e);return t!=null&&t.some(r=>r.kind===R.SyntaxKind.ExportKeyword)}function Fi(e,t){let r=Mm(e,t),n=e.getChildren(t).flatMap(o=>Fi(o,t));return r==null?n:[r,...n]}function Mm(e,t){let r=Wm(e);if(r==null)return null;let n=Hm(r);if(n==null)return null;let o=Km(r,n);return o==null?null:{kind:n,label:o,line:tf(t,e.getStart(t))}}function Wm(e){return R.isJsxSelfClosingElement(e)&&R.isIdentifier(e.tagName)?{attrs:e.attributes,children:[],tag:e.tagName.text}:R.isJsxElement(e)&&R.isIdentifier(e.openingElement.tagName)?{attrs:e.openingElement.attributes,children:e.children,tag:e.openingElement.tagName.text}:null}function Hm({attrs:e,tag:t}){let r=ue(e,"role");return r!=null?Om.get(r)??null:Bm(t,e)??zm(t)??Gm(e)}var qm=new Map([["button",()=>"click"],["a",e=>ue(e,"href")==null?null:"navigate"],["input",e=>ue(e,"type")==="file"?"upload":"input"],["textarea",()=>"input"],["select",()=>"select"],["form",()=>"submit"]]);function Bm(e,t){return qm.get(e)?.(t)??null}function zm(e){return/^[A-Z]/.test(e)?Lm.find(([t])=>t.test(e))?.[1]??null:null}function Gm(e){return Vi.find(([t])=>Xm(e,t))?.[1]??null}function Km({attrs:e,children:t,tag:r},n){return n==="navigate"?ue(e,"href")??ue(e,"to"):ue(e,"aria-label")??ue(e,"label")??ue(e,"title")??ue(e,"name")??ue(e,"placeholder")??(Jm(r)?void 0:ef(t))??Ym(e,n)}function Jm(e){return e==="input"||e==="textarea"||e==="select"}function Ym(e,t){let r=Vi.find(([,o])=>o===t)?.[0];if(r==null)return;let n=Qm(e,r);if(n!=null){if(R.isIdentifier(n))return n.text;if(R.isArrowFunction(n)||R.isFunctionExpression(n))return Mi(n.body)}}function Mi(e){if(R.isCallExpression(e)){let t=e.expression;return R.isIdentifier(t)?t.text:R.isPropertyAccessExpression(t)?t.name.text:void 0}return R.forEachChild(e,Mi)}function Xm(e,t){return e.properties.some(r=>R.isJsxAttribute(r)&&R.isIdentifier(r.name)&&r.name.text===t)}function Wi(e,t){return e.properties.find(r=>R.isJsxAttribute(r)&&R.isIdentifier(r.name)&&r.name.text===t)}function ue(e,t){let r=Wi(e,t);return r==null?void 0:Zm(r.initializer)}function Qm(e,t){let r=Wi(e,t);if(!(r?.initializer==null||!R.isJsxExpression(r.initializer)))return r.initializer.expression}function Zm(e){if(e==null)return"";if(R.isStringLiteral(e))return e.text;if(R.isJsxExpression(e))return qi(e.expression)}function ef(e){let t=e.flatMap(r=>Hi(r)).join(" ").trim();return t.length===0?void 0:t}function Hi(e){if(R.isJsxText(e)){let t=e.text.trim();return t.length===0?[]:[t]}if(R.isJsxExpression(e)){let t=qi(e.expression);return t==null?[]:[t]}return R.isJsxElement(e)?e.children.flatMap(t=>Hi(t)):[]}function qi(e){if(e!=null){if(R.isStringLiteral(e)||R.isNoSubstitutionTemplateLiteral(e))return e.text;if(R.isCallExpression(e)&&e.arguments.length===1){let t=e.arguments[0];if(t!=null&&(R.isStringLiteral(t)||R.isNoSubstitutionTemplateLiteral(t)))return t.text}}}function tf(e,t){return e.getLineAndCharacterOfPosition(t).line+1}var nf=sn.join(".ripplo","coverage.d.ts");function _e({cwd:e}){of({cwd:e,ignorePaths:ke})}function of({cwd:e,ignorePaths:t}){let r=Ue({cwd:e,ignorePaths:t});lf({content:af(r),cwd:e})}function Ue({cwd:e,ignorePaths:t}){let n=sf({cwd:e,ignorePaths:t}).flatMap(o=>an({cwd:e,file:o}));return[...new Set(n)].sort((o,i)=>o.localeCompare(i))}function sf({cwd:e,ignorePaths:t}){let r=ne(["ls-files","--cached","--others","--exclude-standard","-z"],e),n=rf([...t]);return r.split("\0").filter(o=>o.length>0&&/\.(tsx|jsx)$/.test(o)).filter(o=>!n(o))}function an({cwd:e,file:t}){let r=Vt.readFileSync(sn.join(e,t),"utf8");return Ut({filePath:t,source:r}).map(n=>n.id)}function af(e){let t=`// GENERATED \u2014 do not edit
|
|
202
|
+
import "@ripplo/testing";
|
|
203
|
+
|
|
204
|
+
declare module "@ripplo/testing" {
|
|
205
|
+
interface CoverageRegistry {
|
|
206
|
+
`,r=e.map(o=>` ${JSON.stringify(o)}: true;`).join(`
|
|
207
|
+
`);return e.length===0?`${t} }
|
|
208
|
+
}
|
|
209
|
+
`:`${t}${r}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
`}function lf({content:e,cwd:t}){let r=sn.join(t,nf);Vt.existsSync(r)&&Vt.readFileSync(r,"utf8")===e||Vt.writeFileSync(r,e)}import cf from"path";import{createJiti as df}from"jiti";var uf=["getObservers","getPreconditions","getTests","getUnimplemented"];function pf(e){return e==null||typeof e!="object"?!1:uf.every(t=>typeof Reflect.get(e,t)=="function")}function mf(e){return e===null?"null":Array.isArray(e)?"array":typeof e}async function I(e){let t=cf.join(e,".ripplo","index.ts");try{let n=await df(import.meta.url,{moduleCache:!1}).import(t),o=n!=null&&typeof n=="object"&&"default"in n?Reflect.get(n,"default"):n;if(!pf(o))return{error:`${t} must default-export a RipploBuilder (got ${mf(o)})`,ok:!1};let i=_t(o);return{builder:o,ok:!0,result:i}}catch(r){return{error:r instanceof Error?r.message:String(r),ok:!1}}}function E(e,t){return t==null?`Load \`/ripplo:${e}\` skill for instructions.`:`Load \`/ripplo:${e}\` skill for instructions on ${t}.`}function Bi(e){return e.length===1?E(e[0]):`REQUIRED before proceeding: load ${e.map(r=>`\`/ripplo:${r}\``).join(" AND ")} skills (load every one \u2014 each carries rules the others don't).`}async function zi(e){let t=process.cwd(),r=await I(t);if(r.ok||(process.stderr.write(`Compilation failed: ${r.error}
|
|
213
|
+
`),process.stderr.write(`${E("create","DSL authoring + lint rules")}
|
|
214
|
+
`),process.exit(1)),e.check){let n=await Lt({cwd:t}),o=Dt({compiled:r.result,existing:n});if(o==="match"){process.stdout.write(`${ce} is up to date
|
|
215
|
+
`);return}let i=o==="missing"?"missing":"out of date";process.stderr.write(`${ce} is ${i} \u2014 run \`ripplo compile\` and commit the result
|
|
216
|
+
`),process.stderr.write(`${E("setup")}
|
|
217
|
+
`),process.exit(1)}await de({cwd:t,result:r.result}),_e({cwd:t}),process.stdout.write(`wrote ${ce}
|
|
218
|
+
`)}import me from"process";import ff from"fs";import gf from"path";import yf from"picomatch";function Gi({compileResult:e,cwd:t,ignorePaths:r}){let n=new Set(Ue({cwd:t,ignorePaths:r})),o=Yi(e),i=hf({cwd:t,ignorePaths:r});return Ji({acknowledged:o,allStatements:n,unacked:i})}function Ki({compileResult:e,cwd:t,ignorePaths:r}){let n=new Set(Ue({cwd:t,ignorePaths:r})),o=Yi(e);return Ji({acknowledged:o,allStatements:n,unacked:n})}function Ji({acknowledged:e,allStatements:t,unacked:r}){let n=[...r].filter(i=>!e.has(i)).map(i=>({id:i,kind:"unacknowledged"})),o=[...e].filter(i=>!t.has(i)).map(i=>({id:i,kind:"stale"}));return[...n,...o]}function Yi(e){return new Set(e.tests.flatMap(t=>t.coverage))}function hf({cwd:e,ignorePaths:t}){let r=wf({cwd:e,ignorePaths:t}),n=new Set(r.flatMap(i=>bf({cwd:e,file:i}))),o=new Set(r.flatMap(i=>Sf({cwd:e,file:i})?an({cwd:e,file:i}):[]));return new Set([...o].filter(i=>!n.has(i)))}function wf({cwd:e,ignorePaths:t}){let r=ne(["diff","--name-only","HEAD","-z"],e),n=ne(["ls-files","--others","--exclude-standard","-z"],e),o=yf([...t]);return[...new Set([...r.split("\0"),...n.split("\0")])].filter(i=>i.length>0&&/\.(tsx|jsx)$/.test(i)).filter(i=>!o(i))}function bf({cwd:e,file:t}){let r=_i(`HEAD:${t}`,e);return r==null?[]:Ut({filePath:t,source:r}).map(n=>n.id)}function Sf({cwd:e,file:t}){return ff.existsSync(gf.join(e,t))}async function Xi(){let e=me.cwd(),t=await I(e);t.ok||(me.stderr.write(`Compilation failed: ${t.error}
|
|
219
|
+
`),me.exit(1));let r=Ue({cwd:e,ignorePaths:ke}),n=Ki({compileResult:t.result,cwd:e,ignorePaths:ke}),o=n.filter(a=>a.kind==="unacknowledged"),i=n.filter(a=>a.kind==="stale"),s=r.length-o.length;me.stdout.write(`Coverage: ${String(s)}/${String(r.length)} statements acknowledged
|
|
220
|
+
`),o.length>0&&(me.stdout.write(`
|
|
221
|
+
Unacknowledged (${String(o.length)}):
|
|
222
|
+
`),o.forEach(a=>me.stdout.write(` ${a.id}
|
|
223
|
+
`))),i.length>0&&(me.stdout.write(`
|
|
224
|
+
Stale claims (${String(i.length)}):
|
|
225
|
+
`),i.forEach(a=>me.stdout.write(` ${a.id}
|
|
226
|
+
`))),n.length>0&&me.exit(1)}import cn from"fs";import Rf from"path";import{chromium as xf}from"playwright";import vf from"fs";import kf from"path";async function Qi(e){let t=kf.join(e,".ripplo","index.ts");if(!vf.existsSync(t))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let r=await I(e);if(!r.ok)return{appUrl:void 0,engineUrl:void 0,errors:[{message:r.error,path:".ripplo/"}],valid:!1,warnings:[]};try{let n=Ae();return{appUrl:n.appUrl,engineUrl:n.engineUrl,errors:[],valid:!0,warnings:[]}}catch(n){return{appUrl:void 0,engineUrl:void 0,errors:[{message:n instanceof Error?n.message:String(n),path:""}],valid:!1,warnings:[]}}}async function ln(e){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return}catch{return`appUrl (${e}) is not responding. Make sure your dev server is running on that port.`}}async function Zi({appUrl:e,engineUrl:t}){let r=t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`;try{return(await fetch(`${r}/execute-preconditions`,{body:JSON.stringify({preconditions:[]}),headers:{"Content-Type":"application/json"},method:"PUT",signal:AbortSignal.timeout(5e3)})).ok?"Engine endpoint accepted an unsigned request \u2014 webhook signature verification may be missing.":void 0}catch{return}}function es(e){switch(e.type){case"settings":return!e.valid;case"env-files":return e.missing.length>0;case"token":return!e.exists;case"dev-server":return!e.reachable;case"preconditions":return e.count>0&&!e.configured;case"engine-endpoint":return!e.reachable;case"adapter-enabled":return e.status!=="enabled";case"webhook-verification":return!e.rejectsUnsigned;case"preconditions-validation":return!e.valid;case"workflows":return e.invalidNames.length>0;case"browser":return!e.installed;case"lockfile":return e.status!=="match";case"pre-commit-hook":return!e.installed}}async function ts(e){let t=await Cf(e),r={missing:tr(e),type:"env-files"},n=Tf(),o=Af(),i=await I(e),s=$f(i),a=Nf(i),l=await Pf(e,i),c=Ef(e),d=await Of(t,i);return[t,r,n,...d,s,a,l,c,o]}async function Pf(e,t){if(!t.ok)return{status:"missing",type:"lockfile"};let r=await Lt({cwd:e});return{status:Dt({compiled:t.result,existing:r}),type:"lockfile"}}function Ef(e){let t=Rf.join(e,".git","hooks","pre-commit");return cn.existsSync(t)?{installed:cn.readFileSync(t,"utf8").includes("ripplo compile --check"),type:"pre-commit-hook"}:{installed:!1,type:"pre-commit-hook"}}async function Cf(e){let t=await Qi(e);return t.valid?{missingFields:[],type:"settings",valid:!0}:{missingFields:t.errors.map(n=>n.path).filter(n=>n.length>0),type:"settings",valid:!1}}function Tf(){let e=le();return{exists:e!=null&&e.length>0,type:"token"}}function Af(){let e=xf.executablePath();return{installed:cn.existsSync(e),type:"browser"}}function $f(e){if(!e.ok)return{errorCount:1,errors:[{message:e.error,path:""}],found:!1,type:"preconditions-validation",valid:!1};let t=If(e.result.preconditions,e.result.tests);return{errorCount:t.length,errors:t,found:!0,type:"preconditions-validation",valid:t.length===0}}function If(e,t){let r=[],n=new Set(Object.keys(e));return Object.entries(e).forEach(([o,i])=>{(i.depends??[]).forEach(s=>{n.has(s)||r.push({message:`Depends on non-existent precondition "${s}"`,path:`preconditions.${o}.depends`})})}),t.forEach(o=>{Object.entries(o.requiresKeys).forEach(([i,s])=>{n.has(s)||r.push({message:`Test "${o.slug}" requires non-existent precondition "${s}" (as ${i})`,path:`tests.${o.slug}.requiresKeys.${i}`})})}),jf(e).forEach(o=>{r.push({message:o,path:"preconditions"})}),r}function jf(e){let t=new Set,r=new Set,n=[];function o(i){if(r.has(i)){n.push(`Precondition "${i}" has a circular dependency`);return}t.has(i)||(t.add(i),r.add(i),(e[i]?.depends??[]).forEach(s=>{o(s)}),r.delete(i))}return Object.keys(e).forEach(i=>{o(i)}),n}function Nf(e){if(!e.ok)return{invalidNames:[],invalidWorkflows:[],total:0,type:"workflows",valid:0};let t=e.result.tests.length;return{invalidNames:[],invalidWorkflows:[],total:t,type:"workflows",valid:t}}async function Of(e,t){if(!e.valid||!t.ok)return[];let r;try{let s=Ae();r={appUrl:s.appUrl,engineUrl:s.engineUrl,webhookSecret:s.webhookSecret}}catch{return[]}let n=[],o=await ln(r.appUrl)==null;n.push({appUrl:r.appUrl,reachable:o,type:"dev-server"});let i=await Lf(r,t);return n.push(...i),n}async function Lf(e,t){let r=t.ok?Object.keys(t.result.preconditions).length:0,n=e.engineUrl.length>0,o={configured:n,count:r,endpointReachable:void 0,type:"preconditions"};if(r===0||!n)return[o];let i=Uf(e.appUrl,e.engineUrl);if(i==null)return[o];let s=await ln(i)==null,a=[];if(a.push({configured:!0,count:r,endpointReachable:s,type:"preconditions"}),rs(e.engineUrl)&&a.push({reachable:s,type:"engine-endpoint",url:i}),!s)return a;let l=await Zi({appUrl:e.appUrl,engineUrl:e.engineUrl});a.push({rejectsUnsigned:l==null,type:"webhook-verification"});let c=await Df({engineUrl:i,webhookSecret:e.webhookSecret});return a.push({status:c,type:"adapter-enabled",url:i}),a}async function Df({engineUrl:e,webhookSecret:t}){if(t.length===0)return"no-secret";let r=JSON.stringify({preconditions:[]});try{let n=await fetch(`${e}/execute-preconditions`,{body:r,headers:{"Content-Type":"application/json",...Se({body:r,secret:t})},method:"PUT",signal:AbortSignal.timeout(5e3)});return n.status===404?"disabled":n.status===401||n.status===403?"bad-secret":"enabled"}catch{return"unreachable"}}function _f(e){switch(e.status){case"enabled":return`\u2713 Adapter: enabled at ${e.url}`;case"disabled":return"\u2717 Adapter: disabled (handler returned 404). Set ENABLE_RIPPLO_TESTING=true in your app's env (e.g. apps/<app>/.env.local for Next.js) and restart the dev server.";case"bad-secret":return"\u2717 Adapter: webhook signature rejected. RIPPLO_WEBHOOK_SECRET seen by your dev server does not match the one in your env file.";case"unreachable":return`\u2717 Adapter: ${e.url} could not be reached for signed probe.`;case"no-secret":return"\u2717 Adapter: RIPPLO_WEBHOOK_SECRET is not set in your env file (declared in .ripplo/project.json)."}}function rs(e){return e.startsWith("http://")||e.startsWith("https://")}function Uf(e,t){return rs(t)?t:`${e}${t}`}function ns(e){switch(e.type){case"settings":return Mf(e);case"env-files":return Wf(e);case"token":return Hf(e);case"dev-server":return qf(e);case"preconditions":return Gf(e);case"webhook-verification":return Bf(e);case"preconditions-validation":return Kf(e);case"workflows":return Jf(e);case"browser":return zf(e);case"engine-endpoint":return e.reachable?`\u2713 Engine endpoint: ${e.url} is reachable`:`\u2717 Engine endpoint: ${e.url} is not reachable`;case"adapter-enabled":return _f(e);case"lockfile":return Vf(e);case"pre-commit-hook":return Ff(e)}}function Vf(e){switch(e.status){case"match":return`\u2713 Lockfile: ${ce} is up to date`;case"missing":return`\u2717 Lockfile: ${ce} is missing \u2014 run \`ripplo compile\` and commit it`;case"stale":return`\u2717 Lockfile: ${ce} is out of date \u2014 run \`ripplo compile\` and commit it`}}function Ff(e){return e.installed?"\u2713 Pre-commit hook: .git/hooks/pre-commit runs `ripplo compile --check`":"! Pre-commit hook: .git/hooks/pre-commit does not run `ripplo compile --check` \u2014 see the setup skill for the snippet"}function Mf(e){return e.valid?"\u2713 Settings: Project configured":`\u2717 Settings: Missing fields: ${e.missingFields.join(", ")}`}function Wf(e){return e.missing.length===0?"\u2713 Env files: declared files present":`\u2717 Env files: declared in .ripplo/project.json but missing:
|
|
227
|
+
${e.missing.map(r=>` ${r}`).join(`
|
|
228
|
+
`)}
|
|
229
|
+
If you're in a git worktree, copy the env file from the main checkout (or symlink to a shared file outside the working tree).`}function Hf(e){return e.exists?"\u2713 Auth: Token found":"\u2717 Auth: No token found. Run `ripplo` to authenticate."}function qf(e){return e.reachable?`\u2713 Dev server: ${e.appUrl} is reachable`:`\u2717 Dev server: ${e.appUrl} is not responding. Make sure your dev server is running.`}function Bf(e){return e.rejectsUnsigned?"\u2713 Webhook verification: Unsigned requests are correctly rejected":"\u2717 Webhook verification: Endpoint accepted an unsigned request \u2014 webhook signature verification may be missing or misconfigured."}function zf(e){return e.installed?"\u2713 Browser: Chromium installed":"\u2717 Browser: Chromium not installed. Run: npx playwright install chromium"}function Gf(e){return e.count===0?"! Preconditions: None defined":e.configured?e.endpointReachable===void 0?`! Preconditions: ${String(e.count)} defined (could not verify endpoint)`:`\u2713 Preconditions: ${String(e.count)} defined, endpoint configured`:`\u2717 Preconditions: ${String(e.count)} defined but RIPPLO_ENGINE_URL is not set in your env file`}function Kf(e){if(!e.found)return"\u2717 State graph: DSL compilation failed";if(e.valid)return"\u2713 State graph: Valid";let t=e.errors.map(r=>` - ${r.path===""?"":r.path+": "}${r.message}`);return`\u2717 State graph: ${String(e.errorCount)} validation error${e.errorCount===1?"":"s"}
|
|
177
230
|
${t.join(`
|
|
178
|
-
`)}`}function
|
|
231
|
+
`)}`}function Jf(e){if(e.total===0)return"! Tests: No tests defined";if(e.invalidNames.length===0)return`\u2713 Tests: ${String(e.total)} valid`;let t=e.invalidWorkflows.map(r=>Yf(r));return`\u2717 Tests: ${String(e.invalidNames.length)} invalid
|
|
179
232
|
${t.join(`
|
|
180
|
-
`)}`}function
|
|
233
|
+
`)}`}function Yf(e){let t=e.errors.map(r=>" - "+(r.path===""?"":r.path+": ")+r.message);return" "+e.name+`:
|
|
181
234
|
`+t.join(`
|
|
182
|
-
`)}
|
|
235
|
+
`)}async function os(){let e=process.cwd(),t=await ts(e),r=t.map(o=>ns(o));process.stdout.write(r.join(`
|
|
236
|
+
`)+`
|
|
237
|
+
`);let n=t.some(o=>es(o));process.exit(n?1:0)}import{graphql as Mt,readFragment as og}from"gql.tada";import Qf from"crypto";import{graphql as Zf}from"gql.tada";import dn from"fs";import un from"path";function Ft(e){try{let t=un.join(Xf(e),"HEAD"),r=dn.readFileSync(t,"utf8").trim(),n="ref: refs/heads/";return r.startsWith(n)?r.slice(n.length):r.length===0?void 0:r.slice(0,7)}catch{return}}function Xf(e){let t=un.join(e,".git");if(dn.statSync(t).isDirectory())return t;let n=dn.readFileSync(t,"utf8").trim(),o="gitdir:";if(!n.startsWith(o))throw new Error(`unrecognized .git file at ${t}`);let i=n.slice(o.length).trim();if(i.length===0)throw new Error(`empty gitdir pointer at ${t}`);return un.resolve(e,i)}var eg=Zf(`
|
|
183
238
|
mutation SyncDevSession(
|
|
184
239
|
$projectId: String!
|
|
240
|
+
$cwd: String!
|
|
241
|
+
$branch: String
|
|
185
242
|
$preconditions: [SyncDevPreconditionInput!]!
|
|
186
243
|
$workflows: [SyncDevWorkflowInput!]!
|
|
187
244
|
) {
|
|
188
|
-
syncDevSession(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
`)});var od={};ei(od,{redirectStdioToFile:()=>wS});import Tn from"fs";import bS from"path";function wS(e){Tn.mkdirSync(bS.dirname(e),{recursive:!0});let t=Tn.openSync(e,"a"),n=process.stdout.write.bind(process.stdout),r=process.stderr.write.bind(process.stderr);function o(l,s,d){let c=typeof s=="string"?s:void 0,u=typeof l=="string"?Buffer.from(l,c??"utf8"):Buffer.from(l);Tn.writeSync(t,u);let y=typeof s=="function"?s:d;return y?.(),!0}let i=o;process.stdout.write=i,process.stderr.write=i;let a=!1;return function(){a||(a=!0,process.stdout.write=n,process.stderr.write=r,Tn.closeSync(t))}}var id=p(()=>{"use strict"});import{initGraphQLTada as AS}from"gql.tada";import{readFragment as xI}from"gql.tada";var No,ad=p(()=>{"use strict";No=AS()});var vo,Co=p(()=>{"use strict";vo={__schema:{queryType:{name:"Query",kind:"OBJECT"},mutationType:{name:"Mutation",kind:"OBJECT"},subscriptionType:{name:"Subscription",kind:"OBJECT"},types:[{kind:"OBJECT",name:"AgentProfile",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"description",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"icon",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"output",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"sourceTemplateSlug",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"successCriteria",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"AgentTemplate",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"description",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"icon",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"output",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"slug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"successCriteria",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"BankPaymentMethod",fields:[{name:"bankName",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"last4",type:{kind:"SCALAR",name:"Any"},args:[]}],interfaces:[]},{kind:"OBJECT",name:"BillingSubscription",fields:[{name:"billingInterval",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"cancelAtPeriodEnd",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"periodEnd",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"periodStart",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"plan",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"seats",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"status",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"BranchSnapshot",fields:[{name:"commitMessage",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"commitSha",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"graphFileHash",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"workflowHashes",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"CardPaymentMethod",fields:[{name:"brand",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"last4",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"CliToken",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"lastUsedAt",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"revokedAt",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"tokenPrefix",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"DevSession",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"expiresAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"healthChecks",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"HealthCheck",ofType:null}}},args:[]},{name:"hooksPaused",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"preconditions",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Precondition",ofType:null}}},args:[]},{name:"scopeItems",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"ScopeItem",ofType:null}}},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"workflowDiff",type:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"DevSessionWorkflowDiff",ofType:null}},args:[]},{name:"workflows",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Workflow",ofType:null}}},args:[{name:"where",type:{kind:"SCALAR",name:"Any"}}]}],interfaces:[]},{kind:"OBJECT",name:"DevSessionEvent",fields:[{name:"active",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"DevSessionSyncedEvent",fields:[{name:"devSession",type:{kind:"OBJECT",name:"DevSession",ofType:null},args:[]},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"DevSessionWorkflowDiff",fields:[{name:"added",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Workflow",ofType:null}}}},args:[]},{name:"modified",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Workflow",ofType:null}}}},args:[]},{name:"removed",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Workflow",ofType:null}}}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"DevWorkflowDeleteRequestedEvent",fields:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"slug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"DevWorkflowDuplicateRequestedEvent",fields:[{name:"newSlug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"sourceSlug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"GitHubInstallation",fields:[{name:"accountLogin",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"accountType",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"installationId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"GithubRepository",fields:[{name:"description",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"fullName",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"installationId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"url",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"HealthCheck",fields:[{name:"detail",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"tone",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"type",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"HealthChecksChangedEvent",fields:[{name:"devSession",type:{kind:"OBJECT",name:"DevSession",ofType:null},args:[]},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"userId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"HooksPausedRequestedEvent",fields:[{name:"paused",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"Invoice",fields:[{name:"date",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"hostedInvoiceUrl",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"status",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"totalCents",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"LinkPaymentMethod",fields:[{name:"email",type:{kind:"SCALAR",name:"Any"},args:[]}],interfaces:[]},{kind:"OBJECT",name:"Mutation",fields:[{name:"addAgentScopeItems",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"ScopeItem",ofType:null}}},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"workflowSlugs",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}}}]},{name:"addScopeItem",type:{kind:"OBJECT",name:"ScopeItem",ofType:null},args:[{name:"label",type:{kind:"SCALAR",name:"Any"}},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"source",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"workflowId",type:{kind:"SCALAR",name:"Any"}}]},{name:"cancelAllPendingRuns",type:{kind:"SCALAR",name:"Any"},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"cancelRun",type:{kind:"OBJECT",name:"Run",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"cloneAgentTemplate",type:{kind:"OBJECT",name:"AgentProfile",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"templateSlug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"completeRun",type:{kind:"OBJECT",name:"RunResult",ofType:null},args:[{name:"duration",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"failCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"passCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"runResultId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"status",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"summary",type:{kind:"SCALAR",name:"Any"}},{name:"warnCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"createAgentProfile",type:{kind:"OBJECT",name:"AgentProfile",ofType:null},args:[{name:"description",type:{kind:"SCALAR",name:"Any"}},{name:"icon",type:{kind:"SCALAR",name:"Any"}},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"createProject",type:{kind:"OBJECT",name:"Project",ofType:null},args:[{name:"cloudBaseUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"installationId",type:{kind:"SCALAR",name:"Any"}},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"organizationId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"provider",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"repoUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"createRun",type:{kind:"OBJECT",name:"Run",ofType:null},args:[{name:"agentProfileDescription",type:{kind:"SCALAR",name:"Any"}},{name:"agentProfileId",type:{kind:"SCALAR",name:"Any"}},{name:"concurrency",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"executor",type:{kind:"SCALAR",name:"Any"}},{name:"isTest",type:{kind:"SCALAR",name:"Any"}},{name:"platforms",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}}},{name:"workflowId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"deleteAgentProfile",type:{kind:"OBJECT",name:"AgentProfile",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"deleteDevWorkflow",type:{kind:"OBJECT",name:"Workflow",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"slug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"deleteProject",type:{kind:"OBJECT",name:"Project",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"duplicateDevWorkflow",type:{kind:"SCALAR",name:"Any"},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"slug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"endDevSession",type:{kind:"OBJECT",name:"DevSession",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"linkScopeItem",type:{kind:"OBJECT",name:"ScopeItem",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"workflowId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"pushHealthChecks",type:{kind:"SCALAR",name:"Any"},args:[{name:"checks",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}}},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"removeGitHubInstallation",type:{kind:"OBJECT",name:"GitHubInstallation",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"removeScopeItem",type:{kind:"SCALAR",name:"Any"},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"removeScopeItems",type:{kind:"SCALAR",name:"Any"},args:[{name:"ids",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}}}]},{name:"revokeCurrentCliToken",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"rotateWebhookSecret",type:{kind:"OBJECT",name:"Project",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"runAllWorkflows",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Run",ofType:null}}},args:[{name:"agentProfileDescription",type:{kind:"SCALAR",name:"Any"}},{name:"agentProfileId",type:{kind:"SCALAR",name:"Any"}},{name:"concurrency",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"executor",type:{kind:"SCALAR",name:"Any"}},{name:"platforms",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}}},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"workflowIds",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}}}]},{name:"saveGitHubInstallation",type:{kind:"OBJECT",name:"GitHubInstallation",ofType:null},args:[{name:"input",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"setHooksPaused",type:{kind:"SCALAR",name:"Any"},args:[{name:"paused",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"setOverageCap",type:{kind:"SCALAR",name:"Any"},args:[{name:"capCents",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"organizationId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"startRun",type:{kind:"OBJECT",name:"RunResult",ofType:null},args:[{name:"agentProfileId",type:{kind:"SCALAR",name:"Any"}},{name:"platform",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"runId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"submitRunRecordingChunk",type:{kind:"SCALAR",name:"Any"},args:[{name:"input",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"submitRunResults",type:{kind:"OBJECT",name:"RunResult",ofType:null},args:[{name:"agentProfileId",type:{kind:"SCALAR",name:"Any"}},{name:"duration",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"failCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"passCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"platform",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"runId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"status",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"steps",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"warnCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"submitRunSteps",type:{kind:"SCALAR",name:"Any"},args:[{name:"runResultId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"steps",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}}}]},{name:"syncBranch",type:{kind:"OBJECT",name:"TrackedBranch",ofType:null},args:[{name:"branchName",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"syncDevSession",type:{kind:"OBJECT",name:"DevSession",ofType:null},args:[{name:"preconditions",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}}},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"workflows",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}}}]},{name:"trackBranch",type:{kind:"OBJECT",name:"TrackedBranch",ofType:null},args:[{name:"branchName",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"untrackBranch",type:{kind:"OBJECT",name:"TrackedBranch",ofType:null},args:[{name:"branchName",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"updateAgentProfile",type:{kind:"OBJECT",name:"AgentProfile",ofType:null},args:[{name:"description",type:{kind:"SCALAR",name:"Any"}},{name:"icon",type:{kind:"SCALAR",name:"Any"}},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"name",type:{kind:"SCALAR",name:"Any"}},{name:"output",type:{kind:"SCALAR",name:"Any"}},{name:"successCriteria",type:{kind:"SCALAR",name:"Any"}}]},{name:"updateProject",type:{kind:"OBJECT",name:"Project",ofType:null},args:[{name:"cloudBaseUrl",type:{kind:"SCALAR",name:"Any"}},{name:"engineBaseUrl",type:{kind:"SCALAR",name:"Any"}},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"logoUrl",type:{kind:"SCALAR",name:"Any"}},{name:"name",type:{kind:"SCALAR",name:"Any"}}]},{name:"updateUsername",type:{kind:"OBJECT",name:"User",ofType:null},args:[{name:"username",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"updateWorkflow",type:{kind:"OBJECT",name:"Workflow",ofType:null},args:[{name:"baseUrl",type:{kind:"SCALAR",name:"Any"}},{name:"codebaseScope",type:{kind:"SCALAR",name:"Any"}},{name:"expectedOutcome",type:{kind:"SCALAR",name:"Any"}},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"name",type:{kind:"SCALAR",name:"Any"}},{name:"status",type:{kind:"SCALAR",name:"Any"}}]}],interfaces:[]},{kind:"OBJECT",name:"Organization",fields:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"limitStatus",type:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"OrganizationLimitStatus",ofType:null}},args:[{name:"projectId",type:{kind:"SCALAR",name:"Any"}}]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"OrganizationLimitStatus",fields:[{name:"agentCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"agentLimitPerProject",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"canCreateAgent",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"canCreateProject",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"canInviteMember",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"memberCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"memberLimit",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"planName",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"projectCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"projectLimit",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"runCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"runLimit",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"runLimitReached",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"tokenBudgetExceeded",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"OrganizationUsage",fields:[{name:"overageCapCents",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"overageSpentCents",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"periodEnd",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"periodStart",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"runCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"runLimit",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"runUsagePercent",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"tokenUsagePercent",type:{kind:"SCALAR",name:"Any"},args:[]}],interfaces:[]},{kind:"OBJECT",name:"OtherPaymentMethod",fields:[{name:"type",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"UNION",name:"PaymentMethod",possibleTypes:[{kind:"OBJECT",name:"BankPaymentMethod"},{kind:"OBJECT",name:"CardPaymentMethod"},{kind:"OBJECT",name:"LinkPaymentMethod"},{kind:"OBJECT",name:"OtherPaymentMethod"}]},{kind:"OBJECT",name:"Plan",fields:[{name:"annualPrice",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"limits",type:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"PlanLimits",ofType:null}},args:[]},{name:"monthlyPrice",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"PlanLimits",fields:[{name:"historyDays",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"maxAgents",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"maxProjects",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"maxRuns",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"maxUsers",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"runOverageCents",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"scheduling",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"tokenBudgetCents",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"Precondition",fields:[{name:"depends",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}},args:[]},{name:"description",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"returns",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"Project",fields:[{name:"agentProfiles",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"AgentProfile",ofType:null}}},args:[]},{name:"cloudBaseUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"defaultBranch",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"devSession",type:{kind:"OBJECT",name:"DevSession",ofType:null},args:[]},{name:"engineBaseUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"limitStatus",type:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"OrganizationLimitStatus",ofType:null}},args:[]},{name:"logoUrl",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"organization",type:{kind:"OBJECT",name:"Organization",ofType:null},args:[]},{name:"organizationId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"preconditions",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Precondition",ofType:null}}},args:[{name:"branch",type:{kind:"SCALAR",name:"Any"}}]},{name:"provider",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"repoUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"webhookSecret",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"workflows",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Workflow",ofType:null}}},args:[{name:"branch",type:{kind:"SCALAR",name:"Any"}}]}],interfaces:[]},{kind:"OBJECT",name:"ProjectRunStatusEvent",fields:[{name:"agentProfileId",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"completedAt",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"hasFailed",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"runId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"status",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"workflowId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"workflowSlug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"Query",fields:[{name:"activeSubscription",type:{kind:"OBJECT",name:"BillingSubscription",ofType:null},args:[{name:"organizationId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"agentProfile",type:{kind:"OBJECT",name:"AgentProfile",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"agentProfiles",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"AgentProfile",ofType:null}}},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"agentTemplates",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"AgentTemplate",ofType:null}}},args:[]},{name:"availablePlans",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Plan",ofType:null}}},args:[]},{name:"currentUser",type:{kind:"OBJECT",name:"User",ofType:null},args:[]},{name:"defaultPaymentMethod",type:{kind:"UNION",name:"PaymentMethod",ofType:null},args:[{name:"organizationId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"gitHubAppInstallUrl",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"gitHubInstallations",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"GitHubInstallation",ofType:null}}},args:[]},{name:"githubRepositories",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"GithubRepository",ofType:null}}},args:[]},{name:"healthcheck",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"invoices",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Invoice",ofType:null}}},args:[{name:"organizationId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"me",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"organizationLimitStatus",type:{kind:"OBJECT",name:"OrganizationLimitStatus",ofType:null},args:[{name:"organizationId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"projectId",type:{kind:"SCALAR",name:"Any"}}]},{name:"organizationUsage",type:{kind:"OBJECT",name:"OrganizationUsage",ofType:null},args:[{name:"organizationId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"pendingDevRuns",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Run",ofType:null}}},args:[{name:"devSessionId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"project",type:{kind:"OBJECT",name:"Project",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"projectRuns",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Run",ofType:null}}},args:[{name:"cursor",type:{kind:"SCALAR",name:"Any"}},{name:"devSessionId",type:{kind:"SCALAR",name:"Any"}},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"take",type:{kind:"SCALAR",name:"Any"}}]},{name:"projects",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Project",ofType:null}}},args:[]},{name:"run",type:{kind:"OBJECT",name:"Run",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"runResult",type:{kind:"OBJECT",name:"RunResult",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"runs",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Run",ofType:null}}},args:[{name:"take",type:{kind:"SCALAR",name:"Any"}},{name:"workflowId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"trackedBranches",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"TrackedBranch",ofType:null}}},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"workflow",type:{kind:"OBJECT",name:"Workflow",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{name:"slug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"workflows",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Workflow",ofType:null}}},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]}],interfaces:[]},{kind:"OBJECT",name:"Run",fields:[{name:"agentProfile",type:{kind:"OBJECT",name:"AgentProfile",ofType:null},args:[]},{name:"completedAt",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"concurrency",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"devSessionId",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"executor",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"failureReason",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"isTest",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"platforms",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}},args:[]},{name:"results",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"RunResult",ofType:null}}},args:[]},{name:"startedAt",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"status",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"totalRuns",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"userId",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"workflow",type:{kind:"OBJECT",name:"Workflow",ofType:null},args:[]}],interfaces:[]},{kind:"UNION",name:"RunProgressEvent",possibleTypes:[{kind:"OBJECT",name:"RunRecordingChunkAdded"},{kind:"OBJECT",name:"RunResultUpdated"},{kind:"OBJECT",name:"RunStatusChanged"},{kind:"OBJECT",name:"RunTraceEntryAdded"}]},{kind:"OBJECT",name:"RunRecordingChunk",fields:[{name:"byteSize",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"chunkIndex",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"endTimestamp",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"eventCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"signedUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"startTimestamp",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"RunRecordingChunkAdded",fields:[{name:"chunk",type:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"RunRecordingChunk",ofType:null}},args:[]},{name:"runResultId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"RunRequestedEvent",fields:[{name:"agentProfileDescription",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"agentProfileId",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"executor",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"runId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"workflowId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"workflowSlug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"RunResult",fields:[{name:"agentProfile",type:{kind:"OBJECT",name:"AgentProfile",ofType:null},args:[]},{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"duration",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"failCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"passCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"perfP50",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"perfP90",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"perfP99",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"perfTotal",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"platform",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"recordingChunks",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"RunRecordingChunk",ofType:null}}}},args:[]},{name:"sideEffects",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"SideEffect",ofType:null}}}},args:[]},{name:"status",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"summary",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"traceEntries",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"TraceEntry",ofType:null}}}},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"warnCount",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"RunResultUpdated",fields:[{name:"runResult",type:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"RunResult",ofType:null}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"RunStatusChanged",fields:[{name:"run",type:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Run",ofType:null}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"RunTraceEntryAdded",fields:[{name:"runResultId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"traceEntry",type:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"TraceEntry",ofType:null}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"ScopeChangedEvent",fields:[{name:"devSession",type:{kind:"OBJECT",name:"DevSession",ofType:null},args:[]},{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"userId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"ScopeItem",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"label",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"source",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"workflow",type:{kind:"OBJECT",name:"Workflow",ofType:null},args:[]}],interfaces:[]},{kind:"OBJECT",name:"ScreenAnnotation",fields:[{name:"height",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"label",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"type",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"width",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"x",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"y",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"SideEffect",fields:[{name:"detail",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"status",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"Subscription",fields:[{name:"devSessionChanged",type:{kind:"OBJECT",name:"DevSessionEvent",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"devSessionSynced",type:{kind:"OBJECT",name:"DevSessionSyncedEvent",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"devWorkflowDeleteRequested",type:{kind:"OBJECT",name:"DevWorkflowDeleteRequestedEvent",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"devWorkflowDuplicateRequested",type:{kind:"OBJECT",name:"DevWorkflowDuplicateRequestedEvent",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"healthChecksChanged",type:{kind:"OBJECT",name:"HealthChecksChangedEvent",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"hooksPausedRequested",type:{kind:"OBJECT",name:"HooksPausedRequestedEvent",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"projectRunStatusChanged",type:{kind:"OBJECT",name:"ProjectRunStatusEvent",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"runProgress",type:{kind:"UNION",name:"RunProgressEvent",ofType:null},args:[{name:"runId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"runRequested",type:{kind:"OBJECT",name:"RunRequestedEvent",ofType:null},args:[]},{name:"scopeChanged",type:{kind:"OBJECT",name:"ScopeChangedEvent",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]}],interfaces:[]},{kind:"OBJECT",name:"TraceAssertion",fields:[{name:"description",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"detail",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"status",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"TraceEntry",fields:[{name:"annotations",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"ScreenAnnotation",ofType:null}}}},args:[]},{name:"assertions",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"TraceAssertion",ofType:null}}}},args:[]},{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"detail",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"duration",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"nodeType",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"pageUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"recordingEndMs",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"recordingStartMs",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"screenshotUrl",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"status",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"statusCode",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"stepIndex",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"timestamp",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"title",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"viewportHeight",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"viewportWidth",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"TrackedBranch",fields:[{name:"branchName",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"headCommit",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"preconditions",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Precondition",ofType:null}}},args:[]},{name:"snapshots",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"BranchSnapshot",ofType:null}}},args:[]},{name:"syncedAt",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"workflows",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Workflow",ofType:null}}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"User",fields:[{name:"email",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"image",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"username",type:{kind:"SCALAR",name:"Any"},args:[]}],interfaces:[]},{kind:"OBJECT",name:"Workflow",fields:[{name:"additionalChecks",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}},args:[]},{name:"agentProfiles",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"AgentProfile",ofType:null}}}},args:[]},{name:"codebaseScope",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"devSessionId",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"expectedOutcome",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"isLocalOnly",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"latestRuns",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Run",ofType:null}}}},args:[]},{name:"name",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"preconditions",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}},args:[]},{name:"project",type:{kind:"OBJECT",name:"Project",ofType:null},args:[]},{name:"requiresKeys",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"WorkflowRequiresKey",ofType:null}}},args:[]},{name:"runs",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Run",ofType:null}}}},args:[]},{name:"slug",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"source",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"spec",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"WorkflowRequiresKey",fields:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"namespace",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"preconditionName",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"SCALAR",name:"Any"}],directives:[]}}});function D(e,t){e.inspectFields("Query").filter(n=>n.fieldName===t).forEach(n=>{e.invalidate("Query",n.fieldName,n.arguments)})}function ae(e,t,n){e.invalidate({__typename:t,id:n})}function TS({argMatches:e,cache:t,childKey:n,fieldName:r}){t.inspectFields("Query").filter(o=>o.fieldName===r&&e(o.arguments??null)).forEach(o=>{let i=t.resolve("Query",o.fieldName,o.arguments);if(!Array.isArray(i))return;let a=i.map(l=>typeof l=="string"?l:null);a.includes(n)||t.link("Query",o.fieldName,o.arguments,[n,...a])})}function Nn({cache:e,childId:t,childTypeName:n,fieldName:r,parentId:o,parentTypeName:i}){let a=e.keyOfEntity({__typename:i,id:o});if(a==null)return!1;let l=e.keyOfEntity({__typename:n,id:t});if(l==null)return!1;let s=e.resolve(a,r);if(!Array.isArray(s))return!1;let d=s.map(c=>typeof c=="string"?c:null);return d.includes(l)||e.link(a,r,void 0,[...d,l]),!0}function NS(e,t){let n=t.traceEntry?.id,r=t.runResultId;if(n==null||r==null)return;Nn({cache:e,childId:n,childTypeName:"TraceEntry",fieldName:"traceEntries",parentId:r,parentTypeName:"RunResult"})||ae(e,"RunResult",r)}function vS(e,t){let n=t.chunk?.id,r=t.runResultId;if(n==null||r==null)return;Nn({cache:e,childId:n,childTypeName:"RunRecordingChunk",fieldName:"recordingChunks",parentId:r,parentTypeName:"RunResult"})||ae(e,"RunResult",r)}function Lo(e){return e==="completed"||e==="failed"}function CS(e,t){if(t.runId==null)return;let n=Lo(t.status),r=t.completedAt??(n?new Date().toISOString():null);e.writeFragment(sd,{agentProfile:t.agentProfileId==null?null:{id:t.agentProfileId},completedAt:r,createdAt:t.createdAt??new Date().toISOString(),id:t.runId,status:t.status??"pending"})}function ld(e,t){e.invalidate({__typename:"Run",id:t},"results")}function LS(e,t){e.workflowId==null||e.runId==null||Nn({cache:t,childId:e.runId,childTypeName:"Run",fieldName:"latestRuns",parentId:e.workflowId,parentTypeName:"Workflow"})}function xS(e,t){let n=e.runId!=null&&t.resolve({__typename:"Run",id:e.runId},"id")==null;CS(t,e),Lo(e.status)&&e.runId!=null&&ld(t,e.runId),n&&(D(t,"run"),PS(t,e)),LS(e,t)}function PS(e,t){if(t.runId==null)return;let n=e.keyOfEntity({__typename:"Run",id:t.runId});if(n==null){D(e,"projectRuns");return}TS({cache:e,childKey:n,fieldName:"projectRuns",argMatches:r=>{if(r?.cursor!=null)return!1;let i=r?.projectId;return!(typeof i=="string"&&i!==t.workflowId)}}),D(e,"projectRuns")}function ES(e,t,n){let r=e.keyOfEntity({__typename:"Project",id:t});if(r==null)return;let o=e.resolve(r,"devSession");if(typeof o!="string")return;let i=e.resolve(o,"scopeItems");if(!Array.isArray(i))return;let a=i.flatMap(s=>typeof s=="string"?[s]:[]),l=e.keyOfEntity({__typename:"ScopeItem",id:n});l==null||a.includes(l)||e.link(o,"scopeItems",void 0,[...a,{__typename:"ScopeItem",id:n}])}function IS(e,t){e.inspectFields("Query").filter(n=>n.fieldName==="project").forEach(n=>{let r=e.resolve("Query",n.fieldName,n.arguments);if(typeof r!="string")return;let o=e.resolve(r,"devSession");typeof o=="string"&&e.writeFragment(OS,{hooksPaused:t,id:o.replace(/^DevSession:/,"")})})}function _S(){return{addScopeItem(e,t,n){let r=e.addScopeItem?.id;r!=null&&ES(n,t.projectId,r)},cancelAllPendingRuns(e,t,n){D(n,"workflows"),D(n,"projectRuns")},cancelRun(e,t,n){let r=e.cancelRun?.id;r!=null&&ae(n,"Run",r)},cloneAgentTemplate(e,t,n){D(n,"agentProfiles")},createAgentProfile(e,t,n){D(n,"agentProfiles")},createRun(e,t,n){D(n,"run"),D(n,"runs"),D(n,"projectRuns");let r=e.createRun?.id;r!=null&&(n.writeFragment(sd,{agentProfile:t.agentProfileId==null?null:{id:t.agentProfileId},completedAt:null,createdAt:new Date().toISOString(),id:r,status:"pending"}),Nn({cache:n,childId:r,childTypeName:"Run",fieldName:"latestRuns",parentId:t.workflowId,parentTypeName:"Workflow"}))},deleteAgentProfile(e,t,n){let r=e.deleteAgentProfile?.id;r!=null&&ae(n,"AgentProfile",r)},deleteDevWorkflow(e,t,n){let r=e.deleteDevWorkflow?.id;r!=null&&ae(n,"Workflow",r),D(n,"workflows")},deleteProject(e,t,n){let r=e.deleteProject?.id;r!=null&&ae(n,"Project",r),D(n,"projects")},duplicateDevWorkflow(e,t,n){D(n,"workflows")},endDevSession(e,t,n){let r=e.endDevSession?.id;r!=null&&ae(n,"DevSession",r)},linkScopeItem(e,t,n){let r=e.linkScopeItem?.id;r!=null&&ae(n,"ScopeItem",r)},removeScopeItem(e,t,n){ae(n,"ScopeItem",t.id)},runAllWorkflows(e,t,n){D(n,"runs"),D(n,"projectRuns")},setHooksPaused(e,t,n){IS(n,t.paused)},setOverageCap(e,t,n){D(n,"organizationUsage")},updateProject(e,t,n){let r=e.updateProject?.id;r!=null&&ae(n,"Project",r)},updateUsername(e,t,n){let r=e.updateUsername?.id;r!=null&&ae(n,"User",r),D(n,"currentUser")}}}function xo(){return{keys:RS,optimistic:{addScopeItem:e=>({__typename:"ScopeItem",createdAt:new Date().toISOString(),id:`optimistic_${String(Date.now())}`,label:e.label??null,source:e.source,workflow:null}),removeScopeItem:()=>!0},schema:vo,updates:{Mutation:_S(),Subscription:{devSessionChanged(e,t,n){let r=e.devSessionChanged;r?.projectId!=null&&ae(n,"Project",r.projectId),r?.active===!1&&(D(n,"workflows"),D(n,"workflow"),D(n,"runs"),D(n,"run"),D(n,"projectRuns"))},devSessionSynced(e,t,n){D(n,"workflow"),D(n,"workflows");let r=e.devSessionSynced?.devSession?.id;r!=null&&n.invalidate({__typename:"DevSession",id:r},"workflowDiff")},projectRunStatusChanged(e,t,n){let r=e.projectRunStatusChanged;r!=null&&xS(r,n)},runProgress(e,t,n){let r=e.runProgress;r?.__typename==="RunTraceEntryAdded"&&NS(n,r),r?.__typename==="RunRecordingChunkAdded"&&vS(n,r),r?.__typename==="RunResultUpdated"&&r.runResult?.id!=null&&ae(n,"RunResult",r.runResult.id),r?.__typename==="RunStatusChanged"&&r.run?.id!=null&&Lo(r.run.status)&&ld(n,r.run.id)}}}}}var RS,sd,OS,dd=p(()=>{"use strict";ad();Co();RS={AgentProfile:e=>e.id??null,AgentTemplate:e=>e.id??null,BankPaymentMethod:()=>null,BillingSubscription:e=>e.id??null,BranchSnapshot:e=>e.id??null,CardPaymentMethod:()=>null,CliToken:e=>e.id??null,DevSession:e=>e.id??null,DevSessionEvent:()=>null,DevSessionSyncedEvent:()=>null,DevSessionWorkflowDiff:()=>null,DevWorkflowDeleteRequestedEvent:()=>null,DevWorkflowDuplicateRequestedEvent:()=>null,GitHubInstallation:e=>e.id??null,GithubRepository:()=>null,HealthCheck:e=>e.id??null,HealthChecksChangedEvent:()=>null,HooksPausedRequestedEvent:()=>null,Invoice:e=>e.id??null,LinkPaymentMethod:()=>null,Organization:e=>e.id??null,OrganizationLimitStatus:()=>null,OrganizationUsage:()=>null,OtherPaymentMethod:()=>null,Plan:()=>null,PlanLimits:()=>null,Precondition:e=>e.id??null,Project:e=>e.id??null,ProjectRunStatusEvent:()=>null,Run:e=>e.id??null,RunRecordingChunk:e=>e.id??null,RunRecordingChunkAdded:()=>null,RunRequestedEvent:()=>null,RunResult:e=>e.id??null,RunResultUpdated:()=>null,RunStatusChanged:()=>null,RunTraceEntryAdded:()=>null,ScopeChangedEvent:()=>null,ScopeItem:e=>e.id??null,ScreenAnnotation:e=>e.id??null,SideEffect:e=>e.id??null,TraceAssertion:e=>e.id??null,TraceEntry:e=>e.id??null,TrackedBranch:e=>e.id??null,User:e=>e.id??null,Workflow:e=>e.id??null,WorkflowRequiresKey:e=>e.id??null};sd=No(`
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
status
|
|
196
|
-
createdAt
|
|
197
|
-
completedAt
|
|
198
|
-
agentProfile {
|
|
245
|
+
syncDevSession(
|
|
246
|
+
projectId: $projectId
|
|
247
|
+
cwd: $cwd
|
|
248
|
+
branch: $branch
|
|
249
|
+
preconditions: $preconditions
|
|
250
|
+
workflows: $workflows
|
|
251
|
+
) {
|
|
199
252
|
id
|
|
200
253
|
}
|
|
201
254
|
}
|
|
202
|
-
`);
|
|
203
|
-
fragment
|
|
255
|
+
`);async function ot(e){let t=tg(e.compiled);return ng({config:e.config,cwd:e.cwd,payload:t})}async function Ce(e,t){let r=await I(e);if(!r.ok)throw new Error(`DSL compilation failed: ${r.error}`);let n=await ot({compiled:r.result,config:t,cwd:e});return{compiled:r.result,devSessionId:n.devSessionId}}function tg(e){return{preconditions:Object.entries(e.preconditions).map(([t,r])=>({depends:[...r.depends??[]],description:r.description,name:t,returns:[...r.returns??[]]})),workflows:e.tests.map(t=>({expectedOutcome:t.expectedOutcome,name:t.name,preconditions:[...t.preconditions],requiresKeys:Object.entries(t.requiresKeys).map(([r,n])=>({namespace:r,preconditionName:n})),slug:t.slug,spec:t.implemented?JSON.stringify(t.spec):null}))}}function rg(e){return Qf.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function ng({config:e,cwd:t,payload:r}){let n=rg(r),o=Ft(t),i=await k({config:e,document:eg,variables:{branch:o??null,cwd:t,preconditions:r.preconditions.map(s=>({depends:[...s.depends],description:s.description,name:s.name,returns:[...s.returns]})),projectId:e.projectId,workflows:r.workflows.map(s=>({expectedOutcome:s.expectedOutcome,name:s.name,preconditions:[...s.preconditions],requiresKeys:s.requiresKeys.map(a=>({namespace:a.namespace,preconditionName:a.preconditionName})),slug:s.slug,spec:s.spec??null}))}});if(i.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:i.syncDevSession.id,hash:n}}import is from"figures";var it={cross:is.cross,tick:is.tick};var as=Mt(`
|
|
256
|
+
fragment WorkflowIdMCP on Workflow {
|
|
204
257
|
id
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
`)});var cd=p(()=>{"use strict";dd();Co()});import{Client as jS,fetchExchange as US,subscriptionExchange as $S}from"urql";import{cacheExchange as DS}from"@urql/exchange-graphcache";import{createClient as BS}from"graphql-sse";function pd({config:e}){let t=`${e.ripploServerUrl}/graphql`,n={Authorization:`Bearer ${e.token}`},r=BS({headers:n,retryAttempts:1/0,url:t});return new jS({exchanges:[DS(xo()),$S({forwardSubscription:o=>({subscribe:i=>o.query==null?{unsubscribe:()=>{}}:{unsubscribe:r.subscribe({query:o.query,variables:o.variables},i)}})}),US],fetchOptions:{headers:n},requestPolicy:"cache-and-network",url:t})}var ud=p(()=>{"use strict";cd()});import{Box as md,Text as B,useInput as VS}from"ink";import{jsx as Q,jsxs as Ee}from"react/jsx-runtime";function fd({deviceCodeInfo:e,error:t,loginStarted:n,startLogin:r}){return VS((o,i)=>{i.return&&!n&&r()}),t!=null?Ee(md,{flexDirection:"column",gap:1,children:[Ee(B,{children:[Q(B,{color:"red",children:" \u2717 "}),Q(B,{children:t})]}),Ee(B,{children:[Q(B,{color:"cyan",children:" \u2192 "}),Q(B,{children:"Press "}),Q(B,{bold:!0,children:"Enter"}),Q(B,{children:" to try again"})]})]}):e!=null?Ee(md,{flexDirection:"column",gap:1,paddingLeft:2,children:[Ee(B,{children:[Q(B,{color:"yellow",children:"* "}),Q(B,{children:"Your code: "}),Q(B,{bold:!0,color:"white",children:e.userCode})]}),Ee(B,{children:[Q(B,{color:"yellow",children:"* "}),Q(B,{children:"Waiting for browser authorization..."})]}),Ee(B,{dimColor:!0,children:[" ",e.verificationUrl]})]}):n?Ee(B,{children:[Q(B,{color:"yellow",children:" * "}),Q(B,{children:"Opening browser..."})]}):Ee(B,{children:[Q(B,{color:"cyan",children:" \u2192 "}),Q(B,{children:"Press "}),Q(B,{bold:!0,children:"Enter"}),Q(B,{children:" to open browser for authentication"})]})}var yd=p(()=>{"use strict"});import{useState as WS}from"react";import{Box as FS,Text as vn,useInput as MS}from"ink";import{jsx as Cn,jsxs as HS}from"react/jsx-runtime";function gd({items:e,onSelect:t}){let[n,r]=WS(0);return MS((o,i)=>{if(i.upArrow&&r(a=>Math.max(0,a-1)),i.downArrow&&r(a=>Math.min(e.length-1,a+1)),i.return){let a=e[n];a!=null&&t(a.value)}}),Cn(FS,{flexDirection:"column",children:e.map((o,i)=>HS(vn,{children:[i===n?Cn(vn,{color:"cyan",children:"> "}):Cn(vn,{children:" "}),Cn(vn,{bold:i===n,children:o.label})]},o.value))})}var hd=p(()=>{"use strict"});import{Box as qS,Text as qe,useInput as JS}from"ink";import{jsx as mt,jsxs as Po}from"react/jsx-runtime";function kd({reexecute:e,serverUrl:t}){let n=`${t}/connect`;return JS((r,o)=>{o.return&&e()}),Po(qS,{flexDirection:"column",children:[Po(qe,{children:[mt(qe,{color:"cyan",children:" \u2192 "}),mt(qe,{children:"No projects found. Create one at: "}),mt(qe,{bold:!0,color:"cyan",children:n})]}),Po(qe,{children:[" ",mt(qe,{dimColor:!0,children:"Press "}),mt(qe,{bold:!0,children:"Enter"}),mt(qe,{dimColor:!0,children:" to refresh after creating a project"})]})]})}var Sd=p(()=>{"use strict"});import{useEffect as zS,useMemo as XS,useRef as GS}from"react";import{Box as bd,Text as Ze}from"ink";import{useQuery as KS}from"urql";import{graphql as QS}from"gql.tada";import{jsx as et,jsxs as Ln}from"react/jsx-runtime";function wd({selectProject:e,serverUrl:t}){let[n,r]=KS({query:YS}),o=GS(!1),i=XS(()=>n.data?.projects??[],[n.data?.projects]);if(zS(()=>{let s=i[0];i.length===1&&s!=null&&(s.workflows?.length??0)===0&&!o.current&&(o.current=!0,e({id:s.id,name:s.name}))},[i,e]),n.fetching)return Ln(Ze,{children:[et(Ze,{color:"yellow",children:" * "}),et(Ze,{children:"Loading projects..."})]});if(n.error!=null)return Ln(Ze,{color:"red",children:[" \u2717 ","Failed to fetch projects: ",n.error.message]});if(i.length===0)return et(kd,{reexecute:r,serverUrl:t});let a=i.map(s=>({label:s.name,value:s.id}));function l(s){let d=i.find(c=>c.id===s);d!=null&&e({id:d.id,name:d.name})}return Ln(bd,{flexDirection:"column",children:[Ln(Ze,{children:[et(Ze,{color:"cyan",children:" \u2192 "}),et(Ze,{children:"Select a project:"})]}),et(bd,{marginLeft:4,marginTop:1,children:et(gd,{items:a,onSelect:l})})]})}var YS,Ad=p(()=>{"use strict";hd();Sd();YS=QS(`
|
|
208
|
-
query SetupProjectSelect {
|
|
209
|
-
projects {
|
|
210
|
-
id
|
|
211
|
-
name
|
|
212
|
-
workflows {
|
|
213
|
-
id
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
`)});import{Box as Ot,Text as ue,useInput as ZS}from"ink";import eb from"ink-spinner";import{jsx as Oe,jsxs as Se}from"react/jsx-runtime";function Rd({config:e,error:t,onDismissWarnings:n,scaffoldingStep:r,scaffoldWarnings:o,selectProject:i,stage:a}){return ZS((l,s)=>{a==="scaffolding-warnings"&&s.return&&n()}),Se(Ot,{flexDirection:"column",padding:1,children:[Se(ue,{bold:!0,children:[" ","ripplo setup"]}),Oe(ue,{children:""}),Se(ue,{children:[Oe(ue,{color:"green",children:" \u2713 "}),Oe(ue,{children:"Authenticated"})]}),tb({config:e,scaffoldingStep:r,scaffoldWarnings:o,selectProject:i,stage:a}),t==null?null:Oe(Ot,{marginTop:1,children:Se(ue,{color:"red",children:[" ","Error: ",t]})})]})}function tb({config:e,scaffoldingStep:t,scaffoldWarnings:n,selectProject:r,stage:o}){return o==="scaffolding"?Se(ue,{children:[Se(ue,{color:"cyan",children:[" ",Oe(eb,{type:"dots"})]}),Se(ue,{children:[" ",t??"Setting up local environment..."]})]}):o==="scaffolding-warnings"?Se(Ot,{flexDirection:"column",marginTop:1,children:[Oe(ue,{color:"yellow",children:" \u26A0 Setup finished with warnings:"}),n.map((i,a)=>Se(Ot,{flexDirection:"column",marginTop:1,children:[Se(ue,{children:[" ",i.message]}),i.manualCommand==null?null:Se(ue,{color:"cyan",children:[" $ ",i.manualCommand]})]},a)),Oe(Ot,{marginTop:1,children:Oe(ue,{dimColor:!0,children:" Press enter to continue to the dashboard."})})]}):Oe(wd,{selectProject:r,serverUrl:e.ripploServerUrl})}var Td=p(()=>{"use strict";Ad()});import{useEffect as nb,useState as rb}from"react";function ft(){let[e,t]=rb(Nd);return nb(()=>{function n(){t(Nd())}return process.stdout.on("resize",n),()=>{process.stdout.off("resize",n)}},[]),e}function Nd(){return{height:process.stdout.rows,width:process.stdout.columns}}var xn=p(()=>{"use strict"});import{useEffect as ob,useRef as ib,useState as ab}from"react";function vd({config:e,cwd:t}){let[n,r]=ab({config:e,devSessionId:void 0,syncError:void 0,syncing:!0}),o=ib(void 0);return ob(()=>{function i({config:l,devSessionId:s}){r(d=>({...d,config:l,devSessionId:s,syncError:void 0,syncing:!1}))}function a(l){r(s=>({...s,syncError:l,syncing:!1}))}return ql({config:e,cwd:t}).then(({config:l,devSessionId:s,hash:d})=>{i({config:l,devSessionId:s}),o.current=wo({config:l,cwd:t,devSessionId:s,lastHash:d,onSyncError:a,onSyncSuccess:i})}).catch(l=>{let s=l instanceof Error?l.message:String(l);a(s),o.current=wo({config:e,cwd:t,devSessionId:"",lastHash:"",onSyncError:a,onSyncSuccess:i})}),()=>{o.current?.()}},[e,t]),n}var Cd=p(()=>{"use strict";An()});function Pn(e){return{...sb(e),type:e.type}}function sb(e){switch(e.type){case"settings":return lb(e);case"token":return db(e.exists);case"dev-server":return cb(e);case"preconditions":return gb(e);case"engine-endpoint":return pb(e);case"adapter-enabled":return kb(e.status);case"webhook-verification":return ub(e.rejectsUnsigned);case"preconditions-validation":return mb(e);case"workflows":return Sb(e);case"browser":return fb(e.installed);case"lockfile":return wb(e.status);case"pre-commit-hook":return yb(e.installed)}}function lb(e){return e.valid?{detail:"configured",label:"Settings",tone:"ok"}:{detail:`missing ${e.missingFields.join(", ")}`,label:"Settings",tone:"error"}}function db(e){return e?{detail:"signed in",label:"Auth",tone:"ok"}:{detail:"not signed in",label:"Auth",tone:"error"}}function cb(e){return e.reachable?{detail:e.appUrl,label:"Dev server",tone:"ok"}:{detail:`${e.appUrl} unreachable`,label:"Dev server",tone:"error"}}function pb(e){return e.reachable?{detail:e.url,label:"Endpoint",tone:"ok"}:{detail:`${e.url} unreachable`,label:"Endpoint",tone:"error"}}function ub(e){return e?{detail:"rejects unsigned",label:"Webhook auth",tone:"ok"}:{detail:"accepts unsigned!",label:"Webhook auth",tone:"error"}}function mb(e){if(e.valid)return{detail:"valid",label:"State graph",tone:"ok"};let t=e.errorCount===1?"":"s";return{detail:`${String(e.errorCount)} error${t}`,label:"State graph",tone:"error"}}function fb(e){return e?{detail:"chromium installed",label:"Browser",tone:"ok"}:{detail:"chromium missing",label:"Browser",tone:"error"}}function yb(e){return e?{detail:"installed",label:"Pre-commit",tone:"ok"}:{detail:"not installed",label:"Pre-commit",tone:"warn"}}function gb(e){return e.count===0?{detail:"none defined",label:"Preconditions",tone:"info"}:e.configured?e.endpointReachable===!1?{detail:`${String(e.count)} defined, endpoint unreachable`,label:"Preconditions",tone:"error"}:{detail:`${String(e.count)} defined`,label:"Preconditions",tone:"ok"}:{detail:`${String(e.count)} defined, url unset`,label:"Preconditions",tone:"error"}}function kb(e){let t=hb[e];return t??{detail:"unreachable",label:"Adapter",tone:"error"}}function Sb(e){return e.total===0?{detail:"none defined",label:"Tests",tone:"info"}:e.invalidNames.length>0?{detail:`${String(e.invalidNames.length)} invalid of ${String(e.total)}`,label:"Tests",tone:"error"}:{detail:`${String(e.total)} valid`,label:"Tests",tone:"ok"}}function wb(e){let t=bb[e];return t??{detail:"stale (run ripplo compile)",label:"Lockfile",tone:"warn"}}var hb,bb,Ld,xd,Eo=p(()=>{"use strict";hb={"bad-secret":{detail:"webhook secret mismatch",label:"Adapter",tone:"error"},disabled:{detail:"disabled (set ENABLE_RIPPLO_TESTING)",label:"Adapter",tone:"error"},enabled:{detail:"enabled",label:"Adapter",tone:"ok"},"no-secret":{detail:"no webhook secret",label:"Adapter",tone:"error"},unreachable:{detail:"unreachable",label:"Adapter",tone:"error"}};bb={match:{detail:"up to date",label:"Lockfile",tone:"ok"},missing:{detail:"missing (run ripplo compile)",label:"Lockfile",tone:"error"},stale:{detail:"stale (run ripplo compile)",label:"Lockfile",tone:"warn"}};Ld={"adapter-enabled":"ADAPTER_ENABLED",browser:"BROWSER","dev-server":"DEV_SERVER","engine-endpoint":"ENGINE_ENDPOINT",lockfile:"LOCKFILE","pre-commit-hook":"PRE_COMMIT_HOOK",preconditions:"PRECONDITIONS","preconditions-validation":"PRECONDITIONS_VALIDATION",settings:"SETTINGS",token:"TOKEN","webhook-verification":"WEBHOOK_VERIFICATION",workflows:"WORKFLOWS"},xd={error:"ERROR",info:"INFO",ok:"OK",warn:"WARN"}});import{useEffect as Ab,useState as Rb}from"react";import Tb from"path";import{watch as Nb}from"chokidar";import{graphql as vb}from"gql.tada";async function Oo(){let e=[...En];En.clear(),await Promise.allSettled(e.map(t=>t.close()))}function Pd({config:e,cwd:t}){let[n,r]=Rb({checks:[],lastRunAt:void 0,running:!1});return Ab(()=>{let o={cancelled:!1,inFlight:!1,lastPushedKey:void 0},i;async function a(){if(!(o.cancelled||o.inFlight)){o.inFlight=!0;try{let d=await hn(t);r({checks:d,lastRunAt:Date.now(),running:!1}),o.lastPushedKey=await xb({checks:d,config:e,lastPushedKey:o.lastPushedKey})}catch(d){g.error(d,"health check tick failed")}finally{o.inFlight=!1}}}function l(){o.cancelled||(i=setTimeout(()=>{a().finally(l)},Cb))}a().finally(l);let s=Nb(Tb.join(t,".ripplo","ripplo.lock"),{ignoreInitial:!0,persistent:!0});return En.add(s),s.on("all",()=>{a()}),()=>{o.cancelled=!0,i!=null&&clearTimeout(i),En.delete(s),s.close()}},[e,t]),n}async function xb({checks:e,config:t,lastPushedKey:n}){if(t.projectId.length===0)return n;let r=e.map(i=>{let a=Pn(i);return{detail:a.detail,tone:xd[a.tone],type:Ld[a.type]}}),o=JSON.stringify(r);if(o===n)return n;try{return await x({config:t,document:Lb,variables:{checks:r,projectId:t.projectId}}),o}catch(i){return g.error(i,"Failed to push health checks"),n}}var Cb,En,Lb,Io=p(()=>{"use strict";M();go();Eo();Cb=5e3,En=new Set;Lb=vb(`
|
|
218
|
-
mutation PushHealthChecks($projectId: String!, $checks: [HealthCheckInput!]!) {
|
|
219
|
-
pushHealthChecks(projectId: $projectId, checks: $checks)
|
|
220
|
-
}
|
|
221
|
-
`)});import _o from"fs";import{useEffect as Pb}from"react";import{useQuery as Eb,useSubscription as Ob}from"urql";import{graphql as Od}from"gql.tada";function Id({cwd:e,projectId:t}){let[{data:n}]=Eb({query:Ib,variables:{projectId:t}});Pb(()=>{let r=n?.project?.devSession?.hooksPaused;r!=null&&Ed({cwd:e,paused:r})},[e,n]),Ob({query:_b,variables:{projectId:t}},(r,o)=>{let i=o.hooksPausedRequested;return i!=null&&Ed({cwd:e,paused:i.paused}),o})}function Ed({cwd:e,paused:t}){let n=Re(e,"hooks-paused");if(t){Ye(e),_o.writeFileSync(n,"");return}_o.existsSync(n)&&_o.unlinkSync(n)}var Ib,_b,_d=p(()=>{"use strict";M();Ib=Od(`
|
|
222
|
-
query HooksPausedState($projectId: String!) {
|
|
223
|
-
project(id: $projectId) {
|
|
224
|
-
id
|
|
225
|
-
devSession {
|
|
226
|
-
id
|
|
227
|
-
hooksPaused
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
`),_b=Od(`
|
|
232
|
-
subscription HooksPausedRequested($projectId: String!) {
|
|
233
|
-
hooksPausedRequested(projectId: $projectId) {
|
|
234
|
-
paused
|
|
235
|
-
projectId
|
|
236
|
-
}
|
|
258
|
+
slug
|
|
237
259
|
}
|
|
238
|
-
`)
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
id
|
|
242
|
-
name
|
|
243
|
-
devSession {
|
|
260
|
+
`),ig=Mt(`
|
|
261
|
+
query ProjectWorkflowIdsMCP($projectId: String!, $cwd: String!) {
|
|
262
|
+
project(id: $projectId) {
|
|
244
263
|
id
|
|
245
|
-
|
|
246
|
-
scopeItems {
|
|
264
|
+
devSession(cwd: $cwd) {
|
|
247
265
|
id
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
slug
|
|
252
|
-
name
|
|
253
|
-
}
|
|
266
|
+
}
|
|
267
|
+
workflows {
|
|
268
|
+
...WorkflowIdMCP
|
|
254
269
|
}
|
|
255
270
|
}
|
|
256
271
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
projectId
|
|
272
|
+
`,[as]),sg=Mt(`
|
|
273
|
+
mutation CreateRunMCP($workflowId: String!, $platforms: [String!]!, $concurrency: Int!) {
|
|
274
|
+
createRun(workflowId: $workflowId, platforms: $platforms, concurrency: $concurrency) {
|
|
275
|
+
id
|
|
276
|
+
status
|
|
263
277
|
}
|
|
264
278
|
}
|
|
265
|
-
`),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
279
|
+
`),ag=Mt(`
|
|
280
|
+
query RunStatusMCP($id: String!) {
|
|
281
|
+
run(id: $id) {
|
|
282
|
+
id
|
|
283
|
+
status
|
|
284
|
+
results {
|
|
270
285
|
id
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
286
|
+
status
|
|
287
|
+
duration
|
|
288
|
+
passCount
|
|
289
|
+
failCount
|
|
290
|
+
warnCount
|
|
291
|
+
summary
|
|
292
|
+
traceEntries {
|
|
293
|
+
title
|
|
294
|
+
status
|
|
295
|
+
detail
|
|
296
|
+
duration
|
|
297
|
+
assertions {
|
|
298
|
+
description
|
|
299
|
+
status
|
|
300
|
+
detail
|
|
278
301
|
}
|
|
279
302
|
}
|
|
280
303
|
}
|
|
281
304
|
}
|
|
282
305
|
}
|
|
283
|
-
`)
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
`),
|
|
295
|
-
|
|
296
|
-
|
|
306
|
+
`);async function Wt({config:e,ids:t}){let r=await lg({config:e,ids:t}),n=await Promise.all(r.map(async s=>{try{let a=await mg({config:e,workflowId:s.workflowId});return{entry:s,ok:!0,runId:a}}catch(a){let l=a instanceof Error?a.message:String(a);return{entry:s,message:l,ok:!1}}})),o=await Promise.all(n.map(async s=>{if(!s.ok)return{id:s.entry.id,runId:"",summary:`ERROR creating run: ${s.message}
|
|
307
|
+
${E("setup","check auth + config")}`};let{entry:a,runId:l}=s;try{let c=await gg({config:e,runId:l}),d=pg({config:e,id:a.id,runId:l}),u=`.ripplo/debug/${l}/`;return{id:a.id,runId:l,summary:`View run: ${d}
|
|
308
|
+
Debug artifacts: ${u}
|
|
309
|
+
${E("debug","read summary.txt, accessibility-tree, network.jsonl before guessing")}
|
|
310
|
+
|
|
311
|
+
${c}`}}catch(c){let d=c instanceof Error?c.message:String(c);return{id:a.id,runId:l,summary:`ERROR polling run ${l}: ${d}
|
|
312
|
+
${E("debug")}`}}})),i=o.map(s=>`**${s.id}:**
|
|
313
|
+
${s.summary}`).join(`
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
`);return{results:o,summary:i}}async function lg({config:e,ids:t}){let r=await Ce(e.cwd,e),n=await k({config:e,document:ig,variables:{cwd:e.cwd,projectId:e.projectId}});if(n.project==null)throw new Error("Project not found");if(n.project.devSession==null)throw new Error("No active dev session. Start one by running `ripplo` (or `npx ripplo`) in your terminal, then try again.");let o=(n.project.workflows??[]).map(s=>og(as,s));if(t.length===0)return o.map(s=>({id:s.slug,workflowId:s.id}));let i=r.compiled.tests.map(s=>s.slug);return t.map(s=>{let a=o.find(l=>l.slug===s);if(a==null)throw new Error(cg({compiledSlugs:i,slug:s}));return{id:s,workflowId:a.id}})}function cg({compiledSlugs:e,slug:t}){if(e.includes(t))return`Test "${t}" was synced from .ripplo/ but the server didn't return it. This is likely a server-state bug \u2014 check the server logs for the SyncDevSession mutation.`;let r=dg({compiledSlugs:e,limit:3,slug:t}),n=r.length>0?`
|
|
318
|
+
Did you mean: ${r.join(", ")}?`:"";return`Test "${t}" is not registered in this dev session.${n}
|
|
319
|
+
Tests must be exported from .ripplo/tests/index.ts. (ripplo run already syncs on demand \u2014 restarting the dev server will not help.)`}function dg({compiledSlugs:e,limit:t,slug:r}){let n=new Set(r.split("-"));return e.map(i=>({candidate:i,score:ug(n,i)})).filter(i=>i.score>0).toSorted((i,s)=>s.score-i.score).slice(0,t).map(i=>i.candidate)}function ug(e,t){return t.split("-").filter(r=>e.has(r)).length}function pg({config:e,id:t,runId:r}){let n=e.ripploServerUrl.replace(/:3000\b/,":3001"),o=new URL(n.endsWith("/")?n:`${n}/`);return new URL(`projects/${e.projectId}/workflows/${t}/runs/${r}`,o).toString()}async function mg({config:e,workflowId:t}){let r=await k({config:e,document:sg,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});if(r.createRun==null)throw new Error("Failed to create run");return r.createRun.id}var fg=2e3,ss=150;async function gg({config:e,runId:t}){let r=0;for(;r<ss;){await hg(fg),r+=1;let o=(await k({config:e,document:ag,variables:{id:t}})).run;if(o==null)throw new Error(`Run ${t} not found`);if(!(o.status==="pending"||o.status==="running"))return yg({results:o.results??[],runId:t,status:o.status})}return`Run ${t} timed out after polling ${String(ss)} times.`}function yg({results:e,runId:t,status:r}){let n=[`Run ${t}: ${r.toUpperCase()}`];return e.forEach(o=>{n.push(` ${o.status}: ${String(o.passCount)} passed, ${String(o.failCount)} failed (${String(o.duration??0)}ms)`),o.summary!=null&&n.push(` Summary: ${o.summary}`),o.traceEntries.forEach(i=>{let s=i.status==="passed"?it.tick:it.cross,a=i.detail==null?"":` \u2014 ${i.detail}`;n.push(` ${s} ${i.title} (${String(i.duration)}ms)${a}`),i.assertions.forEach(l=>{let c=l.status==="passed"?it.tick:it.cross,d=l.detail==null?"":` \u2014 ${l.detail}`;n.push(` ${c} ${l.description}${d}`)})})}),n.join(`
|
|
320
|
+
`)}function hg(e){return new Promise(t=>{setTimeout(t,e)})}import{graphql as wg}from"gql.tada";import ls from"fs";import pn from"path";function cs(e){let t=ls.realpathSync(e),r=t,n=pn.dirname(r);for(;n!==r;){if(ls.existsSync(pn.join(r,".git")))return r;r=n,n=pn.dirname(r)}return t}function X(e){let t=Qt(e),r=Ae(),n=le();if(n==null)throw new Error("ripplo: not authenticated. Run `ripplo auth login`.");return{appUrl:r.appUrl,cwd:cs(e),engineUrl:r.engineUrl,projectId:t.projectId,ripploServerUrl:Ee(),token:n,webhookSecret:r.webhookSecret}}var bg=wg(`
|
|
321
|
+
query DevSessionCheckPreflight($projectId: String!, $cwd: String!) {
|
|
322
|
+
project(id: $projectId) {
|
|
297
323
|
id
|
|
298
|
-
|
|
324
|
+
devSession(cwd: $cwd) {
|
|
299
325
|
id
|
|
300
326
|
}
|
|
301
|
-
agentProfile {
|
|
302
|
-
id
|
|
303
|
-
description
|
|
304
|
-
}
|
|
305
327
|
}
|
|
306
328
|
}
|
|
307
|
-
`)
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
`),
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
`),Fd=Math.min(10,Mb()/2),$o=Hb(Fd),On=new Set;Gb=5e3});import{Box as Zb,Text as Vo}from"ink";import{jsx as qd,jsxs as Jd}from"react/jsx-runtime";function zd({maxConcurrency:e,queuedRunCount:t,runningRunCount:n}){return Jd(Zb,{paddingX:1,children:[qd(Vo,{dimColor:!0,children:"Activity "}),Jd(Vo,{children:[String(n),"/",String(e)," running"]}),t>0?qd(Vo,{dimColor:!0,children:` \xB7 ${String(t)} queued`}):null]})}var Xd=p(()=>{"use strict"});import{Box as ew,Text as _n}from"ink";import{jsx as jn,jsxs as nw}from"react/jsx-runtime";function Gd({check:e}){let{detail:t,label:n,tone:r}=Pn(e),o=tw[r];return nw(ew,{children:[jn(_n,{color:o,children:r==="info"?"\u25CB":"\u25CF"}),jn(_n,{children:" "}),jn(_n,{children:n.padEnd(18," ")}),jn(_n,{color:o,children:t})]})}var tw,Kd=p(()=>{"use strict";Eo();tw={error:"red",info:"gray",ok:"green",warn:"yellow"}});import{Box as rw,Text as Qd}from"ink";import{jsx as Wo,jsxs as ow}from"react/jsx-runtime";function Yd({checks:e}){return ow(rw,{borderColor:"gray",borderStyle:"round",flexDirection:"column",marginTop:1,paddingX:1,children:[Wo(Qd,{bold:!0,children:"Health"}),e.length===0?Wo(Qd,{dimColor:!0,children:"Running first pass..."}):e.map(t=>Wo(Gd,{check:t},t.type))]})}var Zd=p(()=>{"use strict";Kd()});import{Box as Un,Text as yt}from"ink";import{jsx as gt,jsxs as $n}from"react/jsx-runtime";function ec({appUrl:e,developerUrl:t,projectName:n}){return $n(Un,{borderColor:"gray",borderStyle:"round",flexDirection:"column",paddingX:1,children:[$n(Un,{children:[gt(yt,{dimColor:!0,children:"Project "}),gt(yt,{bold:!0,children:n})]}),$n(Un,{children:[gt(yt,{dimColor:!0,children:"App "}),gt(yt,{color:"cyan",children:e})]}),$n(Un,{children:[gt(yt,{dimColor:!0,children:"Dashboard "}),gt(yt,{color:"cyan",children:t})]})]})}var tc=p(()=>{"use strict"});import{Box as Fo,Text as Ie}from"ink";import{jsx as _e,jsxs as Mo}from"react/jsx-runtime";function nc({paused:e,scope:t}){let n=t.slice(0,iw),r=t.length-n.length;return Mo(Fo,{borderColor:"gray",borderStyle:"round",flexDirection:"column",marginTop:1,paddingX:1,children:[Mo(Fo,{children:[_e(Ie,{bold:!0,children:"Scope"}),_e(Ie,{dimColor:!0,children:` (${String(t.length)})`}),_e(Ie,{children:" "}),_e(Ie,{dimColor:!0,children:"Hooks "}),_e(Ie,{color:e?"yellow":"green",children:e?"paused":"active"})]}),t.length===0?_e(Ie,{dimColor:!0,children:"no scope items \u2014 add from the dashboard or `ripplo scope add`"}):n.map(o=>Mo(Fo,{children:[_e(Ie,{color:"cyan",children:"\u2022 "}),_e(Ie,{children:o.label})]},o.id)),r>0?_e(Ie,{dimColor:!0,children:` \u2026 +${String(r)} more`}):null]})}var iw,rc=p(()=>{"use strict";iw=8});import{Box as aw,Text as oc}from"ink";import{jsx as sw,jsxs as ic}from"react/jsx-runtime";function ac({preconditions:e,workflows:t}){let n=t?.type==="workflows"?t.total:0,r=t?.type==="workflows"?t.invalidNames.length:0,o=e?.type==="preconditions"?e.count:0;return ic(aw,{marginTop:1,paddingX:1,children:[sw(oc,{dimColor:!0,children:"Workflows "}),ic(oc,{children:[String(n)," tests \xB7 ",String(o)," preconditions",r>0?` \xB7 ${String(r)} invalid`:""]})]})}var sc=p(()=>{"use strict"});import mj from"chalk";import{z as lc}from"zod";async function dc(){let e=new AbortController,t=setTimeout(()=>{e.abort()},3e3);try{let n=await fetch(`https://registry.npmjs.org/${lw}/latest`,{headers:{accept:"application/json"},signal:e.signal});if(!n.ok)return;let r=await n.json();return dw.parse(r).version}catch{return}finally{clearTimeout(t)}}var Ho,lw,dw,cc=p(()=>{"use strict";M();Ho="0.3.16",lw="ripplo",dw=lc.object({version:lc.string()})});import{useEffect as cw,useState as pw}from"react";import{Text as ht}from"ink";import{jsx as It,jsxs as gw}from"react/jsx-runtime";function pc({connected:e,projectId:t,queuedRunCount:n,ripploServerUrl:r,runningRunCount:o,syncError:i,width:a}){let l=yw(),s=l!=null&&l!==Ho,d=uw({connected:e,syncError:i}),c=mw({queuedRunCount:n,runningRunCount:o}),u=`v${Ho}`,y=s?` \u2192 v${l}`:"",S=`project ${t} \xB7 q to quit`,b=` ripplo ${u}${y} | ${r} ${d}${c}`,k=Math.max(0,a-b.length-S.length-1);return gw(ht,{inverse:!0,children:[It(ht,{bold:!0,children:" ripplo "}),It(ht,{dimColor:!0,children:u}),s?It(ht,{color:"yellow",children:` \u2192 v${l}`}):null,` | ${r} `,It(ht,{color:fw({connected:e,syncError:i}),children:d}),c," ".repeat(k),It(ht,{dimColor:!0,children:S})," "]})}function uw({connected:e,syncError:t}){return t!=null?"sync failed":e?"connected":"connecting..."}function mw({queuedRunCount:e,runningRunCount:t}){if(t===0&&e===0)return"";let n=e>0?` (+${String(e)} queued)`:"";return` ${String(t)} running${n}`}function fw({connected:e,syncError:t}){return t!=null?"red":e?"green":"yellow"}function yw(){let[e,t]=pw();return cw(()=>{dc().then(n=>{n!=null&&t(n)})},[]),e}var uc=p(()=>{"use strict";cc()});import{useEffect as hw}from"react";import{Box as qo,Text as kw,useApp as Sw,useInput as bw}from"ink";import{jsx as Je,jsxs as mc}from"react/jsx-runtime";function fc({config:e,cwd:t}){let n=Sw(),{height:r,width:o}=ft(),{config:i,devSessionId:a,syncError:l}=vd({config:e,cwd:t}),{connected:s,maxConcurrency:d,queuedRunCount:c,runningRunCount:u}=Md({config:i,cwd:t,devSessionId:a}),{checks:y}=Pd({config:i,cwd:t}),{paused:S,projectName:b,scope:k}=Dd({devSessionId:a,projectId:e.projectId});Id({cwd:t,projectId:e.projectId}),hw(()=>Ol(t),[t]),bw($=>{$==="q"&&n.exit()});let N=`${i.ripploServerUrl}/projects/${i.projectId}/developer`,R=y.filter($=>ww.has($.type)),O=y.find($=>$.type==="workflows"),F=y.find($=>$.type==="preconditions"),U=b??"\u2026";return mc(qo,{flexDirection:"column",height:r,width:o,children:[Je(pc,{connected:s,projectId:i.projectId,queuedRunCount:c,ripploServerUrl:i.ripploServerUrl,runningRunCount:u,syncError:l,width:o}),mc(qo,{flexDirection:"column",flexGrow:1,paddingX:1,paddingY:1,children:[Je(ec,{appUrl:i.appUrl,developerUrl:N,projectName:U}),Je(nc,{paused:S,scope:k}),Je(Yd,{checks:R}),Je(ac,{preconditions:F,workflows:O}),Je(zd,{maxConcurrency:d,queuedRunCount:c,runningRunCount:u}),Je(qo,{marginTop:1,paddingX:1,children:Je(kw,{dimColor:!0,children:"q quit"})})]})]})}var ww,yc=p(()=>{"use strict";ko();xn();Cd();Io();_d();Bd();Bo();Xd();Zd();tc();rc();sc();uc();ww=new Set(["dev-server","preconditions","adapter-enabled","webhook-verification","lockfile","pre-commit-hook","browser"])});import{Text as gc}from"ink";import Aw from"ink-spinner";import{jsx as hc,jsxs as Tw}from"react/jsx-runtime";function kc({loading:e}){return e?Tw(gc,{color:Rw,children:[hc(Aw,{type:"dots"})," Starting..."]}):hc(gc,{children:""})}var Rw,Sc=p(()=>{"use strict";Rw="#24CFFF"});import{useEffect as Nw,useState as _t}from"react";import{Box as tt,Text as Jo,useInput as vw}from"ink";import{jsx as ze,jsxs as zo}from"react/jsx-runtime";function wc({onDismiss:e}){let{height:t,width:n}=ft(),[r,o]=_t(0),[i,a]=_t(!1),[l,s]=_t(!1),[d,c]=_t(!1),[u,y]=_t(!1);vw(()=>{u&&e()}),Nw(()=>{let k=80+Dn.length*70+80,N=[...Dn.map((R,O)=>setTimeout(()=>{o(O+1)},80+O*70)),setTimeout(()=>{a(!0)},k),setTimeout(()=>{s(!0)},k+200),setTimeout(()=>{c(!0)},k+400),setTimeout(()=>{c(!1),y(!0)},k+2e3),setTimeout(()=>{e()},k+2800)];return()=>{N.forEach(R=>{clearTimeout(R)})}},[e]);let S=Dn.length+5,b=Math.max(0,Math.floor((t-S)/2));return zo(tt,{flexDirection:"column",height:t,width:n,children:[ze(tt,{height:b}),zo(tt,{alignItems:"flex-start",flexDirection:"row",justifyContent:"center",children:[ze(tt,{flexDirection:"column",children:Dn.map((k,N)=>ze(Jo,{color:bc,children:N<r?k:""},k))}),zo(tt,{flexDirection:"column",paddingLeft:4,paddingTop:5,children:[ze(Jo,{bold:!0,color:bc,children:i?Cw:""}),ze(tt,{marginTop:1,children:ze(Jo,{color:"gray",dimColor:!0,children:l?"developer CLI":""})}),ze(tt,{marginTop:2,children:ze(kc,{loading:d})})]})]})]})}var Dn,bc,Cw,Ac=p(()=>{"use strict";xn();Sc();Dn=[" XXXX XXXXXXX "," XX XX X X "," XXX XX XX X X ","XXXXXX XX XX XXXXXXX ","XX XXX XX XX ","XX XXX XX XXXXXXXX "," XX XX XX XX "," XX XX XX XX "," XX XXXXX XX"," XX XX XX XX"," XX XX XXXX "," XXX XX "," XXXXXXXXX XX "," XXX XX "," XXXXXXX "],bc="#24CFFF",Cw="ripplo"});import{createAuthClient as Lw}from"better-auth/client";import{deviceAuthorizationClient as xw}from"better-auth/client/plugins";function Bn({baseURL:e}){return Lw({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[xw()]})}var Xo=p(()=>{"use strict"});import{exec as Pw}from"child_process";async function Tc({cwd:e,onDeviceCode:t,url:n}){let r=n??xt().RIPPLO_SERVER_URL,o=Bn({baseURL:r}),i=await o.device.code({client_id:Rc});if(i.error!=null)throw new Error(`Failed to request device code: ${i.error.error_description}`);let{device_code:a,user_code:l,verification_uri_complete:s}=i.data;t({userCode:l,verificationUrl:s}),$w(s);let d=await Ow({authClient:o,deviceCode:a});return Hr(e,d),d}async function Ow({authClient:e,deviceCode:t}){for(;;){await jw(Ew);let n=await e.device.token({client_id:Rc,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(n.data?.access_token!=null)return n.data.access_token;if(n.error==null)continue;if(!_w(n.error.error))throw new Error(`Authorization failed: ${n.error.error_description}`)}}function _w(e){return Iw.has(e)}function jw(e){return new Promise(t=>{setTimeout(t,e)})}function Uw(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function $w(e){let t=Uw();Pw(`${t} "${e}"`,()=>{})}var Ew,Rc,Iw,Nc=p(()=>{"use strict";M();Xo();Me();Ew=5e3,Rc="ripplo-cli";Iw=new Set(["authorization_pending","slow_down"])});import{useCallback as Vn,useEffect as Dw,useState as Xe}from"react";import{exec as Bw}from"child_process";import{promisify as Vw}from"util";import H from"fs";import W from"path";function Cc({cwd:e,initialToken:t,serverUrl:n}){let[r,o]=Xe(t==null?"login":"validating"),[i,a]=Xe(),[l,s]=Xe(),[d,c]=Xe(t),[u,y]=Xe(!1),[S,b]=Xe(),[k,N]=Xe(),[R,O]=Xe([]);Dw(()=>{if(t==null)return;Bn({baseURL:n}).getSession({fetchOptions:{headers:{Authorization:`Bearer ${t}`}}}).then(j=>{if(j.data==null){o("login");return}return Go({cwd:e,serverUrl:n,token:t})}).then(j=>{if(j==null){o("select-project");return}a(j),o("complete")}).catch(j=>{s(j instanceof Error?j.message:String(j)),o("login")})},[e,t,n]);let F=Vn(()=>{u||(y(!0),s(void 0),Tc({cwd:e,onDeviceCode:b,url:n}).then(q=>(c(q),Go({cwd:e,serverUrl:n,token:q}))).then(q=>{q==null?o("select-project"):(a(q),o("complete"))}).catch(q=>{y(!1),b(void 0),s(q instanceof Error?q.message:String(q))}))},[e,u,n]),U=Vn(q=>{let j=i?.token??d??t;if(j==null){s("No authentication token available");return}o("scaffolding"),s(void 0),Hw({cwd:e,onStep:N,projectId:q.id}).then(async G=>{O(G);let Ge=await Go({cwd:e,serverUrl:n,token:j});a(Ge??Ww({projectId:q.id,serverUrl:n,token:j})),o(G.length>0?"scaffolding-warnings":"complete")}).catch(G=>{s(G instanceof Error?G.message:String(G)),o("select-project")})},[i,e,t,n,d]),$=Vn(()=>{o("complete")},[]),se=Vn(()=>{a(void 0),o("login"),y(!1),b(void 0),s(void 0)},[]);return{config:i,deviceCodeInfo:S,dismissScaffoldWarnings:$,error:l,loginStarted:u,resetToLogin:se,scaffoldingStep:k,scaffoldWarnings:R,selectProject:U,setStage:o,stage:r,startLogin:F,token:d}}function Ww({projectId:e,serverUrl:t,token:n}){return{appUrl:"",engineUrl:"",projectId:e,ripploServerUrl:t,token:n,webhookSecret:""}}async function Go({cwd:e,serverUrl:t,token:n}){let r=await L(e);if(r.ok)return{...r.result.config,ripploServerUrl:t,token:n}}async function Hw({cwd:e,onStep:t,projectId:n}){t("Scaffolding project files..."),Zw({cwd:e,projectId:n}),t("Updating .gitignore..."),lA(e),t("Marking ripplo.lock as generated..."),Xw(e),t("Installing dependencies...");let r=await qw(e),o=[];if(r.ok||o.push({manualCommand:r.cmd,message:`Couldn't auto-install dev dependencies (${r.reason}). Run this manually, then re-run \`npx ripplo\`.`}),r.ok){t("Compiling initial lockfile...");let i=await Jw(e);i!=null&&o.push({manualCommand:void 0,message:i})}return t("Setting up browser..."),await vr(),o}async function qw(e){let t=Gw({cwd:e,pm:Yw(e)});g.info("Installing dependencies: %s",t);try{return await Mw(t,{cwd:e}),{ok:!0}}catch(n){let r=n instanceof Error?n.message.split(`
|
|
323
|
-
`)[0]??n.message:String(n);return g.warn("Install failed (%s): %s",t,r),{cmd:t,ok:!1,reason:r}}}async function Jw(e){try{await zw(e);return}catch(t){let n=t instanceof Error?t.message:String(t);return g.warn("Initial lockfile compile failed: %s",n),`Couldn't compile initial lockfile: ${n}. You can run \`npx ripplo\` again after fixing the DSL.`}}async function zw(e){let t=await L(e);if(!t.ok){g.warn("Initial compile failed, skipping lockfile write: %s",t.error);return}await me({cwd:e,result:t.result})}function Xw(e){let t=W.join(e,".gitattributes"),n=H.existsSync(t)?H.readFileSync(t,"utf8"):"";if(n.includes(vc))return;let r=n.length===0||n.endsWith(`
|
|
329
|
+
`);function fe(){try{return X(process.cwd())}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`${t}
|
|
330
|
+
`),process.stderr.write(`${E("setup")}
|
|
331
|
+
`),process.exit(1)}}async function ge(e){(await k({config:e,document:bg,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession==null&&(process.stderr.write("No active dev session. Start one by running `ripplo` (or `npx ripplo`) in a terminal first.\n"),process.stderr.write(`${E("setup")}
|
|
332
|
+
`),process.exit(1))}async function ds({id:e,runs:t}){let r=fe();await ge(r),process.stdout.write(`flake-detect "${e}" x${String(t)}...
|
|
333
|
+
`);let n=await Promise.allSettled(Array.from({length:t},()=>Wt({config:r,ids:[e]}))),o=0,i=0,s=new Map;n.forEach(l=>{if(l.status==="rejected"){i++;let d=l.reason instanceof Error?l.reason.message:"unknown error";s.set(d,(s.get(d)??0)+1);return}let c=l.value.results[0];if(c==null){i++;return}if(c.summary.includes("FAILED")||c.summary.includes("ERROR")){i++;let d=c.summary.split(`
|
|
334
|
+
`).find(u=>u.includes("FAILED")||u.includes("ERROR"))??"unknown failure";s.set(d,(s.get(d)??0)+1)}else o++});let a=t>0?i/t*100:0;process.stdout.write(`${String(o)} passed / ${String(i)} failed (${a.toFixed(1)}% flake)
|
|
335
|
+
`),s.size>0&&s.forEach((l,c)=>{process.stdout.write(` ${String(l)}x: ${c}
|
|
336
|
+
`)}),i>0&&process.stderr.write(`${E("flake-detect","parallel safety + race conditions")}
|
|
337
|
+
`),process.exit(i>0?1:0)}import Ve from"fs";import Fe from"path";import{input as ms,select as fs}from"@inquirer/prompts";import{graphql as Vg}from"gql.tada";import{exec as Sg}from"child_process";import F from"fs";import H from"path";import{promisify as vg}from"util";var kg=["@ripplo/testing"],us=".ripplo/ripplo.lock linguist-generated=true",Rg=[".ripplo/debug/",".ripplo/.local/"],xg=vg(Sg);async function ps({cwd:e,onStep:t}){t("Scaffolding project files..."),jg({cwd:e}),t("Updating .gitignore..."),Ng(e),t("Marking ripplo.lock as generated..."),Cg(e),t("Installing dependencies...");let r=await Pg(e),n=[];if(r.ok||n.push({manualCommand:r.cmd,message:`Couldn't auto-install dev dependencies (${r.reason}). Run the command below, then run \`ripplo lint\` to compile the lockfile.`}),r.ok){t("Compiling initial lockfile...");let o=await Eg(e);o!=null&&n.push({manualCommand:void 0,message:o})}return t("Setting up browser..."),await Sr(),n}async function Pg(e){let t=Tg({cwd:e,pm:Ig(e)});g.info("Installing dependencies: %s",t);try{return await xg(t,{cwd:e}),{ok:!0}}catch(r){let n=r instanceof Error?r.message.split(`
|
|
338
|
+
`)[0]??r.message:String(r);return g.warn("Install failed (%s): %s",t,n),{cmd:t,ok:!1,reason:n}}}async function Eg(e){try{let t=await I(e);if(!t.ok)return;await de({cwd:e,result:t.result});return}catch(t){return`Couldn't compile initial lockfile: ${t instanceof Error?t.message:String(t)}.`}}function Cg(e){let t=H.join(e,".gitattributes"),r=F.existsSync(t)?F.readFileSync(t,"utf8"):"";if(r.includes(us))return;let n=r.length===0||r.endsWith(`
|
|
339
|
+
`)?"":`
|
|
340
|
+
`;F.writeFileSync(t,`${r}${n}${us}
|
|
341
|
+
`)}function Tg({cwd:e,pm:t}){let r=kg.join(" ");return t==="pnpm"?Ag(e)?`pnpm add -wD ${r}`:`pnpm add -D ${r}`:t==="yarn"?$g(e)?`yarn add -WD ${r}`:`yarn add -D ${r}`:t==="bun"?`bun add -d ${r}`:`npm install -D ${r}`}function Ag(e){return F.existsSync(H.join(e,"pnpm-workspace.yaml"))||F.existsSync(H.join(e,"pnpm-workspace.yml"))}function $g(e){let t=H.join(e,"package.json");if(!F.existsSync(t))return!1;try{let r=JSON.parse(F.readFileSync(t,"utf8"));if(r==null||typeof r!="object"||!("workspaces"in r))return!1;let n=r.workspaces;return Array.isArray(n)||n!=null&&typeof n=="object"}catch{return!1}}function Ig(e){return F.existsSync(H.join(e,"pnpm-lock.yaml"))?"pnpm":F.existsSync(H.join(e,"yarn.lock"))?"yarn":F.existsSync(H.join(e,"bun.lockb"))||F.existsSync(H.join(e,"bun.lock"))?"bun":"npm"}function jg({cwd:e}){let t=H.join(e,".ripplo"),r=H.join(t,"tests"),n=H.join(t,"preconditions"),o=H.join(t,"observers");F.mkdirSync(r,{recursive:!0}),F.mkdirSync(n,{recursive:!0}),F.mkdirSync(o,{recursive:!0}),st(H.join(t,"index.ts"),Og),st(H.join(n,"index.ts"),Lg),st(H.join(o,"index.ts"),Dg),st(H.join(r,"index.ts"),_g),st(H.join(t,"tsconfig.json"),Ug)}function st(e,t){F.existsSync(e)||F.writeFileSync(e,t)}function Ng(e){let t=H.join(e,".gitignore");if(!F.existsSync(t))return;let r=F.readFileSync(t,"utf8"),n=Rg.filter(i=>!r.includes(i));if(n.length===0)return;let o=r.endsWith(`
|
|
324
342
|
`)?"":`
|
|
325
|
-
`;
|
|
326
|
-
`)
|
|
343
|
+
`;F.writeFileSync(t,r+o+n.join(`
|
|
344
|
+
`)+`
|
|
345
|
+
`)}var Og=`import { createRipplo } from "@ripplo/testing";
|
|
327
346
|
import { preconditions } from "./preconditions/index.js";
|
|
328
347
|
import { observers } from "./observers/index.js";
|
|
329
348
|
import { tests } from "./tests/index.js";
|
|
330
349
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
engineUrl: "http://localhost:3000/ripplo",
|
|
335
|
-
projectId: "${e}",
|
|
336
|
-
},
|
|
337
|
-
{ preconditions, observers, tests },
|
|
338
|
-
);
|
|
339
|
-
|
|
340
|
-
export default ripplo;
|
|
341
|
-
`}function tA(){return`RIPPLO_WEBHOOK_SECRET="${no()}"
|
|
342
|
-
`}function lA(e){let t=W.join(e,".gitignore");if(!H.existsSync(t))return;let n=H.readFileSync(t,"utf8"),r=sA.filter(i=>!n.includes(i));if(r.length===0)return;let o=n.endsWith(`
|
|
343
|
-
`)?"":`
|
|
344
|
-
`;H.writeFileSync(t,n+o+r.join(`
|
|
345
|
-
`)+`
|
|
346
|
-
`)}var Fw,Mw,vc,nA,rA,oA,iA,aA,sA,Lc=p(()=>{"use strict";M();$e();Nc();Xo();z();Fw=["@ripplo/testing"],Mw=Vw(Bw);vc=".ripplo/ripplo.lock linguist-generated=true";nA=`// Re-exports for CLI / adapter / server imports.
|
|
347
|
-
export { default } from "./ripplo.js";
|
|
348
|
-
export { preconditions } from "./preconditions/index.js";
|
|
349
|
-
export { observers } from "./observers/index.js";
|
|
350
|
-
export { tests } from "./tests/index.js";
|
|
351
|
-
`,rA=`// Declare preconditions with \`precondition(name)\` from @ripplo/testing and collect them
|
|
350
|
+
export { preconditions, observers, tests };
|
|
351
|
+
export default createRipplo({ preconditions, observers, tests });
|
|
352
|
+
`,Lg=`// Declare preconditions with \`precondition(name)\` from @ripplo/testing and collect them
|
|
352
353
|
// in the \`preconditions\` registry below. Every handle in this registry must be implemented
|
|
353
354
|
// in your app server's \`createEngine(ripplo, { preconditions: {...}, observers: {...} })\` call.
|
|
354
355
|
//
|
|
@@ -362,7 +363,7 @@ export { tests } from "./tests/index.js";
|
|
|
362
363
|
// export const preconditions = { authLoggedIn };
|
|
363
364
|
|
|
364
365
|
export const preconditions = {};
|
|
365
|
-
`,
|
|
366
|
+
`,Dg=`// Declare observers with \`observer(name)\` from @ripplo/testing and collect them in
|
|
366
367
|
// the \`observers\` registry below. Use them in tests via \`assert.backend(handle, params)\`.
|
|
367
368
|
//
|
|
368
369
|
// Example:
|
|
@@ -375,15 +376,15 @@ export const preconditions = {};
|
|
|
375
376
|
// export const observers = { orgNameIs };
|
|
376
377
|
|
|
377
378
|
export const observers = {};
|
|
378
|
-
`,
|
|
379
|
-
// to the \`tests\` array \u2014 that's what \`createRipplo(...,
|
|
379
|
+
`,_g=`// Each test file under ./tests exports a TestDefinition. Import them here and add them
|
|
380
|
+
// to the \`tests\` array \u2014 that's what \`createRipplo({ ..., tests })\` receives.
|
|
380
381
|
//
|
|
381
382
|
// Example:
|
|
382
383
|
// import { myTest } from "./my-test.js";
|
|
383
384
|
// export const tests = [myTest] as const;
|
|
384
385
|
|
|
385
386
|
export const tests = [] as const;
|
|
386
|
-
`,
|
|
387
|
+
`,Ug=`{
|
|
387
388
|
"compilerOptions": {
|
|
388
389
|
"strict": true,
|
|
389
390
|
"noUncheckedIndexedAccess": true,
|
|
@@ -399,153 +400,89 @@ export const tests = [] as const;
|
|
|
399
400
|
"include": ["*.ts", "coverage.d.ts", "observers/**/*.ts", "preconditions/**/*.ts", "tests/**/*.ts"],
|
|
400
401
|
"exclude": ["node_modules"]
|
|
401
402
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
${d}
|
|
406
|
-
|
|
407
|
-
`)}catch{}})}var SA,Wn,Fn,Yo=p(()=>{"use strict";M();Oc();Me();Io();Bo();SA=kA(`
|
|
408
|
-
mutation EndDevSessionExit($projectId: String!) {
|
|
409
|
-
endDevSession(projectId: $projectId) {
|
|
403
|
+
`;var Fg=Vg(`
|
|
404
|
+
query InitProjects {
|
|
405
|
+
projects {
|
|
410
406
|
id
|
|
407
|
+
name
|
|
411
408
|
}
|
|
412
409
|
}
|
|
413
|
-
`)});Hn();import{config as _c}from"dotenv";import Ut from"path";import{fileURLToPath as RA}from"url";import TA from"yargs";import{hideBin as NA}from"yargs/helpers";$e();import Ht from"fs";import nr from"path";import{z as we}from"zod";var Yn=["**/src/**","**/app/**","**/apps/**","**/pages/**","**/routes/**","**/components/**","**/server/**","**/api/**","**/backend/**","**/features/**","**/modules/**","**/views/**","**/ui/**","**/hooks/**","**/contexts/**","**/providers/**","**/controllers/**","**/handlers/**","**/resolvers/**","**/services/**","**/middleware/**","**/lib/**"],Ke=["**/*.gen.*","**/generated/**","**/*.d.ts","**/*.test.*","**/*.spec.*","**/node_modules/**","**/dist/**","**/build/**",".ripplo/**","**/*.md","**/.next/**","**/.turbo/**","**/.vercel/**","**/.svelte-kit/**","**/.nuxt/**","**/.astro/**","**/coverage/**","**/storybook-static/**","**/*.stories.*","**/*.story.*","**/cli/**","**/scripts/**","**/tools/**","**/__tests__/**","**/__mocks__/**","**/__fixtures__/**","**/*.config.*","**/*.setup.*","**/public/**","**/static/**","**/assets/**","**/migrations/**","**/prisma/migrations/**","**/scripts/**"],tu=we.object({appUrl:we.string(),engineUrl:we.string(),ignorePaths:we.array(we.string()).optional(),projectId:we.string(),watchPaths:we.array(we.string()).optional(),webhookSecret:we.string()}),nu=tu.extend({webhookSecret:we.string().optional()});Zn();Wt();import{Webhook as sR,WebhookVerificationError as lR}from"standardwebhooks";import{z as _}from"zod";var cR=_.object({preconditions:_.array(_.string().min(1))}),pR=_.object({data:_.record(_.string(),_.record(_.string(),_.string())),preconditions:_.array(_.string().min(1))}),uR=_.object({observer:_.string().min(1).max(200),params:_.record(_.string().max(200),_.string())}),cu=_.discriminatedUnion("kind",[_.object({kind:_.literal("pass")}),_.object({kind:_.literal("retry"),reason:_.string()}),_.object({kind:_.literal("fail"),reason:_.string()})]),mR=_.object({error:_.string().optional(),outcome:cu.optional(),success:_.boolean()});$t();function ot(e){let t=[];return e.tests.forEach(n=>{let r=pu(n),o=i=>{t.push({...i,test:n.slug})};Iu.forEach(i=>{i(r,n,o)})}),{diagnostics:t}}function pu(e){let t=[],n=e.spec.entryNode,r=new Set;for(;n!=null&&!r.has(n);){r.add(n);let o=e.spec.nodes[n];if(o==null)break;t.push(o),n=o.next}return t}function uu(e,t,n){e.forEach(r=>{r.type==="assertText"&&"operator"in r&&r.operator!=="equals"&&n({message:`${r.type} uses operator "${r.operator}" \u2014 only "equals" is allowed for determinism`,rule:"exact-text-match",step:r.label??r.id})})}function mu(e,t,n){Object.keys(t.spec.variables??{}).length>0&&e.forEach(o=>{if(o.type==="fill"&&fi(o.value)){let i=o.value.value;!yi(i)&&bu(i)&&n({message:`fill() uses hardcoded value "${i}" \u2014 consider using precondition data via {{namespace.key}}`,rule:"no-hardcoded-data",step:o.label??o.id})}})}function fu(e,t,n){if(Object.keys(t.spec.variables??{}).length===0)return;e.some(i=>JSON.stringify(i).includes("{{"))||n({message:"Test requires preconditions but steps() never references precondition data \u2014 destructure and use it",rule:"prefer-precondition-data",step:void 0})}function yu(e,t,n){e.forEach(r=>{(r.label==null||r.label.length===0)&&n({message:`Step "${r.id}" lacks .as("...") label \u2014 every step must be labeled`,rule:"missing-label",step:r.id})})}function gu(e,t,n){let r=new Map;e.forEach(o=>{if(o.label==null)return;let i=r.get(o.label);i==null?r.set(o.label,o.id):n({message:`Duplicate label "${o.label}" \u2014 also used by ${i}`,rule:"no-duplicate-labels",step:o.label})})}function hu(e,t,n){let r=0;e.forEach(o=>{it(o)?r=0:(r++,r===3&&n({message:"3+ consecutive actions without an assertion \u2014 add verification between actions",rule:"assert-after-action",step:o.label??o.id}))})}function ku(e,t,n){if(e.length===0)return;let r=e.at(-1);r!=null&&!it(r)&&n({message:"Last step is an action, not an assertion \u2014 expectedOutcome should be verified by assertions at the end",rule:"assert-matches-outcome",step:r.label??r.id})}function Su(e,t,n){t.implemented&&e.length===0&&n({message:"Test has zero steps",rule:"no-empty-steps",step:void 0})}function fi(e){return!(typeof e!="object"||e==null||!("type"in e)||e.type!=="static"||!("value"in e)||typeof e.value!="string")}function yi(e){return e.includes("{{")}function bu(e){return e.includes("@")||/\b[a-f0-9]{8,}\b/.test(e)||/^(test|ripplo|example|sample|demo)/i.test(e)}function it(e){return e.type.startsWith("assert")}var wu=new Set(["assertText","assertValue","assertCount","assertUrl","assertNotVisible","assertChecked","assertNotChecked","assertAttribute","assertDisabled","assertEnabled"]);function Au(e){return wu.has(e.type)}function Ru(e,t,n){!t.implemented||e.length===0||e.some(r=>it(r))||n({message:"Test has zero assertion steps \u2014 cannot verify expectedOutcome. Add assert.* steps.",rule:"no-assertions",step:void 0})}function Tu(e,t,n){if(!t.implemented||e.length<=3)return;let r=e.filter(i=>it(i)).length;if(r===0)return;let o=r/e.length;if(o<.15){let i=Math.round(o*100);n({message:`Only ${String(r)}/${String(e.length)} steps are assertions (${String(i)}%) \u2014 add more verification between actions`,rule:"low-assertion-ratio",step:void 0})}}function er(e){if(!("locator"in e)||e.locator==null)return;let t=e.locator;return t.by==="role"?`role:${t.role}:${t.name??""}`:`testId:${t.value}`}function Nu(e,t,n){e.forEach((r,o)=>{if(r.type!=="click")return;let i=er(r);if(i==null)return;let a=e.slice(o+1,o+4);a.find(d=>d.type==="assertVisible"&&er(d)===i)==null||a.some(d=>Au(d)||it(d)&&er(d)!==i)||n({message:`click "${r.label??r.id}" is followed only by assert.visible on the same locator \u2014 verifies nothing about the click's effect`,rule:"tautological-post-click-assert",step:r.label??r.id})})}var vu=new Set(["the","is","a","an","and","or","of","to","in","on","at","for","that","this","with","be","are","was","were","it","its","as","by","from","after","before","should","will","can","still","but","not","no","so","if","then","than","user","users","page","view","shows","show","see","click","clicks","clicked","clickable","visible","appears","appear","displayed","stays","remains"]);function tr(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>=3&&!vu.has(t))}function Cu(e){let t=e.label==null?[]:tr(e.label);if(!("locator"in e)||e.locator==null)return t;let n=e.locator,r=n.by==="role"?n.name??"":n.value;return[...t,...tr(r)]}function Lu(e,t,n){if(!t.implemented||e.length===0)return;let r=new Set(tr(t.expectedOutcome));if(r.size===0)return;let o=e.filter(a=>it(a));if(o.length===0)return;o.some(a=>Cu(a).some(l=>r.has(l)))||n({message:`No assertion references any keyword from expectedOutcome (${[...r].join(", ")}) \u2014 the outcome may not actually be verified`,rule:"expected-outcome-keyword-coverage",step:void 0})}var xu=/save|submit|create|delete|remove|send|invite|update|confirm|publish|apply|pay|subscribe|upgrade|cancel|archive|rename/i;function mi(e){if(e.type==="upload"||e.type==="handleDialog"&&e.action==="accept")return!0;if(e.type!=="click")return!1;let t=e.locator,n=t.by==="role"?t.name??"":t.value;return xu.test(n)}function Pu(e,t,n){!t.implemented||t.spec.uiOnly===!0||e.forEach((r,o)=>{if(!mi(r)||"uiOnly"in r&&r.uiOnly===!0)return;let i=e.slice(o+1),a=i.findIndex(c=>mi(c)),l=a===-1?i.length:a;i.slice(0,l).some(c=>c.type==="assertObserver")||n({message:`"${r.label??r.id}" looks like it mutates backend state but no assert.backend(...) observer verifies it \u2014 the test can pass while the server is broken. You need to add an observer that checks the persisted result (see .ripplo/observers/ for examples). Only if this action truly does NOT change any server state (pure client-side interaction, presentation toggle, etc.) should you fall back to marking the step { uiOnly: true } to silence this rule.`,rule:"mutation-without-observer-coverage",step:r.label??r.id})})}function Eu(e,t,n){Object.keys(t.spec.variables??{}).length!==0&&e.forEach(o=>{if(o.type!=="assertObserver")return;let i=Object.entries(o.params);i.length===0||i.some(([,l])=>fi(l)&&yi(l.value))||n({message:`assert.backend "${o.label??o.id}" passes only hardcoded params while the test defines precondition variables \u2014 observer assertions should reference {{namespace.key}} so they match the actual precondition data`,rule:"observer-params-reference-variables",step:o.label??o.id})})}function Ou(e,t,n){let r=new Set(Object.keys(t.spec.variables??{})),o=/\{\{([^{}]+?)\}\}/g;e.forEach(i=>{let l=[...JSON.stringify(i).matchAll(o)],s=[...new Set(l.map(u=>u[1]).filter(u=>u!=null&&!r.has(u)))];if(s.length===0)return;let d=s.map(u=>`{{${u}}}`).join(", "),c=[...new Set(s.map(u=>u.split(".")[0]??u))].join(", ");n({message:`"${i.label??i.id}" contains literal template string(s) ${d} \u2014 destructure the proxy in .steps(({ ${c} }) => \u2026) and pass the proxy value (e.g. \`${s[0]??""}\`) directly. Writing the template as a string bypasses type-checking and silently accepts typos.`,rule:"no-literal-template-strings",step:i.label??i.id})})}var Iu=[uu,mu,Ou,fu,yu,gu,hu,ku,Su,Ru,Tu,Nu,Lu,Pu,Eu];import om from"picomatch";import{execFileSync as _u,spawnSync as ju}from"child_process";function fe(e,t){return _u("git",[...e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}function gi(e,t){let n=ju("git",["show",e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]});if(n.status===0)return n.stdout;if(n.status===128)return null;throw new Error(`git show ${e} failed (${String(n.status)}): ${n.stderr}`)}import T from"typescript";import*as hi from"remeda";var ki=[["onClick","click"],["onContextMenu","click"],["onKeyDown","click"],["onKeyPress","click"],["onKeyUp","click"],["onSelect","click"],["onOpenChange","click"],["onPress","click"],["onActivate","click"],["onToggle","click"],["onOpen","click"],["onClose","click"],["onDismiss","click"],["onConfirm","click"],["onCancel","click"],["onApply","click"],["onClear","click"],["onSubmit","submit"],["onReset","submit"],["onDrop","drag"],["onDragEnd","drag"],["onDragEnter","drag"],["onDragLeave","drag"],["onDragOver","drag"],["onDragStart","drag"],["onValueChange","select"],["onSelectionChange","select"],["onChange","input"],["onCheckedChange","input"],["onInput","input"]],Uu=new Map([["button","click"],["link","navigate"],["textbox","input"],["searchbox","input"],["combobox","select"],["listbox","select"]]),$u=[[/(?:^|[a-z])Button$/,"click"],[/(?:^|[a-z])(?:Link|NavLink|Anchor)$/,"navigate"],[/(?:^|[a-z])(?:Textarea|TextArea|Input|Field|SearchBox)$/,"input"],[/(?:^|[a-z])(?:Select|Combobox|ComboBox|Dropdown)$/,"select"],[/(?:^|[a-z])Form$/,"submit"]];function Mt({filePath:e,source:t}){let n=T.createSourceFile(e,t,T.ScriptTarget.Latest,!0,T.ScriptKind.TSX);return n.statements.flatMap(r=>Du({filePath:e,sf:n,stmt:r}))}function Du({filePath:e,sf:t,stmt:n}){let r=Vu(n);if(r==null||Bu(r))return[];let o=Si(n,t).map(i=>({id:`${e}#${r}.${i.kind}[${i.label}]`,line:i.line}));return hi.uniqueBy(o,i=>i.id)}function Bu(e){return e.endsWith("Fragment")||e.endsWith("Skeleton")||/^use[A-Z]/.test(e)||/^[A-Z][A-Z0-9_]*$/.test(e)}function Vu(e){if(T.isExportAssignment(e))return Wu(e.expression);if(!Fu(e))return null;if(T.isFunctionDeclaration(e)||T.isClassDeclaration(e))return e.name?.text??null;if(T.isVariableStatement(e)){let t=e.declarationList.declarations[0];return t!=null&&T.isIdentifier(t.name)?t.name.text:null}return null}function Wu(e){return T.isIdentifier(e)?e.text:(T.isFunctionExpression(e)||T.isClassExpression(e))&&e.name!=null?e.name.text:"default"}function Fu(e){if(!T.canHaveModifiers(e))return!1;let t=T.getModifiers(e);return t!=null&&t.some(n=>n.kind===T.SyntaxKind.ExportKeyword)}function Si(e,t){let n=Mu(e,t),r=e.getChildren(t).flatMap(o=>Si(o,t));return n==null?r:[n,...r]}function Mu(e,t){let n=Hu(e);if(n==null)return null;let r=qu(n);if(r==null)return null;let o=Ku(n,r);return o==null?null:{kind:r,label:o,line:rm(t,e.getStart(t))}}function Hu(e){return T.isJsxSelfClosingElement(e)&&T.isIdentifier(e.tagName)?{attrs:e.attributes,children:[],tag:e.tagName.text}:T.isJsxElement(e)&&T.isIdentifier(e.openingElement.tagName)?{attrs:e.openingElement.attributes,children:e.children,tag:e.openingElement.tagName.text}:null}function qu({attrs:e,tag:t}){let n=Ae(e,"role");return n!=null?Uu.get(n)??null:zu(t,e)??Xu(t)??Gu(e)}var Ju=new Map([["button",()=>"click"],["a",e=>Ae(e,"href")==null?null:"navigate"],["input",e=>Ae(e,"type")==="file"?"upload":"input"],["textarea",()=>"input"],["select",()=>"select"],["form",()=>"submit"]]);function zu(e,t){return Ju.get(e)?.(t)??null}function Xu(e){return/^[A-Z]/.test(e)?$u.find(([t])=>t.test(e))?.[1]??null:null}function Gu(e){return ki.find(([t])=>Zu(e,t))?.[1]??null}function Ku({attrs:e,children:t,tag:n},r){return r==="navigate"?Ae(e,"href")??Ae(e,"to"):Ae(e,"aria-label")??Ae(e,"label")??Ae(e,"title")??Ae(e,"name")??Ae(e,"placeholder")??(Qu(n)?void 0:nm(t))??Yu(e,r)}function Qu(e){return e==="input"||e==="textarea"||e==="select"}function Yu(e,t){let n=ki.find(([,o])=>o===t)?.[0];if(n==null)return;let r=em(e,n);if(r!=null){if(T.isIdentifier(r))return r.text;if(T.isArrowFunction(r)||T.isFunctionExpression(r))return bi(r.body)}}function bi(e){if(T.isCallExpression(e)){let t=e.expression;return T.isIdentifier(t)?t.text:T.isPropertyAccessExpression(t)?t.name.text:void 0}return T.forEachChild(e,bi)}function Zu(e,t){return e.properties.some(n=>T.isJsxAttribute(n)&&T.isIdentifier(n.name)&&n.name.text===t)}function wi(e,t){return e.properties.find(n=>T.isJsxAttribute(n)&&T.isIdentifier(n.name)&&n.name.text===t)}function Ae(e,t){let n=wi(e,t);return n==null?void 0:tm(n.initializer)}function em(e,t){let n=wi(e,t);if(!(n?.initializer==null||!T.isJsxExpression(n.initializer)))return n.initializer.expression}function tm(e){if(e==null)return"";if(T.isStringLiteral(e))return e.text;if(T.isJsxExpression(e))return Ri(e.expression)}function nm(e){let t=e.flatMap(n=>Ai(n)).join(" ").trim();return t.length===0?void 0:t}function Ai(e){if(T.isJsxText(e)){let t=e.text.trim();return t.length===0?[]:[t]}if(T.isJsxExpression(e)){let t=Ri(e.expression);return t==null?[]:[t]}return T.isJsxElement(e)?e.children.flatMap(t=>Ai(t)):[]}function Ri(e){if(e!=null){if(T.isStringLiteral(e)||T.isNoSubstitutionTemplateLiteral(e))return e.text;if(T.isCallExpression(e)&&e.arguments.length===1){let t=e.arguments[0];if(t!=null&&(T.isStringLiteral(t)||T.isNoSubstitutionTemplateLiteral(t)))return t.text}}}function rm(e,t){return e.getLineAndCharacterOfPosition(t).line+1}var im=nr.join(".ripplo","coverage.d.ts");function at({config:e,cwd:t}){am({cwd:t,ignorePaths:e.ignorePaths??Ke})}function am({cwd:e,ignorePaths:t}){let n=st({cwd:e,ignorePaths:t});dm({content:lm(n),cwd:e})}function st({cwd:e,ignorePaths:t}){let r=sm({cwd:e,ignorePaths:t}).flatMap(o=>rr({cwd:e,file:o}));return[...new Set(r)].sort((o,i)=>o.localeCompare(i))}function sm({cwd:e,ignorePaths:t}){let n=fe(["ls-files","--cached","--others","--exclude-standard","-z"],e),r=om([...t]);return n.split("\0").filter(o=>o.length>0&&/\.(tsx|jsx)$/.test(o)).filter(o=>!r(o))}function rr({cwd:e,file:t}){let n=Ht.readFileSync(nr.join(e,t),"utf8");return Mt({filePath:t,source:n}).map(r=>r.id)}function lm(e){let t=`// GENERATED \u2014 do not edit
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
`)
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
`}function
|
|
425
|
-
`)
|
|
426
|
-
|
|
427
|
-
`)
|
|
428
|
-
`),process.stderr.write(
|
|
429
|
-
`),process.
|
|
430
|
-
`)
|
|
431
|
-
|
|
432
|
-
`),
|
|
433
|
-
|
|
434
|
-
`),
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
`)
|
|
438
|
-
|
|
439
|
-
`)
|
|
440
|
-
`)
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
`),
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
410
|
+
`),mn=["../.env.local","../.env"];async function gs(e=Hg()){let t=process.cwd(),r=le();r==null&&(process.stdout.write("Not authenticated. Run `ripplo auth login` first.\n"),process.exit(1));let n=Ee();Mg(t)&&(process.stdout.write(`\`.ripplo/index.ts\` already exists at ${t}. Delete it first if you want to re-init.
|
|
411
|
+
`),process.exit(1));let o=await Wg({serverUrl:n,token:r});o.length===0&&(process.stdout.write("No projects found. Create one in the dashboard first, then re-run `ripplo init`.\n"),process.exit(1));let i=await Bg(o,e.projectId),s=await zg(t,e.envFile),a=await Gg(e.appUrl),l=qg(a,e.engineUrl),c=Fe.resolve(Fe.join(t,".ripplo"),s);vn({cwd:t,envFiles:[s],projectId:i}),Yg({appUrl:a,engineUrl:l,filePath:c});let d=await ps({cwd:t,onStep:u=>{process.stdout.write(` ${u}
|
|
412
|
+
`)}});if(d.length>0){process.stdout.write(`Done with warnings:
|
|
413
|
+
`),d.forEach(u=>{process.stdout.write(` - ${u.message}
|
|
414
|
+
`),u.manualCommand!=null&&process.stdout.write(` run: ${u.manualCommand}
|
|
415
|
+
`)});return}process.stdout.write("Ready. Add `ripplo watch` to your dev script, then write tests in `.ripplo/tests/`.\n")}function Mg(e){return Ve.existsSync(Fe.join(e,".ripplo","index.ts"))}async function Wg({serverUrl:e,token:t}){return((await k({config:rt({serverUrl:e,token:t}),document:Fg,variables:void 0})).projects??[]).map(n=>({id:n.id,name:n.name}))}function Hg(){return{appUrl:void 0,engineUrl:void 0,envFile:void 0,projectId:void 0}}function qg(e,t){if(t!=null){try{new URL(t)}catch{process.stdout.write(`--engine-url is not a valid URL: ${t}
|
|
416
|
+
`),process.exit(1)}return t}return`${e.replace(/\/$/,"")}/ripplo`}async function Bg(e,t){if(t!=null){let r=e.find(n=>n.id===t);return r==null&&(process.stdout.write(`Unknown project id: ${t}
|
|
417
|
+
`),process.exit(1)),process.stdout.write(`Using project: ${r.name} (${r.id})
|
|
418
|
+
`),r.id}if(e.length===1){let r=e[0];if(r==null)throw new Error("unreachable");return process.stdout.write(`Using project: ${r.name} (${r.id})
|
|
419
|
+
`),r.id}return fs({choices:e.map(r=>({name:r.name,value:r.id})),message:"Select a project"})}async function zg(e,t){return t!=null?(t.trim().length===0&&(process.stdout.write(`--env-file must not be empty
|
|
420
|
+
`),process.exit(1)),t):Kg(e)}async function Gg(e){if(e!=null){try{new URL(e)}catch{process.stdout.write(`--app-url is not a valid URL: ${e}
|
|
421
|
+
`),process.exit(1)}return e}return Jg()}async function Kg(e){let t=Fe.join(e,".ripplo"),r=mn.find(o=>Ve.existsSync(Fe.resolve(t,o))),n=await fs({choices:[...mn.map(o=>({name:r===o?`${o} (detected)`:o,value:o})),{name:"custom path",value:"__custom__"}],default:r??mn[0],message:"Which env file should ripplo write RIPPLO_APP_URL, RIPPLO_ENGINE_URL, and RIPPLO_WEBHOOK_SECRET to?"});return n!=="__custom__"?n:ms({message:"Path to env file (relative to .ripplo/, e.g. ../apps/server/.env)",validate:o=>o.trim().length>0?!0:"required"})}async function Jg(){return ms({default:"http://localhost:3000",message:"Where does your dev server run? (RIPPLO_APP_URL)",validate:e=>{try{return new URL(e),!0}catch{return"must be a valid URL"}}})}function Yg({appUrl:e,engineUrl:t,filePath:r}){Ve.mkdirSync(Fe.dirname(r),{recursive:!0});let n=Ve.existsSync(r)?Ve.readFileSync(r,"utf8"):"",o=[];if(/^RIPPLO_APP_URL=/m.test(n)||o.push(`RIPPLO_APP_URL=${e}`),/^RIPPLO_ENGINE_URL=/m.test(n)||o.push(`RIPPLO_ENGINE_URL=${t}`),/^RIPPLO_WEBHOOK_SECRET=/m.test(n)||o.push(`RIPPLO_WEBHOOK_SECRET=${Mr()}`),o.length===0)return;let i=n.length===0||n.endsWith(`
|
|
422
|
+
`)?"":`
|
|
423
|
+
`;Ve.writeFileSync(r,`${n}${i}${o.join(`
|
|
424
|
+
`)}
|
|
425
|
+
`)}import fn from"fs";import ys from"path";import*as hs from"remeda";async function ws(e){let{ids:t,requireImplemented:r}=e,n=process.cwd(),o=await I(n);o.ok||(process.stderr.write(`Compilation failed: ${o.error}
|
|
426
|
+
`),process.stderr.write(`${E("create","DSL authoring + lint rules")}
|
|
427
|
+
`),process.exit(1)),await de({cwd:n,result:o.result});let i=Le(o.result),s=t.length===0?i.diagnostics:i.diagnostics.filter(w=>t.includes(w.test)),a=hs.groupBy(s,w=>w.test);Object.entries(a).forEach(([w,h])=>{process.stderr.write(`
|
|
428
|
+
${w}
|
|
429
|
+
`),h.forEach(S=>{let C=S.step==null?"":` at "${S.step}"`;process.stderr.write(` [${S.rule}]${C}
|
|
430
|
+
`),process.stderr.write(` ${S.message}
|
|
431
|
+
`)})});let l=new Set(o.builder.getUnimplemented().tests),c=r.filter(w=>l.has(w));c.length>0&&(process.stderr.write(`
|
|
432
|
+
not-implemented
|
|
433
|
+
`),c.forEach(w=>{process.stderr.write(` ${w} is still marked .notImplemented()
|
|
434
|
+
`)}));let d=ey(n);d.length>0&&(process.stderr.write(`
|
|
435
|
+
preconditions
|
|
436
|
+
`),d.forEach(w=>{process.stderr.write(` [hardcoded-identifier] ${w.file}
|
|
437
|
+
`),process.stderr.write(` ${w.message}
|
|
438
|
+
`)}));let u=s.length+c.length+d.length;u>0&&(process.stderr.write(`
|
|
439
|
+
${String(u)} error(s)
|
|
440
|
+
`),Xg({diagnostics:s,hardcodeWarnings:d,stillStubbed:c}),process.exit(1));let f=o.result.tests.length,b=t.length===0?"all tests":`${String(t.length)} test(s)`;process.stdout.write(`\u2713 ripplo lint: ${b} passed (${String(f)} compiled, lockfile written)
|
|
441
|
+
`)}function Xg({diagnostics:e,hardcodeWarnings:t,stillStubbed:r}){let n=new Set;(e.length>0||r.length>0)&&n.add("create"),t.length>0&&n.add("explore"),n.forEach(o=>process.stderr.write(`${E(o)}
|
|
442
|
+
`))}var Qg=/['"`][\w.+-]+@[\w.-]+\.[a-z]{2,}['"`]/i,Zg=/['"`][0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}['"`]/i;function ey(e){let t=ys.join(e,".ripplo","preconditions");return fn.existsSync(t)?fn.readdirSync(t).filter(n=>n.endsWith(".ts")).flatMap(n=>ty(ys.join(t,n))):[]}function ty(e){let t=fn.readFileSync(e,"utf8"),r=t.includes("ctx.uniqueEmail")||t.includes("ctx.uniqueId"),n=[],o=Qg.exec(t);o!=null&&!r&&n.push({file:e,message:`hardcoded email literal ${o[0]} \u2014 use ctx.uniqueEmail() so parallel runs don't collide`});let i=Zg.exec(t);return i!=null&&!r&&n.push({file:e,message:`hardcoded UUID-like literal ${i[0]} \u2014 use ctx.uniqueId() so parallel runs don't collide`}),n}async function bs(e){let t=fe();await ge(t);let{results:r,summary:n}=await Wt({config:t,ids:e});process.stdout.write(`${n}
|
|
443
|
+
`);let o=r.some(i=>i.summary.includes("FAILED")||i.summary.includes("ERROR"));o&&(process.stderr.write(`Artifacts in .ripplo/debug/<runId>/ \u2014 read before re-running.
|
|
444
|
+
`),process.stderr.write(`${E("debug")}
|
|
445
|
+
`)),process.exit(o?1:0)}async function Ss(){let e=process.cwd(),t=X(e);try{let r=await Ce(t.cwd,t),n=r.compiled.tests.length,o=Object.keys(r.compiled.preconditions).length;process.stdout.write(`synced ${String(n)} tests, ${String(o)} preconditions to dev session ${r.devSessionId}
|
|
446
|
+
`)}catch(r){let n=r instanceof Error?r.message:String(r);process.stderr.write(`ripplo sync failed: ${n}
|
|
447
|
+
`),process.stderr.write(`${E("setup","verify auth + server reachability")}
|
|
448
|
+
`),process.exit(1)}}import yn from"fs";import{createClient as dy}from"graphql-sse";import{graphql as Ht}from"gql.tada";import{print as Ps}from"graphql";import at from"fs";var ry="dev.pid";function vs(e){return Ze(e,ry)}function ks(e){let t=vs(e);if(!at.existsSync(t))return!1;let r=at.readFileSync(t,"utf8").trim(),n=Number.parseInt(r,10);if(!Number.isFinite(n)||n<=0)return!1;try{return process.kill(n,0),!0}catch{return!1}}function Rs(e){Ir(e);let t=vs(e);at.writeFileSync(t,String(process.pid));let r=!1;return()=>{if(!r){r=!0;try{let n=at.readFileSync(t,"utf8").trim();Number.parseInt(n,10)===process.pid&&at.unlinkSync(t)}catch{}}}}import ny from"fs";function lt(e){return Ze(e,"hooks-paused")}function V(e){return ny.existsSync(lt(e))?!1:ks(e)}import{availableParallelism as oy}from"os";import iy from"p-limit";var sy=Math.min(10,oy()/2),ay=iy(sy),gn=new Set;async function xs(e){if(!gn.has(e.runId)){gn.add(e.runId);try{await ay(()=>ly(e))}finally{gn.delete(e.runId)}}}async function ly({agentProfileDescription:e,agentProfileId:t,config:r,cwd:n,runId:o,workflowId:i,workflowSlug:s}){let a=await xe({headed:!1});try{await Tr({maxRuns:100});let l=n!=null&&s!=null?await cy({cwd:n,workflowSlug:s}):void 0;await Kr({agentProfileDescription:e,agentProfileId:t,baseUrl:r.appUrl,browser:a,config:r,headed:!1,preconditionNames:l,runId:o,webhookSecret:r.webhookSecret,workflowId:i})}catch(l){g.error(l,"Runner error")}finally{await a.close()}}async function cy({cwd:e,workflowSlug:t}){let r=await I(e);if(!r.ok)return;let n=r.result.tests.find(o=>o.slug===t);if(n!=null)return n.preconditions}var uy=3e4,py=Ht(`
|
|
449
|
+
subscription RunRequestedWatch($devSessionId: String!) {
|
|
450
|
+
runRequested(devSessionId: $devSessionId) {
|
|
451
|
+
agentProfileDescription
|
|
452
|
+
agentProfileId
|
|
453
|
+
runId
|
|
454
|
+
workflowId
|
|
455
|
+
workflowSlug
|
|
456
456
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
457
|
+
}
|
|
458
|
+
`),my=Ht(`
|
|
459
|
+
subscription HooksPausedWatch($projectId: String!) {
|
|
460
|
+
hooksPausedRequested(projectId: $projectId) {
|
|
461
|
+
paused
|
|
462
|
+
projectId
|
|
462
463
|
}
|
|
463
464
|
}
|
|
464
|
-
`),
|
|
465
|
-
|
|
466
|
-
|
|
465
|
+
`),fy=Ht(`
|
|
466
|
+
mutation HeartbeatDevSessionWatch($id: String!) {
|
|
467
|
+
heartbeatDevSession(id: $id) {
|
|
467
468
|
id
|
|
468
|
-
status
|
|
469
|
-
results {
|
|
470
|
-
id
|
|
471
|
-
status
|
|
472
|
-
duration
|
|
473
|
-
passCount
|
|
474
|
-
failCount
|
|
475
|
-
warnCount
|
|
476
|
-
summary
|
|
477
|
-
traceEntries {
|
|
478
|
-
title
|
|
479
|
-
status
|
|
480
|
-
detail
|
|
481
|
-
duration
|
|
482
|
-
assertions {
|
|
483
|
-
description
|
|
484
|
-
status
|
|
485
|
-
detail
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
469
|
}
|
|
490
470
|
}
|
|
491
|
-
`)
|
|
492
|
-
$
|
|
493
|
-
|
|
494
|
-
${w("debug","read summary.txt, accessibility-tree, network.jsonl before guessing")}
|
|
495
|
-
|
|
496
|
-
${d}`}}catch(d){let c=d instanceof Error?d.message:String(d);return{id:l.id,runId:s,summary:`ERROR polling run ${s}: ${c}
|
|
497
|
-
${w("debug")}`}}})),i=o.map(a=>`**${a.id}:**
|
|
498
|
-
${a.summary}`).join(`
|
|
499
|
-
|
|
500
|
-
---
|
|
501
|
-
|
|
502
|
-
`);return{results:o,summary:i}}async function Kh({config:e,ids:t}){let n=await x({config:e,document:zh,variables:{projectId:e.projectId}});if(n.project==null)throw new Error("Project not found");if(n.project.devSession==null)throw new Error("No active dev session. Start one by running `ripplo` (or `npx ripplo`) in your terminal, then try again.");let r=(n.project.workflows??[]).map(o=>Jh(gl,o));return t.length===0?r.map(o=>({id:o.slug,workflowId:o.id})):t.map(o=>{let i=r.find(a=>a.slug===o);if(i==null)throw new Error(`Test "${o}" not found on server. Is the dev session running? (It watches .ripplo/ files and syncs them automatically.)`);return{id:o,workflowId:i.id}})}function Qh({config:e,id:t,runId:n}){let r=e.ripploServerUrl.replace(/:3000\b/,":3001"),o=new URL(r.endsWith("/")?r:`${r}/`);return new URL(`projects/${e.projectId}/workflows/${t}/runs/${n}`,o).toString()}async function Yh({config:e,workflowId:t}){let n=await x({config:e,document:Xh,variables:{concurrency:1,platforms:["chromium"],workflowId:t}});if(n.createRun==null)throw new Error("Failed to create run");return n.createRun.id}var Zh=2e3,yl=150;async function ek({config:e,runId:t}){let n=0;for(;n<yl;){await nk(Zh),n+=1;let o=(await x({config:e,document:Gh,variables:{id:t}})).run;if(o==null)throw new Error(`Run ${t} not found`);if(!(o.status==="pending"||o.status==="running"))return tk({results:o.results??[],runId:t,status:o.status})}return`Run ${t} timed out after polling ${String(yl)} times.`}function tk({results:e,runId:t,status:n}){let r=[`Run ${t}: ${n.toUpperCase()}`];return e.forEach(o=>{r.push(` ${o.status}: ${String(o.passCount)} passed, ${String(o.failCount)} failed (${String(o.duration??0)}ms)`),o.summary!=null&&r.push(` Summary: ${o.summary}`),o.traceEntries.forEach(i=>{let a=i.status==="passed"?Lt.tick:Lt.cross,l=i.detail==null?"":` \u2014 ${i.detail}`;r.push(` ${a} ${i.title} (${String(i.duration)}ms)${l}`),i.assertions.forEach(s=>{let d=s.status==="passed"?Lt.tick:Lt.cross,c=s.detail==null?"":` \u2014 ${s.detail}`;r.push(` ${d} ${s.description}${c}`)})})}),r.join(`
|
|
503
|
-
`)}function nk(e){return new Promise(t=>{setTimeout(t,e)})}M();z();Me();import{graphql as lk}from"gql.tada";var dk=lk(`
|
|
504
|
-
query DevSessionCheckPreflight($projectId: String!) {
|
|
505
|
-
project(id: $projectId) {
|
|
471
|
+
`),gy=Ht(`
|
|
472
|
+
mutation EndDevSessionWatch($projectId: String!, $cwd: String!) {
|
|
473
|
+
endDevSession(projectId: $projectId, cwd: $cwd) {
|
|
506
474
|
id
|
|
507
|
-
devSession {
|
|
508
|
-
id
|
|
509
|
-
}
|
|
510
475
|
}
|
|
511
476
|
}
|
|
512
|
-
`);async function
|
|
513
|
-
`),process.exit(1));let n=await
|
|
514
|
-
`),process.
|
|
515
|
-
`),
|
|
516
|
-
`),process.exit(1)
|
|
517
|
-
|
|
518
|
-
`).find(u=>u.includes("FAILED")||u.includes("ERROR"))??"unknown failure";a.set(c,(a.get(c)??0)+1)}else o++});let l=t>0?i/t*100:0;process.stdout.write(`
|
|
519
|
-
Results: ${String(o)} passed, ${String(i)} failed out of ${String(t)} runs
|
|
520
|
-
`),process.stdout.write(`Flake rate: ${l.toFixed(1)}%
|
|
521
|
-
`),a.size>0&&(process.stdout.write(`
|
|
522
|
-
Failure patterns:
|
|
523
|
-
`),a.forEach((s,d)=>{process.stdout.write(` ${String(s)}x: ${d}
|
|
524
|
-
`)})),i>0&&process.stderr.write(`${w("flake-detect","parallel safety + race conditions")}
|
|
525
|
-
`),process.exit(i>0?1:0)}import ho from"fs";import bl from"path";import*as wl from"remeda";$e();z();async function Al(e){let{ids:t,requireImplemented:n}=e,r=process.cwd(),o=await L(r);o.ok||(process.stderr.write(`Compilation failed: ${o.error}
|
|
526
|
-
`),process.stderr.write(`${w("create","DSL authoring + lint rules")}
|
|
527
|
-
`),process.exit(1)),await me({cwd:r,result:o.result});let i=ot(o.result),a=t.length===0?i.diagnostics:i.diagnostics.filter(y=>t.includes(y.test)),l=wl.groupBy(a,y=>y.test);Object.entries(l).forEach(([y,S])=>{process.stderr.write(`
|
|
528
|
-
${y}
|
|
529
|
-
`),S.forEach(b=>{let k=b.step==null?"":` at "${b.step}"`;process.stderr.write(` [${b.rule}]${k}
|
|
530
|
-
`),process.stderr.write(` ${b.message}
|
|
531
|
-
`)})});let s=new Set(o.builder.getUnimplemented().tests),d=n.filter(y=>s.has(y));d.length>0&&(process.stderr.write(`
|
|
532
|
-
not-implemented
|
|
533
|
-
`),d.forEach(y=>{process.stderr.write(` ${y} is still marked .notImplemented()
|
|
534
|
-
`)}));let c=mk(r);c.length>0&&(process.stderr.write(`
|
|
535
|
-
preconditions
|
|
536
|
-
`),c.forEach(y=>{process.stderr.write(` [hardcoded-identifier] ${y.file}
|
|
537
|
-
`),process.stderr.write(` ${y.message}
|
|
538
|
-
`)}));let u=a.length+d.length+c.length;u>0&&(process.stderr.write(`
|
|
539
|
-
${String(u)} error(s)
|
|
540
|
-
`),ck({diagnostics:a,hardcodeWarnings:c,stillStubbed:d}),process.exit(1))}function ck({diagnostics:e,hardcodeWarnings:t,stillStubbed:n}){let r=new Set;(e.length>0||n.length>0)&&r.add("create"),t.length>0&&r.add("explore"),r.forEach(o=>process.stderr.write(`${w(o)}
|
|
541
|
-
`))}var pk=/['"`][\w.+-]+@[\w.-]+\.[a-z]{2,}['"`]/i,uk=/['"`][0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}['"`]/i;function mk(e){let t=bl.join(e,".ripplo","preconditions");return ho.existsSync(t)?ho.readdirSync(t).filter(r=>r.endsWith(".ts")).flatMap(r=>fk(bl.join(t,r))):[]}function fk(e){let t=ho.readFileSync(e,"utf8"),n=t.includes("ctx.uniqueEmail")||t.includes("ctx.uniqueId"),r=[],o=pk.exec(t);o!=null&&!n&&r.push({file:e,message:`hardcoded email literal ${o[0]} \u2014 use ctx.uniqueEmail() so parallel runs don't collide`});let i=uk.exec(t);return i!=null&&!n&&r.push({file:e,message:`hardcoded UUID-like literal ${i[0]} \u2014 use ctx.uniqueId() so parallel runs don't collide`}),r}async function Rl(e){let t=await ve();await Ce(t);let{results:n,summary:r}=await Sn({config:t,ids:e});process.stdout.write(`${r}
|
|
542
|
-
`);let o=n.some(i=>i.summary.includes("FAILED")||i.summary.includes("ERROR"));o&&(process.stderr.write(`Artifacts for this run are fresh in .ripplo/debug/<runId>/. Read them before re-running \u2014 a rerun takes ~30-60s and almost never reveals more than summary.txt + steps/<failedIndex>/dom.html + accessibility-tree.txt already do. Only re-run after you've made a change you believe will fix the failure.
|
|
543
|
-
`),process.stderr.write(`${w("debug")}
|
|
544
|
-
`)),process.exit(o?1:0)}M();import{graphql as Pt}from"gql.tada";var yk=Pt(`
|
|
545
|
-
query ScopeStatus($projectId: String!) {
|
|
477
|
+
`);async function Es(){let e=by(process.cwd()),t=e.cwd,r=await I(t);r.ok||(process.stderr.write(`ripplo: DSL compilation failed: ${r.error}
|
|
478
|
+
`),process.exit(1));let n=await ky(()=>ot({compiled:r.result,config:e,cwd:t})),o=Ft(t);o!=null&&g.info("watching branch %s in %s",o,t);let i=Rs(t),s=dy({headers:{Authorization:`Bearer ${e.token}`},retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`}),a=yy({config:e,cwd:t,devSessionId:n.devSessionId,sseClient:s}),l=hy({cwd:t,projectId:e.projectId,sseClient:s}),c=wy({config:e,devSessionId:n.devSessionId});process.stdout.write(`ripplo watch: ready as local executor for session ${n.devSessionId} (sync happens on each \`ripplo run\`; Ctrl-C to stop)
|
|
479
|
+
`);let d=async()=>{c(),a(),l(),await Promise.race([k({config:e,document:gy,variables:{cwd:e.cwd,projectId:e.projectId}}).catch(()=>{}),new Promise(u=>setTimeout(u,3e3))]),i()};process.on("SIGINT",()=>{d().finally(()=>process.exit(0))}),process.on("SIGTERM",()=>{d().finally(()=>process.exit(0))}),await new Promise(()=>{})}function yy({config:e,cwd:t,devSessionId:r,sseClient:n}){return n.subscribe({query:Ps(py),variables:{devSessionId:r}},{complete:()=>{},error:o=>{g.error(o,"runRequested subscription error")},next:o=>{let i=o.data?.runRequested;i!=null&&(process.stdout.write(`ripplo: run ${i.runId} (${i.workflowSlug})
|
|
480
|
+
`),xs({agentProfileDescription:i.agentProfileDescription??void 0,agentProfileId:i.agentProfileId??void 0,config:e,cwd:t,runId:i.runId,workflowId:i.workflowId,workflowSlug:i.workflowSlug}))}})}function hy({cwd:e,projectId:t,sseClient:r}){return r.subscribe({query:Ps(my),variables:{projectId:t}},{complete:()=>{},error:n=>{g.error(n,"hooksPaused subscription error")},next:n=>{let o=n.data?.hooksPausedRequested?.paused;if(o===!0){yn.writeFileSync(lt(e),"");return}o===!1&&yn.existsSync(lt(e))&&yn.unlinkSync(lt(e))}})}function wy({config:e,devSessionId:t}){let r=setInterval(()=>{k({config:e,document:fy,variables:{id:t}}).catch(n=>{g.warn("heartbeat failed: %s",n instanceof Error?n.message:String(n))})},uy);return()=>{clearInterval(r)}}function by(e){try{return X(e)}catch(t){let r=t instanceof Error?t.message:String(t);process.stderr.write(`${r}
|
|
481
|
+
`),process.exit(1)}}var Sy=1e3,vy=6e4;async function ky(e){let t=Date.now()+vy,r;for(;Date.now()<t;){let n=await Ry(e);if(n.ok)return n.value;if(!xy(n.message))throw n.error;r=n.error,await Py(Sy)}throw r instanceof Error?r:new Error("server never became ready")}async function Ry(e){try{return{ok:!0,value:await e()}}catch(t){let r=t instanceof Error?t.message:String(t);return{error:t,message:r,ok:!1}}}function xy(e){return e.includes("status 502")||e.includes("ECONNREFUSED")||e.includes("Failed to connect")||e.includes("fetch failed")}function Py(e){return new Promise(t=>setTimeout(t,e))}import{graphql as ct}from"gql.tada";var Ey=ct(`
|
|
482
|
+
query ScopeStatus($projectId: String!, $cwd: String!) {
|
|
546
483
|
project(id: $projectId) {
|
|
547
484
|
id
|
|
548
|
-
devSession {
|
|
485
|
+
devSession(cwd: $cwd) {
|
|
549
486
|
id
|
|
550
487
|
scopeItems {
|
|
551
488
|
id
|
|
@@ -561,11 +498,11 @@ ${String(u)} error(s)
|
|
|
561
498
|
}
|
|
562
499
|
}
|
|
563
500
|
}
|
|
564
|
-
`),
|
|
565
|
-
query ScopeWorkflowBySlug($projectId: String!, $slug: String!) {
|
|
501
|
+
`),Cy=ct(`
|
|
502
|
+
query ScopeWorkflowBySlug($projectId: String!, $cwd: String!, $slug: String!) {
|
|
566
503
|
project(id: $projectId) {
|
|
567
504
|
id
|
|
568
|
-
devSession {
|
|
505
|
+
devSession(cwd: $cwd) {
|
|
569
506
|
id
|
|
570
507
|
workflows(where: { slug: $slug }) {
|
|
571
508
|
id
|
|
@@ -574,9 +511,9 @@ ${String(u)} error(s)
|
|
|
574
511
|
}
|
|
575
512
|
}
|
|
576
513
|
}
|
|
577
|
-
`),
|
|
578
|
-
mutation ScopeAddAgent($projectId: String!, $workflowSlugs: [String!]!) {
|
|
579
|
-
addAgentScopeItems(projectId: $projectId, workflowSlugs: $workflowSlugs) {
|
|
514
|
+
`),Ty=ct(`
|
|
515
|
+
mutation ScopeAddAgent($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
516
|
+
addAgentScopeItems(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
580
517
|
id
|
|
581
518
|
workflow {
|
|
582
519
|
id
|
|
@@ -584,63 +521,46 @@ ${String(u)} error(s)
|
|
|
584
521
|
}
|
|
585
522
|
}
|
|
586
523
|
}
|
|
587
|
-
`),
|
|
524
|
+
`),Ay=ct(`
|
|
588
525
|
mutation ScopeLink($id: ID!, $workflowId: String!) {
|
|
589
526
|
linkScopeItem(id: $id, workflowId: $workflowId) {
|
|
590
527
|
id
|
|
591
528
|
}
|
|
592
529
|
}
|
|
593
|
-
`)
|
|
530
|
+
`),$y=ct(`
|
|
594
531
|
mutation ScopeRemoveMany($ids: [ID!]!) {
|
|
595
532
|
removeScopeItems(ids: $ids)
|
|
596
533
|
}
|
|
597
|
-
`);async function
|
|
598
|
-
`);return}if(
|
|
599
|
-
`);return}let
|
|
600
|
-
`)})}async function
|
|
601
|
-
`)}
|
|
602
|
-
`)}async function
|
|
603
|
-
`)}async function
|
|
604
|
-
`),process.stderr.write(
|
|
605
|
-
`),process.
|
|
606
|
-
`),process.exit(1))
|
|
607
|
-
`);
|
|
608
|
-
`)}
|
|
609
|
-
`)
|
|
610
|
-
`).filter(
|
|
611
|
-
`).filter(r=>r.length>0)
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
${w("scope")}
|
|
617
|
-
${w("create")}
|
|
618
|
-
`)}import wn from"fs";import Uk from"os";import Dl from"path";function Pe(e){process.stderr.write(`${e}
|
|
619
|
-
`),process.exit(2)}async function Bl(){if((await Y()).tool_name!=="ExitPlanMode"||!Z(process.cwd()))return;let t=$k();if(t==null)return;let n=wn.readFileSync(t,"utf8");/\.ripplo\/tests|Tests to implement|No e2e coverage needed/.test(n)||Pe(`Plan must cite ripplo test stubs before exiting plan mode.
|
|
620
|
-
Add a "Tests to implement" section to the plan listing .ripplo/tests/<id>.ts files for every user flow touched. Stub template:
|
|
621
|
-
|
|
622
|
-
export const myFlow = test("my-flow").name("...").requires({...}).notImplemented();
|
|
623
|
-
|
|
624
|
-
If this plan genuinely touches no user-facing behavior (pure refactor, internal tooling, type-only change), add a "No e2e coverage needed: <reason>" line to the plan and re-exit.
|
|
625
|
-
It is YOUR job to keep scope accurate and sufficiently broad \u2014 err on the side of breadth, up to ~50 tests.
|
|
626
|
-
${w("explore")}`)}function $k(){let e=Dl.join(Uk.homedir(),".claude","plans");return wn.existsSync(e)?wn.readdirSync(e).filter(n=>n.endsWith(".md")).map(n=>Dl.join(e,n)).map(n=>({full:n,mtime:wn.statSync(n).mtimeMs})).sort((n,r)=>r.mtime-n.mtime)[0]?.full??null:null}z();async function Vl(){if((await Y()).mode!=="plan")return;let t=process.cwd();if(!ee(t)||!Z(t))return;let n=await L(t);if(!n.ok)return;let{tests:r}=n.builder.getUnimplemented();process.stderr.write('Scope this plan: identify which user flows it touches, then for each one either\n \u2022 add existing test(s) from .ripplo/tests/ to scope (`npx ripplo scope add <test-ids..>` \u2014 variadic) so Stop validates they still pass, or\n \u2022 stub new `.notImplemented()` test(s) under .ripplo/tests/ and bulk scope-add them.\nList the test ids under a "Tests to implement" section in your plan \u2014 ExitPlanMode blocks otherwise.\n'),r.length>0&&(process.stderr.write(`Existing stubs (already .notImplemented()):
|
|
627
|
-
`),r.forEach(o=>process.stderr.write(` ${o}
|
|
628
|
-
`)))}import Dk from"path";import Wl from"picomatch";z();async function Fl(){let t=(await Y()).tool_input?.file_path;if(t==null)return;let n=process.cwd();if(!ee(n)||!Z(n))return;let r=Dk.relative(n,t);if(r.startsWith(".."))return;let{ignorePaths:o,watchPaths:i}=await He(n),a=Wl([...i]),l=Wl([...o]);if(!a(r)||l(r))return;let s=await L(n);if(!s.ok)return;let{tests:d}=s.builder.getUnimplemented();d.length!==0&&process.stderr.write(`Reminder: .notImplemented() stubs still present \u2014 tests: ${d.join(", ")}
|
|
629
|
-
`)}import qk from"path";$e();M();import{graphql as Jk}from"gql.tada";z();Me();An();var zk=Jk(`
|
|
630
|
-
mutation AutoScopeAdd($projectId: String!, $workflowSlugs: [String!]!) {
|
|
631
|
-
addAgentScopeItems(projectId: $projectId, workflowSlugs: $workflowSlugs) {
|
|
534
|
+
`);async function Cs(e){let t=fe();await ge(t);let n=(await k({config:t,document:Ey,variables:{cwd:t.cwd,projectId:t.projectId}})).project?.devSession?.scopeItems??[];if(e.format==="json"){process.stdout.write(`${JSON.stringify(n,null,2)}
|
|
535
|
+
`);return}if(n.length===0){process.stdout.write("No scope items. Add via `ripplo scope add <test-ids..>` (variadic) or from the dashboard.\n");return}n.forEach(o=>{let i=o.workflow;if(i==null){process.stdout.write(` [intent] (${o.id}) ${o.label??""}
|
|
536
|
+
`);return}let s=i.spec==null?"stub":"implemented";process.stdout.write(` [${s}] (${o.id}) ${i.slug} \u2014 ${i.name}
|
|
537
|
+
`)})}async function Ts({testIds:e}){let t=fe();await ge(t),await Ce(t.cwd,t);let n=(await k({config:t,document:Ty,variables:{cwd:t.cwd,projectId:t.projectId,workflowSlugs:[...e]}})).addAgentScopeItems??[];if(n.length===0){process.stdout.write(`No scope items added.
|
|
538
|
+
`);return}let o=n.map(i=>i.workflow?.slug??"?").join(", ");process.stdout.write(`Added ${String(n.length)} scope item(s): ${o}
|
|
539
|
+
`)}async function As({id:e,testId:t}){let r=fe();await ge(r),await Ce(r.cwd,r);let n=await Iy({cfg:r,slug:t});await k({config:r,document:Ay,variables:{id:e,workflowId:n}}),process.stdout.write(`Linked scope item ${e} to ${t}
|
|
540
|
+
`)}async function $s({ids:e}){let t=fe();await ge(t);let n=(await k({config:t,document:$y,variables:{ids:[...e]}})).removeScopeItems??0;process.stdout.write(`Removed ${String(n)} scope item(s)
|
|
541
|
+
`)}async function Iy({cfg:e,slug:t}){let n=(await k({config:e,document:Cy,variables:{cwd:e.cwd,projectId:e.projectId,slug:t}})).project?.devSession?.workflows?.[0];return n==null&&(process.stderr.write(`No workflow found with id "${t}". Create a stub first via the testing DSL.
|
|
542
|
+
`),process.stderr.write(`${E("create")}
|
|
543
|
+
`),process.exit(1)),n.id}async function Is(e){let t=process.cwd(),r=await I(t);r.ok||(process.stderr.write(`Compilation failed: ${r.error}
|
|
544
|
+
`),process.exit(1));let{tests:n}=r.builder.getUnimplemented();if(e.format==="summary"){n.length>0&&process.stdout.write(`tests: ${n.join(", ")}
|
|
545
|
+
`);return}let o={tests:n.map(i=>({id:i,implemented:!1}))};process.stdout.write(`${JSON.stringify(o,null,2)}
|
|
546
|
+
`)}import{z as jy}from"zod";function O(e,t){let r=jy.custom(n=>typeof n=="object"&&n!==null&&"hook_event_name"in n&&n.hook_event_name===e);return{event:e,run:async n=>await t(r.parse(n))??void 0}}import{createHash as iT}from"crypto";import js from"picomatch";function Ny(e){return ne(["diff","--name-only","HEAD"],e).split(`
|
|
547
|
+
`).filter(t=>t.length>0)}function Ns({cwd:e,ignoreGlobs:t,watchGlobs:r}){let n=js([...r]),o=js([...t]);return Ny(e).filter(i=>n(i)&&!o(i))}function qt(e,...t){return ne(["diff","--name-only","HEAD","--",...t],e).split(`
|
|
548
|
+
`).filter(r=>r.length>0)}import{createHash as Oy}from"crypto";import{mkdirSync as Ly,readFileSync as Os,writeFileSync as Dy}from"fs";import hn from"path";var _y=[".ts",".tsx",".js",".jsx"];function Me(e){let t=Oy("sha256");return t.update(ne(["rev-parse","HEAD"],e)),t.update("\0"),t.update(ne(["diff","HEAD"],e)),t.update("\0"),ne(["ls-files","--others","--exclude-standard"],e).split(`
|
|
549
|
+
`).filter(n=>n.length>0).filter(n=>_y.some(o=>n.endsWith(o))).toSorted((n,o)=>n.localeCompare(o)).forEach(n=>{t.update(n),t.update("\0"),t.update(Uy(hn.join(e,n))),t.update("\0")}),t.digest("hex")}function We(e,t){try{return Os(Ls(e,t),"utf8").trim()}catch{return null}}function He(e,t,r){let n=Ls(e,t);Ly(hn.dirname(n),{recursive:!0}),Dy(n,r)}function Ls(e,t){return hn.join(e,".ripplo",".local",`${t}.hash`)}function Uy(e){try{return Os(e)}catch{return Buffer.alloc(0)}}function Re(){return{ignorePaths:ke,watchPaths:rn}}import Vy from"fs";import Fy from"path";function _(e){return Vy.existsSync(Fy.join(e,".ripplo"))}var Ds=O("UserPromptSubmit",e=>{let{cwd:t}=e;if(!_(t)||!V(t))return;let r=Me(t);if(We(t,"coverage-nudge")===r)return;let{ignorePaths:n,watchPaths:o}=Re(),i=Ns({cwd:t,ignoreGlobs:n,watchGlobs:o});if(He(t,"coverage-nudge",r),!(i.length===0||qt(t,".ripplo/tests",".ripplo/preconditions",".ripplo/observers").length>0))return{hookSpecificOutput:{additionalContext:`SCOPE DRIFT: ${String(i.length)} app file(s) changed without .ripplo/tests updates. ${E("scope")}`,hookEventName:"UserPromptSubmit"}}});import Bt from"fs";import My from"os";import _s from"path";var Us=O("PreToolUse",e=>{if(e.tool_name!=="ExitPlanMode"||!V(e.cwd))return;let t=Wy();if(t==null)return;let r=Bt.readFileSync(t,"utf8");if(!/\.ripplo\/tests|Tests to implement|No e2e coverage needed/.test(r))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`Plan must cite ripplo test stubs. Add a "Tests to implement" section listing .ripplo/tests/<id>.ts per affected flow, OR add "No e2e coverage needed: <reason>" if this plan touches no user-facing behavior. ${E("explore")}`}}});function Wy(){let e=_s.join(My.homedir(),".claude","plans");return Bt.existsSync(e)?Bt.readdirSync(e).filter(r=>r.endsWith(".md")).map(r=>_s.join(e,r)).map(r=>({full:r,mtime:Bt.statSync(r).mtimeMs})).sort((r,n)=>n.mtime-r.mtime)[0]?.full??null:null}var Vs=O("UserPromptSubmit",async e=>{if(e.permission_mode!=="plan"||!_(e.cwd)||!V(e.cwd))return;let t=await I(e.cwd);if(!t.ok)return;let{tests:r}=t.builder.getUnimplemented(),n=['Plan must include "Tests to implement" with .ripplo/tests/<id>.ts per affected flow (ExitPlanMode blocks otherwise).'];return r.length>0&&n.push(`Existing stubs: ${r.join(", ")}`),{hookSpecificOutput:{additionalContext:n.join(`
|
|
550
|
+
`),hookEventName:"UserPromptSubmit"}}});import Hy from"path";import Fs from"picomatch";import{z as Ms}from"zod";var qy=Ms.looseObject({file_path:Ms.string()}),Ws=O("PostToolUse",async e=>{let t=qy.safeParse(e.tool_input);if(!t.success)return;let r=t.data.file_path,{cwd:n}=e;if(!_(n)||!V(n))return;let o=Hy.relative(n,r);if(o.startsWith(".."))return;let{ignorePaths:i,watchPaths:s}=Re(),a=Fs([...s]),l=Fs([...i]);if(!a(o)||l(o))return;let c=await I(n);if(!c.ok)return;let{tests:d}=c.builder.getUnimplemented();if(d.length!==0)return{hookSpecificOutput:{additionalContext:`Reminder: .notImplemented() stubs still present \u2014 tests: ${d.join(", ")}`,hookEventName:"PostToolUse"}}});import By from"path";import{graphql as zy}from"gql.tada";import{z as Hs}from"zod";var Gy=Hs.looseObject({file_path:Hs.string()}),Ky=zy(`
|
|
551
|
+
mutation AutoScopeAdd($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
552
|
+
addAgentScopeItems(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
632
553
|
id
|
|
633
554
|
}
|
|
634
555
|
}
|
|
635
|
-
`)
|
|
636
|
-
${
|
|
556
|
+
`),qs=O("PostToolUse",async e=>{let t=Gy.safeParse(e.tool_input);if(!t.success)return;let r=t.data.file_path;if(!/\/\.ripplo\/.*\.ts$/.test(r))return;let{cwd:n}=e;if(!_(n)||!V(n))return;let o=await I(n);if(!o.ok)return{decision:"block",reason:`Compilation failed: ${o.error}
|
|
557
|
+
${E("create","DSL authoring + lint rules")}`};await de({cwd:n,result:o.result}),_e({cwd:n});let{diagnostics:i}=Le(o.result);return i.length===0?Jy({compileResult:o,cwd:n,file:r}):{decision:"block",reason:`${i.map(a=>{let l=a.step==null?"":` at "${a.step}"`;return` [${a.rule}]${l} ${a.test}: ${a.message}`}).join(`
|
|
637
558
|
`)}
|
|
638
|
-
${
|
|
639
|
-
|
|
640
|
-
query PreEditScopeGate($projectId: String!) {
|
|
559
|
+
${E("create")}`}});async function Jy({compileResult:e,cwd:t,file:r}){let n=Yy(r);if(n==null)return;let o;try{o=X(t)}catch{return}if(await ot({compiled:e.result,config:o,cwd:t}).catch(l=>(g.warn("auto-sync failed: %s",l instanceof Error?l.message:String(l)),null))==null)return;let s=await k({config:o,document:Ky,variables:{cwd:o.cwd,projectId:o.projectId,workflowSlugs:[n]}}).catch(l=>(g.warn("auto-scope failed: %s",l instanceof Error?l.message:String(l)),null));if(!(s==null||(s.addAgentScopeItems??[]).length===0))return{hookSpecificOutput:{additionalContext:`Auto-scoped ${n} (edited test).`,hookEventName:"PostToolUse"}}}function Yy(e){if(!/\/\.ripplo\/tests\/[^/]+\.ts$/.test(e))return null;let t=By.basename(e,".ts");return t==="index"?null:t}import{z as Gs}from"zod";import{existsSync as Xy,mkdirSync as Qy,rmSync as dA,writeFileSync as Zy}from"fs";import wn from"path";function Bs(e,t,r){let n=zs(e,t,r);Qy(wn.dirname(n),{recursive:!0}),Zy(n,"")}function zt(e,t,r){return Xy(zs(e,t,r))}function eh(e,t){return wn.join(e,".ripplo",".local","skills-loaded",t)}function zs(e,t,r){return wn.join(eh(e,t),r)}var th=Gs.looseObject({command:Gs.string()}),rh=/\bripplo run\b/,nh="debug",Ks=O("PreToolUse",e=>{if(e.tool_name!=="Bash")return;let t=th.safeParse(e.tool_input);if(!t.success||!rh.test(t.data.command))return;let{cwd:r}=e;if(!(!_(r)||!V(r))&&!zt(r,e.session_id,nh))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:"Running `ripplo run` requires the `/ripplo:debug` skill loaded first. Load `/ripplo:debug` then retry \u2014 it carries the artifact-read order, the 3-strike rule, and the no-grep-piping guidance for run failures."}}});import oh from"path";import{z as Js}from"zod";var ih=new Set(["Edit","Write","NotebookEdit"]),sh=Js.looseObject({file_path:Js.string()}),ah="create",Ys=O("PreToolUse",e=>{if(!ih.has(e.tool_name))return;let t=sh.safeParse(e.tool_input);if(!t.success)return;let{cwd:r}=e;if(!_(r)||!V(r))return;let n=oh.relative(r,t.data.file_path);if(!(n.startsWith("..")||n!==".ripplo"&&!n.startsWith(".ripplo/"))&&!zt(r,e.session_id,ah))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`Editing \`.ripplo/\` files (${n}) requires the \`/ripplo:create\` skill loaded first. Load \`/ripplo:create\` then retry \u2014 it carries the DSL builder shape, lint rules, and the parallelization guidance you'll need.`}}});import lh from"path";import Xs from"picomatch";import{graphql as ch}from"gql.tada";import{z as Qs}from"zod";var dh=new Set(["Edit","Write","NotebookEdit"]),uh=Qs.looseObject({file_path:Qs.string()}),ph=ch(`
|
|
560
|
+
query PreEditScopeGate($projectId: String!, $cwd: String!) {
|
|
641
561
|
project(id: $projectId) {
|
|
642
562
|
id
|
|
643
|
-
devSession {
|
|
563
|
+
devSession(cwd: $cwd) {
|
|
644
564
|
id
|
|
645
565
|
scopeItems {
|
|
646
566
|
id
|
|
@@ -648,18 +568,11 @@ ${w("create")}`)}async function Xk({compileResult:e,cwd:t,file:n}){let r=Gk(n);i
|
|
|
648
568
|
}
|
|
649
569
|
}
|
|
650
570
|
}
|
|
651
|
-
`)
|
|
652
|
-
|
|
653
|
-
1. Stub .notImplemented() tests under .ripplo/tests/ for the user flow(s) this change affects, then \`npx ripplo scope add <ids...>\` (variadic).
|
|
654
|
-
2. If this change genuinely touches no user-facing behavior (pure refactor, internal tooling, type-only), explicitly acknowledge that in your next response and retry \u2014 the hook will re-fire until scope is populated or the user pauses hooks in the dev dashboard.
|
|
655
|
-
Use \`npx ripplo scope remove <id>\` if a scoped test turns out not to apply \u2014 do not use it as a Stop-gate shortcut.
|
|
656
|
-
${w("explore")}
|
|
657
|
-
${w("scope")}
|
|
658
|
-
${w("create")}`}M();z();Me();import{graphql as oS}from"gql.tada";var iS=oS(`
|
|
659
|
-
query ScopeReminder($projectId: String!) {
|
|
571
|
+
`),Zs=O("PreToolUse",async e=>{if(!dh.has(e.tool_name))return;let t=uh.safeParse(e.tool_input);if(!t.success)return;let{cwd:r}=e;if(!_(r)||!V(r))return;let n=lh.relative(r,t.data.file_path);if(!(n.startsWith("..")||n===".ripplo"||n.startsWith(".ripplo/")||!mh(n)||await fh(r)))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`Scope empty; edit touches app code (${n}). Stub a test or \`scope add\` an existing one before proceeding \u2014 or acknowledge "no user-facing behavior" if pure refactor. Hook re-fires until scope is populated (or hooks paused via the web UI). ${Bi(["scope","create"])}`}}});function mh(e){let{ignorePaths:t,watchPaths:r}=Re(),n=Xs([...r]),o=Xs([...t]);return n(e)&&!o(e)}async function fh(e){let t;try{t=X(e)}catch{return!0}let r=await k({config:t,document:ph,variables:{cwd:t.cwd,projectId:t.projectId}}).catch(()=>null);return r==null?!0:(r.project?.devSession?.scopeItems??[]).length>0}import{graphql as gh}from"gql.tada";var yh=gh(`
|
|
572
|
+
query ScopeReminder($projectId: String!, $cwd: String!) {
|
|
660
573
|
project(id: $projectId) {
|
|
661
574
|
id
|
|
662
|
-
devSession {
|
|
575
|
+
devSession(cwd: $cwd) {
|
|
663
576
|
id
|
|
664
577
|
scopeItems {
|
|
665
578
|
id
|
|
@@ -672,23 +585,13 @@ ${w("create")}`}M();z();Me();import{graphql as oS}from"gql.tada";var iS=oS(`
|
|
|
672
585
|
}
|
|
673
586
|
}
|
|
674
587
|
}
|
|
675
|
-
`)
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
2. Or, if a scoped test truly doesn't apply, use \`npx ripplo scope remove <id>\` \u2014 never as a Stop-gate shortcut.
|
|
680
|
-
It is YOUR job to keep scope accurate and sufficiently broad. Under-scoping is the default failure mode.
|
|
681
|
-
Skills: ${w("explore")} ${w("scope")} ${w("create")}
|
|
682
|
-
`),xe(e,"scope-reminder",t);return}let l=a.map(s=>{let d=s.workflow;return d==null?` [intent] (${s.id}) ${s.label??""}`:` [${d.spec==null?"stub":"implemented"}] (${s.id}) ${d.slug}`});process.stderr.write(`RIPPLO SCOPE (${String(a.length)} items): each is a commitment that the app works AND a test passes this session. Stop hook will block otherwise.
|
|
683
|
-
${l.join(`
|
|
684
|
-
`)}
|
|
685
|
-
If your next change touches existing tests' user flows, \`npx ripplo scope add <test-ids..>\` (variadic) to mark them for Stop validation. If it introduces new flows, stub \`.notImplemented()\` tests and bulk scope-add them. \`scope remove <ids..>\` only for items genuinely out of scope \u2014 not as a Stop-gate shortcut.
|
|
686
|
-
${w("scope")}
|
|
687
|
-
`),xe(e,"scope-reminder",t)}var aS="# Ripplo \u2014 always-on session context\n\nRipplo closes the loop on full-stack app development in this repo: every user-facing change ships with a deterministic, backend-aware test that proves it works end-to-end. Tests are how you and the user define success criteria \u2014 preconditions set the starting state, observers assert backend mutations, coverage IDs ensure the app's surface area is covered. The `ripplo` plugin ships task-specific skills; load the right one from the triage table below. If in doubt, start with `/ripplo:explore` or `/ripplo:create`.\n\n## Skill triage\n\n- `/ripplo:setup` \u2014 initializing Ripplo in a project; `npx ripplo doctor` reports the engine endpoint missing.\n- `/ripplo:explore` \u2014 planning/stubbing test coverage for a new project or new feature area.\n- `/ripplo:scope` \u2014 managing the working set of tests this session is responsible for (`scope add/status/remove`).\n- `/ripplo:create` \u2014 authoring a single new test spec for a user flow.\n- `/ripplo:run` \u2014 executing existing tests (`npx ripplo run`).\n- `/ripplo:debug` \u2014 a run failed; read artifacts in `.ripplo/debug/<runId>/` before re-running.\n- `/ripplo:flake-detect` \u2014 only when you have evidence of intermittent failure; parallelizes N runs.\n\n## Universal rules (apply regardless of sub-task)\n\n- **Two funnels.** Definitions funnel into `createRipplo(config, { preconditions, observers, tests })` in `.ripplo/ripplo.ts`. Implementations funnel into `createEngine(ripplo, { preconditions, observers })` in `apps/server/src/test/engine.ts`. Never call either elsewhere. TS enforces exhaustiveness between the two.\n- **Scope is your job, not the user's.** For any non-trivial change, enumerate every user flow it could affect and either `scope add` existing tests or stub `.notImplemented()` tests. Don't wait to be told.\n- **`scope remove` is never for size or effort.** Valid only when an item is genuinely out of scope (wrong flow, duplicate, user said \"not this session,\" feature cut). \"Too many stubs\" means parallelize with subagents, not trim. Don't present \"implement all vs. remove some\" as a neutral choice to the user.\n- **\"Done\" = the app code delivers the user-facing behavior AND a passing test proves it.** Shipping the feature without a test isn't done; writing a test against broken UI/API isn't done. Both halves, together.\n- **Never weaken a test to make it pass.** No `contains`/regex in place of exact text, no removing assertions, no fabricated locators. If the app lacks an accessible name, add one to the app \u2014 don't fall back to `testId()`. If the test reveals an app bug, report with evidence.\n- **3-strike rule.** Same failure after 3 targeted fixes \u2192 stop and report to the user. Repeated failure on the same step almost always means the diagnosis is wrong, not that one more try will land.\n- **Artifacts first, re-run last.** A failed run already produced DOM, a11y tree, console, network, screenshots under `.ripplo/debug/<runId>/` (the CLI prints the exact path for each failed run). Read those files. Never pipe `npx ripplo run` through `grep`/`tail`/`head` to find the failed step, and don't re-run to reshape stdout. Form a specific hypothesis citing an artifact line, make ONE change, re-run once to verify.\n- **`.ripplo/ripplo.lock` is committed and never hand-edited.** `npx ripplo lint` regenerates it. Pre-commit runs `ripplo compile --check` and blocks stale commits.\n- **Scratch files live in `.ripplo/.local/`.** Never write loose files in `.ripplo/`.\n- **`uiOnly: true` is not a stub.** Observer wiring is in-scope for mutation flows; don't use it to silence observer lint.\n- **DSL locators are semantic.** No `css` / `placeholder` / `waitFor` / `group` \u2014 keep tests non-brittle.\n- **New backend assertion?** Declare in `.ripplo/observers/index.ts`, then implement in `apps/server/src/test/engine.ts` (TS will flag the missing impl).\n\n## Key files\n\n- `.ripplo/ripplo.ts` \u2014 `createRipplo` call; registries for preconditions, observers, tests.\n- `.ripplo/{preconditions,observers,tests}/index.ts` \u2014 registry aggregators.\n- `apps/server/src/test/engine.ts` \u2014 single impl funnel via `createEngine`.\n- `packages/testing/README.md` \u2014 DSL reference.\n";function td(){return ee(process.cwd())&&process.stdout.write(aS),Promise.resolve()}import{execFileSync as sS}from"child_process";import lS from"path";import To from"process";$e();M();import{graphql as dS}from"gql.tada";import{z as Rn}from"zod";z();Me();var cS=dS(`
|
|
688
|
-
query ScopeEnforce($projectId: String!) {
|
|
588
|
+
`),ea=O("UserPromptSubmit",async e=>{let{cwd:t}=e;if(!_(t)||!V(t))return;let r=Me(t);if(We(t,"scope-reminder")===r)return;let n;try{n=X(t)}catch{return}let o=await k({config:n,document:yh,variables:{cwd:n.cwd,projectId:n.projectId}}).catch(()=>null);if(o==null)return;He(t,"scope-reminder",r);let i=o.project?.devSession?.scopeItems??[];return{hookSpecificOutput:{additionalContext:i.length===0?`RIPPLO SCOPE: empty. ${E("scope")}`:`RIPPLO SCOPE (${String(i.length)}):
|
|
589
|
+
${i.map(a=>{let l=a.workflow;return l==null?` [intent] (${a.id}) ${a.label??""}`:` [${l.spec==null?"stub":"implemented"}] (${a.id}) ${l.slug}`}).join(`
|
|
590
|
+
`)}`,hookEventName:"UserPromptSubmit"}}});var hh="# Ripplo \u2014 always-on session context\n\nEvery user-facing change in this repo ships with a deterministic, backend-aware test that proves it works end-to-end.\n\n## Load the right skill before acting \u2014 this is critical\n\nThe skills below carry the procedural detail you need to do Ripplo work correctly: precondition isolation, observer budget tiers, coverage IDs, scope discipline, artifact-read order on failures, parallelization patterns. **None of that is reproduced in this preamble** \u2014 only the always-on guardrails are. If you act on a Ripplo task without loading the matching skill, you will skip rules that exist to prevent specific past failure modes (cross-run data leakage, \"passing\" tests that never asserted backend state, cleared coverage gates without proof, etc.).\n\nMatch the task to a skill from the triage table; if unsure between two, load both. If completely unsure, load `/ripplo:explore` or `/ripplo:create`. Loading is cheap; acting under-informed is not.\n\n## Skill triage\n\n- Load `/ripplo:setup` skill for instructions on initializing Ripplo in a project; `ripplo doctor` reports the engine endpoint missing.\n- Load `/ripplo:explore` skill for instructions on planning/stubbing test coverage for a new project or new feature area.\n- Load `/ripplo:scope` skill for instructions on managing the working set of tests this session is responsible for.\n- Load `/ripplo:create` skill for instructions on authoring a single test spec for a user flow.\n- Load `/ripplo:run` skill for instructions on executing existing tests.\n- Load `/ripplo:debug` skill for instructions on a failed run; read artifacts in `.ripplo/debug/<runId>/` before re-running.\n- Load `/ripplo:flake-detect` skill for instructions on intermittent failures; parallelizes N runs (only use with evidence of flake).\n\n## Universal rules\n\n- **Start the dev server before building features.** Run the user's dev script (e.g. `pnpm dev`) as a background process at the start of feature work. `ripplo watch` runs alongside it, which is what enables Ripplo dev mode and arms the coverage/scope hooks. Without it, edits ship without their guardrails firing.\n- **Two funnels.** Definitions \u2192 `createRipplo({ preconditions, observers, tests })` in `.ripplo/index.ts`. Implementations \u2192 `createEngine(ripplo, { preconditions, observers })` in your app server's `test/engine.ts`. Never call either elsewhere. TS enforces exhaustiveness across both.\n- **\"Done\" = app code delivers the behavior AND a passing test proves it.** Both halves. Shipping without a test isn't done; writing a test against broken UI/API isn't done.\n- **Scope is your job.** For any non-trivial change, enumerate every flow it could affect and either `scope add` existing tests or stub `.notImplemented()` tests. Don't wait to be told.\n- **`scope remove` is never for size/effort.** Valid only when an item is genuinely out of scope (wrong flow, duplicate, user said \"not this session,\" feature cut). \"Too many stubs\" \u2192 parallelize with subagents. Don't present \"implement vs. remove\" as a neutral A/B.\n- **Stub gates are not a question.** When `stop-enforce` blocks on `.notImplemented()` stubs, implement them \u2014 don't ask the user \"implement or defer?\", don't propose pausing hooks as option B. The fix isn't done until the test is. New scaffolding (precondition, observer, engine impl) is in-scope work, not follow-up.\n- **`uiOnly: true` is not a stub.** Observer wiring is in-scope for mutation flows; don't use it to silence observer lint.\n- **Never weaken a test to make it pass.** No `contains`/regex for exact text, no removed assertions, no fabricated locators. App lacks an accessible name \u2192 add one to the app, don't fall back to `testId()`. App bug \u2192 report with evidence.\n- **Artifacts first, re-run last.** Failed runs produce DOM, a11y tree, console, network, screenshots under `.ripplo/debug/<runId>/`. Read them. Never pipe `ripplo run` through `grep`/`tail`/`head`. Form a hypothesis citing an artifact line, make ONE change, re-run once.\n- **3-strike rule.** Same failure after 3 targeted fixes \u2192 stop and report. Repeated failure on the same step almost always means the diagnosis is wrong.\n- **`.ripplo/ripplo.lock` is committed, never hand-edited.** `ripplo lint` / `ripplo compile` regenerates it. Pre-commit runs `ripplo compile --check`.\n- **Scratch files live in `.ripplo/.local/`.** Never loose in `.ripplo/`.\n- **Worktrees are self-contained.** Each worktree has its own `.ripplo/` checkout, DevSession, scope, and debug artifacts. Auth and projectId are shared globally. Env files (typically gitignored) won't carry over to a fresh worktree \u2014 copy from main or point at a shared file. **If sibling worktrees run dev servers on different ports, the worktree's env file MUST update both `RIPPLO_APP_URL` and `RIPPLO_ENGINE_URL` to match the port that worktree's dev server is bound to** (e.g. main on `:3000`, this worktree on `:3001` \u2192 set `RIPPLO_APP_URL=http://localhost:3001` and `RIPPLO_ENGINE_URL=http://localhost:3001/ripplo` in the worktree's env file). Mismatched ports = `ripplo watch` talks to the wrong server, runs silently fail or hit the sibling worktree's app.\n- **DSL locators are semantic.** No `css` / `placeholder` / `waitFor` / `group`.\n- **New backend assertion?** Declare in `.ripplo/observers/index.ts`, implement in your app server's `engine.ts` (TS flags the missing impl).\n\n## Key files\n\n- `.ripplo/index.ts` \u2014 `createRipplo` call.\n- `.ripplo/{preconditions,observers,tests}/index.ts` \u2014 registry aggregators.\n- `.ripplo/project.json` \u2014 project id + env-file pointers.\n- `<app>/src/test/engine.ts` \u2014 single impl funnel via `createEngine`.\n- `packages/testing/README.md` (or the npm page for `@ripplo/testing`) \u2014 DSL reference.\n",ta=O("SessionStart",e=>{if(_(e.cwd))return{hookSpecificOutput:{additionalContext:hh,hookEventName:"SessionStart"}}});import{execFileSync as wh}from"child_process";import bh from"path";import ra from"process";import{graphql as Sh}from"gql.tada";import{z as Gt}from"zod";var vh=Sh(`
|
|
591
|
+
query ScopeEnforce($projectId: String!, $cwd: String!) {
|
|
689
592
|
project(id: $projectId) {
|
|
690
593
|
id
|
|
691
|
-
devSession {
|
|
594
|
+
devSession(cwd: $cwd) {
|
|
692
595
|
id
|
|
693
596
|
scopeItems {
|
|
694
597
|
id
|
|
@@ -703,39 +606,43 @@ ${w("scope")}
|
|
|
703
606
|
}
|
|
704
607
|
}
|
|
705
608
|
}
|
|
706
|
-
`)
|
|
609
|
+
`),oa=O("Stop",async e=>{let{cwd:t}=e;if(!_(t)||!V(t))return;let r=Me(t),n=We(t,"stop-enforce")===r;if(n&&!e.stop_hook_active)return;let o=kh(t),i=await Rh(t,o);if(He(t,"stop-enforce",r),i.length!==0)return n&&e.stop_hook_active?{continue:!1,stopReason:`Stop-enforce: same repo state across consecutive stop attempts; agent appears stuck. Errors:
|
|
610
|
+
${i.join(`
|
|
707
611
|
|
|
708
|
-
`)
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
${
|
|
713
|
-
`);
|
|
714
|
-
${
|
|
715
|
-
|
|
612
|
+
`)}`}:{decision:"block",reason:i.join(`
|
|
613
|
+
|
|
614
|
+
`)}});function kh(e){return qt(e,".ripplo/tests").filter(t=>t.endsWith(".ts")).map(t=>bh.basename(t,".ts")).filter(t=>t!=="index")}async function Rh(e,t){let r=await I(e);if(!r.ok)return[`--- Compilation failed ---
|
|
615
|
+
${r.error}
|
|
616
|
+
${E("create")}`];await de({cwd:e,result:r.result}),_e({cwd:e});let n=await Ph(e),o=[...new Set([...t,...n.scopedSlugsToRun])],i=Eh(r,t),s=Ch(r),a=xh(e,r),l=Th(e,o);return[i,s,a,l,n.error].filter(c=>c!=null)}function xh(e,t){let{ignorePaths:r}=Re(),n=Gi({compileResult:t.result,cwd:e,ignorePaths:r});if(n.length===0)return null;let o=n.filter(a=>a.kind==="unacknowledged"),i=n.filter(a=>a.kind==="stale"),s=[];if(o.length>0){let a=o.map(l=>` ${l.id}`).join(`
|
|
617
|
+
`);s.push(`Unacknowledged interactions (add to a test's .coverage(...)):
|
|
618
|
+
${a}`)}if(i.length>0){let a=i.map(l=>` ${l.id}`).join(`
|
|
619
|
+
`);s.push(`Stale .coverage(...) claims (id no longer exists in source):
|
|
620
|
+
${a}`)}return`--- Exhaustiveness ---
|
|
621
|
+
${s.join(`
|
|
716
622
|
|
|
717
623
|
`)}
|
|
718
|
-
${
|
|
719
|
-
${
|
|
624
|
+
${E("create")}`}async function Ph(e){let t;try{t=X(e)}catch{return{error:null,scopedSlugsToRun:[]}}let n=(await k({config:t,document:vh,variables:{cwd:t.cwd,projectId:t.projectId}}).catch(()=>null))?.project?.devSession?.scopeItems??[],o=n.flatMap(a=>{let l=a.workflow;return l==null?[` [intent] ${a.label??"(no label)"} \u2014 stub a test for this flow`]:l.spec==null?[` [stub] ${l.slug} \u2014 implement \`${l.name}\``]:[]}),i=n.flatMap(a=>a.workflow?.spec==null?[]:[a.workflow.slug]);return{error:o.length===0?null:`--- Testing Scope ---
|
|
625
|
+
${o.join(`
|
|
720
626
|
`)}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
Only use \`npx ripplo scope remove <ids..>\` if an item is genuinely out of scope or no longer needed \u2014 not as a shortcut when implementation feels long. If scope itself is wrong, raise it with the user before removing.
|
|
725
|
-
${w("create")}`,scopedSlugsToRun:l}}function yS(e,t){let{diagnostics:n}=ot(e.result),r=new Set(e.builder.getUnimplemented().tests),o=t.filter(l=>r.has(l));if(n.length===0&&o.length===0)return null;let i=n.map(l=>{let s=l.step==null?"":` at "${l.step}"`;return` [${l.rule}]${s} ${l.test}: ${l.message}`}),a=o.map(l=>` [not-implemented] ${l} is still marked .notImplemented()`);return`--- Ripplo Lint ---
|
|
726
|
-
${[...i,...a].join(`
|
|
627
|
+
${E("create")}`,scopedSlugsToRun:i}}function Eh(e,t){let{diagnostics:r}=Le(e.result),n=new Set(e.builder.getUnimplemented().tests),o=t.filter(a=>n.has(a));if(r.length===0&&o.length===0)return null;let i=r.map(a=>{let l=a.step==null?"":` at "${a.step}"`;return` [${a.rule}]${l} ${a.test}: ${a.message}`}),s=o.map(a=>` [not-implemented] ${a} is still marked .notImplemented()`);return`--- Ripplo Lint ---
|
|
628
|
+
${[...i,...s].join(`
|
|
727
629
|
`)}
|
|
728
|
-
${
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
${w("create")}`}function hS(e,t){if(t.length===0)return null;let n=SS(["run",...t],e);if(n.code===0)return null;let r=n.output.split(`
|
|
630
|
+
${E("create")}`}function Ch(e){let{tests:t}=e.builder.getUnimplemented();return t.length===0?null:`--- Unimplemented stubs ---
|
|
631
|
+
${t.join(", ")}
|
|
632
|
+
Implement the stub now. Do not ask the user "implement or defer?" \u2014 that framing is forbidden by /ripplo:create. New scaffolding (precondition, observer, engine impl) is in-scope, not follow-up.
|
|
633
|
+
${E("create")}`}function Th(e,t){if(t.length===0)return null;let r=$h(["run",...t],e);if(r.code===0)return null;let n=r.output.split(`
|
|
733
634
|
`).filter(o=>/FAILED/.test(o)).join(`
|
|
734
|
-
`);return
|
|
735
|
-
${
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
`)
|
|
740
|
-
|
|
741
|
-
|
|
635
|
+
`);return n.length===0?null:`--- Ripplo Run Failures (${t.join(" ")}) ---
|
|
636
|
+
${n}
|
|
637
|
+
Artifacts: .ripplo/debug/<runId>/. ${E("debug")}`}var Ah=Gt.object({status:Gt.number().nullish(),stderr:Gt.unknown().optional(),stdout:Gt.unknown().optional()});function na(e){return e instanceof Buffer?e.toString("utf8"):typeof e=="string"?e:""}function $h(e,t){let r=ra.argv[1];if(r==null)return{code:1,output:""};try{return{code:0,output:wh(ra.execPath,[r,...e],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}}catch(n){let o=Ah.safeParse(n);if(!o.success)return{code:1,output:""};let i=`${na(o.data.stdout)}${na(o.data.stderr)}`;return{code:o.data.status??1,output:i}}}import{z as ia}from"zod";var Ih=ia.looseObject({skill:ia.string()}),sa=O("PostToolUse",e=>{if(e.tool_name!=="Skill")return;let t=Ih.safeParse(e.tool_input);if(!t.success)return;let r=/^ripplo:(.+)$/.exec(t.data.skill);if(r==null)return;let n=r[1];n!=null&&_(e.cwd)&&Bs(e.cwd,e.session_id,n)});Vh();Rn(process.cwd());var aa={"coverage-nudge":Ds,"exit-plan-gate":Us,"plan-reminder":Vs,"post-edit-flag-stubs":Ws,"post-edit-lint":qs,"pre-bash-run-gate":Ks,"pre-edit-ripplo-skill-gate":Ys,"pre-edit-scope-gate":Zs,"scope-reminder":ea,"session-preamble":ta,"stop-enforce":oa,"track-skill-load":sa};async function Oh(){await jh(Nh(process.argv)).scriptName("ripplo").command("watch","Watch for run requests and execute locally",()=>{},()=>Es()).command("auth <subcommand>","Manage authentication",Uh).command("init","Scaffold .ripplo/ in this project",e=>e.option("project",{type:"string"}).option("env-file",{type:"string"}).option("app-url",{type:"string"}).option("engine-url",{type:"string"}),e=>gs({appUrl:e["app-url"],engineUrl:e["engine-url"],envFile:e["env-file"],projectId:e.project})).command("run [ids..]","Run tests in parallel",e=>{let t=[];return e.positional("ids",{array:!0,default:t,describe:"Test ids to run (all if omitted)",type:"string"})},e=>bs(e.ids)).command("lint [ids..]","Compile and lint tests (all or specific ids)",e=>{let t=[];return e.positional("ids",{array:!0,default:t,describe:"Test ids to lint (all if omitted)",type:"string"}).option("require-implemented",{array:!0,default:t,describe:"Test ids that must not be .notImplemented() \u2014 fails if any still are",type:"string"})},e=>ws({ids:e.ids,requireImplemented:e["require-implemented"]})).command("flake-detect <id>","Run N times to detect flakiness",e=>e.positional("id",{demandOption:!0,type:"string"}).option("runs",{default:10,type:"number"}),e=>ds({id:e.id,runs:e.runs})).command("sync","Push the compiled .ripplo/ resources to the server (no run)",()=>{},()=>Ss()).command("compile","Compile the DSL and write .ripplo/ripplo.lock",e=>e.option("check",{default:!1,describe:"Exit non-zero if the lockfile is missing or stale (does not write)",type:"boolean"}),e=>zi({check:e.check})).command("cover","Audit all coverage statements",()=>{},()=>Xi()).command("doctor","Check project health",()=>{},()=>os()).command("status","Report unimplemented tests and preconditions",e=>e.option("format",{choices:["json","summary"],default:"json",describe:"Output format"}),e=>Is({format:e.format})).command("scope <subcommand>","Manage testing scope",_h).command("hook <name>","Internal: run a Claude Code plugin hook",e=>e.positional("name",{choices:Object.keys(aa),demandOption:!0,type:"string"}),e=>Lh(e.name)).option("env",{choices:["dev","local"],describe:"Server environment",type:"string"}).strict().help().parse()}async function Lh(e){let t=aa[e];t==null&&(process.stderr.write(`Unknown hook: ${e}
|
|
638
|
+
`),process.exit(1));let r=await Dh(),n=r.trim()===""?{}:JSON.parse(r),o=await t.run(n);o!=null&&process.stdout.write(JSON.stringify(o))}function Dh(){return new Promise((e,t)=>{if(process.stdin.isTTY){e("");return}let r=[];process.stdin.on("data",n=>r.push(n)),process.stdin.on("end",()=>{e(Buffer.concat(r).toString("utf8"))}),process.stdin.on("error",t)})}Oh().catch(e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}
|
|
639
|
+
`),process.exit(1)});function _h(e){return e.command("status","Print the current scope",t=>t.option("format",{choices:["json","text"],default:"text",describe:"Output format"}),t=>Cs({format:t.format})).command("add <test-ids..>","Bind one or more existing tests (stubs or implemented) to scope as agent intent",t=>{let r=[];return t.positional("test-ids",{array:!0,default:r,demandOption:!0,describe:"Slugs of existing workflows",type:"string"})},t=>Ts({testIds:t["test-ids"]})).command("link <id> <test-id>","Link an existing scope item to a test",t=>t.positional("id",{demandOption:!0,describe:"Scope item id",type:"string"}).positional("test-id",{demandOption:!0,describe:"Slug of the workflow to link",type:"string"}),t=>As({id:t.id,testId:t["test-id"]})).command("remove <ids..>","Remove one or more scope items by id",t=>{let r=[];return t.positional("ids",{array:!0,default:r,demandOption:!0,describe:"Scope item ids",type:"string"})},t=>$s({ids:t.ids})).demandCommand(1)}function Uh(e){return e.command("login","Authenticate via device flow",()=>{},()=>Si()).command("status","Show authentication status",()=>{},()=>vi()).command("logout","Remove the saved token",()=>{},()=>{ki()}).demandCommand(1)}function Vh(){let e=process.cwd(),t=Kt(e);t!=null&&t!==e&&(process.chdir(t),process.stderr.write(`ripplo: resolved .ripplo/ at ${t}
|
|
640
|
+
`))}export{Oh as main};
|
|
641
|
+
/*! Bundled license information:
|
|
642
|
+
|
|
643
|
+
mustache/mustache.mjs:
|
|
644
|
+
(*!
|
|
645
|
+
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
646
|
+
* http://github.com/janl/mustache.js
|
|
647
|
+
*)
|
|
648
|
+
*/
|