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