ripplo 0.7.29 → 0.7.30

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,220 @@
1
+ #!/usr/bin/env node
2
+ import{K as Ve,N as ze,a as N,d as Oe,f as De,g as _e,h as qe,i as h,j as He,l as S,m as j,n as We,q as b,v as Be}from"./chunk-JW6AP56L.js";import{b as Le,d as m,e as g,g as Ue,h as x,i as Ne}from"./chunk-5VRJXHWH.js";import Ge from"fs";import H from"path";import{config as mt}from"dotenv";import{z as _}from"zod";import{err as gt,ok as Qe}from"neverthrow";import D from"fs";import ie from"path";import{err as re,ok as Je}from"neverthrow";import{z as O}from"zod";var ct=ie.join(".ripplo","project.json"),oe=[".env",".env.local"],ut=O.object({envFiles:O.array(O.string().min(1)).optional(),projectId:O.string().min(1)});function Ke(e){return ie.join(e,ct)}function ae(e){let n=Ke(e);return D.existsSync(n)?pt(n).andThen(t=>{let r=ut.safeParse(t);return r.success?Je({envFiles:r.data.envFiles??oe,projectId:r.data.projectId}):re({issues:r.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:n})}):re({kind:"project-file-missing",path:n})}function se(e){return ae(e).match(n=>n,()=>{})}function pt(e){try{return Je(JSON.parse(D.readFileSync(e,"utf8")))}catch(n){return re({issues:[n instanceof Error?n.message:String(n)],kind:"project-file-invalid",path:e})}}function Ti({cwd:e,envFiles:n,projectId:t}){let r=Ke(e);D.mkdirSync(ie.dirname(r),{recursive:!0});let o={projectId:t};n!=null&&!ft(n)&&(o.envFiles=[...n]),D.writeFileSync(r,JSON.stringify(o,null,2)+`
3
+ `)}function ft(e){return e.length!==oe.length?!1:e.every((n,t)=>n===oe[t])}function Di(e){let t=se(e)?.envFiles??[".env",".env.local"],r=H.join(e,".ripplo");t.forEach(o=>{let i=H.resolve(r,o);Ge.existsSync(i)&&mt({override:!0,path:i,quiet:!0})}),q=void 0}var yt=_.object({RIPPLO_APP_URL:_.url(),RIPPLO_ENGINE_URL:_.url(),RIPPLO_WEBHOOK_SECRET:_.string().min(1)}),q;function W(){return q!=null?Qe(q):Rt().map(e=>(q=e,e))}function ht(e){let t=se(e)?.envFiles??[],r=H.join(e,".ripplo");return t.map(o=>H.resolve(r,o)).filter(o=>!Ge.existsSync(o))}function Rt(){let e=yt.safeParse(process.env);if(!e.success)return gt({issues:e.error.issues.map(t=>`${t.path.join(".")}: ${t.message}`),kind:"env-invalid",missingEnvFiles:ht(process.cwd())});let n=e.data;return Qe({appUrl:n.RIPPLO_APP_URL,engineUrl:n.RIPPLO_ENGINE_URL,webhookSecret:n.RIPPLO_WEBHOOK_SECRET})}import{readFileSync as kt}from"fs";import{z as Xe}from"zod";var St=Xe.object({version:Xe.string()});function B(){let e=kt(new URL("../package.json",import.meta.url),"utf8");return St.parse(JSON.parse(e)).version}import pe from"fs";import V from"path";import{createJiti as At}from"jiti";import{err as $,ok as nn}from"neverthrow";import xt from"fs";import A from"path";import E from"typescript";function Ye(e){let n=A.join(e,"index.ts"),t=Et(e);xt.mkdirSync(A.dirname(t.tsBuildInfoFile??""),{recursive:!0});let r=E.createIncrementalCompilerHost(t),o=E.createIncrementalProgram({host:r,options:t,rootNames:[n]}),i=[...o.getSyntacticDiagnostics(),...o.getSemanticDiagnostics()];o.emit();let s=i.filter(d=>wt(d,e));if(s.length===0)return{diagnostics:[],ok:!0};let l={getCanonicalFileName:d=>d,getCurrentDirectory:()=>A.dirname(e),getNewLine:()=>`
4
+ `};return{diagnostics:E.formatDiagnosticsWithColorAndContext(s,l).split(`
5
+ `).filter(d=>d.length>0),ok:!1}}function wt(e,n){let t=e.file?.fileName;return t==null?!0:t.startsWith(n)}var bt=A.join(".local","tsbuildinfo");function Et(e){return{allowImportingTsExtensions:!0,allowJs:!1,esModuleInterop:!0,incremental:!0,module:E.ModuleKind.Preserve,moduleResolution:E.ModuleResolutionKind.Bundler,noEmit:!0,resolveJsonModule:!0,skipLibCheck:!0,strict:!1,target:E.ScriptTarget.ES2022,tsBuildInfoFile:A.join(e,bt)}}import{createHash as vt}from"crypto";import Ze from"fs/promises";import le from"path";import{err as v,ok as de,Result as It}from"neverthrow";var T=".ripplo/fixtures",ce=10*1024*1024,ue=50*1024*1024;async function en(e,n){let t=Pt(n);if(t.length===0)return de({});let r=le.join(e,T),o=await Promise.all(t.map(i=>Ct({fixturesRoot:r,name:i})));return It.combine(o).andThen(jt)}function Pt(e){let t=e.workflows.flatMap(r=>[...r.steps,...r.tests.flatMap(o=>o.steps)]).flatMap(r=>r.action.kind==="upload"?r.action.files:[]);return[...new Set(t)].toSorted((r,o)=>r.localeCompare(o))}async function Ct({fixturesRoot:e,name:n}){if(n.includes("..")||le.isAbsolute(n))return v({kind:"fixture-invalid-name",name:n});let t=le.join(e,n),r=await Ze.lstat(t).catch(()=>null);if(r==null)return v({kind:"fixture-missing",name:n,path:t});if(r.isSymbolicLink())return v({kind:"fixture-symlink",name:n});if(!r.isFile())return v({kind:"fixture-not-file",name:n});let o=await Ze.readFile(t);if(o.byteLength>ce)return v({kind:"fixture-too-large",name:n,size:o.byteLength});let i=vt("sha256").update(o).digest("hex");return de([n,{sha256:i,size:o.byteLength}])}function jt(e){let n=e.reduce((t,[,r])=>t+r.size,0);return n>ue?v({kind:"fixtures-total-too-large",total:n}):de(Object.fromEntries(e))}var I=".ripplo/ripplo.lock",F;async function tn(e){let{result:n}=await fe(e);return n}async function fe(e){let n=Ft(V.join(e,".ripplo"));if(F!=null&&F.fingerprint===n&&F.result.isOk())return{fingerprint:n,result:F.result};let t=await M(e);return F={fingerprint:n,result:t},{fingerprint:n,result:t}}async function M(e){let n=V.join(e,".ripplo"),t=V.join(n,"index.ts"),r=Ye(n);return r.ok?(await $t(t)).andThen(s=>Lt({entryPath:t,exported:s})).match(async s=>(await en(e,s)).map(p=>({...s,fixtures:p})).mapErr(p=>({error:p,kind:"fixture-failed"})),s=>Promise.resolve($(s))):$({diagnostics:r.diagnostics,kind:"typecheck-failed"})}var Tt=new Set([".local","debug","node_modules"]);function Ft(e){return rn(e).toSorted((n,t)=>n.localeCompare(t)).join("|")}function rn(e){return(pe.existsSync(e)?pe.readdirSync(e,{withFileTypes:!0}):[]).flatMap(t=>{if(Tt.has(t.name))return[];let r=V.join(e,t.name);if(t.isDirectory())return rn(r);let o=pe.statSync(r);return[`${r}:${String(o.mtimeMs)}:${String(o.size)}`]})}async function $t(e){try{let t=await At(import.meta.url,{fsCache:!1,moduleCache:!1,sourceMaps:!0}).import(e),r=t!=null&&typeof t=="object"&&"default"in t?Reflect.get(t,"default"):t;return nn(r)}catch(n){return $({kind:"load-threw",message:Mt(n)})}}function Mt(e){return e instanceof Error?e.message:String(e)}function Lt({entryPath:e,exported:n}){if(n==null||typeof n!="object"||!("lockfile"in n))return $({entryPath:e,kind:"not-ripplo"});let t=Oe.safeParse(Reflect.get(n,"lockfile"));return t.success?nn(t.data):$({issues:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`),kind:"invalid-lockfile"})}function P(e,n){return n==null?`Load \`/ripplo:${e}\` skill for instructions.`:`Load \`/ripplo:${e}\` skill for instructions on ${n}.`}function sa(e){return e.length===1?P(e[0]):`Before proceeding, load the ${e.map(t=>`\`/ripplo:${t}\``).join(" and ")} skills \u2014 every one, each carries rules the others don't.`}function J(e){return[`Compilation failed: ${Ut(e)}`,P("create","DSL authoring + lint rules")].join(`
6
+ `)}function pa(){return`${I} is up to date`}function fa(e){return[`${I} is ${e==="missing"?"missing":"out of date"} \u2014 run \`npx ripplo compile\` and commit the result`,P("setup")].join(`
7
+ `)}function ma(){return`Wrote ${I}`}function Ut(e){switch(e.kind){case"typecheck-failed":return["TypeScript errors in .ripplo/:",...on(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?):",...on(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 Nt(e.error)}}function on(e,n=8){return e.length<=n?e:[...e.slice(0,n),`\u2026 and ${String(e.length-n)} more`]}function Nt(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(ce)} per-file limit.`;case"fixtures-total-too-large":return`Fixtures total ${z(e.total)} \u2014 over the ${z(ue)} limit.`}}function z(e){return`${String(Math.round(e/(1024*1024)*10)/10)} MB`}var K=class extends Error{failure;constructor(n){super(n.kind),this.name="CliError",this.failure=n}};function Sa(e){return e instanceof K?me(e.failure):e instanceof Error?e.message:String(e)}function me(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(n=>` ${n}`),"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 Ot(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 Ot(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(`
17
+ `)}import{err as qt,ok as Ht}from"neverthrow";import{z as ge}from"zod";var Dt="https://ripplo.ai";function sn(){return dn().RIPPLO_SERVER_URL}function ln(){return dn().RIPPLO_PROJECT_ID}var _t=ge.object({RIPPLO_PROJECT_ID:ge.string().min(1).optional(),RIPPLO_SERVER_URL:ge.string().min(1).default(Dt)}),an;function dn(){return an??=_t.parse(process.env),an}import cn from"fs";import ye from"path";function un(e){let n=cn.realpathSync(e),t=n,r=ye.dirname(t);for(;r!==t;){if(cn.existsSync(ye.join(t,".git")))return t;t=r,r=ye.dirname(t)}return n}function pn(e){return ae(e).andThen(n=>W().andThen(t=>{let r=sn(),o=Ne(r);return o==null?qt({kind:"not-authenticated"}):Ht({appUrl:t.appUrl,cwd:un(e),engineUrl:t.engineUrl,projectId:ln()??n.projectId,ripploServerUrl:r,token:o,tunnelAuth:void 0,webhookSecret:t.webhookSecret})}))}import fn from"fs";import{checkSync as Wt,lockSync as Bt}from"proper-lockfile";var Vt="dev.pid",mn=15e3;function gn(e){return x(e,Vt)}function yn(e){try{return Wt(gn(e),{realpath:!1,stale:mn})}catch{return!1}}var he=class extends Error{pid;cwd;constructor({cwd:n,pid:t}){super("dev-lock-held"),this.name="DevLockHeldError",this.pid=t,this.cwd=n}};function Na({cwd:e,onCompromised:n}){Ue(e);let t=gn(e),r=zt({cwd:e,onCompromised:n,path:t});return fn.writeFileSync(t,String(process.pid)),()=>{try{r()}catch{}}}function zt({cwd:e,onCompromised:n,path:t}){try{return Bt(t,{realpath:!1,stale:mn,onCompromised:()=>{n()}})}catch(r){throw Jt(r)?new he({cwd:e,pid:Kt(t)}):r}}function Jt(e){if(!(e instanceof Error)||!("code"in e))return!1;let{code:n}=e;return n==="ELOCKED"}function Kt(e){try{let n=fn.readFileSync(e,"utf8").trim(),t=Number.parseInt(n,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}}import Gt from"p-queue";var Qt=4,Xt={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},G=new Gt({concurrency:Qt}),R={headedActive:0,interactiveActive:0,interactiveQueued:0},hn={current:null};function _a({headed:e,task:n,workClass:t}){let r=Xt[t];return t==="p3-explore"?G.add(n,{priority:r}):(R.interactiveQueued+=1,Q(),G.add(()=>Yt({headed:e,task:n}),{priority:r}))}function qa(e){!Number.isFinite(e)||e<1||(G.concurrency=Math.floor(e),Q())}function Re(){return{active:R.interactiveActive,headedActive:R.headedActive,poolSize:G.concurrency,queued:R.interactiveQueued}}function Ha(e){hn.current=e}async function Yt({headed:e,task:n}){R.interactiveQueued-=1,R.interactiveActive+=1,R.headedActive+=e?1:0,Q();try{return await n()}finally{R.interactiveActive-=1,R.headedActive-=e?1:0,Q()}}function Q(){hn.current?.()}import ke from"fs";import Se from"path";function Rn(e){try{let n=Zt(e);if(n==null)return;let t=Se.join(n,"HEAD"),r=ke.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 Zt(e){let n=Se.join(e,".git");if(ke.statSync(n).isDirectory())return n;let r=ke.readFileSync(n,"utf8").trim(),o="gitdir:";if(!r.startsWith(o))return;let i=r.slice(o.length).trim();if(i.length!==0)return Se.resolve(e,i)}import er from"crypto";import{readFile as kn}from"fs/promises";import Sn from"path";import{graphql as nr}from"gql.tada";import{err as tr,ok as rr}from"neverthrow";var or=nr(`
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 rs(e,n){let t=await M(e);if(t.isErr())return tr({error:t.error,kind:"compilation-failed"});let r=await xe({config:n,cwd:e,lockfile:t.value});return rr({devSessionId:r.devSessionId,lockfile:t.value})}async function xe(e){let n=_e(e.lockfile);return ar({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:n})}function ir(e){return er.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function ar({config:e,cwd:n,fixtures:t,payload:r}){let o=ir(r),i=Rn(n),s=await lr(n),l=await sr(n,t),p=await m({config:e,document:or,variables:{branch:i??null,cwd:n,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(p.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:p.syncDevSession.id,hash:o,hooksPaused:p.syncDevSession.hooksPaused}}async function sr(e,n){let t=Object.entries(n);return Promise.all(t.map(async([r,o])=>({contentBase64:(await kn(Sn.join(e,T,r))).toString("base64"),sha256:o.sha256})))}async function lr(e){try{return await kn(Sn.join(e,I),"utf8")}catch{return null}}import{randomUUID as qr}from"crypto";import{createId as Hr}from"@paralleldrive/cuid2";import{CancellationTokenSource as Wr,ResponseError as Br}from"vscode-jsonrpc/node";import{graphql as dr}from"gql.tada";var cr=dr(`
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 xn(e){try{let t=(await m({config:e.config,document:cr,variables:ur(e)})).createRun;return t==null?X({detail:"create-run-null",type:"generic"}):t.__typename==="MutationCreateRunSuccess"?null:t.__typename==="LimitExceededError"?X({code:t.code,type:"limit"}):X({detail:t.__typename,type:"generic"})}catch(n){return pr(n)}}function ur({executor:e,lockfileHash:n,runId:t,target:r}){return{clientVersion:B(),executor:e,id:t,lockfileHash:n,target:e==="cloud"?"tunnel":void 0,testId:r.testId,workflowId:r.workflowId}}function X(e){return{kind:"dispatch-error",reason:e}}function pr(e){return e instanceof Le?{detail:e.message,kind:"infra-error"}:X({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{createMessageConnection as fr,NotificationType as wn,RequestType as mr,RequestType0 as bn,SocketMessageReader as gr,SocketMessageWriter as yr}from"vscode-jsonrpc/node";import{z as a}from"zod";var hr="daemon.sock",Rr="daemon.log";function ps(e){return x(e,hr)}function fs(e){return x(e,Rr)}function En(e){return fr(new gr(e),new yr(e))}var vn=a.object({all:a.boolean(),headed:a.boolean(),tests:a.array(a.string())}),ms=a.object({jobId:a.string(),total:a.number()}),kr=a.enum(["on","off"]),Sr=a.object({attempts:a.number(),findings:a.number()}),gs=a.object({active:a.number(),explorer:kr,exploring:a.number(),progress:Sr,queued:a.number(),sseHealth:a.object({detail:a.string().optional(),ok:a.boolean()}).optional(),version:a.string().optional()}),xr=a.enum(["MAX_RUNS","OVERAGE_CAP","MAX_AGENTS","MAX_CONCURRENT_RUNS","MAX_PROJECTS"]),wr=a.discriminatedUnion("type",[a.object({code:xr,type:a.literal("limit")}),a.object({detail:a.string(),type:a.literal("generic")})]),we=a.discriminatedUnion("kind",[a.object({kind:a.literal("pass")}),a.object({findingLines:a.array(a.string()),kind:a.literal("findings")}),a.object({detail:a.string(),kind:a.literal("error")}),a.object({kind:a.literal("dispatch-error"),reason:wr}),a.object({detail:a.string(),kind:a.literal("dispatch-timeout")}),a.object({detail:a.string(),kind:a.literal("infra-error")})]),br=a.discriminatedUnion("kind",[a.object({kind:a.literal("test-started"),runId:a.string(),testName:a.string(),workflowName:a.string()}),a.object({kind:a.literal("test-outcome"),outcome:we,runId:a.string(),testName:a.string(),workflowName:a.string()})]),ys=a.object({event:br,jobId:a.string()}),hs=a.object({failed:a.number(),jobId:a.string(),notRun:a.number(),passed:a.number()}),Rs=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")})]),In=new mr("ripplo/enqueue"),Pn=new bn("ripplo/status"),Cn=new bn("ripplo/shutdownIfIdle"),jn=new wn("ripplo/jobEvent"),An=new wn("ripplo/jobDone");import{graphql as Er}from"gql.tada";async function Tn(e,n){let r=(await m({config:e,document:vr,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 vr=Er(`
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 Ir}from"vscode-jsonrpc/node";function be(e){return`${e.workflowSlug}/${e.testSlug}`}function Fn(e){let{headed:n,inflight:t,jobId:r,lockfileHashValue:o,onExpire:i,runId:s,selection:l,timeoutMs:p}=e,d=be(l),c=`${d}@${o}@${String(n)}`,u=t.get(c);if(u!=null)return u.jobIds.add(r),null;let y={cancellation:new Ir,claimed:!1,claimKey:d,headed:n,inflightKey:c,jobIds:new Set([r]),runId:s,testName:l.testName,timer:null,workflowName:l.workflowName};return y.timer=setTimeout(()=>{Y(t,y),i(y)},p),t.set(c,y),y}function Y(e,n){n.timer!=null&&(clearTimeout(n.timer),n.timer=null),e.delete(n.inflightKey)}function Ee(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 $n(e,n){[...e.values()].filter(t=>t.jobIds.has(n)).forEach(t=>{t.jobIds.delete(n),t.jobIds.size===0&&(Y(e,t),t.cancellation.cancel())})}import{err as ve,ok as Mn}from"neverthrow";function Un({all:e,ids:n,lockfile:t}){if(e&&n.length>0)return ve({kind:"conflicting-flags"});if(e)return Mn(t.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>S(s))));if(n.length===0)return ve({kind:"nothing-selected"});let r=n.map(i=>({id:i,refs:Cr(t,i)})),o=r.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?ve({kind:"unknown-ids",known:Pr(t),unknown:o}):Mn([...new Set(r.flatMap(i=>i.refs))])}function Nn(e,n){let t=new Map(j(e).map(r=>[r.ref,{testName:r.test.name,testSlug:r.test.slug,workflowName:r.workflow.name,workflowSlug:h(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 Pr(e){return e.workflows.map(n=>h(n.name))}function Cr(e,n){let t=e.workflows.find(r=>r.name===n||h(r.name)===h(n));return t!=null?t.tests.map(r=>S(r)):j(e).filter(r=>r.ref===n||Ln(r.ref)===Ln(n)).map(r=>r.ref)}function Ln(e){let n=e.lastIndexOf("/");return n===-1?h(e):`${h(e.slice(0,n))}/${h(e.slice(n+1))}`}import{err as Ie,ok as Dn}from"neverthrow";import{graphql as _n}from"gql.tada";import{execFileSync as jr}from"child_process";var Ar=256*1024*1024;function Z(e,n){return jr("git",[...e],{cwd:n,encoding:"utf8",maxBuffer:Ar,stdio:["ignore","pipe","pipe"]})}async function qn({config:e,cwd:n,lockfile:t}){await Fr({config:e,cwd:n,lockfile:t});let r=await Mr(e);if(r.isErr())return Ie(r.error);let o=new Map(t.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(p=>S(p))});return i.length===0?Ie({kind:"scope-empty"}):Dn(i)}var Tr=_n(`
90
+ mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
91
+ addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
92
+ __typename
93
+ }
94
+ }
95
+ `);async function Fr({config:e,cwd:n,lockfile:t}){let r=new Set(Lr(n)),o=t.workflows.filter(i=>i.sourcePath!=null&&r.has(i.sourcePath)).map(i=>h(i.name));o.length!==0&&await m({config:e,document:Tr,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{g.warn({err:i},"auto-scope of dirty tests failed")})}var $r=_n(`
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 Mr(e){try{let t=(await m({config:e,document:$r,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return Dn(t.flatMap(r=>r.workflow==null?[]:[r.workflow.slug]))}catch(n){return Ie({detail:n instanceof Error?n.message:String(n),kind:"scope-fetch-failed"})}}var On=".ripplo/workflows/";function Lr(e){try{return Z(["status","--porcelain","--",".ripplo/workflows"],e).split(`
112
+ `).map(n=>n.slice(3).trim()).filter(n=>n.startsWith(On)&&n.endsWith(".ts")).map(n=>n.slice(On.length)).filter(n=>n!=="index.ts"&&!n.endsWith("/index.ts"))}catch{return[]}}import{graphql as Ur}from"gql.tada";var Nr=2e3,Or=Ur(`
113
+ query DaemonCloudRunStatus($runId: String!) {
114
+ run(id: $runId) {
115
+ status
116
+ failureReason
117
+ }
118
+ }
119
+ `);function Wn({config:e,onComplete:n,onStarted:t,runId:r,signal:o}){let i=!1,s,l=!1,p=async()=>{if(i||o.aborted)return;let d=await Dr(e,r).catch(()=>"unknown");if(!l&&(d==="running"||Hn(d))&&(l=!0,t()),Hn(d)){i=!0,n(_r(d));return}s=setTimeout(()=>{p()},Nr)};return p(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function Dr(e,n){let r=(await m({config:e,document:Or,variables:{runId:n}})).run?.status;return r??"unknown"}function Hn(e){return e==="passed"||e==="failed"||e==="warning"||e==="cancelled"||e==="unready"}function _r(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 Vr=12e4,zr=-32099;function Jr(e){let n=new AbortController;return e.isCancellationRequested?(n.abort(),n.signal):(e.onCancellationRequested(()=>{n.abort()}),n.signal)}function rl(e){let n={...e,inflight:new Map,jobs:new Map};return{claim:t=>Yr(n,t),handleConnection:t=>{Kr(n,t)},idle:()=>zn(n)}}function Kr(e,n){let t=En(n);t.onRequest(In,(r,o)=>Gr({connection:t,ctx:e,params:r,token:o})),t.onRequest(Pn,()=>{let r=Re();return{active:r.active,queued:r.queued,sseHealth:e.sseHealth(),version:B(),...e.explorationStatus()}}),t.onRequest(Cn,()=>{let r=zn(e);return r&&e.onShutdownRequest(),r}),t.onClose(()=>{Qr(e,t)}),t.onError(r=>{g.warn({err:r},"ipc connection error")}),n.on("error",r=>{g.warn({err:r},"ipc socket error")}),t.listen()}function zn(e){let n=Re();return e.jobs.size===0&&n.active===0&&n.queued===0}async function Gr({connection:e,ctx:n,params:t,token:r}){let o=vn.safeParse(t);if(!o.success)throw Bn({code:"bad-message"});await n.ready;let i=await eo({config:n.config,cwd:n.cwd,message:o.data});if(i.kind==="error")throw Bn(i.error);let s=qr(),l=new Wr;return r.onCancellationRequested(()=>{Jn(n,s)}),n.jobs.set(s,{cancellation:l,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),lo({ctx:n,headed:o.data.headed,jobId:s,lockfileHashValue:i.lockfileHashValue,selections:i.selections,targetsByClaimKey:i.targetsByClaimKey,token:l.token}).catch(p=>{g.error({err:p},"ipc dispatch failed")}),{jobId:s,total:i.selections.length}}function Bn(e){return new Br(zr,e.code,e)}function Jn(e,n){let t=e.jobs.get(n);t!=null&&(t.cancellation.cancel(),e.jobs.delete(n),$n(e.inflight,n))}function Qr(e,n){[...e.jobs.entries()].filter(([,t])=>t.connection===n).forEach(([t])=>{Jn(e,t)})}function Kn(e,n,t){let r=e.jobs.get(n);r!=null&&(Vn(()=>r.connection.sendNotification(jn,{event:t,jobId:n})),t.kind==="test-outcome"&&(Xr(r,t.outcome.kind),r.passed+r.failed+r.notRun>=r.total&&(Vn(()=>r.connection.sendNotification(An,{failed:r.failed,jobId:n,notRun:r.notRun,passed:r.passed})),e.jobs.delete(n))))}function Vn(e){e().catch(n=>{g.warn({err:n},"ipc notification failed")})}function Xr(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 C(e,n,t){n.jobIds.forEach(r=>{Kn(e,r,t)})}function Yr(e,n){let t=Ee(e.inflight,n);return t==null?null:{headed:t.headed,token:t.cancellation.token,finished:(r,o)=>{e.inflight.delete(t.inflightKey),C(e,t,{kind:"test-outcome",outcome:o,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},started:()=>{C(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}}}function Zr(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 eo({config:e,cwd:n,message:t}){return(await tn(n)).match(o=>no({config:e,cwd:n,lockfile:o,message:t}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...Zr(o)]},kind:"error"}))}async function no({config:e,cwd:n,lockfile:t,message:r}){let o=await ro(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=await oo({config:e,cwd:n,lockfile:t});return i!=null?{error:{code:"sync-failed",detail:i},kind:"error"}:(await io({config:e,cwd:n,lockfile:t,message:r})).match(async l=>({kind:"ready",lockfileHashValue:De(t),selections:Nn(t,l),targetsByClaimKey:await Tn(e,n)}),l=>Promise.resolve({error:l,kind:"error"}))}var to=2e3;async function ro(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(to)}),null}catch(n){return n instanceof Error?n.message:String(n)}}async function oo(e){try{return await xe(e),null}catch(n){return n instanceof Error?n.message:String(n)}}async function io({config:e,cwd:n,lockfile:t,message:r}){return!r.all&&r.tests.length===0?(await qn({config:e,cwd:n,lockfile:t})).mapErr(ao):Un({all:r.all,ids:r.tests,lockfile:t}).mapErr(so)}function ao(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function so(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 lo(e){await e.selections.reduce((n,t)=>n.then(()=>co(e,t)),Promise.resolve())}async function co(e,n){let{ctx:t,headed:r,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:l}=e;if(l.isCancellationRequested)return;let p=be(n),d=s.get(p);if(d==null){Kn(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 c=Fn({headed:r,inflight:t.inflight,jobId:o,lockfileHashValue:i,runId:Hr(),selection:n,timeoutMs:Vr,onExpire:y=>{C(t,y,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:y.testName,workflowName:y.workflowName})}});if(c==null)return;let u=await uo(t,d,c.runId,i);if(u!=null){Y(t.inflight,c),C(t,c,{kind:"test-outcome",outcome:u,runId:"",testName:n.testName,workflowName:n.workflowName});return}t.executor==="cloud"&&po(t,c)}function uo(e,n,t,r){return xn({config:e.config,executor:e.executor,lockfileHash:r,runId:t,target:n})}function po(e,n){let t=Ee(e.inflight,n.runId);t!=null&&Wn({config:e.config,runId:t.runId,signal:Jr(t.cancellation.token),onComplete:r=>{e.inflight.delete(t.inflightKey),C(e,t,{kind:"test-outcome",outcome:r,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},onStarted:()=>{C(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}})}import fo from"fs";import mo from"path";async function ul(e){let n=mo.join(e,".ripplo","index.ts");if(!fo.existsSync(n))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let t=await M(e);return t.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:J(t.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:me(r),path:""}],valid:!1,warnings:[]}))}async function pl(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 fl({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 Ro from"fs";import go from"fs";import Pe from"path";var yo=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function Gn(e){let n=ho(e);return n==null?!1:yo.some(t=>go.existsSync(Pe.join(n,t)))}function ho(e){try{let n=Z(["rev-parse","--git-dir"],e).trim();return n.length===0?null:Pe.isAbsolute(n)?n:Pe.resolve(e,n)}catch{return null}}function ko(e){return x(e,"hooks-paused")}function bl(e){return Ro.existsSync(ko(e))||Gn(e)?!1:yn(e)}import{createMessageConnection as Qn,IPCMessageReader as Xn,IPCMessageWriter as Yn,NotificationType as So,NotificationType0 as Zn,RequestType as Ce}from"vscode-jsonrpc/node";import{z as f}from"zod";var Cl=f.object({headed:f.boolean(),lockfileFingerprint:f.string(),runId:f.string().min(1),testRef:f.string().min(1)}),jl=f.object({fingerprint:f.string()}),Al=f.object({lockfileJson:f.string().optional(),unavailable:f.string().optional()}),xo=f.enum(["unspecified","internal","server","client","producer","consumer"]),wo=f.enum(["unset","ok","error"]),bo=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:xo,status:f.object({code:wo,message:f.union([f.string(),f.undefined()])}),timeNanos:f.string(),traceId:f.string()}),Tl=f.object({runId:f.string().min(1),span:bo}),Fl=f.object({outcome:we,serverNotified:f.boolean()}),$l=new Zn("worker/ready"),Ml=new Ce("worker/run"),Ll=new Ce("worker/lockfile"),Ul=new Ce("worker/exploreTrail"),Nl=new So("worker/span"),Ol=new Zn("worker/shutdown");function Dl(e){let n=Qn(new Xn(e),new Yn(e));return n.listen(),n}function _l(){let e=Qn(new Xn(process),new Yn(process));return e.listen(),e}import Eo from"path";import{randomUUID as vo}from"crypto";async function Kl({cwd:e,ref:n,signal:t,step:r}){let o=pn(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 fe(e);if(s.result.isErr())return{error:s.result.error,kind:"compile-failed"};let l=s.result.value,p=j(l).find(c=>c.ref===n);return p==null?{kind:"no-test",ref:n}:(await Ve({lockfile:l,options:{baseUrl:i.appUrl,engineUrl:i.engineUrl,fixturesDir:Eo.join(i.cwd,T),generate:b,headed:!0,secret:i.webhookSecret,tunnelAuth:i.tunnelAuth},params:void 0,runId:`teleport-${vo()}`,stopAfterStep:r,test:p.test},t)).match(c=>({kind:"done",result:c}),c=>({error:c,kind:"run-failed"}))}import{gzip as $o}from"zlib";import{promisify as Mo}from"util";import{existsSync as Ae,readFileSync as Te}from"fs";import ee from"path";import{graphql as w}from"gql.tada";function et(e){return[e.kind,e.target,e.value].filter(n=>n.length>0).join(" ")}var Io={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},Po={"data-rule":"dataRule","page-rule":"pageRule",step:"step"},Co={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 nt(e){return e.kind==="consistency"?{consistency:{mismatch:To(e.mismatch),pending:e.pending}}:e.kind==="pending-check"?{pendingCheck:{budget:e.budget,source:Po[e.source.kind],...jo(e.source)}}:e.kind==="unrunnable"?{unrunnable:{reason:Io[e.reason]}}:e.kind==="driver-error"?{driverError:{errorKind:Co[e.error.kind],message:Fo(e.error)}}:{impossibleAction:{subject:Ao(e.step.action)}}}function jo(e){return"check"in e?tt(e.check,!1):{checkKind:void 0,expected:void 0,negated:void 0,subject:void 0}}function tt(e,n){return e.kind==="not"?tt(e.inner,!n):e.kind==="browser"?{checkKind:"browser",expected:e.value,negated:n,subject:e.name}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:n,subject:N(e.locator)}:{checkKind:e.kind,expected:void 0,negated:n,subject:N(e.locator)}}function Ao(e){let n=e.locator==null?e.url??"":N(e.locator);return`${e.kind} ${n}`.trim()}function To(e){return e.kind==="wrong-value"?{wrongValue:{entity:e.entity,field:e.field,key:e.key,snapshot:L(e.snapshot),sut:L(e.sut)}}:e.kind==="expected-change"?{expectedChange:{entity:e.entity,field:e.field,key:e.key,value:L(e.value)}}:e.kind==="singleton-mismatch"?{singletonMismatch:{singleton:e.singleton,snapshot:L(e.snapshot),sut:L(e.sut)}}:e.kind==="unexpected-row"?{unexpectedRow:{entity:e.entity,key:e.key}}:{missingRow:{entity:e.entity,key:e.key}}}function L(e){return e==null?null:String(e)}function Fo(e){return"message"in e?e.message:"detail"in e?e.detail:null}async function Lo({config:e,cwd:n,fixturesDir:t,headed:r,lockfile:o,runId:i,session:s,signal:l,test:p}){if(!await ai(e,i))return{kind:"dispatch-failed",reason:"already-claimed",runId:i};let c=ee.join(n,".ripplo","debug"),u=[];return(await s.runOnce({capture:!0,lockfile:o,onPhase:void 0,options:{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:t,generate:b,headed:r,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth},params:void 0,runId:i,sequence:void 0,test:p,onEvent:k=>{u.push(k)}},l)).match(async k=>{let te=ot(u).flatMap(dt=>dt.findings),Me=Uo(te);return Me!=null?(await rt({config:e,debugDir:c,events:u,recordingOptional:!0,runId:i,stepSources:void 0}),{error:Me,kind:"error",runId:i}):(await ne({config:e,debugDir:c,events:u,recordingOptional:!1,runId:i,stepSources:void 0}),te.length>0?{findings:te,kind:"findings",runId:i}:{kind:"pass",runId:i})},k=>Promise.resolve({error:k,kind:"error",runId:i}))}function Uo(e){let n=e.find(t=>t.kind==="driver-error"&&He(t.error));return n!=null&&n.kind==="driver-error"?n.error:void 0}async function ne(e){let n=await rt(e);await ii(e.config,e.runId,n),await Oo(e.config,e.debugDir,e.runId)}async function rt({config:e,debugDir:n,events:t,recordingOptional:r,runId:o,stepSources:i}){let s=ot(t),l=_o(n,o);if(l==null&&!r)throw new Error("recording-missing");return await Ko({aliases:[...Wo(t),...Bo(s)],config:e,generated:Vo(t),generatedSingletons:zo(t),origin:l==null?Do(s):l.origin,records:s,rrwebEvents:l==null?[]:l.events,runId:o,stepSources:i}),l!=null&&await oi(e,o,l),s}var No=w(`
120
+ mutation ClipUploadUrl($runId: ID!) {
121
+ clipUploadUrl(runId: $runId)
122
+ }
123
+ `);async function Oo(e,n,t){let r=ee.join(n,t,"clip.gif");if(Ae(r))try{let o=await m({config:e,document:No,variables:{runId:t}});if(o.clipUploadUrl==null)return;let i=await fetch(o.clipUploadUrl,{body:new Uint8Array(Te(r)),headers:{"Content-Type":"image/gif"},method:"PUT"});i.ok||g.warn({runId:t,status:i.status},"Clip upload failed")}catch(o){g.warn({err:o,runId:t},"Clip upload skipped")}}function Do(e){return e.reduce((n,t)=>Math.min(n,t.startMs),e[0]?.startMs??0)}function ot(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}]:[])}function _o(e,n){let t=ee.join(e,n,"behavior.jsonl");if(!Ae(t))return null;let r=Te(t,"utf8").split(`
124
+ `).filter(i=>i.length>0).map(i=>qo(i)).flatMap(i=>Ho(i)?[i.event]:[]),o=r[0];return o==null?null:{events:r,origin:o.timestamp}}function qo(e){return JSON.parse(e)}function Ho(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function Wo(e){return e.flatMap(n=>n.kind==="world"?n.aliases:[])}function Bo(e){return e.flatMap(n=>{let t=Jo(n.source);return t.flatMap(r=>{let i=t.filter(l=>l.entity===r.entity).indexOf(r),s=n.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 Vo(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generated.map(t=>it(t)):[]))}function it({entity:e,field:n,key:t}){return`${e}\0${t}\0${n}`}function zo(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generatedSingletons:[]))}function Jo(e){return e==null?[]:e.expect.flatMap(n=>je(n))}function je(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(n=>je(n)):e.kind==="when"?e.branches.flatMap(n=>n.consequence.flatMap(t=>je(t))):[]}async function Ko({aliases:e,config:n,generated:t,generatedSingletons:r,origin:o,records:i,rrwebEvents:s,runId:l,stepSources:p}){let d=i.map((c,u)=>Yo({aliases:e,generated:t,generatedSingletons:r,origin:o,record:c,rrwebEvents:s,sourceTest:p?.[u]??null}));await m({config:n,document:li,variables:{items:[{runId:l,steps:d}]}})}var Go=3,Qo=0;function Xo({endMs:e,rrwebEvents:n,startMs:t}){let r=n.find(o=>o.type===Go&&o.data?.source===Qo&&o.timestamp>=t&&o.timestamp<=e);return r==null?t:r.timestamp}function Yo({aliases:e,generated:n,generatedSingletons:t,origin:r,record:o,rrwebEvents:i,sourceTest:s}){let l=qe(o.source,o.index),p=Xo({endMs:o.endMs,rrwebEvents:i,startMs:o.startMs}),d=o.annotations.map(u=>({kind:u.kind,label:u.label,outcome:u.outcome,recordingStartMs:Math.max(0,(u.kind==="action"?p:u.atMs)-r),rrwebIds:[...u.rrwebIds],url:u.url})),c=o.annotations.find(u=>u.kind==="action")?.rrwebIds??[];return{annotations:d,detail:null,duration:Math.max(0,o.endMs-o.startMs),findings:o.findings.map(u=>nt(u)),nodeType:l.kind,recordingEndMs:Math.max(0,o.endMs-r),recordingStartMs:Math.max(0,p-r),rrwebIds:[...c],snapshotTimestamp:Math.max(0,o.endMs-r),sourceTest:s,stateRows:o.state.rows.map(u=>Zo({aliases:e,generated:n,row:u})),stateSingletons:o.state.singletons.map(u=>({changed:u.changed,generated:t.has(u.name),name:u.name,value:u.value==null?null:String(u.value)})),status:o.findings.length>0?"failed":"passed",stepIndex:o.index,title:et(l),url:o.url}}function Zo({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(it({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 ei=Mo($o);async function at(e,n){await m({config:e,document:ui,variables:{runIds:[n]}})}var ni="application/x-ndjson";async function ti({config:e,debugDir:n,runId:t}){let r=ee.join(n,t,"behavior.jsonl");if(Ae(r))try{let o=await m({config:e,document:ri,variables:{runId:t}}),i=await fetch(o.debugArtifactUploadUrl,{body:Te(r),headers:{"content-type":ni},method:"PUT"});if(!i.ok){g.warn({runId:t,status:i.status},"behavior upload PUT failed");return}await at(e,t)}catch(o){g.warn({error:o,runId:t},"behavior upload failed")}}var ri=w(`
125
+ mutation DebugArtifactUploadUrl($runId: String!) {
126
+ debugArtifactUploadUrl(runId: $runId)
127
+ }
128
+ `);async function oi(e,n,t){let r=t.events.map(s=>JSON.stringify(s)).join(`
129
+ `),o=await ei(Buffer.from(r,"utf8")),i=t.events.at(-1);await m({config:e,document:di,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}}})}async function ii(e,n,t){let r=t.filter(s=>s.findings.length>0).length,o=t.length-r,i=t.reduce((s,l)=>s+Math.max(0,l.endMs-l.startMs),0);await m({config:e,document:ci,variables:{items:[{duration:i,failCount:r,passCount:o,runId:n,status:r>0?"failed":"passed",summary:null,warnCount:0}]}})}async function ai(e,n){return((await m({config:e,document:si,variables:{runIds:[n]}})).startRunsBatch??[]).some(r=>r.id===n)}var si=w(`
130
+ mutation StartRunsBatch($runIds: [String!]!) {
131
+ startRunsBatch(runIds: $runIds) {
132
+ id
133
+ }
134
+ }
135
+ `),li=w(`
136
+ mutation SubmitRunStepsBatch($items: [SubmitRunStepsItem!]!) {
137
+ submitRunStepsBatch(items: $items)
138
+ }
139
+ `),di=w(`
140
+ mutation SubmitRunRecordingChunk($input: SubmitRunRecordingChunkInput!) {
141
+ submitRunRecordingChunk(input: $input)
142
+ }
143
+ `),ci=w(`
144
+ mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
145
+ completeRunsBatch(items: $items) {
146
+ id
147
+ status
148
+ }
149
+ }
150
+ `),ui=w(`
151
+ mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
152
+ markRunArtifactsUploadedBatch(runIds: $runIds)
153
+ }
154
+ `);import{graphql as st}from"gql.tada";async function pi(e,n,t){await m({config:e,document:fi,variables:{reason:t,runId:n}}).catch(r=>{g.error(r,"failRun submission failed")})}var fi=st(`
155
+ mutation FailRun($runId: String!, $reason: String!) {
156
+ failRun(runId: $runId, reason: $reason)
157
+ }
158
+ `),pd=st(`
159
+ mutation MarkRunUnready($runId: String!, $cause: RunUnreadyCause!) {
160
+ markRunUnready(runId: $runId, cause: $cause)
161
+ }
162
+ `);import{randomUUID as hi}from"crypto";import{graphql as U}from"gql.tada";async function Fe({baseState:e,branchName:n,category:t,commitSha:r,config:o,debugDir:i,devSessionId:s,events:l,lockfileHash:p,reproJson:d,runId:c,signature:u,spec:y,stepSources:k}){await m({config:o,document:mi,variables:{branchName:n??null,commitSha:r??null,devSessionId:s??null,lockfileHash:p??null,projectId:o.projectId,reproJson:d,runId:c,spec:y??null}}),await ne({config:o,debugDir:i,events:l,recordingOptional:!0,runId:c,stepSources:k}),await m({config:o,document:gi,variables:{baseState:e,category:t,projectId:o.projectId,reproRunId:c,signature:u}})}async function $e(e,n,t){return(await m({config:e,document:yi,variables:{lockfileHash:t,projectId:e.projectId,signature:n}})).exploreFindingExists}var hd=U(`
163
+ mutation RecordExplorationProgress($devSessionId: String!, $attempts: Int!, $findings: Int!) {
164
+ recordExplorationProgress(devSessionId: $devSessionId, attempts: $attempts, findings: $findings)
165
+ }
166
+ `),mi=U(`
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
+ `),gi=U(`
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
+ `),Rd=U(`
209
+ mutation SetExploreFindingStatus(
210
+ $projectId: String!
211
+ $signature: String!
212
+ $status: ExploreFindingStatus!
213
+ ) {
214
+ setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
215
+ }
216
+ `),yi=U(`
217
+ query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
218
+ exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
219
+ }
220
+ `);async function Ri({assign:e,config:n,debugDir:t,devSessionId:r,fixturesDir:o,headed:i,lockfile:s,report:l,session:p,signal:d}){let c=We(s);if(e.stepRuns.length===0)return{kind:"error",reason:"empty-trail"};let u=vi(c,e.stepRuns),y=await ze({baseState:{name:S(e.baseStateTest),test:e.baseStateTest},corpus:c,lockfile:s,options:{baseUrl:n.appUrl,engineUrl:n.engineUrl,fixturesDir:o,generate:b,headed:i,secret:n.webhookSecret,tunnelAuth:n.tunnelAuth},session:p,stepRuns:e.stepRuns,runIdFor:k=>`explore-${hi()}-${String(k)}`},d);return l&&await wi({baseStateTest:e.baseStateTest,config:n,debugDir:t,devSessionId:r,lockfileHash:e.lockfileHash,outcome:y,reproJson:Si(c,e),stepSources:xi(u)}),ki(y,u.length),Ii(y)}function lt(e){return e.engineMs+e.worldMs+e.browserMs+e.driveMs+e.teardownMs}function ki(e,n){if(e.kind==="error"||e.kind==="aborted"){g.info({kind:e.kind,steps:n},"explore trail");return}let t=e.timing.detect,r=e.timing.confirm;g.info({browserMs:t.browserMs,confirmMs:r==null?void 0:lt(r),detectMs:lt(t),driveMs:t.driveMs,engineMs:t.engineMs,kind:e.kind,steps:n,teardownMs:t.teardownMs,worldMs:t.worldMs},"explore trail")}function Si(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:S(n.baseStateTest),steps:t};return JSON.stringify(r)}function xi(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(()=>t)})}async function wi({baseStateTest:e,config:n,debugDir:t,devSessionId:r,lockfileHash:o,outcome:i,reproJson:s,stepSources:l}){if(!(i.kind!=="finding"||i.captureEvents.length===0)){if(await $e(n,i.signature,o)){g.info({devSessionId:r,signature:i.signature},"explore finding already reported, skipping duplicate");return}await Fe({baseState:i.baseState,branchName:void 0,category:bi(i.verifierLayer),commitSha:void 0,config:n,debugDir:t,devSessionId:r,events:i.captureEvents,lockfileHash:o,reproJson:s,runId:i.runId,signature:i.signature,spec:Ei(e,i.captureEvents),stepSources:l}).catch(p=>{g.warn({error:p},"explore finding report failed")})}}function bi(e){return e==="data-rule"?"dataRule":e==="page-rule"?"pageRule":e}function Ei(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 vi(e,n){return n.flatMap(t=>{let r=e[t.idx];return r==null?[]:[{actions:[...r.nav,...r.steps].map(o=>Be(o.action)),label:`${r.test}#${String(r.index)}`}]})}function Ii(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{Ti as a,Di as b,W as c,ht as d,B as e,T as f,I as g,fe as h,M as i,P as j,sa as k,J as l,pa as m,fa as n,ma as o,Sa as p,me as q,sn as r,dn as s,pn as t,yn as u,he as v,Na as w,Z as x,Gn as y,ul as z,pl as A,fl as B,ko as C,bl as D,ps as E,fs as F,En as G,ms as H,gs as I,ys as J,hs as K,Rs as L,In as M,Pn as N,Cn as O,jn as P,An as Q,Cl as R,jl as S,Tl as T,Fl as U,$l as V,Ml as W,Ll as X,Ul as Y,Nl as Z,Ol as _,Dl as $,_l as aa,_a as ba,qa as ca,Re as da,Ha as ea,Rn as fa,rs as ga,xe as ha,Jr as ia,rl as ja,Lo as ka,ti as la,pi as ma,Ri as na,Kl as oa};
@@ -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-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};
2
+ import{P as a,Q as b,R as c,S as d,T as e,U as f,V as g,W as h,X as i,Y as j,Z as k}from"./chunk-JW6AP56L.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};
@@ -1,5 +1,5 @@
1
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(`
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,ma as C,oa as We,q as Z,t as P,v as ee,w as re}from"./chunk-RJKZX4CJ.js";import{A as ie,B as ae,C as se,L as le,Q as ue,R as pe,S as fe,T as me,U as ye,V as ge,b as V,e as K,f as X,i as Y,l as ne,x as te}from"./chunk-JW6AP56L.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
3
  subscription RunRequestedWatch($devSessionId: String!) {
4
4
  runRequested(devSessionId: $devSessionId) {
5
5
  runId
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-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(`
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,la as Ke,m as Er,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-RJKZX4CJ.js";import{D as Jr,E as zr,F as Kr,G as Qr,H as Xr,I as Yr,J as Zr,M as ke,O as et,W as ut,Y as pt,Z as mt,b as J,c as Cr,e as U,i as _,k as _r,m as Or,n as Nr,o as Ur,p as Fr,q as Mr,r as x,s as Hr,t as Wr,u as qr,w as Br,y as Vr,z as Gr}from"./chunk-JW6AP56L.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-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)}
355
+ `)}async function go({executor:e}){let{runDaemon:r}=await import("./daemon-PLTX45O2.js"),{TunnelProvisionFailedError:t}=await import("./daemon-tunnel-DYA5LIEG.js"),{renderTunnelProvisionFailed:n}=await import("./daemon-B5DVEIXJ.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.29",
3
+ "version": "0.7.30",
4
4
  "description": "CLI for Ripplo — AI-powered end-to-end testing",
5
5
  "type": "module",
6
6
  "homepage": "https://ripplo.ai",
@@ -59,13 +59,13 @@
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",
62
63
  "@ripplo/eslint-config": "0.0.0",
63
- "@ripplo/runtime": "^0.0.0",
64
- "@ripplo/rrweb-bundle": "0.0.0",
65
- "@ripplo/spec": "^0.0.0",
64
+ "@ripplo/graphql": "^0.0.0",
66
65
  "@ripplo/run-report": "0.0.0",
67
- "@ripplo/core": "^0.0.0",
68
- "@ripplo/graphql": "^0.0.0"
66
+ "@ripplo/spec": "^0.0.0",
67
+ "@ripplo/runtime": "^0.0.0",
68
+ "@ripplo/rrweb-bundle": "0.0.0"
69
69
  },
70
70
  "scripts": {
71
71
  "dev": "tsx watch src/index.ts",