ripplo 0.7.27 → 0.7.29
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-RJNO37CR.js +220 -0
- package/dist/{chunk-3DQXKHCR.js → chunk-UODLSLH7.js} +6 -6
- package/dist/daemon-SACK4YJZ.js +94 -0
- package/dist/{daemon-2VCH67XS.js → daemon-W57NHXDG.js} +1 -1
- package/dist/index.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-OPYF32NG.js +0 -220
- package/dist/daemon-APONU377.js +0 -92
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{$ as Ee,A as oe,C as ce,E as de,S as Se,U as ke,V as ve,W as we,X as be,Y as xe,Z as he,_ as Pe,b as G,ba as E,ca as R,da as Re,e as J,ea as _,fa as Ce,h as v,ha as M,i as D,ia as Ie,ja as Te,l as H,la as C,oa as We,q as Z,t as P,v as ee,w as re}from"./chunk-RJNO37CR.js";import{A as ae,B as se,K as le,P as ue,Q as pe,R as fe,S as me,T as ye,U as ge,b as V,e as K,f as X,i as Y,k as ne,w as te,z as ie}from"./chunk-UODLSLH7.js";import{b as Ae}from"./chunk-RLXQYG7H.js";import{c as z,d as k,e as l,f as L,g as Q}from"./chunk-5VRJXHWH.js";import"./chunk-IHSHBPJY.js";import"./chunk-7UWDMECF.js";import Co from"path";import{createClient as Io}from"graphql-sse";import To,{AbortError as Wo}from"p-retry";import{graphql as $}from"gql.tada";import{graphql as Cr}from"gql.tada";import{print as Ir}from"graphql";async function Le({config:e,cwd:r,headed:o,pool:n,runId:t,signal:i,testSlug:a,workClass:s,workflowSlug:c}){let{fingerprint:d,result:u}=await v(r);if(u.isErr())return await C(e,t,`lockfile:${u.error.kind}`),{kind:"dispatch-error",reason:{detail:`lockfile:${u.error.kind}`,type:"generic"}};let S=Rr(u.value,{testSlug:a,workflowSlug:c});if(S==null)return await C(e,t,`no-test:${c}/${a}`),{kind:"dispatch-error",reason:{detail:`no-test:${c}/${a}`,type:"generic"}};let p=await E({headed:o,workClass:s,task:()=>n.execute({headed:o,lockfileFingerprint:d,runId:t,testRef:S},i)});return!p.serverNotified&&p.outcome.kind==="error"&&await C(e,t,p.outcome.detail),p.outcome}function Rr(e,{testSlug:r,workflowSlug:o}){let t=e.workflows.find(i=>Y(i.name)===o)?.tests.find(i=>i.slug===r);return t==null?void 0:ne(t)}var Tr=6e4,Wr=Cr(`
|
|
3
|
+
subscription RunRequestedWatch($devSessionId: String!) {
|
|
4
|
+
runRequested(devSessionId: $devSessionId) {
|
|
5
|
+
runId
|
|
6
|
+
testSlug
|
|
7
|
+
workflowId
|
|
8
|
+
workflowSlug
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`);async function De(e){let r=Math.min(1e3*2**e,Tr)+Dr();await new Promise(o=>setTimeout(o,r))}function He({claim:e,cwd:r,devSessionId:o,onSubscriptionDead:n,pool:t,sseClient:i,sseHealth:a}){let s=new Set;return i.subscribe({query:Ir(Wr),variables:{devSessionId:o}},{complete:()=>{},error:c=>{let d=c instanceof Error?c.message:String(c);l.warn("runRequested SSE failed: %s; re-registering session",d),n(d)},next:c=>{Ar({claim:e,cwd:r,event:c.data?.runRequested,inFlightRunIds:s,pool:t})}},{connected:()=>{a.onConnected()},connecting:c=>{a.onConnecting(c),c&&l.debug("runRequested SSE reconnecting")}})}function Ar({claim:e,cwd:r,event:o,inFlightRunIds:n,pool:t}){if(o==null)return;if(n.has(o.runId)){l.warn({runId:o.runId,workflowSlug:o.workflowSlug},"duplicate runRequested event; skipping dispatch");return}n.add(o.runId),process.stdout.write(`ripplo: run ${o.workflowSlug}
|
|
12
|
+
`),G(r);let i=P(r).match(s=>s,s=>{l.error({failure:s,runId:o.runId},"failed to load env for run dispatch; skipping")});if(i==null){n.delete(o.runId);return}let a=Lr(e(o.runId),o);a.started(),Le({config:i,cwd:r,headed:a.headed,pool:t,runId:o.runId,signal:a.signal,testSlug:o.testSlug,workClass:a.workClass,workflowSlug:o.workflowSlug}).then(s=>{a.finished(s)}).catch(s=>{l.error({err:s,runId:o.runId,workflowSlug:o.workflowSlug},"run execution failed; daemon continuing"),a.finished({detail:s instanceof Error?s.message:String(s),kind:"error"})}).finally(()=>{n.delete(o.runId)})}function Lr(e,r){return e==null?(l.debug({runId:r.runId,workflowSlug:r.workflowSlug},"dispatching unclaimed run (externally triggered or replayed)"),{headed:!1,signal:new AbortController().signal,workClass:"p0-ui",finished:()=>{},started:()=>{}}):{headed:e.headed,signal:Ie(e.token),workClass:"p1-cli",finished:o=>{e.finished(r.runId,o)},started:()=>{e.started(r.runId)}}}function Dr(){return Math.floor(Math.random()*2700)+300}import{graphql as Hr}from"gql.tada";import{print as _r}from"graphql";var Mr=Hr(`
|
|
13
|
+
subscription TeleportRequestedWatch($devSessionId: String!) {
|
|
14
|
+
teleportRequested(devSessionId: $devSessionId) {
|
|
15
|
+
runId
|
|
16
|
+
stepIndex
|
|
17
|
+
testSlug
|
|
18
|
+
workflowSlug
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`);function _e({cwd:e,devSessionId:r,onSubscriptionDead:o,sseClient:n}){let t=new Set,i=n.subscribe({query:_r(Mr),variables:{devSessionId:r}},{complete:()=>{},error:a=>{let s=a instanceof Error?a.message:String(a);l.warn("teleportRequested SSE failed: %s; re-registering session",s),o(s)},next:a=>{qr({cwd:e,event:a.data?.teleportRequested,running:t})}});return()=>{t.forEach(a=>{a.abort()}),t.clear(),i()}}function qr({cwd:e,event:r,running:o}){if(r==null)return;let n=`${r.workflowSlug}/${r.testSlug}`,t=new AbortController;o.add(t),process.stdout.write(`ripplo: teleport ${n} step ${String(r.stepIndex+1)}
|
|
22
|
+
`),We({cwd:e,ref:n,signal:t.signal,step:r.stepIndex+1}).then(i=>{i.kind!=="done"&&l.warn({kind:i.kind,ref:n},"teleport could not open")}).catch(i=>{l.error({err:i,ref:n},"teleport failed; daemon continuing")}).finally(()=>{o.delete(t)})}function Me(){let e=!0,r,o=null,n=()=>{o!=null&&(clearTimeout(o),o=null)};return{markUnhealthy:t=>{e=!1,r=t,n()},onConnected:()=>{n(),o=setTimeout(()=>{e=!0,r=void 0,o=null},1e4)},onConnecting:()=>{n()},snapshot:()=>({detail:r,ok:e})}}import Fr from"fs";import Ne from"net";import{err as Ue,ok as Or}from"neverthrow";async function $e({cwd:e,onConnection:r}){Q(e);let o=de(e),n=await qe({onConnection:r,socketPath:o});return n.isOk()||n.error.kind!=="stale-candidate"?n.map(Fe(o)).mapErr(Oe(o)):await Nr(o)?Ue({kind:"already-running",socketPath:o}):(je(o),(await qe({onConnection:r,socketPath:o})).map(Fe(o)).mapErr(Oe(o)))}function Nr(e){return new Promise(r=>{let o=Ne.connect(e);o.once("connect",()=>{o.destroy(),r(!0)}),o.once("error",()=>{r(!1)})})}async function qe(e){let r=await Ur(e);return r.kind==="listening"?Or(r.server):Ue(r.error)}function Ur({onConnection:e,socketPath:r}){return new Promise(o=>{let n=Ne.createServer(e);n.once("error",t=>{o({error:t.code==="EADDRINUSE"?{kind:"stale-candidate"}:{kind:"listen-failed",message:t.message},kind:"failed"})}),n.listen(r,()=>{o({kind:"listening",server:n})})})}function Fe(e){return r=>({socketPath:e,close:()=>{r.close(),je(e)}})}function je(e){Fr.rmSync(e,{force:!0})}function Oe(e){return r=>r.kind==="stale-candidate"?{kind:"already-running",socketPath:e}:{kind:"bind-failed",message:r.message}}import{randomInt as $r,randomUUID as jr}from"crypto";function Ge(e){let r={attempts:0,consecutiveErrors:0,findings:0,haltedUntil:0,prepared:null,preparing:!1,refreshing:!1,windowAttempts:0,windowFindings:0,windowStartMs:Date.now()},o=q(e,r);return{priority:"p3",next:()=>Gr(e,r),onResult:()=>{},ready:()=>o,status:()=>({attempts:r.attempts,findings:r.findings}),stop:()=>Promise.resolve()}}var Br=10;async function q(e,r){if(!r.preparing){r.preparing=!0;try{let o=await e.loadLockfile(),n=o==null?null:await zr(o);if(n==null)return;r.prepared=n,r.consecutiveErrors=0,r.haltedUntil=0,e.notifyWork()}finally{r.preparing=!1}}}async function zr({fingerprint:e,lockfile:r}){let o=await ae(r);return o==null?null:{exploration:o,fingerprint:e,lockfileHashValue:X(r),strategy:te("even")}}var Be=20,ze=3e5;async function Qr(e,r){if(!(r.refreshing||r.preparing||r.prepared==null)){r.refreshing=!0;try{let o=await e.loadLockfile();if(o==null||o.fingerprint===r.prepared.fingerprint)return;l.info("workflow definitions changed, re-preparing exploration"),r.prepared=null,await q(e,r)}finally{r.refreshing=!1}}}function Gr(e,r){Qr(e,r);let o=r.prepared;if(o==null||Date.now()<r.haltedUntil)return null;let n=se({lockfileFingerprint:o.fingerprint,lockfileHash:o.lockfileHashValue,prepared:o.exploration,random:Jr,strategy:{...o.strategy,maxAttemptLength:e.maxTrailLength()}});if(n==null)return null;let t=n.baseStateTest.name;return{id:`explore:${jr()}`,label:t,run:i=>Vr({assign:n,params:e,signal:i,state:r})}}var Qe=2**31;function Jr(){return $r(Qe)/Qe}async function Vr({assign:e,params:r,signal:o,state:n}){if(!await r.probeApp()){Je(n,"app-unreachable");return}let t=await r.executeTrail(e,o);if(t.kind!=="aborted"){if(t.kind==="error"){Xr({params:r,reason:t.reason,state:n});return}n.consecutiveErrors=0,n.attempts+=1,n.windowAttempts+=1,t.kind==="finding"&&(n.findings+=1,n.windowFindings+=1,l.info("exploration finding recorded")),n.windowAttempts>=Br&&Kr(n)}}function Kr(e){let r=Date.now()-e.windowStartMs;l.info({attempts:e.windowAttempts,avgTrailMs:Math.round(r/e.windowAttempts),findings:e.windowFindings,windowMs:r,yield:Number((e.windowFindings/e.windowAttempts).toFixed(3))},"explore window"),e.windowAttempts=0,e.windowFindings=0,e.windowStartMs=Date.now()}function Xr({params:e,reason:r,state:o}){if(r==="lockfile:fingerprint-mismatch"){Yr(e,o);return}Je(o,r)}function Yr(e,r){r.preparing||(r.prepared=null,q(e,r))}function Je(e,r){e.consecutiveErrors+=1,l.debug("exploration trail error: %s",r),e.consecutiveErrors>=Be&&(e.haltedUntil=Date.now()+ze,e.consecutiveErrors=0,l.warn("exploration cooling down for %ds after %d consecutive trail errors (last: %s)",ze/1e3,Be,r))}function Zr(e){let{backoffActive:r,exploreEnabled:o,headedActive:n,interactiveActive:t,interactiveQueued:i}=e,{explorationActive:a,exploreConcurrency:s,poolSize:c}=e;if(!o||n||i>0)return{abortCount:a,refillCount:0};if(r)return{abortCount:0,refillCount:0};let d=Math.min(s,c-1,c-t);return{abortCount:0,refillCount:Math.max(0,d-a)}}function Xe(e){let r={active:new Map,backoffUntil:0,cancelBackoffTimer:null,cancelHeartbeat:null,prevInteractiveActive:e.probe().interactiveActive,stopped:!1};return Ye(r,e),{explorationActive:()=>r.active.size,notifyQueueChange:()=>{eo(r,e)},stop:()=>{r.stopped=!0,r.cancelBackoffTimer?.(),r.cancelBackoffTimer=null,r.cancelHeartbeat?.(),r.cancelHeartbeat=null,Ze(r,r.active.size)}}}function Ye(e,r){e.stopped||(e.cancelHeartbeat=r.setTimer(()=>{I(e,r),Ye(e,r)},15e3))}function I(e,r){if(e.stopped)return;let o=r.probe(),n=Zr({backoffActive:r.now()<e.backoffUntil,explorationActive:e.active.size,exploreConcurrency:r.exploreConcurrency(),exploreEnabled:r.exploreEnabled(),headedActive:o.headedActive>0,interactiveActive:o.interactiveActive,interactiveQueued:o.interactiveQueued,poolSize:o.poolSize});Ze(e,n.abortCount),er({count:n.refillCount,params:r,state:e})}function Ze(e,r){[...e.active.values()].slice(0,r).forEach(({controller:o})=>{o.abort()})}function eo(e,r){let o=r.probe();o.interactiveActive<e.prevInteractiveActive&&ro(e,r),e.prevInteractiveActive=o.interactiveActive,I(e,r)}function ro(e,r){e.backoffUntil=r.now()+3e4,e.cancelBackoffTimer?.(),e.cancelBackoffTimer=r.setTimer(()=>{e.cancelBackoffTimer=null,I(e,r)},3e4)}function er({count:e,params:r,state:o}){if(e<=0)return;let n=oo(r.sources);n!=null&&(no({params:r,pulled:n,state:o}),er({count:e-1,params:r,state:o}))}function oo(e){return e.reduce((r,o)=>{if(r!=null)return r;let n=o.next();return n==null?null:{job:n,source:o}},null)}function no({params:e,pulled:r,state:o}){let{job:n,source:t}=r,i=new AbortController;o.active.set(n.id,{controller:i,job:n,source:t}),e.execute({job:n,priority:t.priority,signal:i.signal}).then(()=>{Ke({job:n,outcome:Ve(i.signal,null),params:e,source:t,state:o})}).catch(a=>{Ke({job:n,outcome:Ve(i.signal,{error:a}),params:e,source:t,state:o})})}function Ve(e,r){return e.aborted?{kind:"aborted"}:r==null?{kind:"completed"}:{error:r.error,kind:"error"}}function Ke({job:e,outcome:r,params:o,source:n,state:t}){t.active.delete(e.id),n.onResult(e,r),I(t,o)}function F(e){return{priority:e,next:()=>null,onResult:()=>{}}}var io=12;function rr({config:e,executor:r,pool:o}){return ao({appUrl:e.appUrl,cwd:e.cwd,localExecutor:r==="local",executeTrail:async(n,t)=>(await o).exploreTrail(n,t)})}function ao({appUrl:e,cwd:r,executeTrail:o,localExecutor:n}){let t={concurrency:2,enabled:!1,maxTrailLength:io},i={notify:()=>{}},a=so({appUrl:e,cwd:r,executeTrail:o,maxTrailLength:()=>t.maxTrailLength,notifyWork:()=>{i.notify()}}),s=Xe({now:Date.now,probe:lo,setTimer:co,sources:[F("p0"),F("p1"),a],execute:({job:c,priority:d,signal:u})=>E({headed:!1,workClass:uo(d),task:()=>c.run(u)}),exploreConcurrency:()=>t.concurrency,exploreEnabled:()=>t.enabled});return _(()=>{s.notifyQueueChange()}),i.notify=()=>{s.notifyQueueChange()},{progress:()=>a.status(),setConcurrency:c=>{n&&c!==t.concurrency&&l.info({workers:c},"explore local worker count changed"),t.concurrency=c,s.notifyQueueChange()},setEnabled:c=>{t.enabled=c&&n,s.notifyQueueChange()},setMaxTrailLength:c=>{t.maxTrailLength=c},status:()=>({explorer:t.enabled?"on":"off",exploring:s.explorationActive(),progress:a.status()}),stop:()=>{s.stop(),_(null),a.stop()}}}function so({appUrl:e,cwd:r,executeTrail:o,maxTrailLength:n,notifyWork:t}){return Ge({cwd:r,executeTrail:o,maxTrailLength:n,notifyWork:t,loadLockfile:async()=>{let{fingerprint:i,result:a}=await v(r);return a.match(s=>({fingerprint:i,lockfile:s}),()=>null)},probeApp:async()=>await oe(e)==null})}function lo(){let e=Re();return{headedActive:e.headedActive,interactiveActive:e.active,interactiveQueued:e.queued,poolSize:e.poolSize}}function co(e,r){let o=setTimeout(e,r);return()=>{clearTimeout(o)}}function uo(e){switch(e){case"p0":return"p0-ui";case"p1":return"p1-cli";case"p2":return"p2-cover";case"p3":return"p3-explore"}}import{fork as po}from"child_process";import or from"os";import{CancellationTokenSource as nr,ResponseError as tr}from"vscode-jsonrpc/node";function ir(e,r){return()=>{let o=po(e,["run-worker"],{cwd:r,detached:!0,stdio:["ignore","inherit","inherit","ipc"]});return{connection:Ee(o),kill:()=>{fo(o)},onExit:n=>{o.once("exit",n)}}}}function ar(e){let r={closed:!1,lockfileProvider:e.lockfileProvider,nextId:0,size:e.initialSize,spawn:e.spawn,waiters:[],workers:[]};return{close:async()=>{r.closed=!0,await Promise.all([...r.workers].map(o=>O(o,r)))},execute:(o,n)=>yo(o,n,r),exploreTrail:(o,n)=>ko(o,n,r),routeSpan:(o,n)=>{let t=r.workers.find(i=>i.runId===o);t?.worker.connection.sendNotification(he,{runId:o,span:n})},setSize:o=>{wo(o,r)}}}function fo(e){let r=e.pid;if(r!=null)try{process.kill(-r,"SIGKILL")}catch{e.kill("SIGKILL")}}var mo=1e4,sr=-32800;async function yo(e,r,o){let n=await lr(o);if(n.runId=e.runId,!n.alive)return T(n,o),{outcome:{detail:"worker-exit",kind:"error"},serverNotified:!1};let t=new nr,i=()=>{t.cancel()};r.aborted&&t.cancel(),r.addEventListener("abort",i,{once:!0});try{let a=await n.worker.connection.sendRequest(we,e,t.token),s=ke.safeParse(a);return s.success?s.data:{outcome:{detail:"bad-outcome-frame",kind:"error"},serverNotified:!1}}catch(a){return So(a,n)}finally{r.removeEventListener("abort",i),t.dispose(),T(n,o)}}async function lr(e){let r=e.workers.find(o=>o.alive&&o.runId===void 0);if(r!=null)return r.runId="pending",r;if(e.workers.length<e.size){let o=go(e);return o.runId="pending",await o.ready,o}return new Promise(o=>{e.waiters.push(n=>{n.runId="pending",o(n)})})}function go(e){let r=e.spawn(),o={resolve:()=>{}},n={alive:!0,id:e.nextId,ready:new Promise(t=>{o.resolve=t,r.connection.onNotification(ve,t)}),runId:void 0,worker:r};return e.nextId+=1,r.connection.onRequest(be,async t=>{let i=Se.safeParse(t);return i.success?e.lockfileProvider(i.data.fingerprint):{unavailable:"bad-lockfile-request"}}),r.onExit(()=>{n.alive=!1,e.workers=e.workers.filter(t=>t!==n),r.connection.dispose(),o.resolve()}),e.workers.push(n),n}function T(e,r){if(e.runId=void 0,!e.alive||r.closed)return;if(r.workers.length>r.size){O(e,r);return}let o=r.waiters.shift();o?.(e)}async function O(e,r){if(r.workers=r.workers.filter(t=>t!==e),!e.alive)return;let o=new Promise(t=>{e.worker.onExit(t)});await e.worker.connection.sendNotification(Pe).catch(()=>{});let n=setTimeout(()=>{e.worker.kill()},mo);await o,clearTimeout(n)}function So(e,r){return e instanceof tr&&e.code===sr?{outcome:{detail:"aborted",kind:"error"},serverNotified:!1}:r.alive?{outcome:{detail:e instanceof Error?e.message:String(e),kind:"error"},serverNotified:!1}:{outcome:{detail:"worker-exit",kind:"error"},serverNotified:!1}}async function ko(e,r,o){let n=await lr(o);if(n.runId="explore",!n.alive)return T(n,o),{kind:"error"};let t=new nr,i=()=>{t.cancel()};r.aborted&&t.cancel(),r.addEventListener("abort",i,{once:!0});try{let a=await n.worker.connection.sendRequest(xe,e,t.token),s=ie.safeParse(a);return s.success?s.data:{kind:"error"}}catch(a){return vo(a)}finally{r.removeEventListener("abort",i),t.dispose(),T(n,o)}}function vo(e){return e instanceof tr&&e.code===sr?{kind:"aborted"}:{kind:"error",reason:`transport:${e instanceof Error?e.message.slice(0,120):"unknown"}`}}function wo(e,r){r.size=e,e>or.availableParallelism()&&l.warn({cores:or.availableParallelism(),size:e},"worker pool size exceeds available cores");let o=r.workers.filter(t=>t.alive&&t.runId===void 0),n=r.workers.length-e;o.slice(0,Math.max(0,n)).forEach(t=>{O(t,r)})}import W from"fs";import{graphql as x}from"gql.tada";import{print as N}from"graphql";var bo=x(`
|
|
23
|
+
query DaemonExploration($devSessionId: String!) {
|
|
24
|
+
exploration(devSessionId: $devSessionId) {
|
|
25
|
+
active
|
|
26
|
+
localWorkers
|
|
27
|
+
maxTrailLength
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`),xo=x(`
|
|
31
|
+
subscription WatchExplorationChanged($devSessionId: String!) {
|
|
32
|
+
explorationChanged(devSessionId: $devSessionId) {
|
|
33
|
+
exploration {
|
|
34
|
+
active
|
|
35
|
+
localWorkers
|
|
36
|
+
maxTrailLength
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`);function dr({config:e,devSessionId:r,machinery:o,sseClient:n}){return ho({config:e,devSessionId:r,machinery:o}),n.subscribe({query:N(xo),variables:{devSessionId:r}},{complete:()=>{},error:t=>{l.error(t,"exploration subscription error")},next:t=>{ur(o,t.data?.explorationChanged.exploration)}})}async function ho({config:e,devSessionId:r,machinery:o}){let n=await k({config:e,document:bo,variables:{devSessionId:r}});ur(o,n.exploration)}function ur(e,r){r!=null&&(e.setMaxTrailLength(r.maxTrailLength),e.setConcurrency(r.localWorkers),e.setEnabled(r.active))}var Po=x(`
|
|
41
|
+
mutation RecordExplorationProgress($devSessionId: String!, $attempts: Int!, $findings: Int!) {
|
|
42
|
+
recordExplorationProgress(devSessionId: $devSessionId, attempts: $attempts, findings: $findings)
|
|
43
|
+
}
|
|
44
|
+
`),cr=3e4;function pr({config:e,devSessionId:r,machinery:o}){let n={attempts:0,findings:0},t=async()=>{let a=o.progress(),s=a.attempts-n.attempts,c=a.findings-n.findings;(s>0||c>0)&&(n.attempts=a.attempts,n.findings=a.findings,await k({config:e,document:Po,variables:{attempts:s,devSessionId:r,findings:c}}).catch(d=>{l.warn({error:d},"exploration progress flush failed")})),i=setTimeout(()=>{t()},cr)},i=setTimeout(()=>{t()},cr);return()=>{clearTimeout(i)}}var Eo=x(`
|
|
45
|
+
subscription HooksPausedWatch($projectId: String!) {
|
|
46
|
+
hooksPausedRequested(projectId: $projectId) {
|
|
47
|
+
paused
|
|
48
|
+
projectId
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
`),Ro=x(`
|
|
52
|
+
subscription WatchLocalConcurrencyChanged {
|
|
53
|
+
myMaxLocalConcurrentRunsChanged
|
|
54
|
+
}
|
|
55
|
+
`);function fr({pool:e,sseClient:r}){return r.subscribe({query:N(Ro)},{complete:()=>{},error:o=>{l.error(o,"localConcurrency subscription error")},next:o=>{let n=o.data?.myMaxLocalConcurrentRunsChanged;n!=null&&(R(n),e.setSize(n))}})}function mr({cwd:e,projectId:r,sseClient:o}){return o.subscribe({query:N(Eo),variables:{projectId:r}},{complete:()=>{},error:n=>{l.error(n,"hooksPaused subscription error")},next:n=>{let t=n.data?.hooksPausedRequested?.paused;t!=null&&U({cwd:e,paused:t})}})}function U({cwd:e,paused:r}){let o=ce(e);if(r&&!W.existsSync(o)){W.writeFileSync(o,"");return}!r&&W.existsSync(o)&&W.unlinkSync(o)}var Ao=6e4,yr=500,Lo=15e3,gr=6e4,Do=3,Ho=$(`
|
|
56
|
+
mutation HeartbeatDevSessionWatch($id: String!) {
|
|
57
|
+
heartbeatDevSession(id: $id) {
|
|
58
|
+
__typename
|
|
59
|
+
... on DevSession {
|
|
60
|
+
id
|
|
61
|
+
}
|
|
62
|
+
... on DevSessionEndedError {
|
|
63
|
+
message
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`),_o=$(`
|
|
68
|
+
query WatchLocalConcurrency {
|
|
69
|
+
currentUser {
|
|
70
|
+
id
|
|
71
|
+
maxLocalConcurrentRuns
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`),Mo=$(`
|
|
75
|
+
mutation EndDevSessionWatch($projectId: String!, $cwd: String!) {
|
|
76
|
+
endDevSession(projectId: $projectId, cwd: $cwd) {
|
|
77
|
+
__typename
|
|
78
|
+
... on DevSession {
|
|
79
|
+
id
|
|
80
|
+
}
|
|
81
|
+
... on NoActiveDevSessionError {
|
|
82
|
+
message
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
`);async function At(e){let{executor:r}=e;en();let o=Ko(process.cwd()),n=o.cwd,t=zo(n),i=Vo(),a=rr({config:o,executor:r,pool:i.pool}),s={handler:()=>{}},c=Go(),d=Me(),u=Te({config:o,cwd:n,executor:r,explorationStatus:a.status,ready:c.promise,onShutdownRequest:()=>{s.handler()},sseHealth:()=>d.snapshot()}),S=await Jo({cwd:n,ipc:u,releasePid:t}),p=await D(n);p.isErr()&&(process.stderr.write(`ripplo: ${H(p.error)}
|
|
87
|
+
`),process.exit(1));let w=p.value,g=await Sr(()=>M({config:o,cwd:n,lockfile:w}),{config:o,label:"initial sync"}),h=await on(o);U({cwd:n,paused:g.hooksPaused});let f=Ce(n);f!=null&&l.info("watching branch %s in %s",f,n);let m=Io({headers:{Authorization:`Bearer ${o.token}`},retry:De,retryAttempts:1/0,url:`${o.ripploServerUrl}/graphql`}),y=Bo({cwd:n,initialConcurrency:h});i.provide(y);let A=await Oo({cwd:n,pool:y}),j=$o({claim:u.claim,config:o,cwd:n,initialId:g.devSessionId,pool:y,sseClient:m,sseHealth:d}),kr=mr({cwd:n,projectId:o.projectId,sseClient:m}),vr=fr({pool:y,sseClient:m}),wr=dr({config:o,devSessionId:g.devSessionId,machinery:a,sseClient:m}),br=pr({config:o,devSessionId:g.devSessionId,machinery:a}),xr=Uo({config:o,session:j}),hr=Zo(),B=await qo({config:o,devSessionId:g.devSessionId,executor:r});c.resolve(),No({devSessionId:g.devSessionId,executor:r,tunnel:B});let Pr=async()=>{xr(),hr(),a.stop(),S.close(),j.stop(),kr(),vr(),wr(),br(),await y.close(),await Fo(B),await A.stop().catch(()=>{}),await Promise.race([k({config:o,document:Mo,variables:{cwd:o.cwd,projectId:o.projectId}}).catch(()=>{}),new Promise(Er=>setTimeout(Er,3e3))]),t()},b=()=>{Pr().finally(()=>process.exit(0))};s.handler=b,process.on("SIGINT",b),process.on("SIGTERM",b),process.on("SIGHUP",b),process.on("SIGBREAK",b),await new Promise(()=>{})}async function qo({config:e,devSessionId:r,executor:o}){if(o==="cloud")return Ae({config:e,devSessionId:r})}async function Fo(e){e!=null&&await e.stop()}function Oo({cwd:e,pool:r}){return le({localDir:Co.join(e,".ripplo",".local"),writePortFile:!0,onRrwebBatch:()=>{},onSpan:o=>{let n=o.attributes["ripplo.run"];n!=null&&r.routeSpan(n,o)}})}function No({devSessionId:e,executor:r,tunnel:o}){process.stdout.write(`${me({devSessionId:e,executor:r,tunnelHostname:o?.hostname,version:J()})}
|
|
88
|
+
`)}function Uo({config:e,session:r}){let o=async()=>{try{let t=await k({config:e,document:Ho,variables:{id:r.getId()}});t.heartbeatDevSession?.__typename==="DevSessionEndedError"&&(l.warn("dev session ended server-side (%s); re-registering",t.heartbeatDevSession.message),await r.reregister())}catch(t){l.warn("heartbeat failed: %s",t instanceof Error?t.message:String(t))}},n=setInterval(()=>{o()},Lo);return()=>{clearInterval(n)}}function $o({claim:e,config:r,cwd:o,initialId:n,pool:t,sseClient:i,sseHealth:a}){let s=n,c=null,d=0,u=0,S=f=>{h(f)},p=()=>{let f=He({claim:e,cwd:o,devSessionId:s,onSubscriptionDead:S,pool:t,sseClient:i,sseHealth:a}),m=_e({cwd:o,devSessionId:s,onSubscriptionDead:S,sseClient:i});return()=>{f(),m()}},w=p(),g=async f=>{let m=Date.now();d=m-u>gr*2?1:d+1,u=m,d>=Do&&a.markUnhealthy(f),await jo(Math.min(1e3*2**(d-1),gr));let y=await D(o);if(y.isErr()){l.error("re-register: compile failed: %s",H(y.error));return}let A=await Sr(()=>M({config:r,cwd:o,lockfile:y.value}),{config:r,label:"re-register sync"});w(),s=A.devSessionId,w=p(),l.info("re-registered dev session as %s",s)},h=f=>(c!=null||(c=g(f).finally(()=>{c=null})),c);return{getId:()=>s,reregister:()=>h("dev session ended server-side"),stop:()=>{w()}}}function jo(e){return new Promise(r=>setTimeout(r,e))}function Bo({cwd:e,initialConcurrency:r}){return ar({initialSize:r,spawn:ir(nn(),e),lockfileProvider:async o=>{let n=await v(e);return n.result.isErr()?{unavailable:`daemon-load-failed:${n.result.error.kind}`}:n.fingerprint!==o?{unavailable:"fingerprint-mismatch"}:{lockfileJson:V(K,n.result.value)}}})}function zo(e){try{return re({cwd:e,onCompromised:Qo})}catch(r){throw r instanceof ee&&(process.stderr.write(`${ye({cwd:r.cwd,pid:r.pid})}
|
|
89
|
+
`),process.exit(1)),r}}function Qo(){l.error("daemon lock compromised; shutting down"),process.stderr.write(`${ge()}
|
|
90
|
+
`),process.exit(1)}function Go(){let e={handler:()=>{}};return{promise:new Promise(o=>{e.handler=o}),resolve:()=>{e.handler()}}}async function Jo({cwd:e,ipc:r,releasePid:o}){return(await $e({cwd:e,onConnection:r.handleConnection})).match(t=>t,t=>{process.stderr.write(`${ue(t)}
|
|
91
|
+
`),o(),process.exit(1)})}function Vo(){let e={provide:()=>{}};return{pool:new Promise(o=>{e.provide=o}),provide:o=>{e.provide(o)}}}function Ko(e){return P(e).match(r=>r,r=>{process.stderr.write(`${Z(r)}
|
|
92
|
+
`),process.exit(1)})}function Sr(e,{config:r,label:o}){let n=r.ripploServerUrl.includes("localhost")||r.ripploServerUrl.includes("127.0.0.1");return To(async()=>{try{return await e()}catch(t){Xo({config:r,error:t});let i=t instanceof Error?t.message:String(t);throw Yo(i)?t:(l.error("%s failed: %s",o,i),new Wo(i))}},{factor:2,maxTimeout:n?2e3:1e4,minTimeout:n?100:1e3,retries:1/0,onFailedAttempt:({attemptNumber:t,error:i})=>{l.warn("%s attempt %d failed \u2014 retrying: %s",o,t,i.message)}})}function Xo({config:e,error:r}){let o=z(r);o==="UNAUTHENTICATED"&&(process.stderr.write(`ripplo: ${fe()}
|
|
93
|
+
`),process.exit(1)),o==="FORBIDDEN"&&(process.stderr.write(`ripplo: ${pe({projectId:e.projectId,serverUrl:e.ripploServerUrl})}
|
|
94
|
+
`),process.exit(1))}function Yo(e){return e.includes("status 502")||e.includes("ECONNREFUSED")||e.includes("Failed to connect")||e.includes("fetch failed")}function Zo(){L({maxRuns:yr});let e=setInterval(()=>{L({maxRuns:yr})},Ao);return()=>{clearInterval(e)}}function en(){process.on("unhandledRejection",e=>{l.error({err:e},"unhandledRejection in watch; continuing")}),process.on("uncaughtException",e=>{l.error({err:e},"uncaughtException in watch; continuing")})}var rn=4;async function on(e){try{let o=(await k({config:e,document:_o,variables:void 0})).currentUser?.maxLocalConcurrentRuns;if(o!=null)return R(o),o}catch(r){l.warn({err:r},"failed to fetch local concurrency setting; using default")}return rn}function nn(){let e=process.argv[1];if(e==null)throw new Error("cli entry unavailable");return e}export{At as runDaemon};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{O as a,P as b,Q as c,R as d,S as e,T as f,U as g,V as h,W as i,X as j,Y as k}from"./chunk-
|
|
2
|
+
import{O as a,P as b,Q as c,R as d,S as e,T as f,U as g,V as h,W as i,X as j,Y as k}from"./chunk-UODLSLH7.js";import"./chunk-IHSHBPJY.js";import"./chunk-7UWDMECF.js";export{b as renderDaemonBindError,g as renderDaemonLockCompromised,f as renderDaemonLockHeld,e as renderDaemonReady,h as renderDaemonStatus,j as renderDaemonVersionNote,i as renderExplorationProgress,d as renderNotSignedIn,c as renderProjectAccessDenied,a as renderTunnelProvisionFailed,k as wireOutcome};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{A as Ge,B as Dr,C as ne,D as w,E as V,F as Je,G as rt,H as tt,I as nt,J as ot,K as it,L as st,M as at,N as lt,O as we,P as dt,Q as ct,R as ft,T as gt,V as ht,W as yt,X as kt,Y as wt,Z as vt,_ as bt,a as br,aa as St,b as B,c as Sr,d as Rr,e as P,f as te,g as T,ga as oe,h as xr,ha as Rt,i as R,ia as ze,j as u,k as Pr,ka as Ct,l as C,m as Er,ma as Ke,n as $r,na as xt,o as jr,oa as Pt,p as Ir,q as E,r as $,s as Ar,t as y,u as ye,x as O,y as Tr,z as Lr}from"./chunk-
|
|
2
|
+
import{A as Ge,B as Dr,C as ne,D as w,E as V,F as Je,G as rt,H as tt,I as nt,J as ot,K as it,L as st,M as at,N as lt,O as we,P as dt,Q as ct,R as ft,T as gt,V as ht,W as yt,X as kt,Y as wt,Z as vt,_ as bt,a as br,aa as St,b as B,c as Sr,d as Rr,e as P,f as te,g as T,ga as oe,h as xr,ha as Rt,i as R,ia as ze,j as u,k as Pr,ka as Ct,l as C,m as Er,ma as Ke,n as $r,na as xt,o as jr,oa as Pt,p as Ir,q as E,r as $,s as Ar,t as y,u as ye,x as O,y as Tr,z as Lr}from"./chunk-RJNO37CR.js";import{C as Jr,D as zr,E as Kr,F as Qr,G as Xr,H as Yr,I as Zr,L as ke,N as et,V as ut,X as pt,Y as mt,b as J,c as Cr,e as U,i as _,j as _r,l as Or,m as Nr,n as Ur,o as Fr,p as Mr,q as x,r as Hr,s as Wr,t as qr,v as Br,x as Vr,y as Gr}from"./chunk-UODLSLH7.js";import{a as pr,b as mr,c as fr,d as c,e as L,g as he,h as gr,i as D,j as hr,k as yr,l as Ve,m as kr,n as wr,o as vr}from"./chunk-5VRJXHWH.js";import"./chunk-IHSHBPJY.js";import"./chunk-7UWDMECF.js";import lc from"update-notifier";import dc from"yargs";import{hideBin as cc}from"yargs/helpers";function ve({current:e,latest:r}){return r==null?`ripplo v${e} (latest: unknown)`:r===e?`ripplo v${e} (latest)`:`ripplo v${e} (latest: v${r} \u2014 run \`npx ripplo update\`)`}function Et(){return"Update available {currentVersion} \u2192 {latestVersion}\nRun `npx ripplo update`"}import{graphql as Pi}from"gql.tada";import{exec as gi}from"child_process";import{createAuthClient as mi}from"better-auth/client";import{deviceAuthorizationClient as fi}from"better-auth/client/plugins";function $t({baseURL:e}){return mi({baseURL:e,fetchOptions:{headers:{"User-Agent":"Ripplo CLI"}},plugins:[fi()]})}import{err as jt,ok as hi}from"neverthrow";var yi=5e3,It="ripplo-cli";async function At({onDeviceCode:e,url:r}){let t=r??Ar().RIPPLO_SERVER_URL,n=$t({baseURL:t}),o=await n.device.code({client_id:It});if(o.error!=null)return jt({description:o.error.error_description,kind:"oauth-device-code-failed"});let{device_code:i,user_code:s,verification_uri_complete:a}=o.data;return e({userCode:s,verificationUrl:a}),Ri(a),(await ki({authClient:n,deviceCode:i})).map(d=>(hr({serverUrl:t,token:d}),d))}async function ki({authClient:e,deviceCode:r}){for(;;){await bi(yi);let t=await e.device.token({client_id:It,device_code:r,grant_type:"urn:ietf:params:oauth:grant-type:device_code"});if(t.data?.access_token!=null)return hi(t.data.access_token);if(t.error==null)continue;if(!vi(t.error.error))return jt({code:t.error.error,description:t.error.error_description,kind:"oauth-authorization-failed"})}}var wi=new Set(["authorization_pending","slow_down"]);function vi(e){return wi.has(e)}function bi(e){return new Promise(r=>{setTimeout(r,e)})}function Si(){return process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open"}function Ri(e){let r=Si();gi(`${r} "${e}"`,()=>{})}function F({serverUrl:e,token:r}){return{appUrl:"",cwd:process.cwd(),engineUrl:"",projectId:"",ripploServerUrl:e,token:r,tunnelAuth:void 0,webhookSecret:""}}import Ci from"fs";import xi from"path";function f(e){return Ci.existsSync(xi.join(e,".ripplo"))}var Ei=Pi(`
|
|
3
3
|
query AuthViewer {
|
|
4
4
|
currentUser {
|
|
5
5
|
name
|
|
@@ -352,7 +352,7 @@ ${e.findings.map(n=>Hr({evidencePath:void 0,finding:n})).join(`
|
|
|
352
352
|
`);return}Pl(e)}function Pl(e){let r=`ripplo@${e}`,t=wl("npm",["install","-g",r],{stdio:"inherit"});if(t.status!==0){let n=`exit ${String(t.status)}`;process.stderr.write(`${po(n)}
|
|
353
353
|
`),process.exit(1)}process.stdout.write(`${sr({evicted:0,latest:e,mode:"global"})}
|
|
354
354
|
`)}async function El(e){if((await Ie(e)).kind==="not-running")return;let t=await vn(e);process.stdout.write(`${mo(t)}
|
|
355
|
-
`)}async function go({executor:e}){let{runDaemon:r}=await import("./daemon-
|
|
355
|
+
`)}async function go({executor:e}){let{runDaemon:r}=await import("./daemon-SACK4YJZ.js"),{TunnelProvisionFailedError:t}=await import("./daemon-tunnel-DYA5LIEG.js"),{renderTunnelProvisionFailed:n}=await import("./daemon-W57NHXDG.js");try{await r({executor:e})}catch(o){throw o instanceof t&&(process.stderr.write(`${n(o.failure)}
|
|
356
356
|
`),process.exit(1)),o}}import{graphql as Fe}from"gql.tada";function ho(){return"No scope items added \u2014 the matched tests are already in scope (check `npx ripplo scope status`)."}function yo(e){return[`No test found for: ${e.join(", ")}`,"Pass a test id (kebab-case slug of the test name) or the exact intent string.","List known tests with `npx ripplo status`. To add one, stub it first via the testing DSL.",u("create")].join(`
|
|
357
357
|
`)}import{graphql as $l}from"gql.tada";var ko=$l(`
|
|
358
358
|
query ScopeStatus($projectId: String!, $cwd: String!) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ripplo",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.29",
|
|
4
4
|
"description": "CLI for Ripplo — AI-powered end-to-end testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://ripplo.ai",
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"eslint-plugin-neverthrow": "^1.1.4",
|
|
60
60
|
"tsup": "^8.5.1",
|
|
61
61
|
"vitest": "^4.1.4",
|
|
62
|
-
"@ripplo/core": "^0.0.0",
|
|
63
62
|
"@ripplo/eslint-config": "0.0.0",
|
|
64
63
|
"@ripplo/runtime": "^0.0.0",
|
|
65
|
-
"@ripplo/run-report": "0.0.0",
|
|
66
|
-
"@ripplo/spec": "^0.0.0",
|
|
67
64
|
"@ripplo/rrweb-bundle": "0.0.0",
|
|
65
|
+
"@ripplo/spec": "^0.0.0",
|
|
66
|
+
"@ripplo/run-report": "0.0.0",
|
|
67
|
+
"@ripplo/core": "^0.0.0",
|
|
68
68
|
"@ripplo/graphql": "^0.0.0"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
package/dist/chunk-OPYF32NG.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{J as We,M as Be,a as O,d as Ne,f as Oe,g as Ue,h as _e,i as h,j as De,k as S,l as A,m as qe,p as E,u as He}from"./chunk-3DQXKHCR.js";import{b as $e,d as m,e as y,g as Le,h as w,i as Me}from"./chunk-5VRJXHWH.js";import Je from"fs";import H from"path";import{config as cn}from"dotenv";import{z as D}from"zod";import{err as un,ok as Ke}from"neverthrow";import _ from"fs";import oe from"path";import{err as ne,ok as Ve}from"neverthrow";import{z as U}from"zod";var an=oe.join(".ripplo","project.json"),re=[".env",".env.local"],sn=U.object({envFiles:U.array(U.string().min(1)).optional(),projectId:U.string().min(1)});function ze(e){return oe.join(e,an)}function ie(e){let t=ze(e);return _.existsSync(t)?ln(t).andThen(n=>{let r=sn.safeParse(n);return r.success?Ve({envFiles:r.data.envFiles??re,projectId:r.data.projectId}):ne({issues:r.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:t})}):ne({kind:"project-file-missing",path:t})}function ae(e){return ie(e).match(t=>t,()=>{})}function ln(e){try{return Ve(JSON.parse(_.readFileSync(e,"utf8")))}catch(t){return ne({issues:[t instanceof Error?t.message:String(t)],kind:"project-file-invalid",path:e})}}function Ei({cwd:e,envFiles:t,projectId:n}){let r=ze(e);_.mkdirSync(oe.dirname(r),{recursive:!0});let o={projectId:n};t!=null&&!dn(t)&&(o.envFiles=[...t]),_.writeFileSync(r,JSON.stringify(o,null,2)+`
|
|
3
|
-
`)}function dn(e){return e.length!==re.length?!1:e.every((t,n)=>t===re[n])}function Ti(e){let n=ae(e)?.envFiles??[".env",".env.local"],r=H.join(e,".ripplo");n.forEach(o=>{let i=H.resolve(r,o);Je.existsSync(i)&&cn({override:!0,path:i,quiet:!0})}),q=void 0}var pn=D.object({RIPPLO_APP_URL:D.url(),RIPPLO_ENGINE_URL:D.url(),RIPPLO_WEBHOOK_SECRET:D.string().min(1)}),q;function W(){return q!=null?Ke(q):mn().map(e=>(q=e,e))}function fn(e){let n=ae(e)?.envFiles??[],r=H.join(e,".ripplo");return n.map(o=>H.resolve(r,o)).filter(o=>!Je.existsSync(o))}function mn(){let e=pn.safeParse(process.env);if(!e.success)return un({issues:e.error.issues.map(n=>`${n.path.join(".")}: ${n.message}`),kind:"env-invalid",missingEnvFiles:fn(process.cwd())});let t=e.data;return Ke({appUrl:t.RIPPLO_APP_URL,engineUrl:t.RIPPLO_ENGINE_URL,webhookSecret:t.RIPPLO_WEBHOOK_SECRET})}import{readFileSync as gn}from"fs";import{z as Ge}from"zod";var yn=Ge.object({version:Ge.string()});function B(){let e=gn(new URL("../package.json",import.meta.url),"utf8");return yn.parse(JSON.parse(e)).version}import ue from"fs";import V from"path";import{createJiti as In}from"jiti";import{err as L,ok as Ze}from"neverthrow";import hn from"fs";import T from"path";import b from"typescript";function Qe(e){let t=T.join(e,"index.ts"),n=Sn(e);hn.mkdirSync(T.dirname(n.tsBuildInfoFile??""),{recursive:!0});let r=b.createIncrementalCompilerHost(n),o=b.createIncrementalProgram({host:r,options:n,rootNames:[t]}),i=[...o.getSyntacticDiagnostics(),...o.getSemanticDiagnostics()];o.emit();let s=i.filter(d=>Rn(d,e));if(s.length===0)return{diagnostics:[],ok:!0};let l={getCanonicalFileName:d=>d,getCurrentDirectory:()=>T.dirname(e),getNewLine:()=>`
|
|
4
|
-
`};return{diagnostics:b.formatDiagnosticsWithColorAndContext(s,l).split(`
|
|
5
|
-
`).filter(d=>d.length>0),ok:!1}}function Rn(e,t){let n=e.file?.fileName;return n==null?!0:n.startsWith(t)}var kn=T.join(".local","tsbuildinfo");function Sn(e){return{allowImportingTsExtensions:!0,allowJs:!1,esModuleInterop:!0,incremental:!0,module:b.ModuleKind.Preserve,moduleResolution:b.ModuleResolutionKind.Bundler,noEmit:!0,resolveJsonModule:!0,skipLibCheck:!0,strict:!1,target:b.ScriptTarget.ES2022,tsBuildInfoFile:T.join(e,kn)}}import{createHash as xn}from"crypto";import Xe from"fs/promises";import se from"path";import{err as v,ok as le,Result as wn}from"neverthrow";var F=".ripplo/fixtures",de=10*1024*1024,ce=50*1024*1024;async function Ye(e,t){let n=En(t);if(n.length===0)return le({});let r=se.join(e,F),o=await Promise.all(n.map(i=>bn({fixturesRoot:r,name:i})));return wn.combine(o).andThen(vn)}function En(e){let n=e.workflows.flatMap(r=>[...r.steps,...r.tests.flatMap(o=>o.steps)]).flatMap(r=>r.action.kind==="upload"?r.action.files:[]);return[...new Set(n)].toSorted((r,o)=>r.localeCompare(o))}async function bn({fixturesRoot:e,name:t}){if(t.includes("..")||se.isAbsolute(t))return v({kind:"fixture-invalid-name",name:t});let n=se.join(e,t),r=await Xe.lstat(n).catch(()=>null);if(r==null)return v({kind:"fixture-missing",name:t,path:n});if(r.isSymbolicLink())return v({kind:"fixture-symlink",name:t});if(!r.isFile())return v({kind:"fixture-not-file",name:t});let o=await Xe.readFile(n);if(o.byteLength>de)return v({kind:"fixture-too-large",name:t,size:o.byteLength});let i=xn("sha256").update(o).digest("hex");return le([t,{sha256:i,size:o.byteLength}])}function vn(e){let t=e.reduce((n,[,r])=>n+r.size,0);return t>ce?v({kind:"fixtures-total-too-large",total:t}):le(Object.fromEntries(e))}var I=".ripplo/ripplo.lock",$;async function et(e){let{result:t}=await pe(e);return t}async function pe(e){let t=Cn(V.join(e,".ripplo"));if($!=null&&$.fingerprint===t&&$.result.isOk())return{fingerprint:t,result:$.result};let n=await M(e);return $={fingerprint:t,result:n},{fingerprint:t,result:n}}async function M(e){let t=V.join(e,".ripplo"),n=V.join(t,"index.ts"),r=Qe(t);return r.ok?(await jn(n)).andThen(s=>Tn({entryPath:n,exported:s})).match(async s=>(await Ye(e,s)).map(u=>({...s,fixtures:u})).mapErr(u=>({error:u,kind:"fixture-failed"})),s=>Promise.resolve(L(s))):L({diagnostics:r.diagnostics,kind:"typecheck-failed"})}var Pn=new Set([".local","debug","node_modules"]);function Cn(e){return tt(e).toSorted((t,n)=>t.localeCompare(n)).join("|")}function tt(e){return(ue.existsSync(e)?ue.readdirSync(e,{withFileTypes:!0}):[]).flatMap(n=>{if(Pn.has(n.name))return[];let r=V.join(e,n.name);if(n.isDirectory())return tt(r);let o=ue.statSync(r);return[`${r}:${String(o.mtimeMs)}:${String(o.size)}`]})}async function jn(e){try{let n=await In(import.meta.url,{fsCache:!1,moduleCache:!1,sourceMaps:!0}).import(e),r=n!=null&&typeof n=="object"&&"default"in n?Reflect.get(n,"default"):n;return Ze(r)}catch(t){return L({kind:"load-threw",message:An(t)})}}function An(e){return e instanceof Error?e.message:String(e)}function Tn({entryPath:e,exported:t}){if(t==null||typeof t!="object"||!("lockfile"in t))return L({entryPath:e,kind:"not-ripplo"});let n=Ne.safeParse(Reflect.get(t,"lockfile"));return n.success?Ze(n.data):L({issues:n.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`),kind:"invalid-lockfile"})}function P(e,t){return t==null?`Load \`/ripplo:${e}\` skill for instructions.`:`Load \`/ripplo:${e}\` skill for instructions on ${t}.`}function Zi(e){return e.length===1?P(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 J(e){return[`Compilation failed: ${Fn(e)}`,P("create","DSL authoring + lint rules")].join(`
|
|
6
|
-
`)}function oa(){return`${I} is up to date`}function ia(e){return[`${I} is ${e==="missing"?"missing":"out of date"} \u2014 run \`npx ripplo compile\` and commit the result`,P("setup")].join(`
|
|
7
|
-
`)}function aa(){return`Wrote ${I}`}function Fn(e){switch(e.kind){case"typecheck-failed":return["TypeScript errors in .ripplo/:",...nt(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?):",...nt(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 $n(e.error)}}function nt(e,t=8){return e.length<=t?e:[...e.slice(0,t),`\u2026 and ${String(e.length-t)} more`]}function $n(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 ${z(e.size)} \u2014 over the ${z(de)} per-file limit.`;case"fixtures-total-too-large":return`Fixtures total ${z(e.total)} \u2014 over the ${z(ce)} limit.`}}function z(e){return`${String(Math.round(e/(1024*1024)*10)/10)} MB`}var K=class extends Error{failure;constructor(t){super(t.kind),this.name="CliError",this.failure=t}};function pa(e){return e instanceof K?fe(e.failure):e instanceof Error?e.message:String(e)}function fe(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).",P("setup")].join(`
|
|
11
|
-
`);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(t=>` ${t}`),"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 Ln(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 J(e.error)}}function Ln(e){let t=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.",...t].join(`
|
|
17
|
-
`)}import{err as On,ok as Un}from"neverthrow";import{z as me}from"zod";var Mn="https://ripplo.ai";function ot(){return at().RIPPLO_SERVER_URL}function it(){return at().RIPPLO_PROJECT_ID}var Nn=me.object({RIPPLO_PROJECT_ID:me.string().min(1).optional(),RIPPLO_SERVER_URL:me.string().min(1).default(Mn)}),rt;function at(){return rt??=Nn.parse(process.env),rt}import st from"fs";import ge from"path";function lt(e){let t=st.realpathSync(e),n=t,r=ge.dirname(n);for(;r!==n;){if(st.existsSync(ge.join(n,".git")))return n;n=r,r=ge.dirname(n)}return t}function dt(e){return ie(e).andThen(t=>W().andThen(n=>{let r=ot(),o=Me(r);return o==null?On({kind:"not-authenticated"}):Un({appUrl:n.appUrl,cwd:lt(e),engineUrl:n.engineUrl,projectId:it()??t.projectId,ripploServerUrl:r,token:o,tunnelAuth:void 0,webhookSecret:n.webhookSecret})}))}import ct from"fs";import{checkSync as _n,lockSync as Dn}from"proper-lockfile";var qn="dev.pid",ut=15e3;function pt(e){return w(e,qn)}function ft(e){try{return _n(pt(e),{realpath:!1,stale:ut})}catch{return!1}}var ye=class extends Error{pid;cwd;constructor({cwd:t,pid:n}){super("dev-lock-held"),this.name="DevLockHeldError",this.pid=n,this.cwd=t}};function ja({cwd:e,onCompromised:t}){Le(e);let n=pt(e),r=Hn({cwd:e,onCompromised:t,path:n});return ct.writeFileSync(n,String(process.pid)),()=>{try{r()}catch{}}}function Hn({cwd:e,onCompromised:t,path:n}){try{return Dn(n,{realpath:!1,stale:ut,onCompromised:()=>{t()}})}catch(r){throw Wn(r)?new ye({cwd:e,pid:Bn(n)}):r}}function Wn(e){if(!(e instanceof Error)||!("code"in e))return!1;let{code:t}=e;return t==="ELOCKED"}function Bn(e){try{let t=ct.readFileSync(e,"utf8").trim(),n=Number.parseInt(t,10);return Number.isFinite(n)&&n>0?n:null}catch{return null}}import Vn from"p-queue";var zn=4,Jn={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},G=new Vn({concurrency:zn}),k={headedActive:0,interactiveActive:0,interactiveQueued:0},mt={current:null};function Fa({headed:e,task:t,workClass:n}){let r=Jn[n];return n==="p3-explore"?G.add(t,{priority:r}):(k.interactiveQueued+=1,Q(),G.add(()=>Kn({headed:e,task:t}),{priority:r}))}function $a(e){!Number.isFinite(e)||e<1||(G.concurrency=Math.floor(e),Q())}function he(){return{active:k.interactiveActive,headedActive:k.headedActive,poolSize:G.concurrency,queued:k.interactiveQueued}}function La(e){mt.current=e}async function Kn({headed:e,task:t}){k.interactiveQueued-=1,k.interactiveActive+=1,k.headedActive+=e?1:0,Q();try{return await t()}finally{k.interactiveActive-=1,k.headedActive-=e?1:0,Q()}}function Q(){mt.current?.()}import Re from"fs";import ke from"path";function gt(e){try{let t=Gn(e);if(t==null)return;let n=ke.join(t,"HEAD"),r=Re.readFileSync(n,"utf8").trim(),o="ref: refs/heads/";return r.startsWith(o)?r.slice(o.length):r.length===0?void 0:r.slice(0,7)}catch{return}}function Gn(e){let t=ke.join(e,".git");if(Re.statSync(t).isDirectory())return t;let r=Re.readFileSync(t,"utf8").trim(),o="gitdir:";if(!r.startsWith(o))return;let i=r.slice(o.length).trim();if(i.length!==0)return ke.resolve(e,i)}import Qn from"crypto";import{readFile as yt}from"fs/promises";import ht from"path";import{graphql as Xn}from"gql.tada";import{err as Yn,ok as Zn}from"neverthrow";var er=Xn(`
|
|
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 Ga(e,t){let n=await M(e);if(n.isErr())return Yn({error:n.error,kind:"compilation-failed"});let r=await Se({config:t,cwd:e,lockfile:n.value});return Zn({devSessionId:r.devSessionId,lockfile:n.value})}async function Se(e){let t=Ue(e.lockfile);return nr({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:t})}function tr(e){return Qn.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function nr({config:e,cwd:t,fixtures:n,payload:r}){let o=tr(r),i=gt(t),s=await or(t),l=await rr(t,n),u=await m({config:e,document:er,variables:{branch:i??null,cwd:t,fixtures:l,lockfileContent:s,preconditions:r.preconditions.map(d=>({depends:[...d.depends],description:d.description,name:d.name,returns:[...d.returns]})),projectId:e.projectId,singletons:r.singletons.map(d=>({defaultValue:d.defaultValue,description:d.description,name:d.name,type:d.type})),workflows:r.workflows.map(d=>({expectedOutcome:d.expectedOutcome,name:d.name,preconditions:[...d.preconditions],requiresKeys:d.requiresKeys.map(c=>({namespace:c.namespace,preconditionName:c.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 rr(e,t){let n=Object.entries(t);return Promise.all(n.map(async([r,o])=>({contentBase64:(await yt(ht.join(e,F,r))).toString("base64"),sha256:o.sha256})))}async function or(e){try{return await yt(ht.join(e,I),"utf8")}catch{return null}}import{randomUUID as Or}from"crypto";import{createId as Ur}from"@paralleldrive/cuid2";import{CancellationTokenSource as _r,ResponseError as Dr}from"vscode-jsonrpc/node";import{graphql as ir}from"gql.tada";var ar=ir(`
|
|
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 Rt(e){try{let n=(await m({config:e.config,document:ar,variables:sr(e)})).createRun;return n==null?X({detail:"create-run-null",type:"generic"}):n.__typename==="MutationCreateRunSuccess"?null:n.__typename==="LimitExceededError"?X({code:n.code,type:"limit"}):X({detail:n.__typename,type:"generic"})}catch(t){return lr(t)}}function sr({executor:e,lockfileHash:t,runId:n,target:r}){return{clientVersion:B(),executor:e,id:n,lockfileHash:t,target:e==="cloud"?"tunnel":void 0,testId:r.testId,workflowId:r.workflowId}}function X(e){return{kind:"dispatch-error",reason:e}}function lr(e){return e instanceof $e?{detail:e.message,kind:"infra-error"}:X({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{createMessageConnection as dr,NotificationType as kt,RequestType as cr,RequestType0 as St,SocketMessageReader as ur,SocketMessageWriter as pr}from"vscode-jsonrpc/node";import{z as a}from"zod";var fr="daemon.sock",mr="daemon.log";function os(e){return w(e,fr)}function is(e){return w(e,mr)}function xt(e){return dr(new ur(e),new pr(e))}var wt=a.object({all:a.boolean(),headed:a.boolean(),tests:a.array(a.string())}),as=a.object({jobId:a.string(),total:a.number()}),gr=a.enum(["on","off"]),yr=a.object({attempts:a.number(),findings:a.number()}),ss=a.object({active:a.number(),explorer:gr,exploring:a.number(),progress:yr,queued:a.number(),sseHealth:a.object({detail:a.string().optional(),ok:a.boolean()}).optional(),version:a.string().optional()}),hr=a.enum(["MAX_RUNS","OVERAGE_CAP","MAX_AGENTS","MAX_CONCURRENT_RUNS","MAX_PROJECTS"]),Rr=a.discriminatedUnion("type",[a.object({code:hr,type:a.literal("limit")}),a.object({detail:a.string(),type:a.literal("generic")})]),xe=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:Rr}),a.object({detail:a.string(),kind:a.literal("dispatch-timeout")}),a.object({detail:a.string(),kind:a.literal("infra-error")})]),kr=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:xe,runId:a.string(),testName:a.string(),workflowName:a.string()})]),ls=a.object({event:kr,jobId:a.string()}),ds=a.object({failed:a.number(),jobId:a.string(),notRun:a.number(),passed:a.number()}),cs=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")})]),Et=new cr("ripplo/enqueue"),bt=new St("ripplo/status"),vt=new St("ripplo/shutdownIfIdle"),It=new kt("ripplo/jobEvent"),Pt=new kt("ripplo/jobDone");import{graphql as Sr}from"gql.tada";async function Ct(e,t){let r=(await m({config:e,document:xr,variables:{cwd:t,projectId:e.projectId}})).project?.devSession?.workflows??[];return new Map(r.flatMap(o=>o.tests.map(i=>[`${o.slug}/${i.slug}`,{testId:i.id,workflowId:o.id}])))}var xr=Sr(`
|
|
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 wr}from"vscode-jsonrpc/node";function we(e){return`${e.workflowSlug}/${e.testSlug}`}function jt(e){let{headed:t,inflight:n,jobId:r,lockfileHashValue:o,onExpire:i,runId:s,selection:l,timeoutMs:u}=e,d=we(l),c=`${d}@${o}@${String(t)}`,p=n.get(c);if(p!=null)return p.jobIds.add(r),null;let g={cancellation:new wr,claimed:!1,claimKey:d,headed:t,inflightKey:c,jobIds:new Set([r]),runId:s,testName:l.testName,timer:null,workflowName:l.workflowName};return g.timer=setTimeout(()=>{Y(n,g),i(g)},u),n.set(c,g),g}function Y(e,t){t.timer!=null&&(clearTimeout(t.timer),t.timer=null),e.delete(t.inflightKey)}function Ee(e,t){let n=[...e.values()].find(r=>r.runId===t&&!r.claimed);return n==null?null:(n.claimed=!0,n.timer!=null&&(clearTimeout(n.timer),n.timer=null),n)}function At(e,t){[...e.values()].filter(n=>n.jobIds.has(t)).forEach(n=>{n.jobIds.delete(t),n.jobIds.size===0&&(Y(e,n),n.cancellation.cancel())})}import{err as be,ok as Tt}from"neverthrow";function $t({all:e,ids:t,lockfile:n}){if(e&&t.length>0)return be({kind:"conflicting-flags"});if(e)return Tt(n.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>S(s))));if(t.length===0)return be({kind:"nothing-selected"});let r=t.map(i=>({id:i,refs:br(n,i)})),o=r.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?be({kind:"unknown-ids",known:Er(n),unknown:o}):Tt([...new Set(r.flatMap(i=>i.refs))])}function Lt(e,t){let n=new Map(A(e).map(r=>[r.ref,{testName:r.test.name,testSlug:r.test.slug,workflowName:r.workflow.name,workflowSlug:h(r.workflow.name)}]));return t.map(r=>{let o=n.get(r);if(o==null)throw new Error(`selectionsFor: ref not in lockfile: ${r}`);return o})}function Er(e){return e.workflows.map(t=>h(t.name))}function br(e,t){let n=e.workflows.find(r=>r.name===t||h(r.name)===h(t));return n!=null?n.tests.map(r=>S(r)):A(e).filter(r=>r.ref===t||Ft(r.ref)===Ft(t)).map(r=>r.ref)}function Ft(e){let t=e.lastIndexOf("/");return t===-1?h(e):`${h(e.slice(0,t))}/${h(e.slice(t+1))}`}import{err as ve,ok as Nt}from"neverthrow";import{graphql as Ot}from"gql.tada";import{execFileSync as vr}from"child_process";var Ir=256*1024*1024;function Z(e,t){return vr("git",[...e],{cwd:t,encoding:"utf8",maxBuffer:Ir,stdio:["ignore","pipe","pipe"]})}async function Ut({config:e,cwd:t,lockfile:n}){await Cr({config:e,cwd:t,lockfile:n});let r=await Ar(e);if(r.isErr())return ve(r.error);let o=new Map(n.workflows.filter(s=>!s.stub).map(s=>[h(s.name),s])),i=[...new Set(r.value)].flatMap(s=>{let l=o.get(s);return l==null?[]:l.tests.map(u=>S(u))});return i.length===0?ve({kind:"scope-empty"}):Nt(i)}var Pr=Ot(`
|
|
90
|
-
mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
91
|
-
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
92
|
-
__typename
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
`);async function Cr({config:e,cwd:t,lockfile:n}){let r=new Set(Tr(t)),o=n.workflows.filter(i=>i.sourcePath!=null&&r.has(i.sourcePath)).map(i=>h(i.name));o.length!==0&&await m({config:e,document:Pr,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{y.warn({err:i},"auto-scope of dirty tests failed")})}var jr=Ot(`
|
|
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 Ar(e){try{let n=(await m({config:e,document:jr,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return Nt(n.flatMap(r=>r.workflow==null?[]:[r.workflow.slug]))}catch(t){return ve({detail:t instanceof Error?t.message:String(t),kind:"scope-fetch-failed"})}}var Mt=".ripplo/workflows/";function Tr(e){try{return Z(["status","--porcelain","--",".ripplo/workflows"],e).split(`
|
|
112
|
-
`).map(t=>t.slice(3).trim()).filter(t=>t.startsWith(Mt)&&t.endsWith(".ts")).map(t=>t.slice(Mt.length)).filter(t=>t!=="index.ts"&&!t.endsWith("/index.ts"))}catch{return[]}}import{graphql as Fr}from"gql.tada";var $r=2e3,Lr=Fr(`
|
|
113
|
-
query DaemonCloudRunStatus($runId: String!) {
|
|
114
|
-
run(id: $runId) {
|
|
115
|
-
status
|
|
116
|
-
failureReason
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
`);function Dt({config:e,onComplete:t,onStarted:n,runId:r,signal:o}){let i=!1,s,l=!1,u=async()=>{if(i||o.aborted)return;let d=await Mr(e,r).catch(()=>"unknown");if(!l&&(d==="running"||_t(d))&&(l=!0,n()),_t(d)){i=!0,t(Nr(d));return}s=setTimeout(()=>{u()},$r)};return u(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function Mr(e,t){let r=(await m({config:e,document:Lr,variables:{runId:t}})).run?.status;return r??"unknown"}function _t(e){return e==="passed"||e==="failed"||e==="warning"||e==="cancelled"}function Nr(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 qr=12e4,Hr=-32099;function Wr(e){let t=new AbortController;return e.isCancellationRequested?(t.abort(),t.signal):(e.onCancellationRequested(()=>{t.abort()}),t.signal)}function Gs(e){let t={...e,inflight:new Map,jobs:new Map};return{claim:n=>Kr(t,n),handleConnection:n=>{Br(t,n)},idle:()=>Wt(t)}}function Br(e,t){let n=xt(t);n.onRequest(Et,(r,o)=>Vr({connection:n,ctx:e,params:r,token:o})),n.onRequest(bt,()=>{let r=he();return{active:r.active,queued:r.queued,sseHealth:e.sseHealth(),version:B(),...e.explorationStatus()}}),n.onRequest(vt,()=>{let r=Wt(e);return r&&e.onShutdownRequest(),r}),n.onClose(()=>{zr(e,n)}),n.onError(r=>{y.warn({err:r},"ipc connection error")}),t.on("error",r=>{y.warn({err:r},"ipc socket error")}),n.listen()}function Wt(e){let t=he();return e.jobs.size===0&&t.active===0&&t.queued===0}async function Vr({connection:e,ctx:t,params:n,token:r}){let o=wt.safeParse(n);if(!o.success)throw qt({code:"bad-message"});await t.ready;let i=await Qr({config:t.config,cwd:t.cwd,message:o.data});if(i.kind==="error")throw qt(i.error);let s=Or(),l=new _r;return r.onCancellationRequested(()=>{Bt(t,s)}),t.jobs.set(s,{cancellation:l,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),oo({ctx:t,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 qt(e){return new Dr(Hr,e.code,e)}function Bt(e,t){let n=e.jobs.get(t);n!=null&&(n.cancellation.cancel(),e.jobs.delete(t),At(e.inflight,t))}function zr(e,t){[...e.jobs.entries()].filter(([,n])=>n.connection===t).forEach(([n])=>{Bt(e,n)})}function Vt(e,t,n){let r=e.jobs.get(t);r!=null&&(Ht(()=>r.connection.sendNotification(It,{event:n,jobId:t})),n.kind==="test-outcome"&&(Jr(r,n.outcome.kind),r.passed+r.failed+r.notRun>=r.total&&(Ht(()=>r.connection.sendNotification(Pt,{failed:r.failed,jobId:t,notRun:r.notRun,passed:r.passed})),e.jobs.delete(t))))}function Ht(e){e().catch(t=>{y.warn({err:t},"ipc notification failed")})}function Jr(e,t){if(t==="pass"){e.passed+=1;return}if(t==="dispatch-error"||t==="dispatch-timeout"||t==="infra-error"){e.notRun+=1;return}e.failed+=1}function C(e,t,n){t.jobIds.forEach(r=>{Vt(e,r,n)})}function Kr(e,t){let n=Ee(e.inflight,t);return n==null?null:{headed:n.headed,token:n.cancellation.token,finished:(r,o)=>{e.inflight.delete(n.inflightKey),C(e,n,{kind:"test-outcome",outcome:o,runId:n.runId,testName:n.testName,workflowName:n.workflowName})},started:()=>{C(e,n,{kind:"test-started",runId:n.runId,testName:n.testName,workflowName:n.workflowName})}}}function Gr(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 Qr({config:e,cwd:t,message:n}){return(await et(t)).match(o=>Xr({config:e,cwd:t,lockfile:o,message:n}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...Gr(o)]},kind:"error"}))}async function Xr({config:e,cwd:t,lockfile:n,message:r}){let o=await Zr(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=await eo({config:e,cwd:t,lockfile:n});return i!=null?{error:{code:"sync-failed",detail:i},kind:"error"}:(await to({config:e,cwd:t,lockfile:n,message:r})).match(async l=>({kind:"ready",lockfileHashValue:Oe(n),selections:Lt(n,l),targetsByClaimKey:await Ct(e,t)}),l=>Promise.resolve({error:l,kind:"error"}))}var Yr=2e3;async function Zr(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(Yr)}),null}catch(t){return t instanceof Error?t.message:String(t)}}async function eo(e){try{return await Se(e),null}catch(t){return t instanceof Error?t.message:String(t)}}async function to({config:e,cwd:t,lockfile:n,message:r}){return!r.all&&r.tests.length===0?(await Ut({config:e,cwd:t,lockfile:n})).mapErr(no):$t({all:r.all,ids:r.tests,lockfile:n}).mapErr(ro)}function no(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function ro(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 oo(e){await e.selections.reduce((t,n)=>t.then(()=>io(e,n)),Promise.resolve())}async function io(e,t){let{ctx:n,headed:r,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:l}=e;if(l.isCancellationRequested)return;let u=we(t),d=s.get(u);if(d==null){Vt(n,o,{kind:"test-outcome",outcome:{kind:"dispatch-error",reason:{detail:"test-not-found",type:"generic"}},runId:"",testName:t.testName,workflowName:t.workflowName});return}let c=jt({headed:r,inflight:n.inflight,jobId:o,lockfileHashValue:i,runId:Ur(),selection:t,timeoutMs:qr,onExpire:g=>{C(n,g,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:g.testName,workflowName:g.workflowName})}});if(c==null)return;let p=await ao(n,d,c.runId,i);if(p!=null){Y(n.inflight,c),C(n,c,{kind:"test-outcome",outcome:p,runId:"",testName:t.testName,workflowName:t.workflowName});return}n.executor==="cloud"&&so(n,c)}function ao(e,t,n,r){return Rt({config:e.config,executor:e.executor,lockfileHash:r,runId:n,target:t})}function so(e,t){let n=Ee(e.inflight,t.runId);n!=null&&Dt({config:e.config,runId:n.runId,signal:Wr(n.cancellation.token),onComplete:r=>{e.inflight.delete(n.inflightKey),C(e,n,{kind:"test-outcome",outcome:r,runId:n.runId,testName:n.testName,workflowName:n.workflowName})},onStarted:()=>{C(e,n,{kind:"test-started",runId:n.runId,testName:n.testName,workflowName:n.workflowName})}})}import lo from"fs";import co from"path";async function rl(e){let t=co.join(e,".ripplo","index.ts");if(!lo.existsSync(t))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let n=await M(e);return n.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:J(n.error),path:".ripplo/"}],valid:!1,warnings:[]}:W().match(r=>({appUrl:r.appUrl,engineUrl:r.engineUrl,errors:[],valid:!0,warnings:[]}),r=>({appUrl:void 0,engineUrl:void 0,errors:[{message:fe(r),path:""}],valid:!1,warnings:[]}))}async function ol(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 il({appUrl:e,engineUrl:t}){let n=t.startsWith("http://")||t.startsWith("https://")?t:`${e}${t}`;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 mo from"fs";import uo from"fs";import Ie from"path";var po=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function zt(e){let t=fo(e);return t==null?!1:po.some(n=>uo.existsSync(Ie.join(t,n)))}function fo(e){try{let t=Z(["rev-parse","--git-dir"],e).trim();return t.length===0?null:Ie.isAbsolute(t)?t:Ie.resolve(e,t)}catch{return null}}function go(e){return w(e,"hooks-paused")}function gl(e){return mo.existsSync(go(e))||zt(e)?!1:ft(e)}import{createMessageConnection as Jt,IPCMessageReader as Kt,IPCMessageWriter as Gt,NotificationType as yo,NotificationType0 as Qt,RequestType as Pe}from"vscode-jsonrpc/node";import{z as f}from"zod";var Sl=f.object({headed:f.boolean(),lockfileFingerprint:f.string(),runId:f.string().min(1),testRef:f.string().min(1)}),xl=f.object({fingerprint:f.string()}),wl=f.object({lockfileJson:f.string().optional(),unavailable:f.string().optional()}),ho=f.enum(["unspecified","internal","server","client","producer","consumer"]),Ro=f.enum(["unset","ok","error"]),ko=f.object({attributes:f.record(f.string(),f.string()),durationMs:f.number(),kind:f.literal("span"),name:f.string(),parentSpanId:f.union([f.string(),f.undefined()]),source:f.literal("server"),spanId:f.string(),spanKind:ho,status:f.object({code:Ro,message:f.union([f.string(),f.undefined()])}),timeNanos:f.string(),traceId:f.string()}),El=f.object({runId:f.string().min(1),span:ko}),bl=f.object({outcome:xe,serverNotified:f.boolean()}),vl=new Qt("worker/ready"),Il=new Pe("worker/run"),Pl=new Pe("worker/lockfile"),Cl=new Pe("worker/exploreTrail"),jl=new yo("worker/span"),Al=new Qt("worker/shutdown");function Tl(e){let t=Jt(new Kt(e),new Gt(e));return t.listen(),t}function Fl(){let e=Jt(new Kt(process),new Gt(process));return e.listen(),e}import So from"path";import{randomUUID as xo}from"crypto";async function Dl({cwd:e,ref:t,signal:n,step:r}){let o=dt(e).match(c=>({config:c}),c=>({failure:c}));if("failure"in o)return{failure:o.failure,kind:"config-failed"};let i=o.config,s=await pe(e);if(s.result.isErr())return{error:s.result.error,kind:"compile-failed"};let l=s.result.value,u=A(l).find(c=>c.ref===t);return u==null?{kind:"no-test",ref:t}:(await We({lockfile:l,options:{baseUrl:i.appUrl,engineUrl:i.engineUrl,fixturesDir:So.join(i.cwd,F),generate:E,headed:!0,secret:i.webhookSecret,tunnelAuth:i.tunnelAuth},params:void 0,runId:`teleport-${xo()}`,stopAfterStep:r,test:u.test},n)).match(c=>({kind:"done",result:c}),c=>({error:c,kind:"run-failed"}))}import{gzip as jo}from"zlib";import{promisify as Ao}from"util";import{existsSync as je,readFileSync as Ae}from"fs";import ee from"path";import{graphql as x}from"gql.tada";function Xt(e){return[e.kind,e.target,e.value].filter(t=>t.length>0).join(" ")}var wo={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},Eo={"data-rule":"dataRule","page-rule":"pageRule",step:"step"},bo={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 Yt(e){return e.kind==="consistency"?{consistency:{mismatch:Po(e.mismatch),pending:e.pending}}:e.kind==="pending-check"?{pendingCheck:{budget:e.budget,source:Eo[e.source.kind],...vo(e.source)}}:e.kind==="unrunnable"?{unrunnable:{reason:wo[e.reason]}}:e.kind==="driver-error"?{driverError:{errorKind:bo[e.error.kind],message:Co(e.error)}}:{impossibleAction:{subject:Io(e.step.action)}}}function vo(e){return"check"in e?Zt(e.check,!1):{checkKind:void 0,expected:void 0,negated:void 0,subject:void 0}}function Zt(e,t){return e.kind==="not"?Zt(e.inner,!t):e.kind==="browser"?{checkKind:"browser",expected:e.value,negated:t,subject:e.name}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:t,subject:O(e.locator)}:{checkKind:e.kind,expected:void 0,negated:t,subject:O(e.locator)}}function Io(e){let t=e.locator==null?e.url??"":O(e.locator);return`${e.kind} ${t}`.trim()}function Po(e){return e.kind==="wrong-value"?{wrongValue:{entity:e.entity,field:e.field,key:e.key,snapshot:N(e.snapshot),sut:N(e.sut)}}:e.kind==="expected-change"?{expectedChange:{entity:e.entity,field:e.field,key:e.key,value:N(e.value)}}:e.kind==="singleton-mismatch"?{singletonMismatch:{singleton:e.singleton,snapshot:N(e.snapshot),sut:N(e.sut)}}:e.kind==="unexpected-row"?{unexpectedRow:{entity:e.entity,key:e.key}}:{missingRow:{entity:e.entity,key:e.key}}}function N(e){return e==null?null:String(e)}function Co(e){return"message"in e?e.message:"detail"in e?e.detail:null}async function To({config:e,cwd:t,fixturesDir:n,headed:r,lockfile:o,runId:i,session:s,signal:l,test:u}){if(!await ti(e,i))return{kind:"dispatch-failed",reason:"already-claimed",runId:i};let c=ee.join(t,".ripplo","debug"),p=[];return(await s.runOnce({capture:!0,lockfile:o,options:{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:n,generate:E,headed:r,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth},params:void 0,runId:i,sequence:void 0,test:u,onEvent:R=>{p.push(R)}},l)).match(async R=>{await te({config:e,debugDir:c,events:p,recordingOptional:!1,runId:i,stepSources:void 0});let Fe=en(p).flatMap(on=>on.findings);return Fe.length>0?{findings:Fe,kind:"findings",runId:i}:{kind:"pass",runId:i}},async R=>(await nn(e,i,De(R)),{error:R,kind:"error",runId:i}))}async function te({config:e,debugDir:t,events:n,recordingOptional:r,runId:o,stepSources:i}){let s=en(n),l=Mo(t,o);if(l==null&&!r)throw new Error("recording-missing");await Wo({aliases:[...Uo(n),..._o(s)],config:e,generated:Do(n),generatedSingletons:qo(n),origin:l==null?Lo(s):l.origin,records:s,rrwebEvents:l==null?[]:l.events,runId:o,stepSources:i}),l!=null&&await Zo(e,o,l),await ei(e,o,s),await $o(e,t,o)}var Fo=x(`
|
|
120
|
-
mutation ClipUploadUrl($runId: ID!) {
|
|
121
|
-
clipUploadUrl(runId: $runId)
|
|
122
|
-
}
|
|
123
|
-
`);async function $o(e,t,n){let r=ee.join(t,n,"clip.gif");if(je(r))try{let o=await m({config:e,document:Fo,variables:{runId:n}});if(o.clipUploadUrl==null)return;let i=await fetch(o.clipUploadUrl,{body:new Uint8Array(Ae(r)),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 Lo(e){return e.reduce((t,n)=>Math.min(t,n.startMs),e[0]?.startMs??0)}function en(e){return e.flatMap(t=>t.kind==="step"?[{annotations:t.annotations,endMs:t.endMs,findings:t.findings,index:t.index,source:t.source,startMs:t.startMs,state:t.state,url:t.url}]:[])}function Mo(e,t){let n=ee.join(e,t,"behavior.jsonl");if(!je(n))return null;let r=Ae(n,"utf8").split(`
|
|
124
|
-
`).filter(i=>i.length>0).map(i=>No(i)).flatMap(i=>Oo(i)?[i.event]:[]),o=r[0];return o==null?null:{events:r,origin:o.timestamp}}function No(e){return JSON.parse(e)}function Oo(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function Uo(e){return e.flatMap(t=>t.kind==="world"?t.aliases:[])}function _o(e){return e.flatMap(t=>{let n=Ho(t.source);return n.flatMap(r=>{let i=n.filter(l=>l.entity===r.entity).indexOf(r),s=t.state.rows.filter(l=>l.status==="created"&&l.entity===r.entity).at(i);return s==null?[]:[{alias:r.as,entity:r.entity,key:s.key}]})})}function Do(e){return new Set(e.flatMap(t=>t.kind==="world"?t.generated.map(n=>tn(n)):[]))}function tn({entity:e,field:t,key:n}){return`${e}\0${n}\0${t}`}function qo(e){return new Set(e.flatMap(t=>t.kind==="world"?t.generatedSingletons:[]))}function Ho(e){return e==null?[]:e.expect.flatMap(t=>Ce(t))}function Ce(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(t=>Ce(t)):e.kind==="when"?e.branches.flatMap(t=>t.consequence.flatMap(n=>Ce(n))):[]}async function Wo({aliases:e,config:t,generated:n,generatedSingletons:r,origin:o,records:i,rrwebEvents:s,runId:l,stepSources:u}){let d=i.map((c,p)=>Jo({aliases:e,generated:n,generatedSingletons:r,origin:o,record:c,rrwebEvents:s,sourceTest:u?.[p]??null}));await m({config:t,document:ri,variables:{items:[{runId:l,steps:d}]}})}var Bo=3,Vo=0;function zo({endMs:e,rrwebEvents:t,startMs:n}){let r=t.find(o=>o.type===Bo&&o.data?.source===Vo&&o.timestamp>=n&&o.timestamp<=e);return r==null?n:r.timestamp}function Jo({aliases:e,generated:t,generatedSingletons:n,origin:r,record:o,rrwebEvents:i,sourceTest:s}){let l=_e(o.source,o.index),u=zo({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)-r),rrwebIds:[...p.rrwebIds],url:p.url})),c=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=>Yt(p)),nodeType:l.kind,recordingEndMs:Math.max(0,o.endMs-r),recordingStartMs:Math.max(0,u-r),rrwebIds:[...c],snapshotTimestamp:Math.max(0,o.endMs-r),sourceTest:s,stateRows:o.state.rows.map(p=>Ko({aliases:e,generated:t,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:Xt(l),url:o.url}}function Ko({aliases:e,generated:t,row:n}){let r=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:t.has(tn({entity:n.entity,field:o.field,key:n.key})),value:o.value==null?null:String(o.value)})),key:n.key,label:r?.alias??n.key,status:n.status}}var Go=Ao(jo);async function nn(e,t,n){await m({config:e,document:ai,variables:{reason:n,runId:t}}).catch(r=>{y.error(r,"failRun submission failed")})}async function rn(e,t){await m({config:e,document:si,variables:{runIds:[t]}})}var Qo="application/x-ndjson";async function Xo({config:e,debugDir:t,runId:n}){let r=ee.join(t,n,"behavior.jsonl");if(je(r))try{let o=await m({config:e,document:Yo,variables:{runId:n}}),i=await fetch(o.debugArtifactUploadUrl,{body:Ae(r),headers:{"content-type":Qo},method:"PUT"});if(!i.ok){y.warn({runId:n,status:i.status},"behavior upload PUT failed");return}await rn(e,n)}catch(o){y.warn({error:o,runId:n},"behavior upload failed")}}var Yo=x(`
|
|
125
|
-
mutation DebugArtifactUploadUrl($runId: String!) {
|
|
126
|
-
debugArtifactUploadUrl(runId: $runId)
|
|
127
|
-
}
|
|
128
|
-
`);async function Zo(e,t,n){let r=n.events.map(s=>JSON.stringify(s)).join(`
|
|
129
|
-
`),o=await Go(Buffer.from(r,"utf8")),i=n.events.at(-1);await m({config:e,document:oi,variables:{input:{bodyBase64:o.toString("base64"),chunkIndex:0,endTimestamp:Math.max(0,(i?.timestamp??n.origin)-n.origin),eventCount:n.events.length,runId:t,startTimestamp:0}}})}async function ei(e,t,n){let r=n.filter(s=>s.findings.length>0).length,o=n.length-r,i=n.reduce((s,l)=>s+Math.max(0,l.endMs-l.startMs),0);await m({config:e,document:ii,variables:{items:[{duration:i,failCount:r,passCount:o,runId:t,status:r>0?"failed":"passed",summary:null,warnCount:0}]}})}async function ti(e,t){return((await m({config:e,document:ni,variables:{runIds:[t]}})).startRunsBatch??[]).some(r=>r.id===t)}var ni=x(`
|
|
130
|
-
mutation StartRunsBatch($runIds: [String!]!) {
|
|
131
|
-
startRunsBatch(runIds: $runIds) {
|
|
132
|
-
id
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
`),ri=x(`
|
|
136
|
-
mutation SubmitRunStepsBatch($items: [SubmitRunStepsItem!]!) {
|
|
137
|
-
submitRunStepsBatch(items: $items)
|
|
138
|
-
}
|
|
139
|
-
`),oi=x(`
|
|
140
|
-
mutation SubmitRunRecordingChunk($input: SubmitRunRecordingChunkInput!) {
|
|
141
|
-
submitRunRecordingChunk(input: $input)
|
|
142
|
-
}
|
|
143
|
-
`),ii=x(`
|
|
144
|
-
mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
|
|
145
|
-
completeRunsBatch(items: $items) {
|
|
146
|
-
id
|
|
147
|
-
status
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
`),ai=x(`
|
|
151
|
-
mutation FailRun($runId: String!, $reason: String!) {
|
|
152
|
-
failRun(runId: $runId, reason: $reason)
|
|
153
|
-
}
|
|
154
|
-
`),si=x(`
|
|
155
|
-
mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
|
|
156
|
-
markRunArtifactsUploadedBatch(runIds: $runIds)
|
|
157
|
-
}
|
|
158
|
-
`);import{randomUUID as ci}from"crypto";import{graphql as j}from"gql.tada";async function Te({baseState:e,branchName:t,category:n,commitSha:r,config:o,debugDir:i,devSessionId:s,events:l,lockfileHash:u,reproJson:d,runId:c,signature:p,spec:g,stepSources:R}){await m({config:o,document:li,variables:{branchName:t??null,commitSha:r??null,devSessionId:s??null,lockfileHash:u??null,projectId:o.projectId,reproJson:d,runId:c,spec:g??null}}),await te({config:o,debugDir:i,events:l,recordingOptional:!0,runId:c,stepSources:R}),await m({config:o,document:di,variables:{baseState:e,category:n,projectId:o.projectId,reproRunId:c,signature:p}})}var id=j(`
|
|
159
|
-
mutation RecordExplorationProgress($devSessionId: String!, $attempts: Int!, $findings: Int!) {
|
|
160
|
-
recordExplorationProgress(devSessionId: $devSessionId, attempts: $attempts, findings: $findings)
|
|
161
|
-
}
|
|
162
|
-
`),ad=j(`
|
|
163
|
-
mutation ContinueExploreLoop($devSessionId: String!, $epoch: Int!) {
|
|
164
|
-
continueExploreLoop(devSessionId: $devSessionId, epoch: $epoch)
|
|
165
|
-
}
|
|
166
|
-
`),li=j(`
|
|
167
|
-
mutation CreateExploreRun(
|
|
168
|
-
$projectId: String!
|
|
169
|
-
$runId: String!
|
|
170
|
-
$devSessionId: String
|
|
171
|
-
$branchName: String
|
|
172
|
-
$commitSha: String
|
|
173
|
-
$lockfileHash: String
|
|
174
|
-
$spec: String
|
|
175
|
-
$reproJson: String
|
|
176
|
-
) {
|
|
177
|
-
createExploreRun(
|
|
178
|
-
projectId: $projectId
|
|
179
|
-
runId: $runId
|
|
180
|
-
devSessionId: $devSessionId
|
|
181
|
-
branchName: $branchName
|
|
182
|
-
commitSha: $commitSha
|
|
183
|
-
lockfileHash: $lockfileHash
|
|
184
|
-
spec: $spec
|
|
185
|
-
reproJson: $reproJson
|
|
186
|
-
) {
|
|
187
|
-
id
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
`),di=j(`
|
|
191
|
-
mutation SubmitExploreFinding(
|
|
192
|
-
$projectId: String!
|
|
193
|
-
$signature: String!
|
|
194
|
-
$baseState: String!
|
|
195
|
-
$category: ExploreFindingCategory!
|
|
196
|
-
$reproRunId: String!
|
|
197
|
-
) {
|
|
198
|
-
submitExploreFinding(
|
|
199
|
-
projectId: $projectId
|
|
200
|
-
signature: $signature
|
|
201
|
-
baseState: $baseState
|
|
202
|
-
category: $category
|
|
203
|
-
reproRunId: $reproRunId
|
|
204
|
-
) {
|
|
205
|
-
id
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
`),sd=j(`
|
|
209
|
-
mutation SetExploreFindingStatus(
|
|
210
|
-
$projectId: String!
|
|
211
|
-
$signature: String!
|
|
212
|
-
$status: ExploreFindingStatus!
|
|
213
|
-
) {
|
|
214
|
-
setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
|
|
215
|
-
}
|
|
216
|
-
`),ld=j(`
|
|
217
|
-
query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
|
|
218
|
-
exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
|
|
219
|
-
}
|
|
220
|
-
`);async function ui({assign:e,config:t,debugDir:n,devSessionId:r,fixturesDir:o,headed:i,lockfile:s,report:l,session:u,signal:d}){let c=qe(s);if(e.stepRuns.length===0)return{kind:"error",reason:"empty-trail"};let p=hi(c,e.stepRuns),g=await Be({baseState:{name:S(e.baseStateTest),test:e.baseStateTest},corpus:c,lockfile:s,options:{baseUrl:t.appUrl,engineUrl:t.engineUrl,fixturesDir:o,generate:E,headed:i,secret:t.webhookSecret,tunnelAuth:t.tunnelAuth},session:u,stepRuns:e.stepRuns,runIdFor:R=>`explore-${ci()}-${String(R)}`},d);return l&&await mi({baseStateTest:e.baseStateTest,config:t,debugDir:n,devSessionId:r,lockfileHash:e.lockfileHash,outcome:g,reproJson:pi(c,e),stepSources:fi(p)}),Ri(g)}function pi(e,t){let n=t.stepRuns.flatMap(o=>{let i=e[o.idx];return i==null?[]:[{index:i.index,params:o.params,test:i.test}]}),r={baseStateRef:S(t.baseStateTest),steps:n};return JSON.stringify(r)}function fi(e){return e.flatMap(t=>{let n=t.label.split("#")[0]??t.label;return t.actions.map(()=>n)})}async function mi({baseStateTest:e,config:t,debugDir:n,devSessionId:r,lockfileHash:o,outcome:i,reproJson:s,stepSources:l}){i.kind!=="finding"||i.captureEvents.length===0||await Te({baseState:i.baseState,branchName:void 0,category:gi(i.verifierLayer),commitSha:void 0,config:t,debugDir:n,devSessionId:r,events:i.captureEvents,lockfileHash:o,reproJson:s,runId:i.runId,signature:i.signature,spec:yi(e,i.captureEvents),stepSources:l}).catch(u=>{y.warn({error:u},"explore finding report failed")})}function gi(e){return e==="data-rule"?"dataRule":e==="page-rule"?"pageRule":e}function yi(e,t){let n=t.flatMap(o=>o.kind==="step"?[o.source]:[]),r={absent:e.absent,exclusive:e.exclusive,intent:e.intent,maybe:[],name:e.name,params:e.params,singletons:e.singletons,steps:n,stub:!1,tests:[],world:e.world};return JSON.stringify(r)}function hi(e,t){return t.flatMap(n=>{let r=e[n.idx];return r==null?[]:[{actions:[...r.nav,...r.steps].map(o=>He(o.action)),label:`${r.test}#${String(r.index)}`}]})}function Ri(e){return e.kind==="error"?{kind:e.kind,reason:`runtime:${e.error.kind}`}:e.kind==="finding"?{kind:e.kind,runId:e.runId}:{kind:e.kind}}export{Ei as a,Ti as b,W as c,fn as d,B as e,F as f,I as g,pe as h,M as i,P as j,Zi as k,J as l,oa as m,ia as n,aa as o,pa as p,fe as q,ot as r,at as s,dt as t,ft as u,ye as v,ja as w,Z as x,zt as y,rl as z,ol as A,il as B,go as C,gl as D,os as E,is as F,xt as G,as as H,ss as I,ls as J,ds as K,cs as L,Et as M,bt as N,vt as O,It as P,Pt as Q,Sl as R,xl as S,El as T,bl as U,vl as V,Il as W,Pl as X,Cl as Y,jl as Z,Al as _,Tl as $,Fl as aa,Fa as ba,$a as ca,he as da,La as ea,gt as fa,Ga as ga,Se as ha,Wr as ia,Gs as ja,To as ka,nn as la,Xo as ma,ui as na,Dl as oa};
|