ripplo 0.7.46 → 0.7.47

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.
@@ -0,0 +1,279 @@
1
+ #!/usr/bin/env node
2
+ import{c as qe}from"./chunk-4J4T7534.js";import{A as on,a as P,b as C,c as De,d as Ue,e as Le,f as T,g as Ne,i as A,o as Ye,p as Xe,s as Ze,w as en,x as nn,y as tn,z as rn}from"./chunk-LISHXK5I.js";import{b as Ae,d as c,e as p,h as je,i as Me}from"./chunk-4K4VY5OR.js";import{A as Ve,B as Be,E as Ke,S as Je,T as Qe,W as ze,X as Ge,a as v,b as $e,i as Fe,j as Oe,k as m,l as _e,m as g,n as E,o as He,s as We,u as j,v as M}from"./chunk-S3KN37I7.js";import ln from"fs";import U from"path";import{config as ft}from"dotenv";import{z as O}from"zod";import{err as yt,ok as dn}from"neverthrow";import F from"fs";import te from"path";import{err as ee,ok as an}from"neverthrow";import{z as $}from"zod";var dt=te.join(".ripplo","project.json"),ne=[".env",".env.local"],ct=$.object({envFiles:$.array($.string().min(1)).optional(),projectId:$.string().min(1)});function sn(e){return te.join(e,dt)}function re(e){let n=sn(e);return F.existsSync(n)?ut(n).andThen(t=>{let r=ct.safeParse(t);return r.success?an({envFiles:r.data.envFiles??ne,projectId:r.data.projectId}):ee({issues:r.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:n})}):ee({kind:"project-file-missing",path:n})}function oe(e){return re(e).match(n=>n,()=>{})}function ut(e){try{return an(JSON.parse(F.readFileSync(e,"utf8")))}catch(n){return ee({issues:[n instanceof Error?n.message:String(n)],kind:"project-file-invalid",path:e})}}function ci({cwd:e,envFiles:n,projectId:t}){let r=sn(e);F.mkdirSync(te.dirname(r),{recursive:!0});let o={projectId:t};n!=null&&!pt(n)&&(o.envFiles=[...n]),F.writeFileSync(r,JSON.stringify(o,null,2)+`
3
+ `)}function pt(e){return e.length!==ne.length?!1:e.every((n,t)=>n===ne[t])}function hi(e){let t=oe(e)?.envFiles??[".env",".env.local"],r=U.join(e,".ripplo");t.forEach(o=>{let i=U.resolve(r,o);ln.existsSync(i)&&ft({override:!0,path:i,quiet:!0})}),D=void 0}var mt=O.object({RIPPLO_APP_URL:O.url(),RIPPLO_ENGINE_URL:O.url(),RIPPLO_WEBHOOK_SECRET:O.string().min(1)}),D;function L(){return D!=null?dn(D):Rt().map(e=>(D=e,e))}function gt(e){let t=oe(e)?.envFiles??[],r=U.join(e,".ripplo");return t.map(o=>U.resolve(r,o)).filter(o=>!ln.existsSync(o))}function Rt(){let e=mt.safeParse(process.env);if(!e.success)return yt({issues:e.error.issues.map(t=>`${t.path.join(".")}: ${t.message}`),kind:"env-invalid",missingEnvFiles:gt(process.cwd())});let n=e.data;return dn({appUrl:n.RIPPLO_APP_URL,engineUrl:n.RIPPLO_ENGINE_URL,webhookSecret:n.RIPPLO_WEBHOOK_SECRET})}var N=class extends Error{failure;constructor(n){super(n.kind),this.name="CliError",this.failure=n}};function bi(e){return e instanceof N?ie(e.failure):e instanceof Error?e.message:String(e)}function ie(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).",Ne("setup")].join(`
4
+ `);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(n=>` ${n}`),"Fix the file by hand or re-run `npx ripplo init`."].join(`
5
+ `);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(`
6
+ `);case"env-invalid":return ht(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(`
7
+ `);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(`
8
+ `);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(`
9
+ `);case"compilation-failed":return A(e.error)}}function ht(e){let n=e.missingEnvFiles.length===0?[]:["Declared env files not found:",...e.missingEnvFiles.map(t=>` ${t}`),"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(t=>` ${t}`),"Add the missing values to the env files declared in .ripplo/project.json.",...n].join(`
10
+ `)}import{err as wt,ok as vt}from"neverthrow";import{z as ae}from"zod";var St="https://ripplo.ai";function un(){return fn().RIPPLO_SERVER_URL}function pn(){return fn().RIPPLO_PROJECT_ID}var kt=ae.object({RIPPLO_PROJECT_ID:ae.string().min(1).optional(),RIPPLO_SERVER_URL:ae.string().min(1).default(St)}),cn;function fn(){return cn??=kt.parse(process.env),cn}import yn from"fs";import se from"path";function mn(e){let n=yn.realpathSync(e),t=n,r=se.dirname(t);for(;r!==t;){if(yn.existsSync(se.join(t,".git")))return t;t=r,r=se.dirname(t)}return n}function q(e){return re(e).andThen(n=>L().andThen(t=>{let r=un(),o=Me(r);return o==null?wt({kind:"not-authenticated"}):vt({appUrl:t.appUrl,cwd:mn(e),engineUrl:t.engineUrl,projectId:pn()??n.projectId,ripploServerUrl:r,token:o,tunnelAuth:void 0,webhookSecret:t.webhookSecret})}))}import xt from"p-queue";var bt=4,Et={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},_=new xt({concurrency:bt}),S={headedActive:0,interactiveActive:0,interactiveQueued:0},gn={current:null};function Ni({headed:e,task:n,workClass:t}){let r=Et[t];return t==="p3-explore"?_.add(n,{priority:r}):(S.interactiveQueued+=1,H(),_.add(()=>It({headed:e,task:n}),{priority:r}))}function qi(e){!Number.isFinite(e)||e<1||(_.concurrency=Math.floor(e),H())}function le(){return{active:S.interactiveActive,headedActive:S.headedActive,poolSize:_.concurrency,queued:S.interactiveQueued}}function _i(e){gn.current=e}async function It({headed:e,task:n}){S.interactiveQueued-=1,S.interactiveActive+=1,S.headedActive+=e?1:0,H();try{return await n()}finally{S.interactiveActive-=1,S.headedActive-=e?1:0,H()}}function H(){gn.current?.()}import de from"fs";import ce from"path";function Rn(e){try{let n=Pt(e);if(n==null)return;let t=ce.join(n,"HEAD"),r=de.readFileSync(t,"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 Pt(e){let n=ce.join(e,".git");if(de.statSync(n).isDirectory())return n;let r=de.readFileSync(n,"utf8").trim(),o="gitdir:";if(!r.startsWith(o))return;let i=r.slice(o.length).trim();if(i.length!==0)return ce.resolve(e,i)}import Ct from"crypto";import{readFile as hn}from"fs/promises";import Sn from"path";import{graphql as ue}from"gql.tada";import{err as Tt,ok as At}from"neverthrow";var jt=ue(`
11
+ mutation SyncDevSession(
12
+ $projectId: String!
13
+ $cwd: String!
14
+ $branch: String
15
+ $lockfileContent: String
16
+ $fixtures: [SyncDevFixtureInput!]
17
+ $preconditions: [SyncDevPreconditionInput!]!
18
+ $singletons: [SyncDevSingletonInput!]
19
+ $workflows: [SyncDevWorkflowInput!]!
20
+ ) {
21
+ syncDevSession(
22
+ projectId: $projectId
23
+ cwd: $cwd
24
+ branch: $branch
25
+ lockfileContent: $lockfileContent
26
+ fixtures: $fixtures
27
+ preconditions: $preconditions
28
+ singletons: $singletons
29
+ workflows: $workflows
30
+ ) {
31
+ id
32
+ hooksPaused
33
+ }
34
+ }
35
+ `);async function ta(e,n){let t=await T(e);if(t.isErr())return Tt({error:t.error,kind:"compilation-failed"});let r=await x({config:n,cwd:e,lockfile:t.value});return At({devSessionId:r.devSessionId,lockfile:t.value})}async function x(e){let n=Fe(e.lockfile);return Ft({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:n})}var Mt=ue(`
36
+ query DevSessionSyncState($projectId: String!, $cwd: String!) {
37
+ project(id: $projectId) {
38
+ devSession(cwd: $cwd) {
39
+ id
40
+ hooksPaused
41
+ lockfileHash
42
+ }
43
+ }
44
+ }
45
+ `),$t=ue(`
46
+ mutation AnnounceDevSessionActive($projectId: String!, $cwd: String!) {
47
+ announceDevSessionActive(projectId: $projectId, cwd: $cwd)
48
+ }
49
+ `);async function ra(e){let n=await pe(e.cwd);if(n!=null){let r=(await c({config:e.config,document:Mt,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null))?.project?.devSession;if(r!=null&&r.lockfileHash===n)return await c({config:e.config,document:$t,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null),{devSessionId:r.id,hooksPaused:r.hooksPaused}}return x(e)}async function pe(e){let n=await kn(e);return n==null?null:Ct.createHash("sha256").update(n).digest("hex")}async function Ft({config:e,cwd:n,fixtures:t,payload:r}){let o=Rn(n),i=await kn(n),a=await Ot(n,t),s=await c({config:e,document:jt,variables:{branch:o??null,cwd:n,fixtures:a,lockfileContent:i,preconditions:r.preconditions.map(l=>({depends:[...l.depends],description:l.description,name:l.name,returns:[...l.returns]})),projectId:e.projectId,singletons:r.singletons.map(l=>({defaultValue:l.defaultValue,description:l.description,name:l.name,type:l.type})),workflows:r.workflows.map(l=>({expectedOutcome:l.expectedOutcome,name:l.name,preconditions:[...l.preconditions],requiresKeys:l.requiresKeys.map(u=>({namespace:u.namespace,preconditionName:u.preconditionName})),slug:l.slug,sourcePath:l.sourcePath,spec:JSON.stringify(l.spec)}))}});if(s.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:s.syncDevSession.id,hooksPaused:s.syncDevSession.hooksPaused}}async function Ot(e,n){let t=Object.entries(n);return Promise.all(t.map(async([r,o])=>({contentBase64:(await hn(Sn.join(e,C,r))).toString("base64"),sha256:o.sha256})))}async function kn(e){try{return await hn(Sn.join(e,De),"utf8")}catch{return null}}import{randomUUID as cr}from"crypto";import{createId as ur}from"@paralleldrive/cuid2";import{CancellationTokenSource as pr,ResponseError as fr}from"vscode-jsonrpc/node";import{graphql as Dt}from"gql.tada";var Ut=Dt(`
50
+ mutation DaemonCreateRun(
51
+ $id: String
52
+ $workflowId: String!
53
+ $testId: String
54
+ $clientVersion: String
55
+ $executor: RunExecutor
56
+ $target: RunTarget
57
+ $lockfileHash: String
58
+ ) {
59
+ createRun(
60
+ id: $id
61
+ workflowId: $workflowId
62
+ testId: $testId
63
+ executor: $executor
64
+ target: $target
65
+ clientVersion: $clientVersion
66
+ lockfileHash: $lockfileHash
67
+ ) {
68
+ __typename
69
+ ... on MutationCreateRunSuccess {
70
+ data {
71
+ id
72
+ }
73
+ }
74
+ ... on LimitExceededError {
75
+ code
76
+ }
77
+ }
78
+ }
79
+ `);async function wn(e){try{let t=(await c({config:e.config,document:Ut,variables:Lt(e)})).createRun;return t==null?W({detail:"create-run-null",type:"generic"}):t.__typename==="MutationCreateRunSuccess"?null:t.__typename==="LimitExceededError"?W({code:t.code,type:"limit"}):W({detail:t.__typename,type:"generic"})}catch(n){return Nt(n)}}function Lt({executor:e,lockfileHash:n,runId:t,target:r}){return{clientVersion:P(),executor:e,id:t,lockfileHash:n,target:e==="cloud"?"tunnel":void 0,testId:r.testId,workflowId:r.workflowId}}function W(e){return{kind:"dispatch-error",reason:e}}function Nt(e){return e instanceof Ae?{detail:e.message,kind:"infra-error"}:W({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{graphql as qt}from"gql.tada";async function vn(e,n){let r=(await c({config:e,document:_t,variables:{cwd:n,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 _t=qt(`
80
+ query DaemonWorkflows($projectId: String!, $cwd: String!) {
81
+ project(id: $projectId) {
82
+ id
83
+ devSession(cwd: $cwd) {
84
+ id
85
+ workflows {
86
+ id
87
+ slug
88
+ tests {
89
+ id
90
+ slug
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ `);import{CancellationTokenSource as Ht}from"vscode-jsonrpc/node";function fe(e){return`${e.workflowSlug}/${e.testSlug}`}function xn(e){let{headed:n,inflight:t,jobId:r,lockfileHashValue:o,onExpire:i,runId:a,selection:s,timeoutMs:l}=e,u=fe(s),f=`${u}@${o}@${String(n)}`,d=t.get(f);if(d!=null)return d.jobIds.add(r),null;let y={cancellation:new Ht,claimed:!1,claimKey:u,headed:n,inflightKey:f,jobIds:new Set([r]),runId:a,testName:s.testName,timer:null,workflowName:s.workflowName};return y.timer=setTimeout(()=>{V(t,y),i(y)},l),t.set(f,y),y}function V(e,n){n.timer!=null&&(clearTimeout(n.timer),n.timer=null),e.delete(n.inflightKey)}function ye(e,n){let t=[...e.values()].find(r=>r.runId===n&&!r.claimed);return t==null?null:(t.claimed=!0,t.timer!=null&&(clearTimeout(t.timer),t.timer=null),t)}function bn(e,n){[...e.values()].filter(t=>t.jobIds.has(n)).forEach(t=>{t.jobIds.delete(n),t.jobIds.size===0&&(V(e,t),t.cancellation.cancel())})}import{err as me,ok as En}from"neverthrow";function Pn({all:e,ids:n,lockfile:t}){if(e&&n.length>0)return me({kind:"conflicting-flags"});if(e)return En(t.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(a=>g(a))));if(n.length===0)return me({kind:"nothing-selected"});let r=n.map(i=>({id:i,refs:Vt(t,i)})),o=r.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?me({kind:"unknown-ids",known:Wt(t),unknown:o}):En([...new Set(r.flatMap(i=>i.refs))])}function Cn(e,n){let t=new Map(E(e).map(r=>[r.ref,{testName:r.test.name,testSlug:r.test.slug,workflowName:r.workflow.name,workflowSlug:m(r.workflow.name)}]));return n.map(r=>{let o=t.get(r);if(o==null)throw new Error(`selectionsFor: ref not in lockfile: ${r}`);return o})}function Wt(e){return e.workflows.map(n=>m(n.name))}function Vt(e,n){let t=e.workflows.find(r=>r.name===n||m(r.name)===m(n));return t!=null?t.tests.map(r=>g(r)):E(e).filter(r=>r.ref===n||In(r.ref)===In(n)).map(r=>r.ref)}function In(e){let n=e.lastIndexOf("/");return n===-1?m(e):`${m(e.slice(0,n))}/${m(e.slice(n+1))}`}import{err as he,ok as $n}from"neverthrow";import{graphql as Fn}from"gql.tada";import{graphql as Xt}from"gql.tada";import{execFileSync as Bt}from"child_process";var Kt=256*1024*1024;function B(e,n){return Bt("git",[...e],{cwd:n,encoding:"utf8",maxBuffer:Kt,stdio:["ignore","pipe","pipe"]})}import Gt from"fs";import Jt from"fs";import ge from"path";var Qt=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function Tn(e){let n=zt(e);return n==null?!1:Qt.some(t=>Jt.existsSync(ge.join(n,t)))}function zt(e){try{let n=B(["rev-parse","--git-dir"],e).trim();return n.length===0?null:ge.isAbsolute(n)?n:ge.resolve(e,n)}catch{return null}}function Yt(e){return je(e,"hooks-paused")}function An(e){return Gt.existsSync(Yt(e))||Tn(e)?!1:qe(e)}var Zt=Xt(`
97
+ mutation AutoScopeAddDirty($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
98
+ addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
99
+ __typename
100
+ ... on MutationAddDirtyTestsToScopeSuccess {
101
+ data {
102
+ id
103
+ }
104
+ }
105
+ }
106
+ }
107
+ `);async function Da({cwd:e,lockfile:n}){if(!An(e))return{addedSlugs:[]};let t=Re(e);if(t.length===0)return{addedSlugs:[]};let r=new Set(t),o=n.workflows.filter(l=>l.sourcePath!=null&&r.has(l.sourcePath)).map(l=>m(l.name));if(o.length===0)return{addedSlugs:[]};let i=q(e).unwrapOr(void 0);return i==null?{addedSlugs:[]}:await x({config:i,cwd:e,lockfile:n}).catch(l=>(p.warn("auto-sync failed: %s",l instanceof Error?l.message:String(l)),null))==null?{addedSlugs:[]}:{addedSlugs:await er({cfg:i,slugs:o})?o:[]}}async function er({cfg:e,slugs:n}){let r=(await c({config:e,document:Zt,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:[...n]}}).catch(o=>(p.warn("auto-scope failed: %s",o instanceof Error?o.message:String(o)),null)))?.addDirtyTestsToScope;return r?.__typename!=="MutationAddDirtyTestsToScopeSuccess"?!1:r.data.length>0}var jn=".ripplo/workflows/",Mn=" -> ";function Re(e){let n;try{n=B(["status","--porcelain","-uall","--",".ripplo/workflows"],e)}catch{return[]}return n.split(`
108
+ `).map(t=>t.slice(3).trim()).map(t=>t.includes(Mn)?t.split(Mn)[1]:t).filter(t=>t!=null).filter(t=>t.startsWith(jn)&&t.endsWith(".ts")).map(t=>t.slice(jn.length)).filter(t=>t!=="index.ts"&&!t.endsWith("/index.ts"))}async function On({config:e,cwd:n,lockfile:t}){await tr({config:e,cwd:n,lockfile:t});let r=await or(e);if(r.isErr())return he(r.error);let o=new Map(t.workflows.filter(a=>!a.stub).map(a=>[m(a.name),a])),i=[...new Set(r.value)].flatMap(a=>{let s=o.get(a);return s==null?[]:s.tests.map(l=>g(l))});return i.length===0?he({kind:"scope-empty"}):$n(i)}var nr=Fn(`
109
+ mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
110
+ addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
111
+ __typename
112
+ }
113
+ }
114
+ `);async function tr({config:e,cwd:n,lockfile:t}){let r=new Set(Re(n)),o=t.workflows.filter(i=>i.sourcePath!=null&&r.has(i.sourcePath)).map(i=>m(i.name));o.length!==0&&await c({config:e,document:nr,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{p.warn({err:i},"auto-scope of dirty tests failed")})}var rr=Fn(`
115
+ query ScopeSelection($projectId: String!, $cwd: String!) {
116
+ project(id: $projectId) {
117
+ id
118
+ devSession(cwd: $cwd) {
119
+ id
120
+ scopeItems {
121
+ id
122
+ workflow {
123
+ id
124
+ slug
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ `);async function or(e){try{let t=(await c({config:e,document:rr,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return $n(t.flatMap(r=>r.workflow==null?[]:[r.workflow.slug]))}catch(n){return he({detail:n instanceof Error?n.message:String(n),kind:"scope-fetch-failed"})}}import{graphql as ir}from"gql.tada";var ar=2e3,sr=ir(`
131
+ query DaemonCloudRunStatus($runId: String!) {
132
+ run(id: $runId) {
133
+ status
134
+ failureReason
135
+ }
136
+ }
137
+ `);function Un({config:e,onComplete:n,onStarted:t,runId:r,signal:o}){let i=!1,a,s=!1,l=async()=>{if(i||o.aborted)return;let u=await lr(e,r).catch(()=>"unknown");if(!(i||o.aborted)){if(!s&&(u==="running"||Dn(u))&&(s=!0,t()),Dn(u)){i=!0,n(dr(u));return}a=setTimeout(()=>{l()},ar)}};return l(),{stop:()=>{i=!0,a!=null&&clearTimeout(a)}}}async function lr(e,n){let r=(await c({config:e,document:sr,variables:{runId:n}})).run?.status;return r??"unknown"}function Dn(e){return e==="passed"||e==="failed"||e==="warning"||e==="cancelled"||e==="unready"}function dr(e){return e==="passed"?{kind:"pass"}:e==="failed"?{detail:"failed",kind:"error"}:e==="warning"?{findingLines:[],kind:"findings"}:e==="cancelled"?{detail:"cancelled",kind:"error"}:e==="unready"?{detail:"unready",kind:"error"}:{detail:"unknown",kind:"error"}}var yr=12e4,mr=-32099,Se=new Set,Ln=new Map;function ds(e){Se.add(e)}function gr(e){let n=new AbortController;return e.isCancellationRequested?(n.abort(),n.signal):(e.onCancellationRequested(()=>{n.abort()}),n.signal)}function cs(e){let n={...e,inflight:new Map,jobs:new Map};return{claim:t=>wr(n,t),handleConnection:t=>{Rr(n,t)},idle:()=>_n(n)}}function Rr(e,n){let t=Ye(n);t.onRequest(en,(r,o)=>hr({connection:t,ctx:e,params:r,token:o})),t.onRequest(nn,()=>{let r=le();return{active:r.active,queued:r.queued,sseHealth:e.sseHealth(),version:P(),...e.explorationStatus()}}),t.onRequest(tn,()=>{let r=_n(e);return r&&e.onShutdownRequest(),r}),t.onClose(()=>{Sr(e,t)}),t.onError(r=>{p.warn({err:r},"ipc connection error")}),n.on("error",r=>{p.warn({err:r},"ipc socket error")}),t.listen()}function _n(e){let n=le();return e.jobs.size===0&&n.active===0&&n.queued===0}async function hr({connection:e,ctx:n,params:t,token:r}){let o=Xe.safeParse(t);if(!o.success)throw Nn({code:"bad-message"});await n.ready;let i=await xr({config:n.config,cwd:n.cwd,message:o.data});if(i.kind==="error")throw Nn(i.error);let a=cr(),s=new pr;return r.onCancellationRequested(()=>{Hn(n,a)}),n.jobs.set(a,{cancellation:s,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),Mr({ctx:n,headed:o.data.headed,jobId:a,lockfileHashValue:i.lockfileHashValue,selections:i.selections,targetsByClaimKey:i.targetsByClaimKey,token:s.token}).catch(l=>{p.error({err:l},"ipc dispatch failed")}),{jobId:a,total:i.selections.length}}function Nn(e){return new fr(mr,e.code,e)}function Hn(e,n){let t=e.jobs.get(n);t!=null&&(t.cancellation.cancel(),e.jobs.delete(n),bn(e.inflight,n))}function Sr(e,n){[...e.jobs.entries()].filter(([,t])=>t.connection===n).forEach(([t])=>{Hn(e,t)})}function Wn(e,n,t){let r=e.jobs.get(n);r!=null&&(qn(()=>r.connection.sendNotification(rn,{event:t,jobId:n})),t.kind==="test-outcome"&&(kr(r,t.outcome.kind),r.passed+r.failed+r.notRun>=r.total&&(qn(()=>r.connection.sendNotification(on,{failed:r.failed,jobId:n,notRun:r.notRun,passed:r.passed})),e.jobs.delete(n))))}function qn(e){Promise.resolve().then(e).catch(n=>{p.warn({err:n},"ipc notification failed")})}function kr(e,n){if(n==="pass"){e.passed+=1;return}if(n==="dispatch-error"||n==="dispatch-timeout"||n==="infra-error"){e.notRun+=1;return}e.failed+=1}function b(e,n,t){n.jobIds.forEach(r=>{Wn(e,r,t)})}function wr(e,n){let t=ye(e.inflight,n);return t==null?null:{headed:t.headed,token:t.cancellation.token,finished:(r,o)=>{e.inflight.delete(t.inflightKey),b(e,t,{kind:"test-outcome",outcome:o,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},started:()=>{b(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}}}function vr(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 xr({config:e,cwd:n,message:t}){return(await Ue(n)).match(o=>br({config:e,cwd:n,lockfile:o,message:t}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...vr(o)]},kind:"error"}))}async function br({config:e,cwd:n,lockfile:t,message:r}){let o=await Pr(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=await pe(n);if(i==null)return{error:{code:"sync-failed",detail:"lockfile-missing"},kind:"error"};if(!Se.has(i)){let s=await Cr({config:e,cwd:n,lockfile:t});if(s!=null)return{error:{code:"sync-failed",detail:s},kind:"error"};Se.add(i)}return(await Tr({config:e,cwd:n,lockfile:t,message:r})).match(async s=>({kind:"ready",lockfileHashValue:i,selections:Cn(t,s),targetsByClaimKey:await Er({config:e,cwd:n,hash:i})}),s=>Promise.resolve({error:s,kind:"error"}))}async function Er({config:e,cwd:n,hash:t}){let r=Ln.get(t);if(r!=null)return r;let o=await vn(e,n);return Ln.set(t,o),o}var Ir=2e3;async function Pr(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(Ir)}),null}catch(n){return n instanceof Error?n.message:String(n)}}async function Cr(e){try{return await x(e),null}catch(n){return n instanceof Error?n.message:String(n)}}async function Tr({config:e,cwd:n,lockfile:t,message:r}){return!r.all&&r.tests.length===0?(await On({config:e,cwd:n,lockfile:t})).mapErr(Ar):Pn({all:r.all,ids:r.tests,lockfile:t}).mapErr(jr)}function Ar(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function jr(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 Mr(e){await e.selections.reduce((n,t)=>n.then(()=>$r(e,t)),Promise.resolve())}async function $r(e,n){let{ctx:t,headed:r,jobId:o,lockfileHashValue:i,targetsByClaimKey:a,token:s}=e;if(s.isCancellationRequested)return;let l=fe(n),u=a.get(l);if(u==null){Wn(t,o,{kind:"test-outcome",outcome:{kind:"dispatch-error",reason:{detail:"test-not-found",type:"generic"}},runId:"",testName:n.testName,workflowName:n.workflowName});return}let f=xn({headed:r,inflight:t.inflight,jobId:o,lockfileHashValue:i,runId:ur(),selection:n,timeoutMs:yr,onExpire:k=>{b(t,k,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:k.testName,workflowName:k.workflowName})}});if(f==null)return;let d=t.executor(),y=await Fr({ctx:t,executor:d,lockfileHashValue:i,run:f,target:u});if(y!=null){V(t.inflight,f),b(t,f,{kind:"test-outcome",outcome:y,runId:"",testName:n.testName,workflowName:n.workflowName});return}d==="cloud"&&Or(t,f)}function Fr({ctx:e,executor:n,lockfileHashValue:t,run:r,target:o}){return wn({config:e.config,executor:n,lockfileHash:t,runId:r.runId,target:o})}function Or(e,n){let t=ye(e.inflight,n.runId);t!=null&&Un({config:e.config,runId:t.runId,signal:gr(t.cancellation.token),onComplete:r=>{e.inflight.delete(t.inflightKey),b(e,t,{kind:"test-outcome",outcome:r,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},onStarted:()=>{b(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}})}import Dr from"fs";import Ur from"path";async function hs(e){let n=Ur.join(e,".ripplo","index.ts");if(!Dr.existsSync(n))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let t=await T(e);return t.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:A(t.error),path:".ripplo/"}],valid:!1,warnings:[]}:L().match(r=>({appUrl:r.appUrl,engineUrl:r.engineUrl,errors:[],valid:!0,warnings:[]}),r=>({appUrl:void 0,engineUrl:void 0,errors:[{message:ie(r),path:""}],valid:!1,warnings:[]}))}async function Ss(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 ks({appUrl:e,engineUrl:n}){let t=n.startsWith("http://")||n.startsWith("https://")?n:`${e}${n}`;try{return(await fetch(`${t}/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{createMessageConnection as Vn,IPCMessageReader as Bn,IPCMessageWriter as Kn,NotificationType as Lr,NotificationType0 as Jn,RequestType as Qn,RequestType0 as Nr}from"vscode-jsonrpc/node";import{z as R}from"zod";var Is=R.object({headed:R.boolean(),runId:R.string().min(1),testRef:R.string().min(1)}),Ps=R.object({lockfileJson:R.string().optional(),unavailable:R.string().optional()}),Cs=R.object({runId:R.string().min(1),span:$e}),Ts=R.object({outcome:Ze,serverNotified:R.boolean()}),As=new Jn("worker/ready"),js=new Qn("worker/run"),Ms=new Nr("worker/lockfile"),$s=new Qn("worker/exploreTrail"),Fs=new Lr("worker/span"),Os=new Jn("worker/shutdown");function Ds(e){let n=Vn(new Bn(e),new Kn(e));return n.listen(),n}function Us(){let e=Vn(new Bn(process),new Kn(process));return e.listen(),e}import{graphql as w}from"gql.tada";import{gzip as zr}from"zlib";import{promisify as Gr}from"util";import{existsSync as Xn,readFileSync as Zn}from"fs";import et from"path";import{graphql as I}from"gql.tada";function zn(e){return[e.kind,e.target,e.value].filter(n=>n.length>0).join(" ")}var qr={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},_r={"data-rule":"dataRule",fact:"fact",step:"step"},Hr={aborted:"aborted","action-failed":"actionFailed","app-not-ready":"appNotReady","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 Gn(e){return e.kind==="consistency"?{consistency:{mismatch:Br(e.mismatch),pending:e.pending}}:e.kind==="pending-check"?{pendingCheck:{budget:e.budget,source:_r[e.source.kind],...Wr(e.source)}}:e.kind==="unrunnable"?{unrunnable:{reason:qr[e.reason]}}:e.kind==="lift-visibility"?{liftVisibility:{subject:v(e.locator)}}:e.kind==="driver-error"?{driverError:{errorKind:Hr[e.error.kind],message:Qr(e.error)}}:{impossibleAction:{subject:Vr(e.step.action)}}}function Wr(e){return"check"in e?Yn(e.check,!1):{checkKind:void 0,expected:void 0,negated:void 0,subject:void 0}}function Yn(e,n){return e.kind==="not"?Yn(e.inner,!n):e.kind==="browser"?{checkKind:"browser",expected:e.value??void 0,negated:n,subject:_e(e.key)}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:n,subject:v(e.locator)}:{checkKind:e.kind,expected:void 0,negated:n,subject:v(e.locator)}}function Vr(e){let n=e.locator==null?e.url??"":v(e.locator);return`${e.kind} ${n}`.trim()}function Br(e){return e.kind==="wrong-value"?{wrongValue:{entity:e.entity,field:e.field,key:e.key,snapshot:K(e.snapshot),sut:K(e.sut)}}:e.kind==="expected-change"?{expectedChange:{entity:e.entity,field:e.field,key:e.key,value:K(e.value)}}:e.kind==="scalar-mismatch"?Kr(e):e.kind==="unexpected-row"?{unexpectedRow:{entity:e.entity,key:e.key}}:{missingRow:{entity:e.entity,key:e.key}}}function Kr(e){let n=e.subject.kind==="element"?e.subject:void 0,t=e.subject.kind==="variable"?e.subject:void 0;return{scalarMismatch:{checkKind:n?.state,singleton:t?.name,snapshot:Be(e.want),subject:Jr(e,n),sut:K(e.sut)}}}function Jr(e,n){if(n!=null)return v(n.locator);if(e.subject.kind!=="variable")return Ve(e.subject)}function K(e){return e==null?null:String(e)}function Qr(e){return"message"in e?e.message:"detail"in e?e.detail:null}function J({config:e,fixturesDir:n,headed:t}){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:n,generate:M,headed:t,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth}}async function we(e){let n=await Q(e);await ve(e.config,e.runId,n)}async function Q({config:e,debugDir:n,events:t,recordingOptional:r,runId:o,stepSources:i}){let a=xe(t),s=eo(n,o);if(s==null&&!r)throw new Error("recording-missing");return await Promise.all([lo({aliases:[...ro(t),...oo(a)],config:e,generated:io(t),generatedSingletons:ao(t),origin:s==null?Zr(a):s.origin,records:a,rrwebEvents:s==null?[]:s.events,runId:o,stepSources:i}),s==null?Promise.resolve():go(e,o,s)]),a}async function ve(e,n,t){let r=t.filter(a=>a.findings.length>0).length,o=t.length-r,i=t.reduce((a,s)=>a+Math.max(0,s.endMs-s.startMs),0);await c({config:e,document:ko,variables:{items:[{duration:i,failCount:r,passCount:o,runId:n,status:r>0?"failed":"passed",summary:null,warnCount:0}]}})}function xe(e){return e.flatMap(n=>n.kind==="step"?[{annotations:n.annotations,endMs:n.endMs,findings:n.findings,index:n.index,source:n.source,startMs:n.startMs,state:n.state,url:n.url}]:[])}async function nt(e,n){await c({config:e,document:wo,variables:{runIds:[n]}})}async function Yr({config:e,debugDir:n,runId:t}){let r=et.join(n,t,"behavior.jsonl");if(Xn(r))try{let o=await c({config:e,document:Ro,variables:{runId:t}}),i=await fetch(o.debugArtifactUploadUrl,{body:Zn(r),headers:{"content-type":Xr},method:"PUT"});if(!i.ok){p.warn({runId:t,status:i.status},"behavior upload PUT failed");return}await nt(e,t)}catch(o){p.warn({error:o,runId:t},"behavior upload failed")}}var Xr="application/x-ndjson";function Zr(e){return e.reduce((n,t)=>Math.min(n,t.startMs),e[0]?.startMs??0)}function eo(e,n){let t=et.join(e,n,"behavior.jsonl");if(!Xn(t))return null;let r=Zn(t,"utf8").split(`
138
+ `).filter(i=>i.length>0).map(i=>no(i)).flatMap(i=>to(i)?[i.event]:[]),o=r[0];return o==null?null:{events:r,origin:o.timestamp}}function no(e){return JSON.parse(e)}function to(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function ro(e){return e.flatMap(n=>n.kind==="world"?n.aliases:[])}function oo(e){return e.flatMap(n=>{let t=so(n.source);return t.flatMap(r=>{let i=t.filter(s=>s.entity===r.entity).indexOf(r),a=n.state.rows.filter(s=>s.status==="created"&&s.entity===r.entity).at(i);return a==null?[]:[{alias:r.as,entity:r.entity,key:a.key}]})})}function io(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generated.map(t=>tt(t)):[]))}function tt({entity:e,field:n,key:t}){return`${e} ${t} ${n}`}function ao(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generatedSingletons:[]))}function so(e){return e==null?[]:e.expect.flatMap(n=>ke(n))}function ke(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(n=>ke(n)):e.kind==="when"?e.branches.flatMap(n=>n.consequence.flatMap(t=>ke(t))):[]}async function lo({aliases:e,config:n,generated:t,generatedSingletons:r,origin:o,records:i,rrwebEvents:a,runId:s,stepSources:l}){let u=i.map((f,d)=>fo({aliases:e,generated:t,generatedSingletons:r,origin:o,record:f,rrwebEvents:a,sourceTest:l?.[d]??null}));await c({config:n,document:ho,variables:{items:[{runId:s,steps:u}]}})}var co=3,uo=0;function po({endMs:e,rrwebEvents:n,startMs:t}){let r=n.find(o=>o.type===co&&o.data?.source===uo&&o.timestamp>=t&&o.timestamp<=e);return r==null?t:r.timestamp}function fo({aliases:e,generated:n,generatedSingletons:t,origin:r,record:o,rrwebEvents:i,sourceTest:a}){let s=Oe(o.source,o.index),l=po({endMs:o.endMs,rrwebEvents:i,startMs:o.startMs}),u=o.annotations.map(d=>({kind:d.kind,label:d.label,outcome:d.outcome,recordingStartMs:Math.max(0,(d.kind==="action"?l:d.atMs)-r),rrwebIds:[...d.rrwebIds],url:d.url,value:d.value??null})),f=o.annotations.find(d=>d.kind==="action")?.rrwebIds??[];return{annotations:u,detail:null,duration:Math.max(0,o.endMs-o.startMs),findings:o.findings.map(d=>Gn(d)),nodeType:s.kind,recordingEndMs:Math.max(0,o.endMs-r),recordingStartMs:Math.max(0,l-r),rrwebIds:[...f],snapshotTimestamp:Math.max(0,o.endMs-r),sourceTest:a,stateRows:o.state.rows.map(d=>yo({aliases:e,generated:n,row:d})),stateSingletons:o.state.singletons.map(d=>({changed:d.changed,generated:t.has(d.name),name:d.name,value:d.value==null?null:String(d.value)})),status:o.findings.length>0?"failed":"passed",stepIndex:o.index,title:zn(s),url:o.url}}function yo({aliases:e,generated:n,row:t}){let r=e.find(o=>o.entity===t.entity&&o.key===t.key);return{entity:t.entity,fields:t.fields.map(o=>({changed:o.changed,field:o.field,generated:n.has(tt({entity:t.entity,field:o.field,key:t.key})),value:o.value==null?null:String(o.value)})),key:t.key,label:r?.alias??t.key,status:t.status}}var mo=Gr(zr);async function go(e,n,t){let r=t.events.map(a=>JSON.stringify(a)).join(`
139
+ `),o=await mo(Buffer.from(r,"utf8")),i=t.events.at(-1);await c({config:e,document:So,variables:{input:{bodyBase64:o.toString("base64"),chunkIndex:0,endTimestamp:Math.max(0,(i?.timestamp??t.origin)-t.origin),eventCount:t.events.length,runId:n,startTimestamp:0}}})}var Ro=I(`
140
+ mutation DebugArtifactUploadUrl($runId: String!) {
141
+ debugArtifactUploadUrl(runId: $runId)
142
+ }
143
+ `),ho=I(`
144
+ mutation SubmitRunStepsBatch($items: [SubmitRunStepsItem!]!) {
145
+ submitRunStepsBatch(items: $items)
146
+ }
147
+ `),So=I(`
148
+ mutation SubmitRunRecordingChunk($input: SubmitRunRecordingChunkInput!) {
149
+ submitRunRecordingChunk(input: $input)
150
+ }
151
+ `),ko=I(`
152
+ mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
153
+ completeRunsBatch(items: $items) {
154
+ id
155
+ status
156
+ }
157
+ }
158
+ `),wo=I(`
159
+ mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
160
+ markRunArtifactsUploadedBatch(runIds: $runIds)
161
+ }
162
+ `);function vo(e){let n=e.trail;if(!(n==null||!xo(e.kind)))return{baseLabel:n.baseLabel,baseState:n.baseState,durationMs:n.durationMs,outcome:e.kind,runId:e.runId,signature:n.signature,steps:n.steps}}function xo(e){return e==="clean"||e==="flaky"||e==="finding"}async function be({baseState:e,branchName:n,category:t,commitSha:r,config:o,debugDir:i,devSessionId:a,events:s,lockfileHash:l,reproJson:u,runId:f,signature:d,spec:y,stepSources:k}){await c({config:o,document:Ao,variables:{branchName:n??null,commitSha:r??null,devSessionId:a??null,lockfileHash:l??null,projectId:o.projectId,reproJson:u,runId:f,spec:y??null}}),await we({config:o,debugDir:i,events:s,recordingOptional:!0,runId:f,stepSources:k}),await c({config:o,document:jo,variables:{baseState:e,category:t,projectId:o.projectId,reproRunId:f,signature:d}})}async function z(e,n,t){return(await c({config:e,document:Mo,variables:{lockfileHash:t,projectId:e.projectId,signature:n}})).exploreFindingExists}async function bo({attempts:e,config:n,devSessionId:t,findings:r,trail:o}){await c({config:n,document:Co,variables:{attempts:e,devSessionId:t,findings:r,trail:o==null?null:{baseLabel:o.baseLabel,baseState:o.baseState,durationMs:o.durationMs,findingRunId:o.runId??null,findingSignature:o.signature??null,outcome:o.outcome,steps:o.steps.map(i=>({test:i.test,text:i.text}))}}})}async function Eo(e,n,t){let r=await c({config:e,document:Io,variables:{devSessionId:n}}).catch(i=>(p.warn({error:i},"fetchScopedTestRefs failed"),null)),o=new Set(r?.exploreScope??[]);return o.size===0?new Set:new Set(t.workflows.filter(i=>o.has(m(i.name))).flatMap(i=>i.tests.map(a=>g(a))))}var Io=w(`
163
+ query ExploreScope($devSessionId: String!) {
164
+ exploreScope(devSessionId: $devSessionId)
165
+ }
166
+ `);async function Po(e,n){return(await c({config:e,document:To,variables:{devSessionId:n}}).catch(r=>(p.warn({error:r},"reportExploreUnhealthy failed"),null)))?.reportExploreUnhealthy??!1}var Co=w(`
167
+ mutation RecordExplorationProgress(
168
+ $devSessionId: String!
169
+ $attempts: Int!
170
+ $findings: Int!
171
+ $trail: ExploreTrailInput
172
+ ) {
173
+ recordExplorationProgress(
174
+ devSessionId: $devSessionId
175
+ attempts: $attempts
176
+ findings: $findings
177
+ trail: $trail
178
+ )
179
+ }
180
+ `),To=w(`
181
+ mutation ReportExploreUnhealthy($devSessionId: String!) {
182
+ reportExploreUnhealthy(devSessionId: $devSessionId)
183
+ }
184
+ `),Ao=w(`
185
+ mutation CreateExploreRun(
186
+ $projectId: String!
187
+ $runId: String!
188
+ $devSessionId: String
189
+ $branchName: String
190
+ $commitSha: String
191
+ $lockfileHash: String
192
+ $spec: String
193
+ $reproJson: String
194
+ ) {
195
+ createExploreRun(
196
+ projectId: $projectId
197
+ runId: $runId
198
+ devSessionId: $devSessionId
199
+ branchName: $branchName
200
+ commitSha: $commitSha
201
+ lockfileHash: $lockfileHash
202
+ spec: $spec
203
+ reproJson: $reproJson
204
+ ) {
205
+ id
206
+ }
207
+ }
208
+ `),jo=w(`
209
+ mutation SubmitExploreFinding(
210
+ $projectId: String!
211
+ $signature: String!
212
+ $baseState: String!
213
+ $category: ExploreFindingCategory!
214
+ $reproRunId: String!
215
+ ) {
216
+ submitExploreFinding(
217
+ projectId: $projectId
218
+ signature: $signature
219
+ baseState: $baseState
220
+ category: $category
221
+ reproRunId: $reproRunId
222
+ ) {
223
+ id
224
+ }
225
+ }
226
+ `),il=w(`
227
+ mutation SetExploreFindingStatus(
228
+ $projectId: String!
229
+ $signature: String!
230
+ $status: ExploreFindingStatus!
231
+ ) {
232
+ setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
233
+ }
234
+ `),Mo=w(`
235
+ query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
236
+ exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
237
+ }
238
+ `);import Oo from"path";import{graphql as Do}from"gql.tada";import{graphql as Ee}from"gql.tada";function Ie(e){switch(e.kind){case"app-not-ready":return"appNotReady";case"client-mount-missing":return"appNotReady";case"engine-network":case"engine-http":return"backendUnreachable";case"engine-unreachable":return"engineUnreachable";case"engine-decode":case"state-identity":case"setup-missing-row":case"conflicting-sessions":case"driver-launch":case"action-failed":case"check-failed":case"aborted":return null}}async function Pe(e,n,t){await c({config:e,document:$o,variables:{reason:t,runId:n}}).catch(r=>{p.error(r,"failRun submission failed")})}async function Ce(e,n,t){await c({config:e,document:Fo,variables:{cause:t,runId:n}}).catch(r=>{p.error(r,"markRunUnready submission failed")})}var dl=Ee(`
239
+ mutation ReleaseRun($runId: String!) {
240
+ releaseRun(runId: $runId)
241
+ }
242
+ `),$o=Ee(`
243
+ mutation FailRun($runId: String!, $reason: String!) {
244
+ failRun(runId: $runId, reason: $reason)
245
+ }
246
+ `),Fo=Ee(`
247
+ mutation MarkRunUnready($runId: String!, $cause: RunUnreadyCause!) {
248
+ markRunUnready(runId: $runId, cause: $cause)
249
+ }
250
+ `);async function Uo({config:e,cwd:n,errorSettle:t,fixturesDir:r,headed:o,lockfile:i,runId:a,session:s,signal:l,test:u}){if(!await No(e,a))return{outcome:{kind:"dispatch-failed",reason:"already-claimed",runId:a},persisted:Promise.resolve()};let d=Oo.join(n,".ripplo","debug"),y=[];return(await s.runOnce({capture:!0,lockfile:i,onPhase:void 0,options:J({config:e,fixturesDir:r,headed:o}),params:void 0,runId:a,sequence:void 0,test:u,onEvent:h=>{y.push(h)}},l)).match(async h=>{let Te=xe(y),X=Te.flatMap(lt=>lt.findings),Z=Lo(X);if(Z!=null)return await Q({config:e,debugDir:d,events:y,recordingOptional:!0,runId:a,stepSources:void 0}),await rt({config:e,error:Z,errorSettle:t,runId:a}),{outcome:{error:Z,kind:"error",runId:a},persisted:Promise.resolve()};await ve(e,a,Te);let st=Q({config:e,debugDir:d,events:y,recordingOptional:!0,runId:a,stepSources:void 0}).then(()=>{});return{outcome:X.length>0?{findings:X,kind:"findings",runId:a}:{kind:"pass",runId:a},persisted:st}},async h=>(await rt({config:e,error:h,errorSettle:t,runId:a}),{outcome:{error:h,kind:"error",runId:a},persisted:Promise.resolve()}))}async function rt({config:e,error:n,errorSettle:t,runId:r}){if(t==="defer")return;let o=Ie(n);if(o!=null){await Ce(e,r,o);return}await Pe(e,r,j(n))}function Lo(e){let n=e.find(t=>t.kind==="driver-error"&&We(t.error));return n!=null&&n.kind==="driver-error"?n.error:void 0}async function No(e,n){return((await c({config:e,document:qo,variables:{runIds:[n]}})).startRunsBatch??[]).some(r=>r.id===n)}var qo=Do(`
251
+ mutation StartRunsBatch($runIds: [String!]!) {
252
+ startRunsBatch(runIds: $runIds) {
253
+ id
254
+ }
255
+ }
256
+ `);import{randomUUID as _o}from"crypto";async function Ho({assign:e,config:n,debugDir:t,devSessionId:r,fixturesDir:o,headed:i,lockfile:a,report:s,session:l,signal:u}){let f=He(a);if(e.stepRuns.length===0)return{kind:"error",reason:"empty-trail"};let d=Yo(f,e.stepRuns),y=await ze({baseState:{name:g(e.baseStateTest),test:e.baseStateTest},corpus:f,lockfile:a,options:J({config:n,fixturesDir:o,headed:i}),seenSignature:s?h=>z(n,h,e.lockfileHash):void 0,session:l,stepRuns:e.stepRuns,runIdFor:h=>`explore-${_o()}-${String(h)}`},u),k=s?await Qo({baseStateTest:e.baseStateTest,config:n,debugDir:t,devSessionId:r,lockfileHash:e.lockfileHash,outcome:y,reproJson:Ko(f,e),stepSources:Jo(d)}):!1;return Bo(y,d.length),Xo(y,k,Wo(d,e,y))}function Wo(e,n,t){if(t.kind==="error"||t.kind==="aborted")return;let r=t.timing.confirm;return{baseLabel:n.baseStateTest.intent,baseState:g(n.baseStateTest),durationMs:Math.round(G(t.timing.detect)+(r==null?0:G(r))),signature:t.kind==="finding"?t.signature:void 0,steps:Vo(e)}}function Vo(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(r=>({test:t,text:r}))})}function G(e){return e.engineMs+e.worldMs+e.browserMs+e.driveMs+e.teardownMs}function Bo(e,n){if(e.kind==="error"){p.info({detail:j(e.error),kind:e.kind,reason:e.error.kind,steps:n},"explore trail");return}if(e.kind==="aborted"){p.info({kind:e.kind,steps:n},"explore trail");return}let t=e.timing.detect,r=e.timing.confirm;p.info({browserMs:t.browserMs,confirmMs:r==null?void 0:G(r),detectMs:G(t),driveMs:t.driveMs,engineMs:t.engineMs,kind:e.kind,steps:n,teardownMs:t.teardownMs,worldMs:t.worldMs},"explore trail")}function Ko(e,n){let t=n.stepRuns.flatMap(o=>{let i=e[o.idx];return i==null?[]:[{index:i.index,params:o.params,test:i.test}]}),r={baseStateRef:g(n.baseStateTest),steps:t};return JSON.stringify(r)}function Jo(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(()=>t)})}async function Qo({baseStateTest:e,config:n,debugDir:t,devSessionId:r,lockfileHash:o,outcome:i,reproJson:a,stepSources:s}){return i.kind!=="finding"||i.captureEvents.length===0?!1:await z(n,i.signature,o)?(p.info({devSessionId:r,signature:i.signature},"explore finding already reported, skipping duplicate"),!1):(await be({baseState:i.baseState,branchName:void 0,category:zo(i.verifierLayer),commitSha:void 0,config:n,debugDir:t,devSessionId:r,events:i.captureEvents,lockfileHash:o,reproJson:a,runId:i.runId,signature:i.signature,spec:Go(e,i.captureEvents),stepSources:s}).catch(l=>{p.warn({error:l},"explore finding report failed")}),!0)}function zo(e){return e==="data-rule"?"dataRule":e==="fact"?"fact":e}function Go(e,n){let t=n.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:t,stub:!1,tests:[],world:e.world};return JSON.stringify(r)}function Yo(e,n){return n.flatMap(t=>{let r=e[t.idx];return r==null?[]:[{actions:[...r.nav,...r.steps].map(o=>Ke(o.action)),label:`${r.test}#${String(r.index)}`}]})}function Xo(e,n,t){return e.kind==="error"?{kind:e.kind,reason:`runtime:${e.error.kind}`}:e.kind==="finding"?{kind:e.kind,runId:n?e.runId:void 0,trail:t}:{kind:e.kind,trail:t}}import Zo from"path";import{randomUUID as ei}from"crypto";async function Ll({cwd:e,onReady:n,signal:t,step:r,target:o}){let i=q(e).match(d=>({config:d}),d=>({failure:d}));if("failure"in i)return{failure:i.failure,kind:"config-failed"};let a=i.config,s=await Le(e);if(s.result.isErr())return{error:s.result.error,kind:"compile-failed"};let l=s.result.value,u=await ni(l,o);return u.kind!=="ok"?u:(await Je({lockfile:l,onReady:n,options:ti(a),runId:`teleport-${ei()}`,sequence:u.sequence,stopAfterStep:r,test:u.test},t)).match(d=>({kind:"done",result:d}),d=>({error:d,kind:"run-failed"}))}async function ni(e,n){if(n.kind==="explore"){let r=await Ge(e,n.repro);return r.kind==="unplannable"?{kind:"unplannable"}:{kind:"ok",sequence:r.sequence,test:r.baseTest}}let t=E(e).find(r=>r.ref===n.ref);return t==null?{kind:"no-test",ref:n.ref}:{kind:"ok",sequence:Qe(e,t.test,void 0),test:t.test}}function ti(e){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:Zo.join(e.cwd,C),generate:M,headed:!0,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth}}import{graphql as ot}from"gql.tada";import{err as Y,ok as it}from"neverthrow";var ri=ot(`
257
+ query ExecutorSession($projectId: String!, $cwd: String!) {
258
+ project(id: $projectId) {
259
+ id
260
+ devSession(cwd: $cwd) {
261
+ id
262
+ executor
263
+ }
264
+ }
265
+ }
266
+ `),oi=ot(`
267
+ mutation SetDevSessionExecutor($devSessionId: String!, $executor: RunExecutor!) {
268
+ setDevSessionExecutor(devSessionId: $devSessionId, executor: $executor) {
269
+ __typename
270
+ ... on DevSession {
271
+ id
272
+ executor
273
+ }
274
+ ... on DevSessionEndedError {
275
+ message
276
+ }
277
+ }
278
+ }
279
+ `);async function Wl(e){return(await at(e)).map(t=>t.executor)}async function Vl(e,n){let t=await at(e);if(t.isErr())return Y(t.error);let o=(await c({config:e,document:oi,variables:{devSessionId:t.value.id,executor:n}})).setDevSessionExecutor;return o==null?Y({kind:"empty-response"}):o.__typename!=="DevSession"?Y({kind:"session-ended"}):it(o.executor)}async function at(e){let t=(await c({config:e,document:ri,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;return t==null?Y({kind:"no-session"}):it({executor:t.executor,id:t.id})}export{ci as a,hi as b,L as c,gt as d,bi as e,ie as f,un as g,fn as h,q as i,B as j,Tn as k,hs as l,Ss as m,ks as n,Yt as o,An as p,Is as q,Cs as r,Ts as s,As as t,js as u,Ms as v,$s as w,Fs as x,Os as y,Ds as z,Us as A,Ni as B,qi as C,le as D,_i as E,Rn as F,ta as G,x as H,ra as I,pe as J,Da as K,ds as L,gr as M,cs as N,Yr as O,Pe as P,Uo as Q,vo as R,bo as S,Eo as T,Po as U,Ho as V,Ll as W,Wl as X,Vl as Y};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{B as C,C as T,D as _e,E as O,F as He,H as Me,I as qe,J as I,L as Ue,M as Fe,N as Oe,Q as A,R as $e,S as Ne,T as Be,U as je,W as Qe,X as ze,Y as $,b as ee,f as ae,i as w,m as ce,o as ve,s as Re,t as Ce,u as Te,v as Ie,w as Ae,x as We,y as Le,z as De}from"./chunk-54ZXA3RS.js";import{e as le,f as se}from"./chunk-4J4T7534.js";import{a as re,d as R,e as ie,f as U,i as F,m as ke}from"./chunk-LISHXK5I.js";import{c as Z,d as g,e as a,f as q,g as P,h as E}from"./chunk-4K4VY5OR.js";import{$ as he,K as pe,M as fe,N as me,O as ye,P as Se,Q as ge,_ as we,aa as xe,ba as be,ca as Pe,e as oe,ea as Ee,h as ne,k as te,m as de,t as ue}from"./chunk-S3KN37I7.js";import"./chunk-SB7H6IAS.js";import Tn from"path";import{createClient as In}from"graphql-sse";import An,{AbortError as Wn}from"p-retry";import{graphql as Y}from"gql.tada";import{graphql as Qr}from"gql.tada";import{print as zr}from"graphql";async function Ge({config:e,cwd:r,headed:o,pool:n,runId:t,signal:i,testSlug:l,workClass:s,workflowSlug:d}){let c=await R(r);if(c.isErr())return await A(e,t,`lockfile:${c.error.kind}`),{kind:"dispatch-error",reason:{detail:`lockfile:${c.error.kind}`,type:"generic"}};let p=jr(c.value,{testSlug:l,workflowSlug:d});if(p==null)return await A(e,t,`no-test:${d}/${l}`),{kind:"dispatch-error",reason:{detail:`no-test:${d}/${l}`,type:"generic"}};let u=await C({headed:o,workClass:s,task:()=>n.execute({headed:o,runId:t,testRef:p},i)});return!u.serverNotified&&u.outcome.kind==="error"&&await A(e,t,u.outcome.detail),u.outcome}function jr(e,{testSlug:r,workflowSlug:o}){let t=e.workflows.find(i=>te(i.name)===o)?.tests.find(i=>i.slug===r);return t==null?void 0:de(t)}var Gr=6e4,Jr=Qr(`
2
+ import{B as C,C as T,D as _e,E as O,F as He,H as Me,I as qe,J as I,L as Ue,M as Fe,N as Oe,P as A,R as $e,S as Ne,T as Be,U as je,W as Qe,X as ze,Y as $,b as ee,f as ae,i as w,m as ce,o as ve,s as Re,t as Ce,u as Te,v as Ie,w as Ae,x as We,y as Le,z as De}from"./chunk-JZVB5QXR.js";import{e as le,f as se}from"./chunk-4J4T7534.js";import{a as re,d as R,e as ie,f as U,i as F,m as ke}from"./chunk-LISHXK5I.js";import{c as Z,d as g,e as a,f as q,g as P,h as E}from"./chunk-4K4VY5OR.js";import{$ as he,K as pe,M as fe,N as me,O as ye,P as Se,Q as ge,_ as we,aa as xe,ba as be,ca as Pe,e as oe,ea as Ee,h as ne,k as te,m as de,t as ue}from"./chunk-S3KN37I7.js";import"./chunk-SB7H6IAS.js";import Tn from"path";import{createClient as In}from"graphql-sse";import An,{AbortError as Wn}from"p-retry";import{graphql as Y}from"gql.tada";import{graphql as Qr}from"gql.tada";import{print as zr}from"graphql";async function Ge({config:e,cwd:r,headed:o,pool:n,runId:t,signal:i,testSlug:l,workClass:s,workflowSlug:d}){let c=await R(r);if(c.isErr())return await A(e,t,`lockfile:${c.error.kind}`),{kind:"dispatch-error",reason:{detail:`lockfile:${c.error.kind}`,type:"generic"}};let p=jr(c.value,{testSlug:l,workflowSlug:d});if(p==null)return await A(e,t,`no-test:${d}/${l}`),{kind:"dispatch-error",reason:{detail:`no-test:${d}/${l}`,type:"generic"}};let u=await C({headed:o,workClass:s,task:()=>n.execute({headed:o,runId:t,testRef:p},i)});return!u.serverNotified&&u.outcome.kind==="error"&&await A(e,t,u.outcome.detail),u.outcome}function jr(e,{testSlug:r,workflowSlug:o}){let t=e.workflows.find(i=>te(i.name)===o)?.tests.find(i=>i.slug===r);return t==null?void 0:de(t)}var Gr=6e4,Jr=Qr(`
3
3
  subscription RunRequestedWatch($devSessionId: String!) {
4
4
  runRequested(devSessionId: $devSessionId) {
5
5
  runId