ripplo 0.0.10 → 0.0.11

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.
Files changed (2) hide show
  1. package/dist/index.js +82 -79
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,43 +1,43 @@
1
1
  #!/usr/bin/env node
2
- var ui=Object.create;var Er=Object.defineProperty;var fi=Object.getOwnPropertyDescriptor;var mi=Object.getOwnPropertyNames;var yi=Object.getPrototypeOf,gi=Object.prototype.hasOwnProperty;var St=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var hi=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of mi(t))!gi.call(e,o)&&o!==n&&Er(e,o,{get:()=>t[o],enumerable:!(r=fi(t,o))||r.enumerable});return e};var wi=(e,t,n)=>(n=e!=null?ui(yi(e)):{},hi(t||!e||!e.__esModule?Er(n,"default",{value:e,enumerable:!0}):n,e));var Ta=St(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.timingSafeEqual=void 0;function Na(e,t=""){if(!e)throw new Error(t)}function Wd(e,t){if(e.byteLength!==t.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),t instanceof DataView||(t=new DataView(ArrayBuffer.isView(t)?t.buffer:t)),Na(e instanceof DataView),Na(t instanceof DataView);let n=e.byteLength,r=0,o=-1;for(;++o<n;)r|=e.getUint8(o)^t.getUint8(o);return r===0}Ot.timingSafeEqual=Wd});var xa=St(z=>{"use strict";var qd=z&&z.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(z,"__esModule",{value:!0});var _=256,Jn=(function(){function e(t){t===void 0&&(t="="),this._paddingCharacter=t}return e.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(t*8+5)/6|0},e.prototype.encode=function(t){for(var n="",r=0;r<t.length-2;r+=3){var o=t[r]<<16|t[r+1]<<8|t[r+2];n+=this._encodeByte(o>>>18&63),n+=this._encodeByte(o>>>12&63),n+=this._encodeByte(o>>>6&63),n+=this._encodeByte(o>>>0&63)}var a=t.length-r;if(a>0){var o=t[r]<<16|(a===2?t[r+1]<<8:0);n+=this._encodeByte(o>>>18&63),n+=this._encodeByte(o>>>12&63),a===2?n+=this._encodeByte(o>>>6&63):n+=this._paddingCharacter||"",n+=this._paddingCharacter||""}return n},e.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(t*6+7)/8|0},e.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},e.prototype.decode=function(t){if(t.length===0)return new Uint8Array(0);for(var n=this._getPaddingLength(t),r=t.length-n,o=new Uint8Array(this.maxDecodedLength(r)),a=0,s=0,i=0,l=0,c=0,d=0,f=0;s<r-4;s+=4)l=this._decodeChar(t.charCodeAt(s+0)),c=this._decodeChar(t.charCodeAt(s+1)),d=this._decodeChar(t.charCodeAt(s+2)),f=this._decodeChar(t.charCodeAt(s+3)),o[a++]=l<<2|c>>>4,o[a++]=c<<4|d>>>2,o[a++]=d<<6|f,i|=l&_,i|=c&_,i|=d&_,i|=f&_;if(s<r-1&&(l=this._decodeChar(t.charCodeAt(s)),c=this._decodeChar(t.charCodeAt(s+1)),o[a++]=l<<2|c>>>4,i|=l&_,i|=c&_),s<r-2&&(d=this._decodeChar(t.charCodeAt(s+2)),o[a++]=c<<4|d>>>2,i|=d&_),s<r-3&&(f=this._decodeChar(t.charCodeAt(s+3)),o[a++]=d<<6|f,i|=f&_),i!==0)throw new Error("Base64Coder: incorrect characters for decoding");return o},e.prototype._encodeByte=function(t){var n=t;return n+=65,n+=25-t>>>8&6,n+=51-t>>>8&-75,n+=61-t>>>8&-15,n+=62-t>>>8&3,String.fromCharCode(n)},e.prototype._decodeChar=function(t){var n=_;return n+=(42-t&t-44)>>>8&-_+t-43+62,n+=(46-t&t-48)>>>8&-_+t-47+63,n+=(47-t&t-58)>>>8&-_+t-48+52,n+=(64-t&t-91)>>>8&-_+t-65+0,n+=(96-t&t-123)>>>8&-_+t-97+26,n},e.prototype._getPaddingLength=function(t){var n=0;if(this._paddingCharacter){for(var r=t.length-1;r>=0&&t[r]===this._paddingCharacter;r--)n++;if(t.length<4||n>2)throw new Error("Base64Coder: incorrect padding")}return n},e})();z.Coder=Jn;var ot=new Jn;function Md(e){return ot.encode(e)}z.encode=Md;function Gd(e){return ot.decode(e)}z.decode=Gd;var va=(function(e){qd(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype._encodeByte=function(n){var r=n;return r+=65,r+=25-n>>>8&6,r+=51-n>>>8&-75,r+=61-n>>>8&-13,r+=62-n>>>8&49,String.fromCharCode(r)},t.prototype._decodeChar=function(n){var r=_;return r+=(44-n&n-46)>>>8&-_+n-45+62,r+=(94-n&n-96)>>>8&-_+n-95+63,r+=(47-n&n-58)>>>8&-_+n-48+52,r+=(64-n&n-91)>>>8&-_+n-65+0,r+=(96-n&n-123)>>>8&-_+n-97+26,r},t})(Jn);z.URLSafeCoder=va;var Ca=new va;function Jd(e){return Ca.encode(e)}z.encodeURLSafe=Jd;function zd(e){return Ca.decode(e)}z.decodeURLSafe=zd;z.encodedLength=function(e){return ot.encodedLength(e)};z.maxDecodedLength=function(e){return ot.maxDecodedLength(e)};z.decodedLength=function(e){return ot.decodedLength(e)}});var Pa=St((La,It)=>{"use strict";(function(e,t){var n={};t(n);var r=n.default;for(var o in n)r[o]=n[o];typeof It=="object"&&typeof It.exports=="object"?It.exports=r:typeof define=="function"&&define.amd?define(function(){return r}):e.sha256=r})(La,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(f,u,m,y,h){for(var S,k,b,C,I,v,q,x,$,B,Xe,Ke,wt;h>=64;){for(S=u[0],k=u[1],b=u[2],C=u[3],I=u[4],v=u[5],q=u[6],x=u[7],B=0;B<16;B++)Xe=y+B*4,f[B]=(m[Xe]&255)<<24|(m[Xe+1]&255)<<16|(m[Xe+2]&255)<<8|m[Xe+3]&255;for(B=16;B<64;B++)$=f[B-2],Ke=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10,$=f[B-15],wt=($>>>7|$<<25)^($>>>18|$<<14)^$>>>3,f[B]=(Ke+f[B-7]|0)+(wt+f[B-16]|0);for(B=0;B<64;B++)Ke=(((I>>>6|I<<26)^(I>>>11|I<<21)^(I>>>25|I<<7))+(I&v^~I&q)|0)+(x+(t[B]+f[B]|0)|0)|0,wt=((S>>>2|S<<30)^(S>>>13|S<<19)^(S>>>22|S<<10))+(S&k^S&b^k&b)|0,x=q,q=v,v=I,I=C+Ke|0,C=b,b=k,k=S,S=Ke+wt|0;u[0]+=S,u[1]+=k,u[2]+=b,u[3]+=C,u[4]+=I,u[5]+=v,u[6]+=q,u[7]+=x,y+=64,h-=64}return y}var r=(function(){function f(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return f.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},f.prototype.clean=function(){for(var u=0;u<this.buffer.length;u++)this.buffer[u]=0;for(var u=0;u<this.temp.length;u++)this.temp[u]=0;this.reset()},f.prototype.update=function(u,m){if(m===void 0&&(m=u.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var y=0;if(this.bytesHashed+=m,this.bufferLength>0){for(;this.bufferLength<64&&m>0;)this.buffer[this.bufferLength++]=u[y++],m--;this.bufferLength===64&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(m>=64&&(y=n(this.temp,this.state,u,y,m),m%=64);m>0;)this.buffer[this.bufferLength++]=u[y++],m--;return this},f.prototype.finish=function(u){if(!this.finished){var m=this.bytesHashed,y=this.bufferLength,h=m/536870912|0,S=m<<3,k=m%64<56?64:128;this.buffer[y]=128;for(var b=y+1;b<k-8;b++)this.buffer[b]=0;this.buffer[k-8]=h>>>24&255,this.buffer[k-7]=h>>>16&255,this.buffer[k-6]=h>>>8&255,this.buffer[k-5]=h>>>0&255,this.buffer[k-4]=S>>>24&255,this.buffer[k-3]=S>>>16&255,this.buffer[k-2]=S>>>8&255,this.buffer[k-1]=S>>>0&255,n(this.temp,this.state,this.buffer,0,k),this.finished=!0}for(var b=0;b<8;b++)u[b*4+0]=this.state[b]>>>24&255,u[b*4+1]=this.state[b]>>>16&255,u[b*4+2]=this.state[b]>>>8&255,u[b*4+3]=this.state[b]>>>0&255;return this},f.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},f.prototype._saveState=function(u){for(var m=0;m<this.state.length;m++)u[m]=this.state[m]},f.prototype._restoreState=function(u,m){for(var y=0;y<this.state.length;y++)this.state[y]=u[y];this.bytesHashed=m,this.finished=!1,this.bufferLength=0},f})();e.Hash=r;var o=(function(){function f(u){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var m=new Uint8Array(this.blockSize);if(u.length>this.blockSize)new r().update(u).finish(m).clean();else for(var y=0;y<u.length;y++)m[y]=u[y];for(var y=0;y<m.length;y++)m[y]^=54;this.inner.update(m);for(var y=0;y<m.length;y++)m[y]^=106;this.outer.update(m),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var y=0;y<m.length;y++)m[y]=0}return f.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},f.prototype.clean=function(){for(var u=0;u<this.istate.length;u++)this.ostate[u]=this.istate[u]=0;this.inner.clean(),this.outer.clean()},f.prototype.update=function(u){return this.inner.update(u),this},f.prototype.finish=function(u){return this.outer.finished?this.outer.finish(u):(this.inner.finish(u),this.outer.update(u,this.digestLength).finish(u)),this},f.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},f})();e.HMAC=o;function a(f){var u=new r().update(f),m=u.digest();return u.clean(),m}e.hash=a,e.default=a;function s(f,u){var m=new o(f).update(u),y=m.digest();return m.clean(),y}e.hmac=s;function i(f,u,m,y){var h=y[0];if(h===0)throw new Error("hkdf: cannot expand more");u.reset(),h>1&&u.update(f),m&&u.update(m),u.update(y),u.finish(f),y[0]++}var l=new Uint8Array(e.digestLength);function c(f,u,m,y){u===void 0&&(u=l),y===void 0&&(y=32);for(var h=new Uint8Array([1]),S=s(u,f),k=new o(S),b=new Uint8Array(k.digestLength),C=b.length,I=new Uint8Array(y),v=0;v<y;v++)C===b.length&&(i(b,k,m,h),C=0),I[v]=b[C++];return k.clean(),b.fill(0),h.fill(0),I}e.hkdf=c;function d(f,u,m,y){for(var h=new o(f),S=h.digestLength,k=new Uint8Array(4),b=new Uint8Array(S),C=new Uint8Array(S),I=new Uint8Array(y),v=0;v*S<y;v++){var q=v+1;k[0]=q>>>24&255,k[1]=q>>>16&255,k[2]=q>>>8&255,k[3]=q>>>0&255,h.reset(),h.update(u),h.update(k),h.finish(C);for(var x=0;x<S;x++)b[x]=C[x];for(var x=2;x<=m;x++){h.reset(),h.update(C).finish(C);for(var $=0;$<S;$++)b[$]^=C[$]}for(var x=0;x<S&&v*S+x<y;x++)I[v*S+x]=b[x]}for(var v=0;v<S;v++)b[v]=C[v]=0;for(var v=0;v<4;v++)k[v]=0;return h.clean(),I}e.pbkdf2=d})});var Ia=St(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.Webhook=Be.WebhookVerificationError=void 0;var Hd=Ta(),Ea=xa(),Xd=Pa(),Oa=300,zn=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="ExtendableError",this.stack=new Error(t).stack}},me=class e extends zn{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="WebhookVerificationError"}};Be.WebhookVerificationError=me;var Ut=class e{constructor(t,n){if(!t)throw new Error("Secret can't be empty.");if(n?.format==="raw")t instanceof Uint8Array?this.key=t:this.key=Uint8Array.from(t,r=>r.charCodeAt(0));else{if(typeof t!="string")throw new Error("Expected secret to be of type string");t.startsWith(e.prefix)&&(t=t.substring(e.prefix.length)),this.key=Ea.decode(t)}}verify(t,n){let r={};for(let u of Object.keys(n))r[u.toLowerCase()]=n[u];let o=r["webhook-id"],a=r["webhook-signature"],s=r["webhook-timestamp"];if(!a||!o||!s)throw new me("Missing required headers");let i=this.verifyTimestamp(s),c=this.sign(o,i,t).split(",")[1],d=a.split(" "),f=new globalThis.TextEncoder;for(let u of d){let[m,y]=u.split(",");if(m==="v1"&&(0,Hd.timingSafeEqual)(f.encode(y),f.encode(c)))return JSON.parse(t.toString())}throw new me("No matching signature found")}sign(t,n,r){if(typeof r!="string")if(r.constructor.name==="Buffer")r=r.toString();else throw new Error("Expected payload to be of type string or Buffer.");let o=new TextEncoder,a=Math.floor(n.getTime()/1e3),s=o.encode(`${t}.${a}.${r}`);return`v1,${Ea.encode(Xd.hmac(this.key,s))}`}verifyTimestamp(t){let n=Math.floor(Date.now()/1e3),r=parseInt(t,10);if(isNaN(r))throw new me("Invalid Signature Headers");if(n-r>Oa)throw new me("Message timestamp too old");if(r>n+Oa)throw new me("Message timestamp too new");return new Date(r*1e3)}};Be.Webhook=Ut;Ut.prefix="whsec_"});import{config as di}from"dotenv";import en from"path";import{fileURLToPath as $m}from"url";import st from"fs";import De from"path";import{z as kt}from"zod";var tn=kt.object({from:kt.string().min(1).describe("Key of the source state in the states record"),to:kt.string().min(1).describe("Key of the target state in the states record"),workflow:kt.string().min(1).describe("Filename (without .json) of the workflow in .ripplo/workflows/ that executes this edge")}).describe("A directed edge between two states, executed by a workflow");import{z as de}from"zod";import{z as j}from"zod";var Or=j.object({precondition:j.string().min(1).describe("Name of the precondition to check or execute, e.g. 'auth:admin'")}).describe("Request payload sent by Ripplo to both the check and execute endpoints"),bt=j.object({satisfied:j.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),At=j.object({data:j.record(j.string(),j.string()).optional().describe("Key-value data returned by the precondition. Values are injected as variables that can be interpolated into route patterns ({{key}}) and workflow spec variable references. For example, a data:project precondition should return { projectId: 'clx...' } so the route /projects/{{projectId}}/settings resolves correctly."),error:j.string().optional().describe("Human-readable error message if success is false"),navigateTo:j.string().optional().describe("URL to navigate the browser to after this precondition executes. Use this to set the starting page for the test \u2014 e.g. an auth token URL or the page the workflow begins on. If multiple preconditions return navigateTo, only the last one is used."),success:j.boolean().describe("Whether the precondition was successfully satisfied")}).describe("Response from PUT {preconditionApiUrl}/execute. Set-Cookie headers are automatically captured and injected into the browser context. The data field provides values for route param interpolation and workflow variables."),Ir=j.object({preconditions:j.array(j.string().min(1)).describe("Names of all preconditions that were executed during this run")}).describe("Request payload sent after a run completes. Fire-and-forget \u2014 errors are logged but don't fail the run."),Ur=j.object({error:j.string().optional().describe("Human-readable error message if success is false"),success:j.boolean().describe("Whether teardown completed successfully")}).describe("Response from PUT {preconditionApiUrl}/teardown"),Pe=j.object({depends:j.array(j.string().min(1)).optional().describe("Names of other preconditions that must be satisfied first. Resolved via topological sort; cycles are rejected at validation time."),description:j.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:j.array(j.string().min(1)).optional().describe("Keys that the execute response's data field will contain. e.g. ['projectId', 'workflowId']. These are used for route param interpolation ({{projectId}}) and workflow variables. Declared here so generated types are strongly typed per precondition.")}).describe("A named precondition declared at the graph level. States reference these by name.");import{z as Rt}from"zod";var nn=Rt.object({preconditions:Rt.array(Rt.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:Rt.string().min(1).describe("URL pattern with {{placeholders}} for dynamic segments, e.g. '/projects/{{projectId}}/settings'")}).describe("A distinct application state \u2014 a unique combination of location, auth context, and data conditions");var Ee=de.object({edges:de.array(tn).describe("Directed edges between states, each executed by a workflow"),preconditions:de.record(de.string(),Pe).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:de.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:de.record(de.string(),nn).describe("States keyed by stable ID (kebab-case)"),version:de.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions");function rn(e){let t=Ee.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(n=>({message:n.message,path:n.path.join(".")})),success:!1}}function Si(e){let t=e.preconditions,n=new Set,r=new Set,o=[];function a(s){if(r.has(s)){o.push(`Precondition "${s}" has a circular dependency`);return}if(n.has(s))return;n.add(s),r.add(s);let i=t[s];i?.depends!=null&&i.depends.forEach(l=>{a(l)}),r.delete(s)}return Object.keys(t).forEach(s=>{a(s)}),o}function on(e){let t=[],n=new Set(Object.keys(e.preconditions)),r=new Set(Object.keys(e.states));e.edges.forEach((l,c)=>{r.has(l.from)||t.push({message:`References non-existent source state "${l.from}"`,path:`edges[${String(c)}].from`}),r.has(l.to)||t.push({message:`References non-existent target state "${l.to}"`,path:`edges[${String(c)}].to`})}),Object.entries(e.states).forEach(([l,c])=>{c.preconditions.forEach(d=>{n.has(d)||t.push({message:`References non-existent precondition "${d}"`,path:`states.${l}.preconditions`})})}),Object.entries(e.preconditions).forEach(([l,c])=>{c.depends!=null&&c.depends.forEach(d=>{n.has(d)||t.push({message:`Depends on non-existent precondition "${d}"`,path:`preconditions.${l}.depends`})})}),e.resetPrecondition!=null&&!n.has(e.resetPrecondition)&&t.push({message:`References non-existent precondition "${e.resetPrecondition}"`,path:"resetPrecondition"});let o=new Set(e.edges.flatMap(l=>[l.from,l.to]));Object.keys(e.states).forEach(l=>{o.has(l)||t.push({message:"State is not referenced by any edge (orphan)",path:`states.${l}`})});let a=new Set;Object.values(e.states).forEach(l=>{l.preconditions.forEach(c=>a.add(c))}),Object.values(e.preconditions).forEach(l=>{l.depends!=null&&l.depends.forEach(c=>a.add(c))}),e.resetPrecondition!=null&&a.add(e.resetPrecondition),Object.keys(e.preconditions).forEach(l=>{a.has(l)||t.push({message:"Defined but never used by any state or dependency",path:`preconditions.${l}`})});let s=new Set;return e.edges.forEach((l,c)=>{let d=`${l.from}|${l.to}|${l.workflow}`;s.has(d)&&t.push({message:`Duplicate edge from "${l.from}" to "${l.to}" with workflow "${l.workflow}"`,path:`edges[${String(c)}]`}),s.add(d)}),Si(e).forEach(l=>t.push({message:l,path:"preconditions"})),t}function T({locator:e,page:t}){switch(e.by){case"css":return t.locator(e.value);case"testId":return t.getByTestId(e.value);case"role":return t.getByRole(e.role,{exact:e.exact,name:e.name});case"text":return t.getByText(e.value,{exact:e.exact});case"label":return t.getByLabel(e.value,{exact:e.exact});case"placeholder":return t.getByPlaceholder(e.value);case"altText":return t.getByAltText(e.value)}}function Ye({defs:e}){return e==null?{}:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,bi({def:n,name:t})]))}var ki={boolean:!1,number:0,string:""};function bi({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??ki[e.type]??""}function ke({ref:e,variables:t}){if(e.type==="static")return e.value;let n=t[e.name];if(n==null)throw new Error(`Variable "${e.name}" is not defined`);return n}function P({ref:e,variables:t}){let n=String(ke({ref:e,variables:t}));return Ai({raw:n,variables:t})}function Ai({raw:e,variables:t}){return e.replaceAll(/\{\{(\w+)\}\}/g,(n,r)=>{let o=t[r];if(o==null)throw new Error(`Template variable "{{${r}}}" is not defined`);return String(o)})}function an({ref:e,variables:t}){let n=ke({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 oe({name:e,store:t,value:n}){return{...t,[e]:n}}async function jr({node:e,page:t,timeout:n}){await T({locator:e.source,page:t}).dragTo(T({locator:e.target,page:t}),{timeout:n})}async function _r({node:e,page:t,timeout:n}){await T({locator:e.locator,page:t}).click({button:"right",timeout:n})}function $r({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 Br({node:e,page:t}){let n=e.x??0,r=e.y??0;if(e.locator==null){await t.mouse.wheel(n,r);return}let a=await T({locator:e.locator,page:t}).elementHandle();if(a==null)throw new Error("scroll target element not found");await a.evaluate("([dx, dy]) => this.scrollBy(dx, dy)",[n,r])}async function Dr({node:e,page:t,variables:n}){if(e.action==="write"){if(e.value==null)throw new Error("clipboard write requires a value");let o=P({ref:e.value,variables:n}),a=JSON.stringify(o);return await t.evaluate(`navigator.clipboard.writeText(${a})`),{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:oe({name:e.variable,store:n,value:r})}}async function Fr({node:e,page:t}){let n=t.context();e.state==="granted"?await n.grantPermissions([e.permission]):await n.clearPermissions()}async function sn({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 Ni({node:e,page:t,timeout:n,variables:r});case"rightClick":return await _r({node:e,page:t,timeout:n}),{variables:r};case"goto":{let o=P({ref:e.url,variables:r});return await t.goto(o,{timeout:n,waitUntil:"domcontentloaded"}),{variables:r}}case"fill":{let o=P({ref:e.value,variables:r});return await T({locator:e.locator,page:t}).fill(o,{timeout:n}),{variables:r}}case"select":{let o=P({ref:e.value,variables:r});return await T({locator:e.locator,page:t}).selectOption(o,{timeout:n}),{variables:r}}case"type":{let o=P({ref:e.value,variables:r});return await T({locator:e.locator,page:t}).pressSequentially(o,{timeout:n}),{variables:r}}case"press":return await vi({node:e,page:t,timeout:n}),{variables:r};case"drag":return await jr({node:e,page:t,timeout:n}),{variables:r};case"upload":return await T({locator:e.locator,page:t}).setInputFiles(e.files,{timeout:n}),{variables:r};case"extractText":{let o=await T({locator:e.locator,page:t}).textContent({timeout:n});if(o==null)throw new Error("extractText: element had no text content");return{variables:oe({name:e.variable,store:r,value:o})}}case"setVariable":{let o=ke({ref:e.value,variables:r});return{variables:oe({name:e.variable,store:r,value:o})}}case"fail":throw new Error(e.message);case"waitFor":return await T({locator:e.locator,page:t}).waitFor({state:e.state??"visible",timeout:n}),{variables:r};case"waitForUrl":{let o=P({ref:e.expected,variables:r});return await t.waitForURL(Ti({expected:o,operator:e.operator}),{timeout:n}),{variables:r}}case"waitForResponse":{let o=P({ref:e.urlPattern,variables:r});return await t.waitForResponse(a=>a.url().includes(o),{timeout:n}),{variables:r}}case"waitForRequest":{let o=P({ref:e.urlPattern,variables:r});return await t.waitForRequest(a=>a.url().includes(o),{timeout:n}),{variables:r}}case"wait":return await t.waitForTimeout(e.duration),{variables:r};case"screenshot":return await t.screenshot(),{variables:r};case"setViewport":return await t.setViewportSize({height:e.height,width:e.width}),{variables:r};case"handleDialog":return $r({node:e,page:t,variables:r});case"scroll":return await Br({node:e,page:t}),{variables:r};case"clipboard":return Dr({node:e,page:t,variables:r});case"setPermission":return await Fr({node:e,page:t}),{variables:r}}}var Ri={check:"check",clear:"clear",click:"click",dblclick:"dblclick",focus:"focus",hover:"hover",scrollIntoView:"scrollIntoViewIfNeeded",uncheck:"uncheck"};async function Ni({node:e,page:t,timeout:n,variables:r}){return await T({locator:e.locator,page:t})[Ri[e.type]]({timeout:n}),{variables:r}}function Ti({expected:e,operator:t}){return n=>{let r=n.toString();return t==="equals"?r===e:t==="notEquals"?r!==e:t==="contains"?r.includes(e):t==="startsWith"?r.startsWith(e):t==="endsWith"?r.endsWith(e):new RegExp(e).test(r)}}async function vi({node:e,page:t,timeout:n}){e.locator==null?await t.keyboard.press(e.key):await T({locator:e.locator,page:t}).press(e.key,{timeout:n})}import Ol from"@anthropic-ai/sdk";import{z as Vr}from"zod";import{z as Ei}from"zod";async function pe({page:e,runStartTime:t,targets:n}){let r=e.viewportSize();if(r==null)throw new Error("Page has no viewport set");let[o,a]=await Promise.all([e.screenshot({type:"png"}),xi(n)]),s=o.toString("base64");return{annotations:a,screenshotBase64:s,snapshotTimestamp:Math.round(performance.now()-t),url:e.url(),viewportHeight:r.height,viewportWidth:r.width}}function Ci(e){return"locator"in e}async function xi(e){return(await Promise.all(e.map(n=>Li(n)))).filter(n=>n!=null)}async function Li(e){if(!Ci(e))return{height:0,label:e.label,type:e.type,width:0,x:0,y:0};let t=await e.locator.boundingBox({timeout:2e3}).catch(()=>null);if(t!=null)return{height:Math.round(t.height),label:e.label,type:e.type,width:Math.round(t.width),x:Math.round(t.x),y:Math.round(t.y)}}function Nt({node:e,page:t}){if(e.type==="assertUrl"||e.type==="waitForUrl")return[{label:e.type,type:"urlBar"}];if(e.type==="drag"){let o=T({locator:e.source,page:t}),a=T({locator:e.target,page:t});return[{label:"drag-source",locator:o,type:"action"},{label:"drag-target",locator:a,type:"action"}]}if(!Pi(e))return[];let n=e.type.startsWith("assert")?"assertion":"action",r=T({locator:e.locator,page:t});return[{label:e.type,locator:r,type:n}]}function Pi(e){return"locator"in e&&e.locator!=null}function g({description:e,execute:t,name:n,schema:r}){let o=Ei.toJSONSchema(r,{target:"draft-2020-12"});return{anthropicTool:{description:e,input_schema:{...o,type:"object"},name:n},name:n,async execute(a,s){let i=r.parse(s);return{...await Promise.resolve(t(a,i)),kind:"action"}}}}async function A(e){let t=e.specNode==null?[]:Nt({node:e.specNode,page:e.page}),n=await pe({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,screenshotBase64:n.screenshotBase64,snapshotTimestamp:n.snapshotTimestamp,status:e.status,stepIndex:e.stepIndex,title:e.title,url:n.url,viewportHeight:n.viewportHeight,viewportWidth:n.viewportWidth},a=r.length>0?r.map(s=>`${s.status}: ${s.description} \u2014 ${s.detail??""}`).join(`
3
- `):`${e.status}: ${e.title}`;return{specNode:e.specNode,stepResult:o,toolOutput:a}}var Oi=Vr.object({selector:Vr.string().describe("CSS selector for the checkbox or radio button")}),Wr=g({description:"Assert that a checkbox or radio button is checked",name:"assert_checked",schema:Oi,execute:async(e,t)=>{let n=performance.now(),r=await e.page.locator(t.selector).isChecked().catch(()=>!1),o=r?"passed":"failed",a=[{description:`Element ${t.selector} is checked`,detail:r?void 0:"Element is not checked",status:o}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertChecked"};return A({assertions:a,detail:r?"Element is checked":"Element is not checked",duration:performance.now()-n,nodeType:"assertChecked",page:e.page,runStartTime:e.runStartTime,specNode:i,status:o,stepIndex:e.stepIndex,title:`Assert checked: ${t.selector}`})}});import{z as Oe}from"zod";var Ii=Oe.object({httpOnly:Oe.boolean().optional().describe("Assert httpOnly flag value"),name:Oe.string().describe("Cookie name to check"),sameSite:Oe.enum(["Strict","Lax","None"]).optional().describe("Assert sameSite value"),secure:Oe.boolean().optional().describe("Assert secure flag value"),value:Oe.string().optional().describe("Expected cookie value (substring match)")}),Mr=g({description:"Assert properties of a browser cookie. Check existence, value, and security flags (httpOnly, secure, sameSite).",name:"assert_cookie",schema:Ii,execute:async(e,t)=>{let n=performance.now(),o=(await e.page.context().cookies()).find(d=>d.name===t.name),a=o==null?[{description:`Cookie "${t.name}" exists`,detail:"Cookie not found",status:"failed"}]:[{description:`Cookie "${t.name}" exists`,detail:void 0,status:"passed"},...Ui({cookie:o,input:t})],s=a.some(d=>d.status==="failed"),i=s?"failed":"passed",c={id:`agent-step-${String(e.stepIndex)}`,name:{type:"static",value:t.name},type:"assertCookie"};return A({assertions:a,detail:s?a.filter(d=>d.status==="failed").map(d=>d.detail).join("; "):"Cookie OK",duration:performance.now()-n,nodeType:"assertCookie",page:e.page,runStartTime:e.runStartTime,specNode:c,status:i,stepIndex:e.stepIndex,title:`Assert cookie: ${t.name}`})}});function Ui({cookie:e,input:t}){return[ji(t.value,e.value),qr("httpOnly",t.httpOnly,e.httpOnly),qr("secure",t.secure,e.secure),_i("sameSite",t.sameSite,e.sameSite)].filter(n=>n!=null)}function ji(e,t){if(e==null)return;let n=t.includes(e);return{description:`Cookie value contains "${e}"`,detail:n?void 0:`Got: "${t}"`,status:n?"passed":"failed"}}function qr(e,t,n){if(t!=null)return{description:`Cookie ${e} is ${String(t)}`,detail:n===t?void 0:`Got: ${String(n)}`,status:n===t?"passed":"failed"}}function _i(e,t,n){if(t!=null)return{description:`Cookie ${e} is ${t}`,detail:n===t?void 0:`Got: ${n}`,status:n===t?"passed":"failed"}}import{z as Gr}from"zod";var $i=Gr.object({selector:Gr.string().describe("CSS selector for the element to check focus on")}),Jr=g({description:"Assert that an element has keyboard focus. Use for accessibility tab-order testing.",name:"assert_focused",schema:$i,execute:async(e,t)=>{let n=performance.now(),o=!!await e.page.locator(t.selector).evaluate("(el) => document.activeElement === el").catch(()=>!1),a=o?"passed":"failed",s=[{description:`Element ${t.selector} is focused`,detail:o?void 0:"Element does not have focus",status:a}],l={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertFocused"};return A({assertions:s,detail:o?"Element is focused":"Element does not have focus",duration:performance.now()-n,nodeType:"assertFocused",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert focused: ${t.selector}`})}});import{z as Ie}from"zod";var Bi=Ie.object({bodyContains:Ie.string().optional().describe("Assert response body contains this string"),headerName:Ie.string().optional().describe("Response header name to check"),headerValue:Ie.string().optional().describe("Expected value the header should contain"),status:Ie.number().int().optional().describe("Expected HTTP status code"),urlPattern:Ie.string().describe("URL substring to match the response against")}),zr=g({description:"Wait for a network response matching the URL pattern and assert on its status, body, or headers. Useful for verifying API calls and security headers (CSP, CORS).",name:"assert_response",schema:Bi,execute:async(e,t)=>{let n=performance.now(),r=await e.page.waitForResponse(c=>c.url().includes(t.urlPattern),{timeout:1e4}),o=[Di(t.status,r.status()),await Fi(t.bodyContains,r),Vi(t.headerName,t.headerValue,r.headers())].filter(c=>c!=null),a=o.length===0?[{description:`Response matching "${t.urlPattern}" received`,detail:void 0,status:"passed"}]:o,s=a.some(c=>c.status==="failed"),l={id:`agent-step-${String(e.stepIndex)}`,type:"assertResponse",urlPattern:{type:"static",value:t.urlPattern}};return A({assertions:a,detail:s?a.filter(c=>c.status==="failed").map(c=>c.detail).join("; "):"Response OK",duration:performance.now()-n,nodeType:"assertResponse",page:e.page,runStartTime:e.runStartTime,specNode:l,status:s?"failed":"passed",stepIndex:e.stepIndex,title:`Assert response: ${t.urlPattern}`})}});function Di(e,t){if(e!=null)return{description:`Response status equals ${String(e)}`,detail:t===e?void 0:`Got: ${String(t)}`,status:t===e?"passed":"failed"}}async function Fi(e,t){if(e==null)return;let r=(await t.text()).includes(e);return{description:`Response body contains "${e}"`,detail:r?void 0:"Not found in response body",status:r?"passed":"failed"}}function Vi(e,t,n){if(e==null||t==null)return;let r=n[e.toLowerCase()],o=r!=null&&r.includes(t);return{description:`Response header "${e}" contains "${t}"`,detail:o?void 0:`Got: "${r??"(missing)"}"`,status:o?"passed":"failed"}}import{z as ln}from"zod";var Wi=ln.object({expected:ln.string().describe("The expected text content"),selector:ln.string().describe("CSS selector for the element to check")}),Hr=g({description:"Assert that an element's text content matches the expected value",name:"assert_text",schema:Wi,execute:async(e,t)=>{let n=performance.now(),r=await e.page.locator(t.selector).textContent({timeout:5e3}).catch(()=>null),o=r!=null&&r.includes(t.expected),a=o?"passed":"failed",s=[{description:`Text contains "${t.expected}"`,detail:`Actual: "${r??"(not found)"}"`,status:a}],i=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:i,locator:{by:"css",value:t.selector},operator:"contains",type:"assertText"};return A({assertions:s,detail:o?`Text matches: "${t.expected}"`:`Expected "${t.expected}", got "${r??"(not found)"}"`,duration:performance.now()-n,nodeType:"assertText",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert text: ${t.selector}`})}});import{z as cn}from"zod";var qi=cn.object({expected:cn.string().describe("Expected page title or substring"),operator:cn.enum(["equals","contains","startsWith","endsWith"]).describe("Comparison operator").default("contains")}),Xr=g({description:"Assert that the page title matches an expected value",name:"assert_title",schema:qi,execute:async(e,t)=>{let n=performance.now(),r=await e.page.title(),o=Mi({actual:r,expected:t.expected,operator:t.operator}),a=o?"passed":"failed",s=[{description:`Title ${t.operator} "${t.expected}"`,detail:o?void 0:`Got: "${r}"`,status:a}],i=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:i,operator:t.operator,type:"assertTitle"};return A({assertions:s,detail:o?"Title matches":`Expected title ${t.operator} "${t.expected}", got "${r}"`,duration:performance.now()-n,nodeType:"assertTitle",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert title ${t.operator} "${t.expected}"`})}});function Mi({actual:e,expected:t,operator:n}){return n==="equals"?e===t:n==="contains"?e.includes(t):n==="startsWith"?e.startsWith(t):n==="endsWith"?e.endsWith(t):!1}import{z as Kr}from"zod";var Gi=Kr.object({selector:Kr.string().describe("CSS selector for the element to check")}),Yr=g({description:"Assert that an element matching the selector is visible on the page",name:"assert_visible",schema:Gi,execute:async(e,t)=>{let n=performance.now(),r=await e.page.locator(t.selector).isVisible().catch(()=>!1),o=r?"passed":"failed",a=[{description:`Element ${t.selector} is visible`,detail:r?"Element is visible":"Element is not visible",status:o}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertVisible"};return A({assertions:a,detail:r?"Element is visible":"Element is not visible",duration:performance.now()-n,nodeType:"assertVisible",page:e.page,runStartTime:e.runStartTime,specNode:i,status:o,stepIndex:e.stepIndex,title:`Assert visible: ${t.selector}`})}});import{z as Qr}from"zod";var Ji=Qr.object({selector:Qr.string().describe("CSS selector for the checkbox to check")}),Zr=g({description:"Check a checkbox matching the CSS selector",name:"check",schema:Ji,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).check({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"check"};return A({assertions:[],detail:`Checked ${t.selector}`,duration:performance.now()-n,nodeType:"check",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Check ${t.selector}`})}});import{z as eo}from"zod";var zi=eo.object({selector:eo.string().describe("CSS selector for the input to clear")}),to=g({description:"Clear the contents of an input field",name:"clear",schema:zi,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).clear({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"clear"};return A({assertions:[],detail:`Cleared ${t.selector}`,duration:performance.now()-n,nodeType:"clear",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Clear ${t.selector}`})}});import{z as no}from"zod";var Hi=no.object({selector:no.string().describe("CSS selector for the element to click")}),ro=g({description:"Click an element matching the CSS selector",name:"click",schema:Hi,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).click({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"click"};return A({assertions:[],detail:`Clicked ${t.selector}`,duration:performance.now()-n,nodeType:"click",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Click ${t.selector}`})}});import{z as dn}from"zod";var Xi=dn.object({action:dn.enum(["read","write"]).describe("Whether to read from or write to the clipboard"),value:dn.string().optional().describe("Text to write (required for write action)")}),oo=g({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:Xi,execute:async(e,t)=>{let n=performance.now(),r=`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 i={action:"write",id:r,type:"clipboard",value:{type:"static",value:t.value}};return A({assertions:[],detail:`Wrote to clipboard: "${t.value}"`,duration:performance.now()-n,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:i,status:"passed",stepIndex:e.stepIndex,title:"Clipboard write"})}let o=String(await e.page.evaluate("navigator.clipboard.readText()")),a={action:"read",id:r,type:"clipboard"};return A({assertions:[],detail:`Clipboard contents: "${o}"`,duration:performance.now()-n,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:a,status:"passed",stepIndex:e.stepIndex,title:"Clipboard read"})}});import{z as Tt}from"zod";var ao=Tt.object({summary:Tt.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:Tt.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.")}),so={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:{...Tt.toJSONSchema(ao,{target:"draft-2020-12"}),type:"object"},name:"complete_test"},name:"complete_test",execute(e,t){let n=ao.parse(t),r={kind:"verdict",summary:n.summary,toolOutput:`Verdict: ${n.verdict}
4
- ${n.summary}`,verdict:n.verdict};return Promise.resolve(r)}};import{z as io}from"zod";var Ki=io.object({selector:io.string().describe("CSS selector for the element to extract text from")}),lo=g({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:Ki,execute:async(e,t)=>{let n=performance.now(),o=await e.page.locator(t.selector).textContent({timeout:5e3})??"",s={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"extractText",variable:"extractedText"};return A({assertions:[],detail:`Extracted text: "${o}"`,duration:performance.now()-n,nodeType:"extractText",page:e.page,runStartTime:e.runStartTime,specNode:s,status:"passed",stepIndex:e.stepIndex,title:`Extract text from ${t.selector}`})}});import{z as pn}from"zod";var Yi=pn.object({selector:pn.string().describe("CSS selector for the input element"),value:pn.string().describe("The text to type into the element")}),co=g({description:"Clear and type text into an input element matching the CSS selector",name:"fill",schema:Yi,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).fill(t.value,{timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"fill",value:{type:"static",value:t.value}};return A({assertions:[],detail:`Filled ${t.selector} with "${t.value}"`,duration:performance.now()-n,nodeType:"fill",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Fill ${t.selector}`})}});import{z as po}from"zod";var Qi=po.object({level:po.string().describe("Filter by log level: 'error', 'warning', 'log', 'info', 'debug', or 'all'").default("all")}),uo=g({description:"Get console log messages from the browser. Optionally filter by level (error, warning, log, info, debug, all).",name:"get_console_logs",schema:Qi,execute:(e,t)=>{let n=t.level==="all"?e.monitor.consoleEntries:e.monitor.consoleEntries.filter(o=>o.level===t.level);if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console ${t.level==="all"?"messages":t.level+" messages"} recorded.`};let r=n.map(o=>Zi(o)).join(`
2
+ var fi=Object.create;var Ir=Object.defineProperty;var mi=Object.getOwnPropertyDescriptor;var yi=Object.getOwnPropertyNames;var gi=Object.getPrototypeOf,hi=Object.prototype.hasOwnProperty;var St=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var wi=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of yi(t))!hi.call(e,o)&&o!==n&&Ir(e,o,{get:()=>t[o],enumerable:!(r=mi(t,o))||r.enumerable});return e};var Si=(e,t,n)=>(n=e!=null?fi(gi(e)):{},wi(t||!e||!e.__esModule?Ir(n,"default",{value:e,enumerable:!0}):n,e));var Ca=St(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.timingSafeEqual=void 0;function va(e,t=""){if(!e)throw new Error(t)}function qd(e,t){if(e.byteLength!==t.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),t instanceof DataView||(t=new DataView(ArrayBuffer.isView(t)?t.buffer:t)),va(e instanceof DataView),va(t instanceof DataView);let n=e.byteLength,r=0,o=-1;for(;++o<n;)r|=e.getUint8(o)^t.getUint8(o);return r===0}Ot.timingSafeEqual=qd});var Pa=St(z=>{"use strict";var Md=z&&z.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(z,"__esModule",{value:!0});var _=256,zn=(function(){function e(t){t===void 0&&(t="="),this._paddingCharacter=t}return e.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(t*8+5)/6|0},e.prototype.encode=function(t){for(var n="",r=0;r<t.length-2;r+=3){var o=t[r]<<16|t[r+1]<<8|t[r+2];n+=this._encodeByte(o>>>18&63),n+=this._encodeByte(o>>>12&63),n+=this._encodeByte(o>>>6&63),n+=this._encodeByte(o>>>0&63)}var a=t.length-r;if(a>0){var o=t[r]<<16|(a===2?t[r+1]<<8:0);n+=this._encodeByte(o>>>18&63),n+=this._encodeByte(o>>>12&63),a===2?n+=this._encodeByte(o>>>6&63):n+=this._paddingCharacter||"",n+=this._paddingCharacter||""}return n},e.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(t*6+7)/8|0},e.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},e.prototype.decode=function(t){if(t.length===0)return new Uint8Array(0);for(var n=this._getPaddingLength(t),r=t.length-n,o=new Uint8Array(this.maxDecodedLength(r)),a=0,s=0,i=0,l=0,c=0,d=0,p=0;s<r-4;s+=4)l=this._decodeChar(t.charCodeAt(s+0)),c=this._decodeChar(t.charCodeAt(s+1)),d=this._decodeChar(t.charCodeAt(s+2)),p=this._decodeChar(t.charCodeAt(s+3)),o[a++]=l<<2|c>>>4,o[a++]=c<<4|d>>>2,o[a++]=d<<6|p,i|=l&_,i|=c&_,i|=d&_,i|=p&_;if(s<r-1&&(l=this._decodeChar(t.charCodeAt(s)),c=this._decodeChar(t.charCodeAt(s+1)),o[a++]=l<<2|c>>>4,i|=l&_,i|=c&_),s<r-2&&(d=this._decodeChar(t.charCodeAt(s+2)),o[a++]=c<<4|d>>>2,i|=d&_),s<r-3&&(p=this._decodeChar(t.charCodeAt(s+3)),o[a++]=d<<6|p,i|=p&_),i!==0)throw new Error("Base64Coder: incorrect characters for decoding");return o},e.prototype._encodeByte=function(t){var n=t;return n+=65,n+=25-t>>>8&6,n+=51-t>>>8&-75,n+=61-t>>>8&-15,n+=62-t>>>8&3,String.fromCharCode(n)},e.prototype._decodeChar=function(t){var n=_;return n+=(42-t&t-44)>>>8&-_+t-43+62,n+=(46-t&t-48)>>>8&-_+t-47+63,n+=(47-t&t-58)>>>8&-_+t-48+52,n+=(64-t&t-91)>>>8&-_+t-65+0,n+=(96-t&t-123)>>>8&-_+t-97+26,n},e.prototype._getPaddingLength=function(t){var n=0;if(this._paddingCharacter){for(var r=t.length-1;r>=0&&t[r]===this._paddingCharacter;r--)n++;if(t.length<4||n>2)throw new Error("Base64Coder: incorrect padding")}return n},e})();z.Coder=zn;var ot=new zn;function Gd(e){return ot.encode(e)}z.encode=Gd;function Jd(e){return ot.decode(e)}z.decode=Jd;var xa=(function(e){Md(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype._encodeByte=function(n){var r=n;return r+=65,r+=25-n>>>8&6,r+=51-n>>>8&-75,r+=61-n>>>8&-13,r+=62-n>>>8&49,String.fromCharCode(r)},t.prototype._decodeChar=function(n){var r=_;return r+=(44-n&n-46)>>>8&-_+n-45+62,r+=(94-n&n-96)>>>8&-_+n-95+63,r+=(47-n&n-58)>>>8&-_+n-48+52,r+=(64-n&n-91)>>>8&-_+n-65+0,r+=(96-n&n-123)>>>8&-_+n-97+26,r},t})(zn);z.URLSafeCoder=xa;var La=new xa;function zd(e){return La.encode(e)}z.encodeURLSafe=zd;function Hd(e){return La.decode(e)}z.decodeURLSafe=Hd;z.encodedLength=function(e){return ot.encodedLength(e)};z.maxDecodedLength=function(e){return ot.maxDecodedLength(e)};z.decodedLength=function(e){return ot.decodedLength(e)}});var Oa=St((Ea,It)=>{"use strict";(function(e,t){var n={};t(n);var r=n.default;for(var o in n)r[o]=n[o];typeof It=="object"&&typeof It.exports=="object"?It.exports=r:typeof define=="function"&&define.amd?define(function(){return r}):e.sha256=r})(Ea,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(p,u,m,y,g){for(var S,k,b,C,L,v,q,x,$,B,Xe,Ke,wt;g>=64;){for(S=u[0],k=u[1],b=u[2],C=u[3],L=u[4],v=u[5],q=u[6],x=u[7],B=0;B<16;B++)Xe=y+B*4,p[B]=(m[Xe]&255)<<24|(m[Xe+1]&255)<<16|(m[Xe+2]&255)<<8|m[Xe+3]&255;for(B=16;B<64;B++)$=p[B-2],Ke=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10,$=p[B-15],wt=($>>>7|$<<25)^($>>>18|$<<14)^$>>>3,p[B]=(Ke+p[B-7]|0)+(wt+p[B-16]|0);for(B=0;B<64;B++)Ke=(((L>>>6|L<<26)^(L>>>11|L<<21)^(L>>>25|L<<7))+(L&v^~L&q)|0)+(x+(t[B]+p[B]|0)|0)|0,wt=((S>>>2|S<<30)^(S>>>13|S<<19)^(S>>>22|S<<10))+(S&k^S&b^k&b)|0,x=q,q=v,v=L,L=C+Ke|0,C=b,b=k,k=S,S=Ke+wt|0;u[0]+=S,u[1]+=k,u[2]+=b,u[3]+=C,u[4]+=L,u[5]+=v,u[6]+=q,u[7]+=x,y+=64,g-=64}return y}var r=(function(){function p(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return p.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},p.prototype.clean=function(){for(var u=0;u<this.buffer.length;u++)this.buffer[u]=0;for(var u=0;u<this.temp.length;u++)this.temp[u]=0;this.reset()},p.prototype.update=function(u,m){if(m===void 0&&(m=u.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var y=0;if(this.bytesHashed+=m,this.bufferLength>0){for(;this.bufferLength<64&&m>0;)this.buffer[this.bufferLength++]=u[y++],m--;this.bufferLength===64&&(n(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(m>=64&&(y=n(this.temp,this.state,u,y,m),m%=64);m>0;)this.buffer[this.bufferLength++]=u[y++],m--;return this},p.prototype.finish=function(u){if(!this.finished){var m=this.bytesHashed,y=this.bufferLength,g=m/536870912|0,S=m<<3,k=m%64<56?64:128;this.buffer[y]=128;for(var b=y+1;b<k-8;b++)this.buffer[b]=0;this.buffer[k-8]=g>>>24&255,this.buffer[k-7]=g>>>16&255,this.buffer[k-6]=g>>>8&255,this.buffer[k-5]=g>>>0&255,this.buffer[k-4]=S>>>24&255,this.buffer[k-3]=S>>>16&255,this.buffer[k-2]=S>>>8&255,this.buffer[k-1]=S>>>0&255,n(this.temp,this.state,this.buffer,0,k),this.finished=!0}for(var b=0;b<8;b++)u[b*4+0]=this.state[b]>>>24&255,u[b*4+1]=this.state[b]>>>16&255,u[b*4+2]=this.state[b]>>>8&255,u[b*4+3]=this.state[b]>>>0&255;return this},p.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},p.prototype._saveState=function(u){for(var m=0;m<this.state.length;m++)u[m]=this.state[m]},p.prototype._restoreState=function(u,m){for(var y=0;y<this.state.length;y++)this.state[y]=u[y];this.bytesHashed=m,this.finished=!1,this.bufferLength=0},p})();e.Hash=r;var o=(function(){function p(u){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var m=new Uint8Array(this.blockSize);if(u.length>this.blockSize)new r().update(u).finish(m).clean();else for(var y=0;y<u.length;y++)m[y]=u[y];for(var y=0;y<m.length;y++)m[y]^=54;this.inner.update(m);for(var y=0;y<m.length;y++)m[y]^=106;this.outer.update(m),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var y=0;y<m.length;y++)m[y]=0}return p.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},p.prototype.clean=function(){for(var u=0;u<this.istate.length;u++)this.ostate[u]=this.istate[u]=0;this.inner.clean(),this.outer.clean()},p.prototype.update=function(u){return this.inner.update(u),this},p.prototype.finish=function(u){return this.outer.finished?this.outer.finish(u):(this.inner.finish(u),this.outer.update(u,this.digestLength).finish(u)),this},p.prototype.digest=function(){var u=new Uint8Array(this.digestLength);return this.finish(u),u},p})();e.HMAC=o;function a(p){var u=new r().update(p),m=u.digest();return u.clean(),m}e.hash=a,e.default=a;function s(p,u){var m=new o(p).update(u),y=m.digest();return m.clean(),y}e.hmac=s;function i(p,u,m,y){var g=y[0];if(g===0)throw new Error("hkdf: cannot expand more");u.reset(),g>1&&u.update(p),m&&u.update(m),u.update(y),u.finish(p),y[0]++}var l=new Uint8Array(e.digestLength);function c(p,u,m,y){u===void 0&&(u=l),y===void 0&&(y=32);for(var g=new Uint8Array([1]),S=s(u,p),k=new o(S),b=new Uint8Array(k.digestLength),C=b.length,L=new Uint8Array(y),v=0;v<y;v++)C===b.length&&(i(b,k,m,g),C=0),L[v]=b[C++];return k.clean(),b.fill(0),g.fill(0),L}e.hkdf=c;function d(p,u,m,y){for(var g=new o(p),S=g.digestLength,k=new Uint8Array(4),b=new Uint8Array(S),C=new Uint8Array(S),L=new Uint8Array(y),v=0;v*S<y;v++){var q=v+1;k[0]=q>>>24&255,k[1]=q>>>16&255,k[2]=q>>>8&255,k[3]=q>>>0&255,g.reset(),g.update(u),g.update(k),g.finish(C);for(var x=0;x<S;x++)b[x]=C[x];for(var x=2;x<=m;x++){g.reset(),g.update(C).finish(C);for(var $=0;$<S;$++)b[$]^=C[$]}for(var x=0;x<S&&v*S+x<y;x++)L[v*S+x]=b[x]}for(var v=0;v<S;v++)b[v]=C[v]=0;for(var v=0;v<4;v++)k[v]=0;return g.clean(),L}e.pbkdf2=d})});var ja=St(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.Webhook=Be.WebhookVerificationError=void 0;var Xd=Ca(),Ia=Pa(),Kd=Oa(),Ua=300,Hn=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="ExtendableError",this.stack=new Error(t).stack}},me=class e extends Hn{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="WebhookVerificationError"}};Be.WebhookVerificationError=me;var Ut=class e{constructor(t,n){if(!t)throw new Error("Secret can't be empty.");if(n?.format==="raw")t instanceof Uint8Array?this.key=t:this.key=Uint8Array.from(t,r=>r.charCodeAt(0));else{if(typeof t!="string")throw new Error("Expected secret to be of type string");t.startsWith(e.prefix)&&(t=t.substring(e.prefix.length)),this.key=Ia.decode(t)}}verify(t,n){let r={};for(let u of Object.keys(n))r[u.toLowerCase()]=n[u];let o=r["webhook-id"],a=r["webhook-signature"],s=r["webhook-timestamp"];if(!a||!o||!s)throw new me("Missing required headers");let i=this.verifyTimestamp(s),c=this.sign(o,i,t).split(",")[1],d=a.split(" "),p=new globalThis.TextEncoder;for(let u of d){let[m,y]=u.split(",");if(m==="v1"&&(0,Xd.timingSafeEqual)(p.encode(y),p.encode(c)))return JSON.parse(t.toString())}throw new me("No matching signature found")}sign(t,n,r){if(typeof r!="string")if(r.constructor.name==="Buffer")r=r.toString();else throw new Error("Expected payload to be of type string or Buffer.");let o=new TextEncoder,a=Math.floor(n.getTime()/1e3),s=o.encode(`${t}.${a}.${r}`);return`v1,${Ia.encode(Kd.hmac(this.key,s))}`}verifyTimestamp(t){let n=Math.floor(Date.now()/1e3),r=parseInt(t,10);if(isNaN(r))throw new me("Invalid Signature Headers");if(n-r>Ua)throw new me("Message timestamp too old");if(r>n+Ua)throw new me("Message timestamp too new");return new Date(r*1e3)}};Be.Webhook=Ut;Ut.prefix="whsec_"});import{config as pi}from"dotenv";import tn from"path";import{fileURLToPath as Dm}from"url";import st from"fs";import De from"path";import{z as kt}from"zod";var nn=kt.object({from:kt.string().min(1).describe("Key of the source state in the states record"),to:kt.string().min(1).describe("Key of the target state in the states record"),workflow:kt.string().min(1).describe("Filename (without .json) of the workflow in .ripplo/workflows/ that executes this edge")}).describe("A directed edge between two states, executed by a workflow");import{z as de}from"zod";import{z as j}from"zod";var Ur=j.object({precondition:j.string().min(1).describe("Name of the precondition to check or execute, e.g. 'auth:admin'")}).describe("Request payload sent by Ripplo to both the check and execute endpoints"),bt=j.object({satisfied:j.boolean().describe("Whether the precondition is already satisfied. If true, execution is skipped.")}).describe("Response from POST {preconditionApiUrl}/check"),At=j.object({data:j.record(j.string(),j.string()).optional().describe("Key-value data returned by the precondition. Values are injected as variables that can be interpolated into route patterns ({{key}}) and workflow spec variable references. For example, a data:project precondition should return { projectId: 'clx...' } so the route /projects/{{projectId}}/settings resolves correctly."),error:j.string().optional().describe("Human-readable error message if success is false"),navigateTo:j.string().optional().describe("URL to navigate the browser to after this precondition executes. Use this to set the starting page for the test \u2014 e.g. an auth token URL or the page the workflow begins on. If multiple preconditions return navigateTo, only the last one is used."),success:j.boolean().describe("Whether the precondition was successfully satisfied")}).describe("Response from PUT {preconditionApiUrl}/execute. Set-Cookie headers are automatically captured and injected into the browser context. The data field provides values for route param interpolation and workflow variables."),jr=j.object({preconditions:j.array(j.string().min(1)).describe("Names of all preconditions that were executed during this run")}).describe("Request payload sent after a run completes. Fire-and-forget \u2014 errors are logged but don't fail the run."),_r=j.object({error:j.string().optional().describe("Human-readable error message if success is false"),success:j.boolean().describe("Whether teardown completed successfully")}).describe("Response from PUT {preconditionApiUrl}/teardown"),Pe=j.object({depends:j.array(j.string().min(1)).optional().describe("Names of other preconditions that must be satisfied first. Resolved via topological sort; cycles are rejected at validation time."),description:j.string().min(1).describe("Human-readable description of what this precondition ensures"),returns:j.array(j.string().min(1)).optional().describe("Keys that the execute response's data field will contain. e.g. ['projectId', 'workflowId']. These are used for route param interpolation ({{projectId}}) and workflow variables. Declared here so generated types are strongly typed per precondition.")}).describe("A named precondition declared at the graph level. States reference these by name.");import{z as Rt}from"zod";var rn=Rt.object({preconditions:Rt.array(Rt.string().min(1)).describe("Ordered list of precondition names to satisfy before entering this state"),route:Rt.string().min(1).describe("URL pattern with {{placeholders}} for dynamic segments, e.g. '/projects/{{projectId}}/settings'")}).describe("A distinct application state \u2014 a unique combination of location, auth context, and data conditions");var Ee=de.object({edges:de.array(nn).describe("Directed edges between states, each executed by a workflow"),preconditions:de.record(de.string(),Pe).describe("Named preconditions keyed by name (e.g. 'auth:admin', 'data:three-projects'). States reference these by name."),resetPrecondition:de.string().optional().describe("Name of a precondition to run before every state setup as a global clean slate"),states:de.record(de.string(),rn).describe("States keyed by stable ID (kebab-case)"),version:de.literal(3).describe("Schema version, always 3")}).describe("Ripplo State Graph v3 \u2014 models application states, edges, and executable preconditions");function on(e){let t=Ee.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(n=>({message:n.message,path:n.path.join(".")})),success:!1}}function ki(e){let t=e.preconditions,n=new Set,r=new Set,o=[];function a(s){if(r.has(s)){o.push(`Precondition "${s}" has a circular dependency`);return}if(n.has(s))return;n.add(s),r.add(s);let i=t[s];i?.depends!=null&&i.depends.forEach(l=>{a(l)}),r.delete(s)}return Object.keys(t).forEach(s=>{a(s)}),o}function an(e){let t=[],n=new Set(Object.keys(e.preconditions)),r=new Set(Object.keys(e.states));e.edges.forEach((l,c)=>{r.has(l.from)||t.push({message:`References non-existent source state "${l.from}"`,path:`edges[${String(c)}].from`}),r.has(l.to)||t.push({message:`References non-existent target state "${l.to}"`,path:`edges[${String(c)}].to`})}),Object.entries(e.states).forEach(([l,c])=>{c.preconditions.forEach(d=>{n.has(d)||t.push({message:`References non-existent precondition "${d}"`,path:`states.${l}.preconditions`})})}),Object.entries(e.preconditions).forEach(([l,c])=>{c.depends!=null&&c.depends.forEach(d=>{n.has(d)||t.push({message:`Depends on non-existent precondition "${d}"`,path:`preconditions.${l}.depends`})})}),e.resetPrecondition!=null&&!n.has(e.resetPrecondition)&&t.push({message:`References non-existent precondition "${e.resetPrecondition}"`,path:"resetPrecondition"});let o=new Set(e.edges.flatMap(l=>[l.from,l.to]));Object.keys(e.states).forEach(l=>{o.has(l)||t.push({message:"State is not referenced by any edge (orphan)",path:`states.${l}`})});let a=new Set;Object.values(e.states).forEach(l=>{l.preconditions.forEach(c=>a.add(c))}),Object.values(e.preconditions).forEach(l=>{l.depends!=null&&l.depends.forEach(c=>a.add(c))}),e.resetPrecondition!=null&&a.add(e.resetPrecondition),Object.keys(e.preconditions).forEach(l=>{a.has(l)||t.push({message:"Defined but never used by any state or dependency",path:`preconditions.${l}`})});let s=new Set;return e.edges.forEach((l,c)=>{let d=`${l.from}|${l.to}|${l.workflow}`;s.has(d)&&t.push({message:`Duplicate edge from "${l.from}" to "${l.to}" with workflow "${l.workflow}"`,path:`edges[${String(c)}]`}),s.add(d)}),ki(e).forEach(l=>t.push({message:l,path:"preconditions"})),t}function T({locator:e,page:t}){switch(e.by){case"css":return t.locator(e.value);case"testId":return t.getByTestId(e.value);case"role":return t.getByRole(e.role,{exact:e.exact,name:e.name});case"text":return t.getByText(e.value,{exact:e.exact});case"label":return t.getByLabel(e.value,{exact:e.exact});case"placeholder":return t.getByPlaceholder(e.value);case"altText":return t.getByAltText(e.value)}}function Ye({defs:e}){return e==null?{}:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Ai({def:n,name:t})]))}var bi={boolean:!1,number:0,string:""};function Ai({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??bi[e.type]??""}function ke({ref:e,variables:t}){if(e.type==="static")return e.value;let n=t[e.name];if(n==null)throw new Error(`Variable "${e.name}" is not defined`);return n}function E({ref:e,variables:t}){let n=String(ke({ref:e,variables:t}));return Ri({raw:n,variables:t})}function Ri({raw:e,variables:t}){return e.replaceAll(/\{\{(\w+)\}\}/g,(n,r)=>{let o=t[r];if(o==null)throw new Error(`Template variable "{{${r}}}" is not defined`);return String(o)})}function sn({ref:e,variables:t}){let n=ke({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 oe({name:e,store:t,value:n}){return{...t,[e]:n}}async function $r({node:e,page:t,timeout:n}){await T({locator:e.source,page:t}).dragTo(T({locator:e.target,page:t}),{timeout:n})}async function Br({node:e,page:t,timeout:n}){await T({locator:e.locator,page:t}).click({button:"right",timeout:n})}function Dr({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 Fr({node:e,page:t}){let n=e.x??0,r=e.y??0;if(e.locator==null){await t.mouse.wheel(n,r);return}let a=await T({locator:e.locator,page:t}).elementHandle();if(a==null)throw new Error("scroll target element not found");await a.evaluate("([dx, dy]) => this.scrollBy(dx, dy)",[n,r])}async function Vr({node:e,page:t,variables:n}){if(e.action==="write"){if(e.value==null)throw new Error("clipboard write requires a value");let o=E({ref:e.value,variables:n}),a=JSON.stringify(o);return await t.evaluate(`navigator.clipboard.writeText(${a})`),{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:oe({name:e.variable,store:n,value:r})}}async function Wr({node:e,page:t}){let n=t.context();e.state==="granted"?await n.grantPermissions([e.permission]):await n.clearPermissions()}async function ln({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 Ti({node:e,page:t,timeout:n,variables:r});case"rightClick":return await Br({node:e,page:t,timeout:n}),{variables:r};case"goto":{let o=E({ref:e.url,variables:r});return await t.goto(o,{timeout:n,waitUntil:"domcontentloaded"}),{variables:r}}case"fill":{let o=E({ref:e.value,variables:r});return await T({locator:e.locator,page:t}).fill(o,{timeout:n}),{variables:r}}case"select":{let o=E({ref:e.value,variables:r});return await T({locator:e.locator,page:t}).selectOption(o,{timeout:n}),{variables:r}}case"type":{let o=E({ref:e.value,variables:r});return await T({locator:e.locator,page:t}).pressSequentially(o,{timeout:n}),{variables:r}}case"press":return await Ci({node:e,page:t,timeout:n}),{variables:r};case"drag":return await $r({node:e,page:t,timeout:n}),{variables:r};case"upload":return await T({locator:e.locator,page:t}).setInputFiles(e.files,{timeout:n}),{variables:r};case"extractText":{let o=await T({locator:e.locator,page:t}).textContent({timeout:n});if(o==null)throw new Error("extractText: element had no text content");return{variables:oe({name:e.variable,store:r,value:o})}}case"setVariable":{let o=ke({ref:e.value,variables:r});return{variables:oe({name:e.variable,store:r,value:o})}}case"fail":throw new Error(e.message);case"waitFor":return await T({locator:e.locator,page:t}).waitFor({state:e.state??"visible",timeout:n}),{variables:r};case"waitForUrl":{let o=E({ref:e.expected,variables:r});return await t.waitForURL(vi({expected:o,operator:e.operator}),{timeout:n}),{variables:r}}case"waitForResponse":{let o=E({ref:e.urlPattern,variables:r});return await t.waitForResponse(a=>a.url().includes(o),{timeout:n}),{variables:r}}case"waitForRequest":{let o=E({ref:e.urlPattern,variables:r});return await t.waitForRequest(a=>a.url().includes(o),{timeout:n}),{variables:r}}case"wait":return await t.waitForTimeout(e.duration),{variables:r};case"screenshot":return await t.screenshot(),{variables:r};case"setViewport":return await t.setViewportSize({height:e.height,width:e.width}),{variables:r};case"handleDialog":return Dr({node:e,page:t,variables:r});case"scroll":return await Fr({node:e,page:t}),{variables:r};case"clipboard":return Vr({node:e,page:t,variables:r});case"setPermission":return await Wr({node:e,page:t}),{variables:r}}}var Ni={check:"check",clear:"clear",click:"click",dblclick:"dblclick",focus:"focus",hover:"hover",scrollIntoView:"scrollIntoViewIfNeeded",uncheck:"uncheck"};async function Ti({node:e,page:t,timeout:n,variables:r}){return await T({locator:e.locator,page:t})[Ni[e.type]]({timeout:n}),{variables:r}}function vi({expected:e,operator:t}){return n=>{let r=n.toString();return t==="equals"?r===e:t==="notEquals"?r!==e:t==="contains"?r.includes(e):t==="startsWith"?r.startsWith(e):t==="endsWith"?r.endsWith(e):new RegExp(e).test(r)}}async function Ci({node:e,page:t,timeout:n}){e.locator==null?await t.keyboard.press(e.key):await T({locator:e.locator,page:t}).press(e.key,{timeout:n})}import Il from"@anthropic-ai/sdk";import{z as qr}from"zod";import{z as Oi}from"zod";async function pe({page:e,runStartTime:t,targets:n}){let r=e.viewportSize();if(r==null)throw new Error("Page has no viewport set");let[o,a]=await Promise.all([e.screenshot({type:"png"}),Li(n)]),s=o.toString("base64");return{annotations:a,screenshotBase64:s,snapshotTimestamp:Math.round(performance.now()-t),url:e.url(),viewportHeight:r.height,viewportWidth:r.width}}function xi(e){return"locator"in e}async function Li(e){return(await Promise.all(e.map(n=>Pi(n)))).filter(n=>n!=null)}async function Pi(e){if(!xi(e))return{height:0,label:e.label,type:e.type,width:0,x:0,y:0};let t=await e.locator.boundingBox({timeout:2e3}).catch(()=>null);if(t!=null)return{height:Math.round(t.height),label:e.label,type:e.type,width:Math.round(t.width),x:Math.round(t.x),y:Math.round(t.y)}}function Nt({node:e,page:t}){if(e.type==="assertUrl"||e.type==="waitForUrl")return[{label:e.type,type:"urlBar"}];if(e.type==="drag"){let o=T({locator:e.source,page:t}),a=T({locator:e.target,page:t});return[{label:"drag-source",locator:o,type:"action"},{label:"drag-target",locator:a,type:"action"}]}if(!Ei(e))return[];let n=e.type.startsWith("assert")?"assertion":"action",r=T({locator:e.locator,page:t});return[{label:e.type,locator:r,type:n}]}function Ei(e){return"locator"in e&&e.locator!=null}function h({description:e,execute:t,name:n,schema:r}){let o=Oi.toJSONSchema(r,{target:"draft-2020-12"});return{anthropicTool:{description:e,input_schema:{...o,type:"object"},name:n},name:n,async execute(a,s){let i=r.parse(s);return{...await Promise.resolve(t(a,i)),kind:"action"}}}}async function A(e){let t=e.specNode==null?[]:Nt({node:e.specNode,page:e.page}),n=await pe({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,screenshotBase64:n.screenshotBase64,snapshotTimestamp:n.snapshotTimestamp,status:e.status,stepIndex:e.stepIndex,title:e.title,url:n.url,viewportHeight:n.viewportHeight,viewportWidth:n.viewportWidth},a=r.length>0?r.map(s=>`${s.status}: ${s.description} \u2014 ${s.detail??""}`).join(`
3
+ `):`${e.status}: ${e.title}`;return{specNode:e.specNode,stepResult:o,toolOutput:a}}var Ii=qr.object({selector:qr.string().describe("CSS selector for the checkbox or radio button")}),Mr=h({description:"Assert that a checkbox or radio button is checked",name:"assert_checked",schema:Ii,execute:async(e,t)=>{let n=performance.now(),r=await e.page.locator(t.selector).isChecked().catch(()=>!1),o=r?"passed":"failed",a=[{description:`Element ${t.selector} is checked`,detail:r?void 0:"Element is not checked",status:o}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertChecked"};return A({assertions:a,detail:r?"Element is checked":"Element is not checked",duration:performance.now()-n,nodeType:"assertChecked",page:e.page,runStartTime:e.runStartTime,specNode:i,status:o,stepIndex:e.stepIndex,title:`Assert checked: ${t.selector}`})}});import{z as Oe}from"zod";var Ui=Oe.object({httpOnly:Oe.boolean().optional().describe("Assert httpOnly flag value"),name:Oe.string().describe("Cookie name to check"),sameSite:Oe.enum(["Strict","Lax","None"]).optional().describe("Assert sameSite value"),secure:Oe.boolean().optional().describe("Assert secure flag value"),value:Oe.string().optional().describe("Expected cookie value (substring match)")}),Jr=h({description:"Assert properties of a browser cookie. Check existence, value, and security flags (httpOnly, secure, sameSite).",name:"assert_cookie",schema:Ui,execute:async(e,t)=>{let n=performance.now(),o=(await e.page.context().cookies()).find(d=>d.name===t.name),a=o==null?[{description:`Cookie "${t.name}" exists`,detail:"Cookie not found",status:"failed"}]:[{description:`Cookie "${t.name}" exists`,detail:void 0,status:"passed"},...ji({cookie:o,input:t})],s=a.some(d=>d.status==="failed"),i=s?"failed":"passed",c={id:`agent-step-${String(e.stepIndex)}`,name:{type:"static",value:t.name},type:"assertCookie"};return A({assertions:a,detail:s?a.filter(d=>d.status==="failed").map(d=>d.detail).join("; "):"Cookie OK",duration:performance.now()-n,nodeType:"assertCookie",page:e.page,runStartTime:e.runStartTime,specNode:c,status:i,stepIndex:e.stepIndex,title:`Assert cookie: ${t.name}`})}});function ji({cookie:e,input:t}){return[_i(t.value,e.value),Gr("httpOnly",t.httpOnly,e.httpOnly),Gr("secure",t.secure,e.secure),$i("sameSite",t.sameSite,e.sameSite)].filter(n=>n!=null)}function _i(e,t){if(e==null)return;let n=t.includes(e);return{description:`Cookie value contains "${e}"`,detail:n?void 0:`Got: "${t}"`,status:n?"passed":"failed"}}function Gr(e,t,n){if(t!=null)return{description:`Cookie ${e} is ${String(t)}`,detail:n===t?void 0:`Got: ${String(n)}`,status:n===t?"passed":"failed"}}function $i(e,t,n){if(t!=null)return{description:`Cookie ${e} is ${t}`,detail:n===t?void 0:`Got: ${n}`,status:n===t?"passed":"failed"}}import{z as zr}from"zod";var Bi=zr.object({selector:zr.string().describe("CSS selector for the element to check focus on")}),Hr=h({description:"Assert that an element has keyboard focus. Use for accessibility tab-order testing.",name:"assert_focused",schema:Bi,execute:async(e,t)=>{let n=performance.now(),o=!!await e.page.locator(t.selector).evaluate("(el) => document.activeElement === el").catch(()=>!1),a=o?"passed":"failed",s=[{description:`Element ${t.selector} is focused`,detail:o?void 0:"Element does not have focus",status:a}],l={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertFocused"};return A({assertions:s,detail:o?"Element is focused":"Element does not have focus",duration:performance.now()-n,nodeType:"assertFocused",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert focused: ${t.selector}`})}});import{z as Ie}from"zod";var Di=Ie.object({bodyContains:Ie.string().optional().describe("Assert response body contains this string"),headerName:Ie.string().optional().describe("Response header name to check"),headerValue:Ie.string().optional().describe("Expected value the header should contain"),status:Ie.number().int().optional().describe("Expected HTTP status code"),urlPattern:Ie.string().describe("URL substring to match the response against")}),Xr=h({description:"Wait for a network response matching the URL pattern and assert on its status, body, or headers. Useful for verifying API calls and security headers (CSP, CORS).",name:"assert_response",schema:Di,execute:async(e,t)=>{let n=performance.now(),r=await e.page.waitForResponse(c=>c.url().includes(t.urlPattern),{timeout:1e4}),o=[Fi(t.status,r.status()),await Vi(t.bodyContains,r),Wi(t.headerName,t.headerValue,r.headers())].filter(c=>c!=null),a=o.length===0?[{description:`Response matching "${t.urlPattern}" received`,detail:void 0,status:"passed"}]:o,s=a.some(c=>c.status==="failed"),l={id:`agent-step-${String(e.stepIndex)}`,type:"assertResponse",urlPattern:{type:"static",value:t.urlPattern}};return A({assertions:a,detail:s?a.filter(c=>c.status==="failed").map(c=>c.detail).join("; "):"Response OK",duration:performance.now()-n,nodeType:"assertResponse",page:e.page,runStartTime:e.runStartTime,specNode:l,status:s?"failed":"passed",stepIndex:e.stepIndex,title:`Assert response: ${t.urlPattern}`})}});function Fi(e,t){if(e!=null)return{description:`Response status equals ${String(e)}`,detail:t===e?void 0:`Got: ${String(t)}`,status:t===e?"passed":"failed"}}async function Vi(e,t){if(e==null)return;let r=(await t.text()).includes(e);return{description:`Response body contains "${e}"`,detail:r?void 0:"Not found in response body",status:r?"passed":"failed"}}function Wi(e,t,n){if(e==null||t==null)return;let r=n[e.toLowerCase()],o=r!=null&&r.includes(t);return{description:`Response header "${e}" contains "${t}"`,detail:o?void 0:`Got: "${r??"(missing)"}"`,status:o?"passed":"failed"}}import{z as cn}from"zod";var qi=cn.object({expected:cn.string().describe("The expected text content"),selector:cn.string().describe("CSS selector for the element to check")}),Kr=h({description:"Assert that an element's text content matches the expected value",name:"assert_text",schema:qi,execute:async(e,t)=>{let n=performance.now(),r=await e.page.locator(t.selector).textContent({timeout:5e3}).catch(()=>null),o=r!=null&&r.includes(t.expected),a=o?"passed":"failed",s=[{description:`Text contains "${t.expected}"`,detail:`Actual: "${r??"(not found)"}"`,status:a}],i=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:i,locator:{by:"css",value:t.selector},operator:"contains",type:"assertText"};return A({assertions:s,detail:o?`Text matches: "${t.expected}"`:`Expected "${t.expected}", got "${r??"(not found)"}"`,duration:performance.now()-n,nodeType:"assertText",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert text: ${t.selector}`})}});import{z as dn}from"zod";var Mi=dn.object({expected:dn.string().describe("Expected page title or substring"),operator:dn.enum(["equals","contains","startsWith","endsWith"]).describe("Comparison operator").default("contains")}),Yr=h({description:"Assert that the page title matches an expected value",name:"assert_title",schema:Mi,execute:async(e,t)=>{let n=performance.now(),r=await e.page.title(),o=Gi({actual:r,expected:t.expected,operator:t.operator}),a=o?"passed":"failed",s=[{description:`Title ${t.operator} "${t.expected}"`,detail:o?void 0:`Got: "${r}"`,status:a}],i=`agent-step-${String(e.stepIndex)}`,l={expected:{type:"static",value:t.expected},id:i,operator:t.operator,type:"assertTitle"};return A({assertions:s,detail:o?"Title matches":`Expected title ${t.operator} "${t.expected}", got "${r}"`,duration:performance.now()-n,nodeType:"assertTitle",page:e.page,runStartTime:e.runStartTime,specNode:l,status:a,stepIndex:e.stepIndex,title:`Assert title ${t.operator} "${t.expected}"`})}});function Gi({actual:e,expected:t,operator:n}){return n==="equals"?e===t:n==="contains"?e.includes(t):n==="startsWith"?e.startsWith(t):n==="endsWith"?e.endsWith(t):!1}import{z as Qr}from"zod";var Ji=Qr.object({selector:Qr.string().describe("CSS selector for the element to check")}),Zr=h({description:"Assert that an element matching the selector is visible on the page",name:"assert_visible",schema:Ji,execute:async(e,t)=>{let n=performance.now(),r=await e.page.locator(t.selector).isVisible().catch(()=>!1),o=r?"passed":"failed",a=[{description:`Element ${t.selector} is visible`,detail:r?"Element is visible":"Element is not visible",status:o}],i={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"assertVisible"};return A({assertions:a,detail:r?"Element is visible":"Element is not visible",duration:performance.now()-n,nodeType:"assertVisible",page:e.page,runStartTime:e.runStartTime,specNode:i,status:o,stepIndex:e.stepIndex,title:`Assert visible: ${t.selector}`})}});import{z as eo}from"zod";var zi=eo.object({selector:eo.string().describe("CSS selector for the checkbox to check")}),to=h({description:"Check a checkbox matching the CSS selector",name:"check",schema:zi,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).check({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"check"};return A({assertions:[],detail:`Checked ${t.selector}`,duration:performance.now()-n,nodeType:"check",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Check ${t.selector}`})}});import{z as no}from"zod";var Hi=no.object({selector:no.string().describe("CSS selector for the input to clear")}),ro=h({description:"Clear the contents of an input field",name:"clear",schema:Hi,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).clear({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"clear"};return A({assertions:[],detail:`Cleared ${t.selector}`,duration:performance.now()-n,nodeType:"clear",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Clear ${t.selector}`})}});import{z as oo}from"zod";var Xi=oo.object({selector:oo.string().describe("CSS selector for the element to click")}),ao=h({description:"Click an element matching the CSS selector",name:"click",schema:Xi,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).click({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"click"};return A({assertions:[],detail:`Clicked ${t.selector}`,duration:performance.now()-n,nodeType:"click",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Click ${t.selector}`})}});import{z as pn}from"zod";var Ki=pn.object({action:pn.enum(["read","write"]).describe("Whether to read from or write to the clipboard"),value:pn.string().optional().describe("Text to write (required for write action)")}),so=h({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:Ki,execute:async(e,t)=>{let n=performance.now(),r=`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 i={action:"write",id:r,type:"clipboard",value:{type:"static",value:t.value}};return A({assertions:[],detail:`Wrote to clipboard: "${t.value}"`,duration:performance.now()-n,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:i,status:"passed",stepIndex:e.stepIndex,title:"Clipboard write"})}let o=String(await e.page.evaluate("navigator.clipboard.readText()")),a={action:"read",id:r,type:"clipboard"};return A({assertions:[],detail:`Clipboard contents: "${o}"`,duration:performance.now()-n,nodeType:"clipboard",page:e.page,runStartTime:e.runStartTime,specNode:a,status:"passed",stepIndex:e.stepIndex,title:"Clipboard read"})}});import{z as Tt}from"zod";var io=Tt.object({summary:Tt.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:Tt.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.")}),lo={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:{...Tt.toJSONSchema(io,{target:"draft-2020-12"}),type:"object"},name:"complete_test"},name:"complete_test",execute(e,t){let n=io.parse(t),r={kind:"verdict",summary:n.summary,toolOutput:`Verdict: ${n.verdict}
4
+ ${n.summary}`,verdict:n.verdict};return Promise.resolve(r)}};import{z as co}from"zod";var Yi=co.object({selector:co.string().describe("CSS selector for the element to extract text from")}),po=h({description:"Extract the text content of an element matching the CSS selector. Returns the text so you can use it in assertions or decisions.",name:"extract_text",schema:Yi,execute:async(e,t)=>{let n=performance.now(),o=await e.page.locator(t.selector).textContent({timeout:5e3})??"",s={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"extractText",variable:"extractedText"};return A({assertions:[],detail:`Extracted text: "${o}"`,duration:performance.now()-n,nodeType:"extractText",page:e.page,runStartTime:e.runStartTime,specNode:s,status:"passed",stepIndex:e.stepIndex,title:`Extract text from ${t.selector}`})}});import{z as un}from"zod";var Qi=un.object({selector:un.string().describe("CSS selector for the input element"),value:un.string().describe("The text to type into the element")}),uo=h({description:"Clear and type text into an input element matching the CSS selector",name:"fill",schema:Qi,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).fill(t.value,{timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"fill",value:{type:"static",value:t.value}};return A({assertions:[],detail:`Filled ${t.selector} with "${t.value}"`,duration:performance.now()-n,nodeType:"fill",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Fill ${t.selector}`})}});import{z as fo}from"zod";var Zi=fo.object({level:fo.string().describe("Filter by log level: 'error', 'warning', 'log', 'info', 'debug', or 'all'").default("all")}),mo=h({description:"Get console log messages from the browser. Optionally filter by level (error, warning, log, info, debug, all).",name:"get_console_logs",schema:Zi,execute:(e,t)=>{let n=t.level==="all"?e.monitor.consoleEntries:e.monitor.consoleEntries.filter(o=>o.level===t.level);if(n.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console ${t.level==="all"?"messages":t.level+" messages"} recorded.`};let r=n.map(o=>el(o)).join(`
5
5
  `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(n.length)} console messages:
6
- ${r}`}}});function Zi(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as fo}from"zod";var un=50,el=fo.object({urlFilter:fo.string().describe("Optional regex to filter network entries by URL. Omit to see all.").default("")}),mo=g({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:el,execute:(e,t)=>{let n=t.urlFilter.length>0?new RegExp(t.urlFilter,"i"):void 0,r=n==null?e.monitor.networkEntries:e.monitor.networkEntries.filter(i=>n.test(i.url));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No network requests recorded."};let o=r.slice(-un),a=o.map(i=>{let l=i.statusCode==null?"pending":String(i.statusCode),c=i.responseHeaders["content-type"]??"";return`${i.method} ${l} ${i.url} [${c}]`}).join(`
7
- `),s=r.length>un?`
8
- (showing last ${String(un)} of ${String(r.length)})`:"";return{specNode:void 0,stepResult:void 0,toolOutput:`${String(o.length)} network requests:${s}
9
- ${a}`}}});import{z as yo}from"zod";var tl=yo.object({urlPattern:yo.string().describe("Regex pattern to match the request URL")}),go=g({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:tl,execute:(e,t)=>{let n=new RegExp(t.urlPattern,"i"),r=e.monitor.networkEntries.filter(l=>n.test(l.url));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let o=r.at(-1);if(o==null)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let a=o.statusCode==null?"pending":String(o.statusCode),s=Object.entries(o.responseHeaders).map(([l,c])=>` ${l}: ${c}`).join(`
6
+ ${r}`}}});function el(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as yo}from"zod";var fn=50,tl=yo.object({urlFilter:yo.string().describe("Optional regex to filter network entries by URL. Omit to see all.").default("")}),go=h({description:"Get a summary of network requests/responses. Shows method, URL, status code, and content type. Optionally filter by URL regex.",name:"get_network_log",schema:tl,execute:(e,t)=>{let n=t.urlFilter.length>0?new RegExp(t.urlFilter,"i"):void 0,r=n==null?e.monitor.networkEntries:e.monitor.networkEntries.filter(i=>n.test(i.url));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No network requests recorded."};let o=r.slice(-fn),a=o.map(i=>{let l=i.statusCode==null?"pending":String(i.statusCode),c=i.responseHeaders["content-type"]??"";return`${i.method} ${l} ${i.url} [${c}]`}).join(`
7
+ `),s=r.length>fn?`
8
+ (showing last ${String(fn)} of ${String(r.length)})`:"";return{specNode:void 0,stepResult:void 0,toolOutput:`${String(o.length)} network requests:${s}
9
+ ${a}`}}});import{z as ho}from"zod";var nl=ho.object({urlPattern:ho.string().describe("Regex pattern to match the request URL")}),wo=h({description:"Get the full response body for a specific network request matching the URL pattern. Returns the most recent match.",name:"get_network_response",schema:nl,execute:(e,t)=>{let n=new RegExp(t.urlPattern,"i"),r=e.monitor.networkEntries.filter(l=>n.test(l.url));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let o=r.at(-1);if(o==null)return{specNode:void 0,stepResult:void 0,toolOutput:`No network requests matching: ${t.urlPattern}`};let a=o.statusCode==null?"pending":String(o.statusCode),s=Object.entries(o.responseHeaders).map(([l,c])=>` ${l}: ${c}`).join(`
10
10
  `),i=o.responseBody??"(no body captured)";return{specNode:void 0,stepResult:void 0,toolOutput:`${o.method} ${a} ${o.url}
11
11
 
12
12
  Response Headers:
13
13
  ${s}
14
14
 
15
15
  Body:
16
- ${i}`}}});import{z as ho}from"zod";var nl=ho.object({selector:ho.string().optional().describe("CSS selector to scope the tree to a subtree (defaults to full page)")}),wo=g({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:nl,execute:async(e,t)=>{let n=t.selector==null?e.page.locator(":root"):e.page.locator(t.selector);try{return{specNode:void 0,stepResult:void 0,toolOutput:await n.ariaSnapshot()}}catch{return{specNode:void 0,stepResult:void 0,toolOutput:"(unable to capture accessibility tree)"}}}});import{z as rl}from"zod";var ol=rl.object({}),So=g({description:"Get a text representation of the current page content for inspection",name:"get_page_content",schema:ol,execute:async(e,t)=>{let n=await e.page.locator("body").textContent({timeout:5e3}),r=e.page.url(),o=await e.page.title();return{specNode:void 0,stepResult:void 0,toolOutput:`URL: ${r}
16
+ ${i}`}}});import{z as So}from"zod";var rl=So.object({selector:So.string().optional().describe("CSS selector to scope the tree to a subtree (defaults to full page)")}),ko=h({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:rl,execute:async(e,t)=>{let n=t.selector==null?e.page.locator(":root"):e.page.locator(t.selector);try{return{specNode:void 0,stepResult:void 0,toolOutput:await n.ariaSnapshot()}}catch{return{specNode:void 0,stepResult:void 0,toolOutput:"(unable to capture accessibility tree)"}}}});import{z as ol}from"zod";var al=ol.object({}),bo=h({description:"Get a text representation of the current page content for inspection",name:"get_page_content",schema:al,execute:async(e,t)=>{let n=await e.page.locator("body").textContent({timeout:5e3}),r=e.page.url(),o=await e.page.title();return{specNode:void 0,stepResult:void 0,toolOutput:`URL: ${r}
17
17
  Title: ${o}
18
18
 
19
- ${n??""}`}}});import{z as al}from"zod";var sl=al.object({}),ko=g({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:sl,execute:(e,t)=>{if(e.monitor.pageErrors.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No page errors recorded."};let n=e.monitor.pageErrors.map((r,o)=>`--- Error ${String(o+1)} ---
19
+ ${n??""}`}}});import{z as sl}from"zod";var il=sl.object({}),Ao=h({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:il,execute:(e,t)=>{if(e.monitor.pageErrors.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:"No page errors recorded."};let n=e.monitor.pageErrors.map((r,o)=>`--- Error ${String(o+1)} ---
20
20
  ${r}`).join(`
21
21
 
22
22
  `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(e.monitor.pageErrors.length)} page errors:
23
23
 
24
- ${n}`}}});import{z as bo}from"zod";var il=bo.object({type:bo.enum(["all","cookies","localStorage","sessionStorage"]).describe("Which storage to retrieve").default("all")}),Ro=g({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:il,execute:async(e,t)=>({specNode:void 0,stepResult:void 0,toolOutput:[...t.type==="all"||t.type==="cookies"?[await ll(e.page)]:[],...t.type==="all"||t.type==="localStorage"?[await Ao(e.page,"localStorage")]:[],...t.type==="all"||t.type==="sessionStorage"?[await Ao(e.page,"sessionStorage")]:[]].join(`
24
+ ${n}`}}});import{z as Ro}from"zod";var ll=Ro.object({type:Ro.enum(["all","cookies","localStorage","sessionStorage"]).describe("Which storage to retrieve").default("all")}),To=h({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:ll,execute:async(e,t)=>({specNode:void 0,stepResult:void 0,toolOutput:[...t.type==="all"||t.type==="cookies"?[await cl(e.page)]:[],...t.type==="all"||t.type==="localStorage"?[await No(e.page,"localStorage")]:[],...t.type==="all"||t.type==="sessionStorage"?[await No(e.page,"sessionStorage")]:[]].join(`
25
25
 
26
- `)})});async function ll(e){let t=await e.context().cookies();if(t.length===0)return`## Cookies
26
+ `)})});async function cl(e){let t=await e.context().cookies();if(t.length===0)return`## Cookies
27
27
  (none)`;let n=t.map(r=>` ${r.name}=${r.value} (domain=${r.domain}, httpOnly=${String(r.httpOnly)}, secure=${String(r.secure)}, sameSite=${r.sameSite})`);return`## Cookies (${String(t.length)})
28
28
  ${n.join(`
29
- `)}`}async function Ao(e,t){let n=await e.evaluate(`JSON.stringify(Object.fromEntries(Object.entries(${t})))`);return`## ${t}
30
- ${String(n)}`}import{z as fn}from"zod";var cl=fn.object({action:fn.enum(["accept","dismiss"]).describe("Whether to accept or dismiss the dialog"),promptText:fn.string().optional().describe("Text to enter for prompt dialogs")}),No=g({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:cl,execute:(e,t)=>{let n=performance.now();e.page.once("dialog",async a=>{t.action==="accept"?await a.accept(t.promptText??void 0):await a.dismiss()});let r=`agent-step-${String(e.stepIndex)}`,o={action:t.action,id:r,type:"handleDialog"};return A({assertions:[],detail:`Dialog handler set: ${t.action}`,duration:performance.now()-n,nodeType:"handleDialog",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Handle dialog: ${t.action}`})}});import{z as To}from"zod";var dl=To.object({selector:To.string().describe("CSS selector for the element to hover over")}),vo=g({description:"Hover over an element matching the CSS selector",name:"hover",schema:dl,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).hover({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"hover"};return A({assertions:[],detail:`Hovered over ${t.selector}`,duration:performance.now()-n,nodeType:"hover",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Hover ${t.selector}`})}});import{z as mn}from"zod";var pl=mn.object({permission:mn.string().describe("Permission name (e.g. geolocation, notifications, camera, clipboard-read)"),state:mn.enum(["granted","prompt"]).describe("Permission state to set")}),Co=g({description:"Set a browser permission state (geolocation, notifications, camera, etc.)",name:"set_permission",schema:pl,execute:async(e,t)=>{let n=performance.now(),r=e.page.context();t.state==="granted"?await r.grantPermissions([t.permission]):await r.clearPermissions();let a={id:`agent-step-${String(e.stepIndex)}`,permission:t.permission,state:t.state,type:"setPermission"};return A({assertions:[],detail:`Set ${t.permission} to ${t.state}`,duration:performance.now()-n,nodeType:"setPermission",page:e.page,runStartTime:e.runStartTime,specNode:a,status:"passed",stepIndex:e.stepIndex,title:`Set permission: ${t.permission} \u2192 ${t.state}`})}});import{z as xo}from"zod";var ul=xo.object({url:xo.string().describe("The URL to navigate to")}),Lo=g({description:"Navigate the browser to a URL",name:"navigate",schema:ul,execute:async(e,t)=>{let n=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 A({assertions:[],detail:`Navigated to ${t.url}`,duration:performance.now()-n,nodeType:"goto",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Navigate to ${t.url}`})}});import{z as Po}from"zod";var fl=Po.object({key:Po.string().describe("Key to press, e.g. 'Enter', 'Tab', 'Escape'")}),Eo=g({description:"Press a keyboard key",name:"press",schema:fl,execute:async(e,t)=>{let n=performance.now();await e.page.keyboard.press(t.key);let o={id:`agent-step-${String(e.stepIndex)}`,key:t.key,type:"press"};return A({assertions:[],detail:`Pressed ${t.key}`,duration:performance.now()-n,nodeType:"press",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Press ${t.key}`})}});import{z as yn}from"zod";var ml=yn.object({height:yn.number().int().positive().describe("Viewport height in pixels"),width:yn.number().int().positive().describe("Viewport width in pixels")}),Oo=g({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:ml,execute:async(e,t)=>{let n=performance.now();await e.page.setViewportSize({height:t.height,width:t.width});let r=`agent-step-${String(e.stepIndex)}`,o={height:t.height,id:r,type:"setViewport",width:t.width};return A({assertions:[],detail:`Resized viewport to ${String(t.width)}x${String(t.height)}`,duration:performance.now()-n,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 Io}from"zod";var yl=Io.object({selector:Io.string().describe("CSS selector for the element to right-click")}),Uo=g({description:"Right-click an element to open the context menu",name:"right_click",schema:yl,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).click({button:"right",timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"rightClick"};return A({assertions:[],detail:`Right-clicked ${t.selector}`,duration:performance.now()-n,nodeType:"rightClick",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Right-click ${t.selector}`})}});import{z as vt}from"zod";var gl=vt.object({selector:vt.string().optional().describe("CSS selector to scroll within (omit to scroll the page)"),x:vt.number().int().optional().describe("Horizontal scroll offset in pixels").default(0),y:vt.number().int().optional().describe("Vertical scroll offset in pixels").default(0)}),jo=g({description:"Scroll the page or a specific element by pixel offset. Positive y scrolls down, negative scrolls up.",name:"scroll",schema:gl,execute:async(e,t)=>{let n=performance.now();if(t.selector==null)await e.page.mouse.wheel(t.x,t.y);else{let s=await e.page.locator(t.selector).elementHandle();if(s==null)throw new Error("Scroll target element not found");await s.evaluate(`(el) => el.scrollBy(${String(t.x)}, ${String(t.y)})`)}let o={id:`agent-step-${String(e.stepIndex)}`,type:"scroll",x:t.x,y:t.y},a=t.selector??"page";return A({assertions:[],detail:`Scrolled ${a} by (${String(t.x)}, ${String(t.y)})`,duration:performance.now()-n,nodeType:"scroll",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Scroll ${a}`})}});import{z as hl}from"zod";var wl=hl.object({}),_o=g({description:"Take a screenshot of the current page",name:"screenshot",schema:wl,execute:async(e,t)=>{let n=performance.now(),o={id:`agent-step-${String(e.stepIndex)}`,type:"screenshot"};return A({assertions:[],detail:"Screenshot captured",duration:performance.now()-n,nodeType:"screenshot",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:"Screenshot"})}});import{z as $o}from"zod";var Sl=$o.object({pattern:$o.string().describe("Regex pattern to search console log messages")}),Bo=g({description:"Search console log messages for a regex pattern. Returns matching entries.",name:"search_console",schema:Sl,execute:(e,t)=>{let n=new RegExp(t.pattern,"i"),r=e.monitor.consoleEntries.filter(a=>n.test(a.text));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console messages matching: ${t.pattern}`};let o=r.map(a=>kl(a)).join(`
29
+ `)}`}async function No(e,t){let n=await e.evaluate(`JSON.stringify(Object.fromEntries(Object.entries(${t})))`);return`## ${t}
30
+ ${String(n)}`}import{z as mn}from"zod";var dl=mn.object({action:mn.enum(["accept","dismiss"]).describe("Whether to accept or dismiss the dialog"),promptText:mn.string().optional().describe("Text to enter for prompt dialogs")}),vo=h({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:dl,execute:(e,t)=>{let n=performance.now();e.page.once("dialog",async a=>{t.action==="accept"?await a.accept(t.promptText??void 0):await a.dismiss()});let r=`agent-step-${String(e.stepIndex)}`,o={action:t.action,id:r,type:"handleDialog"};return A({assertions:[],detail:`Dialog handler set: ${t.action}`,duration:performance.now()-n,nodeType:"handleDialog",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Handle dialog: ${t.action}`})}});import{z as Co}from"zod";var pl=Co.object({selector:Co.string().describe("CSS selector for the element to hover over")}),xo=h({description:"Hover over an element matching the CSS selector",name:"hover",schema:pl,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).hover({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"hover"};return A({assertions:[],detail:`Hovered over ${t.selector}`,duration:performance.now()-n,nodeType:"hover",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Hover ${t.selector}`})}});import{z as yn}from"zod";var ul=yn.object({permission:yn.string().describe("Permission name (e.g. geolocation, notifications, camera, clipboard-read)"),state:yn.enum(["granted","prompt"]).describe("Permission state to set")}),Lo=h({description:"Set a browser permission state (geolocation, notifications, camera, etc.)",name:"set_permission",schema:ul,execute:async(e,t)=>{let n=performance.now(),r=e.page.context();t.state==="granted"?await r.grantPermissions([t.permission]):await r.clearPermissions();let a={id:`agent-step-${String(e.stepIndex)}`,permission:t.permission,state:t.state,type:"setPermission"};return A({assertions:[],detail:`Set ${t.permission} to ${t.state}`,duration:performance.now()-n,nodeType:"setPermission",page:e.page,runStartTime:e.runStartTime,specNode:a,status:"passed",stepIndex:e.stepIndex,title:`Set permission: ${t.permission} \u2192 ${t.state}`})}});import{z as Po}from"zod";var fl=Po.object({url:Po.string().describe("The URL to navigate to")}),Eo=h({description:"Navigate the browser to a URL",name:"navigate",schema:fl,execute:async(e,t)=>{let n=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 A({assertions:[],detail:`Navigated to ${t.url}`,duration:performance.now()-n,nodeType:"goto",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Navigate to ${t.url}`})}});import{z as Oo}from"zod";var ml=Oo.object({key:Oo.string().describe("Key to press, e.g. 'Enter', 'Tab', 'Escape'")}),Io=h({description:"Press a keyboard key",name:"press",schema:ml,execute:async(e,t)=>{let n=performance.now();await e.page.keyboard.press(t.key);let o={id:`agent-step-${String(e.stepIndex)}`,key:t.key,type:"press"};return A({assertions:[],detail:`Pressed ${t.key}`,duration:performance.now()-n,nodeType:"press",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Press ${t.key}`})}});import{z as gn}from"zod";var yl=gn.object({height:gn.number().int().positive().describe("Viewport height in pixels"),width:gn.number().int().positive().describe("Viewport width in pixels")}),Uo=h({description:"Resize the browser viewport to the specified dimensions. Use this to test responsive layouts at different screen sizes (e.g. mobile: 375x812, tablet: 768x1024, desktop: 1440x900).",name:"resize_viewport",schema:yl,execute:async(e,t)=>{let n=performance.now();await e.page.setViewportSize({height:t.height,width:t.width});let r=`agent-step-${String(e.stepIndex)}`,o={height:t.height,id:r,type:"setViewport",width:t.width};return A({assertions:[],detail:`Resized viewport to ${String(t.width)}x${String(t.height)}`,duration:performance.now()-n,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 jo}from"zod";var gl=jo.object({selector:jo.string().describe("CSS selector for the element to right-click")}),_o=h({description:"Right-click an element to open the context menu",name:"right_click",schema:gl,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).click({button:"right",timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"rightClick"};return A({assertions:[],detail:`Right-clicked ${t.selector}`,duration:performance.now()-n,nodeType:"rightClick",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Right-click ${t.selector}`})}});import{z as vt}from"zod";var hl=vt.object({selector:vt.string().optional().describe("CSS selector to scroll within (omit to scroll the page)"),x:vt.number().int().optional().describe("Horizontal scroll offset in pixels").default(0),y:vt.number().int().optional().describe("Vertical scroll offset in pixels").default(0)}),$o=h({description:"Scroll the page or a specific element by pixel offset. Positive y scrolls down, negative scrolls up.",name:"scroll",schema:hl,execute:async(e,t)=>{let n=performance.now();if(t.selector==null)await e.page.mouse.wheel(t.x,t.y);else{let s=await e.page.locator(t.selector).elementHandle();if(s==null)throw new Error("Scroll target element not found");await s.evaluate(`(el) => el.scrollBy(${String(t.x)}, ${String(t.y)})`)}let o={id:`agent-step-${String(e.stepIndex)}`,type:"scroll",x:t.x,y:t.y},a=t.selector??"page";return A({assertions:[],detail:`Scrolled ${a} by (${String(t.x)}, ${String(t.y)})`,duration:performance.now()-n,nodeType:"scroll",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Scroll ${a}`})}});import{z as wl}from"zod";var Sl=wl.object({}),Bo=h({description:"Take a screenshot of the current page",name:"screenshot",schema:Sl,execute:async(e,t)=>{let n=performance.now(),o={id:`agent-step-${String(e.stepIndex)}`,type:"screenshot"};return A({assertions:[],detail:"Screenshot captured",duration:performance.now()-n,nodeType:"screenshot",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:"Screenshot"})}});import{z as Do}from"zod";var kl=Do.object({pattern:Do.string().describe("Regex pattern to search console log messages")}),Fo=h({description:"Search console log messages for a regex pattern. Returns matching entries.",name:"search_console",schema:kl,execute:(e,t)=>{let n=new RegExp(t.pattern,"i"),r=e.monitor.consoleEntries.filter(a=>n.test(a.text));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No console messages matching: ${t.pattern}`};let o=r.map(a=>bl(a)).join(`
31
31
  `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(r.length)} matching console messages:
32
- ${o}`}}});function kl(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as Do}from"zod";var bl=Do.object({pattern:Do.string().describe("Regex pattern to search across network request URLs and response bodies")}),Fo=g({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:bl,execute:(e,t)=>{let n=new RegExp(t.pattern,"i"),r=e.monitor.networkEntries.filter(a=>n.test(a.url)||a.responseBody!=null&&n.test(a.responseBody));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network entries matching: ${t.pattern}`};let o=r.map(a=>{let s=a.statusCode==null?"pending":String(a.statusCode),i=n.test(a.url)?" [URL match]":"",l=a.responseBody!=null&&n.test(a.responseBody)?" [body match]":"";return`${a.method} ${s} ${a.url}${i}${l}`}).join(`
32
+ ${o}`}}});function bl(e){let t=e.url.length>0?` (${e.url})`:"";return`[${e.level.toUpperCase()}] ${e.text}${t}`}import{z as Vo}from"zod";var Al=Vo.object({pattern:Vo.string().describe("Regex pattern to search across network request URLs and response bodies")}),Wo=h({description:"Search network requests and response bodies for a regex pattern. Useful for finding API calls, tokens, or specific data in responses.",name:"search_network",schema:Al,execute:(e,t)=>{let n=new RegExp(t.pattern,"i"),r=e.monitor.networkEntries.filter(a=>n.test(a.url)||a.responseBody!=null&&n.test(a.responseBody));if(r.length===0)return{specNode:void 0,stepResult:void 0,toolOutput:`No network entries matching: ${t.pattern}`};let o=r.map(a=>{let s=a.statusCode==null?"pending":String(a.statusCode),i=n.test(a.url)?" [URL match]":"",l=a.responseBody!=null&&n.test(a.responseBody)?" [body match]":"";return`${a.method} ${s} ${a.url}${i}${l}`}).join(`
33
33
  `);return{specNode:void 0,stepResult:void 0,toolOutput:`${String(r.length)} matching network entries:
34
- ${o}`}}});import{z as Vo}from"zod";var Al=20,Rl=2,Nl=Vo.object({pattern:Vo.string().describe("Regex pattern to search for in the page HTML")}),Wo=g({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:Nl,execute:async(e,t)=>{let r=(await e.page.content()).split(`
35
- `),o=Tl({contextLines:Rl,lines:r,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(`
34
+ ${o}`}}});import{z as qo}from"zod";var Rl=20,Nl=2,Tl=qo.object({pattern:qo.string().describe("Regex pattern to search for in the page HTML")}),Mo=h({description:"Search the current page's full HTML/DOM for a regex pattern. Returns matching lines with context. Useful for finding elements, attributes, text content, or hidden data without reading the entire page.",name:"search_page",schema:Tl,execute:async(e,t)=>{let r=(await e.page.content()).split(`
35
+ `),o=vl({contextLines:Nl,lines:r,maxResults:Rl,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(`
36
36
  ---
37
- `)}}});function Tl({contextLines:e,lines:t,maxResults:n,pattern:r}){let o=new RegExp(r,"i"),a=[];return t.forEach((s,i)=>{if(a.length>=n||!o.test(s))return;let l=Math.max(0,i-e),c=Math.min(t.length-1,i+e),d=t.slice(l,c+1).map((f,u)=>{let m=l+u+1;return`${l+u===i?">":" "} ${String(m)}: ${f}`}).join(`
38
- `);a.push(d)}),a}import{z as gn}from"zod";var vl=gn.object({selector:gn.string().describe("CSS selector for the select element"),value:gn.string().describe("The option value to select")}),qo=g({description:"Select an option from a dropdown/select element",name:"select",schema:vl,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).selectOption(t.value,{timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"select",value:{type:"static",value:t.value}};return A({assertions:[],detail:`Selected "${t.value}" in ${t.selector}`,duration:performance.now()-n,nodeType:"select",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Select ${t.value}`})}});import{z as Mo}from"zod";var Cl=Mo.object({selector:Mo.string().describe("CSS selector for the checkbox to uncheck")}),Go=g({description:"Uncheck a checkbox matching the CSS selector",name:"uncheck",schema:Cl,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).uncheck({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"uncheck"};return A({assertions:[],detail:`Unchecked ${t.selector}`,duration:performance.now()-n,nodeType:"uncheck",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Uncheck ${t.selector}`})}});import{z as Jo}from"zod";var xl=Jo.object({ms:Jo.number().describe("Milliseconds to wait")}),zo=g({description:"Wait for a specified duration in milliseconds",name:"wait",schema:xl,execute:async(e,t)=>{let n=performance.now();await e.page.waitForTimeout(t.ms);let r=`agent-step-${String(e.stepIndex)}`,o={duration:t.ms,id:r,type:"wait"};return A({assertions:[],detail:`Waited ${String(t.ms)}ms`,duration:performance.now()-n,nodeType:"wait",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Wait ${String(t.ms)}ms`})}});import{z as hn}from"zod";var Ll=hn.object({selector:hn.string().describe("CSS selector for the element to wait for"),state:hn.enum(["visible","hidden","attached","detached"]).default("visible").describe("The state to wait for (default: visible)")}),Ho=g({description:"Wait for an element matching the CSS selector to reach the specified state. More reliable than a blind wait \u2014 use this to wait for elements to appear, disappear, or attach/detach from the DOM.",name:"wait_for",schema:Ll,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).waitFor({state:t.state,timeout:15e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},state:t.state,type:"waitFor"};return A({assertions:[],detail:`Waited for ${t.selector} to be ${t.state}`,duration:performance.now()-n,nodeType:"waitFor",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Wait for ${t.selector} to be ${t.state}`})}});var Ct=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(n=>{this.responseBody=n.length>1e5?`${n.slice(0,1e5)}... (truncated)`:n}).catch(()=>{this.responseBody="(unable to read body)"})}};function Qe(e){let t=[],n=[],r=[],o=new Map;function a(f){t.push({level:f.type(),text:f.text(),timestamp:Date.now(),url:f.location().url})}function s(f){let u=new Ct(f);o.set(f,u),n.push(u)}function i(f){let u=o.get(f.request());u!=null&&(o.delete(f.request()),u.applyResponse(f))}function l(f){r.push(`${f.message}
39
- ${f.stack??""}`)}function c(f){let u=f.failure(),m=new Ct(f);m.responseBody=`(request failed: ${u?.errorText??"unknown"})`,n.push(m)}e.on("console",a),e.on("request",s),e.on("response",i),e.on("pageerror",l),e.on("requestfailed",c);function d(){e.off("console",a),e.off("request",s),e.off("response",i),e.off("pageerror",l),e.off("requestfailed",c)}return{consoleEntries:t,detach:d,networkEntries:n,pageErrors:r}}var wn=[Lo,ro,co,Eo,Zr,Go,qo,vo,zo,Ho,_o,So,Wo,to,Uo,jo,No,oo,Co,Yr,Hr,Xr,Wr,Jr,Mr,zr,uo,mo,go,ko,wo,Ro,Bo,Fo,Oo,lo,so],Pl=new Map(wn.map(e=>[e.name,e])),Sn=wn.map(e=>e.anthropicTool),Xo=wn.map(e=>`- **${e.name}**: ${e.anthropicTool.description??""}`).join(`
40
- `);async function Ko({input:e,monitor:t,name:n,page:r,runStartTime:o,stepIndex:a}){let s=Pl.get(n);if(s==null)throw new Error(`Unknown agent tool: ${n}`);return s.execute({monitor:t,page:r,runStartTime:o,stepIndex:a},e)}import Yo from"fs";import El from"path";import kn from"pino";var w=kn({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}});function bn({filePath:e}){let t=El.dirname(e);Yo.mkdirSync(t,{recursive:!0}),Yo.writeFileSync(e,"");let n=kn.destination({dest:e,sync:!0}),r=kn({level:"info"},n);w.info=r.info.bind(r),w.warn=r.warn.bind(r),w.error=r.error.bind(r),w.debug=r.debug.bind(r),w.fatal=r.fatal.bind(r),w.trace=r.trace.bind(r)}var Il=50,Qo=16384;async function An({baseUrl:e,executedPreconditions:t,extraVariables:n,onStep:r,page:o,runId:a,serverUrl:s,spec:i,systemPrompt:l,token:c,workflowContext:d}){let f=new Ol({apiKey:"ripplo",baseURL:`${s}/api/proxy/anthropic`,defaultHeaders:{Authorization:`Bearer ${c}`,"x-run-id":a}}),u=performance.now(),m=Qe(o);await Fl({baseUrl:e,page:o});let y=_l({extraVariables:n,spec:i}),h=$l({baseUrl:e,executedPreconditions:t,spec:i,systemPrompt:l,variables:y,workflowContext:d}),S=Bl({baseUrl:e,spec:i,variables:y}),b=[{content:Dl({page:o,startUrl:S}),role:"user"}],C=[],I=[],v={findings:"",stepIndex:0,verdict:void 0};v=await Ul({client:f,messages:b,monitor:m,onStep:r,page:o,runStartTime:u,specNodes:I,state:v,steps:C,system:h}),v.verdict==null&&(v=await jl({client:f,messages:b,monitor:m,onStep:r,page:o,runStartTime:u,specNodes:I,state:v,steps:C,system:h}));let q=Wl(I);return{findings:v.findings,generatedSpec:q,monitor:m,steps:C,verdict:v.verdict??"fail"}}function Zo({result:e,state:t}){return{findings:e.newFindings.length>0?e.newFindings:t.findings,stepIndex:e.nextStepIndex,verdict:e.verdict??t.verdict}}async function Ul({client:e,messages:t,monitor:n,onStep:r,page:o,runStartTime:a,specNodes:s,state:i,steps:l,system:c}){let d=i;for(let f=0;f<Il;f++){w.info("Agent iteration %d",f+1);let u=await e.messages.create({max_tokens:Qo,messages:t,model:"server-controlled",system:c,tools:Sn}),m=await ea({messages:t,monitor:n,onStep:r,page:o,response:u,runStartTime:a,specNodes:s,stepIndex:d.stepIndex,steps:l});if(d=Zo({result:m,state:d}),!m.continueLoop)break}return d}async function jl({client:e,messages:t,monitor:n,onStep:r,page:o,runStartTime:a,specNodes:s,state:i,steps:l,system:c}){w.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:Qo,messages:t,model:"server-controlled",system:c,tool_choice:{name:"complete_test",type:"tool"},tools:Sn}),f=await ea({messages:t,monitor:n,onStep:r,page:o,response:d,runStartTime:a,specNodes:s,stepIndex:i.stepIndex,steps:l});return Zo({result:f,state:i})}function _l({extraVariables:e,spec:t}){return{...Ye({defs:t?.variables}),...e}}function $l({baseUrl:e,executedPreconditions:t,spec:n,systemPrompt:r,variables:o,workflowContext:a}){let s=a==null?"":[`
37
+ `)}}});function vl({contextLines:e,lines:t,maxResults:n,pattern:r}){let o=new RegExp(r,"i"),a=[];return t.forEach((s,i)=>{if(a.length>=n||!o.test(s))return;let l=Math.max(0,i-e),c=Math.min(t.length-1,i+e),d=t.slice(l,c+1).map((p,u)=>{let m=l+u+1;return`${l+u===i?">":" "} ${String(m)}: ${p}`}).join(`
38
+ `);a.push(d)}),a}import{z as hn}from"zod";var Cl=hn.object({selector:hn.string().describe("CSS selector for the select element"),value:hn.string().describe("The option value to select")}),Go=h({description:"Select an option from a dropdown/select element",name:"select",schema:Cl,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).selectOption(t.value,{timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"select",value:{type:"static",value:t.value}};return A({assertions:[],detail:`Selected "${t.value}" in ${t.selector}`,duration:performance.now()-n,nodeType:"select",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Select ${t.value}`})}});import{z as Jo}from"zod";var xl=Jo.object({selector:Jo.string().describe("CSS selector for the checkbox to uncheck")}),zo=h({description:"Uncheck a checkbox matching the CSS selector",name:"uncheck",schema:xl,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).uncheck({timeout:5e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},type:"uncheck"};return A({assertions:[],detail:`Unchecked ${t.selector}`,duration:performance.now()-n,nodeType:"uncheck",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Uncheck ${t.selector}`})}});import{z as Ho}from"zod";var Ll=Ho.object({ms:Ho.number().describe("Milliseconds to wait")}),Xo=h({description:"Wait for a specified duration in milliseconds",name:"wait",schema:Ll,execute:async(e,t)=>{let n=performance.now();await e.page.waitForTimeout(t.ms);let r=`agent-step-${String(e.stepIndex)}`,o={duration:t.ms,id:r,type:"wait"};return A({assertions:[],detail:`Waited ${String(t.ms)}ms`,duration:performance.now()-n,nodeType:"wait",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Wait ${String(t.ms)}ms`})}});import{z as wn}from"zod";var Pl=wn.object({selector:wn.string().describe("CSS selector for the element to wait for"),state:wn.enum(["visible","hidden","attached","detached"]).default("visible").describe("The state to wait for (default: visible)")}),Ko=h({description:"Wait for an element matching the CSS selector to reach the specified state. More reliable than a blind wait \u2014 use this to wait for elements to appear, disappear, or attach/detach from the DOM.",name:"wait_for",schema:Pl,execute:async(e,t)=>{let n=performance.now();await e.page.locator(t.selector).waitFor({state:t.state,timeout:15e3});let o={id:`agent-step-${String(e.stepIndex)}`,locator:{by:"css",value:t.selector},state:t.state,type:"waitFor"};return A({assertions:[],detail:`Waited for ${t.selector} to be ${t.state}`,duration:performance.now()-n,nodeType:"waitFor",page:e.page,runStartTime:e.runStartTime,specNode:o,status:"passed",stepIndex:e.stepIndex,title:`Wait for ${t.selector} to be ${t.state}`})}});var Ct=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(n=>{this.responseBody=n.length>1e5?`${n.slice(0,1e5)}... (truncated)`:n}).catch(()=>{this.responseBody="(unable to read body)"})}};function Qe(e){let t=[],n=[],r=[],o=new Map;function a(p){t.push({level:p.type(),text:p.text(),timestamp:Date.now(),url:p.location().url})}function s(p){let u=new Ct(p);o.set(p,u),n.push(u)}function i(p){let u=o.get(p.request());u!=null&&(o.delete(p.request()),u.applyResponse(p))}function l(p){r.push(`${p.message}
39
+ ${p.stack??""}`)}function c(p){let u=p.failure(),m=new Ct(p);m.responseBody=`(request failed: ${u?.errorText??"unknown"})`,n.push(m)}e.on("console",a),e.on("request",s),e.on("response",i),e.on("pageerror",l),e.on("requestfailed",c);function d(){e.off("console",a),e.off("request",s),e.off("response",i),e.off("pageerror",l),e.off("requestfailed",c)}return{consoleEntries:t,detach:d,networkEntries:n,pageErrors:r}}var Sn=[Eo,ao,uo,Io,to,zo,Go,xo,Xo,Ko,Bo,bo,Mo,ro,_o,$o,vo,so,Lo,Zr,Kr,Yr,Mr,Hr,Jr,Xr,mo,go,wo,Ao,ko,To,Fo,Wo,Uo,po,lo],El=new Map(Sn.map(e=>[e.name,e])),kn=Sn.map(e=>e.anthropicTool),Yo=Sn.map(e=>`- **${e.name}**: ${e.anthropicTool.description??""}`).join(`
40
+ `);async function Qo({input:e,monitor:t,name:n,page:r,runStartTime:o,stepIndex:a}){let s=El.get(n);if(s==null)throw new Error(`Unknown agent tool: ${n}`);return s.execute({monitor:t,page:r,runStartTime:o,stepIndex:a},e)}import Zo from"fs";import Ol from"path";import bn from"pino";var w=bn({transport:{options:{ignore:"pid,hostname"},target:"pino-pretty"}});function An({filePath:e}){let t=Ol.dirname(e);Zo.mkdirSync(t,{recursive:!0}),Zo.writeFileSync(e,"");let n=bn.destination({dest:e,sync:!0}),r=bn({level:"info"},n);w.info=r.info.bind(r),w.warn=r.warn.bind(r),w.error=r.error.bind(r),w.debug=r.debug.bind(r),w.fatal=r.fatal.bind(r),w.trace=r.trace.bind(r)}var Ul=50,ea=16384;async function Rn({baseUrl:e,executedPreconditions:t,extraVariables:n,onStep:r,page:o,runId:a,serverUrl:s,spec:i,systemPrompt:l,token:c,workflowContext:d}){let p=new Il({apiKey:"ripplo",baseURL:`${s}/api/proxy/anthropic`,defaultHeaders:{Authorization:`Bearer ${c}`,"x-run-id":a}}),u=performance.now(),m=Qe(o);await Vl({baseUrl:e,page:o});let y=$l({extraVariables:n,spec:i}),g=Bl({baseUrl:e,executedPreconditions:t,spec:i,systemPrompt:l,variables:y,workflowContext:d}),S=Dl({baseUrl:e,spec:i,variables:y}),b=[{content:Fl({page:o,startUrl:S}),role:"user"}],C=[],L=[],v={findings:"",stepIndex:0,verdict:void 0};v=await jl({client:p,messages:b,monitor:m,onStep:r,page:o,runStartTime:u,specNodes:L,state:v,steps:C,system:g}),v.verdict==null&&(v=await _l({client:p,messages:b,monitor:m,onStep:r,page:o,runStartTime:u,specNodes:L,state:v,steps:C,system:g}));let q=ql(L);return{findings:v.findings,generatedSpec:q,monitor:m,steps:C,verdict:v.verdict??"fail"}}function ta({result:e,state:t}){return{findings:e.newFindings.length>0?e.newFindings:t.findings,stepIndex:e.nextStepIndex,verdict:e.verdict??t.verdict}}async function jl({client:e,messages:t,monitor:n,onStep:r,page:o,runStartTime:a,specNodes:s,state:i,steps:l,system:c}){let d=i;for(let p=0;p<Ul;p++){w.info("Agent iteration %d",p+1);let u=await e.messages.create({max_tokens:ea,messages:t,model:"server-controlled",system:c,tools:kn}),m=await na({messages:t,monitor:n,onStep:r,page:o,response:u,runStartTime:a,specNodes:s,stepIndex:d.stepIndex,steps:l});if(d=ta({result:m,state:d}),!m.continueLoop)break}return d}async function _l({client:e,messages:t,monitor:n,onStep:r,page:o,runStartTime:a,specNodes:s,state:i,steps:l,system:c}){w.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:ea,messages:t,model:"server-controlled",system:c,tool_choice:{name:"complete_test",type:"tool"},tools:kn}),p=await na({messages:t,monitor:n,onStep:r,page:o,response:d,runStartTime:a,specNodes:s,stepIndex:i.stepIndex,steps:l});return ta({result:p,state:i})}function $l({extraVariables:e,spec:t}){return{...Ye({defs:t?.variables}),...e}}function Bl({baseUrl:e,executedPreconditions:t,spec:n,systemPrompt:r,variables:o,workflowContext:a}){let s=a==null?"":[`
41
41
 
42
42
  ## Workflow Under Test`,`**Name:** ${a.name}`,`**Description:** ${a.description}`,`**Expected Outcome:** ${a.expectedOutcome}`,`
43
43
  Focus your testing ONLY on this specific workflow. Do not test unrelated parts of the application.`].join(`
@@ -53,56 +53,56 @@ ${JSON.stringify(n,null,2)}
53
53
  The following setup steps have already been run before your session started:
54
54
  ${l}
55
55
 
56
- Do not repeat any of these steps.`,d=Object.entries(o),f=d.map(([m,y])=>`- **${m}:** ${String(y)}`).join(`
56
+ Do not repeat any of these steps.`,d=Object.entries(o),p=d.map(([m,y])=>`- **${m}:** ${String(y)}`).join(`
57
57
  `),u=d.length===0?"":`
58
58
 
59
59
  ## Resolved Variables
60
- ${f}`;return[`You are testing the application at: ${e}`,"Use the provided tools to navigate, interact with, and assert things about the page.","Use get_page_content to inspect the page when you need to understand what's on screen.","Follow the workflow steps to complete the task.",`
61
- ## Available Tools`,Xo,s,c,i,u,`
60
+ ${p}`;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.",`
61
+ ## Available Tools`,Yo,s,c,i,u,`
62
62
  ## Agent Profile (HIGHEST PRIORITY \u2014 these instructions override any defaults above)`,r].join(`
63
- `)}function Bl({baseUrl:e,spec:t,variables:n}){if(t==null)return e;let r=t.nodes[t.entryNode];if(r==null||r.type!=="goto"||r.url.type!=="static")return e;let a=r.url.value.replaceAll(/\{\{(\w+)\}\}/g,(s,i)=>{let l=n[i];return l==null?`{{${i}}}`:String(l)});return a.startsWith("http")?a:`${e}${a.startsWith("/")?"":"/"}${a}`}function Dl({page:e,startUrl:t}){let n=e.url();return n!=="about:blank"&&n.length>0?`You are already on the page at ${n}. Begin testing from this page \u2014 do not navigate away unless the workflow requires it.`:`Navigate to ${t} and begin testing.`}async function Fl({baseUrl:e,page:t}){let n=new URL(e).origin;await t.route("**/*",r=>{let o=r.request();return o.isNavigationRequest()&&new URL(o.url()).origin!==n?(w.warn("Blocked navigation to off-origin URL: %s",o.url()),r.abort("blockedbyclient")):r.continue()})}async function ea({messages:e,monitor:t,onStep:n,page:r,response:o,runStartTime:a,specNodes:s,stepIndex:i,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(`
64
- `),nextStepIndex:i,verdict:void 0};let f=[],u=i,m,y;for(let S of d){let k=await Vl({block:S,monitor:t,onStep:n,page:r,runStartTime:a,specNodes:s,stepIndex:u,steps:l});f.push(k.toolResult),u=k.nextStepIndex,k.verdict!=null&&(m=k.verdict,y=k.summary)}e.push({content:o.content,role:"assistant"},{content:f,role:"user"});let h=y??c.join(`
65
- `);return{continueLoop:m==null&&o.stop_reason==="tool_use",newFindings:h,nextStepIndex:u,verdict:m}}async function Vl({block:e,monitor:t,onStep:n,page:r,runStartTime:o,specNodes:a,stepIndex:s,steps:i}){try{let l=await Ko({input:e.input,monitor:t,name:e.name,page:r,runStartTime:o,stepIndex:s}),c={content:l.toolOutput,tool_use_id:e.id,type:"tool_result"};return l.kind==="verdict"?(w.info(" [%d] %s \u2014 verdict: %s",s,e.name,l.verdict),{nextStepIndex:s,summary:l.summary,toolResult:c,verdict:l.verdict}):(l.specNode!=null&&a.push(l.specNode),l.stepResult!=null?(i.push(l.stepResult),n?.(l.stepResult),w.info(" [%d] %s \u2014 %s",s,e.name,l.stepResult.status),{nextStepIndex:s+1,summary:void 0,toolResult:c,verdict:void 0}):(w.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";w.error(" [%d] %s \u2014 error: %s",s,e.name,c);let d=await pe({page:r,runStartTime:o,targets:[]}),f={annotations:d.annotations,assertions:[],detail:`Error: ${c}`,duration:0,nodeId:`agent-step-${String(s)}`,nodeType:"click",screenshotBase64:d.screenshotBase64,snapshotTimestamp:d.snapshotTimestamp,status:"failed",stepIndex:s,title:`${e.name} (error)`,url:d.url,viewportHeight:d.viewportHeight,viewportWidth:d.viewportWidth};return i.push(f),n?.(f),{nextStepIndex:s+1,summary:void 0,toolResult:{content:`Error: ${c}`,is_error:!0,tool_use_id:e.id,type:"tool_result"},verdict:void 0}}}function Wl(e){if(e.length===0)return{entryNode:"",nodes:{},version:2};let t={};e.forEach((r,o)=>{let a=e[o+1],s=a==null?r:{...r,next:a.id};t[r.id]=s});let n=e[0];if(n==null)throw new Error("Expected at least one spec node after length check");return{entryNode:n.id,nodes:t,version:2}}function Rn({description:e,output:t,successCriteria:n}){let r=[`## Agent Identity
63
+ `)}function Dl({baseUrl:e,spec:t,variables:n}){if(t==null)return e;let r=t.nodes[t.entryNode];if(r==null||r.type!=="goto"||r.url.type!=="static")return e;let a=r.url.value.replaceAll(/\{\{(\w+)\}\}/g,(s,i)=>{let l=n[i];return l==null?`{{${i}}}`:String(l)});return a.startsWith("http")?a:`${e}${a.startsWith("/")?"":"/"}${a}`}function Fl({page:e,startUrl:t}){let n=e.url();return n!=="about:blank"&&n.length>0?`You are already on the page at ${n}. Begin testing from this page \u2014 do not navigate away unless the workflow requires it.`:`Navigate to ${t} and begin testing.`}async function Vl({baseUrl:e,page:t}){let n=new URL(e).origin;await t.route("**/*",r=>{let o=r.request();return o.isNavigationRequest()&&new URL(o.url()).origin!==n?(w.warn("Blocked navigation to off-origin URL: %s",o.url()),r.abort("blockedbyclient")):r.continue()})}async function na({messages:e,monitor:t,onStep:n,page:r,response:o,runStartTime:a,specNodes:s,stepIndex:i,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(`
64
+ `),nextStepIndex:i,verdict:void 0};let p=[],u=i,m,y;for(let S of d){let k=await Wl({block:S,monitor:t,onStep:n,page:r,runStartTime:a,specNodes:s,stepIndex:u,steps:l});p.push(k.toolResult),u=k.nextStepIndex,k.verdict!=null&&(m=k.verdict,y=k.summary)}e.push({content:o.content,role:"assistant"},{content:p,role:"user"});let g=y??c.join(`
65
+ `);return{continueLoop:m==null&&o.stop_reason==="tool_use",newFindings:g,nextStepIndex:u,verdict:m}}async function Wl({block:e,monitor:t,onStep:n,page:r,runStartTime:o,specNodes:a,stepIndex:s,steps:i}){try{let l=await Qo({input:e.input,monitor:t,name:e.name,page:r,runStartTime:o,stepIndex:s}),c={content:l.toolOutput,tool_use_id:e.id,type:"tool_result"};return l.kind==="verdict"?(w.info(" [%d] %s \u2014 verdict: %s",s,e.name,l.verdict),{nextStepIndex:s,summary:l.summary,toolResult:c,verdict:l.verdict}):(l.specNode!=null&&a.push(l.specNode),l.stepResult!=null?(i.push(l.stepResult),n?.(l.stepResult),w.info(" [%d] %s \u2014 %s",s,e.name,l.stepResult.status),{nextStepIndex:s+1,summary:void 0,toolResult:c,verdict:void 0}):(w.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";w.error(" [%d] %s \u2014 error: %s",s,e.name,c);let d=await pe({page:r,runStartTime:o,targets:[]}),p={annotations:d.annotations,assertions:[],detail:`Error: ${c}`,duration:0,nodeId:`agent-step-${String(s)}`,nodeType:"click",screenshotBase64:d.screenshotBase64,snapshotTimestamp:d.snapshotTimestamp,status:"failed",stepIndex:s,title:`${e.name} (error)`,url:d.url,viewportHeight:d.viewportHeight,viewportWidth:d.viewportWidth};return i.push(p),n?.(p),{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 ql(e){if(e.length===0)return{entryNode:"",nodes:{},version:2};let t={};e.forEach((r,o)=>{let a=e[o+1],s=a==null?r:{...r,next:a.id};t[r.id]=s});let n=e[0];if(n==null)throw new Error("Expected at least one spec node after length check");return{entryNode:n.id,nodes:t,version:2}}function Nn({description:e,output:t,successCriteria:n}){let r=[`## Agent Identity
66
66
  ${e}`];t!=null&&t.length>0&&r.push(`## Output
67
67
  ${t}`),n!=null&&n.length>0&&r.push(`## Success Criteria
68
- ${n}`);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.',ql({hasSuccessCriteria:n!=null&&n.length>0}),Ml({hasOutput:t!=null&&t.length>0})];return r.push(o.join(`
68
+ ${n}`);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.',Ml({hasSuccessCriteria:n!=null&&n.length>0}),Gl({hasOutput:t!=null&&t.length>0})];return r.push(o.join(`
69
69
  `)),r.join(`
70
70
 
71
- `)}function ql({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 Ml({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 Gl}from"child_process";import{createRequire as Jl}from"module";import ta from"fs";import na from"path";import{chromium as Nn}from"playwright";async function Ze({headed:e}){w.info("Browser executable: %s",Nn.executablePath());try{return await Nn.launch({headless:!e})}catch(t){throw zl(t)?new Error(`Playwright browsers are not installed. Run:
71
+ `)}function Ml({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 Gl({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 Jl}from"child_process";import{createRequire as zl}from"module";import ra from"fs";import oa from"path";import{chromium as Tn}from"playwright";async function Ze({headed:e}){w.info("Browser executable: %s",Tn.executablePath());try{return await Tn.launch({headless:!e})}catch(t){throw Hl(t)?new Error(`Playwright browsers are not installed. Run:
72
72
 
73
73
  npx playwright install chromium
74
- `):t}}async function Tn(){let e=Nn.executablePath();if(ta.existsSync(e))return;w.info("Chromium not found. Installing via Playwright...");let t=Jl(import.meta.url),n=na.dirname(t.resolve("playwright/package.json")),r=na.join(n,"cli.js");if(await new Promise((o,a)=>{Gl(process.execPath,[r,"install","chromium"],s=>{if(s!=null){a(new Error(`Playwright install failed: ${s.message}`));return}o()})}),!ta.existsSync(e))throw new Error(`Playwright browser installation failed. Try running manually:
74
+ `):t}}async function vn(){let e=Tn.executablePath();if(ra.existsSync(e))return;w.info("Chromium not found. Installing via Playwright...");let t=zl(import.meta.url),n=oa.dirname(t.resolve("playwright/package.json")),r=oa.join(n,"cli.js");if(await new Promise((o,a)=>{Jl(process.execPath,[r,"install","chromium"],s=>{if(s!=null){a(new Error(`Playwright install failed: ${s.message}`));return}o()})}),!ra.existsSync(e))throw new Error(`Playwright browser installation failed. Try running manually:
75
75
 
76
76
  npx playwright install chromium
77
- `);w.info("\u2713 Chromium installed")}function zl(e){return e instanceof Error?e.message.includes("Executable doesn't exist"):!1}import{mkdir as vn,writeFile as Q}from"fs/promises";import M from"path";async function xt({context:e,page:t,runId:n,stepIndex:r,stepResult:o}){try{let a=M.join(process.cwd(),".ripplo","debug",n,"steps",String(r));await vn(a,{recursive:!0});let s={annotations:o.annotations,assertions:o.assertions,detail:o.detail,duration:o.duration,nodeId:o.nodeId,nodeType:o.nodeType,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth};await Promise.all([Q(M.join(a,"info.json"),JSON.stringify(s,null,2)),Q(M.join(a,"screenshot.png"),Buffer.from(o.screenshotBase64,"base64")),Hl({context:e,page:t,stepDir:a})])}catch(a){let s=a instanceof Error?a.message:String(a);w.warn("Failed to write step debug data for step %d: %s",r,s)}}async function Hl({context:e,page:t,stepDir:n}){let[r,o,a]=await Promise.all([t.content().catch(()=>"(unable to capture DOM)"),Xl(t),Kl({context:e,page:t})]);await Promise.all([Q(M.join(n,"dom.html"),r),Q(M.join(n,"accessibility-tree.txt"),o),Q(M.join(n,"storage.json"),JSON.stringify(a,null,2))])}async function Xl(e){try{return await e.locator(":root").ariaSnapshot()}catch{return"(unable to capture accessibility tree)"}}async function Kl({context:e,page:t}){let[n,r]=await Promise.all([t.evaluate(()=>({localStorage:Object.fromEntries(Array.from({length:localStorage.length},(o,a)=>{let s=localStorage.key(a);return s==null?void 0:[s,localStorage.getItem(s)??""]}).filter(o=>o!=null)),sessionStorage:Object.fromEntries(Array.from({length:sessionStorage.length},(o,a)=>{let s=sessionStorage.key(a);return s==null?void 0:[s,sessionStorage.getItem(s)??""]}).filter(o=>o!=null))})).catch(()=>({localStorage:{},sessionStorage:{}})),e.cookies().catch(()=>[])]);return{cookies:r,localStorage:n.localStorage,sessionStorage:n.sessionStorage}}async function Lt({monitor:e,runId:t,steps:n,summary:r}){try{let o=M.join(process.cwd(),".ripplo","debug",t);await vn(o,{recursive:!0}),await Promise.all([Q(M.join(o,"summary.txt"),Yl({steps:n,summary:r})),Q(M.join(o,"console.log"),Ql(e.consoleEntries)),Q(M.join(o,"network.jsonl"),Zl(e.networkEntries)),Q(M.join(o,"page-errors.log"),e.pageErrors.join(`
77
+ `);w.info("\u2713 Chromium installed")}function Hl(e){return e instanceof Error?e.message.includes("Executable doesn't exist"):!1}import{mkdir as Cn,writeFile as Q}from"fs/promises";import M from"path";async function xt({context:e,page:t,runId:n,stepIndex:r,stepResult:o}){try{let a=M.join(process.cwd(),".ripplo","debug",n,"steps",String(r));await Cn(a,{recursive:!0});let s={annotations:o.annotations,assertions:o.assertions,detail:o.detail,duration:o.duration,nodeId:o.nodeId,nodeType:o.nodeType,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth};await Promise.all([Q(M.join(a,"info.json"),JSON.stringify(s,null,2)),Q(M.join(a,"screenshot.png"),Buffer.from(o.screenshotBase64,"base64")),Xl({context:e,page:t,stepDir:a})])}catch(a){let s=a instanceof Error?a.message:String(a);w.warn("Failed to write step debug data for step %d: %s",r,s)}}async function Xl({context:e,page:t,stepDir:n}){let[r,o,a]=await Promise.all([t.content().catch(()=>"(unable to capture DOM)"),Kl(t),Yl({context:e,page:t})]);await Promise.all([Q(M.join(n,"dom.html"),r),Q(M.join(n,"accessibility-tree.txt"),o),Q(M.join(n,"storage.json"),JSON.stringify(a,null,2))])}async function Kl(e){try{return await e.locator(":root").ariaSnapshot()}catch{return"(unable to capture accessibility tree)"}}async function Yl({context:e,page:t}){let[n,r]=await Promise.all([t.evaluate(()=>({localStorage:Object.fromEntries(Array.from({length:localStorage.length},(o,a)=>{let s=localStorage.key(a);return s==null?void 0:[s,localStorage.getItem(s)??""]}).filter(o=>o!=null)),sessionStorage:Object.fromEntries(Array.from({length:sessionStorage.length},(o,a)=>{let s=sessionStorage.key(a);return s==null?void 0:[s,sessionStorage.getItem(s)??""]}).filter(o=>o!=null))})).catch(()=>({localStorage:{},sessionStorage:{}})),e.cookies().catch(()=>[])]);return{cookies:r,localStorage:n.localStorage,sessionStorage:n.sessionStorage}}async function Lt({monitor:e,runId:t,steps:n,summary:r}){try{let o=M.join(process.cwd(),".ripplo","debug",t);await Cn(o,{recursive:!0}),await Promise.all([Q(M.join(o,"summary.txt"),Ql({steps:n,summary:r})),Q(M.join(o,"console.log"),Zl(e.consoleEntries)),Q(M.join(o,"network.jsonl"),ec(e.networkEntries)),Q(M.join(o,"page-errors.log"),e.pageErrors.join(`
78
78
  ---
79
- `))]),w.info("Debug artifacts written to .ripplo/debug/%s/",t)}catch(o){let a=o instanceof Error?o.message:String(o);w.warn("Failed to write run debug summary: %s",a)}}function Yl({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(r=>` [${String(r.stepIndex)}] ${r.status==="passed"?"\u2713":"\u2717"} ${r.title} (${String(r.duration)}ms) \u2014 ${r.detail??"ok"}`)].join(`
80
- `)}function Ql(e){return e.map(t=>`[${new Date(t.timestamp).toISOString()}] [${t.level.toUpperCase()}] (${t.url}) ${t.text}`).join(`
81
- `)}function Zl(e){return e.map(t=>JSON.stringify(t)).join(`
82
- `)}async function ra({error:e,runId:t,stack:n,workflowName:r}){try{let o=M.join(process.cwd(),".ripplo","debug",t);await vn(o,{recursive:!0});let a=n==null?e:`${e}
79
+ `))]),w.info("Debug artifacts written to .ripplo/debug/%s/",t)}catch(o){let a=o instanceof Error?o.message:String(o);w.warn("Failed to write run debug summary: %s",a)}}function Ql({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(r=>` [${String(r.stepIndex)}] ${r.status==="passed"?"\u2713":"\u2717"} ${r.title} (${String(r.duration)}ms) \u2014 ${r.detail??"ok"}`)].join(`
80
+ `)}function Zl(e){return e.map(t=>`[${new Date(t.timestamp).toISOString()}] [${t.level.toUpperCase()}] (${t.url}) ${t.text}`).join(`
81
+ `)}function ec(e){return e.map(t=>JSON.stringify(t)).join(`
82
+ `)}async function aa({error:e,runId:t,stack:n,workflowName:r}){try{let o=M.join(process.cwd(),".ripplo","debug",t);await Cn(o,{recursive:!0});let a=n==null?e:`${e}
83
83
 
84
84
  ${n}`,s=[`Run ID: ${t}`,`Workflow: ${r}`,"Status: failed","",`Error: ${e}`,"",n==null?"":`Stack trace:
85
85
  ${n}`].join(`
86
- `);await Promise.all([Q(M.join(o,"error.txt"),a),Q(M.join(o,"summary.txt"),s)]),w.info("Debug error artifacts written to .ripplo/debug/%s/",t)}catch(o){let a=o instanceof Error?o.message:String(o);w.warn("Failed to write error debug artifacts: %s",a)}}async function Cn({baseUrl:e,cookies:t,executedPreconditions:n,extraVariables:r,headed:o,navigateTo:a,runId:s,serverUrl:i,spec:l,streaming:c,systemPrompt:d,token:f,workflowContext:u}){let m=await Ze({headed:o}),y=await m.newContext({baseURL:e});t.length>0&&(await y.addCookies([...t]),w.info("Injected %d cookies from preconditions",t.length));let h=await y.newPage();a!=null&&(w.info("Navigating to precondition start page: %s",a),await h.goto(a,{waitUntil:"domcontentloaded"}));try{let k=function(x){c.enqueueStep(x),xt({context:y,page:h,runId:s,stepIndex:x.stepIndex,stepResult:x})};var S=k;let b=await An({baseUrl:e,executedPreconditions:n,extraVariables:r,onStep:k,page:h,runId:s,serverUrl:i,spec:l,systemPrompt:d,token:f,workflowContext:u}),C=b.verdict==="pass"?"passed":"failed";await c.complete({statusOverride:C,steps:b.steps,summary:b.findings});let I=b.steps.filter(x=>x.status==="passed").length,v=b.steps.filter(x=>x.status==="failed").length,q={duration:b.steps.reduce((x,$)=>x+$.duration,0),failCount:v,passCount:I,runId:s,status:C,workflowName:u.name};await Lt({monitor:b.monitor,runId:s,steps:b.steps,summary:q}),w.info("Agent test complete: %d passed, %d failed",I,v),w.info(`
86
+ `);await Promise.all([Q(M.join(o,"error.txt"),a),Q(M.join(o,"summary.txt"),s)]),w.info("Debug error artifacts written to .ripplo/debug/%s/",t)}catch(o){let a=o instanceof Error?o.message:String(o);w.warn("Failed to write error debug artifacts: %s",a)}}async function xn({baseUrl:e,cookies:t,executedPreconditions:n,extraVariables:r,headed:o,navigateTo:a,runId:s,serverUrl:i,spec:l,streaming:c,systemPrompt:d,token:p,workflowContext:u}){let m=await Ze({headed:o}),y=await m.newContext({baseURL:e});t.length>0&&(await y.addCookies([...t]),w.info("Injected %d cookies from preconditions",t.length));let g=await y.newPage();a!=null&&(w.info("Navigating to precondition start page: %s",a),await g.goto(a,{waitUntil:"domcontentloaded"}));try{let k=function(x){c.enqueueStep(x),xt({context:y,page:g,runId:s,stepIndex:x.stepIndex,stepResult:x})};var S=k;let b=await Rn({baseUrl:e,executedPreconditions:n,extraVariables:r,onStep:k,page:g,runId:s,serverUrl:i,spec:l,systemPrompt:d,token:p,workflowContext:u}),C=b.verdict==="pass"?"passed":"failed";await c.complete({statusOverride:C,steps:b.steps,summary:b.findings});let L=b.steps.filter(x=>x.status==="passed").length,v=b.steps.filter(x=>x.status==="failed").length,q={duration:b.steps.reduce((x,$)=>x+$.duration,0),failCount:v,passCount:L,runId:s,status:C,workflowName:u.name};await Lt({monitor:b.monitor,runId:s,steps:b.steps,summary:q}),w.info("Agent test complete: %d passed, %d failed",L,v),w.info(`
87
87
  === Agent Summary ===
88
- %s`,b.findings)}finally{await m.close()}}async function xn({expected:e,locator:t,operator:n,timeout:r}){let o=await t.textContent({timeout:r});return Z({actual:o??"",expected:e,label:"Text",operator:n})}function Ln({expected:e,operator:t,url:n}){return Z({actual:n,expected:e,label:"URL",operator:t})}async function Pn({expected:e,locator:t,operator:n}){let r=await t.count();return Pt({actual:r,expected:e,label:"Count",operator:n})}async function En({expected:e,locator:t,operator:n,timeout:r}){let o=await t.inputValue({timeout:r});return Z({actual:o,expected:e,label:"Value",operator:n})}async function et({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 tt({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 aa({attribute:e,expected:t,locator:n,operator:r,timeout:o}){let a=await n.getAttribute(e,{timeout:o});return Z({actual:a??"",expected:t,label:`Attribute "${e}"`,operator:r})}async function sa({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 ia({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),await e.isDisabled()?{description:"Element is disabled",detail:void 0,status:"passed"}:{description:"Element is disabled",detail:"Element is enabled",status:"failed"}}catch{return{description:"Element is disabled",detail:"Element not found",status:"failed"}}}function la({expected:e,operator:t,title:n}){return Z({actual:n,expected:e,label:"Title",operator:t})}async function ca({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 da({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 pa({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"}}}function ua({cookies:e,expected:t}){let n=e.find(o=>o.name===t.name);if(n==null)return{description:`Cookie "${t.name}" exists`,detail:"Cookie not found",status:"failed"};let r=ec({cookie:n,expected:t});return r.length>0?{description:`Cookie "${t.name}"`,detail:r.join("; "),status:"failed"}:{description:`Cookie "${t.name}"`,detail:void 0,status:"passed"}}function ec({cookie:e,expected:t}){return[tc({cookie:e,expected:t}),oa("httpOnly",t.httpOnly,e.httpOnly),oa("secure",t.secure,e.secure),nc(t.sameSite,e.sameSite)].filter(n=>n!=null)}function tc({cookie:e,expected:t}){if(t.value==null||t.operator==null)return;let n=Z({actual:e.value,expected:t.value,label:"Value",operator:t.operator});return n.status==="failed"?n.detail??"value mismatch":void 0}function oa(e,t,n){if(!(t==null||n===t))return`${e}: expected ${String(t)}, got ${String(n)}`}function nc(e,t){if(!(e==null||t===e))return`sameSite: expected ${e}, got ${t}`}async function fa({bodyContains:e,headerContains:t,page:n,status:r,timeout:o,urlPattern:a}){let s=await n.waitForResponse(l=>l.url().includes(a),{timeout:o}),i=[rc(r,s.status()),await oc(e,s),ac(t,s.headers())].filter(l=>l!=null);return i.length===0?[{description:"Response matching "+JSON.stringify(a)+" received",detail:void 0,status:"passed"}]:i}function rc(e,t){if(e!=null)return{description:`Response status equals ${String(e)}`,detail:t===e?void 0:`Got: ${String(t)}`,status:t===e?"passed":"failed"}}async function oc(e,t){if(e==null)return;let r=(await t.text()).includes(e);return{description:`Response body contains "${e}"`,detail:r?void 0:"Not found in response body",status:r?"passed":"failed"}}function ac(e,t){if(e==null)return;let n=t[e.name.toLowerCase()],r=n!=null&&n.includes(e.value);return{description:`Response header "${e.name}" contains "${e.value}"`,detail:r?void 0:`Got: "${n??"(missing)"}"`,status:r?"passed":"failed"}}function Z(e){let t=`${e.label} ${e.operator} "${e.expected}"`,n=sc(e),r=n?void 0:`Got: "${e.actual}"`;return{description:t,detail:r,status:n?"passed":"failed"}}function sc({actual:e,expected:t,operator:n}){return n==="equals"?e===t:n==="notEquals"?e!==t:n==="contains"?e.includes(t):n==="startsWith"?e.startsWith(t):n==="endsWith"?e.endsWith(t):new RegExp(t).test(e)}function Pt(e){let t=`${e.label} ${e.operator} ${String(e.expected)}`,n=ic(e),r=n?void 0:`Got: ${String(e.actual)}`;return{description:t,detail:r,status:n?"passed":"failed"}}function ic({actual:e,expected:t,operator:n}){return n==="equals"?e===t:n==="notEquals"?e!==t:n==="greaterThan"?e>t:n==="greaterThanOrEqual"?e>=t:n==="lessThan"?e<t:e<=t}import{readdir as pc,rm as uc,stat as fc}from"fs/promises";import Vw from"os";import ga from"path";import{graphql as mc}from"gql.tada";import{print as lc}from"graphql";async function G(e){let t=lc(e.document),n=JSON.stringify({query:t,variables:e.variables}),r=`${e.config.ripploServerUrl}/graphql`,o;try{o=await fetch(r,{body:n,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST"})}catch(s){let i=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: ${i}`)}let a=await o.json();if(!cc(a))throw new Error("Invalid GraphQL response");if(dc(a))throw new Error(a.errors.map(s=>s.message).join(", "));if(a.data==null)throw new Error("No data returned from server");return a.data}function cc(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function dc(e){return Array.isArray(e.errors)&&e.errors.length>0}var ma=ga.join(process.cwd(),".ripplo","debug"),ya=360*60*1e3,Jw=mc(`
88
+ %s`,b.findings)}finally{await m.close()}}async function Ln({expected:e,locator:t,operator:n,timeout:r}){let o=await t.textContent({timeout:r});return Z({actual:o??"",expected:e,label:"Text",operator:n})}function Pn({expected:e,operator:t,url:n}){return Z({actual:n,expected:e,label:"URL",operator:t})}async function En({expected:e,locator:t,operator:n}){let r=await t.count();return Pt({actual:r,expected:e,label:"Count",operator:n})}async function On({expected:e,locator:t,operator:n,timeout:r}){let o=await t.inputValue({timeout:r});return Z({actual:o,expected:e,label:"Value",operator:n})}async function et({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 tt({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 ia({attribute:e,expected:t,locator:n,operator:r,timeout:o}){let a=await n.getAttribute(e,{timeout:o});return Z({actual:a??"",expected:t,label:`Attribute "${e}"`,operator:r})}async function la({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 ca({locator:e,timeout:t}){try{return await e.waitFor({state:"visible",timeout:t}),await e.isDisabled()?{description:"Element is disabled",detail:void 0,status:"passed"}:{description:"Element is disabled",detail:"Element is enabled",status:"failed"}}catch{return{description:"Element is disabled",detail:"Element not found",status:"failed"}}}function da({expected:e,operator:t,title:n}){return Z({actual:n,expected:e,label:"Title",operator:t})}async function pa({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 ua({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 fa({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"}}}function ma({cookies:e,expected:t}){let n=e.find(o=>o.name===t.name);if(n==null)return{description:`Cookie "${t.name}" exists`,detail:"Cookie not found",status:"failed"};let r=tc({cookie:n,expected:t});return r.length>0?{description:`Cookie "${t.name}"`,detail:r.join("; "),status:"failed"}:{description:`Cookie "${t.name}"`,detail:void 0,status:"passed"}}function tc({cookie:e,expected:t}){return[nc({cookie:e,expected:t}),sa("httpOnly",t.httpOnly,e.httpOnly),sa("secure",t.secure,e.secure),rc(t.sameSite,e.sameSite)].filter(n=>n!=null)}function nc({cookie:e,expected:t}){if(t.value==null||t.operator==null)return;let n=Z({actual:e.value,expected:t.value,label:"Value",operator:t.operator});return n.status==="failed"?n.detail??"value mismatch":void 0}function sa(e,t,n){if(!(t==null||n===t))return`${e}: expected ${String(t)}, got ${String(n)}`}function rc(e,t){if(!(e==null||t===e))return`sameSite: expected ${e}, got ${t}`}async function ya({bodyContains:e,headerContains:t,page:n,status:r,timeout:o,urlPattern:a}){let s=await n.waitForResponse(l=>l.url().includes(a),{timeout:o}),i=[oc(r,s.status()),await ac(e,s),sc(t,s.headers())].filter(l=>l!=null);return i.length===0?[{description:"Response matching "+JSON.stringify(a)+" received",detail:void 0,status:"passed"}]:i}function oc(e,t){if(e!=null)return{description:`Response status equals ${String(e)}`,detail:t===e?void 0:`Got: ${String(t)}`,status:t===e?"passed":"failed"}}async function ac(e,t){if(e==null)return;let r=(await t.text()).includes(e);return{description:`Response body contains "${e}"`,detail:r?void 0:"Not found in response body",status:r?"passed":"failed"}}function sc(e,t){if(e==null)return;let n=t[e.name.toLowerCase()],r=n!=null&&n.includes(e.value);return{description:`Response header "${e.name}" contains "${e.value}"`,detail:r?void 0:`Got: "${n??"(missing)"}"`,status:r?"passed":"failed"}}function Z(e){let t=`${e.label} ${e.operator} "${e.expected}"`,n=ic(e),r=n?void 0:`Got: "${e.actual}"`;return{description:t,detail:r,status:n?"passed":"failed"}}function ic({actual:e,expected:t,operator:n}){return n==="equals"?e===t:n==="notEquals"?e!==t:n==="contains"?e.includes(t):n==="startsWith"?e.startsWith(t):n==="endsWith"?e.endsWith(t):new RegExp(t).test(e)}function Pt(e){let t=`${e.label} ${e.operator} ${String(e.expected)}`,n=lc(e),r=n?void 0:`Got: ${String(e.actual)}`;return{description:t,detail:r,status:n?"passed":"failed"}}function lc({actual:e,expected:t,operator:n}){return n==="equals"?e===t:n==="notEquals"?e!==t:n==="greaterThan"?e>t:n==="greaterThanOrEqual"?e>=t:n==="lessThan"?e<t:e<=t}import{readdir as uc,rm as fc,stat as mc}from"fs/promises";import qw from"os";import wa from"path";import{graphql as yc}from"gql.tada";import{print as cc}from"graphql";async function G(e){let t=cc(e.document),n=JSON.stringify({query:t,variables:e.variables}),r=`${e.config.ripploServerUrl}/graphql`,o;try{o=await fetch(r,{body:n,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST"})}catch(s){let i=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: ${i}`)}let a=await o.json();if(!dc(a))throw new Error("Invalid GraphQL response");if(pc(a))throw new Error(a.errors.map(s=>s.message).join(", "));if(a.data==null)throw new Error("No data returned from server");return a.data}function dc(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 ga=wa.join(process.cwd(),".ripplo","debug"),ha=360*60*1e3,Hw=yc(`
89
89
  mutation RevokeCurrentCliToken {
90
90
  revokeCurrentCliToken
91
91
  }
92
- `);async function On({maxRuns:e}){try{let n=(await pc(ma,{withFileTypes:!0})).filter(c=>c.isDirectory()),r=Date.now(),o=await Promise.all(n.map(async c=>{let d=ga.join(ma,c.name),f=await fc(d);return{dirPath:d,mtime:f.mtimeMs}})),a=o.filter(c=>r-c.mtime>ya),i=o.filter(c=>r-c.mtime<=ya).toSorted((c,d)=>d.mtime-c.mtime).slice(e),l=[...a,...i];if(l.length===0)return;await Promise.allSettled(l.map(c=>uc(c.dirPath,{force:!0,recursive:!0}))),w.info("Pruned %d old debug run(s)",l.length)}catch{w.warn("Debug run pruning failed, ignoring")}}var yc=5e3;async function In({baseUrl:e}){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(yc)})}catch(t){let n=t instanceof Error?t.message:String(t);throw w.debug("Base URL reachability check failed: %s",n),new Error([`Could not reach your dev server at ${e}.`,"","Troubleshooting:",` 1. Make sure your app is running at ${e}`," 2. Check the `baseUrl` in `.ripplo/settings.json` \u2014 is the port correct?"," 3. If your app runs on a different port, update `baseUrl` in `.ripplo/settings.json`"].join(`
93
- `))}}async function Un({condition:e,page:t,timeout:n,variables:r}){switch(e.type){case"elementVisible":return(await et({locator:T({locator:e.locator,page:t}),timeout:n})).status==="passed";case"elementNotVisible":return(await tt({locator:T({locator:e.locator,page:t}),timeout:n})).status==="passed";case"urlMatch":{let o=P({ref:e.expected,variables:r});return Z({actual:t.url(),expected:o,label:"URL",operator:e.operator}).status==="passed"}case"textMatch":{let a=await T({locator:e.locator,page:t}).textContent({timeout:n}),s=P({ref:e.expected,variables:r});return Z({actual:a??"",expected:s,label:"Text",operator:e.operator}).status==="passed"}case"variableCompare":{let o=r[e.variable];if(o==null)throw new Error(`Variable "${e.variable}" is not defined`);let a=typeof o=="number"?o:Number(o),s=ke({ref:e.expected,variables:r}),i=typeof s=="number"?s:Number(s);return Pt({actual:a,expected:i,label:e.variable,operator:e.operator}).status==="passed"}}}import Ue from"fs";import jn from"path";import{z as ae}from"zod";var gc=ae.object({baseUrl:ae.string(),cloudBaseUrl:ae.string(),preconditionApiPath:ae.string(),projectId:ae.string()}),hc=ae.object({ripploServerUrl:ae.string(),token:ae.string(),webhookSecret:ae.string()}),wc=gc.extend(hc.shape),Et=jn.join(process.cwd(),".ripplo"),wa=jn.join(Et,"settings.json"),Sa=jn.join(Et,"settings.local.json");function ha(e){if(!Ue.existsSync(e))return null;let t=Ue.readFileSync(e,"utf8");return JSON.parse(t)}function ue(){let e=ha(wa),t=ha(Sa);if(e==null||t==null)return null;let n=wc.safeParse({...e,...t});return n.success?n.data:null}function be(e){Ue.existsSync(Et)||Ue.mkdirSync(Et,{recursive:!0});let{ripploServerUrl:t,token:n,webhookSecret:r,...o}=e;Ue.writeFileSync(wa,JSON.stringify(o,null,2)+`
94
- `),Ue.writeFileSync(Sa,JSON.stringify({ripploServerUrl:t,token:n,webhookSecret:r},null,2)+`
95
- `)}async function _n({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){let c=await Un({condition:n.condition,page:r,timeout:s,variables:i})?n.consequent:n.alternate??[];return c.length===0?{steps:[],variables:i}:e({failFast:t,nodeIds:c,page:r,spec:o,startIndex:a,timeout:s,variables:i})}async function $n({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){let l=[],c=i;for(let d=0;d<n.times;d++){n.iteratorVar!=null&&(c=oe({name:n.iteratorVar,store:c,value:d}));let f=await e({failFast:t,nodeIds:n.body,page:r,spec:o,startIndex:a+l.length,timeout:s,variables:c});if(l.push(...f.steps),c=f.variables,t&&f.steps.some(u=>u.status==="failed"))break}return{steps:l,variables:c}}async function Bn({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){let l=kc({collection:n.collection,variables:i}),c=[],d=i;for(let f of l){d=oe({name:n.iteratorVar,store:d,value:Sc(f)});let u=await e({failFast:t,nodeIds:n.body,page:r,spec:o,startIndex:a+c.length,timeout:s,variables:d});if(c.push(...u.steps),d=u.variables,t&&u.steps.some(m=>m.status==="failed"))break}return{steps:c,variables:d}}function Sc(e){return typeof e=="object"&&e!=null?JSON.stringify(e):e==null?"":String(e)}function kc({collection:e,variables:t}){if(Array.isArray(e))return e;let n=t[e.name];if(n==null)throw new Error(`Variable "${e.name}" is not defined`);return bc(n)}function bc(e){if(typeof e!="string")return[e];try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return[e]}async function Dn({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){let l=await Promise.all(n.branches.map(f=>e({failFast:t,nodeIds:f,page:r,spec:o,startIndex:a,timeout:s,variables:i}))),c=l.flatMap(f=>f.steps),d=Ac({base:i,results:l});return{steps:c,variables:d}}function Ac({base:e,results:t}){let n=e;return t.forEach(r=>{n={...n,...r.variables}}),n}async function Fn({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){let l=[],c=i;try{let d=await e({failFast:t,nodeIds:n.body,page:r,spec:o,startIndex:a,timeout:s,variables:c});if(l.push(...d.steps),c=d.variables,d.steps.some(u=>u.status==="failed")&&n.catch!=null){let u=await e({failFast:t,nodeIds:n.catch,page:r,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...u.steps),c=u.variables}}catch{if(n.catch!=null){let d=await e({failFast:t,nodeIds:n.catch,page:r,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...d.steps),c=d.variables}}finally{if(n.finally!=null){let d=await e({failFast:t,nodeIds:n.finally,page:r,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...d.steps),c=d.variables}}return{steps:l,variables:c}}async function Vn({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){return e({failFast:t,nodeIds:n.nodes,page:r,spec:o,startIndex:a,timeout:s,variables:i})}import{z as p}from"zod";import{z as K}from"zod";import{z as E}from"zod";var Rc=E.object({by:E.literal("css"),value:E.string().min(1)}),Nc=E.object({by:E.literal("testId"),value:E.string().min(1)}),Tc=E.object({by:E.literal("role"),exact:E.boolean().optional(),name:E.string().optional(),role:E.string().min(1)}),vc=E.object({by:E.literal("text"),exact:E.boolean().optional(),value:E.string().min(1)}),Cc=E.object({by:E.literal("label"),exact:E.boolean().optional(),value:E.string().min(1)}),xc=E.object({by:E.literal("placeholder"),value:E.string().min(1)}),Lc=E.object({by:E.literal("altText"),value:E.string().min(1)}),N=E.discriminatedUnion("by",[Rc,Nc,Tc,vc,Cc,xc,Lc]);import{z as ka}from"zod";var W=ka.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),fe=ka.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]);import{z as D}from"zod";var Pc=D.object({type:D.literal("static"),value:D.union([D.string(),D.number(),D.boolean()])}),Wn=D.object({name:D.string().min(1),type:D.literal("variable")}),Ae=D.discriminatedUnion("type",[Pc,Wn]),O=D.discriminatedUnion("type",[D.object({type:D.literal("static"),value:D.string()}),Wn]),je=D.discriminatedUnion("type",[D.object({type:D.literal("static"),value:D.number().int().nonnegative()}),Wn]);var _e=K.discriminatedUnion("type",[K.object({locator:N,type:K.literal("elementVisible")}),K.object({locator:N,type:K.literal("elementNotVisible")}),K.object({expected:O,operator:W,type:K.literal("urlMatch")}),K.object({expected:O,locator:N,operator:W,type:K.literal("textMatch")}),K.object({expected:Ae,operator:fe,type:K.literal("variableCompare"),variable:K.string().min(1)})]);import{z as J}from"zod";var nt=J.discriminatedUnion("type",[J.object({default:J.string().optional(),type:J.literal("string")}),J.object({default:J.number().optional(),type:J.literal("number")}),J.object({default:J.boolean().optional(),type:J.literal("boolean")}),J.object({key:J.string().min(1),type:J.literal("env")})]);var Ec=p.string().min(1),se=p.array(Ec).min(1),R={comment:p.string().optional(),id:p.string().min(1),label:p.string().optional(),next:p.string().optional(),timeout:p.number().int().positive().optional()},Oc=p.object({...R,type:p.literal("goto"),url:O}),Ic=p.object({...R,locator:N,type:p.literal("click")}),Uc=p.object({...R,locator:N,type:p.literal("fill"),value:O}),jc=p.object({...R,locator:N,type:p.literal("select"),value:O}),_c=p.object({...R,locator:N,type:p.literal("hover")}),$c=p.object({...R,key:p.string().min(1),locator:N.optional(),type:p.literal("press")}),Bc=p.object({...R,locator:N,type:p.literal("check")}),Dc=p.object({...R,locator:N,type:p.literal("uncheck")}),Fc=p.object({...R,type:p.literal("screenshot")}),Vc=p.object({...R,height:p.number().int().positive(),type:p.literal("setViewport"),width:p.number().int().positive()}),Wc=p.object({...R,duration:p.number().int().positive(),type:p.literal("wait")}),qc=p.object({...R,message:p.string().min(1),type:p.literal("fail")}),Mc=p.object({...R,type:p.literal("setVariable"),value:Ae,variable:p.string().min(1)}),Gc=p.object({...R,locator:N,type:p.literal("extractText"),variable:p.string().min(1)}),Jc=p.object({...R,files:p.array(p.string()).min(1),locator:N,type:p.literal("upload")}),zc=p.object({...R,locator:N,type:p.literal("dblclick")}),Hc=p.object({...R,source:N,target:N,type:p.literal("drag")}),Xc=p.object({...R,locator:N,type:p.literal("scrollIntoView")}),Kc=p.object({...R,locator:N,type:p.literal("type"),value:O}),Yc=p.object({...R,locator:N,type:p.literal("focus")}),Qc=p.object({...R,locator:N,type:p.literal("clear")}),Zc=p.object({...R,locator:N,type:p.literal("rightClick")}),ed=p.object({...R,action:p.enum(["accept","dismiss"]),promptText:p.string().optional(),type:p.literal("handleDialog")}),td=p.object({...R,locator:N.optional(),type:p.literal("scroll"),x:p.number().int().optional(),y:p.number().int().optional()}),nd=p.object({...R,action:p.enum(["read","write"]),type:p.literal("clipboard"),value:O.optional(),variable:p.string().min(1).optional()}),rd=p.object({...R,permission:p.string().min(1),state:p.enum(["granted","prompt"]),type:p.literal("setPermission")}),od=p.object({...R,locator:N,state:p.enum(["visible","hidden","attached","detached"]).optional(),type:p.literal("waitFor")}),ad=p.object({...R,expected:O,operator:W,type:p.literal("waitForUrl")}),sd=p.object({...R,type:p.literal("waitForResponse"),urlPattern:O}),id=p.object({...R,type:p.literal("waitForRequest"),urlPattern:O}),ld=p.object({...R,locator:N,type:p.literal("assertVisible")}),cd=p.object({...R,locator:N,type:p.literal("assertNotVisible")}),dd=p.object({...R,expected:O,locator:N,operator:W,type:p.literal("assertText")}),pd=p.object({...R,expected:O,operator:W,type:p.literal("assertUrl")}),ud=p.object({...R,expected:je,locator:N,operator:fe,type:p.literal("assertCount")}),fd=p.object({...R,expected:O,locator:N,operator:W,type:p.literal("assertValue")}),md=p.object({...R,attribute:p.string().min(1),expected:O,locator:N,operator:W,type:p.literal("assertAttribute")}),yd=p.object({...R,locator:N,type:p.literal("assertEnabled")}),gd=p.object({...R,locator:N,type:p.literal("assertDisabled")}),hd=p.object({...R,expected:O,operator:W,type:p.literal("assertTitle")}),wd=p.object({...R,locator:N,type:p.literal("assertChecked")}),Sd=p.object({...R,locator:N,type:p.literal("assertNotChecked")}),kd=p.object({...R,locator:N,type:p.literal("assertFocused")}),bd=p.object({...R,httpOnly:p.boolean().optional(),name:O,operator:W.optional(),sameSite:p.enum(["Strict","Lax","None"]).optional(),secure:p.boolean().optional(),type:p.literal("assertCookie"),value:O.optional()}),Ad=p.object({...R,bodyContains:O.optional(),headerContains:p.object({name:p.string().min(1),value:O}).optional(),status:p.number().int().positive().optional(),type:p.literal("assertResponse"),urlPattern:O}),Rd=p.object({...R,alternate:se.optional(),condition:_e,consequent:se,type:p.literal("if")}),Nd=p.object({...R,body:se,iteratorVar:p.string().min(1).optional(),times:p.number().int().positive(),type:p.literal("loop")}),Td=p.object({...R,body:se,collection:p.union([p.array(p.record(p.string(),p.unknown())).min(1),p.object({name:p.string().min(1),type:p.literal("variable")})]),iteratorVar:p.string().min(1),type:p.literal("forEach")}),vd=p.object({...R,branches:p.array(se).min(2),type:p.literal("parallel")}),Cd=p.object({...R,body:se,catch:se.optional(),finally:se.optional(),type:p.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),xd=p.object({...R,nodes:se,type:p.literal("group")}),qn=p.discriminatedUnion("type",[Oc,Ic,Uc,jc,_c,$c,Bc,Dc,od,ad,sd,id,ld,cd,dd,pd,ud,fd,md,yd,gd,Fc,Vc,Wc,qc,Mc,Gc,Jc,zc,Hc,Xc,Kc,Yc,Qc,Zc,ed,td,nd,rd,hd,wd,Sd,kd,bd,Ad,Rd,Nd,Td,vd,xd]),ba=p.union([qn,Cd]),$e=p.object({entryNode:p.string().min(1),nodes:p.record(p.string(),ba),variables:p.record(p.string(),nt).optional(),version:p.literal(2)});function rt(e){let t=$e.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(n=>({message:n.message,path:n.path.join(".")})),success:!1}}import{graphql as _t,readFragment as Zn}from"gql.tada";async function Aa({node:e,page:t,timeout:n,variables:r}){switch(e.type){case"assertTitle":{let o=P({ref:e.expected,variables:r});return[la({expected:o,operator:e.operator,title:await t.title()})]}case"assertChecked":return[await ca({locator:T({locator:e.locator,page:t}),timeout:n})];case"assertNotChecked":return[await da({locator:T({locator:e.locator,page:t}),timeout:n})];case"assertFocused":return[await pa({locator:T({locator:e.locator,page:t}),timeout:n})];case"assertCookie":return Ld({node:e,page:t,variables:r});case"assertResponse":return Pd({node:e,page:t,timeout:n,variables:r})}}async function Ld({node:e,page:t,variables:n}){let r=P({ref:e.name,variables:n}),o=e.value==null?void 0:P({ref:e.value,variables:n}),a=await t.context().cookies();return[ua({cookies:a,expected:{httpOnly:e.httpOnly,name:r,operator:e.operator,sameSite:e.sameSite,secure:e.secure,value:o}})]}async function Pd({node:e,page:t,timeout:n,variables:r}){let o=P({ref:e.urlPattern,variables:r}),a=e.bodyContains==null?void 0:P({ref:e.bodyContains,variables:r}),s=e.headerContains==null?void 0:{name:e.headerContains.name,value:P({ref:e.headerContains.value,variables:r})};return fa({bodyContains:a,headerContains:s,page:t,status:e.status,timeout:n,urlPattern:o})}async function ee({fn:e,label:t}){let n=performance.now(),r=await e();return w.info("%s: %dms",t,Math.round(performance.now()-n)),r}var Ed=5e3;async function Mn({failFast:e,onStep:t,page:n,spec:r,variables:o}){let a=performance.now();return Id({currentId:r.entryNode,failFast:e,onStep:t,page:n,runStartTime:a,spec:r,startIndex:0,variables:o})}function Od({onStep:e,steps:t,target:n}){t.forEach(r=>{n.push(r),e?.(r)})}async function Id({currentId:e,failFast:t,onStep:n,page:r,runStartTime:o,spec:a,startIndex:s,variables:i}){let l=[],c=i,d=e;for(;d!=null;){let f=a.nodes[d];if(f==null)throw new Error(`Node "${d}" not found in spec`);let u=d,m=f.label??`${f.type} (${d})`;w.info("Executing node: %s [%s]",m,f.type);let y=await Ra({failFast:t,node:f,nodeId:u,page:r,runStartTime:o,spec:a,startIndex:s+l.length,variables:c});if(Od({onStep:n,steps:y.steps,target:l}),c=y.variables,t&&y.steps.some(h=>h.status==="failed"))break;d=f.next}return{steps:l,variables:c}}async function Ra({failFast:e,node:t,nodeId:n,page:r,runStartTime:o,spec:a,startIndex:s,variables:i}){let l=performance.now(),c=t.label??`${t.type} (${t.id})`,d=t.timeout??Ed;if(Ud(t))return jd({failFast:e,node:t,page:r,spec:a,startIndex:s,timeout:d,variables:i});let f=Nt({node:t,page:r});try{let u=await Dd({node:t,page:r,timeout:d,variables:i}),m=Math.round(performance.now()-l),y=u.assertions.some(k=>k.status==="failed"),h=await ee({label:`Snapshot [${c}]`,fn:()=>pe({page:r,runStartTime:o,targets:f})});return{steps:[{annotations:h.annotations,assertions:u.assertions,detail:void 0,duration:m,nodeId:n,nodeType:t.type,screenshotBase64:h.screenshotBase64,snapshotTimestamp:h.snapshotTimestamp,status:y?"failed":"passed",stepIndex:s,title:c,url:h.url,viewportHeight:h.viewportHeight,viewportWidth:h.viewportWidth}],variables:u.variables}}catch(u){let m=Math.round(performance.now()-l),y=u instanceof Error?u.message:String(u),h=await ee({label:`Snapshot [${c}] (error)`,fn:()=>pe({page:r,runStartTime:o,targets:f})});return{steps:[{annotations:h.annotations,assertions:[],detail:y,duration:m,nodeId:n,nodeType:t.type,screenshotBase64:h.screenshotBase64,snapshotTimestamp:h.snapshotTimestamp,status:"failed",stepIndex:s,title:c,url:h.url,viewportHeight:h.viewportHeight,viewportWidth:h.viewportWidth}],variables:i}}}function Ud(e){return["if","loop","forEach","parallel","try","group"].includes(e.type)}async function jd({failFast:e,node:t,page:n,spec:r,startIndex:o,timeout:a,variables:s}){let i={executeSequence:Bd,failFast:e,page:n,spec:r,startIndex:o,timeout:a,variables:s};switch(t.type){case"if":return _n({...i,node:t});case"loop":return $n({...i,node:t});case"forEach":return Bn({...i,node:t});case"parallel":return Dn({...i,node:t});case"try":return Fn({...i,node:t});case"group":return Vn({...i,node:t})}}function _d(e){return e.some(t=>t.status==="failed")}function $d({nodeId:e,spec:t,timeout:n}){let r=t.nodes[e];if(r==null)throw new Error(`Node "${e}" not found in spec`);return r.timeout==null?{...r,timeout:n}:r}async function Bd({failFast:e,nodeIds:t,page:n,spec:r,startIndex:o,timeout:a,variables:s}){let i=[],l=s;for(let c of t){let d=$d({nodeId:c,spec:r,timeout:a}),f=await Ra({failFast:e,node:d,nodeId:c,page:n,runStartTime:0,spec:r,startIndex:o+i.length,variables:l});if(i.push(...f.steps),l=f.variables,e&&_d(f.steps))break}return{steps:i,variables:l}}async function Dd({node:e,page:t,timeout:n,variables:r}){if(Fd(e)){let a=await sn({node:e,page:t,timeout:n,variables:r});return{assertions:[],variables:a.variables}}return{assertions:await Vd({node:e,page:t,timeout:n,variables:r}),variables:r}}function Fd(e){return["goto","click","dblclick","fill","select","hover","press","check","uncheck","clear","rightClick","handleDialog","scroll","clipboard","setPermission","waitFor","waitForUrl","waitForResponse","waitForRequest","screenshot","setViewport","wait","fail","setVariable","extractText","upload","drag","scrollIntoView","type","focus"].includes(e.type)}async function Vd({node:e,page:t,timeout:n,variables:r}){let o=e;switch(o.type){case"assertVisible":return[await et({locator:T({locator:o.locator,page:t}),timeout:n})];case"assertNotVisible":return[await tt({locator:T({locator:o.locator,page:t}),timeout:n})];case"assertText":{let a=P({ref:o.expected,variables:r});return[await xn({expected:a,locator:T({locator:o.locator,page:t}),operator:o.operator,timeout:n})]}case"assertUrl":{let a=P({ref:o.expected,variables:r});return[Ln({expected:a,operator:o.operator,url:t.url()})]}case"assertCount":{let a=an({ref:o.expected,variables:r});return[await Pn({expected:a,locator:T({locator:o.locator,page:t}),operator:o.operator})]}case"assertValue":{let a=P({ref:o.expected,variables:r});return[await En({expected:a,locator:T({locator:o.locator,page:t}),operator:o.operator,timeout:n})]}case"assertAttribute":{let a=P({ref:o.expected,variables:r});return[await aa({attribute:o.attribute,expected:a,locator:T({locator:o.locator,page:t}),operator:o.operator,timeout:n})]}case"assertEnabled":return[await sa({locator:T({locator:o.locator,page:t}),timeout:n})];case"assertDisabled":return[await ia({locator:T({locator:o.locator,page:t}),timeout:n})];case"assertTitle":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertCookie":case"assertResponse":return Aa({node:o,page:t,timeout:n,variables:r})}}async function Gn({baseUrl:e,browser:t,cookies:n,extraVariables:r,navigateTo:o,onStep:a,runId:s,spec:i}){let l=await t.newContext({baseURL:e});w.info("Browser context created"),n.length>0&&await l.addCookies(n);let c=await l.newPage();w.info("Page created");let d=Qe(c);o!=null&&(w.info("Navigating to: %s",o),await c.goto(o,{waitUntil:"domcontentloaded"}),w.info("Navigation complete"));function f(k){a?.(k),xt({context:l,page:c,runId:s,stepIndex:k.stepIndex,stepResult:k})}let u={...Ye({defs:i.variables}),...r};w.info("Starting graph execution (entry: %s)",i.entryNode);let m=await Mn({failFast:!0,onStep:f,page:c,spec:i,variables:u}),y=m.steps.filter(k=>k.status==="passed").length,h=m.steps.filter(k=>k.status==="failed").length,S={duration:m.steps.reduce((k,b)=>k+b.duration,0),failCount:h,passCount:y,runId:s,status:h>0?"failed":"passed",workflowName:""};return await Lt({monitor:d,runId:s,steps:m.steps,summary:S}),await l.close(),m.steps}import{parseSetCookie as Kd}from"set-cookie-parser";import{z as _a}from"zod";var ja=wi(Ia(),1);import Ua from"crypto";function jt({body:e,secret:t}){let n=new ja.Webhook(t),r=`msg_${Ua.randomUUID()}`,o=new Date,a=n.sign(r,o,e),s=Math.floor(o.getTime()/1e3);return{"webhook-id":r,"webhook-signature":a,"webhook-timestamp":String(s)}}function at(){return`whsec_${Ua.randomBytes(24).toString("base64")}`}async function Hn({apiUrl:e,cookies:t,executed:n,webhookSecret:r}){if(n.length!==0)try{let o=JSON.stringify({preconditions:n}),a=await fetch(`${e}/teardown`,{body:o,headers:{"Content-Type":"application/json",...Xn({cookies:t}),...jt({body:o,secret:r})},method:"PUT"});a.ok||w.error("Teardown returned %s",String(a.status))}catch{w.error("Teardown request failed")}}function Yd({preconditionNames:e,preconditions:t}){let n=[],r=new Set;function o(a){if(r.has(a))return;r.add(a);let s=t[a];s?.depends!=null&&s.depends.forEach(i=>{o(i)}),n.push(a)}return e.forEach(a=>{o(a)}),n}async function Qd({apiUrl:e,cookies:t,name:n,webhookSecret:r}){let o=JSON.stringify({precondition:n}),a=await fetch(`${e}/check`,{body:o,headers:{"Content-Type":"application/json",...Xn({cookies:t}),...jt({body:o,secret:r})},method:"POST"});if(!a.ok)return!1;let s=await a.json(),i=bt.safeParse(s);if(!i.success)throw new Error(`Check response for "${n}" has invalid shape: ${i.error.message}`);return i.data.satisfied}async function Zd({apiUrl:e,cookies:t,name:n,webhookSecret:r}){let o=JSON.stringify({precondition:n}),a=await fetch(`${e}/execute`,{body:o,headers:{"Content-Type":"application/json",...Xn({cookies:t}),...jt({body:o,secret:r})},method:"PUT"});if(!a.ok)throw new Error(`Execute for "${n}" returned ${String(a.status)}`);let s=await a.json(),i=At.safeParse(s);if(!i.success)throw new Error(`Execute response for "${n}" has invalid shape: ${i.error.message}`);if(!i.data.success){let c=i.data.error??"no error detail";throw new Error(`Precondition "${n}" failed to execute: ${c}`)}return{cookies:ep({domain:new URL(e).hostname,res:a}),data:i.data.data??{},navigateTo:i.data.navigateTo}}function Xn({cookies:e}){return e.length===0?{}:{Cookie:e.map(n=>`${n.name}=${n.value}`).join("; ")}}function ep({domain:e,res:t}){let n=t.headers.getSetCookie();return Kd(n,{decodeValues:!1}).map(o=>tp({cookie:o,domain:e}))}function tp({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=rp({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}var np={lax:"Lax",none:"None",strict:"Strict"};function rp({raw:e}){return np[e.toLowerCase()]??"Lax"}var op=_a.record(_a.string(),Pe);async function Kn({baseUrl:e,project:t,webhookSecret:n,workflowSlug:r}){let o={apiUrl:void 0,cookies:[],data:{},executed:[],navigateTo:void 0},a=t.stateGraph;if(a==null)return o;let s=(a.edges??[]).find(f=>f.workflowSlug===r);if(s?.sourceState==null)return o;let i=ip({baseUrl:e,preconditionApiPath:t.preconditionApiPath}),l=s.sourceState.preconditions;if(l.length===0)return{...o,apiUrl:i};if(i==null)return o;let c=op.safeParse(a.preconditions);if(!c.success)return{...o,apiUrl:i};let d=await sp({apiUrl:i,preconditionNames:l,preconditions:c.data,webhookSecret:n});return{apiUrl:i,cookies:d.cookies,data:d.data,executed:d.executed,navigateTo:d.navigateTo}}async function ap({acc:e,apiUrl:t,name:n,webhookSecret:r}){if(await Qd({apiUrl:t,cookies:e.cookies,name:n,webhookSecret:r}))return e;let a=await Zd({apiUrl:t,cookies:e.cookies,name:n,webhookSecret:r});return{cookies:[...e.cookies,...a.cookies],data:{...e.data,...a.data},executed:[...e.executed,n],navigateTo:a.navigateTo??e.navigateTo}}async function sp({apiUrl:e,preconditionNames:t,preconditions:n,webhookSecret:r}){let o=Yd({preconditionNames:t,preconditions:n}),s={cookies:[],data:{},executed:[],navigateTo:void 0};for(let i of o)s=await ap({acc:s,apiUrl:e,name:i,webhookSecret:r});return s}function ip({baseUrl:e,preconditionApiPath:t}){if(t.length!==0)return t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`}import{graphql as Yn}from"gql.tada";async function Qn({agentProfileId:e,config:t,runId:n}){let r=await G({config:t,document:cp,variables:{agentProfileId:e??null,platform:"chromium",runId:n}});if(r.startRun==null)throw new Error("Failed to start run");let o=r.startRun.id,a=Promise.resolve();function s(l){a=a.then(()=>lp({config:t,runResultId:o,steps:[l]})).catch(c=>{let d=c instanceof Error?c.message:"Unknown error";w.error("Failed to submit step %d: %s",l.stepIndex,d)})}async function i({statusOverride:l,steps:c,summary:d}){await a;let f=c.filter(h=>h.status==="passed").length,u=c.filter(h=>h.status==="failed").length,m=c.reduce((h,S)=>h+S.duration,0),y=l??(u>0?"failed":"passed");await G({config:t,document:pp,variables:{duration:m,failCount:u,passCount:f,runResultId:o,status:y,summary:d??null,warnCount:0}})}return{complete:i,enqueueStep:s,runResultId:o}}async function lp({config:e,runResultId:t,steps:n}){let r=n.map(o=>({annotations:o.annotations.map(a=>({height:a.height,label:a.label,type:a.type,width:a.width,x:a.x,y:a.y})),assertions:o.assertions.map(a=>({description:a.description,detail:a.detail,status:a.status})),detail:o.detail,duration:o.duration,nodeType:o.nodeType,screenshotBase64:o.screenshotBase64,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth}));await G({config:e,document:dp,variables:{runResultId:t,steps:r}})}var cp=Yn(`
92
+ `);async function In({maxRuns:e}){try{let n=(await uc(ga,{withFileTypes:!0})).filter(c=>c.isDirectory()),r=Date.now(),o=await Promise.all(n.map(async c=>{let d=wa.join(ga,c.name),p=await mc(d);return{dirPath:d,mtime:p.mtimeMs}})),a=o.filter(c=>r-c.mtime>ha),i=o.filter(c=>r-c.mtime<=ha).toSorted((c,d)=>d.mtime-c.mtime).slice(e),l=[...a,...i];if(l.length===0)return;await Promise.allSettled(l.map(c=>fc(c.dirPath,{force:!0,recursive:!0}))),w.info("Pruned %d old debug run(s)",l.length)}catch{w.warn("Debug run pruning failed, ignoring")}}var gc=5e3;async function Un({baseUrl:e}){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(gc)})}catch(t){let n=t instanceof Error?t.message:String(t);throw w.debug("Base URL reachability check failed: %s",n),new Error([`Could not reach your dev server at ${e}.`,"","Troubleshooting:",` 1. Make sure your app is running at ${e}`," 2. Check the `baseUrl` in `.ripplo/settings.json` \u2014 is the port correct?"," 3. If your app runs on a different port, update `baseUrl` in `.ripplo/settings.json`"].join(`
93
+ `))}}async function jn({condition:e,page:t,timeout:n,variables:r}){switch(e.type){case"elementVisible":return(await et({locator:T({locator:e.locator,page:t}),timeout:n})).status==="passed";case"elementNotVisible":return(await tt({locator:T({locator:e.locator,page:t}),timeout:n})).status==="passed";case"urlMatch":{let o=E({ref:e.expected,variables:r});return Z({actual:t.url(),expected:o,label:"URL",operator:e.operator}).status==="passed"}case"textMatch":{let a=await T({locator:e.locator,page:t}).textContent({timeout:n}),s=E({ref:e.expected,variables:r});return Z({actual:a??"",expected:s,label:"Text",operator:e.operator}).status==="passed"}case"variableCompare":{let o=r[e.variable];if(o==null)throw new Error(`Variable "${e.variable}" is not defined`);let a=typeof o=="number"?o:Number(o),s=ke({ref:e.expected,variables:r}),i=typeof s=="number"?s:Number(s);return Pt({actual:a,expected:i,label:e.variable,operator:e.operator}).status==="passed"}}}import Ue from"fs";import _n from"path";import{z as ae}from"zod";var hc=ae.object({baseUrl:ae.string(),cloudBaseUrl:ae.string(),preconditionApiPath:ae.string(),projectId:ae.string()}),wc=ae.object({ripploServerUrl:ae.string(),token:ae.string(),webhookSecret:ae.string()}),Sc=hc.extend(wc.shape),Et=_n.join(process.cwd(),".ripplo"),ka=_n.join(Et,"settings.json"),ba=_n.join(Et,"settings.local.json");function Sa(e){if(!Ue.existsSync(e))return null;let t=Ue.readFileSync(e,"utf8");return JSON.parse(t)}function ue(){let e=Sa(ka),t=Sa(ba);if(e==null||t==null)return null;let n=Sc.safeParse({...e,...t});return n.success?n.data:null}function be(e){Ue.existsSync(Et)||Ue.mkdirSync(Et,{recursive:!0});let{ripploServerUrl:t,token:n,webhookSecret:r,...o}=e;Ue.writeFileSync(ka,JSON.stringify(o,null,2)+`
94
+ `),Ue.writeFileSync(ba,JSON.stringify({ripploServerUrl:t,token:n,webhookSecret:r},null,2)+`
95
+ `)}async function $n({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){let c=await jn({condition:n.condition,page:r,timeout:s,variables:i})?n.consequent:n.alternate??[];return c.length===0?{steps:[],variables:i}:e({failFast:t,nodeIds:c,page:r,spec:o,startIndex:a,timeout:s,variables:i})}async function Bn({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){let l=[],c=i;for(let d=0;d<n.times;d++){n.iteratorVar!=null&&(c=oe({name:n.iteratorVar,store:c,value:d}));let p=await e({failFast:t,nodeIds:n.body,page:r,spec:o,startIndex:a+l.length,timeout:s,variables:c});if(l.push(...p.steps),c=p.variables,t&&p.steps.some(u=>u.status==="failed"))break}return{steps:l,variables:c}}async function Dn({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){let l=bc({collection:n.collection,variables:i}),c=[],d=i;for(let p of l){d=oe({name:n.iteratorVar,store:d,value:kc(p)});let u=await e({failFast:t,nodeIds:n.body,page:r,spec:o,startIndex:a+c.length,timeout:s,variables:d});if(c.push(...u.steps),d=u.variables,t&&u.steps.some(m=>m.status==="failed"))break}return{steps:c,variables:d}}function kc(e){return typeof e=="object"&&e!=null?JSON.stringify(e):e==null?"":String(e)}function bc({collection:e,variables:t}){if(Array.isArray(e))return e;let n=t[e.name];if(n==null)throw new Error(`Variable "${e.name}" is not defined`);return Ac(n)}function Ac(e){if(typeof e!="string")return[e];try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return[e]}async function Fn({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){let l=await Promise.all(n.branches.map(p=>e({failFast:t,nodeIds:p,page:r,spec:o,startIndex:a,timeout:s,variables:i}))),c=l.flatMap(p=>p.steps),d=Rc({base:i,results:l});return{steps:c,variables:d}}function Rc({base:e,results:t}){let n=e;return t.forEach(r=>{n={...n,...r.variables}}),n}async function Vn({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){let l=[],c=i;try{let d=await e({failFast:t,nodeIds:n.body,page:r,spec:o,startIndex:a,timeout:s,variables:c});if(l.push(...d.steps),c=d.variables,d.steps.some(u=>u.status==="failed")&&n.catch!=null){let u=await e({failFast:t,nodeIds:n.catch,page:r,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...u.steps),c=u.variables}}catch{if(n.catch!=null){let d=await e({failFast:t,nodeIds:n.catch,page:r,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...d.steps),c=d.variables}}finally{if(n.finally!=null){let d=await e({failFast:t,nodeIds:n.finally,page:r,spec:o,startIndex:a+l.length,timeout:s,variables:c});l.push(...d.steps),c=d.variables}}return{steps:l,variables:c}}async function Wn({executeSequence:e,failFast:t,node:n,page:r,spec:o,startIndex:a,timeout:s,variables:i}){return e({failFast:t,nodeIds:n.nodes,page:r,spec:o,startIndex:a,timeout:s,variables:i})}import{z as f}from"zod";import{z as K}from"zod";import{z as O}from"zod";var Nc=O.object({by:O.literal("css"),value:O.string().min(1)}),Tc=O.object({by:O.literal("testId"),value:O.string().min(1)}),vc=O.object({by:O.literal("role"),exact:O.boolean().optional(),name:O.string().optional(),role:O.string().min(1)}),Cc=O.object({by:O.literal("text"),exact:O.boolean().optional(),value:O.string().min(1)}),xc=O.object({by:O.literal("label"),exact:O.boolean().optional(),value:O.string().min(1)}),Lc=O.object({by:O.literal("placeholder"),value:O.string().min(1)}),Pc=O.object({by:O.literal("altText"),value:O.string().min(1)}),N=O.discriminatedUnion("by",[Nc,Tc,vc,Cc,xc,Lc,Pc]);import{z as Aa}from"zod";var W=Aa.enum(["equals","notEquals","contains","startsWith","endsWith","matches"]),fe=Aa.enum(["equals","notEquals","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual"]);import{z as D}from"zod";var Ec=D.object({type:D.literal("static"),value:D.union([D.string(),D.number(),D.boolean()])}),qn=D.object({name:D.string().min(1),type:D.literal("variable")}),Ae=D.discriminatedUnion("type",[Ec,qn]),I=D.discriminatedUnion("type",[D.object({type:D.literal("static"),value:D.string()}),qn]),je=D.discriminatedUnion("type",[D.object({type:D.literal("static"),value:D.number().int().nonnegative()}),qn]);var _e=K.discriminatedUnion("type",[K.object({locator:N,type:K.literal("elementVisible")}),K.object({locator:N,type:K.literal("elementNotVisible")}),K.object({expected:I,operator:W,type:K.literal("urlMatch")}),K.object({expected:I,locator:N,operator:W,type:K.literal("textMatch")}),K.object({expected:Ae,operator:fe,type:K.literal("variableCompare"),variable:K.string().min(1)})]);import{z as J}from"zod";var nt=J.discriminatedUnion("type",[J.object({default:J.string().optional(),type:J.literal("string")}),J.object({default:J.number().optional(),type:J.literal("number")}),J.object({default:J.boolean().optional(),type:J.literal("boolean")}),J.object({key:J.string().min(1),type:J.literal("env")})]);var Oc=f.string().min(1),se=f.array(Oc).min(1),R={comment:f.string().optional(),id:f.string().min(1),label:f.string().optional(),next:f.string().optional(),timeout:f.number().int().positive().optional()},Ic=f.object({...R,type:f.literal("goto"),url:I}),Uc=f.object({...R,locator:N,type:f.literal("click")}),jc=f.object({...R,locator:N,type:f.literal("fill"),value:I}),_c=f.object({...R,locator:N,type:f.literal("select"),value:I}),$c=f.object({...R,locator:N,type:f.literal("hover")}),Bc=f.object({...R,key:f.string().min(1),locator:N.optional(),type:f.literal("press")}),Dc=f.object({...R,locator:N,type:f.literal("check")}),Fc=f.object({...R,locator:N,type:f.literal("uncheck")}),Vc=f.object({...R,type:f.literal("screenshot")}),Wc=f.object({...R,height:f.number().int().positive(),type:f.literal("setViewport"),width:f.number().int().positive()}),qc=f.object({...R,duration:f.number().int().positive(),type:f.literal("wait")}),Mc=f.object({...R,message:f.string().min(1),type:f.literal("fail")}),Gc=f.object({...R,type:f.literal("setVariable"),value:Ae,variable:f.string().min(1)}),Jc=f.object({...R,locator:N,type:f.literal("extractText"),variable:f.string().min(1)}),zc=f.object({...R,files:f.array(f.string()).min(1),locator:N,type:f.literal("upload")}),Hc=f.object({...R,locator:N,type:f.literal("dblclick")}),Xc=f.object({...R,source:N,target:N,type:f.literal("drag")}),Kc=f.object({...R,locator:N,type:f.literal("scrollIntoView")}),Yc=f.object({...R,locator:N,type:f.literal("type"),value:I}),Qc=f.object({...R,locator:N,type:f.literal("focus")}),Zc=f.object({...R,locator:N,type:f.literal("clear")}),ed=f.object({...R,locator:N,type:f.literal("rightClick")}),td=f.object({...R,action:f.enum(["accept","dismiss"]),promptText:f.string().optional(),type:f.literal("handleDialog")}),nd=f.object({...R,locator:N.optional(),type:f.literal("scroll"),x:f.number().int().optional(),y:f.number().int().optional()}),rd=f.object({...R,action:f.enum(["read","write"]),type:f.literal("clipboard"),value:I.optional(),variable:f.string().min(1).optional()}),od=f.object({...R,permission:f.string().min(1),state:f.enum(["granted","prompt"]),type:f.literal("setPermission")}),ad=f.object({...R,locator:N,state:f.enum(["visible","hidden","attached","detached"]).optional(),type:f.literal("waitFor")}),sd=f.object({...R,expected:I,operator:W,type:f.literal("waitForUrl")}),id=f.object({...R,type:f.literal("waitForResponse"),urlPattern:I}),ld=f.object({...R,type:f.literal("waitForRequest"),urlPattern:I}),cd=f.object({...R,locator:N,type:f.literal("assertVisible")}),dd=f.object({...R,locator:N,type:f.literal("assertNotVisible")}),pd=f.object({...R,expected:I,locator:N,operator:W,type:f.literal("assertText")}),ud=f.object({...R,expected:I,operator:W,type:f.literal("assertUrl")}),fd=f.object({...R,expected:je,locator:N,operator:fe,type:f.literal("assertCount")}),md=f.object({...R,expected:I,locator:N,operator:W,type:f.literal("assertValue")}),yd=f.object({...R,attribute:f.string().min(1),expected:I,locator:N,operator:W,type:f.literal("assertAttribute")}),gd=f.object({...R,locator:N,type:f.literal("assertEnabled")}),hd=f.object({...R,locator:N,type:f.literal("assertDisabled")}),wd=f.object({...R,expected:I,operator:W,type:f.literal("assertTitle")}),Sd=f.object({...R,locator:N,type:f.literal("assertChecked")}),kd=f.object({...R,locator:N,type:f.literal("assertNotChecked")}),bd=f.object({...R,locator:N,type:f.literal("assertFocused")}),Ad=f.object({...R,httpOnly:f.boolean().optional(),name:I,operator:W.optional(),sameSite:f.enum(["Strict","Lax","None"]).optional(),secure:f.boolean().optional(),type:f.literal("assertCookie"),value:I.optional()}),Rd=f.object({...R,bodyContains:I.optional(),headerContains:f.object({name:f.string().min(1),value:I}).optional(),status:f.number().int().positive().optional(),type:f.literal("assertResponse"),urlPattern:I}),Nd=f.object({...R,alternate:se.optional(),condition:_e,consequent:se,type:f.literal("if")}),Td=f.object({...R,body:se,iteratorVar:f.string().min(1).optional(),times:f.number().int().positive(),type:f.literal("loop")}),vd=f.object({...R,body:se,collection:f.union([f.array(f.record(f.string(),f.unknown())).min(1),f.object({name:f.string().min(1),type:f.literal("variable")})]),iteratorVar:f.string().min(1),type:f.literal("forEach")}),Cd=f.object({...R,branches:f.array(se).min(2),type:f.literal("parallel")}),xd=f.object({...R,body:se,catch:se.optional(),finally:se.optional(),type:f.literal("try")}).refine(e=>e.catch!=null||e.finally!=null,{message:"try node must have at least one of 'catch' or 'finally'"}),Ld=f.object({...R,nodes:se,type:f.literal("group")}),Mn=f.discriminatedUnion("type",[Ic,Uc,jc,_c,$c,Bc,Dc,Fc,ad,sd,id,ld,cd,dd,pd,ud,fd,md,yd,gd,hd,Vc,Wc,qc,Mc,Gc,Jc,zc,Hc,Xc,Kc,Yc,Qc,Zc,ed,td,nd,rd,od,wd,Sd,kd,bd,Ad,Rd,Nd,Td,vd,Cd,Ld]),Ra=f.union([Mn,xd]),$e=f.object({entryNode:f.string().min(1),nodes:f.record(f.string(),Ra),variables:f.record(f.string(),nt).optional(),version:f.literal(2)});function rt(e){let t=$e.safeParse(e);return t.success?{data:t.data,success:!0}:{errors:t.error.issues.map(n=>({message:n.message,path:n.path.join(".")})),success:!1}}import{graphql as _t,readFragment as er}from"gql.tada";async function Na({node:e,page:t,timeout:n,variables:r}){switch(e.type){case"assertTitle":{let o=E({ref:e.expected,variables:r});return[da({expected:o,operator:e.operator,title:await t.title()})]}case"assertChecked":return[await pa({locator:T({locator:e.locator,page:t}),timeout:n})];case"assertNotChecked":return[await ua({locator:T({locator:e.locator,page:t}),timeout:n})];case"assertFocused":return[await fa({locator:T({locator:e.locator,page:t}),timeout:n})];case"assertCookie":return Pd({node:e,page:t,variables:r});case"assertResponse":return Ed({node:e,page:t,timeout:n,variables:r})}}async function Pd({node:e,page:t,variables:n}){let r=E({ref:e.name,variables:n}),o=e.value==null?void 0:E({ref:e.value,variables:n}),a=await t.context().cookies();return[ma({cookies:a,expected:{httpOnly:e.httpOnly,name:r,operator:e.operator,sameSite:e.sameSite,secure:e.secure,value:o}})]}async function Ed({node:e,page:t,timeout:n,variables:r}){let o=E({ref:e.urlPattern,variables:r}),a=e.bodyContains==null?void 0:E({ref:e.bodyContains,variables:r}),s=e.headerContains==null?void 0:{name:e.headerContains.name,value:E({ref:e.headerContains.value,variables:r})};return ya({bodyContains:a,headerContains:s,page:t,status:e.status,timeout:n,urlPattern:o})}async function ee({fn:e,label:t}){let n=performance.now(),r=await e();return w.info("%s: %dms",t,Math.round(performance.now()-n)),r}var Od=5e3;async function Gn({failFast:e,onStep:t,page:n,spec:r,variables:o}){let a=performance.now();return Ud({currentId:r.entryNode,failFast:e,onStep:t,page:n,runStartTime:a,spec:r,startIndex:0,variables:o})}function Id({onStep:e,steps:t,target:n}){t.forEach(r=>{n.push(r),e?.(r)})}async function Ud({currentId:e,failFast:t,onStep:n,page:r,runStartTime:o,spec:a,startIndex:s,variables:i}){let l=[],c=i,d=e;for(;d!=null;){let p=a.nodes[d];if(p==null)throw new Error(`Node "${d}" not found in spec`);let u=d,m=p.label??`${p.type} (${d})`;w.info("Executing node: %s [%s]",m,p.type);let y=await Ta({failFast:t,node:p,nodeId:u,page:r,runStartTime:o,spec:a,startIndex:s+l.length,variables:c});if(Id({onStep:n,steps:y.steps,target:l}),c=y.variables,t&&y.steps.some(g=>g.status==="failed"))break;d=p.next}return{steps:l,variables:c}}async function Ta({failFast:e,node:t,nodeId:n,page:r,runStartTime:o,spec:a,startIndex:s,variables:i}){let l=performance.now(),c=t.label??`${t.type} (${t.id})`,d=t.timeout??Od;if(jd(t))return _d({failFast:e,node:t,page:r,spec:a,startIndex:s,timeout:d,variables:i});let p=Nt({node:t,page:r});try{let u=await Fd({node:t,page:r,timeout:d,variables:i}),m=Math.round(performance.now()-l),y=u.assertions.some(k=>k.status==="failed"),g=await ee({label:`Snapshot [${c}]`,fn:()=>pe({page:r,runStartTime:o,targets:p})});return{steps:[{annotations:g.annotations,assertions:u.assertions,detail:void 0,duration:m,nodeId:n,nodeType:t.type,screenshotBase64:g.screenshotBase64,snapshotTimestamp:g.snapshotTimestamp,status:y?"failed":"passed",stepIndex:s,title:c,url:g.url,viewportHeight:g.viewportHeight,viewportWidth:g.viewportWidth}],variables:u.variables}}catch(u){let m=Math.round(performance.now()-l),y=u instanceof Error?u.message:String(u),g=await ee({label:`Snapshot [${c}] (error)`,fn:()=>pe({page:r,runStartTime:o,targets:p})});return{steps:[{annotations:g.annotations,assertions:[],detail:y,duration:m,nodeId:n,nodeType:t.type,screenshotBase64:g.screenshotBase64,snapshotTimestamp:g.snapshotTimestamp,status:"failed",stepIndex:s,title:c,url:g.url,viewportHeight:g.viewportHeight,viewportWidth:g.viewportWidth}],variables:i}}}function jd(e){return["if","loop","forEach","parallel","try","group"].includes(e.type)}async function _d({failFast:e,node:t,page:n,spec:r,startIndex:o,timeout:a,variables:s}){let i={executeSequence:Dd,failFast:e,page:n,spec:r,startIndex:o,timeout:a,variables:s};switch(t.type){case"if":return $n({...i,node:t});case"loop":return Bn({...i,node:t});case"forEach":return Dn({...i,node:t});case"parallel":return Fn({...i,node:t});case"try":return Vn({...i,node:t});case"group":return Wn({...i,node:t})}}function $d(e){return e.some(t=>t.status==="failed")}function Bd({nodeId:e,spec:t,timeout:n}){let r=t.nodes[e];if(r==null)throw new Error(`Node "${e}" not found in spec`);return r.timeout==null?{...r,timeout:n}:r}async function Dd({failFast:e,nodeIds:t,page:n,spec:r,startIndex:o,timeout:a,variables:s}){let i=[],l=s;for(let c of t){let d=Bd({nodeId:c,spec:r,timeout:a}),p=await Ta({failFast:e,node:d,nodeId:c,page:n,runStartTime:0,spec:r,startIndex:o+i.length,variables:l});if(i.push(...p.steps),l=p.variables,e&&$d(p.steps))break}return{steps:i,variables:l}}async function Fd({node:e,page:t,timeout:n,variables:r}){if(Vd(e)){let a=await ln({node:e,page:t,timeout:n,variables:r});return{assertions:[],variables:a.variables}}return{assertions:await Wd({node:e,page:t,timeout:n,variables:r}),variables:r}}function Vd(e){return["goto","click","dblclick","fill","select","hover","press","check","uncheck","clear","rightClick","handleDialog","scroll","clipboard","setPermission","waitFor","waitForUrl","waitForResponse","waitForRequest","screenshot","setViewport","wait","fail","setVariable","extractText","upload","drag","scrollIntoView","type","focus"].includes(e.type)}async function Wd({node:e,page:t,timeout:n,variables:r}){let o=e;switch(o.type){case"assertVisible":return[await et({locator:T({locator:o.locator,page:t}),timeout:n})];case"assertNotVisible":return[await tt({locator:T({locator:o.locator,page:t}),timeout:n})];case"assertText":{let a=E({ref:o.expected,variables:r});return[await Ln({expected:a,locator:T({locator:o.locator,page:t}),operator:o.operator,timeout:n})]}case"assertUrl":{let a=E({ref:o.expected,variables:r});return[Pn({expected:a,operator:o.operator,url:t.url()})]}case"assertCount":{let a=sn({ref:o.expected,variables:r});return[await En({expected:a,locator:T({locator:o.locator,page:t}),operator:o.operator})]}case"assertValue":{let a=E({ref:o.expected,variables:r});return[await On({expected:a,locator:T({locator:o.locator,page:t}),operator:o.operator,timeout:n})]}case"assertAttribute":{let a=E({ref:o.expected,variables:r});return[await ia({attribute:o.attribute,expected:a,locator:T({locator:o.locator,page:t}),operator:o.operator,timeout:n})]}case"assertEnabled":return[await la({locator:T({locator:o.locator,page:t}),timeout:n})];case"assertDisabled":return[await ca({locator:T({locator:o.locator,page:t}),timeout:n})];case"assertTitle":case"assertChecked":case"assertNotChecked":case"assertFocused":case"assertCookie":case"assertResponse":return Na({node:o,page:t,timeout:n,variables:r})}}async function Jn({baseUrl:e,browser:t,cookies:n,extraVariables:r,navigateTo:o,onStep:a,runId:s,spec:i}){let l=await t.newContext({baseURL:e});w.info("Browser context created"),n.length>0&&await l.addCookies(n);let c=await l.newPage();w.info("Page created");let d=Qe(c);o!=null&&(w.info("Navigating to: %s",o),await c.goto(o,{waitUntil:"domcontentloaded"}),w.info("Navigation complete"));function p(k){a?.(k),xt({context:l,page:c,runId:s,stepIndex:k.stepIndex,stepResult:k})}let u={...Ye({defs:i.variables}),...r};w.info("Starting graph execution (entry: %s)",i.entryNode);let m=await Gn({failFast:!0,onStep:p,page:c,spec:i,variables:u}),y=m.steps.filter(k=>k.status==="passed").length,g=m.steps.filter(k=>k.status==="failed").length,S={duration:m.steps.reduce((k,b)=>k+b.duration,0),failCount:g,passCount:y,runId:s,status:g>0?"failed":"passed",workflowName:""};return await Lt({monitor:d,runId:s,steps:m.steps,summary:S}),await l.close(),m.steps}import{parseSetCookie as Yd}from"set-cookie-parser";import{z as Ba}from"zod";var $a=Si(ja(),1);import _a from"crypto";function jt({body:e,secret:t}){let n=new $a.Webhook(t),r=`msg_${_a.randomUUID()}`,o=new Date,a=n.sign(r,o,e),s=Math.floor(o.getTime()/1e3);return{"webhook-id":r,"webhook-signature":a,"webhook-timestamp":String(s)}}function at(){return`whsec_${_a.randomBytes(24).toString("base64")}`}async function Xn({apiUrl:e,cookies:t,executed:n,webhookSecret:r}){if(n.length!==0)try{let o=JSON.stringify({preconditions:n}),a=await fetch(`${e}/teardown`,{body:o,headers:{"Content-Type":"application/json",...Kn({cookies:t}),...jt({body:o,secret:r})},method:"PUT"});a.ok||w.error("Teardown returned %s",String(a.status))}catch{w.error("Teardown request failed")}}function Qd({preconditionNames:e,preconditions:t}){let n=[],r=new Set;function o(a){if(r.has(a))return;r.add(a);let s=t[a];s?.depends!=null&&s.depends.forEach(i=>{o(i)}),n.push(a)}return e.forEach(a=>{o(a)}),n}async function Zd({apiUrl:e,cookies:t,name:n,webhookSecret:r}){let o=JSON.stringify({precondition:n}),a=await fetch(`${e}/check`,{body:o,headers:{"Content-Type":"application/json",...Kn({cookies:t}),...jt({body:o,secret:r})},method:"POST"});if(!a.ok)return!1;let s=await a.json(),i=bt.safeParse(s);if(!i.success)throw new Error(`Check response for "${n}" has invalid shape: ${i.error.message}`);return i.data.satisfied}async function ep({apiUrl:e,cookies:t,name:n,webhookSecret:r}){let o=JSON.stringify({precondition:n}),a=await fetch(`${e}/execute`,{body:o,headers:{"Content-Type":"application/json",...Kn({cookies:t}),...jt({body:o,secret:r})},method:"PUT"});if(!a.ok)throw new Error(`Execute for "${n}" returned ${String(a.status)}`);let s=await a.json(),i=At.safeParse(s);if(!i.success)throw new Error(`Execute response for "${n}" has invalid shape: ${i.error.message}`);if(!i.data.success){let c=i.data.error??"no error detail";throw new Error(`Precondition "${n}" failed to execute: ${c}`)}return{cookies:tp({domain:new URL(e).hostname,res:a}),data:i.data.data??{},navigateTo:i.data.navigateTo}}function Kn({cookies:e}){return e.length===0?{}:{Cookie:e.map(n=>`${n.name}=${n.value}`).join("; ")}}function tp({domain:e,res:t}){let n=t.headers.getSetCookie();return Yd(n,{decodeValues:!1}).map(o=>np({cookie:o,domain:e}))}function np({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=op({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}var rp={lax:"Lax",none:"None",strict:"Strict"};function op({raw:e}){return rp[e.toLowerCase()]??"Lax"}var ap=Ba.record(Ba.string(),Pe);async function Yn({baseUrl:e,project:t,webhookSecret:n,workflowSlug:r}){let o={apiUrl:void 0,cookies:[],data:{},executed:[],navigateTo:void 0},a=t.stateGraph;if(a==null)return o;let s=(a.edges??[]).find(p=>p.workflowSlug===r);if(s?.sourceState==null)return o;let i=lp({baseUrl:e,preconditionApiPath:t.preconditionApiPath}),l=s.sourceState.preconditions;if(l.length===0)return{...o,apiUrl:i};if(i==null)return o;let c=ap.safeParse(a.preconditions);if(!c.success)return{...o,apiUrl:i};let d=await ip({apiUrl:i,preconditionNames:l,preconditions:c.data,webhookSecret:n});return{apiUrl:i,cookies:d.cookies,data:d.data,executed:d.executed,navigateTo:d.navigateTo}}async function sp({acc:e,apiUrl:t,name:n,webhookSecret:r}){if(await Zd({apiUrl:t,cookies:e.cookies,name:n,webhookSecret:r}))return e;let a=await ep({apiUrl:t,cookies:e.cookies,name:n,webhookSecret:r});return{cookies:[...e.cookies,...a.cookies],data:{...e.data,...a.data},executed:[...e.executed,n],navigateTo:a.navigateTo??e.navigateTo}}async function ip({apiUrl:e,preconditionNames:t,preconditions:n,webhookSecret:r}){let o=Qd({preconditionNames:t,preconditions:n}),s={cookies:[],data:{},executed:[],navigateTo:void 0};for(let i of o)s=await sp({acc:s,apiUrl:e,name:i,webhookSecret:r});return s}function lp({baseUrl:e,preconditionApiPath:t}){if(t.length!==0)return t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`}import{graphql as Qn}from"gql.tada";async function Zn({agentProfileId:e,config:t,runId:n}){let r=await G({config:t,document:dp,variables:{agentProfileId:e??null,platform:"chromium",runId:n}});if(r.startRun==null)throw new Error("Failed to start run");let o=r.startRun.id,a=Promise.resolve();function s(l){a=a.then(()=>cp({config:t,runResultId:o,steps:[l]})).catch(c=>{let d=c instanceof Error?c.message:"Unknown error";w.error("Failed to submit step %d: %s",l.stepIndex,d)})}async function i({statusOverride:l,steps:c,summary:d}){await a;let p=c.filter(g=>g.status==="passed").length,u=c.filter(g=>g.status==="failed").length,m=c.reduce((g,S)=>g+S.duration,0),y=l??(u>0?"failed":"passed");await G({config:t,document:up,variables:{duration:m,failCount:u,passCount:p,runResultId:o,status:y,summary:d??null,warnCount:0}})}return{complete:i,enqueueStep:s,runResultId:o}}async function cp({config:e,runResultId:t,steps:n}){let r=n.map(o=>({annotations:o.annotations.map(a=>({height:a.height,label:a.label,type:a.type,width:a.width,x:a.x,y:a.y})),assertions:o.assertions.map(a=>({description:a.description,detail:a.detail,status:a.status})),detail:o.detail,duration:o.duration,nodeType:o.nodeType,screenshotBase64:o.screenshotBase64,snapshotTimestamp:o.snapshotTimestamp,status:o.status,stepIndex:o.stepIndex,title:o.title,url:o.url,viewportHeight:o.viewportHeight,viewportWidth:o.viewportWidth}));await G({config:e,document:pp,variables:{runResultId:t,steps:r}})}var dp=Qn(`
96
96
  mutation StartRunCLI($runId: String!, $platform: String!, $agentProfileId: String) {
97
97
  startRun(runId: $runId, platform: $platform, agentProfileId: $agentProfileId) {
98
98
  id
99
99
  }
100
100
  }
101
- `),dp=Yn(`
101
+ `),pp=Qn(`
102
102
  mutation SubmitRunStepsCLI($runResultId: String!, $steps: [StepInput!]!) {
103
103
  submitRunSteps(runResultId: $runResultId, steps: $steps)
104
104
  }
105
- `),pp=Yn(`
105
+ `),up=Qn(`
106
106
  mutation CompleteRunCLI(
107
107
  $runResultId: String!
108
108
  $status: String!
@@ -125,14 +125,14 @@ ${n}`].join(`
125
125
  status
126
126
  }
127
127
  }
128
- `);var er=_t(`
128
+ `);var tr=_t(`
129
129
  fragment WorkflowRun on Workflow {
130
130
  id
131
131
  slug
132
132
  name
133
133
  spec
134
134
  }
135
- `),$a=_t(`
135
+ `),Da=_t(`
136
136
  fragment ProjectRun on Project {
137
137
  id
138
138
  baseUrl
@@ -151,13 +151,13 @@ ${n}`].join(`
151
151
  ...WorkflowRun
152
152
  }
153
153
  }
154
- `,[er]),up=_t(`
154
+ `,[tr]),fp=_t(`
155
155
  query ProjectRun($projectId: String!) {
156
156
  project(id: $projectId) {
157
157
  ...ProjectRun
158
158
  }
159
159
  }
160
- `,[$a]),fp=_t(`
160
+ `,[Da]),mp=_t(`
161
161
  query AgentProfileRun($id: String!) {
162
162
  agentProfile(id: $id) {
163
163
  id
@@ -167,8 +167,8 @@ ${n}`].join(`
167
167
  successCriteria
168
168
  }
169
169
  }
170
- `);async function tr({agentProfileDescription:e,agentProfileId:t,baseUrl:n,browser:r,config:o,headed:a,runId:s,webhookSecret:i,workflowId:l}){let c="unknown",d,f,u=!1;try{u=r==null,f=mp({externalBrowser:r,headed:a}),await In({baseUrl:n});let{project:m,workflow:y}=await ee({label:"Run context resolved",fn:()=>Sp({config:o,workflowId:l})});c=y.name;let h=bp(y.spec);w.info("Executing workflow: %s",y.name),d=await ee({label:"Streaming run started",fn:()=>Qn({agentProfileId:t,config:o,runId:s})}),await gp({agentProfileDescription:e,agentProfileId:t,baseUrl:n,browserPromise:f,config:o,headed:a,ownsBrowser:u,project:m,runId:s,specData:h,streaming:d,webhookSecret:i,workflow:y})}catch(m){throw await yp({browserPromise:f,error:m,ownsBrowser:u,runId:s,streaming:d,workflowName:c}),m}}function mp({externalBrowser:e,headed:t}){return e!=null?Promise.resolve(e):ee({label:"Browser launched",fn:()=>Ze({headed:t})})}async function yp({browserPromise:e,error:t,ownsBrowser:n,runId:r,streaming:o,workflowName:a}){let s=t instanceof Error?t.message:String(t),i=t instanceof Error?t.stack:void 0;await ra({error:s,runId:r,stack:i,workflowName:a}),o!=null&&await o.complete({statusOverride:"failed",steps:[],summary:s}).catch(()=>{}),n&&e!=null&&await(await e.catch(()=>{}))?.close()}async function gp({agentProfileDescription:e,agentProfileId:t,baseUrl:n,browserPromise:r,config:o,headed:a,ownsBrowser:s,project:i,runId:l,specData:c,streaming:d,webhookSecret:f,workflow:u}){let[m,y]=await Promise.all([ee({label:"Preconditions resolved",fn:()=>Kn({baseUrl:n,project:i,webhookSecret:f,workflowSlug:u.slug})}),r]);if(t!=null){s&&await y.close(),await hp({agentProfileDescription:e,agentProfileId:t,baseUrl:n,config:o,headed:a,preconditionResult:m,runId:l,specData:c,streaming:d,webhookSecret:f,workflow:u});return}await wp({baseUrl:n,browser:y,preconditionResult:m,runId:l,specData:c,streaming:d,webhookSecret:f})}async function hp({agentProfileDescription:e,agentProfileId:t,baseUrl:n,config:r,headed:o,preconditionResult:a,runId:s,specData:i,streaming:l,webhookSecret:c,workflow:d}){let f=e!=null&&e.length>0?e:await kp({config:r,profileId:t});await Cn({baseUrl:n,cookies:a.cookies,executedPreconditions:a.executed,extraVariables:a.data,headed:o,navigateTo:a.navigateTo,runId:s,serverUrl:r.ripploServerUrl,spec:i,streaming:l,systemPrompt:f,token:r.token,workflowContext:{description:d.name,expectedOutcome:d.name,name:d.name}}),await Ba({preconditionResult:a,webhookSecret:c})}async function wp({baseUrl:e,browser:t,preconditionResult:n,runId:r,specData:o,streaming:a,webhookSecret:s}){let i=await ee({label:"Spec executed",fn:()=>Gn({baseUrl:e,browser:t,cookies:n.cookies,extraVariables:n.data,navigateTo:n.navigateTo,onStep:a.enqueueStep,runId:r,spec:o})});await Ba({preconditionResult:n,webhookSecret:s}),await a.complete({statusOverride:void 0,steps:i,summary:void 0});let l=i.filter(d=>d.status==="passed").length,c=i.filter(d=>d.status==="failed").length;w.info("Run complete: %d passed, %d failed",l,c)}async function Ba({preconditionResult:e,webhookSecret:t}){e.apiUrl!=null&&await Hn({apiUrl:e.apiUrl,cookies:e.cookies,executed:e.executed,webhookSecret:t})}async function Sp({config:e,workflowId:t}){let n=await G({config:e,document:up,variables:{projectId:e.projectId}});if(n.project==null)throw new Error("Project not found");let o={...Zn($a,n.project),baseUrl:e.baseUrl,preconditionApiPath:e.preconditionApiPath},s=(o.workflows??[]).find(l=>Zn(er,l).id===t);if(s==null)throw new Error(`Workflow ${t} not found`);let i=Zn(er,s);return{project:o,workflow:i}}async function kp({config:e,profileId:t}){let n=await G({config:e,document:fp,variables:{id:t}});if(n.agentProfile==null)throw new Error(`Agent profile not found: ${t}`);let r=n.agentProfile,o=r.description;if(o==null||o.length===0)throw new Error(`Agent profile "${r.name}" has no description`);return w.info("Using agent profile: %s",r.name),Rn({description:o,output:r.output??void 0,successCriteria:r.successCriteria??void 0})}function bp(e){if(e==null)throw new Error("Workflow has no spec");let t=rt(e);if(!t.success){let n=t.errors.map(r=>`${r.path}: ${r.message}`).join("; ");throw new Error(`Invalid spec: ${n}`)}return t.data}function Fa({graphPath:e,outputPath:t}){let n=Rp(e),r=Np(n),o=Object.entries(r.preconditions).map(([l,c])=>({name:l,returns:c.returns}));if(o.length===0){w.warn("No preconditions found in graph. Nothing to generate.");return}let a=Tp(o),s=Ap({graphPath:n,outputPath:t}),i=De.dirname(s);st.existsSync(i)||st.mkdirSync(i,{recursive:!0}),st.writeFileSync(s,a),w.info("Generated %s with %d precondition(s)",s,o.length)}function Ap({graphPath:e,outputPath:t}){return t!=null?De.resolve(t):De.join(De.dirname(e),"..","generated","precondition-api.ts")}function Rp(e){if(e!=null)return De.resolve(e);let t=De.join(process.cwd(),".ripplo","graph.json");if(!st.existsSync(t))throw new Error("No .ripplo/graph.json found.");return t}function Np(e){let t=st.readFileSync(e,"utf8"),n=JSON.parse(t),r=typeof n=="object"&&n!=null&&"_meta"in n?Object.fromEntries(Object.entries(n).filter(([a])=>a!=="_meta")):n,o=Ee.safeParse(r);if(!o.success){let a=o.error.issues.map(s=>`${s.path.join(".")}: ${s.message}`).join("; ");throw new Error(`Invalid graph: ${a}`)}return o.data}function Tp(e){let t=e.map(r=>` "${r.name}"`).join(`,
171
- `),n=vp(e);return`// Generated by: ripplo generate-types
170
+ `);async function nr({agentProfileDescription:e,agentProfileId:t,baseUrl:n,browser:r,config:o,headed:a,runId:s,webhookSecret:i,workflowId:l}){let c="unknown",d,p,u=!1;try{u=r==null,p=yp({externalBrowser:r,headed:a}),await Un({baseUrl:n});let{project:m,workflow:y}=await ee({label:"Run context resolved",fn:()=>kp({config:o,workflowId:l})});c=y.name;let g=Ap(y.spec);w.info("Executing workflow: %s",y.name),d=await ee({label:"Streaming run started",fn:()=>Zn({agentProfileId:t,config:o,runId:s})}),await hp({agentProfileDescription:e,agentProfileId:t,baseUrl:n,browserPromise:p,config:o,headed:a,ownsBrowser:u,project:m,runId:s,specData:g,streaming:d,webhookSecret:i,workflow:y})}catch(m){throw await gp({browserPromise:p,error:m,ownsBrowser:u,runId:s,streaming:d,workflowName:c}),m}}function yp({externalBrowser:e,headed:t}){return e!=null?Promise.resolve(e):ee({label:"Browser launched",fn:()=>Ze({headed:t})})}async function gp({browserPromise:e,error:t,ownsBrowser:n,runId:r,streaming:o,workflowName:a}){let s=t instanceof Error?t.message:String(t),i=t instanceof Error?t.stack:void 0;await aa({error:s,runId:r,stack:i,workflowName:a}),o!=null&&await o.complete({statusOverride:"failed",steps:[],summary:s}).catch(()=>{}),n&&e!=null&&await(await e.catch(()=>{}))?.close()}async function hp({agentProfileDescription:e,agentProfileId:t,baseUrl:n,browserPromise:r,config:o,headed:a,ownsBrowser:s,project:i,runId:l,specData:c,streaming:d,webhookSecret:p,workflow:u}){let[m,y]=await Promise.all([ee({label:"Preconditions resolved",fn:()=>Yn({baseUrl:n,project:i,webhookSecret:p,workflowSlug:u.slug})}),r]);if(t!=null){s&&await y.close(),await wp({agentProfileDescription:e,agentProfileId:t,baseUrl:n,config:o,headed:a,preconditionResult:m,runId:l,specData:c,streaming:d,webhookSecret:p,workflow:u});return}await Sp({baseUrl:n,browser:y,preconditionResult:m,runId:l,specData:c,streaming:d,webhookSecret:p})}async function wp({agentProfileDescription:e,agentProfileId:t,baseUrl:n,config:r,headed:o,preconditionResult:a,runId:s,specData:i,streaming:l,webhookSecret:c,workflow:d}){let p=e!=null&&e.length>0?e:await bp({config:r,profileId:t});await xn({baseUrl:n,cookies:a.cookies,executedPreconditions:a.executed,extraVariables:a.data,headed:o,navigateTo:a.navigateTo,runId:s,serverUrl:r.ripploServerUrl,spec:i,streaming:l,systemPrompt:p,token:r.token,workflowContext:{description:d.name,expectedOutcome:d.name,name:d.name}}),await Fa({preconditionResult:a,webhookSecret:c})}async function Sp({baseUrl:e,browser:t,preconditionResult:n,runId:r,specData:o,streaming:a,webhookSecret:s}){let i=await ee({label:"Spec executed",fn:()=>Jn({baseUrl:e,browser:t,cookies:n.cookies,extraVariables:n.data,navigateTo:n.navigateTo,onStep:a.enqueueStep,runId:r,spec:o})});await Fa({preconditionResult:n,webhookSecret:s}),await a.complete({statusOverride:void 0,steps:i,summary:void 0});let l=i.filter(d=>d.status==="passed").length,c=i.filter(d=>d.status==="failed").length;w.info("Run complete: %d passed, %d failed",l,c)}async function Fa({preconditionResult:e,webhookSecret:t}){e.apiUrl!=null&&await Xn({apiUrl:e.apiUrl,cookies:e.cookies,executed:e.executed,webhookSecret:t})}async function kp({config:e,workflowId:t}){let n=await G({config:e,document:fp,variables:{projectId:e.projectId}});if(n.project==null)throw new Error("Project not found");let o={...er(Da,n.project),baseUrl:e.baseUrl,preconditionApiPath:e.preconditionApiPath},s=(o.workflows??[]).find(l=>er(tr,l).id===t);if(s==null)throw new Error(`Workflow ${t} not found`);let i=er(tr,s);return{project:o,workflow:i}}async function bp({config:e,profileId:t}){let n=await G({config:e,document:mp,variables:{id:t}});if(n.agentProfile==null)throw new Error(`Agent profile not found: ${t}`);let r=n.agentProfile,o=r.description;if(o==null||o.length===0)throw new Error(`Agent profile "${r.name}" has no description`);return w.info("Using agent profile: %s",r.name),Nn({description:o,output:r.output??void 0,successCriteria:r.successCriteria??void 0})}function Ap(e){if(e==null)throw new Error("Workflow has no spec");let t=rt(e);if(!t.success){let n=t.errors.map(r=>`${r.path}: ${r.message}`).join("; ");throw new Error(`Invalid spec: ${n}`)}return t.data}function Wa({graphPath:e,outputPath:t}){let n=Np(e),r=Tp(n),o=Object.entries(r.preconditions).map(([l,c])=>({name:l,returns:c.returns}));if(o.length===0){w.warn("No preconditions found in graph. Nothing to generate.");return}let a=vp(o),s=Rp({graphPath:n,outputPath:t}),i=De.dirname(s);st.existsSync(i)||st.mkdirSync(i,{recursive:!0}),st.writeFileSync(s,a),w.info("Generated %s with %d precondition(s)",s,o.length)}function Rp({graphPath:e,outputPath:t}){return t!=null?De.resolve(t):De.join(De.dirname(e),"..","generated","precondition-api.ts")}function Np(e){if(e!=null)return De.resolve(e);let t=De.join(process.cwd(),".ripplo","graph.json");if(!st.existsSync(t))throw new Error("No .ripplo/graph.json found.");return t}function Tp(e){let t=st.readFileSync(e,"utf8"),n=JSON.parse(t),r=typeof n=="object"&&n!=null&&"_meta"in n?Object.fromEntries(Object.entries(n).filter(([a])=>a!=="_meta")):n,o=Ee.safeParse(r);if(!o.success){let a=o.error.issues.map(s=>`${s.path.join(".")}: ${s.message}`).join("; ");throw new Error(`Invalid graph: ${a}`)}return o.data}function vp(e){let t=e.map(r=>` "${r.name}"`).join(`,
171
+ `),n=Cp(e);return`// Generated by: ripplo generate-types
172
172
  // Do not edit manually \u2014 regenerate when graph preconditions change.
173
173
 
174
174
  import { z } from "zod";
@@ -217,15 +217,15 @@ export const PreconditionTeardownResponseSchema = z.object({
217
217
  error: z.string().optional(),
218
218
  });
219
219
  export type PreconditionTeardownResponse = z.infer<typeof PreconditionTeardownResponseSchema>;
220
- `}function Da(e){return e.split(/[^a-zA-Z0-9]/).map(t=>{let n=t[0];return n==null?"":n.toUpperCase()+t.slice(1)}).join("")}function vp(e){let t=e.filter(o=>o.returns!=null&&o.returns.length>0);if(t.length===0)return"export type PreconditionDataMap = Record<PreconditionName, Record<string, string>>;";let n=t.map(o=>{let a=Da(o.name),s=o.returns.map(i=>` readonly ${i}: string;`).join(`
220
+ `}function Va(e){return e.split(/[^a-zA-Z0-9]/).map(t=>{let n=t[0];return n==null?"":n.toUpperCase()+t.slice(1)}).join("")}function Cp(e){let t=e.filter(o=>o.returns!=null&&o.returns.length>0);if(t.length===0)return"export type PreconditionDataMap = Record<PreconditionName, Record<string, string>>;";let n=t.map(o=>{let a=Va(o.name),s=o.returns.map(i=>` readonly ${i}: string;`).join(`
221
221
  `);return`export interface ${a}Data {
222
222
  ${s}
223
- }`}),r=e.map(o=>{let s=o.returns!=null&&o.returns.length>0?`${Da(o.name)}Data`:"Record<string, never>";return` readonly "${o.name}": ${s};`});return[...n,"",`export interface PreconditionDataMap {
223
+ }`}),r=e.map(o=>{let s=o.returns!=null&&o.returns.length>0?`${Va(o.name)}Data`:"Record<string, never>";return` readonly "${o.name}": ${s};`});return[...n,"",`export interface PreconditionDataMap {
224
224
  ${r.join(`
225
225
  `)}
226
226
  }`].join(`
227
227
 
228
- `)}import li from"fs";import xr from"path";import Om from"react";import{render as Im}from"ink";import{graphql as Um}from"gql.tada";import{useCallback as Lm,useState as Pm}from"react";import{Box as oi,Text as Cr}from"ink";import{Provider as ai}from"urql";import{Client as Ip,fetchExchange as Up,subscriptionExchange as jp}from"urql";import{cacheExchange as _p}from"@urql/exchange-graphcache";import{createClient as $p}from"graphql-sse";import{initGraphQLTada as Cp}from"gql.tada";import{readFragment as gb}from"gql.tada";var Va=Cp();var nr={__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:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"stateGraph",type:{kind:"OBJECT",name:"StateGraph",ofType:null},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:"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:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},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:"Edge",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"graph",type:{kind:"OBJECT",name:"StateGraph",ofType:null},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:"sourceState",type:{kind:"OBJECT",name:"StateNode",ofType:null},args:[]},{name:"targetState",type:{kind:"OBJECT",name:"StateNode",ofType:null},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"workflow",type:{kind:"OBJECT",name:"Workflow",ofType:null},args:[]},{name:"workflowName",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"workflowSlug",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:"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:"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:"baseUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{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:"removeGitHubInstallation",type:{kind:"OBJECT",name:"GitHubInstallation",ofType:null},args:[{name:"id",type:{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:"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:"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:"graphSpec",type:{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:"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:"description",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:"Project",fields:[{name:"agentProfiles",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"AgentProfile",ofType:null}}},args:[]},{name:"baseUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},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:"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:"preconditionApiPath",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{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:"stateGraph",type:{kind:"OBJECT",name:"StateGraph",ofType:null},args:[{name:"branch",type:{kind:"SCALAR",name:"Any"}}]},{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:"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:"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:"stateGraph",type:{kind:"OBJECT",name:"StateGraph",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"stateNode",type:{kind:"OBJECT",name:"StateNode",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"stateNodes",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"StateNode",ofType:null}}},args:[{name:"graphId",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:"RunResultUpdated"},{kind:"OBJECT",name:"RunStatusChanged"},{kind:"OBJECT",name:"RunTraceEntryAdded"}]},{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:[]}],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:"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:"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:"StateGraph",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"edges",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Edge",ofType:null}}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"localOnlyWorkflows",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Workflow",ofType:null}}}},args:[]},{name:"preconditions",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"project",type:{kind:"OBJECT",name:"Project",ofType:null},args:[]},{name:"states",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"StateNode",ofType:null}}},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"version",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"StateNode",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"graph",type:{kind:"OBJECT",name:"StateGraph",ofType:null},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"incoming",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Edge",ofType:null}}},args:[]},{name:"outgoing",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Edge",ofType:null}}},args:[]},{name:"preconditions",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}},args:[]},{name:"routePattern",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"stableId",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:"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:"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:[]}],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:"screenshotUrl",type:{kind:"NON_NULL",ofType:{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:"snapshots",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"BranchSnapshot",ofType:null}}},args:[]},{name:"stateGraph",type:{kind:"OBJECT",name:"StateGraph",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:"description",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:"project",type:{kind:"OBJECT",name:"Project",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:"SCALAR",name:"Any"}],directives:[]}};var xp={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,DevWorkflowDeleteRequestedEvent:()=>null,DevWorkflowDuplicateRequestedEvent:()=>null,Edge:e=>e.id??null,GitHubInstallation:e=>e.id??null,GithubRepository:()=>null,Invoice:e=>e.id??null,LinkPaymentMethod:()=>null,Organization:e=>e.id??null,OrganizationLimitStatus:()=>null,OrganizationUsage:()=>null,OtherPaymentMethod:()=>null,Plan:()=>null,PlanLimits:()=>null,Project:e=>e.id??null,ProjectRunStatusEvent:()=>null,Run:e=>e.id??null,RunRequestedEvent:()=>null,RunResult:e=>e.id??null,RunResultUpdated:()=>null,RunStatusChanged:()=>null,RunTraceEntryAdded:()=>null,ScreenAnnotation:e=>e.id??null,SideEffect:e=>e.id??null,StateGraph:e=>e.id??null,StateNode: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};function L(e,t){e.inspectFields("Query").filter(n=>n.fieldName===t).forEach(n=>{e.invalidate("Query",n.fieldName,n.arguments)})}function te(e,t,n){e.invalidate({__typename:t,id:n})}function rr({cache:e,childId:t,childTypeName:n,fieldName:r,parentId:o,parentTypeName:a}){let s=e.keyOfEntity({__typename:a,id:o});if(s==null)return!1;let i=e.keyOfEntity({__typename:n,id:t});if(i==null)return!1;let l=e.resolve(s,r);if(!Array.isArray(l))return!1;let c=l.map(d=>typeof d=="string"?d:null);return c.includes(i)||e.link(s,r,void 0,[...c,i]),!0}function Lp(e,t){let n=t.traceEntry?.id,r=t.runResultId;if(n==null||r==null)return;rr({cache:e,childId:n,childTypeName:"TraceEntry",fieldName:"traceEntries",parentId:r,parentTypeName:"RunResult"})||te(e,"RunResult",r)}var Wa=Va(`
228
+ `)}import en from"fs";import Pr from"path";import Um from"react";import{render as jm}from"ink";import{graphql as _m}from"gql.tada";import{useCallback as Em,useState as Om}from"react";import{Box as si,Text as Lr}from"ink";import{Provider as ii}from"urql";import{Client as Up,fetchExchange as jp,subscriptionExchange as _p}from"urql";import{cacheExchange as $p}from"@urql/exchange-graphcache";import{createClient as Bp}from"graphql-sse";import{initGraphQLTada as xp}from"gql.tada";import{readFragment as wb}from"gql.tada";var qa=xp();var rr={__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:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"stateGraph",type:{kind:"OBJECT",name:"StateGraph",ofType:null},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:"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:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},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:"Edge",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"graph",type:{kind:"OBJECT",name:"StateGraph",ofType:null},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:"sourceState",type:{kind:"OBJECT",name:"StateNode",ofType:null},args:[]},{name:"targetState",type:{kind:"OBJECT",name:"StateNode",ofType:null},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"workflow",type:{kind:"OBJECT",name:"Workflow",ofType:null},args:[]},{name:"workflowName",type:{kind:"SCALAR",name:"Any"},args:[]},{name:"workflowSlug",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:"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:"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:"baseUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}},{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:"removeGitHubInstallation",type:{kind:"OBJECT",name:"GitHubInstallation",ofType:null},args:[{name:"id",type:{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:"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:"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:"graphSpec",type:{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:"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:"description",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:"Project",fields:[{name:"agentProfiles",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"AgentProfile",ofType:null}}},args:[]},{name:"baseUrl",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},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:"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:"preconditionApiPath",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{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:"stateGraph",type:{kind:"OBJECT",name:"StateGraph",ofType:null},args:[{name:"branch",type:{kind:"SCALAR",name:"Any"}}]},{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:"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:"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:"stateGraph",type:{kind:"OBJECT",name:"StateGraph",ofType:null},args:[{name:"projectId",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"stateNode",type:{kind:"OBJECT",name:"StateNode",ofType:null},args:[{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}]},{name:"stateNodes",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"StateNode",ofType:null}}},args:[{name:"graphId",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:"RunResultUpdated"},{kind:"OBJECT",name:"RunStatusChanged"},{kind:"OBJECT",name:"RunTraceEntryAdded"}]},{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:[]}],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:"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:"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:"StateGraph",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"edges",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Edge",ofType:null}}},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"localOnlyWorkflows",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Workflow",ofType:null}}}},args:[]},{name:"preconditions",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"project",type:{kind:"OBJECT",name:"Project",ofType:null},args:[]},{name:"states",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"StateNode",ofType:null}}},args:[]},{name:"updatedAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"version",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]}],interfaces:[]},{kind:"OBJECT",name:"StateNode",fields:[{name:"createdAt",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"graph",type:{kind:"OBJECT",name:"StateGraph",ofType:null},args:[]},{name:"id",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"incoming",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Edge",ofType:null}}},args:[]},{name:"outgoing",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"Edge",ofType:null}}},args:[]},{name:"preconditions",type:{kind:"NON_NULL",ofType:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}}}},args:[]},{name:"routePattern",type:{kind:"NON_NULL",ofType:{kind:"SCALAR",name:"Any"}},args:[]},{name:"stableId",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:"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:"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:[]}],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:"screenshotUrl",type:{kind:"NON_NULL",ofType:{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:"snapshots",type:{kind:"LIST",ofType:{kind:"NON_NULL",ofType:{kind:"OBJECT",name:"BranchSnapshot",ofType:null}}},args:[]},{name:"stateGraph",type:{kind:"OBJECT",name:"StateGraph",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:"description",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:"project",type:{kind:"OBJECT",name:"Project",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:"SCALAR",name:"Any"}],directives:[]}};var Lp={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,DevWorkflowDeleteRequestedEvent:()=>null,DevWorkflowDuplicateRequestedEvent:()=>null,Edge:e=>e.id??null,GitHubInstallation:e=>e.id??null,GithubRepository:()=>null,Invoice:e=>e.id??null,LinkPaymentMethod:()=>null,Organization:e=>e.id??null,OrganizationLimitStatus:()=>null,OrganizationUsage:()=>null,OtherPaymentMethod:()=>null,Plan:()=>null,PlanLimits:()=>null,Project:e=>e.id??null,ProjectRunStatusEvent:()=>null,Run:e=>e.id??null,RunRequestedEvent:()=>null,RunResult:e=>e.id??null,RunResultUpdated:()=>null,RunStatusChanged:()=>null,RunTraceEntryAdded:()=>null,ScreenAnnotation:e=>e.id??null,SideEffect:e=>e.id??null,StateGraph:e=>e.id??null,StateNode: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};function P(e,t){e.inspectFields("Query").filter(n=>n.fieldName===t).forEach(n=>{e.invalidate("Query",n.fieldName,n.arguments)})}function te(e,t,n){e.invalidate({__typename:t,id:n})}function or({cache:e,childId:t,childTypeName:n,fieldName:r,parentId:o,parentTypeName:a}){let s=e.keyOfEntity({__typename:a,id:o});if(s==null)return!1;let i=e.keyOfEntity({__typename:n,id:t});if(i==null)return!1;let l=e.resolve(s,r);if(!Array.isArray(l))return!1;let c=l.map(d=>typeof d=="string"?d:null);return c.includes(i)||e.link(s,r,void 0,[...c,i]),!0}function Pp(e,t){let n=t.traceEntry?.id,r=t.runResultId;if(n==null||r==null)return;or({cache:e,childId:n,childTypeName:"TraceEntry",fieldName:"traceEntries",parentId:r,parentTypeName:"RunResult"})||te(e,"RunResult",r)}var Ma=qa(`
229
229
  fragment RunCache on Run {
230
230
  id
231
231
  status
@@ -235,7 +235,7 @@ ${r.join(`
235
235
  id
236
236
  }
237
237
  }
238
- `);function Pp(e,t){t.runId!=null&&e.writeFragment(Wa,{agentProfile:t.agentProfileId==null?null:{id:t.agentProfileId},completedAt:null,createdAt:t.createdAt??new Date().toISOString(),id:t.runId,status:t.status??"pending"})}function Ep(e,t){let n=e.runId!=null&&t.resolve({__typename:"Run",id:e.runId},"id")==null;Pp(t,e),n&&(L(t,"run"),L(t,"projectRuns")),e.workflowId!=null&&e.runId!=null&&rr({cache:t,childId:e.runId,childTypeName:"Run",fieldName:"latestRuns",parentId:e.workflowId,parentTypeName:"Workflow"})}function Op(){return{cancelAllPendingRuns(e,t,n){L(n,"workflows"),L(n,"projectRuns")},cancelRun(e,t,n){let r=e.cancelRun?.id;r!=null&&te(n,"Run",r)},cloneAgentTemplate(e,t,n){L(n,"agentProfiles")},createAgentProfile(e,t,n){L(n,"agentProfiles")},createRun(e,t,n){L(n,"run"),L(n,"runs"),L(n,"projectRuns");let r=e.createRun?.id;r!=null&&(n.writeFragment(Wa,{agentProfile:t.agentProfileId==null?null:{id:t.agentProfileId},completedAt:null,createdAt:new Date().toISOString(),id:r,status:"pending"}),rr({cache:n,childId:r,childTypeName:"Run",fieldName:"latestRuns",parentId:t.workflowId,parentTypeName:"Workflow"}))},deleteAgentProfile(e,t,n){let r=e.deleteAgentProfile?.id;r!=null&&te(n,"AgentProfile",r)},deleteDevWorkflow(e,t,n){let r=e.deleteDevWorkflow?.id;r!=null&&te(n,"Workflow",r),L(n,"workflows"),L(n,"stateGraph")},deleteProject(e,t,n){let r=e.deleteProject?.id;r!=null&&te(n,"Project",r),L(n,"projects")},duplicateDevWorkflow(e,t,n){L(n,"workflows")},endDevSession(e,t,n){let r=e.endDevSession?.id;r!=null&&te(n,"DevSession",r)},runAllWorkflows(e,t,n){L(n,"runs"),L(n,"projectRuns")},setOverageCap(e,t,n){L(n,"organizationUsage")},updateProject(e,t,n){let r=e.updateProject?.id;r!=null&&te(n,"Project",r)},updateUsername(e,t,n){let r=e.updateUsername?.id;r!=null&&te(n,"User",r),L(n,"currentUser")}}}function or(){return{keys:xp,schema:nr,updates:{Mutation:Op(),Subscription:{devSessionChanged(e,t,n){let r=e.devSessionChanged;r?.projectId!=null&&te(n,"Project",r.projectId),r?.active===!1&&(L(n,"stateGraph"),L(n,"workflows"),L(n,"workflow"),L(n,"runs"),L(n,"run"),L(n,"projectRuns"))},devSessionSynced(e,t,n){L(n,"stateGraph"),L(n,"workflow"),L(n,"workflows")},projectRunStatusChanged(e,t,n){let r=e.projectRunStatusChanged;r!=null&&Ep(r,n)},runProgress(e,t,n){let r=e.runProgress;r?.__typename==="RunTraceEntryAdded"&&Lp(n,r)}}}}}function qa({config:e}){let t=`${e.ripploServerUrl}/graphql`,n={Authorization:`Bearer ${e.token}`},r=$p({headers:n,retryAttempts:1/0,url:t});return new Ip({exchanges:[_p(or()),jp({forwardSubscription:o=>({subscribe:a=>o.query==null?{unsubscribe:()=>{}}:{unsubscribe:r.subscribe({query:o.query,variables:o.variables},a)}})}),Up],fetchOptions:{headers:n},requestPolicy:"cache-and-network",url:t})}import{Box as Ma,Text as U,useInput as Bp}from"ink";import{jsx as F,jsxs as ie}from"react/jsx-runtime";function Ga({deviceCodeInfo:e,error:t,loginStarted:n,startLogin:r}){return Bp((o,a)=>{a.return&&!n&&r()}),t!=null?ie(Ma,{flexDirection:"column",gap:1,children:[ie(U,{children:[F(U,{color:"red",children:" \u2717 "}),F(U,{children:t})]}),ie(U,{children:[F(U,{color:"cyan",children:" \u2192 "}),F(U,{children:"Press "}),F(U,{bold:!0,children:"Enter"}),F(U,{children:" to try again"})]})]}):e!=null?ie(Ma,{flexDirection:"column",gap:1,paddingLeft:2,children:[ie(U,{children:[F(U,{color:"yellow",children:"* "}),F(U,{children:"Your code: "}),F(U,{bold:!0,color:"white",children:e.userCode})]}),ie(U,{children:[F(U,{color:"yellow",children:"* "}),F(U,{children:"Waiting for browser authorization..."})]}),ie(U,{dimColor:!0,children:[" ",e.verificationUrl]})]}):n?ie(U,{children:[F(U,{color:"yellow",children:" * "}),F(U,{children:"Opening browser..."})]}):ie(U,{children:[F(U,{color:"cyan",children:" \u2192 "}),F(U,{children:"Press "}),F(U,{bold:!0,children:"Enter"}),F(U,{children:" to open browser for authentication"})]})}import{Box as Ka,Text as le}from"ink";import{useEffect as Gp,useMemo as Jp,useRef as zp}from"react";import{Box as Ha,Text as Re}from"ink";import{useQuery as Hp}from"urql";import{graphql as Xp}from"gql.tada";import{useState as Dp}from"react";import{Box as Fp,Text as $t,useInput as Vp}from"ink";import{jsx as Bt,jsxs as Wp}from"react/jsx-runtime";function Ja({items:e,onSelect:t}){let[n,r]=Dp(0);return Vp((o,a)=>{if(a.upArrow&&r(s=>Math.max(0,s-1)),a.downArrow&&r(s=>Math.min(e.length-1,s+1)),a.return){let s=e[n];s!=null&&t(s.value)}}),Bt(Fp,{flexDirection:"column",children:e.map((o,a)=>Wp($t,{children:[a===n?Bt($t,{color:"cyan",children:"> "}):Bt($t,{children:" "}),Bt($t,{bold:a===n,children:o.label})]},o.value))})}import{Box as qp,Text as ye,useInput as Mp}from"ink";import{jsx as Fe,jsxs as ar}from"react/jsx-runtime";function za({reexecute:e,serverUrl:t}){let n=`${t}/connect`;return Mp((r,o)=>{o.return&&e()}),ar(qp,{flexDirection:"column",children:[ar(ye,{children:[Fe(ye,{color:"cyan",children:" \u2192 "}),Fe(ye,{children:"No projects found. Create one at: "}),Fe(ye,{bold:!0,color:"cyan",children:n})]}),ar(ye,{children:[" ",Fe(ye,{dimColor:!0,children:"Press "}),Fe(ye,{bold:!0,children:"Enter"}),Fe(ye,{dimColor:!0,children:" to refresh after creating a project"})]})]})}import{jsx as Ne,jsxs as Dt}from"react/jsx-runtime";var Kp=Xp(`
238
+ `);function Ep(e,t){t.runId!=null&&e.writeFragment(Ma,{agentProfile:t.agentProfileId==null?null:{id:t.agentProfileId},completedAt:null,createdAt:t.createdAt??new Date().toISOString(),id:t.runId,status:t.status??"pending"})}function Op(e,t){let n=e.runId!=null&&t.resolve({__typename:"Run",id:e.runId},"id")==null;Ep(t,e),n&&(P(t,"run"),P(t,"projectRuns")),e.workflowId!=null&&e.runId!=null&&or({cache:t,childId:e.runId,childTypeName:"Run",fieldName:"latestRuns",parentId:e.workflowId,parentTypeName:"Workflow"})}function Ip(){return{cancelAllPendingRuns(e,t,n){P(n,"workflows"),P(n,"projectRuns")},cancelRun(e,t,n){let r=e.cancelRun?.id;r!=null&&te(n,"Run",r)},cloneAgentTemplate(e,t,n){P(n,"agentProfiles")},createAgentProfile(e,t,n){P(n,"agentProfiles")},createRun(e,t,n){P(n,"run"),P(n,"runs"),P(n,"projectRuns");let r=e.createRun?.id;r!=null&&(n.writeFragment(Ma,{agentProfile:t.agentProfileId==null?null:{id:t.agentProfileId},completedAt:null,createdAt:new Date().toISOString(),id:r,status:"pending"}),or({cache:n,childId:r,childTypeName:"Run",fieldName:"latestRuns",parentId:t.workflowId,parentTypeName:"Workflow"}))},deleteAgentProfile(e,t,n){let r=e.deleteAgentProfile?.id;r!=null&&te(n,"AgentProfile",r)},deleteDevWorkflow(e,t,n){let r=e.deleteDevWorkflow?.id;r!=null&&te(n,"Workflow",r),P(n,"workflows"),P(n,"stateGraph")},deleteProject(e,t,n){let r=e.deleteProject?.id;r!=null&&te(n,"Project",r),P(n,"projects")},duplicateDevWorkflow(e,t,n){P(n,"workflows")},endDevSession(e,t,n){let r=e.endDevSession?.id;r!=null&&te(n,"DevSession",r)},runAllWorkflows(e,t,n){P(n,"runs"),P(n,"projectRuns")},setOverageCap(e,t,n){P(n,"organizationUsage")},updateProject(e,t,n){let r=e.updateProject?.id;r!=null&&te(n,"Project",r)},updateUsername(e,t,n){let r=e.updateUsername?.id;r!=null&&te(n,"User",r),P(n,"currentUser")}}}function ar(){return{keys:Lp,schema:rr,updates:{Mutation:Ip(),Subscription:{devSessionChanged(e,t,n){let r=e.devSessionChanged;r?.projectId!=null&&te(n,"Project",r.projectId),r?.active===!1&&(P(n,"stateGraph"),P(n,"workflows"),P(n,"workflow"),P(n,"runs"),P(n,"run"),P(n,"projectRuns"))},devSessionSynced(e,t,n){P(n,"stateGraph"),P(n,"workflow"),P(n,"workflows")},projectRunStatusChanged(e,t,n){let r=e.projectRunStatusChanged;r!=null&&Op(r,n)},runProgress(e,t,n){let r=e.runProgress;r?.__typename==="RunTraceEntryAdded"&&Pp(n,r)}}}}}function Ga({config:e}){let t=`${e.ripploServerUrl}/graphql`,n={Authorization:`Bearer ${e.token}`},r=Bp({headers:n,retryAttempts:1/0,url:t});return new Up({exchanges:[$p(ar()),_p({forwardSubscription:o=>({subscribe:a=>o.query==null?{unsubscribe:()=>{}}:{unsubscribe:r.subscribe({query:o.query,variables:o.variables},a)}})}),jp],fetchOptions:{headers:n},requestPolicy:"cache-and-network",url:t})}import{Box as Ja,Text as U,useInput as Dp}from"ink";import{jsx as F,jsxs as ie}from"react/jsx-runtime";function za({deviceCodeInfo:e,error:t,loginStarted:n,startLogin:r}){return Dp((o,a)=>{a.return&&!n&&r()}),t!=null?ie(Ja,{flexDirection:"column",gap:1,children:[ie(U,{children:[F(U,{color:"red",children:" \u2717 "}),F(U,{children:t})]}),ie(U,{children:[F(U,{color:"cyan",children:" \u2192 "}),F(U,{children:"Press "}),F(U,{bold:!0,children:"Enter"}),F(U,{children:" to try again"})]})]}):e!=null?ie(Ja,{flexDirection:"column",gap:1,paddingLeft:2,children:[ie(U,{children:[F(U,{color:"yellow",children:"* "}),F(U,{children:"Your code: "}),F(U,{bold:!0,color:"white",children:e.userCode})]}),ie(U,{children:[F(U,{color:"yellow",children:"* "}),F(U,{children:"Waiting for browser authorization..."})]}),ie(U,{dimColor:!0,children:[" ",e.verificationUrl]})]}):n?ie(U,{children:[F(U,{color:"yellow",children:" * "}),F(U,{children:"Opening browser..."})]}):ie(U,{children:[F(U,{color:"cyan",children:" \u2192 "}),F(U,{children:"Press "}),F(U,{bold:!0,children:"Enter"}),F(U,{children:" to open browser for authentication"})]})}import{Box as Qa,Text as le}from"ink";import{useEffect as Jp,useMemo as zp,useRef as Hp}from"react";import{Box as Ka,Text as Re}from"ink";import{useQuery as Xp}from"urql";import{graphql as Kp}from"gql.tada";import{useState as Fp}from"react";import{Box as Vp,Text as $t,useInput as Wp}from"ink";import{jsx as Bt,jsxs as qp}from"react/jsx-runtime";function Ha({items:e,onSelect:t}){let[n,r]=Fp(0);return Wp((o,a)=>{if(a.upArrow&&r(s=>Math.max(0,s-1)),a.downArrow&&r(s=>Math.min(e.length-1,s+1)),a.return){let s=e[n];s!=null&&t(s.value)}}),Bt(Vp,{flexDirection:"column",children:e.map((o,a)=>qp($t,{children:[a===n?Bt($t,{color:"cyan",children:"> "}):Bt($t,{children:" "}),Bt($t,{bold:a===n,children:o.label})]},o.value))})}import{Box as Mp,Text as ye,useInput as Gp}from"ink";import{jsx as Fe,jsxs as sr}from"react/jsx-runtime";function Xa({reexecute:e,serverUrl:t}){let n=`${t}/connect`;return Gp((r,o)=>{o.return&&e()}),sr(Mp,{flexDirection:"column",children:[sr(ye,{children:[Fe(ye,{color:"cyan",children:" \u2192 "}),Fe(ye,{children:"No projects found. Create one at: "}),Fe(ye,{bold:!0,color:"cyan",children:n})]}),sr(ye,{children:[" ",Fe(ye,{dimColor:!0,children:"Press "}),Fe(ye,{bold:!0,children:"Enter"}),Fe(ye,{dimColor:!0,children:" to refresh after creating a project"})]})]})}import{jsx as Ne,jsxs as Dt}from"react/jsx-runtime";var Yp=Kp(`
239
239
  query SetupProjectSelect {
240
240
  projects {
241
241
  id
@@ -247,7 +247,7 @@ ${r.join(`
247
247
  }
248
248
  }
249
249
  }
250
- `);function Xa({selectProject:e,serverUrl:t}){let[n,r]=Hp({query:Kp}),o=zp(!1),a=Jp(()=>n.data?.projects??[],[n.data?.projects]);if(Gp(()=>{let l=a[0];a.length===1&&l!=null&&(l.workflows?.length??0)===0&&!o.current&&(o.current=!0,e({baseUrl:l.baseUrl,cloudBaseUrl:l.cloudBaseUrl,id:l.id,name:l.name}))},[a,e]),n.fetching)return Dt(Re,{children:[Ne(Re,{color:"yellow",children:" * "}),Ne(Re,{children:"Loading projects..."})]});if(n.error!=null)return Dt(Re,{color:"red",children:[" \u2717 ","Failed to fetch projects: ",n.error.message]});if(a.length===0)return Ne(za,{reexecute:r,serverUrl:t});let s=a.map(l=>({label:l.name,value:l.id}));function i(l){let c=a.find(d=>d.id===l);c!=null&&e({baseUrl:c.baseUrl,cloudBaseUrl:c.cloudBaseUrl,id:c.id,name:c.name})}return Dt(Ha,{flexDirection:"column",children:[Dt(Re,{children:[Ne(Re,{color:"cyan",children:" \u2192 "}),Ne(Re,{children:"Select a project:"})]}),Ne(Ha,{marginLeft:4,marginTop:1,children:Ne(Ja,{items:s,onSelect:i})})]})}import{jsx as Te,jsxs as it}from"react/jsx-runtime";function Ya({config:e,error:t,selectProject:n,stage:r}){return it(Ka,{flexDirection:"column",padding:1,children:[it(le,{bold:!0,children:[" ","ripplo setup"]}),Te(le,{children:""}),it(le,{children:[Te(le,{color:"green",children:" \u2713 "}),Te(le,{children:"Authenticated"})]}),r==="scaffolding"?it(le,{children:[Te(le,{color:"yellow",children:" * "}),Te(le,{children:"Setting up local environment..."})]}):Te(Xa,{selectProject:n,serverUrl:e.ripploServerUrl}),t==null?null:Te(Ka,{marginTop:1,children:it(le,{color:"red",children:[" ","Error: ",t]})})]})}import{useEffect as Pf,useState as Ef}from"react";import{Box as Je,useApp as Of,useInput as If}from"ink";import{useQuery as Uf,useSubscription as jf}from"urql";import{graphql as $s}from"gql.tada";import{useEffect as Yp,useState as Qp}from"react";function Ve(){let[e,t]=Qp(Qa);return Yp(()=>{function n(){t(Qa())}return process.stdout.on("resize",n),()=>{process.stdout.off("resize",n)}},[]),e}function Qa(){return{height:process.stdout.rows,width:process.stdout.columns}}import{useEffect as iu,useRef as lu,useState as cu}from"react";import ru from"crypto";import ge from"fs";import ct from"path";import{watch as ou}from"chokidar";import{graphql as au}from"gql.tada";import Zp from"fs";import eu from"path";import{z as V}from"zod";var sr=V.object({edges:V.array(V.object({from:V.string(),to:V.string(),workflow:V.string()})),preconditions:V.record(V.string(),V.unknown()).optional(),resetPrecondition:V.string().optional(),states:V.record(V.string(),V.object({preconditions:V.array(V.string()),route:V.string()})),version:V.literal(3)});function Za(e){return eu.join(e,".ripplo","graph.json")}function Ft(e){let t=Zp.readFileSync(e,"utf8"),n=JSON.parse(t);return sr.parse(n)}function Vt(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}import tu from"fs";import nu from"path";import{z as We}from"zod";var Wt=We.object({additionalChecks:We.array(We.string()).default([]),description:We.string(),expectedOutcome:We.string(),name:We.string(),spec:$e});function lt(e){return nu.join(e,".ripplo","workflows")}function qe(e){let t=tu.readFileSync(e,"utf8"),n=JSON.parse(t);return Wt.parse(n)}var su=au(`
250
+ `);function Ya({selectProject:e,serverUrl:t}){let[n,r]=Xp({query:Yp}),o=Hp(!1),a=zp(()=>n.data?.projects??[],[n.data?.projects]);if(Jp(()=>{let l=a[0];a.length===1&&l!=null&&(l.workflows?.length??0)===0&&!o.current&&(o.current=!0,e({baseUrl:l.baseUrl,cloudBaseUrl:l.cloudBaseUrl,id:l.id,name:l.name}))},[a,e]),n.fetching)return Dt(Re,{children:[Ne(Re,{color:"yellow",children:" * "}),Ne(Re,{children:"Loading projects..."})]});if(n.error!=null)return Dt(Re,{color:"red",children:[" \u2717 ","Failed to fetch projects: ",n.error.message]});if(a.length===0)return Ne(Xa,{reexecute:r,serverUrl:t});let s=a.map(l=>({label:l.name,value:l.id}));function i(l){let c=a.find(d=>d.id===l);c!=null&&e({baseUrl:c.baseUrl,cloudBaseUrl:c.cloudBaseUrl,id:c.id,name:c.name})}return Dt(Ka,{flexDirection:"column",children:[Dt(Re,{children:[Ne(Re,{color:"cyan",children:" \u2192 "}),Ne(Re,{children:"Select a project:"})]}),Ne(Ka,{marginLeft:4,marginTop:1,children:Ne(Ha,{items:s,onSelect:i})})]})}import{jsx as Te,jsxs as it}from"react/jsx-runtime";function Za({config:e,error:t,selectProject:n,stage:r}){return it(Qa,{flexDirection:"column",padding:1,children:[it(le,{bold:!0,children:[" ","ripplo setup"]}),Te(le,{children:""}),it(le,{children:[Te(le,{color:"green",children:" \u2713 "}),Te(le,{children:"Authenticated"})]}),r==="scaffolding"?it(le,{children:[Te(le,{color:"yellow",children:" * "}),Te(le,{children:"Setting up local environment..."})]}):Te(Ya,{selectProject:n,serverUrl:e.ripploServerUrl}),t==null?null:Te(Qa,{marginTop:1,children:it(le,{color:"red",children:[" ","Error: ",t]})})]})}import{useEffect as Of,useState as If}from"react";import{Box as Je,useApp as Uf,useInput as jf}from"ink";import{useQuery as _f,useSubscription as $f}from"urql";import{graphql as Ds}from"gql.tada";import{useEffect as Qp,useState as Zp}from"react";function Ve(){let[e,t]=Zp(es);return Qp(()=>{function n(){t(es())}return process.stdout.on("resize",n),()=>{process.stdout.off("resize",n)}},[]),e}function es(){return{height:process.stdout.rows,width:process.stdout.columns}}import{useEffect as lu,useRef as cu,useState as du}from"react";import ou from"crypto";import ge from"fs";import ct from"path";import{watch as au}from"chokidar";import{graphql as su}from"gql.tada";import eu from"fs";import tu from"path";import{z as V}from"zod";var ir=V.object({edges:V.array(V.object({from:V.string(),to:V.string(),workflow:V.string()})),preconditions:V.record(V.string(),V.unknown()).optional(),resetPrecondition:V.string().optional(),states:V.record(V.string(),V.object({preconditions:V.array(V.string()),route:V.string()})),version:V.literal(3)});function ts(e){return tu.join(e,".ripplo","graph.json")}function Ft(e){let t=eu.readFileSync(e,"utf8"),n=JSON.parse(t);return ir.parse(n)}function Vt(e){return{edges:e.edges,preconditions:e.preconditions??{},resetPrecondition:e.resetPrecondition,states:e.states,version:e.version}}import nu from"fs";import ru from"path";import{z as We}from"zod";var Wt=We.object({additionalChecks:We.array(We.string()).default([]),description:We.string(),expectedOutcome:We.string(),name:We.string(),spec:$e});function lt(e){return ru.join(e,".ripplo","workflows")}function qe(e){let t=nu.readFileSync(e,"utf8"),n=JSON.parse(t);return Wt.parse(n)}var iu=su(`
251
251
  mutation SyncDevSession(
252
252
  $projectId: String!
253
253
  $graphSpec: String!
@@ -257,7 +257,7 @@ ${r.join(`
257
257
  id
258
258
  }
259
259
  }
260
- `);async function es(e){let t=await os(e);return w.info("Synced %d workflow(s) + graph to dev session",as(e.cwd)),t}function ts({config:e,cwd:t,lastHash:n}){let r=ct.join(t,".ripplo"),o=n,a,s=ou(r,{depth:2,ignoreInitial:!0,interval:1e3,persistent:!0,usePolling:!0});s.on("all",(l,c)=>{c.endsWith(".json")&&(a!=null&&clearTimeout(a),a=setTimeout(()=>{i({config:e,cwd:t})},500))});async function i(l){try{let c=ns(l.cwd),d=rs(c);if(d===o)return;o=d,await os(l),w.info("Dev session synced (%d workflow(s))",as(l.cwd))}catch(c){let d=c instanceof Error?c.message:"Unknown error";w.error("Sync failed: %s",d)}}return function(){a!=null&&clearTimeout(a),s.close()}}function ns(e){let t=Za(e),n=Ft(t),r=JSON.stringify(Vt(n)),o=lt(e),s=(ge.existsSync(o)?ge.readdirSync(o).filter(i=>i.endsWith(".json")):[]).map(i=>{let l=ct.join(o,i),c=qe(l),d=i.replace(/\.json$/,"");return{description:c.description,expectedOutcome:c.expectedOutcome,name:c.name,slug:d,spec:JSON.stringify(c.spec)}});return{graphSpec:r,workflows:s}}function rs(e){return ru.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function os({config:e,cwd:t}){let n=ns(t),r=rs(n),o=await G({config:e,document:su,variables:{graphSpec:n.graphSpec,projectId:e.projectId,workflows:[...n.workflows]}});if(o.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:o.syncDevSession.id,hash:r}}function as(e){let t=lt(e);return ge.existsSync(t)?ge.readdirSync(t).filter(n=>n.endsWith(".json")).length:0}function ss({cwd:e,slug:t}){let n=ct.join(lt(e),`${t}.json`);return ge.existsSync(n)?(ge.unlinkSync(n),!0):!1}function is({cwd:e,newSlug:t,sourceSlug:n}){let r=lt(e),o=ct.join(r,`${n}.json`);if(!ge.existsSync(o))return!1;let a=qe(o),s={...a,name:`${a.name} (copy)`};return ge.writeFileSync(ct.join(r,`${t}.json`),JSON.stringify(s,null,2)),!0}function ls({config:e,cwd:t}){let[n,r]=cu({config:e,devSessionId:void 0,syncing:!0}),o=lu(void 0);return iu(()=>{es({config:e,cwd:t}).then(({devSessionId:s,hash:i})=>{r(l=>({...l,devSessionId:s,syncing:!1})),o.current=ts({config:e,cwd:t,lastHash:i})});let a=setInterval(()=>{let s=ue();s!=null&&r(i=>JSON.stringify(i.config)===JSON.stringify(s)?i:{...i,config:s})},5e3);return()=>{o.current?.(),clearInterval(a)}},[e,t]),n}import{useCallback as du,useEffect as cs,useRef as ds,useState as pu}from"react";import{availableParallelism as ps}from"os";import{useSubscription as ir}from"urql";import{graphql as qt}from"gql.tada";import uu from"p-limit";var fu=qt(`
260
+ `);async function ns(e){let t=await as(e);return w.info("Synced %d workflow(s) + graph to dev session",ss(e.cwd)),t}function lr({config:e,cwd:t,lastHash:n,onSyncError:r,onSyncSuccess:o}){let a=ct.join(t,".ripplo"),s=n,i,l=au(a,{depth:2,ignoreInitial:!0,interval:1e3,persistent:!0,usePolling:!0});l.on("all",(d,p)=>{p.endsWith(".json")&&(i!=null&&clearTimeout(i),i=setTimeout(()=>{c({config:e,cwd:t})},500))});async function c(d){try{let p=rs(d.cwd),u=os(p);if(u===s)return;s=u;let m=await as(d);w.info("Dev session synced (%d workflow(s))",ss(d.cwd)),o({devSessionId:m.devSessionId,hash:m.hash})}catch(p){let u=p instanceof Error?p.message:"Unknown error";w.error("Sync failed: %s",u),r(u)}}return function(){i!=null&&clearTimeout(i),l.close()}}function rs(e){let t=ts(e),n=Ft(t),r=JSON.stringify(Vt(n)),o=lt(e),s=(ge.existsSync(o)?ge.readdirSync(o).filter(i=>i.endsWith(".json")):[]).map(i=>{let l=ct.join(o,i),c=qe(l),d=i.replace(/\.json$/,"");return{description:c.description,expectedOutcome:c.expectedOutcome,name:c.name,slug:d,spec:JSON.stringify(c.spec)}});return{graphSpec:r,workflows:s}}function os(e){return ou.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function as({config:e,cwd:t}){let n=rs(t),r=os(n),o=await G({config:e,document:iu,variables:{graphSpec:n.graphSpec,projectId:e.projectId,workflows:[...n.workflows]}});if(o.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:o.syncDevSession.id,hash:r}}function ss(e){let t=lt(e);return ge.existsSync(t)?ge.readdirSync(t).filter(n=>n.endsWith(".json")).length:0}function is({cwd:e,slug:t}){let n=ct.join(lt(e),`${t}.json`);return ge.existsSync(n)?(ge.unlinkSync(n),!0):!1}function ls({cwd:e,newSlug:t,sourceSlug:n}){let r=lt(e),o=ct.join(r,`${n}.json`);if(!ge.existsSync(o))return!1;let a=qe(o),s={...a,name:`${a.name} (copy)`};return ge.writeFileSync(ct.join(r,`${t}.json`),JSON.stringify(s,null,2)),!0}function cs({config:e,cwd:t}){let[n,r]=du({config:e,devSessionId:void 0,syncError:void 0,syncing:!0}),o=cu(void 0);return lu(()=>{function a({devSessionId:l}){r(c=>({...c,devSessionId:l,syncError:void 0,syncing:!1}))}function s(l){r(c=>({...c,syncError:l,syncing:!1}))}ns({config:e,cwd:t}).then(({devSessionId:l,hash:c})=>{a({devSessionId:l}),o.current=lr({config:e,cwd:t,lastHash:c,onSyncError:s,onSyncSuccess:a})}).catch(l=>{let c=l instanceof Error?l.message:String(l);s(c),o.current=lr({config:e,cwd:t,lastHash:"",onSyncError:s,onSyncSuccess:a})});let i=setInterval(()=>{let l=ue();l!=null&&r(c=>JSON.stringify(c.config)===JSON.stringify(l)?c:{...c,config:l})},5e3);return()=>{o.current?.(),clearInterval(i)}},[e,t]),n}import{useCallback as pu,useEffect as ds,useRef as ps,useState as uu}from"react";import{availableParallelism as us}from"os";import{useSubscription as cr}from"urql";import{graphql as qt}from"gql.tada";import fu from"p-limit";var mu=qt(`
261
261
  subscription RunRequestedDashboard {
262
262
  runRequested {
263
263
  agentProfileDescription
@@ -267,7 +267,7 @@ ${r.join(`
267
267
  workflowId
268
268
  }
269
269
  }
270
- `),mu=qt(`
270
+ `),yu=qt(`
271
271
  query PendingDevRunsDashboard($devSessionId: String!) {
272
272
  pendingDevRuns(devSessionId: $devSessionId) {
273
273
  id
@@ -280,14 +280,14 @@ ${r.join(`
280
280
  }
281
281
  }
282
282
  }
283
- `),yu=qt(`
283
+ `),gu=qt(`
284
284
  subscription DevWorkflowDeleteDashboard($projectId: String!) {
285
285
  devWorkflowDeleteRequested(projectId: $projectId) {
286
286
  projectId
287
287
  slug
288
288
  }
289
289
  }
290
- `),gu=qt(`
290
+ `),hu=qt(`
291
291
  subscription DevWorkflowDuplicateDashboard($projectId: String!) {
292
292
  devWorkflowDuplicateRequested(projectId: $projectId) {
293
293
  projectId
@@ -295,7 +295,7 @@ ${r.join(`
295
295
  newSlug
296
296
  }
297
297
  }
298
- `);function us({config:e,cwd:t,devSessionId:n}){let[r,o]=pu({activeRunCount:0,connected:!1,maxConcurrency:ps()}),a=hu({config:e}),s=ds(new Set),i=ds(uu(ps())),l=du(c=>{fs({activeRunIds:s.current,baseUrl:a.baseUrl,config:a,limiter:i.current,setState:o,...c})},[a]);return cs(()=>{n!=null&&o(c=>({...c,connected:!0}))},[n]),ir({pause:n==null,query:fu},(c,d)=>{let f=d.runRequested;return f!=null&&l({agentProfileDescription:f.agentProfileDescription??void 0,agentProfileId:f.agentProfileId??void 0,runId:f.runId,workflowId:f.workflowId}),d}),ir({pause:n==null,query:yu,variables:{projectId:a.projectId}},(c,d)=>{let f=d.devWorkflowDeleteRequested?.slug;return f!=null&&ss({cwd:t,slug:f}),d}),ir({pause:n==null,query:gu,variables:{projectId:a.projectId}},(c,d)=>{let f=d.devWorkflowDuplicateRequested;return f!=null&&is({cwd:t,newSlug:f.newSlug,sourceSlug:f.sourceSlug}),d}),cs(()=>{if(n==null)return;let c=new AbortController;return Su({activeConfig:a,activeRunIds:s.current,devSessionId:n,limiter:i.current,setState:o,signal:c.signal}),()=>{c.abort()}},[a,n]),r}function fs({activeRunIds:e,agentProfileDescription:t,agentProfileId:n,baseUrl:r,config:o,limiter:a,runId:s,setState:i,workflowId:l}){if(e.has(s))return;e.add(s),i(d=>({...d,activeRunCount:e.size}));function c(){e.delete(s),i(d=>({...d,activeRunCount:e.size}))}a(()=>ku({agentProfileDescription:t,agentProfileId:n,baseUrl:r,config:o,runId:s,workflowId:l}).finally(c))}function hu({config:e}){if(e.webhookSecret.length>0)return e;let t={...e,webhookSecret:at()};return be(t),t}var wu=5e3;async function Su({activeConfig:e,activeRunIds:t,devSessionId:n,limiter:r,setState:o,signal:a}){for(;!a.aborted;){if(await new Promise(s=>{let i=setTimeout(s,wu);a.addEventListener("abort",()=>{clearTimeout(i),s()},{once:!0})}),a.aborted)return;try{(await G({config:e,document:mu,variables:{devSessionId:n}})).pendingDevRuns?.filter(i=>!t.has(i.id)).forEach(i=>{let l=i.workflow?.id;l!=null&&fs({activeRunIds:t,agentProfileDescription:i.agentProfile?.description??void 0,agentProfileId:i.agentProfile?.id??void 0,baseUrl:e.baseUrl,config:e,limiter:r,runId:i.id,setState:o,workflowId:l})})}catch(s){w.error(s,"Runner error")}}}async function ku({agentProfileDescription:e,agentProfileId:t,baseUrl:n,config:r,runId:o,workflowId:a}){try{await On({maxRuns:100}),await tr({agentProfileDescription:e,agentProfileId:t,baseUrl:n,browser:void 0,config:r,headed:!1,runId:o,webhookSecret:r.webhookSecret,workflowId:a})}catch(s){w.error(s,"Runner error")}}import{Box as Rs,Text as Ns}from"ink";import{useCallback as $u,useEffect as Bu,useRef as Du,useState as Fu}from"react";import he from"fs";import ve from"path";import{chromium as Cu}from"playwright";import Mt from"fs";import ms from"path";import{z as ce}from"zod";var bu=ce.object({baseUrl:ce.string().optional(),cloudBaseUrl:ce.string(),preconditionApiPath:ce.string().optional(),projectId:ce.string()});function lr(e){let t=ms.join(e,".ripplo","settings.json");if(!Mt.existsSync(t))return{baseUrl:void 0,cloudBaseUrl:void 0,errors:[{message:".ripplo/settings.json not found",path:""}],preconditionApiPath:void 0,valid:!1,warnings:[]};let n=Ru(t);if(!n.success)return{baseUrl:void 0,cloudBaseUrl:void 0,errors:[{message:n.error,path:"settings.json"}],preconditionApiPath:void 0,valid:!1,warnings:[]};let r=bu.safeParse(n.data);if(!r.success)return{baseUrl:void 0,cloudBaseUrl:void 0,errors:r.error.issues.map(i=>({message:i.message,path:i.path.join(".")})),preconditionApiPath:void 0,valid:!1,warnings:[]};let o=[],a=ms.join(e,".ripplo","graph.json");return Mt.existsSync(a)&&Au(a)&&(r.data.preconditionApiPath==null||r.data.preconditionApiPath.length===0)&&o.push("Graph has preconditions but preconditionApiPath is not set in settings.json. Preconditions will not be executed. Set preconditionApiPath to the URL where your app serves precondition endpoints (can be a relative path appended to baseUrl, or an absolute URL)."),{baseUrl:r.data.baseUrl,cloudBaseUrl:r.data.cloudBaseUrl,errors:[],preconditionApiPath:r.data.preconditionApiPath,valid:!0,warnings:o}}async function Gt(e){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return}catch{return`baseUrl (${e}) is not responding. Make sure your dev server is running on that port.`}}function Au(e){return cr(e)>0}function cr(e){try{let t=Mt.readFileSync(e,"utf8"),n=JSON.parse(t),o=ce.object({preconditions:ce.record(ce.string(),ce.unknown()).optional()}).safeParse(n);return o.success?Object.keys(o.data.preconditions??{}).length:0}catch{return 0}}async function ys({baseUrl:e,preconditionApiPath:t}){let n=t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`;try{return(await fetch(`${n}/check`,{body:JSON.stringify({precondition:"__ripplo_health_check"}),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(5e3)})).ok?"Precondition endpoint accepted an unsigned request \u2014 webhook signature verification may be missing or misconfigured. All precondition endpoints must verify the webhook-id, webhook-signature, and webhook-timestamp headers using the Standard Webhooks spec. See get_precondition_schema for setup instructions.":void 0}catch{return}}function Ru(e){try{let t=Mt.readFileSync(e,"utf8");return{data:JSON.parse(t),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}import dr from"fs";import pr from"path";function gs(e){let t=Nu(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let n=sr.safeParse(t.data);if(!n.success)return{errors:n.error.issues.map(d=>({message:d.message,path:d.path.join(".")})),valid:!1};let r=Vt(n.data),o=rn(r);if(!o.success)return{errors:o.errors,valid:!1};let a=[...on(o.data)],s=pr.join(pr.dirname(e),"workflows"),i=dr.existsSync(s),l=new Set(o.data.edges.map(c=>c.workflow));return o.data.edges.forEach((c,d)=>{if(!i){a.push({message:`References workflow "${c.workflow}" but workflows directory does not exist`,path:`edges[${String(d)}].workflow`});return}let f=pr.join(s,`${c.workflow}.json`);dr.existsSync(f)||a.push({message:`References workflow "${c.workflow}" but no file exists at workflows/${c.workflow}.json`,path:`edges[${String(d)}].workflow`})}),i&&dr.readdirSync(s).filter(c=>c.endsWith(".json")).forEach(c=>{let d=c.replace(/\.json$/,"");l.has(d)||a.push({message:`Workflow file "workflows/${c}" is not referenced by any edge`,path:`workflows/${c}`})}),{errors:a,valid:a.length===0}}function Nu(e){try{return{data:Ft(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}function ws(e){let t=Tu(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let n=Wt.safeParse(t.data);if(!n.success)return{errors:n.error.issues.map(s=>({message:s.message,path:s.path.join(".")})),valid:!1};let r=rt(n.data.spec);if(!r.success)return{errors:r.errors,valid:!1};let o=vu(r.data);return o.length>0?{errors:o,valid:!1}:{errors:[],valid:!0}}function Tu(e){try{return{data:qe(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}function vu(e){let t=new Set(Object.keys(e.nodes)),n=[];t.has(e.entryNode)||n.push({message:`entryNode "${e.entryNode}" does not exist in nodes`,path:"entryNode"}),Object.entries(e.nodes).forEach(([s,i])=>{hs(i).forEach(l=>{t.has(l.id)||n.push({message:`references non-existent node "${l.id}"`,path:`nodes.${s}.${l.field}`})})});let r=new Set,o=t.has(e.entryNode)?[e.entryNode]:[],a=0;for(;a<o.length;){let s=o[a];if(a+=1,s==null||r.has(s))continue;r.add(s);let i=e.nodes[s];i!=null&&hs(i).forEach(l=>{r.has(l.id)||o.push(l.id)})}return t.forEach(s=>{r.has(s)||n.push({message:"unreachable from entryNode",path:`nodes.${s}`})}),n}function hs(e){let t=[];typeof e.next=="string"&&t.push({field:"next",id:e.next}),["consequent","alternate","body","catch","finally","nodes"].forEach(o=>{let a=e[o];Array.isArray(a)&&a.forEach((s,i)=>{typeof s=="string"&&t.push({field:`${o}[${String(i)}]`,id:s})})});let r=e.branches;return Array.isArray(r)&&r.forEach((o,a)=>{Array.isArray(o)&&o.forEach((s,i)=>{typeof s=="string"&&t.push({field:`branches[${String(a)}][${String(i)}]`,id:s})})}),t}async function ur(e){let t=xu(e),n=Lu(e),r=Pu(e),o=Eu(),a=Ou(e),s=Iu(e),i=await Uu(e,t);return[t,n,r,...i,a,s,o]}function xu(e){let t=lr(e);return t.valid?{missingFields:[],type:"settings",valid:!0}:{missingFields:t.errors.map(r=>r.path).filter(r=>r.length>0),type:"settings",valid:!1}}function Lu(e){let t=ve.join(e,".ripplo","settings.local.json");if(!he.existsSync(t))return{exists:!1,hasToken:!1,hasWebhookSecret:!1,type:"local-settings"};try{let n=he.readFileSync(t,"utf8"),r=JSON.parse(n);if(r==null||typeof r!="object")return{exists:!0,hasToken:!1,hasWebhookSecret:!1,type:"local-settings"};let o=Object.fromEntries(Object.entries(r)),a=typeof o.token=="string"&&o.token.length>0,s=typeof o.webhookSecret=="string"&&o.webhookSecret.length>0;return{exists:!0,hasToken:a,hasWebhookSecret:s,type:"local-settings"}}catch{return{exists:!0,hasToken:!1,hasWebhookSecret:!1,type:"local-settings"}}}function Pu(e){let t=ve.join(e,".mcp.json");if(!he.existsSync(t))return{installed:!1,type:"mcp-installed"};try{let n=he.readFileSync(t,"utf8"),r=JSON.parse(n);if(r==null||typeof r!="object")return{installed:!1,type:"mcp-installed"};let a=Object.fromEntries(Object.entries(r)).mcpServers;return a==null||typeof a!="object"?{installed:!1,type:"mcp-installed"}:{installed:"ripplo"in a,type:"mcp-installed"}}catch{return{installed:!1,type:"mcp-installed"}}}function Eu(){let e=Cu.executablePath();return{installed:he.existsSync(e),type:"browser"}}function Ou(e){let t=ve.join(e,".ripplo","graph.json");if(!he.existsSync(t))return{errorCount:0,errors:[],found:!1,type:"state-graph",valid:!1};let n=gs(t);return{errorCount:n.errors.length,errors:n.errors,found:!0,type:"state-graph",valid:n.valid}}function Iu(e){let t=ve.join(e,".ripplo","workflows");if(!he.existsSync(t))return{invalidNames:[],invalidWorkflows:[],total:0,type:"workflows",valid:0};let n=he.readdirSync(t).filter(a=>a.endsWith(".json")).map(a=>ve.join(t,a)),r=[],o=[];return n.forEach(a=>{let s=ws(a);if(!s.valid){let i=ve.basename(a,".json");r.push(i),o.push({errors:s.errors,name:i})}}),{invalidNames:r,invalidWorkflows:o,total:n.length,type:"workflows",valid:n.length-r.length}}async function Uu(e,t){if(!t.valid)return[];let n=lr(e),r=[];if(n.baseUrl!=null){let a=await Gt(n.baseUrl)==null;r.push({baseUrl:n.baseUrl,reachable:a,type:"dev-server"})}if(n.cloudBaseUrl!=null){let a=await Gt(n.cloudBaseUrl)==null;r.push({reachable:a,type:"cloud-base-url",url:n.cloudBaseUrl})}let o=await ju(n);return r.push(...o),r}async function ju(e){let t=ve.join(process.cwd(),".ripplo","graph.json"),n=cr(t),r=e.preconditionApiPath!=null&&e.preconditionApiPath.length>0,o={apiPathConfigured:r,count:n,endpointReachable:void 0,type:"preconditions"};if(n===0||!r)return[o];let a=_u(e.baseUrl,e.preconditionApiPath);if(a==null)return[o];let s=await Gt(a)==null,i=[];if(i.push({apiPathConfigured:!0,count:n,endpointReachable:s,type:"preconditions"}),Ss(e.preconditionApiPath)&&i.push({reachable:s,type:"precondition-endpoint",url:a}),!s||e.baseUrl==null)return i;let l=await ys({baseUrl:e.baseUrl,preconditionApiPath:e.preconditionApiPath});return i.push({rejectsUnsigned:l==null,type:"webhook-verification"}),i}function Ss(e){return e.startsWith("http://")||e.startsWith("https://")}function _u(e,t){if(Ss(t))return t;if(e!=null)return`${e}${t}`}var Vu=3e3;function ks(e){let[t,n]=Fu({checks:[],loading:!0}),r=Du(void 0),o=$u(()=>{ur(e).then(a=>{n({checks:a,loading:!1}),r.current=setTimeout(o,Vu)})},[e]);return Bu(()=>(o(),()=>{r.current!=null&&clearTimeout(r.current)}),[o]),t}import{Box as Wu,Text as Me}from"ink";import{jsx as dt,jsxs as bs}from"react/jsx-runtime";function As({check:e}){let{detail:t,detailBelow:n,label:r,status:o,url:a}=Gu(e);return bs(Wu,{flexDirection:"column",children:[bs(Me,{wrap:"truncate-end",children:[dt(Me,{color:Mu[o],children:qu[o]})," ",dt(Me,{bold:!0,children:r}),n?null:dt(Me,{dimColor:!0,children:` \u2014 ${t}`})]}),n?dt(Me,{dimColor:!0,children:` ${t}`}):null,a==null?null:dt(Me,{color:"blue",children:` ${a}`})]})}var qu={fail:"\u2717",pass:"\u2713",warn:"!"},Mu={fail:"red",pass:"green",warn:"yellow"};function Gu(e){switch(e.type){case"settings":return Ju(e);case"local-settings":return zu(e);case"dev-server":return Hu(e);case"preconditions":return Xu(e);case"webhook-verification":return Ku(e);case"state-graph":return Yu(e);case"workflows":return Qu(e);case"browser":return Zu(e);case"cloud-base-url":return ef(e);case"precondition-endpoint":return tf(e);case"mcp-installed":return nf(e)}}function Ju(e){return e.valid?{detail:"Project configured",detailBelow:!1,label:"Settings",status:"pass",url:void 0}:{detail:`Missing: ${e.missingFields.length>0?e.missingFields.join(", "):"invalid"}`,detailBelow:!1,label:"Settings",status:"fail",url:void 0}}function zu(e){return e.exists?!e.hasToken&&!e.hasWebhookSecret?{detail:"Missing token and webhook secret",detailBelow:!1,label:"Auth",status:"fail",url:void 0}:e.hasToken?e.hasWebhookSecret?{detail:"Token + secret configured",detailBelow:!1,label:"Auth",status:"pass",url:void 0}:{detail:"Missing webhook secret",detailBelow:!1,label:"Auth",status:"warn",url:void 0}:{detail:"Missing token",detailBelow:!1,label:"Auth",status:"fail",url:void 0}:{detail:"settings.local.json not found",detailBelow:!1,label:"Auth",status:"fail",url:void 0}}function Hu(e){return e.reachable?{detail:"Reachable",detailBelow:!1,label:"Dev server",status:"pass",url:e.baseUrl}:{detail:"Not responding",detailBelow:!1,label:"Dev server",status:"fail",url:e.baseUrl}}function Xu(e){if(e.count===0)return{detail:"None defined in graph",detailBelow:!0,label:"Preconditions",status:"warn",url:void 0};let t=String(e.count);return e.apiPathConfigured?e.endpointReachable===void 0?{detail:`${t} defined`,detailBelow:!0,label:"Preconditions",status:"warn",url:void 0}:{detail:`${t} defined, endpoint configured`,detailBelow:!0,label:"Preconditions",status:"pass",url:void 0}:{detail:`${t} defined, preconditionApiPath not set`,detailBelow:!0,label:"Preconditions",status:"fail",url:void 0}}function Ku(e){return e.rejectsUnsigned?{detail:"Unsigned requests rejected",detailBelow:!0,label:"Webhook verification",status:"pass",url:void 0}:{detail:"Unsigned requests accepted",detailBelow:!0,label:"Webhook verification",status:"fail",url:void 0}}function Yu(e){return e.found?e.valid?{detail:"Valid",detailBelow:!1,label:"State graph",status:"pass",url:void 0}:{detail:`${String(e.errorCount)} error${e.errorCount===1?"":"s"}`,detailBelow:!1,label:"State graph",status:"fail",url:void 0}:{detail:"graph.json not found",detailBelow:!1,label:"State graph",status:"fail",url:void 0}}function Qu(e){if(e.total===0)return{detail:"No workflows found",detailBelow:!1,label:"Workflows",status:"warn",url:void 0};let t=e.invalidNames.length;return t===0?{detail:`${String(e.total)} valid`,detailBelow:!1,label:"Workflows",status:"pass",url:void 0}:{detail:`${String(t)} invalid (${e.invalidNames.join(", ")})`,detailBelow:!1,label:"Workflows",status:"fail",url:void 0}}function Zu(e){return e.installed?{detail:"Chromium installed",detailBelow:!1,label:"Browser",status:"pass",url:void 0}:{detail:"Run: npx playwright install chromium",detailBelow:!1,label:"Browser",status:"fail",url:void 0}}function ef(e){return e.reachable?{detail:"Reachable",detailBelow:!1,label:"Cloud",status:"pass",url:e.url}:{detail:"Not reachable",detailBelow:!1,label:"Cloud",status:"warn",url:e.url}}function tf(e){return e.reachable?{detail:"Reachable",detailBelow:!1,label:"Precondition endpoint",status:"pass",url:void 0}:{detail:"Not reachable",detailBelow:!1,label:"Precondition endpoint",status:"fail",url:void 0}}function nf(e){return e.installed?{detail:"Configured",detailBelow:!1,label:"MCP",status:"pass",url:void 0}:{detail:"Run: ripplo setup-mcp",detailBelow:!1,label:"MCP",status:"fail",url:void 0}}import{jsx as Jt,jsxs as rf}from"react/jsx-runtime";function Ts({cwd:e}){let{checks:t,loading:n}=ks(e);return rf(Rs,{flexDirection:"column",children:[Jt(Rs,{marginBottom:1,children:Jt(Ns,{bold:!0,children:"Health Checks"})}),n?Jt(Ns,{dimColor:!0,children:"Running checks\u2026"}):t.map(r=>Jt(As,{check:r},r.type))]})}import{Box as fr,Text as pt}from"ink";import{jsx as ut,jsxs as mr}from"react/jsx-runtime";var of=[{arg:"scope",command:"/ripplo:explore"},{arg:"user flow",command:"/ripplo:create"},{arg:"user flow",command:"/ripplo:run"},{arg:"user flow",command:"/ripplo:debug"}];function vs(){return mr(fr,{flexDirection:"column",children:[ut(pt,{bold:!0,children:"Get Started"}),ut(fr,{marginBottom:1,children:ut(pt,{dimColor:!0,children:"Paste a command into your coding agent to create user flows and test your app"})}),of.map(e=>mr(fr,{children:[ut(pt,{bold:!0,children:e.command}),mr(pt,{dimColor:!0,children:[" ",ut(pt,{italic:!0,children:e.arg})]})]},e.command))]})}import{Box as gr,Text as we}from"ink";import{useQuery as uf,useSubscription as ff}from"urql";import{graphql as xs}from"gql.tada";import{Box as af,Text as zt}from"ink";import{graphql as sf,readFragment as lf}from"gql.tada";import{jsx as pf,jsxs as Ht}from"react/jsx-runtime";var yr=sf(`
298
+ `);function fs({config:e,cwd:t,devSessionId:n}){let[r,o]=uu({activeRunCount:0,connected:!1,maxConcurrency:us()}),a=wu({config:e}),s=ps(new Set),i=ps(fu(us())),l=pu(c=>{ms({activeRunIds:s.current,baseUrl:a.baseUrl,config:a,limiter:i.current,setState:o,...c})},[a]);return ds(()=>{n!=null&&o(c=>({...c,connected:!0}))},[n]),cr({pause:n==null,query:mu},(c,d)=>{let p=d.runRequested;return p!=null&&l({agentProfileDescription:p.agentProfileDescription??void 0,agentProfileId:p.agentProfileId??void 0,runId:p.runId,workflowId:p.workflowId}),d}),cr({pause:n==null,query:gu,variables:{projectId:a.projectId}},(c,d)=>{let p=d.devWorkflowDeleteRequested?.slug;return p!=null&&is({cwd:t,slug:p}),d}),cr({pause:n==null,query:hu,variables:{projectId:a.projectId}},(c,d)=>{let p=d.devWorkflowDuplicateRequested;return p!=null&&ls({cwd:t,newSlug:p.newSlug,sourceSlug:p.sourceSlug}),d}),ds(()=>{if(n==null)return;let c=new AbortController;return ku({activeConfig:a,activeRunIds:s.current,devSessionId:n,limiter:i.current,setState:o,signal:c.signal}),()=>{c.abort()}},[a,n]),r}function ms({activeRunIds:e,agentProfileDescription:t,agentProfileId:n,baseUrl:r,config:o,limiter:a,runId:s,setState:i,workflowId:l}){if(e.has(s))return;e.add(s),i(d=>({...d,activeRunCount:e.size}));function c(){e.delete(s),i(d=>({...d,activeRunCount:e.size}))}a(()=>bu({agentProfileDescription:t,agentProfileId:n,baseUrl:r,config:o,runId:s,workflowId:l}).finally(c))}function wu({config:e}){if(e.webhookSecret.length>0)return e;let t={...e,webhookSecret:at()};return be(t),t}var Su=5e3;async function ku({activeConfig:e,activeRunIds:t,devSessionId:n,limiter:r,setState:o,signal:a}){for(;!a.aborted;){if(await new Promise(s=>{let i=setTimeout(s,Su);a.addEventListener("abort",()=>{clearTimeout(i),s()},{once:!0})}),a.aborted)return;try{(await G({config:e,document:yu,variables:{devSessionId:n}})).pendingDevRuns?.filter(i=>!t.has(i.id)).forEach(i=>{let l=i.workflow?.id;l!=null&&ms({activeRunIds:t,agentProfileDescription:i.agentProfile?.description??void 0,agentProfileId:i.agentProfile?.id??void 0,baseUrl:e.baseUrl,config:e,limiter:r,runId:i.id,setState:o,workflowId:l})})}catch(s){w.error(s,"Runner error")}}}async function bu({agentProfileDescription:e,agentProfileId:t,baseUrl:n,config:r,runId:o,workflowId:a}){try{await In({maxRuns:100}),await nr({agentProfileDescription:e,agentProfileId:t,baseUrl:n,browser:void 0,config:r,headed:!1,runId:o,webhookSecret:r.webhookSecret,workflowId:a})}catch(s){w.error(s,"Runner error")}}import{Box as Ts,Text as vs}from"ink";import{useCallback as Bu,useEffect as Du,useRef as Fu,useState as Vu}from"react";import he from"fs";import ve from"path";import{chromium as xu}from"playwright";import Mt from"fs";import ys from"path";import{z as ce}from"zod";var Au=ce.object({baseUrl:ce.string().optional(),cloudBaseUrl:ce.string(),preconditionApiPath:ce.string().optional(),projectId:ce.string()});function dr(e){let t=ys.join(e,".ripplo","settings.json");if(!Mt.existsSync(t))return{baseUrl:void 0,cloudBaseUrl:void 0,errors:[{message:".ripplo/settings.json not found",path:""}],preconditionApiPath:void 0,valid:!1,warnings:[]};let n=Nu(t);if(!n.success)return{baseUrl:void 0,cloudBaseUrl:void 0,errors:[{message:n.error,path:"settings.json"}],preconditionApiPath:void 0,valid:!1,warnings:[]};let r=Au.safeParse(n.data);if(!r.success)return{baseUrl:void 0,cloudBaseUrl:void 0,errors:r.error.issues.map(i=>({message:i.message,path:i.path.join(".")})),preconditionApiPath:void 0,valid:!1,warnings:[]};let o=[],a=ys.join(e,".ripplo","graph.json");return Mt.existsSync(a)&&Ru(a)&&(r.data.preconditionApiPath==null||r.data.preconditionApiPath.length===0)&&o.push("Graph has preconditions but preconditionApiPath is not set in settings.json. Preconditions will not be executed. Set preconditionApiPath to the URL where your app serves precondition endpoints (can be a relative path appended to baseUrl, or an absolute URL)."),{baseUrl:r.data.baseUrl,cloudBaseUrl:r.data.cloudBaseUrl,errors:[],preconditionApiPath:r.data.preconditionApiPath,valid:!0,warnings:o}}async function Gt(e){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return}catch{return`baseUrl (${e}) is not responding. Make sure your dev server is running on that port.`}}function Ru(e){return pr(e)>0}function pr(e){try{let t=Mt.readFileSync(e,"utf8"),n=JSON.parse(t),o=ce.object({preconditions:ce.record(ce.string(),ce.unknown()).optional()}).safeParse(n);return o.success?Object.keys(o.data.preconditions??{}).length:0}catch{return 0}}async function gs({baseUrl:e,preconditionApiPath:t}){let n=t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`;try{return(await fetch(`${n}/check`,{body:JSON.stringify({precondition:"__ripplo_health_check"}),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(5e3)})).ok?"Precondition endpoint accepted an unsigned request \u2014 webhook signature verification may be missing or misconfigured. All precondition endpoints must verify the webhook-id, webhook-signature, and webhook-timestamp headers using the Standard Webhooks spec. See get_precondition_schema for setup instructions.":void 0}catch{return}}function Nu(e){try{let t=Mt.readFileSync(e,"utf8");return{data:JSON.parse(t),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}import ur from"fs";import fr from"path";function hs(e){let t=Tu(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let n=ir.safeParse(t.data);if(!n.success)return{errors:n.error.issues.map(d=>({message:d.message,path:d.path.join(".")})),valid:!1};let r=Vt(n.data),o=on(r);if(!o.success)return{errors:o.errors,valid:!1};let a=[...an(o.data)],s=fr.join(fr.dirname(e),"workflows"),i=ur.existsSync(s),l=new Set(o.data.edges.map(c=>c.workflow));return o.data.edges.forEach((c,d)=>{if(!i){a.push({message:`References workflow "${c.workflow}" but workflows directory does not exist`,path:`edges[${String(d)}].workflow`});return}let p=fr.join(s,`${c.workflow}.json`);ur.existsSync(p)||a.push({message:`References workflow "${c.workflow}" but no file exists at workflows/${c.workflow}.json`,path:`edges[${String(d)}].workflow`})}),i&&ur.readdirSync(s).filter(c=>c.endsWith(".json")).forEach(c=>{let d=c.replace(/\.json$/,"");l.has(d)||a.push({message:`Workflow file "workflows/${c}" is not referenced by any edge`,path:`workflows/${c}`})}),{errors:a,valid:a.length===0}}function Tu(e){try{return{data:Ft(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}function Ss(e){let t=vu(e);if(!t.success)return{errors:[{message:t.error,path:""}],valid:!1};let n=Wt.safeParse(t.data);if(!n.success)return{errors:n.error.issues.map(s=>({message:s.message,path:s.path.join(".")})),valid:!1};let r=rt(n.data.spec);if(!r.success)return{errors:r.errors,valid:!1};let o=Cu(r.data);return o.length>0?{errors:o,valid:!1}:{errors:[],valid:!0}}function vu(e){try{return{data:qe(e),success:!0}}catch(t){return{error:t instanceof Error?t.message:"Failed to read file",success:!1}}}function Cu(e){let t=new Set(Object.keys(e.nodes)),n=[];t.has(e.entryNode)||n.push({message:`entryNode "${e.entryNode}" does not exist in nodes`,path:"entryNode"}),Object.entries(e.nodes).forEach(([s,i])=>{ws(i).forEach(l=>{t.has(l.id)||n.push({message:`references non-existent node "${l.id}"`,path:`nodes.${s}.${l.field}`})})});let r=new Set,o=t.has(e.entryNode)?[e.entryNode]:[],a=0;for(;a<o.length;){let s=o[a];if(a+=1,s==null||r.has(s))continue;r.add(s);let i=e.nodes[s];i!=null&&ws(i).forEach(l=>{r.has(l.id)||o.push(l.id)})}return t.forEach(s=>{r.has(s)||n.push({message:"unreachable from entryNode",path:`nodes.${s}`})}),n}function ws(e){let t=[];typeof e.next=="string"&&t.push({field:"next",id:e.next}),["consequent","alternate","body","catch","finally","nodes"].forEach(o=>{let a=e[o];Array.isArray(a)&&a.forEach((s,i)=>{typeof s=="string"&&t.push({field:`${o}[${String(i)}]`,id:s})})});let r=e.branches;return Array.isArray(r)&&r.forEach((o,a)=>{Array.isArray(o)&&o.forEach((s,i)=>{typeof s=="string"&&t.push({field:`branches[${String(a)}][${String(i)}]`,id:s})})}),t}async function mr(e){let t=Lu(e),n=Pu(e),r=Eu(e),o=Ou(),a=Iu(e),s=Uu(e),i=await ju(e,t);return[t,n,r,...i,a,s,o]}function Lu(e){let t=dr(e);return t.valid?{missingFields:[],type:"settings",valid:!0}:{missingFields:t.errors.map(r=>r.path).filter(r=>r.length>0),type:"settings",valid:!1}}function Pu(e){let t=ve.join(e,".ripplo","settings.local.json");if(!he.existsSync(t))return{exists:!1,hasToken:!1,hasWebhookSecret:!1,type:"local-settings"};try{let n=he.readFileSync(t,"utf8"),r=JSON.parse(n);if(r==null||typeof r!="object")return{exists:!0,hasToken:!1,hasWebhookSecret:!1,type:"local-settings"};let o=Object.fromEntries(Object.entries(r)),a=typeof o.token=="string"&&o.token.length>0,s=typeof o.webhookSecret=="string"&&o.webhookSecret.length>0;return{exists:!0,hasToken:a,hasWebhookSecret:s,type:"local-settings"}}catch{return{exists:!0,hasToken:!1,hasWebhookSecret:!1,type:"local-settings"}}}function Eu(e){let t=ve.join(e,".mcp.json");if(!he.existsSync(t))return{installed:!1,type:"mcp-installed"};try{let n=he.readFileSync(t,"utf8"),r=JSON.parse(n);if(r==null||typeof r!="object")return{installed:!1,type:"mcp-installed"};let a=Object.fromEntries(Object.entries(r)).mcpServers;return a==null||typeof a!="object"?{installed:!1,type:"mcp-installed"}:{installed:"ripplo"in a,type:"mcp-installed"}}catch{return{installed:!1,type:"mcp-installed"}}}function Ou(){let e=xu.executablePath();return{installed:he.existsSync(e),type:"browser"}}function Iu(e){let t=ve.join(e,".ripplo","graph.json");if(!he.existsSync(t))return{errorCount:0,errors:[],found:!1,type:"state-graph",valid:!1};let n=hs(t);return{errorCount:n.errors.length,errors:n.errors,found:!0,type:"state-graph",valid:n.valid}}function Uu(e){let t=ve.join(e,".ripplo","workflows");if(!he.existsSync(t))return{invalidNames:[],invalidWorkflows:[],total:0,type:"workflows",valid:0};let n=he.readdirSync(t).filter(a=>a.endsWith(".json")).map(a=>ve.join(t,a)),r=[],o=[];return n.forEach(a=>{let s=Ss(a);if(!s.valid){let i=ve.basename(a,".json");r.push(i),o.push({errors:s.errors,name:i})}}),{invalidNames:r,invalidWorkflows:o,total:n.length,type:"workflows",valid:n.length-r.length}}async function ju(e,t){if(!t.valid)return[];let n=dr(e),r=[];if(n.baseUrl!=null){let a=await Gt(n.baseUrl)==null;r.push({baseUrl:n.baseUrl,reachable:a,type:"dev-server"})}if(n.cloudBaseUrl!=null){let a=await Gt(n.cloudBaseUrl)==null;r.push({reachable:a,type:"cloud-base-url",url:n.cloudBaseUrl})}let o=await _u(n);return r.push(...o),r}async function _u(e){let t=ve.join(process.cwd(),".ripplo","graph.json"),n=pr(t),r=e.preconditionApiPath!=null&&e.preconditionApiPath.length>0,o={apiPathConfigured:r,count:n,endpointReachable:void 0,type:"preconditions"};if(n===0||!r)return[o];let a=$u(e.baseUrl,e.preconditionApiPath);if(a==null)return[o];let s=await Gt(a)==null,i=[];if(i.push({apiPathConfigured:!0,count:n,endpointReachable:s,type:"preconditions"}),ks(e.preconditionApiPath)&&i.push({reachable:s,type:"precondition-endpoint",url:a}),!s||e.baseUrl==null)return i;let l=await gs({baseUrl:e.baseUrl,preconditionApiPath:e.preconditionApiPath});return i.push({rejectsUnsigned:l==null,type:"webhook-verification"}),i}function ks(e){return e.startsWith("http://")||e.startsWith("https://")}function $u(e,t){if(ks(t))return t;if(e!=null)return`${e}${t}`}var bs=3e3;function As(e){let[t,n]=Vu({checks:[],loading:!0}),r=Fu(void 0),o=Bu(()=>{mr(e).then(a=>{n({checks:a,loading:!1}),r.current=setTimeout(o,bs)}).catch(()=>{n(a=>({...a,loading:!1})),r.current=setTimeout(o,bs)})},[e]);return Du(()=>(o(),()=>{r.current!=null&&clearTimeout(r.current)}),[o]),t}import{Box as Wu,Text as Me}from"ink";import{jsx as dt,jsxs as Rs}from"react/jsx-runtime";function Ns({check:e}){let{detail:t,detailBelow:n,label:r,status:o,url:a}=Gu(e);return Rs(Wu,{flexDirection:"column",children:[Rs(Me,{wrap:"truncate-end",children:[dt(Me,{color:Mu[o],children:qu[o]})," ",dt(Me,{bold:!0,children:r}),n?null:dt(Me,{dimColor:!0,children:` \u2014 ${t}`})]}),n?dt(Me,{dimColor:!0,children:` ${t}`}):null,a==null?null:dt(Me,{color:"blue",children:` ${a}`})]})}var qu={fail:"\u2717",pass:"\u2713",warn:"!"},Mu={fail:"red",pass:"green",warn:"yellow"};function Gu(e){switch(e.type){case"settings":return Ju(e);case"local-settings":return zu(e);case"dev-server":return Hu(e);case"preconditions":return Xu(e);case"webhook-verification":return Ku(e);case"state-graph":return Yu(e);case"workflows":return Qu(e);case"browser":return Zu(e);case"cloud-base-url":return ef(e);case"precondition-endpoint":return tf(e);case"mcp-installed":return nf(e)}}function Ju(e){return e.valid?{detail:"Project configured",detailBelow:!1,label:"Settings",status:"pass",url:void 0}:{detail:`Missing: ${e.missingFields.length>0?e.missingFields.join(", "):"invalid"}`,detailBelow:!1,label:"Settings",status:"fail",url:void 0}}function zu(e){return e.exists?!e.hasToken&&!e.hasWebhookSecret?{detail:"Missing token and webhook secret",detailBelow:!1,label:"Auth",status:"fail",url:void 0}:e.hasToken?e.hasWebhookSecret?{detail:"Token + secret configured",detailBelow:!1,label:"Auth",status:"pass",url:void 0}:{detail:"Missing webhook secret",detailBelow:!1,label:"Auth",status:"warn",url:void 0}:{detail:"Missing token",detailBelow:!1,label:"Auth",status:"fail",url:void 0}:{detail:"settings.local.json not found",detailBelow:!1,label:"Auth",status:"fail",url:void 0}}function Hu(e){return e.reachable?{detail:"Reachable",detailBelow:!1,label:"Dev server",status:"pass",url:e.baseUrl}:{detail:"Not responding",detailBelow:!1,label:"Dev server",status:"fail",url:e.baseUrl}}function Xu(e){if(e.count===0)return{detail:"None defined in graph",detailBelow:!0,label:"Preconditions",status:"warn",url:void 0};let t=String(e.count);return e.apiPathConfigured?e.endpointReachable===void 0?{detail:`${t} defined`,detailBelow:!0,label:"Preconditions",status:"warn",url:void 0}:{detail:`${t} defined, endpoint configured`,detailBelow:!0,label:"Preconditions",status:"pass",url:void 0}:{detail:`${t} defined, preconditionApiPath not set`,detailBelow:!0,label:"Preconditions",status:"fail",url:void 0}}function Ku(e){return e.rejectsUnsigned?{detail:"Unsigned requests rejected",detailBelow:!0,label:"Webhook verification",status:"pass",url:void 0}:{detail:"Unsigned requests accepted",detailBelow:!0,label:"Webhook verification",status:"fail",url:void 0}}function Yu(e){return e.found?e.valid?{detail:"Valid",detailBelow:!1,label:"State graph",status:"pass",url:void 0}:{detail:`${String(e.errorCount)} error${e.errorCount===1?"":"s"}`,detailBelow:!1,label:"State graph",status:"fail",url:void 0}:{detail:"graph.json not found",detailBelow:!1,label:"State graph",status:"fail",url:void 0}}function Qu(e){if(e.total===0)return{detail:"No workflows found",detailBelow:!1,label:"Workflows",status:"warn",url:void 0};let t=e.invalidNames.length;return t===0?{detail:`${String(e.total)} valid`,detailBelow:!1,label:"Workflows",status:"pass",url:void 0}:{detail:`${String(t)} invalid (${e.invalidNames.join(", ")})`,detailBelow:!1,label:"Workflows",status:"fail",url:void 0}}function Zu(e){return e.installed?{detail:"Chromium installed",detailBelow:!1,label:"Browser",status:"pass",url:void 0}:{detail:"Run: npx playwright install chromium",detailBelow:!1,label:"Browser",status:"fail",url:void 0}}function ef(e){return e.reachable?{detail:"Reachable",detailBelow:!1,label:"Cloud",status:"pass",url:e.url}:{detail:"Not reachable",detailBelow:!1,label:"Cloud",status:"warn",url:e.url}}function tf(e){return e.reachable?{detail:"Reachable",detailBelow:!1,label:"Precondition endpoint",status:"pass",url:void 0}:{detail:"Not reachable",detailBelow:!1,label:"Precondition endpoint",status:"fail",url:void 0}}function nf(e){return e.installed?{detail:"Configured",detailBelow:!1,label:"MCP",status:"pass",url:void 0}:{detail:"Run: ripplo setup-mcp",detailBelow:!1,label:"MCP",status:"fail",url:void 0}}import{jsx as Jt,jsxs as rf}from"react/jsx-runtime";function Cs({cwd:e}){let{checks:t,loading:n}=As(e);return rf(Ts,{flexDirection:"column",children:[Jt(Ts,{marginBottom:1,children:Jt(vs,{bold:!0,children:"Health Checks"})}),n?Jt(vs,{dimColor:!0,children:"Running checks\u2026"}):t.map(r=>Jt(Ns,{check:r},r.type))]})}import{Box as yr,Text as pt}from"ink";import{jsx as ut,jsxs as gr}from"react/jsx-runtime";var of=[{arg:"scope",command:"/ripplo:explore"},{arg:"user flow",command:"/ripplo:create"},{arg:"user flow",command:"/ripplo:run"},{arg:"user flow",command:"/ripplo:debug"}];function xs(){return gr(yr,{flexDirection:"column",children:[ut(pt,{bold:!0,children:"Get Started"}),ut(yr,{marginBottom:1,children:ut(pt,{dimColor:!0,children:"Paste a command into your coding agent to create user flows and test your app"})}),of.map(e=>gr(yr,{children:[ut(pt,{bold:!0,children:e.command}),gr(pt,{dimColor:!0,children:[" ",ut(pt,{italic:!0,children:e.arg})]})]},e.command))]})}import{Box as wr,Text as we}from"ink";import{useQuery as uf,useSubscription as ff}from"urql";import{graphql as Ps}from"gql.tada";import{Box as af,Text as zt}from"ink";import{graphql as sf,readFragment as lf}from"gql.tada";import{jsx as pf,jsxs as Ht}from"react/jsx-runtime";var hr=sf(`
299
299
  fragment DashboardTraceEntryRow on TraceEntry {
300
300
  id
301
301
  title
@@ -303,7 +303,7 @@ ${r.join(`
303
303
  status
304
304
  duration
305
305
  }
306
- `);function Cs({data:e}){let t=lf(yr,e),n=df(t.status),r=cf(t.status),o=`${String(t.duration)}ms`;return Ht(af,{children:[pf(zt,{color:n,children:r}),Ht(zt,{children:[" ",t.title]}),Ht(zt,{dimColor:!0,children:[" ",t.nodeType]}),Ht(zt,{dimColor:!0,children:[" ",o]})]})}function cf(e){return{failed:"\u2717",passed:"\u2713",warning:"!"}[e]??"?"}function df(e){return{failed:"red",passed:"green",warning:"yellow"}[e]??"white"}import{jsx as Ce,jsxs as ft}from"react/jsx-runtime";var mf=xs(`
306
+ `);function Ls({data:e}){let t=lf(hr,e),n=df(t.status),r=cf(t.status),o=`${String(t.duration)}ms`;return Ht(af,{children:[pf(zt,{color:n,children:r}),Ht(zt,{children:[" ",t.title]}),Ht(zt,{dimColor:!0,children:[" ",t.nodeType]}),Ht(zt,{dimColor:!0,children:[" ",o]})]})}function cf(e){return{failed:"\u2717",passed:"\u2713",warning:"!"}[e]??"?"}function df(e){return{failed:"red",passed:"green",warning:"yellow"}[e]??"white"}import{jsx as Ce,jsxs as ft}from"react/jsx-runtime";var mf=Ps(`
307
307
  subscription DashboardRunProgress($runId: String!) {
308
308
  runProgress(runId: $runId) {
309
309
  __typename
@@ -338,7 +338,7 @@ ${r.join(`
338
338
  }
339
339
  }
340
340
  }
341
- `),yf=xs(`
341
+ `),yf=Ps(`
342
342
  query DashboardRunDetail($id: String!) {
343
343
  run(id: $id) {
344
344
  id
@@ -362,7 +362,7 @@ ${r.join(`
362
362
  }
363
363
  }
364
364
  }
365
- `,[yr]);function Ls({runId:e}){let[t]=uf({query:yf,variables:{id:e}});if(ff({query:mf,variables:{runId:e}}),t.fetching)return Ce(we,{dimColor:!0,children:"Loading run details..."});let n=t.data?.run;if(n==null)return Ce(we,{color:"red",children:"Run not found"});let r=n.workflow?.slug??n.id.slice(0,8),o=n.results?.[0],a=o?.traceEntries??[];return ft(gr,{flexDirection:"column",children:[ft(gr,{flexDirection:"column",marginBottom:1,children:[Ce(we,{bold:!0,children:r}),o==null?Ce(we,{dimColor:!0,children:n.status}):ft(we,{children:[ft(we,{color:gf(n.status),children:["Run ",n.status]}),ft(we,{dimColor:!0,children:[" | ",String(o.passCount)," pass, ",String(o.failCount)," fail"," | ",String(o.duration??0),"ms"]})]})]}),a.map(s=>Ce(Cs,{data:s},s.id)),o?.summary==null?null:Ce(gr,{marginTop:1,children:Ce(we,{dimColor:!0,children:o.summary})})]})}function gf(e){return{completed:"green",failed:"red"}[e]}import{Box as Os,Text as kr}from"ink";import{Box as hf,Text as hr}from"ink";import wf from"ink-spinner";import{graphql as Sf,readFragment as kf}from"gql.tada";import{jsx as Ps,jsxs as wr}from"react/jsx-runtime";var Sr=Sf(`
365
+ `,[hr]);function Es({runId:e}){let[t]=uf({query:yf,variables:{id:e}});if(ff({query:mf,variables:{runId:e}}),t.fetching)return Ce(we,{dimColor:!0,children:"Loading run details..."});let n=t.data?.run;if(n==null)return Ce(we,{color:"red",children:"Run not found"});let r=n.workflow?.slug??n.id.slice(0,8),o=n.results?.[0],a=o?.traceEntries??[];return ft(wr,{flexDirection:"column",children:[ft(wr,{flexDirection:"column",marginBottom:1,children:[Ce(we,{bold:!0,children:r}),o==null?Ce(we,{dimColor:!0,children:n.status}):ft(we,{children:[ft(we,{color:gf(n.status),children:["Run ",n.status]}),ft(we,{dimColor:!0,children:[" | ",String(o.passCount)," pass, ",String(o.failCount)," fail"," | ",String(o.duration??0),"ms"]})]})]}),a.map(s=>Ce(Ls,{data:s},s.id)),o?.summary==null?null:Ce(wr,{marginTop:1,children:Ce(we,{dimColor:!0,children:o.summary})})]})}function gf(e){return{completed:"green",failed:"red"}[e]}import{Box as Us,Text as Ar}from"ink";import{Box as hf,Text as Sr}from"ink";import wf from"ink-spinner";import{graphql as Sf,readFragment as kf}from"gql.tada";import{jsx as Os,jsxs as kr}from"react/jsx-runtime";var br=Sf(`
366
366
  fragment DashboardRunRow on Run {
367
367
  id
368
368
  status
@@ -378,37 +378,37 @@ ${r.join(`
378
378
  duration
379
379
  }
380
380
  }
381
- `);function Es({data:e,selected:t}){let n=kf(Sr,e),r=bf(n.status),o=Af(n.status),a=n.workflow?.slug??"unknown";return wr(hf,{children:[wr(hr,{children:[t?">":" "," "]}),n.status==="running"?Ps(wf,{type:"dots"}):Ps(hr,{color:o,children:r}),wr(hr,{children:[" ",a]})]})}function bf(e){return{cancelled:"-",completed:"\u2713",failed:"\u2717",pending:".",running:"~"}[e]??"?"}function Af(e){return{cancelled:"gray",completed:"green",failed:"red",pending:"yellow",running:"cyan"}[e]??"white"}import{jsx as br,jsxs as Ar}from"react/jsx-runtime";function Is({connected:e,runs:t,selectedIndex:n,syncing:r}){return Ar(Os,{flexDirection:"column",children:[Ar(Os,{marginBottom:1,children:[br(kr,{bold:!0,children:"Runs"}),Ar(kr,{dimColor:!0,children:[" (",Rf({connected:e,syncing:r}),")"]})]}),t.length===0?br(kr,{dimColor:!0,children:"No runs yet. Trigger a run from the web UI."}):t.map((o,a)=>br(Es,{data:o,selected:a===n},o.id))]})}function Rf({connected:e,syncing:t}){return t?"syncing...":e?"connected":"connecting..."}import{useEffect as vf,useState as Cf}from"react";import{Text as Ge}from"ink";import PR from"chalk";import{z as Us}from"zod";var Rr="0.0.10",Nf="ripplo",Tf=Us.object({version:Us.string()});async function js(){let e=new AbortController,t=setTimeout(()=>{e.abort()},3e3);try{let n=await fetch(`https://registry.npmjs.org/${Nf}/latest`,{headers:{accept:"application/json"},signal:e.signal});if(!n.ok)return;let r=await n.json();return Tf.parse(r).version}catch{return}finally{clearTimeout(t)}}import{jsx as mt,jsxs as Lf}from"react/jsx-runtime";function _s({activeRunCount:e,connected:t,ripploServerUrl:n,width:r}){let o=xf(),a=o!=null&&o!==Rr,s=t?"connected":"connecting...",i=e>0?` ${String(e)} running`:"",l=`v${Rr}`,c=a?` \u2192 v${o}`:"",d="q to quit",f=` ripplo ${l}${c} | ${n} ${s}${i}`,u=Math.max(0,r-f.length-d.length-1);return Lf(Ge,{inverse:!0,children:[mt(Ge,{bold:!0,children:" ripplo "}),mt(Ge,{dimColor:!0,children:l}),a?mt(Ge,{color:"yellow",children:` \u2192 v${o}`}):null,` | ${n} `,mt(Ge,{color:t?"green":"yellow",children:s}),i," ".repeat(u),mt(Ge,{dimColor:!0,children:d})," "]})}function xf(){let[e,t]=Cf();return vf(()=>{js().then(n=>{n!=null&&t(n)})},[]),e}import{jsx as xe,jsxs as Xt}from"react/jsx-runtime";var _f=$s(`
381
+ `);function Is({data:e,selected:t}){let n=kf(br,e),r=bf(n.status),o=Af(n.status),a=n.workflow?.slug??"unknown";return kr(hf,{children:[kr(Sr,{children:[t?">":" "," "]}),n.status==="running"?Os(wf,{type:"dots"}):Os(Sr,{color:o,children:r}),kr(Sr,{children:[" ",a]})]})}function bf(e){return{cancelled:"-",completed:"\u2713",failed:"\u2717",pending:".",running:"~"}[e]??"?"}function Af(e){return{cancelled:"gray",completed:"green",failed:"red",pending:"yellow",running:"cyan"}[e]??"white"}import{jsx as Rr,jsxs as Nr}from"react/jsx-runtime";function js({connected:e,runs:t,selectedIndex:n,syncing:r}){return Nr(Us,{flexDirection:"column",children:[Nr(Us,{marginBottom:1,children:[Rr(Ar,{bold:!0,children:"Runs"}),Nr(Ar,{dimColor:!0,children:[" (",Rf({connected:e,syncing:r}),")"]})]}),t.length===0?Rr(Ar,{dimColor:!0,children:"No runs yet. Trigger a run from the web UI."}):t.map((o,a)=>Rr(Is,{data:o,selected:a===n},o.id))]})}function Rf({connected:e,syncing:t}){return t?"syncing...":e?"connected":"connecting..."}import{useEffect as vf,useState as Cf}from"react";import{Text as Ge}from"ink";import OR from"chalk";import{z as _s}from"zod";var Tr="0.0.11",Nf="ripplo",Tf=_s.object({version:_s.string()});async function $s(){let e=new AbortController,t=setTimeout(()=>{e.abort()},3e3);try{let n=await fetch(`https://registry.npmjs.org/${Nf}/latest`,{headers:{accept:"application/json"},signal:e.signal});if(!n.ok)return;let r=await n.json();return Tf.parse(r).version}catch{return}finally{clearTimeout(t)}}import{jsx as mt,jsxs as Ef}from"react/jsx-runtime";function Bs({activeRunCount:e,connected:t,ripploServerUrl:n,syncError:r,width:o}){let a=Pf(),s=a!=null&&a!==Tr,i=xf({connected:t,syncError:r}),l=e>0?` ${String(e)} running`:"",c=`v${Tr}`,d=s?` \u2192 v${a}`:"",p="q to quit",u=` ripplo ${c}${d} | ${n} ${i}${l}`,m=Math.max(0,o-u.length-p.length-1);return Ef(Ge,{inverse:!0,children:[mt(Ge,{bold:!0,children:" ripplo "}),mt(Ge,{dimColor:!0,children:c}),s?mt(Ge,{color:"yellow",children:` \u2192 v${a}`}):null,` | ${n} `,mt(Ge,{color:Lf({connected:t,syncError:r}),children:i}),l," ".repeat(m),mt(Ge,{dimColor:!0,children:p})," "]})}function xf({connected:e,syncError:t}){return t!=null?"sync failed":e?"connected":"connecting..."}function Lf({connected:e,syncError:t}){return t!=null?"red":e?"green":"yellow"}function Pf(){let[e,t]=Cf();return vf(()=>{$s().then(n=>{n!=null&&t(n)})},[]),e}import{jsx as xe,jsxs as Xt}from"react/jsx-runtime";var Bf=Ds(`
382
382
  query DashboardProjectRuns($projectId: String!, $take: Int, $devSessionId: String) {
383
383
  projectRuns(projectId: $projectId, take: $take, devSessionId: $devSessionId) {
384
384
  id
385
385
  ...DashboardRunRow
386
386
  }
387
387
  }
388
- `,[Sr]),$f=$s(`
388
+ `,[br]),Df=Ds(`
389
389
  subscription DashboardProjectRunStatus($projectId: String!) {
390
390
  projectRunStatusChanged(projectId: $projectId) {
391
391
  runId
392
392
  status
393
393
  }
394
394
  }
395
- `);function Bs({config:e,cwd:t,onAuthError:n}){let r=Of(),{height:o,width:a}=Ve(),{config:s,devSessionId:i,syncing:l}=ls({config:e,cwd:t}),c=us({config:s,cwd:t,devSessionId:i}),[d]=Uf({query:_f,variables:{devSessionId:i,projectId:s.projectId,take:20}});jf({query:$f,variables:{projectId:s.projectId}});let f=d.error?.message.includes("Not authorized")===!0;Pf(()=>{f&&n()},[f,n]);let u=d.data?.projectRuns??[],m=d.error==null&&!d.fetching,[y,h]=Ef(0),k=u[y]?.id;return If((b,C)=>{b==="q"&&r.exit(),Bf({key:C,runs:u,selectedIndex:y,setSelectedIndex:h})}),Xt(Je,{flexDirection:"column",height:o,width:a,children:[xe(_s,{activeRunCount:c.activeRunCount,connected:c.connected,ripploServerUrl:s.ripploServerUrl,width:a}),Xt(Je,{flexGrow:1,padding:1,children:[Xt(Je,{flexDirection:"column",flexShrink:0,minWidth:40,width:40,children:[xe(vs,{}),xe(Je,{borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,marginY:1}),xe(Ts,{cwd:t})]}),Xt(Je,{borderBottom:!1,borderLeft:!0,borderRight:!1,borderStyle:"single",borderTop:!1,flexDirection:"column",flexGrow:1,paddingLeft:1,children:[xe(Is,{connected:m,runs:u,selectedIndex:y,syncing:l}),k==null?null:xe(Je,{borderStyle:"round",flexDirection:"column",flexGrow:1,marginTop:1,paddingX:1,children:xe(Ls,{runId:k})})]})]})]})}function Bf({key:e,runs:t,setSelectedIndex:n}){e.upArrow&&n(r=>Math.max(0,r-1)),e.downArrow&&n(r=>Math.min(t.length-1,r+1))}import{useEffect as Wf,useState as yt}from"react";import{Box as Le,Text as Nr,useInput as qf}from"ink";import{Text as Ds}from"ink";import Df from"ink-spinner";import{jsx as Fs,jsxs as Vf}from"react/jsx-runtime";var Ff="#24CFFF";function Vs({loading:e}){return e?Vf(Ds,{color:Ff,children:[Fs(Df,{type:"dots"})," Starting..."]}):Fs(Ds,{children:""})}import{jsx as Se,jsxs as Tr}from"react/jsx-runtime";var Kt=[" 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 "],Ws="#24CFFF",Mf="ripplo";function qs({onDismiss:e}){let{height:t,width:n}=Ve(),[r,o]=yt(0),[a,s]=yt(!1),[i,l]=yt(!1),[c,d]=yt(!1),[f,u]=yt(!1);qf(()=>{f&&e()}),Wf(()=>{let h=80+Kt.length*70+80,S=[...Kt.map((k,b)=>setTimeout(()=>{o(b+1)},80+b*70)),setTimeout(()=>{s(!0)},h),setTimeout(()=>{l(!0)},h+200),setTimeout(()=>{d(!0)},h+400),setTimeout(()=>{d(!1),u(!0)},h+2e3),setTimeout(()=>{e()},h+2800)];return()=>{S.forEach(k=>{clearTimeout(k)})}},[e]);let m=Kt.length+5,y=Math.max(0,Math.floor((t-m)/2));return Tr(Le,{flexDirection:"column",height:t,width:n,children:[Se(Le,{height:y}),Tr(Le,{alignItems:"flex-start",flexDirection:"row",justifyContent:"center",children:[Se(Le,{flexDirection:"column",children:Kt.map((h,S)=>Se(Nr,{color:Ws,children:S<r?h:""},h))}),Tr(Le,{flexDirection:"column",paddingLeft:4,paddingTop:5,children:[Se(Nr,{bold:!0,color:Ws,children:a?Mf:""}),Se(Le,{marginTop:1,children:Se(Nr,{color:"gray",dimColor:!0,children:i?"developer CLI":""})}),Se(Le,{marginTop:2,children:Se(Vs,{loading:c})})]})]})]})}import{useCallback as vr,useEffect as Rm,useState as ht}from"react";import He from"fs";import Zt from"path";import{exec as Qf}from"child_process";import{createAuthClient as Gf}from"better-auth/client";import{deviceAuthorizationClient as Jf}from"better-auth/client/plugins";function Yt({baseURL:e}){return Gf({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[Jf()]})}import{z as Ms}from"zod";var zf="https://ripplo.ai",Hf="https://ripplo-dev.up.railway.app",Xf="https://localhost:3001",Kf={dev:Hf,local:Xf};function Js(){let e=process.argv.findIndex(o=>o.startsWith("--env"));if(e===-1)return gt().RIPPLO_SERVER_URL;let t=process.argv[e];if(t==null)return gt().RIPPLO_SERVER_URL;let n=t.includes("=")?t.split("=")[1]:process.argv[e+1];if(n==null)return gt().RIPPLO_SERVER_URL;let r=Kf[n];if(r==null)throw new Error(`Unknown env "${n}". Use "dev" or "local".`);return r}var Yf=Ms.object({RIPPLO_SERVER_URL:Ms.string().min(1).default(zf)}),Gs;function gt(){return Gs??=Yf.parse(process.env),Gs}var Zf=5e3,zs="ripplo-cli";async function Hs({onDeviceCode:e,url:t}){let n=t??gt().RIPPLO_SERVER_URL,r=Yt({baseURL:n}),o=await r.device.code({client_id:zs});if(o.error!=null)throw new Error(`Failed to request device code: ${o.error.error_description}`);let{device_code:a,user_code:s,verification_uri_complete:i}=o.data;e({userCode:s,verificationUrl:i}),am(i);let l=await em({authClient:r,deviceCode:a}),c=ue(),d=c==null?{baseUrl:"",cloudBaseUrl:"",preconditionApiPath:"",projectId:"",ripploServerUrl:n,token:l,webhookSecret:""}:{baseUrl:c.baseUrl,cloudBaseUrl:c.cloudBaseUrl,preconditionApiPath:c.preconditionApiPath,projectId:c.projectId,ripploServerUrl:n,token:l,webhookSecret:c.webhookSecret};return be(d),d}async function em({authClient:e,deviceCode:t}){for(;;){await rm(Zf);let n=await e.device.token({client_id:zs,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(!nm(n.error.error))throw new Error(`Authorization failed: ${n.error.error_description}`)}}var tm=new Set(["authorization_pending","slow_down"]);function nm(e){return tm.has(e)}function rm(e){return new Promise(t=>{setTimeout(t,e)})}function om(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function am(e){let t=om();Qf(`${t} "${e}"`,()=>{})}import ne from"fs";import Y from"path";import{fileURLToPath as Zs}from"url";import{z as X}from"zod";import{McpServer as NT}from"@modelcontextprotocol/sdk/server/mcp.js";import{z as vT}from"zod";import{z as H}from"zod";var sm=H.object({additionalProperties:H.unknown().optional(),properties:H.record(H.string(),H.record(H.string(),H.unknown())).optional(),required:H.array(H.string()).optional(),type:H.string().optional()}),xN=H.object({oneOf:H.array(sm).optional()});function im(){return`---
395
+ `);function Fs({config:e,cwd:t,onAuthError:n}){let r=Uf(),{height:o,width:a}=Ve(),{config:s,devSessionId:i,syncError:l,syncing:c}=cs({config:e,cwd:t}),d=fs({config:s,cwd:t,devSessionId:i}),[p]=_f({query:Bf,variables:{devSessionId:i,projectId:s.projectId,take:20}});$f({query:Df,variables:{projectId:s.projectId}});let u=p.error?.message.includes("Not authorized")===!0;Of(()=>{u&&n()},[u,n]);let m=p.data?.projectRuns??[],y=p.error==null&&!p.fetching,[g,S]=If(0),b=m[g]?.id;return jf((C,L)=>{C==="q"&&r.exit(),Ff({key:L,runs:m,selectedIndex:g,setSelectedIndex:S})}),Xt(Je,{flexDirection:"column",height:o,width:a,children:[xe(Bs,{activeRunCount:d.activeRunCount,connected:d.connected,ripploServerUrl:s.ripploServerUrl,syncError:l,width:a}),Xt(Je,{flexGrow:1,padding:1,children:[Xt(Je,{flexDirection:"column",flexShrink:0,minWidth:40,width:40,children:[xe(xs,{}),xe(Je,{borderBottom:!1,borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,marginY:1}),xe(Cs,{cwd:t})]}),Xt(Je,{borderBottom:!1,borderLeft:!0,borderRight:!1,borderStyle:"single",borderTop:!1,flexDirection:"column",flexGrow:1,paddingLeft:1,children:[xe(js,{connected:y,runs:m,selectedIndex:g,syncing:c}),b==null?null:xe(Je,{borderStyle:"round",flexDirection:"column",flexGrow:1,marginTop:1,paddingX:1,children:xe(Es,{runId:b})})]})]})]})}function Ff({key:e,runs:t,setSelectedIndex:n}){e.upArrow&&n(r=>Math.max(0,r-1)),e.downArrow&&n(r=>Math.min(t.length-1,r+1))}import{useEffect as Mf,useState as yt}from"react";import{Box as Le,Text as vr,useInput as Gf}from"ink";import{Text as Vs}from"ink";import Vf from"ink-spinner";import{jsx as Ws,jsxs as qf}from"react/jsx-runtime";var Wf="#24CFFF";function qs({loading:e}){return e?qf(Vs,{color:Wf,children:[Ws(Vf,{type:"dots"})," Starting..."]}):Ws(Vs,{children:""})}import{jsx as Se,jsxs as Cr}from"react/jsx-runtime";var Kt=[" 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 "],Ms="#24CFFF",Jf="ripplo";function Gs({onDismiss:e}){let{height:t,width:n}=Ve(),[r,o]=yt(0),[a,s]=yt(!1),[i,l]=yt(!1),[c,d]=yt(!1),[p,u]=yt(!1);Gf(()=>{p&&e()}),Mf(()=>{let g=80+Kt.length*70+80,S=[...Kt.map((k,b)=>setTimeout(()=>{o(b+1)},80+b*70)),setTimeout(()=>{s(!0)},g),setTimeout(()=>{l(!0)},g+200),setTimeout(()=>{d(!0)},g+400),setTimeout(()=>{d(!1),u(!0)},g+2e3),setTimeout(()=>{e()},g+2800)];return()=>{S.forEach(k=>{clearTimeout(k)})}},[e]);let m=Kt.length+5,y=Math.max(0,Math.floor((t-m)/2));return Cr(Le,{flexDirection:"column",height:t,width:n,children:[Se(Le,{height:y}),Cr(Le,{alignItems:"flex-start",flexDirection:"row",justifyContent:"center",children:[Se(Le,{flexDirection:"column",children:Kt.map((g,S)=>Se(vr,{color:Ms,children:S<r?g:""},g))}),Cr(Le,{flexDirection:"column",paddingLeft:4,paddingTop:5,children:[Se(vr,{bold:!0,color:Ms,children:a?Jf:""}),Se(Le,{marginTop:1,children:Se(vr,{color:"gray",dimColor:!0,children:i?"developer CLI":""})}),Se(Le,{marginTop:2,children:Se(qs,{loading:c})})]})]})]})}import{useCallback as xr,useEffect as Tm,useState as ht}from"react";import He from"fs";import Zt from"path";import{exec as em}from"child_process";import{createAuthClient as zf}from"better-auth/client";import{deviceAuthorizationClient as Hf}from"better-auth/client/plugins";function Yt({baseURL:e}){return zf({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[Hf()]})}import{z as Js}from"zod";var Xf="https://ripplo.ai",Kf="https://ripplo-dev.up.railway.app",Yf="https://localhost:3001",Qf={dev:Kf,local:Yf};function Hs(){let e=process.argv.findIndex(o=>o.startsWith("--env"));if(e===-1)return gt().RIPPLO_SERVER_URL;let t=process.argv[e];if(t==null)return gt().RIPPLO_SERVER_URL;let n=t.includes("=")?t.split("=")[1]:process.argv[e+1];if(n==null)return gt().RIPPLO_SERVER_URL;let r=Qf[n];if(r==null)throw new Error(`Unknown env "${n}". Use "dev" or "local".`);return r}var Zf=Js.object({RIPPLO_SERVER_URL:Js.string().min(1).default(Xf)}),zs;function gt(){return zs??=Zf.parse(process.env),zs}var tm=5e3,Xs="ripplo-cli";async function Ks({onDeviceCode:e,url:t}){let n=t??gt().RIPPLO_SERVER_URL,r=Yt({baseURL:n}),o=await r.device.code({client_id:Xs});if(o.error!=null)throw new Error(`Failed to request device code: ${o.error.error_description}`);let{device_code:a,user_code:s,verification_uri_complete:i}=o.data;e({userCode:s,verificationUrl:i}),im(i);let l=await nm({authClient:r,deviceCode:a}),c=ue(),d=c==null?{baseUrl:"",cloudBaseUrl:"",preconditionApiPath:"",projectId:"",ripploServerUrl:n,token:l,webhookSecret:""}:{baseUrl:c.baseUrl,cloudBaseUrl:c.cloudBaseUrl,preconditionApiPath:c.preconditionApiPath,projectId:c.projectId,ripploServerUrl:n,token:l,webhookSecret:c.webhookSecret};return be(d),d}async function nm({authClient:e,deviceCode:t}){for(;;){await am(tm);let n=await e.device.token({client_id:Xs,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(!om(n.error.error))throw new Error(`Authorization failed: ${n.error.error_description}`)}}var rm=new Set(["authorization_pending","slow_down"]);function om(e){return rm.has(e)}function am(e){return new Promise(t=>{setTimeout(t,e)})}function sm(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function im(e){let t=sm();em(`${t} "${e}"`,()=>{})}import ne from"fs";import Y from"path";import{fileURLToPath as ti}from"url";import{z as X}from"zod";import{McpServer as vT}from"@modelcontextprotocol/sdk/server/mcp.js";import{z as xT}from"zod";import{z as H}from"zod";var lm=H.object({additionalProperties:H.unknown().optional(),properties:H.record(H.string(),H.record(H.string(),H.unknown())).optional(),required:H.array(H.string()).optional(),type:H.string().optional()}),PN=H.object({oneOf:H.array(lm).optional()});function cm(){return`---
396
396
 
397
397
  ## Referenced Schemas
398
398
 
399
- ${[ze("Locator",N),ze("StringValueRef",O),ze("NumericValueRef",je),ze("ComparisonOperator",W),ze("NumericOperator",fe),ze("Condition",_e)].join(`
399
+ ${[ze("Locator",N),ze("StringValueRef",I),ze("NumericValueRef",je),ze("ComparisonOperator",W),ze("NumericOperator",fe),ze("Condition",_e)].join(`
400
400
 
401
- `)}`}var LN=im();function ze(e,t){return`### ${e}
401
+ `)}`}var EN=cm();function ze(e,t){return`### ${e}
402
402
 
403
403
  \`\`\`json
404
404
  ${JSON.stringify(H.toJSONSchema(t),null,2)}
405
- \`\`\``}var PN=["## try","","The `try` node uses a refinement: at least one of `catch` or `finally` is required.","","Fields: body (required), catch? (optional), finally? (optional)","Plus base fields: id, type, next?, timeout?, label?, comment?"].join(`
406
- `);import{graphql as Qt,readFragment as jN}from"gql.tada";import Xs from"figures";var lm={cross:Xs.cross,tick:Xs.tick};var cm=Qt(`
405
+ \`\`\``}var ON=["## try","","The `try` node uses a refinement: at least one of `catch` or `finally` is required.","","Fields: body (required), catch? (optional), finally? (optional)","Plus base fields: id, type, next?, timeout?, label?, comment?"].join(`
406
+ `);import{graphql as Qt,readFragment as $N}from"gql.tada";import Ys from"figures";var dm={cross:Ys.cross,tick:Ys.tick};var pm=Qt(`
407
407
  fragment WorkflowIdMCP on Workflow {
408
408
  id
409
409
  slug
410
410
  }
411
- `),BN=Qt(`
411
+ `),FN=Qt(`
412
412
  query ProjectWorkflowIdsMCP($projectId: String!) {
413
413
  project(id: $projectId) {
414
414
  id
@@ -420,14 +420,14 @@ ${JSON.stringify(H.toJSONSchema(t),null,2)}
420
420
  }
421
421
  }
422
422
  }
423
- `,[cm]),DN=Qt(`
423
+ `,[pm]),VN=Qt(`
424
424
  mutation CreateRunMCP($workflowId: String!, $platforms: [String!]!, $concurrency: Int!) {
425
425
  createRun(workflowId: $workflowId, platforms: $platforms, concurrency: $concurrency) {
426
426
  id
427
427
  status
428
428
  }
429
429
  }
430
- `),FN=Qt(`
430
+ `),WN=Qt(`
431
431
  query RunStatusMCP($id: String!) {
432
432
  run(id: $id) {
433
433
  id
@@ -454,20 +454,23 @@ ${JSON.stringify(H.toJSONSchema(t),null,2)}
454
454
  }
455
455
  }
456
456
  }
457
- `);import{z as qN}from"zod";var Ks={assertAttribute:"assertion",assertChecked:"assertion",assertCookie:"assertion",assertCount:"assertion",assertDisabled:"assertion",assertEnabled:"assertion",assertFocused:"assertion",assertNotChecked:"assertion",assertNotVisible:"assertion",assertResponse:"assertion",assertText:"assertion",assertTitle:"assertion",assertUrl:"assertion",assertValue:"assertion",assertVisible:"assertion",check:"action",clear:"action",click:"action",clipboard:"other",dblclick:"action",drag:"action",extractText:"other",fail:"other",fill:"action",focus:"action",forEach:"controlFlow",goto:"other",group:"controlFlow",handleDialog:"action",hover:"action",if:"controlFlow",loop:"controlFlow",parallel:"controlFlow",press:"action",rightClick:"action",screenshot:"other",scroll:"action",scrollIntoView:"action",select:"action",setPermission:"other",setVariable:"other",setViewport:"other",try:"controlFlow",type:"action",uncheck:"action",upload:"action",wait:"other",waitFor:"other",waitForRequest:"other",waitForResponse:"other",waitForUrl:"other"},dm=new Set,pm=new Set;Object.entries(Ks).forEach(([e,t])=>{t==="assertion"&&dm.add(e),t==="action"&&pm.add(e)});var um=new Set,fm=new Set;Object.entries(Ks).forEach(([e,t])=>{t==="controlFlow"&&um.add(e),t==="assertion"&&fm.add(e)});var zN=["","## Review Instructions","Compare the **Declared Intent** against the **Workflow Steps** and answer these questions:","","1. Does the workflow actually test the **Expected Outcome**? Look at the assertions \u2014 do they verify that the expected outcome was achieved, or do they only check intermediate states?","2. Does the workflow exercise the flow described in **Description**? Are the right forms filled, buttons clicked, and pages navigated?","3. Are there assertions after the key state-changing action (e.g., after form submission, after deletion, after creation)? The final result should be verified, not just that a button was clicked.","4. If there are **Additional Checks**, does the workflow have assertions that cover them?","5. Could this workflow pass even if the feature is broken? For example, if it only asserts a page loaded but never checks the actual outcome.","","If any answer is NO, revise the workflow to address the gap. Then call `validate` and `review_workflow` again."].join(`
458
- `);import KN from"fs";import QN from"path";import nT from"fs";import oT from"path";var Qs=["get_graph_documentation","get_node_schema","get_precondition_schema","get_spec_documentation","get_spec_patterns","review_workflow","run","validate"];var mm=X.looseObject({mcpServers:X.record(X.string(),X.unknown())});function ei(){let e=Y.join(process.cwd(),".mcp.json"),t=ym()?{args:[gm()],command:"node"}:hm(),n=Am(e),r={...n,mcpServers:{...n.mcpServers,ripplo:t}};ne.writeFileSync(e,JSON.stringify(r,null,2)),w.info("Wrote MCP config to %s",e)}function ym(){let e=Zs(import.meta.url),t=Y.dirname(Y.dirname(e));return ne.existsSync(Y.join(t,"tsup.config.ts"))}function gm(){let e=Zs(import.meta.url),t=Y.dirname(Y.dirname(e)),n=Y.join(t,"mcp","index.js");return Y.relative(process.cwd(),n)}function hm(){return process.platform==="win32"?{args:["/c","npx","-y","--package","ripplo@latest","ripplo-mcp"],command:"cmd"}:{args:["-y","--package","ripplo@latest","ripplo-mcp"],command:"npx"}}var wm=X.looseObject({permissions:X.looseObject({allow:X.array(X.string())}).optional()}),Sm=X.record(X.string(),X.looseObject({autoApproveTools:X.array(X.string()).optional()}));function ti(){let e=process.cwd(),t=[];return ne.existsSync(Y.join(e,".claude"))&&(km(e),t.push(".claude/settings.json")),ne.existsSync(Y.join(e,".vscode","cline_mcp_settings.json"))&&(bm(e),t.push(".vscode/cline_mcp_settings.json")),t}function km(e){let t=Y.join(e,".claude","settings.json"),n="mcp__ripplo__*",r=ni(t,wm,{}),o=r.permissions?.allow??[];if(o.includes(n))return;let a={...r,permissions:{...r.permissions,allow:[...o,n]}};ne.writeFileSync(t,JSON.stringify(a,null,2)+`
459
- `)}function bm(e){let t=Y.join(e,".vscode","cline_mcp_settings.json"),n=ni(t,Sm,{}),r=n.ripplo??{},o={...n,ripplo:{...r,autoApproveTools:[...Qs]}};ne.writeFileSync(t,JSON.stringify(o,null,2)+`
460
- `)}function ni(e,t,n){if(!ne.existsSync(e))return n;let r=JSON.parse(ne.readFileSync(e,"utf8")),o=t.safeParse(r);return o.success?o.data:n}function Am(e){if(!ne.existsSync(e))return{mcpServers:{}};let t=JSON.parse(ne.readFileSync(e,"utf8")),n=mm.safeParse(t);return n.success?n.data:{mcpServers:{}}}function ri({cwd:e,initialConfig:t,serverUrl:n}){let[r,o]=ht(t==null?"login":"validating"),[a,s]=ht(t),[i,l]=ht(),[c,d]=ht(!1),[f,u]=ht();Rm(()=>{if(t==null)return;Yt({baseURL:n}).getSession({fetchOptions:{headers:{Authorization:`Bearer ${t.token}`}}}).then(k=>{if(k.data==null){s(void 0),o("login");return}o("complete")})},[t,n]);let m=vr(()=>{c||(d(!0),l(void 0),Hs({onDeviceCode:u,url:n}).then(S=>{s(S),o("select-project")}).catch(S=>{d(!1),u(void 0),l(S instanceof Error?S.message:String(S))}))},[c,n]),y=vr(S=>{if(a==null)return;o("scaffolding"),l(void 0);let k=a.webhookSecret.length>0?a.webhookSecret:at(),b={...a,baseUrl:S.baseUrl,cloudBaseUrl:S.cloudBaseUrl,projectId:S.id,webhookSecret:k};Nm({config:b,cwd:e}).then(()=>{s(b),o("complete")}).catch(C=>{l(C instanceof Error?C.message:String(C)),o("select-project")})},[a,e]),h=vr(()=>{s(void 0),o("login"),d(!1),u(void 0),l(void 0)},[]);return{config:a,deviceCodeInfo:f,error:i,loginStarted:c,resetToLogin:h,selectProject:y,setStage:o,stage:r,startLogin:m}}async function Nm({config:e,cwd:t}){be(e),vm(t),ei(),ti(),await Tn()}var Tm={edges:[],preconditions:{},states:{},version:3};function vm(e){let t=Zt.join(e,".ripplo"),n=Zt.join(t,"graph.json"),r=Zt.join(t,"workflows");He.mkdirSync(r,{recursive:!0}),He.existsSync(n)||He.writeFileSync(n,JSON.stringify(Tm,null,2)+`
461
- `),xm(e)}var Cm=[".ripplo/debug/",".ripplo/settings.local.json"];function xm(e){let t=Zt.join(e,".gitignore");if(!He.existsSync(t))return;let n=He.readFileSync(t,"utf8"),r=Cm.filter(a=>!n.includes(a));if(r.length===0)return;let o=n.endsWith(`
457
+ `);import{z as GN}from"zod";var Qs={assertAttribute:"assertion",assertChecked:"assertion",assertCookie:"assertion",assertCount:"assertion",assertDisabled:"assertion",assertEnabled:"assertion",assertFocused:"assertion",assertNotChecked:"assertion",assertNotVisible:"assertion",assertResponse:"assertion",assertText:"assertion",assertTitle:"assertion",assertUrl:"assertion",assertValue:"assertion",assertVisible:"assertion",check:"action",clear:"action",click:"action",clipboard:"other",dblclick:"action",drag:"action",extractText:"other",fail:"other",fill:"action",focus:"action",forEach:"controlFlow",goto:"other",group:"controlFlow",handleDialog:"action",hover:"action",if:"controlFlow",loop:"controlFlow",parallel:"controlFlow",press:"action",rightClick:"action",screenshot:"other",scroll:"action",scrollIntoView:"action",select:"action",setPermission:"other",setVariable:"other",setViewport:"other",try:"controlFlow",type:"action",uncheck:"action",upload:"action",wait:"other",waitFor:"other",waitForRequest:"other",waitForResponse:"other",waitForUrl:"other"},um=new Set,fm=new Set;Object.entries(Qs).forEach(([e,t])=>{t==="assertion"&&um.add(e),t==="action"&&fm.add(e)});var mm=new Set,ym=new Set;Object.entries(Qs).forEach(([e,t])=>{t==="controlFlow"&&mm.add(e),t==="assertion"&&ym.add(e)});var XN=["","## Review Instructions","Compare the **Declared Intent** against the **Workflow Steps** and answer these questions:","","1. Does the workflow actually test the **Expected Outcome**? Look at the assertions \u2014 do they verify that the expected outcome was achieved, or do they only check intermediate states?","2. Does the workflow exercise the flow described in **Description**? Are the right forms filled, buttons clicked, and pages navigated?","3. Are there assertions after the key state-changing action (e.g., after form submission, after deletion, after creation)? The final result should be verified, not just that a button was clicked.","4. If there are **Additional Checks**, does the workflow have assertions that cover them?","5. Could this workflow pass even if the feature is broken? For example, if it only asserts a page loaded but never checks the actual outcome.","","If any answer is NO, revise the workflow to address the gap. Then call `validate` and `review_workflow` again."].join(`
458
+ `);import QN from"fs";import eT from"path";import oT from"fs";import sT from"path";var ei=["get_graph_documentation","get_node_schema","get_precondition_schema","get_spec_documentation","get_spec_patterns","review_workflow","run","validate"];var gm=X.looseObject({mcpServers:X.record(X.string(),X.unknown())});function ni(){let e=Y.join(process.cwd(),".mcp.json"),t=hm()?{args:[wm()],command:"node"}:Sm(),n=Nm(e),r={...n,mcpServers:{...n.mcpServers,ripplo:t}};ne.writeFileSync(e,JSON.stringify(r,null,2)),w.info("Wrote MCP config to %s",e)}function hm(){let e=ti(import.meta.url),t=Y.dirname(Y.dirname(e));return ne.existsSync(Y.join(t,"tsup.config.ts"))}function wm(){let e=ti(import.meta.url),t=Y.dirname(Y.dirname(e)),n=Y.join(t,"mcp","index.js");return Y.relative(process.cwd(),n)}function Sm(){return process.platform==="win32"?{args:["/c","npx","-y","--package","ripplo@latest","ripplo-mcp"],command:"cmd"}:{args:["-y","--package","ripplo@latest","ripplo-mcp"],command:"npx"}}var km=X.looseObject({permissions:X.looseObject({allow:X.array(X.string())}).optional()}),bm=X.record(X.string(),X.looseObject({autoApproveTools:X.array(X.string()).optional()}));function ri(){let e=process.cwd(),t=[];return ne.existsSync(Y.join(e,".claude"))&&(Am(e),t.push(".claude/settings.json")),ne.existsSync(Y.join(e,".vscode","cline_mcp_settings.json"))&&(Rm(e),t.push(".vscode/cline_mcp_settings.json")),t}function Am(e){let t=Y.join(e,".claude","settings.json"),n="mcp__ripplo__*",r=oi(t,km,{}),o=r.permissions?.allow??[];if(o.includes(n))return;let a={...r,permissions:{...r.permissions,allow:[...o,n]}};ne.writeFileSync(t,JSON.stringify(a,null,2)+`
459
+ `)}function Rm(e){let t=Y.join(e,".vscode","cline_mcp_settings.json"),n=oi(t,bm,{}),r=n.ripplo??{},o={...n,ripplo:{...r,autoApproveTools:[...ei]}};ne.writeFileSync(t,JSON.stringify(o,null,2)+`
460
+ `)}function oi(e,t,n){if(!ne.existsSync(e))return n;let r=JSON.parse(ne.readFileSync(e,"utf8")),o=t.safeParse(r);return o.success?o.data:n}function Nm(e){if(!ne.existsSync(e))return{mcpServers:{}};let t=JSON.parse(ne.readFileSync(e,"utf8")),n=gm.safeParse(t);return n.success?n.data:{mcpServers:{}}}function ai({cwd:e,initialConfig:t,serverUrl:n}){let[r,o]=ht(t==null?"login":"validating"),[a,s]=ht(t),[i,l]=ht(),[c,d]=ht(!1),[p,u]=ht();Tm(()=>{if(t==null)return;Yt({baseURL:n}).getSession({fetchOptions:{headers:{Authorization:`Bearer ${t.token}`}}}).then(k=>{if(k.data==null){s(void 0),o("login");return}o("complete")})},[t,n]);let m=xr(()=>{c||(d(!0),l(void 0),Ks({onDeviceCode:u,url:n}).then(S=>{s(S),o("select-project")}).catch(S=>{d(!1),u(void 0),l(S instanceof Error?S.message:String(S))}))},[c,n]),y=xr(S=>{if(a==null)return;o("scaffolding"),l(void 0);let k=a.webhookSecret.length>0?a.webhookSecret:at(),b={...a,baseUrl:S.baseUrl,cloudBaseUrl:S.cloudBaseUrl,projectId:S.id,webhookSecret:k};vm({config:b,cwd:e}).then(()=>{s(b),o("complete")}).catch(C=>{l(C instanceof Error?C.message:String(C)),o("select-project")})},[a,e]),g=xr(()=>{s(void 0),o("login"),d(!1),u(void 0),l(void 0)},[]);return{config:a,deviceCodeInfo:p,error:i,loginStarted:c,resetToLogin:g,selectProject:y,setStage:o,stage:r,startLogin:m}}async function vm({config:e,cwd:t}){be(e),xm(t),ni(),ri(),await vn()}var Cm={edges:[],preconditions:{},states:{},version:3};function xm(e){let t=Zt.join(e,".ripplo"),n=Zt.join(t,"graph.json"),r=Zt.join(t,"workflows");He.mkdirSync(r,{recursive:!0}),He.existsSync(n)||He.writeFileSync(n,JSON.stringify(Cm,null,2)+`
461
+ `),Pm(e)}var Lm=[".ripplo/debug/",".ripplo/settings.local.json"];function Pm(e){let t=Zt.join(e,".gitignore");if(!He.existsSync(t))return;let n=He.readFileSync(t,"utf8"),r=Lm.filter(a=>!n.includes(a));if(r.length===0)return;let o=n.endsWith(`
462
462
  `)?"":`
463
463
  `;He.writeFileSync(t,n+o+r.join(`
464
464
  `)+`
465
- `)}import{jsx as re,jsxs as Em}from"react/jsx-runtime";function si({cwd:e,initialConfig:t,serverUrl:n}){let[r,o]=Pm(!0),a=ri({cwd:e,initialConfig:t,serverUrl:n}),{height:s,width:i}=Ve(),l=Lm(()=>{o(!1)},[]);if(r)return re(qs,{onDismiss:l});if(a.stage==="validating")return re(oi,{alignItems:"center",height:s,justifyContent:"center",width:i,children:Em(Cr,{children:[re(Cr,{color:"yellow",children:"* "}),re(Cr,{children:"Validating session..."})]})});if(a.stage==="login"||a.config==null)return re(oi,{alignItems:"center",height:s,justifyContent:"center",width:i,children:re(Ga,{deviceCodeInfo:a.deviceCodeInfo,error:a.error,loginStarted:a.loginStarted,startLogin:a.startLogin})});let c=qa({config:a.config});return ii({client:c,projectId:a.config.projectId}),a.stage==="complete"?re(ai,{value:c,children:re(Bs,{config:a.config,cwd:e,onAuthError:a.resetToLogin})}):re(ai,{value:c,children:re(Ya,{config:a.config,error:a.error,selectProject:a.selectProject,stage:a.stage})})}var jm=Um(`
465
+ `)}import{jsx as re,jsxs as Im}from"react/jsx-runtime";function li({cwd:e,initialConfig:t,serverUrl:n}){let[r,o]=Om(!0),a=ai({cwd:e,initialConfig:t,serverUrl:n}),{height:s,width:i}=Ve(),l=Em(()=>{o(!1)},[]);if(r)return re(Gs,{onDismiss:l});if(a.stage==="validating")return re(si,{alignItems:"center",height:s,justifyContent:"center",width:i,children:Im(Lr,{children:[re(Lr,{color:"yellow",children:"* "}),re(Lr,{children:"Validating session..."})]})});if(a.stage==="login"||a.config==null)return re(si,{alignItems:"center",height:s,justifyContent:"center",width:i,children:re(za,{deviceCodeInfo:a.deviceCodeInfo,error:a.error,loginStarted:a.loginStarted,startLogin:a.startLogin})});let c=Ga({config:a.config});return ci({client:c,projectId:a.config.projectId}),a.stage==="complete"?re(ii,{value:c,children:re(Fs,{config:a.config,cwd:e,onAuthError:a.resetToLogin})}):re(ii,{value:c,children:re(Za,{config:a.config,error:a.error,selectProject:a.selectProject,stage:a.stage})})}var $m=_m(`
466
466
  mutation EndDevSessionExit($projectId: String!) {
467
467
  endDevSession(projectId: $projectId) {
468
468
  id
469
469
  }
470
470
  }
471
- `),Lr,Pr;function ii({client:e,projectId:t}){Lr=e,Pr=t}function _m(){if(Lr==null||Pr==null)return Promise.resolve();let e=Lr.mutation(jm,{projectId:Pr}).toPromise().then(()=>{}).catch(()=>{}),t=new Promise(n=>{setTimeout(n,3e3)});return Promise.race([e,t])}function ci(){let e=process.cwd(),t=xr.join(e,".ripplo","debug"),n=xr.join(t,"last-crash.log");function r(s){li.mkdirSync(t,{recursive:!0});let i=s instanceof Error?s.stack??s.message:String(s);li.writeFileSync(n,`${new Date().toISOString()}
471
+ `),Er,Or;function ci({client:e,projectId:t}){Er=e,Or=t}function Bm(){if(Er==null||Or==null)return Promise.resolve();let e=Er.mutation($m,{projectId:Or}).toPromise().then(()=>{}).catch(()=>{}),t=new Promise(n=>{setTimeout(n,3e3)});return Promise.race([e,t])}function di(){let e=process.cwd(),t=Pr.join(e,".ripplo","debug"),n=Pr.join(t,"last-crash.log");function r(s){en.mkdirSync(t,{recursive:!0});let i=s instanceof Error?s.stack??s.message:String(s);en.writeFileSync(n,`${new Date().toISOString()}
472
472
  ${i}
473
- `),process.exit(1)}let o;try{let s=ue(),i=Js();bn({filePath:xr.join(t,"debug.log")}),o=Im(Om.createElement(si,{cwd:e,initialConfig:s??void 0,serverUrl:i}),{alternateScreen:!0}),o.waitUntilExit().then(()=>_m()).then(()=>{process.exit(0)})}catch(s){r(s)}let a=!1;process.on("SIGINT",()=>{a||(a=!0,o?.unmount())}),process.on("SIGTERM",()=>{a||(a=!0,o?.unmount())}),process.on("uncaughtException",s=>{r(s)}),process.on("unhandledRejection",s=>{r(s)})}var pi=en.resolve(en.dirname($m(import.meta.url)),"..");di({path:en.join(pi,".env.local"),quiet:!0});di({path:en.join(pi,".env"),quiet:!0});function Bm(){if(process.argv[2]==="generate-types"){Dm();return}ci()}function Dm(){let e=Fm();Fa(e)}function Fm(){let e=process.argv.slice(3),t=e.indexOf("--output"),n=t===-1?void 0:e[t+1];return{graphPath:e.find(o=>!o.startsWith("--")&&o!==n),outputPath:n}}Bm();export{Bm as main};
473
+ `),process.exit(1)}let o;try{let s=ue(),i=Hs();An({filePath:Pr.join(t,"debug.log")}),o=jm(Um.createElement(li,{cwd:e,initialConfig:s??void 0,serverUrl:i}),{alternateScreen:!0}),o.waitUntilExit().then(()=>Bm()).then(()=>{process.exit(0)})}catch(s){r(s)}let a=!1;process.on("SIGINT",()=>{a||(a=!0,o?.unmount())}),process.on("SIGTERM",()=>{a||(a=!0,o?.unmount())}),process.on("uncaughtException",s=>{r(s)}),process.on("unhandledRejection",s=>{try{en.mkdirSync(t,{recursive:!0});let i=s instanceof Error?s.stack??s.message:String(s);en.appendFileSync(n,`${new Date().toISOString()} [unhandledRejection]
474
+ ${i}
475
+
476
+ `)}catch{}})}var ui=tn.resolve(tn.dirname(Dm(import.meta.url)),"..");pi({path:tn.join(ui,".env.local"),quiet:!0});pi({path:tn.join(ui,".env"),quiet:!0});function Fm(){if(process.argv[2]==="generate-types"){Vm();return}di()}function Vm(){let e=Wm();Wa(e)}function Wm(){let e=process.argv.slice(3),t=e.indexOf("--output"),n=t===-1?void 0:e[t+1];return{graphPath:e.find(o=>!o.startsWith("--")&&o!==n),outputPath:n}}Fm();export{Fm as main};