ripplo 0.7.19 → 0.7.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-7UWDMECF.js +2 -0
- package/dist/{chunk-WNUKCEN6.js → chunk-BJVAPI4P.js} +1 -1
- package/dist/chunk-EVYYSTR7.js +46 -0
- package/dist/chunk-IHSHBPJY.js +2 -0
- package/dist/chunk-OX6IWNCA.js +206 -0
- package/dist/chunk-R7CQWEBF.js +167 -0
- package/dist/daemon-2E6MKBO7.js +62 -0
- package/dist/daemon-APJHNVIG.js +2 -0
- package/dist/daemon-tunnel-AG6FGNXC.js +2 -0
- package/dist/gifenc.esm-GMV2LJ5K.js +2 -0
- package/dist/index.js +185 -194
- package/package.json +6 -6
- package/dist/chunk-7R7PWDYF.js +0 -137
- package/dist/chunk-APGFYCJC.js +0 -200
- package/dist/chunk-SB7H6IAS.js +0 -2
- package/dist/chunk-Y5IXMRSB.js +0 -46
- package/dist/daemon-EQZROAKJ.js +0 -2
- package/dist/daemon-EUZ4KVQP.js +0 -61
- package/dist/daemon-tunnel-MOYCRSSC.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var l=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&f(b,d,{get:()=>a[d],enumerable:!(e=h(a,d))||e.enumerable});return b};var n=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{d as p,e as a}from"./chunk-
|
|
2
|
+
import{d as p,e as a}from"./chunk-EVYYSTR7.js";import{graphql as y}from"gql.tada";import{execFileSync as S,spawn as T}from"child_process";import{existsSync as m}from"fs";var g=2e3,w=["/opt/homebrew/bin/cloudflared","/usr/local/bin/cloudflared","/usr/bin/cloudflared"],d=class extends Error{};function v({token:n}){let e=h(),i=!1,r,o,s=()=>{if(i)return;let t=T(e,["tunnel","--no-autoupdate","run"],{env:{...process.env,TUNNEL_TOKEN:n},stdio:"ignore"});r=t,t.on("error",l=>{a.warn({err:l},"cloudflared spawn failed"),f()}),t.on("exit",(l,c)=>{a.warn({code:l,signal:c},"cloudflared exited"),r=void 0,f()})},f=()=>{i||o!=null||(o=setTimeout(()=>{o=void 0,s()},g))};return s(),{stop:async()=>{i=!0,o!=null&&(clearTimeout(o),o=void 0);let t=r;t!=null&&(t.kill("SIGTERM"),await new Promise(l=>{let c=setTimeout(()=>{t.kill("SIGKILL"),l()},5e3);t.on("exit",()=>{clearTimeout(c),l()})}))}}}function h(){let n=w.find(e=>m(e));if(n!=null)return n;try{let e=S("/usr/bin/env",["which","cloudflared"],{encoding:"utf8"}).trim();if(e.length>0&&m(e))return e}catch{throw new d}throw new d}var P=y(`
|
|
3
3
|
mutation ReleaseDevTunnel($devSessionId: String!) {
|
|
4
4
|
releaseDevTunnel(devSessionId: $devSessionId)
|
|
5
5
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as q}from"./chunk-IHSHBPJY.js";import{b as G}from"./chunk-7UWDMECF.js";import{execFileSync as O}from"child_process";import U from"fs";import p from"path";function F(e){let r=L(e);return r??P(e)}function P(e){let r=p.dirname(e);return N(p.join(e,".ripplo"))?e:r===e?null:P(r)}function N(e){try{return U.statSync(e).isDirectory()}catch{return!1}}function L(e){let r=j(["rev-parse","--show-toplevel"],e);if(r==null)return null;let t=r.trim();return t.length===0?null:p.isAbsolute(t)?t:p.resolve(e,t)}function j(e,r){try{return O("git",e,{cwd:r,encoding:"utf8",stdio:["ignore","pipe","ignore"]})}catch{return null}}var f=class extends Error{detail;serverUrl;constructor({detail:r,serverUrl:t}){super(`Failed to connect to Ripplo server at ${t}. Check the server is running and reachable. Details: ${r}`),this.name="GqlConnectionError",this.detail=r,this.serverUrl=t}},c=class extends Error{errors;constructor(r){super(r.map(t=>t.message).join(", ")),this.name="GqlRequestError",this.errors=r}};function B(e){if(e instanceof c)return e.errors[0]?.extensions?.code}async function x(e){let{print:r}=await import("graphql"),t=r(e.document),n=JSON.stringify({query:t,variables:e.variables}),o=`${e.config.ripploServerUrl}/graphql`,d=await W({init:{body:n,headers:{Authorization:`Bearer ${e.config.token}`,"Content-Type":"application/json"},method:"POST"},serverUrl:e.config.ripploServerUrl,url:o}),s=await Q({res:d,url:o});if(!J(s))throw new Error("Invalid GraphQL response");if(K(s))throw new c(s.errors);if(s.data==null)throw new Error("No data returned from server");return s.data}async function W({init:e,serverUrl:r,url:t}){let n=1,o=await E({init:e,url:t});for(;o.retryable&&n<3;)await H(V(n)),n+=1,o=await E({init:e,url:t});if(o.response!=null)return o.response;throw new f({detail:o.detail,serverUrl:r})}async function E({init:e,url:r}){try{let t=await fetch(r,{...e,signal:AbortSignal.timeout(15e3)});return{detail:"",response:t,retryable:t.status>=500}}catch(t){return{detail:t instanceof Error?t.message:String(t),response:void 0,retryable:!0}}}function V(e){return 300*3**(e-1)*(.5+Math.random())}function H(e){return new Promise(r=>{setTimeout(r,e)})}async function Q({res:e,url:r}){let t=await e.text();if(t.length===0)throw new Error(`Empty response from Ripplo server at ${r} (status ${String(e.status)}). The server may have restarted or the request was rejected before a body was sent.`);try{return JSON.parse(t)}catch{throw new Error(`Non-JSON response from Ripplo server at ${r} (status ${String(e.status)}): ${t.slice(0,200)}`)}}function J(e){return typeof e=="object"&&e!=null&&("data"in e||"errors"in e)}function K(e){return Array.isArray(e.errors)&&e.errors.length>0}import X from"pino";import z from"pino-pretty";var y=X({level:process.env.LOG_LEVEL??"info"},z({ignore:"pid,hostname"}));import{readdir as Y,rm as Z,stat as ee}from"fs/promises";import k from"path";var b=k.join(process.cwd(),".ripplo","debug"),T=360*60*1e3;async function re({maxRuns:e}){try{let t=(await Y(b,{withFileTypes:!0})).filter(i=>i.isDirectory()),n=Date.now(),o=await Promise.all(t.map(async i=>{let m=k.join(b,i.name),$=await ee(m);return{dirPath:m,mtime:$.mtimeMs}})),d=o.filter(i=>n-i.mtime>T),M=o.filter(i=>n-i.mtime<=T).toSorted((i,m)=>m.mtime-i.mtime).slice(e),R=[...d,...M];if(R.length===0)return;await Promise.allSettled(R.map(i=>Z(i.dirPath,{force:!0,recursive:!0}))),y.debug("Pruned %d old debug run(s)",R.length)}catch{y.warn("Debug run pruning failed, ignoring")}}import{Agent as te,RetryAgent as ne,setGlobalDispatcher as oe}from"undici";var ie=1500,se=4e3,ae=3,le=50,de=100,C=!1;function ce(){if(C)return;C=!0;let e=new te({connections:de,keepAliveMaxTimeout:se,keepAliveTimeout:ie}),r=new ne(e,{errorCodes:["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_REQ_CONTENT_LENGTH_MISMATCH","UND_ERR_SOCKET"],maxRetries:ae,methods:["GET","POST","HEAD","OPTIONS","PUT","DELETE"],minTimeout:le});oe(r)}import{graphql as u}from"gql.tada";var Ue=u(`
|
|
3
|
+
query AgentReviewContextWorker($reviewId: String!) {
|
|
4
|
+
agentReview(id: $reviewId) {
|
|
5
|
+
id
|
|
6
|
+
runId
|
|
7
|
+
agentProfile {
|
|
8
|
+
id
|
|
9
|
+
name
|
|
10
|
+
description
|
|
11
|
+
output
|
|
12
|
+
successCriteria
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`);var Fe=u(`
|
|
17
|
+
mutation StartAgentReviewWorker($reviewId: String!) {
|
|
18
|
+
startAgentReview(reviewId: $reviewId)
|
|
19
|
+
}
|
|
20
|
+
`);var Ne=u(`
|
|
21
|
+
mutation CompleteAgentReviewWorker(
|
|
22
|
+
$reviewId: String!
|
|
23
|
+
$markdown: String!
|
|
24
|
+
$shortSummary: String!
|
|
25
|
+
$verdict: AgentReviewVerdict!
|
|
26
|
+
$comments: [AgentReviewCommentInput!]!
|
|
27
|
+
) {
|
|
28
|
+
completeAgentReview(
|
|
29
|
+
reviewId: $reviewId
|
|
30
|
+
markdown: $markdown
|
|
31
|
+
shortSummary: $shortSummary
|
|
32
|
+
verdict: $verdict
|
|
33
|
+
comments: $comments
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
`);var Le=u(`
|
|
37
|
+
mutation UpdateAgentReviewProgressWorker($reviewId: String!, $text: String!) {
|
|
38
|
+
updateAgentReviewProgress(reviewId: $reviewId, text: $text)
|
|
39
|
+
}
|
|
40
|
+
`);var je=u(`
|
|
41
|
+
mutation FailAgentReviewWorker($reviewId: String!, $reason: String!) {
|
|
42
|
+
failAgentReview(reviewId: $reviewId, reason: $reason)
|
|
43
|
+
}
|
|
44
|
+
`);import l from"fs";import I from"path";import a from"fs";import ue from"os";import g from"path";var ge=".local",me=".ripplo";function v(e){return g.join(e,".ripplo",ge)}function pe(e){let r=v(e);a.existsSync(r)||a.mkdirSync(r,{recursive:!0});let t=g.join(r,".gitignore");return a.existsSync(t)||a.writeFileSync(t,`*
|
|
45
|
+
`),r}function fe(e,r){return g.join(v(e),r)}function h(){return g.join(ue.homedir(),me)}function S(){let e=h();return a.existsSync(e)?a.chmodSync(e,448):a.mkdirSync(e,{mode:448,recursive:!0}),e}function A(e){return g.join(h(),e)}function ye(e){let r=process.env.RIPPLO_TOKEN;if(r!=null&&r.trim().length>0)return r.trim();let t=w(e);if(!l.existsSync(t))return null;let n=l.readFileSync(t,"utf8").trim();return n.length===0?null:n}function we({serverUrl:e,token:r}){S();let t=w(e);l.mkdirSync(I.dirname(t),{mode:448,recursive:!0}),l.writeFileSync(t,r+`
|
|
46
|
+
`,{mode:384})}function Re(e){let r=w(e);return l.existsSync(r)?(l.unlinkSync(r),!0):!1}function w(e){return A(I.join("tokens",ve(e)))}function ve(e){return new URL(e).host.replaceAll(/[^a-zA-Z0-9.]/g,"_")}var D=G(q(),1);import _ from"crypto";function he({body:e,secret:r}){let t=new D.Webhook(r),n=`msg_${_.randomUUID()}`,o=new Date,d=t.sign(n,o,e),s=Math.floor(o.getTime()/1e3);return{"webhook-id":n,"webhook-signature":d,"webhook-timestamp":String(s)}}function Se(){return`whsec_${_.randomBytes(24).toString("base64")}`}export{F as a,f as b,B as c,x as d,y as e,re as f,pe as g,fe as h,S as i,A as j,ye as k,we as l,Re as m,w as n,ce as o,he as p,Se as q};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as P}from"./chunk-7UWDMECF.js";var T=P(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.timingSafeEqual=void 0;function N(n,e=""){if(!n)throw new Error(e)}function F(n,e){if(n.byteLength!==e.byteLength)return!1;n instanceof DataView||(n=new DataView(ArrayBuffer.isView(n)?n.buffer:n)),e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),N(n instanceof DataView),N(e instanceof DataView);let r=n.byteLength,i=0,a=-1;for(;++a<r;)i|=n.getUint8(a)^e.getUint8(a);return i===0}V.timingSafeEqual=F});var W=P(S=>{"use strict";var G=S&&S.__extends||(function(){var n=function(e,r){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,a){i.__proto__=a}||function(i,a){for(var g in a)a.hasOwnProperty(g)&&(i[g]=a[g])},n(e,r)};return function(e,r){n(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})();Object.defineProperty(S,"__esModule",{value:!0});var l=256,z=(function(){function n(e){e===void 0&&(e="="),this._paddingCharacter=e}return n.prototype.encodedLength=function(e){return this._paddingCharacter?(e+2)/3*4|0:(e*8+5)/6|0},n.prototype.encode=function(e){for(var r="",i=0;i<e.length-2;i+=3){var a=e[i]<<16|e[i+1]<<8|e[i+2];r+=this._encodeByte(a>>>18&63),r+=this._encodeByte(a>>>12&63),r+=this._encodeByte(a>>>6&63),r+=this._encodeByte(a>>>0&63)}var g=e.length-i;if(g>0){var a=e[i]<<16|(g===2?e[i+1]<<8:0);r+=this._encodeByte(a>>>18&63),r+=this._encodeByte(a>>>12&63),g===2?r+=this._encodeByte(a>>>6&63):r+=this._paddingCharacter||"",r+=this._paddingCharacter||""}return r},n.prototype.maxDecodedLength=function(e){return this._paddingCharacter?e/4*3|0:(e*6+7)/8|0},n.prototype.decodedLength=function(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))},n.prototype.decode=function(e){if(e.length===0)return new Uint8Array(0);for(var r=this._getPaddingLength(e),i=e.length-r,a=new Uint8Array(this.maxDecodedLength(i)),g=0,p=0,m=0,E=0,C=0,A=0,s=0;p<i-4;p+=4)E=this._decodeChar(e.charCodeAt(p+0)),C=this._decodeChar(e.charCodeAt(p+1)),A=this._decodeChar(e.charCodeAt(p+2)),s=this._decodeChar(e.charCodeAt(p+3)),a[g++]=E<<2|C>>>4,a[g++]=C<<4|A>>>2,a[g++]=A<<6|s,m|=E&l,m|=C&l,m|=A&l,m|=s&l;if(p<i-1&&(E=this._decodeChar(e.charCodeAt(p)),C=this._decodeChar(e.charCodeAt(p+1)),a[g++]=E<<2|C>>>4,m|=E&l,m|=C&l),p<i-2&&(A=this._decodeChar(e.charCodeAt(p+2)),a[g++]=C<<4|A>>>2,m|=A&l),p<i-3&&(s=this._decodeChar(e.charCodeAt(p+3)),a[g++]=A<<6|s,m|=s&l),m!==0)throw new Error("Base64Coder: incorrect characters for decoding");return a},n.prototype._encodeByte=function(e){var r=e;return r+=65,r+=25-e>>>8&6,r+=51-e>>>8&-75,r+=61-e>>>8&-15,r+=62-e>>>8&3,String.fromCharCode(r)},n.prototype._decodeChar=function(e){var r=l;return r+=(42-e&e-44)>>>8&-l+e-43+62,r+=(46-e&e-48)>>>8&-l+e-47+63,r+=(47-e&e-58)>>>8&-l+e-48+52,r+=(64-e&e-91)>>>8&-l+e-65+0,r+=(96-e&e-123)>>>8&-l+e-97+26,r},n.prototype._getPaddingLength=function(e){var r=0;if(this._paddingCharacter){for(var i=e.length-1;i>=0&&e[i]===this._paddingCharacter;i--)r++;if(e.length<4||r>2)throw new Error("Base64Coder: incorrect padding")}return r},n})();S.Coder=z;var D=new z;function Q(n){return D.encode(n)}S.encode=Q;function X(n){return D.decode(n)}S.decode=X;var I=(function(n){G(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e.prototype._encodeByte=function(r){var i=r;return i+=65,i+=25-r>>>8&6,i+=51-r>>>8&-75,i+=61-r>>>8&-13,i+=62-r>>>8&49,String.fromCharCode(i)},e.prototype._decodeChar=function(r){var i=l;return i+=(44-r&r-46)>>>8&-l+r-45+62,i+=(94-r&r-96)>>>8&-l+r-95+63,i+=(47-r&r-58)>>>8&-l+r-48+52,i+=(64-r&r-91)>>>8&-l+r-65+0,i+=(96-r&r-123)>>>8&-l+r-97+26,i},e})(z);S.URLSafeCoder=I;var R=new I;function Z(n){return R.encode(n)}S.encodeURLSafe=Z;function ee(n){return R.decode(n)}S.decodeURLSafe=ee;S.encodedLength=function(n){return D.encodedLength(n)};S.maxDecodedLength=function(n){return D.maxDecodedLength(n)};S.decodedLength=function(n){return D.decodedLength(n)}});var K=P(($,j)=>{"use strict";(function(n,e){var r={};e(r);var i=r.default;for(var a in r)i[a]=r[a];typeof j=="object"&&typeof j.exports=="object"?j.exports=i:typeof define=="function"&&define.amd?define(function(){return i}):n.sha256=i})($,function(n){"use strict";n.__esModule=!0,n.digestLength=32,n.blockSize=64;var e=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 r(s,t,o,f,x){for(var c,u,h,_,v,d,U,b,w,y,B,O,M;x>=64;){for(c=t[0],u=t[1],h=t[2],_=t[3],v=t[4],d=t[5],U=t[6],b=t[7],y=0;y<16;y++)B=f+y*4,s[y]=(o[B]&255)<<24|(o[B+1]&255)<<16|(o[B+2]&255)<<8|o[B+3]&255;for(y=16;y<64;y++)w=s[y-2],O=(w>>>17|w<<15)^(w>>>19|w<<13)^w>>>10,w=s[y-15],M=(w>>>7|w<<25)^(w>>>18|w<<14)^w>>>3,s[y]=(O+s[y-7]|0)+(M+s[y-16]|0);for(y=0;y<64;y++)O=(((v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7))+(v&d^~v&U)|0)+(b+(e[y]+s[y]|0)|0)|0,M=((c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10))+(c&u^c&h^u&h)|0,b=U,U=d,d=v,v=_+O|0,_=h,h=u,u=c,c=O+M|0;t[0]+=c,t[1]+=u,t[2]+=h,t[3]+=_,t[4]+=v,t[5]+=d,t[6]+=U,t[7]+=b,f+=64,x-=64}return f}var i=(function(){function s(){this.digestLength=n.digestLength,this.blockSize=n.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 s.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},s.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(var t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},s.prototype.update=function(t,o){if(o===void 0&&(o=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var f=0;if(this.bytesHashed+=o,this.bufferLength>0){for(;this.bufferLength<64&&o>0;)this.buffer[this.bufferLength++]=t[f++],o--;this.bufferLength===64&&(r(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(o>=64&&(f=r(this.temp,this.state,t,f,o),o%=64);o>0;)this.buffer[this.bufferLength++]=t[f++],o--;return this},s.prototype.finish=function(t){if(!this.finished){var o=this.bytesHashed,f=this.bufferLength,x=o/536870912|0,c=o<<3,u=o%64<56?64:128;this.buffer[f]=128;for(var h=f+1;h<u-8;h++)this.buffer[h]=0;this.buffer[u-8]=x>>>24&255,this.buffer[u-7]=x>>>16&255,this.buffer[u-6]=x>>>8&255,this.buffer[u-5]=x>>>0&255,this.buffer[u-4]=c>>>24&255,this.buffer[u-3]=c>>>16&255,this.buffer[u-2]=c>>>8&255,this.buffer[u-1]=c>>>0&255,r(this.temp,this.state,this.buffer,0,u),this.finished=!0}for(var h=0;h<8;h++)t[h*4+0]=this.state[h]>>>24&255,t[h*4+1]=this.state[h]>>>16&255,t[h*4+2]=this.state[h]>>>8&255,t[h*4+3]=this.state[h]>>>0&255;return this},s.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},s.prototype._saveState=function(t){for(var o=0;o<this.state.length;o++)t[o]=this.state[o]},s.prototype._restoreState=function(t,o){for(var f=0;f<this.state.length;f++)this.state[f]=t[f];this.bytesHashed=o,this.finished=!1,this.bufferLength=0},s})();n.Hash=i;var a=(function(){function s(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var o=new Uint8Array(this.blockSize);if(t.length>this.blockSize)new i().update(t).finish(o).clean();else for(var f=0;f<t.length;f++)o[f]=t[f];for(var f=0;f<o.length;f++)o[f]^=54;this.inner.update(o);for(var f=0;f<o.length;f++)o[f]^=106;this.outer.update(o),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var f=0;f<o.length;f++)o[f]=0}return s.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},s.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},s.prototype.update=function(t){return this.inner.update(t),this},s.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},s.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},s})();n.HMAC=a;function g(s){var t=new i().update(s),o=t.digest();return t.clean(),o}n.hash=g,n.default=g;function p(s,t){var o=new a(s).update(t),f=o.digest();return o.clean(),f}n.hmac=p;function m(s,t,o,f){var x=f[0];if(x===0)throw new Error("hkdf: cannot expand more");t.reset(),x>1&&t.update(s),o&&t.update(o),t.update(f),t.finish(s),f[0]++}var E=new Uint8Array(n.digestLength);function C(s,t,o,f){t===void 0&&(t=E),f===void 0&&(f=32);for(var x=new Uint8Array([1]),c=p(t,s),u=new a(c),h=new Uint8Array(u.digestLength),_=h.length,v=new Uint8Array(f),d=0;d<f;d++)_===h.length&&(m(h,u,o,x),_=0),v[d]=h[_++];return u.clean(),h.fill(0),x.fill(0),v}n.hkdf=C;function A(s,t,o,f){for(var x=new a(s),c=x.digestLength,u=new Uint8Array(4),h=new Uint8Array(c),_=new Uint8Array(c),v=new Uint8Array(f),d=0;d*c<f;d++){var U=d+1;u[0]=U>>>24&255,u[1]=U>>>16&255,u[2]=U>>>8&255,u[3]=U>>>0&255,x.reset(),x.update(t),x.update(u),x.finish(_);for(var b=0;b<c;b++)h[b]=_[b];for(var b=2;b<=o;b++){x.reset(),x.update(_).finish(_);for(var w=0;w<c;w++)h[w]^=_[w]}for(var b=0;b<c&&d*c+b<f;b++)v[d*c+b]=h[b]}for(var d=0;d<c;d++)h[d]=_[d]=0;for(var d=0;d<4;d++)u[d]=0;return x.clean(),v}n.pbkdf2=A})});var ie=P(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.Webhook=L.WebhookVerificationError=void 0;var te=T(),J=W(),re=K(),Y=300,H=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name="ExtendableError",this.stack=new Error(e).stack}},k=class n extends H{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name="WebhookVerificationError"}};L.WebhookVerificationError=k;var q=class n{constructor(e,r){if(!e)throw new Error("Secret can't be empty.");if(r?.format==="raw")e instanceof Uint8Array?this.key=e:this.key=Uint8Array.from(e,i=>i.charCodeAt(0));else{if(typeof e!="string")throw new Error("Expected secret to be of type string");e.startsWith(n.prefix)&&(e=e.substring(n.prefix.length)),this.key=J.decode(e)}}verify(e,r){let i={};for(let t of Object.keys(r))i[t.toLowerCase()]=r[t];let a=i["webhook-id"],g=i["webhook-signature"],p=i["webhook-timestamp"];if(!g||!a||!p)throw new k("Missing required headers");let m=this.verifyTimestamp(p),C=this.sign(a,m,e).split(",")[1],A=g.split(" "),s=new globalThis.TextEncoder;for(let t of A){let[o,f]=t.split(",");if(o==="v1"&&(0,te.timingSafeEqual)(s.encode(f),s.encode(C)))return JSON.parse(e.toString())}throw new k("No matching signature found")}sign(e,r,i){if(typeof i!="string")if(i.constructor.name==="Buffer")i=i.toString();else throw new Error("Expected payload to be of type string or Buffer.");let a=new TextEncoder,g=Math.floor(r.getTime()/1e3),p=a.encode(`${e}.${g}.${i}`);return`v1,${J.encode(re.hmac(this.key,p))}`}verifyTimestamp(e){let r=Math.floor(Date.now()/1e3),i=parseInt(e,10);if(isNaN(i))throw new k("Invalid Signature Headers");if(r-i>Y)throw new k("Message timestamp too old");if(i>r+Y)throw new k("Message timestamp too new");return new Date(i*1e3)}};L.Webhook=q;q.prefix="whsec_"});export{ie as a};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{J as Ge,K as Qe,L as Xe,M as Ye,N as ie,O,P as N,Q as D,R as Ze,T as er,U as rr,V as nr,W as tr,X as or,Z as ir,_ as ar,a as Ue,b as $,e as We,f as qe,h as _,i as Be,j as Ve,k as h,l as Ke,m as ze,n as I,o as oe,p as Je,s as C}from"./chunk-R7CQWEBF.js";import{b as _e,d as f,e as y,g as Oe,h as S,i as Ne,j as De,k as He}from"./chunk-EVYYSTR7.js";import cr from"fs";import B from"path";import{config as zn}from"dotenv";import{z as W}from"zod";import{err as Jn,ok as dr}from"neverthrow";import U from"fs";import le from"path";import{err as ae,ok as sr}from"neverthrow";import{z as H}from"zod";var qn=le.join(".ripplo","project.json"),se=[".env",".env.local"],Bn=H.object({envFiles:H.array(H.string().min(1)).optional(),projectId:H.string().min(1)});function lr(e){return le.join(e,qn)}function ce(e){let r=lr(e);return U.existsSync(r)?Vn(r).andThen(n=>{let t=Bn.safeParse(n);return t.success?sr({envFiles:t.data.envFiles??se,projectId:t.data.projectId}):ae({issues:t.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:r})}):ae({kind:"project-file-missing",path:r})}function de(e){return ce(e).match(r=>r,()=>{})}function Vn(e){try{return sr(JSON.parse(U.readFileSync(e,"utf8")))}catch(r){return ae({issues:[r instanceof Error?r.message:String(r)],kind:"project-file-invalid",path:e})}}function Aa({cwd:e,envFiles:r,projectId:n}){let t=lr(e);U.mkdirSync(le.dirname(t),{recursive:!0});let o={projectId:n};r!=null&&!Kn(r)&&(o.envFiles=[...r]),U.writeFileSync(t,JSON.stringify(o,null,2)+`
|
|
3
|
+
`)}function Kn(e){return e.length!==se.length?!1:e.every((r,n)=>r===se[n])}function Oa(e){let n=de(e)?.envFiles??[".env",".env.local"],t=B.join(e,".ripplo");n.forEach(o=>{let i=B.resolve(t,o);cr.existsSync(i)&&zn({override:!0,path:i,quiet:!0})}),q=void 0}var Gn=W.object({RIPPLO_APP_URL:W.url(),RIPPLO_ENGINE_URL:W.url(),RIPPLO_WEBHOOK_SECRET:W.string().min(1)}),q;function V(){return q!=null?dr(q):Xn().map(e=>(q=e,e))}function Qn(e){let n=de(e)?.envFiles??[],t=B.join(e,".ripplo");return n.map(o=>B.resolve(t,o)).filter(o=>!cr.existsSync(o))}function Xn(){let e=Gn.safeParse(process.env);if(!e.success)return Jn({issues:e.error.issues.map(n=>`${n.path.join(".")}: ${n.message}`),kind:"env-invalid",missingEnvFiles:Qn(process.cwd())});let r=e.data;return dr({appUrl:r.RIPPLO_APP_URL,engineUrl:r.RIPPLO_ENGINE_URL,webhookSecret:r.RIPPLO_WEBHOOK_SECRET})}import{readFileSync as Yn}from"fs";import{z as ur}from"zod";var Zn=ur.object({version:ur.string()});function K(){let e=Yn(new URL("../package.json",import.meta.url),"utf8");return Zn.parse(JSON.parse(e)).version}import ge from"fs";import z from"path";import{createJiti as ct}from"jiti";import{err as T,ok as yr}from"neverthrow";import et from"fs";import A from"path";import x from"typescript";function pr(e){let r=A.join(e,"index.ts"),n=tt(e);et.mkdirSync(A.dirname(n.tsBuildInfoFile??""),{recursive:!0});let t=x.createIncrementalCompilerHost(n),o=x.createIncrementalProgram({host:t,options:n,rootNames:[r]}),i=[...o.getSyntacticDiagnostics(),...o.getSemanticDiagnostics()];o.emit();let s=i.filter(d=>rt(d,e));if(s.length===0)return{diagnostics:[],ok:!0};let l={getCanonicalFileName:d=>d,getCurrentDirectory:()=>A.dirname(e),getNewLine:()=>`
|
|
4
|
+
`};return{diagnostics:x.formatDiagnosticsWithColorAndContext(s,l).split(`
|
|
5
|
+
`).filter(d=>d.length>0),ok:!1}}function rt(e,r){let n=e.file?.fileName;return n==null?!0:n.startsWith(r)}var nt=A.join(".local","tsbuildinfo");function tt(e){return{allowImportingTsExtensions:!0,allowJs:!1,esModuleInterop:!0,incremental:!0,module:x.ModuleKind.Preserve,moduleResolution:x.ModuleResolutionKind.Bundler,noEmit:!0,resolveJsonModule:!0,skipLibCheck:!0,strict:!1,target:x.ScriptTarget.ES2022,tsBuildInfoFile:A.join(e,nt)}}import{createHash as ot}from"crypto";import fr from"fs/promises";import ue from"path";import{err as b,ok as pe,Result as it}from"neverthrow";var fe=".ripplo/fixtures",me=10*1024*1024,ye=50*1024*1024;async function mr(e,r){let n=at(r);if(n.length===0)return pe({});let t=ue.join(e,fe),o=await Promise.all(n.map(i=>st({fixturesRoot:t,name:i})));return it.combine(o).andThen(lt)}function at(e){let n=e.workflows.flatMap(t=>[...t.steps,...t.tests.flatMap(o=>o.steps)]).flatMap(t=>t.action.kind==="upload"?t.action.files:[]);return[...new Set(n)].toSorted((t,o)=>t.localeCompare(o))}async function st({fixturesRoot:e,name:r}){if(r.includes("..")||ue.isAbsolute(r))return b({kind:"fixture-invalid-name",name:r});let n=ue.join(e,r),t=await fr.lstat(n).catch(()=>null);if(t==null)return b({kind:"fixture-missing",name:r,path:n});if(t.isSymbolicLink())return b({kind:"fixture-symlink",name:r});if(!t.isFile())return b({kind:"fixture-not-file",name:r});let o=await fr.readFile(n);if(o.byteLength>me)return b({kind:"fixture-too-large",name:r,size:o.byteLength});let i=ot("sha256").update(o).digest("hex");return pe([r,{sha256:i,size:o.byteLength}])}function lt(e){let r=e.reduce((n,[,t])=>n+t.size,0);return r>ye?b({kind:"fixtures-total-too-large",total:r}):pe(Object.fromEntries(e))}var v=".ripplo/ripplo.lock",j;async function gr(e){let{result:r}=await dt(e);return r}async function dt(e){let r=pt(z.join(e,".ripplo"));if(j!=null&&j.fingerprint===r&&j.result.isOk())return{fingerprint:r,result:j.result};let n=await F(e);return j={fingerprint:r,result:n},{fingerprint:r,result:n}}async function F(e){let r=z.join(e,".ripplo"),n=z.join(r,"index.ts"),t=pr(r);return t.ok?(await ft(n)).andThen(s=>yt({entryPath:n,exported:s})).match(async s=>(await mr(e,s)).map(u=>({...s,fixtures:u})).mapErr(u=>({error:u,kind:"fixture-failed"})),s=>Promise.resolve(T(s))):T({diagnostics:t.diagnostics,kind:"typecheck-failed"})}var ut=new Set([".local","debug","node_modules"]);function pt(e){return hr(e).toSorted((r,n)=>r.localeCompare(n)).join("|")}function hr(e){return(ge.existsSync(e)?ge.readdirSync(e,{withFileTypes:!0}):[]).flatMap(n=>{if(ut.has(n.name))return[];let t=z.join(e,n.name);if(n.isDirectory())return hr(t);let o=ge.statSync(t);return[`${t}:${String(o.mtimeMs)}:${String(o.size)}`]})}async function ft(e){try{let n=await ct(import.meta.url,{fsCache:!1,moduleCache:!1,sourceMaps:!0}).import(e),t=n!=null&&typeof n=="object"&&"default"in n?Reflect.get(n,"default"):n;return yr(t)}catch(r){return T({kind:"load-threw",message:mt(r)})}}function mt(e){return e instanceof Error?e.message:String(e)}function yt({entryPath:e,exported:r}){if(r==null||typeof r!="object"||!("lockfile"in r))return T({entryPath:e,kind:"not-ripplo"});let n=qe.safeParse(Reflect.get(r,"lockfile"));return n.success?yr(n.data):T({issues:n.error.issues.map(t=>`${t.path.join(".")}: ${t.message}`),kind:"invalid-lockfile"})}function E(e,r){return r==null?`Load \`/ripplo:${e}\` skill for instructions.`:`Load \`/ripplo:${e}\` skill for instructions on ${r}.`}function is(e){return e.length===1?E(e[0]):`Before proceeding, load the ${e.map(n=>`\`/ripplo:${n}\``).join(" and ")} skills \u2014 every one, each carries rules the others don't.`}function G(e){return[`Compilation failed: ${gt(e)}`,E("create","DSL authoring + lint rules")].join(`
|
|
6
|
+
`)}function ds(){return`${v} is up to date`}function us(e){return[`${v} is ${e==="missing"?"missing":"out of date"} \u2014 run \`npx ripplo compile\` and commit the result`,E("setup")].join(`
|
|
7
|
+
`)}function ps(){return`Wrote ${v}`}function gt(e){switch(e.kind){case"typecheck-failed":return["TypeScript errors in .ripplo/:",...kr(e.diagnostics)].join(`
|
|
8
|
+
`);case"not-ripplo":return`${e.entryPath} must default-export a Ripplo (createRipplo({ entities, singletons, workflows })). Check that the default export is the value returned by createRipplo, not a function or a re-export.`;case"invalid-lockfile":return["Lockfile failed schema validation (stale or hand-edited .ripplo/ripplo.lock?):",...kr(e.issues),"Regenerate with `npx ripplo compile` \u2014 never hand-edit the lockfile."].join(`
|
|
9
|
+
`);case"load-threw":return[`.ripplo/index.ts threw while loading: ${e.message}`,"Usually a bad import or a top-level throw in .ripplo/ \u2014 run `npx ripplo compile` for the stack."].join(`
|
|
10
|
+
`);case"fixture-failed":return ht(e.error)}}function kr(e,r=8){return e.length<=r?e:[...e.slice(0,r),`\u2026 and ${String(e.length-r)} more`]}function ht(e){switch(e.kind){case"fixture-missing":return`Fixture "${e.name}" not found at ${e.path} \u2014 add the file under .ripplo/fixtures/ or fix the upload() name.`;case"fixture-invalid-name":return`Invalid fixture name "${e.name}" \u2014 upload() takes a bare name under .ripplo/fixtures/, no .. or absolute paths.`;case"fixture-symlink":return`Fixture "${e.name}" is a symlink \u2014 only regular files are allowed.`;case"fixture-not-file":return`Fixture "${e.name}" is not a regular file.`;case"fixture-too-large":return`Fixture "${e.name}" is ${J(e.size)} \u2014 over the ${J(me)} per-file limit.`;case"fixtures-total-too-large":return`Fixtures total ${J(e.total)} \u2014 over the ${J(ye)} limit.`}}function J(e){return`${String(Math.round(e/(1024*1024)*10)/10)} MB`}var Q=class extends Error{failure;constructor(r){super(r.kind),this.name="CliError",this.failure=r}};function ks(e){return e instanceof Q?he(e.failure):e instanceof Error?e.message:String(e)}function he(e){switch(e.kind){case"project-file-missing":return[`Missing ${e.path} \u2014 this directory is not a Ripplo project.`,"Run `npx ripplo init` to create it (or cd into the project root).",E("setup")].join(`
|
|
11
|
+
`);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(r=>` ${r}`),"Fix the file by hand or re-run `npx ripplo init`."].join(`
|
|
12
|
+
`);case"not-authenticated":return["Not signed in. Run `npx ripplo auth login`.","(Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)"].join(`
|
|
13
|
+
`);case"env-invalid":return kt(e);case"playwright-install-failed":return["Playwright browser install failed \u2014 Chromium is still missing.","Run `npx playwright install chromium` and check its output for network, proxy, or disk-space errors."].join(`
|
|
14
|
+
`);case"gitdir-unrecognized":return`Unrecognized .git file at ${e.marker} \u2014 expected a directory or a "gitdir:" pointer (worktree). Is the repo corrupted?`;case"gitdir-empty":return`Empty gitdir pointer at ${e.marker} \u2014 the worktree's .git file points nowhere. Re-create the worktree.`;case"oauth-device-code-failed":return[`Could not start sign-in (device-code request failed): ${e.description}`,"Is the Ripplo server reachable? Check RIPPLO_SERVER_URL and retry."].join(`
|
|
15
|
+
`);case"oauth-authorization-failed":return[`Sign-in failed (${e.code}): ${e.description}`,e.code==="expired_token"?"The approval window expired \u2014 run `npx ripplo auth login` again.":"Run `npx ripplo auth login` to retry."].join(`
|
|
16
|
+
`);case"compilation-failed":return G(e.error)}}function kt(e){let r=e.missingEnvFiles.length===0?[]:["Declared env files not found:",...e.missingEnvFiles.map(n=>` ${n}`),"In a git worktree? Env files aren't copied from the main checkout \u2014 recreate them, or symlink to a shared file outside the working tree."];return["Env config invalid:",...e.issues.map(n=>` ${n}`),"Add the missing values to the env files declared in .ripplo/project.json.",...r].join(`
|
|
17
|
+
`)}import{err as xt,ok as bt}from"neverthrow";import{z as ke}from"zod";var St="https://ripplo.ai";function Rr(){return br().RIPPLO_SERVER_URL}function xr(){return br().RIPPLO_PROJECT_ID}var Rt=ke.object({RIPPLO_PROJECT_ID:ke.string().min(1).optional(),RIPPLO_SERVER_URL:ke.string().min(1).default(St)}),Sr;function br(){return Sr??=Rt.parse(process.env),Sr}import vr from"fs";import Se from"path";function Er(e){let r=vr.realpathSync(e),n=r,t=Se.dirname(n);for(;t!==n;){if(vr.existsSync(Se.join(n,".git")))return n;n=t,t=Se.dirname(n)}return r}function Ts(e){return ce(e).andThen(r=>V().andThen(n=>{let t=Rr(),o=He(t);return o==null?xt({kind:"not-authenticated"}):bt({appUrl:n.appUrl,cwd:Er(e),engineUrl:n.engineUrl,projectId:xr()??r.projectId,ripploServerUrl:t,token:o,tunnelAuth:void 0,webhookSecret:n.webhookSecret})}))}import wr from"fs";import{checkSync as vt,lockSync as Et}from"proper-lockfile";var wt="dev.pid",Pr=15e3;function Ir(e){return S(e,wt)}function Cr(e){try{return vt(Ir(e),{realpath:!1,stale:Pr})}catch{return!1}}var Re=class extends Error{pid;cwd;constructor({cwd:r,pid:n}){super("dev-lock-held"),this.name="DevLockHeldError",this.pid=n,this.cwd=r}};function _s({cwd:e,onCompromised:r}){Oe(e);let n=Ir(e),t=Pt({cwd:e,onCompromised:r,path:n});return wr.writeFileSync(n,String(process.pid)),()=>{try{t()}catch{}}}function Pt({cwd:e,onCompromised:r,path:n}){try{return Et(n,{realpath:!1,stale:Pr,onCompromised:()=>{r()}})}catch(t){throw It(t)?new Re({cwd:e,pid:Ct(n)}):t}}function It(e){if(!(e instanceof Error)||!("code"in e))return!1;let{code:r}=e;return r==="ELOCKED"}function Ct(e){try{let r=wr.readFileSync(e,"utf8").trim(),n=Number.parseInt(r,10);return Number.isFinite(n)&&n>0?n:null}catch{return null}}import At from"p-queue";var jt=4,Tt={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},X=new At({concurrency:jt}),k={headedActive:0,interactiveActive:0,interactiveQueued:0},Ar={current:null};function Ds({headed:e,task:r,workClass:n}){let t=Tt[n];return n==="p3-explore"?X.add(r,{priority:t}):(k.interactiveQueued+=1,Y(),X.add(()=>Ft({headed:e,task:r}),{priority:t}))}function Hs(e){!Number.isFinite(e)||e<1||(X.concurrency=Math.floor(e),Y())}function xe(){return{active:k.interactiveActive,headedActive:k.headedActive,poolSize:X.concurrency,queued:k.interactiveQueued}}function Us(e){Ar.current=e}async function Ft({headed:e,task:r}){k.interactiveQueued-=1,k.interactiveActive+=1,k.headedActive+=e?1:0,Y();try{return await r()}finally{k.interactiveActive-=1,k.headedActive-=e?1:0,Y()}}function Y(){Ar.current?.()}import be from"fs";import ve from"path";function jr(e){try{let r=Lt(e);if(r==null)return;let n=ve.join(r,"HEAD"),t=be.readFileSync(n,"utf8").trim(),o="ref: refs/heads/";return t.startsWith(o)?t.slice(o.length):t.length===0?void 0:t.slice(0,7)}catch{return}}function Lt(e){let r=ve.join(e,".git");if(be.statSync(r).isDirectory())return r;let t=be.readFileSync(r,"utf8").trim(),o="gitdir:";if(!t.startsWith(o))return;let i=t.slice(o.length).trim();if(i.length!==0)return ve.resolve(e,i)}import Mt from"crypto";import{readFile as Tr}from"fs/promises";import Fr from"path";import{graphql as $t}from"gql.tada";import{err as _t,ok as Ot}from"neverthrow";var Nt=$t(`
|
|
18
|
+
mutation SyncDevSession(
|
|
19
|
+
$projectId: String!
|
|
20
|
+
$cwd: String!
|
|
21
|
+
$branch: String
|
|
22
|
+
$lockfileContent: String
|
|
23
|
+
$fixtures: [SyncDevFixtureInput!]
|
|
24
|
+
$preconditions: [SyncDevPreconditionInput!]!
|
|
25
|
+
$singletons: [SyncDevSingletonInput!]
|
|
26
|
+
$workflows: [SyncDevWorkflowInput!]!
|
|
27
|
+
) {
|
|
28
|
+
syncDevSession(
|
|
29
|
+
projectId: $projectId
|
|
30
|
+
cwd: $cwd
|
|
31
|
+
branch: $branch
|
|
32
|
+
lockfileContent: $lockfileContent
|
|
33
|
+
fixtures: $fixtures
|
|
34
|
+
preconditions: $preconditions
|
|
35
|
+
singletons: $singletons
|
|
36
|
+
workflows: $workflows
|
|
37
|
+
) {
|
|
38
|
+
id
|
|
39
|
+
hooksPaused
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`);async function nl(e,r){let n=await F(e);if(n.isErr())return _t({error:n.error,kind:"compilation-failed"});let t=await Ee({config:r,cwd:e,lockfile:n.value});return Ot({devSessionId:t.devSessionId,lockfile:n.value})}async function Ee(e){let r=Be(e.lockfile);return Ht({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:r})}function Dt(e){return Mt.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Ht({config:e,cwd:r,fixtures:n,payload:t}){let o=Dt(t),i=jr(r),s=await Wt(r),l=await Ut(r,n),u=await f({config:e,document:Nt,variables:{branch:i??null,cwd:r,fixtures:l,lockfileContent:s,preconditions:t.preconditions.map(d=>({depends:[...d.depends],description:d.description,name:d.name,returns:[...d.returns]})),projectId:e.projectId,singletons:t.singletons.map(d=>({defaultValue:d.defaultValue,description:d.description,name:d.name,type:d.type})),workflows:t.workflows.map(d=>({expectedOutcome:d.expectedOutcome,name:d.name,preconditions:[...d.preconditions],requiresKeys:d.requiresKeys.map(m=>({namespace:m.namespace,preconditionName:m.preconditionName})),slug:d.slug,sourcePath:d.sourcePath,spec:JSON.stringify(d.spec)}))}});if(u.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:u.syncDevSession.id,hash:o,hooksPaused:u.syncDevSession.hooksPaused}}async function Ut(e,r){let n=Object.entries(r);return Promise.all(n.map(async([t,o])=>({contentBase64:(await Tr(Fr.join(e,fe,t))).toString("base64"),sha256:o.sha256})))}async function Wt(e){try{return await Tr(Fr.join(e,v),"utf8")}catch{return null}}import{randomUUID as xo}from"crypto";import{createId as bo}from"@paralleldrive/cuid2";import{CancellationTokenSource as vo,ResponseError as Eo}from"vscode-jsonrpc/node";import{graphql as qt}from"gql.tada";var Bt=qt(`
|
|
43
|
+
mutation DaemonCreateRun(
|
|
44
|
+
$id: String
|
|
45
|
+
$workflowId: String!
|
|
46
|
+
$testId: String
|
|
47
|
+
$clientVersion: String
|
|
48
|
+
$executor: RunExecutor
|
|
49
|
+
$target: RunTarget
|
|
50
|
+
$lockfileHash: String
|
|
51
|
+
) {
|
|
52
|
+
createRun(
|
|
53
|
+
id: $id
|
|
54
|
+
workflowId: $workflowId
|
|
55
|
+
testId: $testId
|
|
56
|
+
executor: $executor
|
|
57
|
+
target: $target
|
|
58
|
+
clientVersion: $clientVersion
|
|
59
|
+
lockfileHash: $lockfileHash
|
|
60
|
+
) {
|
|
61
|
+
__typename
|
|
62
|
+
... on MutationCreateRunSuccess {
|
|
63
|
+
data {
|
|
64
|
+
id
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
... on LimitExceededError {
|
|
68
|
+
code
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`);async function Lr(e){try{let n=(await f({config:e.config,document:Bt,variables:Vt(e)})).createRun;return n==null?Z({detail:"create-run-null",type:"generic"}):n.__typename==="MutationCreateRunSuccess"?null:n.__typename==="LimitExceededError"?Z({code:n.code,type:"limit"}):Z({detail:n.__typename,type:"generic"})}catch(r){return Kt(r)}}function Vt({executor:e,lockfileHash:r,runId:n,target:t}){return{clientVersion:K(),executor:e,id:n,lockfileHash:r,target:e==="cloud"?"tunnel":void 0,testId:t.testId,workflowId:t.workflowId}}function Z(e){return{kind:"dispatch-error",reason:e}}function Kt(e){return e instanceof _e?{detail:e.message,kind:"infra-error"}:Z({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{createMessageConnection as zt,NotificationType as Mr,RequestType as $r,RequestType0 as _r,SocketMessageReader as Jt,SocketMessageWriter as Gt}from"vscode-jsonrpc/node";import{z as a}from"zod";var Qt="daemon.sock",Xt="daemon.log";function ul(e){return S(e,Qt)}function pl(e){return S(e,Xt)}function Or(e){return zt(new Jt(e),new Gt(e))}var Nr=a.object({all:a.boolean(),headed:a.boolean(),tests:a.array(a.string())}),fl=a.object({jobId:a.string(),total:a.number()}),Yt=a.enum(["holder","standby","off"]),Zt=a.object({covered:a.number(),deferred:a.number(),findings:a.number(),saturated:a.boolean(),total:a.number()}),ml=a.object({active:a.number(),explorer:Yt,exploring:a.number(),progress:Zt,queued:a.number(),sseHealth:a.object({detail:a.string().optional(),ok:a.boolean()}).optional(),version:a.string().optional()}),eo=a.enum(["MAX_RUNS","OVERAGE_CAP","MAX_AGENTS","MAX_CONCURRENT_RUNS","MAX_PROJECTS"]),ro=a.discriminatedUnion("type",[a.object({code:eo,type:a.literal("limit")}),a.object({detail:a.string(),type:a.literal("generic")})]),we=a.discriminatedUnion("kind",[a.object({kind:a.literal("pass")}),a.object({findingLines:a.array(a.string()),kind:a.literal("findings")}),a.object({detail:a.string(),kind:a.literal("error")}),a.object({kind:a.literal("dispatch-error"),reason:ro}),a.object({detail:a.string(),kind:a.literal("dispatch-timeout")}),a.object({detail:a.string(),kind:a.literal("infra-error")})]),no=a.discriminatedUnion("kind",[a.object({kind:a.literal("test-started"),runId:a.string(),testName:a.string(),workflowName:a.string()}),a.object({kind:a.literal("test-outcome"),outcome:we,runId:a.string(),testName:a.string(),workflowName:a.string()})]),yl=a.object({event:no,jobId:a.string()}),gl=a.object({failed:a.number(),jobId:a.string(),notRun:a.number(),passed:a.number()}),hl=a.discriminatedUnion("code",[a.object({code:a.literal("compile-failed"),detail:a.string(),diagnostics:a.array(a.string()).default([])}),a.object({code:a.literal("selection-conflicting-flags")}),a.object({code:a.literal("selection-nothing-selected")}),a.object({code:a.literal("selection-unknown-ids"),known:a.array(a.string()),unknown:a.array(a.string())}),a.object({code:a.literal("scope-failed"),detail:a.string()}),a.object({code:a.literal("app-unreachable"),detail:a.string(),url:a.string()}),a.object({code:a.literal("sync-failed"),detail:a.string()}),a.object({code:a.literal("bad-message")})]),Dr=a.object({findingId:a.string().min(1)}),kl=a.discriminatedUnion("kind",[a.object({kind:a.literal("resolved")}),a.object({kind:a.literal("unreachable")}),a.object({kind:a.literal("still-failing"),runId:a.string().optional()}),a.object({kind:a.literal("diverged"),runId:a.string().optional()}),a.object({kind:a.literal("flaky")}),a.object({kind:a.literal("aborted")}),a.object({kind:a.literal("finding-not-found")}),a.object({kind:a.literal("unreplayable"),reason:a.enum(["base-state-missing","action-missing","ledger-unreadable"])}),a.object({kind:a.literal("error"),reason:a.string()})]),Hr=new $r("ripplo/exploreReplay"),Ur=new $r("ripplo/enqueue"),Wr=new _r("ripplo/status"),qr=new _r("ripplo/shutdownIfIdle"),Br=new Mr("ripplo/jobEvent"),Vr=new Mr("ripplo/jobDone");import{graphql as to}from"gql.tada";async function Kr(e,r){let t=(await f({config:e,document:oo,variables:{cwd:r,projectId:e.projectId}})).project?.devSession?.workflows??[];return new Map(t.flatMap(o=>o.tests.map(i=>[`${o.slug}/${i.slug}`,{testId:i.id,workflowId:o.id}])))}var oo=to(`
|
|
73
|
+
query DaemonWorkflows($projectId: String!, $cwd: String!) {
|
|
74
|
+
project(id: $projectId) {
|
|
75
|
+
id
|
|
76
|
+
devSession(cwd: $cwd) {
|
|
77
|
+
id
|
|
78
|
+
workflows {
|
|
79
|
+
id
|
|
80
|
+
slug
|
|
81
|
+
tests {
|
|
82
|
+
id
|
|
83
|
+
slug
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`);import{CancellationTokenSource as io}from"vscode-jsonrpc/node";function Pe(e){return`${e.workflowSlug}/${e.testSlug}`}function zr(e){let{headed:r,inflight:n,jobId:t,lockfileHashValue:o,onExpire:i,runId:s,selection:l,timeoutMs:u}=e,d=Pe(l),m=`${d}@${o}@${String(r)}`,p=n.get(m);if(p!=null)return p.jobIds.add(t),null;let g={cancellation:new io,claimed:!1,claimKey:d,headed:r,inflightKey:m,jobIds:new Set([t]),runId:s,testName:l.testName,timer:null,workflowName:l.workflowName};return g.timer=setTimeout(()=>{ee(n,g),i(g)},u),n.set(m,g),g}function ee(e,r){r.timer!=null&&(clearTimeout(r.timer),r.timer=null),e.delete(r.inflightKey)}function Ie(e,r){let n=[...e.values()].find(t=>t.runId===r&&!t.claimed);return n==null?null:(n.claimed=!0,n.timer!=null&&(clearTimeout(n.timer),n.timer=null),n)}function Jr(e,r){[...e.values()].filter(n=>n.jobIds.has(r)).forEach(n=>{n.jobIds.delete(r),n.jobIds.size===0&&(ee(e,n),n.cancellation.cancel())})}import{err as Ce,ok as Gr}from"neverthrow";function Xr({all:e,ids:r,lockfile:n}){if(e&&r.length>0)return Ce({kind:"conflicting-flags"});if(e)return Gr(n.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>I(s))));if(r.length===0)return Ce({kind:"nothing-selected"});let t=r.map(i=>({id:i,refs:so(n,i)})),o=t.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?Ce({kind:"unknown-ids",known:ao(n),unknown:o}):Gr([...new Set(t.flatMap(i=>i.refs))])}function Yr(e,r){let n=new Map(oe(e).map(t=>[t.ref,{testName:t.test.name,testSlug:t.test.slug,workflowName:t.workflow.name,workflowSlug:h(t.workflow.name)}]));return r.map(t=>{let o=n.get(t);if(o==null)throw new Error(`selectionsFor: ref not in lockfile: ${t}`);return o})}function ao(e){return e.workflows.map(r=>h(r.name))}function so(e,r){let n=e.workflows.find(t=>t.name===r||h(t.name)===h(r));return n!=null?n.tests.map(t=>I(t)):oe(e).filter(t=>t.ref===r||Qr(t.ref)===Qr(r)).map(t=>t.ref)}function Qr(e){let r=e.lastIndexOf("/");return r===-1?h(e):`${h(e.slice(0,r))}/${h(e.slice(r+1))}`}import{err as Ae,ok as en}from"neverthrow";import{graphql as rn}from"gql.tada";import{execFileSync as lo}from"child_process";var co=256*1024*1024;function re(e,r){return lo("git",[...e],{cwd:r,encoding:"utf8",maxBuffer:co,stdio:["ignore","pipe","pipe"]})}async function nn({config:e,cwd:r,lockfile:n}){await po({config:e,cwd:r,lockfile:n});let t=await mo(e);if(t.isErr())return Ae(t.error);let o=new Map(n.workflows.filter(s=>!s.stub).map(s=>[h(s.name),s])),i=[...new Set(t.value)].flatMap(s=>{let l=o.get(s);return l==null?[]:l.tests.map(u=>I(u))});return i.length===0?Ae({kind:"scope-empty"}):en(i)}var uo=rn(`
|
|
90
|
+
mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
91
|
+
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
92
|
+
__typename
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
`);async function po({config:e,cwd:r,lockfile:n}){let t=new Set(yo(r)),o=n.workflows.filter(i=>i.sourcePath!=null&&t.has(i.sourcePath)).map(i=>h(i.name));o.length!==0&&await f({config:e,document:uo,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{y.warn({err:i},"auto-scope of dirty tests failed")})}var fo=rn(`
|
|
96
|
+
query ScopeSelection($projectId: String!, $cwd: String!) {
|
|
97
|
+
project(id: $projectId) {
|
|
98
|
+
id
|
|
99
|
+
devSession(cwd: $cwd) {
|
|
100
|
+
id
|
|
101
|
+
scopeItems {
|
|
102
|
+
id
|
|
103
|
+
workflow {
|
|
104
|
+
id
|
|
105
|
+
slug
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`);async function mo(e){try{let n=(await f({config:e,document:fo,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return en(n.flatMap(t=>t.workflow==null?[]:[t.workflow.slug]))}catch(r){return Ae({detail:r instanceof Error?r.message:String(r),kind:"scope-fetch-failed"})}}var Zr=".ripplo/workflows/";function yo(e){try{return re(["status","--porcelain","--",".ripplo/workflows"],e).split(`
|
|
112
|
+
`).map(r=>r.slice(3).trim()).filter(r=>r.startsWith(Zr)&&r.endsWith(".ts")).map(r=>r.slice(Zr.length)).filter(r=>r!=="index.ts"&&!r.endsWith("/index.ts"))}catch{return[]}}import{graphql as go}from"gql.tada";var ho=2e3,ko=go(`
|
|
113
|
+
query DaemonCloudRunStatus($runId: String!) {
|
|
114
|
+
run(id: $runId) {
|
|
115
|
+
status
|
|
116
|
+
failureReason
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
`);function on({config:e,onComplete:r,onStarted:n,runId:t,signal:o}){let i=!1,s,l=!1,u=async()=>{if(i||o.aborted)return;let d=await So(e,t).catch(()=>"unknown");if(!l&&(d==="running"||tn(d))&&(l=!0,n()),tn(d)){i=!0,r(Ro(d));return}s=setTimeout(()=>{u()},ho)};return u(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function So(e,r){let t=(await f({config:e,document:ko,variables:{runId:r}})).run?.status;return t??"unknown"}function tn(e){return e==="passed"||e==="failed"||e==="warning"||e==="cancelled"}function Ro(e){return e==="passed"?{kind:"pass"}:e==="failed"?{detail:"failed",kind:"error"}:e==="warning"?{findingLines:[],kind:"findings"}:e==="cancelled"?{detail:"cancelled",kind:"error"}:{detail:"unknown",kind:"error"}}var wo=12e4,Po=-32099;function ln(e){let r=new AbortController;return e.isCancellationRequested?(r.abort(),r.signal):(e.onCancellationRequested(()=>{r.abort()}),r.signal)}function tc(e){let r={...e,inflight:new Map,jobs:new Map};return{claim:n=>To(r,n),handleConnection:n=>{Io(r,n)},idle:()=>cn(r)}}function Io(e,r){let n=Or(r);n.onRequest(Ur,(t,o)=>Co({connection:n,ctx:e,params:t,token:o})),n.onRequest(Wr,()=>{let t=xe();return{active:t.active,queued:t.queued,sseHealth:e.sseHealth(),version:K(),...e.explorationStatus()}}),n.onRequest(Hr,async(t,o)=>{let i=Dr.safeParse(t);return i.success?(await e.ready,e.replayFinding(i.data.findingId,ln(o))):{kind:"error",reason:"bad-message"}}),n.onRequest(qr,()=>{let t=cn(e);return t&&e.onShutdownRequest(),t}),n.onClose(()=>{Ao(e,n)}),n.onError(t=>{y.warn({err:t},"ipc connection error")}),r.on("error",t=>{y.warn({err:t},"ipc socket error")}),n.listen()}function cn(e){let r=xe();return e.jobs.size===0&&r.active===0&&r.queued===0}async function Co({connection:e,ctx:r,params:n,token:t}){let o=Nr.safeParse(n);if(!o.success)throw an({code:"bad-message"});await r.ready;let i=await Lo({config:r.config,cwd:r.cwd,message:o.data});if(i.kind==="error")throw an(i.error);let s=xo(),l=new vo;return t.onCancellationRequested(()=>{dn(r,s)}),r.jobs.set(s,{cancellation:l,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),Uo({ctx:r,headed:o.data.headed,jobId:s,lockfileHashValue:i.lockfileHashValue,selections:i.selections,targetsByClaimKey:i.targetsByClaimKey,token:l.token}).catch(u=>{y.error({err:u},"ipc dispatch failed")}),{jobId:s,total:i.selections.length}}function an(e){return new Eo(Po,e.code,e)}function dn(e,r){let n=e.jobs.get(r);n!=null&&(n.cancellation.cancel(),e.jobs.delete(r),Jr(e.inflight,r))}function Ao(e,r){[...e.jobs.entries()].filter(([,n])=>n.connection===r).forEach(([n])=>{dn(e,n)})}function un(e,r,n){let t=e.jobs.get(r);t!=null&&(sn(()=>t.connection.sendNotification(Br,{event:n,jobId:r})),n.kind==="test-outcome"&&(jo(t,n.outcome.kind),t.passed+t.failed+t.notRun>=t.total&&(sn(()=>t.connection.sendNotification(Vr,{failed:t.failed,jobId:r,notRun:t.notRun,passed:t.passed})),e.jobs.delete(r))))}function sn(e){e().catch(r=>{y.warn({err:r},"ipc notification failed")})}function jo(e,r){if(r==="pass"){e.passed+=1;return}if(r==="dispatch-error"||r==="dispatch-timeout"||r==="infra-error"){e.notRun+=1;return}e.failed+=1}function w(e,r,n){r.jobIds.forEach(t=>{un(e,t,n)})}function To(e,r){let n=Ie(e.inflight,r);return n==null?null:{headed:n.headed,token:n.cancellation.token,finished:(t,o)=>{e.inflight.delete(n.inflightKey),w(e,n,{kind:"test-outcome",outcome:o,runId:n.runId,testName:n.testName,workflowName:n.workflowName})},started:()=>{w(e,n,{kind:"test-started",runId:n.runId,testName:n.testName,workflowName:n.workflowName})}}}function Fo(e){return e.kind==="typecheck-failed"?e.diagnostics.slice(0,5):e.kind==="invalid-lockfile"?e.issues.slice(0,5):e.kind==="load-threw"?[e.message]:[]}async function Lo({config:e,cwd:r,message:n}){return(await gr(r)).match(o=>Mo({config:e,cwd:r,lockfile:o,message:n}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...Fo(o)]},kind:"error"}))}async function Mo({config:e,cwd:r,lockfile:n,message:t}){let o=await _o(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=await Oo({config:e,cwd:r,lockfile:n});return i!=null?{error:{code:"sync-failed",detail:i},kind:"error"}:(await No({config:e,cwd:r,lockfile:n,message:t})).match(async l=>({kind:"ready",lockfileHashValue:_(n),selections:Yr(n,l),targetsByClaimKey:await Kr(e,r)}),l=>Promise.resolve({error:l,kind:"error"}))}var $o=2e3;async function _o(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout($o)}),null}catch(r){return r instanceof Error?r.message:String(r)}}async function Oo(e){try{return await Ee(e),null}catch(r){return r instanceof Error?r.message:String(r)}}async function No({config:e,cwd:r,lockfile:n,message:t}){return!t.all&&t.tests.length===0?(await nn({config:e,cwd:r,lockfile:n})).mapErr(Do):Xr({all:t.all,ids:t.tests,lockfile:n}).mapErr(Ho)}function Do(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function Ho(e){switch(e.kind){case"conflicting-flags":return{code:"selection-conflicting-flags"};case"nothing-selected":return{code:"selection-nothing-selected"};case"unknown-ids":return{code:"selection-unknown-ids",known:[...e.known],unknown:[...e.unknown]}}}async function Uo(e){await e.selections.reduce((r,n)=>r.then(()=>Wo(e,n)),Promise.resolve())}async function Wo(e,r){let{ctx:n,headed:t,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:l}=e;if(l.isCancellationRequested)return;let u=Pe(r),d=s.get(u);if(d==null){un(n,o,{kind:"test-outcome",outcome:{kind:"dispatch-error",reason:{detail:"test-not-found",type:"generic"}},runId:"",testName:r.testName,workflowName:r.workflowName});return}let m=zr({headed:t,inflight:n.inflight,jobId:o,lockfileHashValue:i,runId:bo(),selection:r,timeoutMs:wo,onExpire:g=>{w(n,g,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:g.testName,workflowName:g.workflowName})}});if(m==null)return;let p=await qo(n,d,m.runId,i);if(p!=null){ee(n.inflight,m),w(n,m,{kind:"test-outcome",outcome:p,runId:"",testName:r.testName,workflowName:r.workflowName});return}n.executor==="cloud"&&Bo(n,m)}function qo(e,r,n,t){return Lr({config:e.config,executor:e.executor,lockfileHash:t,runId:n,target:r})}function Bo(e,r){let n=Ie(e.inflight,r.runId);n!=null&&on({config:e.config,runId:n.runId,signal:ln(n.cancellation.token),onComplete:t=>{e.inflight.delete(n.inflightKey),w(e,n,{kind:"test-outcome",outcome:t,runId:n.runId,testName:n.testName,workflowName:n.workflowName})},onStarted:()=>{w(e,n,{kind:"test-started",runId:n.runId,testName:n.testName,workflowName:n.workflowName})}})}function Vo(e){let{backoffActive:r,explorerHolder:n,headedActive:t,interactiveActive:o,interactiveQueued:i}=e,{explorationActive:s,exploreConcurrency:l,poolSize:u}=e;if(!n||t||i>0)return{abortCount:s,refillCount:0};if(r)return{abortCount:0,refillCount:0};let d=Math.min(l,u-1,u-o);return{abortCount:0,refillCount:Math.max(0,d-s)}}function ic(e){let r={active:new Map,backoffUntil:0,cancelBackoffTimer:null,cancelHeartbeat:null,holder:!1,prevInteractiveActive:e.probe().interactiveActive,stopped:!1};return mn(r,e),{explorationActive:()=>r.active.size,explorerHolder:()=>r.holder,notifyQueueChange:()=>{Ko(r,e)},setExplorerHolder:n=>{r.holder=n,L(r,e)},stop:()=>{r.stopped=!0,r.cancelBackoffTimer?.(),r.cancelBackoffTimer=null,r.cancelHeartbeat?.(),r.cancelHeartbeat=null,yn(r,r.active.size)}}}function mn(e,r){e.stopped||(e.cancelHeartbeat=r.setTimer(()=>{L(e,r),mn(e,r)},15e3))}function L(e,r){if(e.stopped)return;let n=r.probe(),t=Vo({backoffActive:r.now()<e.backoffUntil,explorationActive:e.active.size,exploreConcurrency:r.exploreConcurrency,explorerHolder:e.holder&&r.exploreEnabled,headedActive:n.headedActive>0,interactiveActive:n.interactiveActive,interactiveQueued:n.interactiveQueued,poolSize:n.poolSize});yn(e,t.abortCount),gn({count:t.refillCount,params:r,state:e})}function yn(e,r){[...e.active.values()].slice(0,r).forEach(({controller:n})=>{n.abort()})}function Ko(e,r){let n=r.probe();n.interactiveActive<e.prevInteractiveActive&&zo(e,r),e.prevInteractiveActive=n.interactiveActive,L(e,r)}function zo(e,r){e.backoffUntil=r.now()+3e4,e.cancelBackoffTimer?.(),e.cancelBackoffTimer=r.setTimer(()=>{e.cancelBackoffTimer=null,L(e,r)},3e4)}function gn({count:e,params:r,state:n}){if(e<=0)return;let t=Jo(r.sources);t!=null&&(Go({params:r,pulled:t,state:n}),gn({count:e-1,params:r,state:n}))}function Jo(e){return e.reduce((r,n)=>{if(r!=null)return r;let t=n.next();return t==null?null:{job:t,source:n}},null)}function Go({params:e,pulled:r,state:n}){let{job:t,source:o}=r,i=new AbortController;n.active.set(t.id,{controller:i,job:t,source:o}),e.execute({job:t,priority:o.priority,signal:i.signal}).then(()=>{fn({job:t,outcome:pn(i.signal,null),params:e,source:o,state:n})}).catch(s=>{fn({job:t,outcome:pn(i.signal,{error:s}),params:e,source:o,state:n})})}function pn(e,r){return e.aborted?{kind:"aborted"}:r==null?{kind:"completed"}:{error:r.error,kind:"error"}}function fn({job:e,outcome:r,params:n,source:t,state:o}){o.active.delete(e.id),t.onResult(e,r),L(o,n)}import Qo from"fs";import Xo from"path";async function fc(e){let r=Xo.join(e,".ripplo","index.ts");if(!Qo.existsSync(r))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let n=await F(e);return n.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:G(n.error),path:".ripplo/"}],valid:!1,warnings:[]}:V().match(t=>({appUrl:t.appUrl,engineUrl:t.engineUrl,errors:[],valid:!0,warnings:[]}),t=>({appUrl:void 0,engineUrl:void 0,errors:[{message:he(t),path:""}],valid:!1,warnings:[]}))}async function mc(e){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return}catch{return`appUrl (${e}) is not responding. Make sure your dev server is running on that port.`}}async function yc({appUrl:e,engineUrl:r}){let n=r.startsWith("http://")||r.startsWith("https://")?r:`${e}${r}`;try{return(await fetch(`${n}/setup`,{body:JSON.stringify({}),headers:{"Content-Type":"application/json"},method:"PUT",signal:AbortSignal.timeout(5e3)})).ok?"Engine endpoint accepted an unsigned request \u2014 webhook signature verification may be missing.":void 0}catch{return}}import ri from"fs";import Yo from"fs";import je from"path";var Zo=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function hn(e){let r=ei(e);return r==null?!1:Zo.some(n=>Yo.existsSync(je.join(r,n)))}function ei(e){try{let r=re(["rev-parse","--git-dir"],e).trim();return r.length===0?null:je.isAbsolute(r)?r:je.resolve(e,r)}catch{return null}}function ni(e){return S(e,"hooks-paused")}function wc(e){return ri.existsSync(ni(e))||hn(e)?!1:Cr(e)}import{graphql as te}from"gql.tada";import{gzip as di}from"zlib";import{promisify as ui}from"util";import{existsSync as xn,readFileSync as bn}from"fs";import Fe from"path";import{graphql as R}from"gql.tada";function kn(e){return[e.kind,e.target,e.value].filter(r=>r.length>0).join(" ")}var ti={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},oi={"data-rule":"dataRule","page-rule":"pageRule",step:"step"},ii={aborted:"aborted","action-failed":"actionFailed","check-failed":"checkFailed","client-mount-missing":"clientMountMissing","conflicting-sessions":"conflictingSessions","driver-launch":"driverLaunch","engine-decode":"engineDecode","engine-http":"engineHttp","engine-network":"engineNetwork","engine-unreachable":"engineUnreachable","setup-missing-row":"setupMissingRow","state-identity":"stateIdentity"};function Sn(e){return e.kind==="consistency"?{consistency:{mismatch:li(e.mismatch),pending:e.pending}}:e.kind==="pending-check"?{pendingCheck:{budget:e.budget,source:oi[e.source.kind],...ai(e.source)}}:e.kind==="unrunnable"?{unrunnable:{reason:ti[e.reason]}}:e.kind==="driver-error"?{driverError:{errorKind:ii[e.error.kind],message:ci(e.error)}}:{impossibleAction:{subject:si(e.step.action)}}}function ai(e){return"check"in e?Rn(e.check,!1):{checkKind:void 0,expected:void 0,negated:void 0,subject:void 0}}function Rn(e,r){return e.kind==="not"?Rn(e.inner,!r):e.kind==="browser"?{checkKind:"browser",expected:e.value,negated:r,subject:e.name}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:r,subject:$(e.locator)}:{checkKind:e.kind,expected:void 0,negated:r,subject:$(e.locator)}}function si(e){let r=e.locator==null?e.url??"":$(e.locator);return`${e.kind} ${r}`.trim()}function li(e){return e.kind==="wrong-value"?{wrongValue:{entity:e.entity,field:e.field,key:e.key,snapshot:M(e.snapshot),sut:M(e.sut)}}:e.kind==="expected-change"?{expectedChange:{entity:e.entity,field:e.field,key:e.key,value:M(e.value)}}:e.kind==="singleton-mismatch"?{singletonMismatch:{singleton:e.singleton,snapshot:M(e.snapshot),sut:M(e.sut)}}:e.kind==="unexpected-row"?{unexpectedRow:{entity:e.entity,key:e.key}}:{missingRow:{entity:e.entity,key:e.key}}}function M(e){return e==null?null:String(e)}function ci(e){return"message"in e?e.message:"detail"in e?e.detail:null}async function pi({config:e,cwd:r,fixturesDir:n,headed:t,lockfile:o,runId:i,session:s,signal:l,test:u}){if(!await Li(e,i))return{kind:"dispatch-failed",reason:"already-claimed",runId:i};let m=Fe.join(r,".ripplo","debug"),p=[];return(await s.runOnce({capture:!0,lockfile:o,options:{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:n,generate:C,headed:t,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth},params:void 0,runId:i,sequence:void 0,test:u,onEvent:P=>{p.push(P)}},l)).match(async P=>{await ne({config:e,debugDir:m,events:p,recordingOptional:!1,runId:i,stepSources:void 0});let $e=vn(p).flatMap(Wn=>Wn.findings);return $e.length>0?{findings:$e,kind:"findings",runId:i}:{kind:"pass",runId:i}},async P=>(await wn(e,i,Ke(P)),{error:P,kind:"error",runId:i}))}async function ne({config:e,debugDir:r,events:n,recordingOptional:t,runId:o,stepSources:i}){let s=vn(n),l=gi(r,o);if(l==null&&!t)throw new Error("recording-missing");await Ei({aliases:[...Si(n),...Ri(s)],config:e,generated:xi(n),generatedSingletons:bi(n),origin:l==null?yi(s):l.origin,records:s,rrwebEvents:l==null?[]:l.events,runId:o,stepSources:i}),l!=null&&await Ti(e,o,l),await Fi(e,o,s),await mi(e,r,o)}var fi=R(`
|
|
120
|
+
mutation ClipUploadUrl($runId: ID!) {
|
|
121
|
+
clipUploadUrl(runId: $runId)
|
|
122
|
+
}
|
|
123
|
+
`);async function mi(e,r,n){let t=Fe.join(r,n,"clip.gif");if(xn(t))try{let o=await f({config:e,document:fi,variables:{runId:n}});if(o.clipUploadUrl==null)return;let i=await fetch(o.clipUploadUrl,{body:new Uint8Array(bn(t)),headers:{"Content-Type":"image/gif"},method:"PUT"});i.ok||y.warn({runId:n,status:i.status},"Clip upload failed")}catch(o){y.warn({err:o,runId:n},"Clip upload skipped")}}function yi(e){return e.reduce((r,n)=>Math.min(r,n.startMs),e[0]?.startMs??0)}function vn(e){return e.flatMap(r=>r.kind==="step"?[{annotations:r.annotations,endMs:r.endMs,findings:r.findings,index:r.index,source:r.source,startMs:r.startMs,state:r.state,url:r.url}]:[])}function gi(e,r){let n=Fe.join(e,r,"behavior.jsonl");if(!xn(n))return null;let t=bn(n,"utf8").split(`
|
|
124
|
+
`).filter(i=>i.length>0).map(i=>hi(i)).flatMap(i=>ki(i)?[i.event]:[]),o=t[0];return o==null?null:{events:t,origin:o.timestamp}}function hi(e){return JSON.parse(e)}function ki(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function Si(e){return e.flatMap(r=>r.kind==="world"?r.aliases:[])}function Ri(e){return e.flatMap(r=>{let n=vi(r.source);return n.flatMap(t=>{let i=n.filter(l=>l.entity===t.entity).indexOf(t),s=r.state.rows.filter(l=>l.status==="created"&&l.entity===t.entity).at(i);return s==null?[]:[{alias:t.as,entity:t.entity,key:s.key}]})})}function xi(e){return new Set(e.flatMap(r=>r.kind==="world"?r.generated.map(n=>En(n)):[]))}function En({entity:e,field:r,key:n}){return`${e}\0${n}\0${r}`}function bi(e){return new Set(e.flatMap(r=>r.kind==="world"?r.generatedSingletons:[]))}function vi(e){return e==null?[]:e.expect.flatMap(r=>Te(r))}function Te(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(r=>Te(r)):e.kind==="when"?e.branches.flatMap(r=>r.consequence.flatMap(n=>Te(n))):[]}async function Ei({aliases:e,config:r,generated:n,generatedSingletons:t,origin:o,records:i,rrwebEvents:s,runId:l,stepSources:u}){let d=i.map((m,p)=>Ci({aliases:e,generated:n,generatedSingletons:t,origin:o,record:m,rrwebEvents:s,sourceTest:u?.[p]??null}));await f({config:r,document:$i,variables:{items:[{runId:l,steps:d}]}})}var wi=3,Pi=0;function Ii({endMs:e,rrwebEvents:r,startMs:n}){let t=r.find(o=>o.type===wi&&o.data?.source===Pi&&o.timestamp>=n&&o.timestamp<=e);return t==null?n:t.timestamp}function Ci({aliases:e,generated:r,generatedSingletons:n,origin:t,record:o,rrwebEvents:i,sourceTest:s}){let l=Ve(o.source,o.index),u=Ii({endMs:o.endMs,rrwebEvents:i,startMs:o.startMs}),d=o.annotations.map(p=>({kind:p.kind,label:p.label,outcome:p.outcome,recordingStartMs:Math.max(0,(p.kind==="action"?u:p.atMs)-t),rrwebIds:[...p.rrwebIds]})),m=o.annotations.find(p=>p.kind==="action")?.rrwebIds??[];return{annotations:d,detail:null,duration:Math.max(0,o.endMs-o.startMs),findings:o.findings.map(p=>Sn(p)),nodeType:l.kind,recordingEndMs:Math.max(0,o.endMs-t),recordingStartMs:Math.max(0,u-t),rrwebIds:[...m],snapshotTimestamp:Math.max(0,o.endMs-t),sourceTest:s,stateRows:o.state.rows.map(p=>Ai({aliases:e,generated:r,row:p})),stateSingletons:o.state.singletons.map(p=>({changed:p.changed,generated:n.has(p.name),name:p.name,value:p.value==null?null:String(p.value)})),status:o.findings.length>0?"failed":"passed",stepIndex:o.index,title:kn(l),url:o.url}}function Ai({aliases:e,generated:r,row:n}){let t=e.find(o=>o.entity===n.entity&&o.key===n.key);return{entity:n.entity,fields:n.fields.map(o=>({changed:o.changed,field:o.field,generated:r.has(En({entity:n.entity,field:o.field,key:n.key})),value:o.value==null?null:String(o.value)})),key:n.key,label:t?.alias??n.key,status:n.status}}var ji=ui(di);async function wn(e,r,n){await f({config:e,document:Ni,variables:{reason:n,runId:r}}).catch(t=>{y.error(t,"failRun submission failed")})}async function Ti(e,r,n){let t=n.events.map(s=>JSON.stringify(s)).join(`
|
|
125
|
+
`),o=await ji(Buffer.from(t,"utf8")),i=n.events.at(-1);await f({config:e,document:_i,variables:{input:{bodyBase64:o.toString("base64"),chunkIndex:0,endTimestamp:Math.max(0,(i?.timestamp??n.origin)-n.origin),eventCount:n.events.length,runId:r,startTimestamp:0}}})}async function Fi(e,r,n){let t=n.filter(s=>s.findings.length>0).length,o=n.length-t,i=n.reduce((s,l)=>s+Math.max(0,l.endMs-l.startMs),0);await f({config:e,document:Oi,variables:{items:[{duration:i,failCount:t,passCount:o,runId:r,status:t>0?"failed":"passed",summary:null,warnCount:0}]}})}async function Li(e,r){return((await f({config:e,document:Mi,variables:{runIds:[r]}})).startRunsBatch??[]).some(t=>t.id===r)}var Mi=R(`
|
|
126
|
+
mutation StartRunsBatch($runIds: [String!]!) {
|
|
127
|
+
startRunsBatch(runIds: $runIds) {
|
|
128
|
+
id
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
`),$i=R(`
|
|
132
|
+
mutation SubmitRunStepsBatch($items: [SubmitRunStepsItem!]!) {
|
|
133
|
+
submitRunStepsBatch(items: $items)
|
|
134
|
+
}
|
|
135
|
+
`),_i=R(`
|
|
136
|
+
mutation SubmitRunRecordingChunk($input: SubmitRunRecordingChunkInput!) {
|
|
137
|
+
submitRunRecordingChunk(input: $input)
|
|
138
|
+
}
|
|
139
|
+
`),Oi=R(`
|
|
140
|
+
mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
|
|
141
|
+
completeRunsBatch(items: $items) {
|
|
142
|
+
id
|
|
143
|
+
status
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
`),Ni=R(`
|
|
147
|
+
mutation FailRun($runId: String!, $reason: String!) {
|
|
148
|
+
failRun(runId: $runId, reason: $reason)
|
|
149
|
+
}
|
|
150
|
+
`),Hc=R(`
|
|
151
|
+
mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
|
|
152
|
+
markRunArtifactsUploadedBatch(runIds: $runIds)
|
|
153
|
+
}
|
|
154
|
+
`);async function Di({baseState:e,branchName:r,category:n,commitSha:t,config:o,debugDir:i,devSessionId:s,events:l,lockfileHash:u,runId:d,signature:m,spec:p,stepSources:g}){await f({config:o,document:Ui,variables:{branchName:r??null,commitSha:t??null,devSessionId:s??null,lockfileHash:u??null,projectId:o.projectId,runId:d,spec:p??null}}),await ne({config:o,debugDir:i,events:l,recordingOptional:!0,runId:d,stepSources:g}),await f({config:o,document:Wi,variables:{baseState:e,category:n,projectId:o.projectId,reproRunId:d,signature:m}})}async function Hi(e,r,n){await f({config:e,document:qi,variables:{projectId:e.projectId,signature:r,status:n}})}var Ui=te(`
|
|
155
|
+
mutation CreateExploreRun(
|
|
156
|
+
$projectId: String!
|
|
157
|
+
$runId: String!
|
|
158
|
+
$devSessionId: String
|
|
159
|
+
$branchName: String
|
|
160
|
+
$commitSha: String
|
|
161
|
+
$lockfileHash: String
|
|
162
|
+
$spec: String
|
|
163
|
+
) {
|
|
164
|
+
createExploreRun(
|
|
165
|
+
projectId: $projectId
|
|
166
|
+
runId: $runId
|
|
167
|
+
devSessionId: $devSessionId
|
|
168
|
+
branchName: $branchName
|
|
169
|
+
commitSha: $commitSha
|
|
170
|
+
lockfileHash: $lockfileHash
|
|
171
|
+
spec: $spec
|
|
172
|
+
) {
|
|
173
|
+
id
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
`),Wi=te(`
|
|
177
|
+
mutation SubmitExploreFinding(
|
|
178
|
+
$projectId: String!
|
|
179
|
+
$signature: String!
|
|
180
|
+
$baseState: String!
|
|
181
|
+
$category: ExploreFindingCategory!
|
|
182
|
+
$reproRunId: String!
|
|
183
|
+
) {
|
|
184
|
+
submitExploreFinding(
|
|
185
|
+
projectId: $projectId
|
|
186
|
+
signature: $signature
|
|
187
|
+
baseState: $baseState
|
|
188
|
+
category: $category
|
|
189
|
+
reproRunId: $reproRunId
|
|
190
|
+
) {
|
|
191
|
+
id
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
`),qi=te(`
|
|
195
|
+
mutation SetExploreFindingStatus(
|
|
196
|
+
$projectId: String!
|
|
197
|
+
$signature: String!
|
|
198
|
+
$status: ExploreFindingStatus!
|
|
199
|
+
) {
|
|
200
|
+
setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
|
|
201
|
+
}
|
|
202
|
+
`),Vc=te(`
|
|
203
|
+
query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
|
|
204
|
+
exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
|
|
205
|
+
}
|
|
206
|
+
`);import Bi from"fs";import{lockSync as Vi}from"proper-lockfile";var Ki="explorer.lock",zi=15e3,Ji=15e3;function Gi(){return De(Ki)}function rd({onChange:e}){let r={release:null,stopped:!1},n=()=>{r.release=null,r.stopped||e(!1)},t=()=>{if(r.stopped||r.release!=null)return;let i=Qi(n);i!=null&&(r.release=i,e(!0))};t();let o=setInterval(t,Ji);return{holder:()=>r.release!=null,stop:()=>{r.stopped=!0,clearInterval(o),r.release?.(),r.release=null}}}function Qi(e){try{Ne();let r=Gi(),n=Vi(r,{onCompromised:e,realpath:!1,stale:zi});return Bi.writeFileSync(r,String(process.pid)),()=>{try{n()}catch{}}}catch{return null}}import Xi from"path";import{randomUUID as Yi}from"crypto";function Pn(e){return{axes:[Qe("unit"),Xe(e)]}}var In=12,Cn=15,An=4,jn=2;var Ln={covered:0,deferred:0,findings:0,saturated:!1,total:0};function dd(){return{priority:"p3",next:()=>null,onResult:()=>{},ready:()=>Promise.resolve(),status:()=>Ln,stop:()=>Promise.resolve()}}function ud(e){let r={claimed:new Set,consecutiveErrors:0,covered:new Set,deferred:new Map,findings:0,haltedUntil:0,prepared:null,preparing:!1,refreshing:!1,saturated:!1,tick:0},n=Le(e,r);return{priority:"p3",next:()=>oa(e,r),onResult:()=>{},ready:()=>n,status:()=>r.prepared==null?Ln:na(r.prepared,r),stop:()=>Promise.resolve()}}async function Le(e,r){if(!r.preparing){r.preparing=!0;try{let n=await e.loadLockfile();if(n==null)return;let t=await Zi(n);if(t==null)return;await D(Mn(e.cwd)).match(o=>{let i=N(o);r.covered=new Set(i.covered),r.findings=[...i.findings.values()].filter(s=>s.resolvedAt==null).length,r.prepared=t,r.consecutiveErrors=0,r.haltedUntil=0,r.deferred.clear(),e.notifyWork()},o=>{y.warn("explore findings log unreadable, exploration disabled: %s",o.kind)})}finally{r.preparing=!1}}}async function Zi({fingerprint:e,lockfile:r}){let n=Pn(r),t=Je(r);if(t.length===0)return null;let o=ir(r,{sweep:!1}),i=await ea(r,o),s=rr({baseStates:i,corpus:t,lens:n,maxCount:jn,maxDepth:An});return{actionHashes:t.map(l=>er(r,l)),baseStates:o,corpus:t,fingerprint:e,graph:s,lens:n,lensIdValue:Ge(n),lockfile:r,lockfileHashValue:_(r)}}async function ea(e,r){let n={generate:C,materialize:ze(C,e.valueSpaces),params:void 0};return(await Promise.all(r.map(async o=>(await ar(e,o,n)).match(s=>({name:o.name,snapshot:s.snapshot}),()=>null)))).flatMap(o=>o==null?[]:[o])}var Tn=20,ra=6e5,Fn=3e5;function na(e,r){let n=tr(e.graph),t=nr({actionHashes:e.actionHashes,corpus:e.corpus,covered:r.covered,graph:e.graph,lensId:e.lensIdValue,tick:r.tick});return{covered:n-t,deferred:_n(r).size,findings:r.findings,saturated:r.saturated,total:n}}async function ta(e,r){if(!(r.refreshing||r.preparing||r.prepared==null)){r.refreshing=!0;try{let n=await e.loadLockfile();if(n==null||n.fingerprint===r.prepared.fingerprint)return;y.info("workflow definitions changed, re-preparing exploration targets"),r.prepared=null,await Le(e,r)}finally{r.refreshing=!1}}}function oa(e,r){ta(e,r);let n=r.prepared;if(n==null||Date.now()<r.haltedUntil)return null;let t=or({actionHashes:n.actionHashes,corpus:n.corpus,covered:new Set([...r.covered,...r.claimed,..._n(r)]),graph:n.graph,lensId:n.lensIdValue,tick:r.tick});if(r.tick+=1,t.kind==="saturated")return r.saturated=!0,null;r.saturated=!1;let o=pa(n,t.target);return r.claimed.add(o),{id:`explore:${Yi()}`,label:t.target.targetKey,run:i=>ia({choice:t.target,key:o,params:e,prepared:n,signal:i,state:r})}}async function ia({choice:e,key:r,params:n,prepared:t,signal:o,state:i}){try{let s=sa({choice:e,params:n,prepared:t});if(s==null)return;if(!await n.probeApp()){$n(i,"app-unreachable");return}let l=await n.executeTrail(s,o);if(l.kind==="aborted")return;if(l.kind==="error"){ca({key:r,params:n,reason:l.reason,state:i});return}i.consecutiveErrors=0,y.info("exploration trail %s: %s @ %s",l.kind,l.trail.map(u=>u.label).join(" -> "),e.targetKey.slice(0,80)),n.onTrailDone?.({kind:l.kind,label:e.targetKey,trail:l.trail}),await la({outcome:aa(l,e,t),params:n,state:i})}finally{i.claimed.delete(r)}}function aa(e,r,n){let t={actionHash:r.actionHash,at:new Date().toISOString(),kind:"covered",lensId:n.lensIdValue,targetKey:r.targetKey};return{...e,rows:[...e.rows,t]}}function sa({choice:e,params:r,prepared:n}){let t=n.baseStates.find(o=>o.name===e.witness.baseState);return t==null?null:{baseStateTest:t.test,lensId:n.lensIdValue,lockfileFingerprint:n.fingerprint,lockfileHash:n.lockfileHashValue,maxLength:r.maxTrailLength??In,shrinkBudget:Cn,stepRuns:e.witness.trail.map(o=>({idx:o.idx,params:o.params}))}}async function la({outcome:e,params:r,state:n}){let t=e.rows.filter(o=>o.kind!=="covered"||!n.covered.has(O(o)));t.forEach(o=>{(o.kind==="covered"||o.kind==="finding"||o.kind==="flaky-candidate")&&n.covered.add(O(o))}),e.kind==="finding"&&(n.findings+=1,y.info("exploration finding recorded")),t.length!==0&&await Ze(Mn(r.cwd),t).match(()=>{},o=>{y.warn("explore findings log append failed: %s",o.kind)})}function Mn(e){return Xi.join(e,".ripplo",".local","explore-ledger.jsonl")}function ca({key:e,params:r,reason:n,state:t}){if(n==="lockfile:fingerprint-mismatch"){da(r,t);return}ua(t,e),$n(t,n)}function da(e,r){r.preparing||(r.prepared=null,Le(e,r))}function ua(e,r){e.deferred.set(r,Date.now()+ra)}function $n(e,r){e.consecutiveErrors+=1,y.debug("exploration trail error: %s",r),e.consecutiveErrors>=Tn&&(e.haltedUntil=Date.now()+Fn,e.consecutiveErrors=0,y.warn("exploration cooling down for %ds after %d consecutive trail errors (last: %s)",Fn/1e3,Tn,r))}function _n(e){let r=Date.now();return[...e.deferred].filter(([,n])=>n<=r).forEach(([n])=>e.deferred.delete(n)),new Set(e.deferred.keys())}function pa(e,r){return O({actionHash:r.actionHash,lensId:e.lensIdValue,targetKey:r.targetKey})}import fa from"path";var ma=3;function yd(e){return D(ya(e)).map(r=>ga(N(r)))}function ya(e){return fa.join(e,".ripplo",".local","explore-ledger.jsonl")}function ga(e){let r=[...e.findings.entries()].filter(([,t])=>t.resolvedAt==null).map(([t,o])=>ha(t,o)).toSorted(Sa),n=[...e.flaky.entries()].filter(([,t])=>t.occurrences>=ma).map(([t,o])=>ka(t,o)).toSorted((t,o)=>o.occurrences-t.occurrences);return{pending:r,recurrentFlaky:n}}function ha(e,r){let n=r.latest;return{baseState:n.baseState,evidence:n.evidence,firstSeen:r.first.at,id:ie(e),lastSeen:n.at,occurrences:r.occurrences,parts:n.parts,runId:n.runId,trail:n.trail,verifierLayer:n.verifierLayer}}function ka(e,r){return{at:r.first.at,baseState:r.first.baseState,id:ie(e),occurrences:r.occurrences,trail:r.first.trail}}var On={crash:0,"data-rule":1,frame:3,"page-rule":2};function Sa(e,r){let n=On[e.verifierLayer]-On[r.verifierLayer];return n===0?r.occurrences-e.occurrences:n}import{createMessageConnection as Nn,IPCMessageReader as Dn,IPCMessageWriter as Hn,NotificationType as Ra,NotificationType0 as Un,RequestType as Me}from"vscode-jsonrpc/node";import{z as c}from"zod";var bd=c.object({headed:c.boolean(),lockfileFingerprint:c.string(),runId:c.string().min(1),testRef:c.string().min(1)}),vd=c.object({fingerprint:c.string()}),Ed=c.object({lockfileJson:c.string().optional(),unavailable:c.string().optional()}),xa=c.enum(["unspecified","internal","server","client","producer","consumer"]),ba=c.enum(["unset","ok","error"]),va=c.object({attributes:c.record(c.string(),c.string()),durationMs:c.number(),kind:c.literal("span"),name:c.string(),parentSpanId:c.union([c.string(),c.undefined()]),source:c.literal("server"),spanId:c.string(),spanKind:xa,status:c.object({code:ba,message:c.union([c.string(),c.undefined()])}),timeNanos:c.string(),traceId:c.string()}),wd=c.object({runId:c.string().min(1),span:va}),Pd=c.object({outcome:we,serverNotified:c.boolean()}),Id=c.object({baseStateTest:We,lensId:c.string().min(1),lockfileFingerprint:c.string(),lockfileHash:c.string().min(1),maxLength:c.number().int().positive(),shrinkBudget:c.number().int().nonnegative(),stepRuns:c.array(c.object({idx:c.number().int().nonnegative(),params:c.record(c.string(),c.union([Ue,c.null()]))}))}),Ea=c.object({actions:c.array(c.string()),label:c.string().min(1)}),Cd=c.object({kind:c.enum(["aborted","clean","error","flaky","finding"]),reason:c.string().optional(),rows:c.array(Ye),trail:c.array(Ea).default([])}),Ad=new Un("worker/ready"),jd=new Me("worker/run"),Td=new Me("worker/lockfile"),Fd=new Me("worker/exploreTrail"),Ld=new Ra("worker/span"),Md=new Un("worker/shutdown");function $d(e){let r=Nn(new Dn(e),new Hn(e));return r.listen(),r}function _d(){let e=Nn(new Dn(process),new Hn(process));return e.listen(),e}export{Aa as a,Oa as b,V as c,Qn as d,K as e,fe as f,v as g,dt as h,F as i,E as j,is as k,G as l,ds as m,us as n,ps as o,ks as p,he as q,Rr as r,br as s,Ts as t,Cr as u,Re as v,_s as w,re as x,hn as y,fc as z,mc as A,yc as B,ni as C,wc as D,pi as E,wn as F,Di as G,Hi as H,rd as I,Pn as J,dd as K,ud as L,yd as M,ya as N,ul as O,pl as P,Or as Q,fl as R,ml as S,yl as T,gl as U,hl as V,kl as W,Hr as X,Ur as Y,Wr as Z,qr as _,Br as $,Vr as aa,Ds as ba,Hs as ca,xe as da,Us as ea,jr as fa,nl as ga,Ee as ha,ln as ia,tc as ja,bd as ka,vd as la,wd as ma,Pd as na,Id as oa,Cd as pa,Ad as qa,jd as ra,Td as sa,Fd as ta,Ld as ua,Md as va,$d as wa,_d as xa,ic as ya};
|