ripplo 0.7.42 → 0.7.43
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/assets/rrweb.js +1 -1
- package/dist/{chunk-6BRDCQIM.js → chunk-5PCTSQWL.js} +1 -1
- package/dist/chunk-IRJGSXWE.js +135 -0
- package/dist/chunk-NZOCRYCO.js +241 -0
- package/dist/{chunk-7DEW7RDD.js → chunk-ZMZVVC65.js} +1 -1
- package/dist/{daemon-SX2HNQO4.js → daemon-AURLLC3T.js} +1 -1
- package/dist/daemon-VI7FKNLE.js +2 -0
- package/dist/index.js +189 -189
- package/dist/status-7WODVHXZ.js +2 -0
- package/package.json +3 -3
- package/dist/chunk-H3XHPJTD.js +0 -241
- package/dist/chunk-PQOQLQTZ.js +0 -135
- package/dist/daemon-QBD2YM3B.js +0 -2
- package/dist/status-TWQR76HF.js +0 -2
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{c as je}from"./chunk-4J4T7534.js";import{A as Ge,a as E,b as P,c as Pe,d as Ce,e as Te,f as C,g as Ae,i as T,o as We,p as Be,s as Ve,w as Ke,x as Je,y as ze,z as Qe}from"./chunk-ZMZVVC65.js";import{A as Ue,B as Ne,E as Le,S as De,T as qe,W as _e,X as He,a as I,b as xe,i as be,j as Ee,k as Ie,l as g,m as Fe,n as $e,p as Me,q as m,r as x,s as Oe,w as A}from"./chunk-IRJGSXWE.js";import{b as ke,d as u,e as f,h as we,i as ve}from"./chunk-4K4VY5OR.js";import Ze from"fs";import O from"path";import{config as tt}from"dotenv";import{z as $}from"zod";import{err as rt,ok as en}from"neverthrow";import F from"fs";import X from"path";import{err as G,ok as Ye}from"neverthrow";import{z as j}from"zod";var Xn=X.join(".ripplo","project.json"),Y=[".env",".env.local"],Zn=j.object({envFiles:j.array(j.string().min(1)).optional(),projectId:j.string().min(1)});function Xe(e){return X.join(e,Xn)}function Z(e){let n=Xe(e);return F.existsSync(n)?et(n).andThen(t=>{let r=Zn.safeParse(t);return r.success?Ye({envFiles:r.data.envFiles??Y,projectId:r.data.projectId}):G({issues:r.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:n})}):G({kind:"project-file-missing",path:n})}function ee(e){return Z(e).match(n=>n,()=>{})}function et(e){try{return Ye(JSON.parse(F.readFileSync(e,"utf8")))}catch(n){return G({issues:[n instanceof Error?n.message:String(n)],kind:"project-file-invalid",path:e})}}function Jo({cwd:e,envFiles:n,projectId:t}){let r=Xe(e);F.mkdirSync(X.dirname(r),{recursive:!0});let o={projectId:t};n!=null&&!nt(n)&&(o.envFiles=[...n]),F.writeFileSync(r,JSON.stringify(o,null,2)+`
|
|
3
|
+
`)}function nt(e){return e.length!==Y.length?!1:e.every((n,t)=>n===Y[t])}function ni(e){let t=ee(e)?.envFiles??[".env",".env.local"],r=O.join(e,".ripplo");t.forEach(o=>{let i=O.resolve(r,o);Ze.existsSync(i)&&tt({override:!0,path:i,quiet:!0})}),M=void 0}var ot=$.object({RIPPLO_APP_URL:$.url(),RIPPLO_ENGINE_URL:$.url(),RIPPLO_WEBHOOK_SECRET:$.string().min(1)}),M;function U(){return M!=null?en(M):at().map(e=>(M=e,e))}function it(e){let t=ee(e)?.envFiles??[],r=O.join(e,".ripplo");return t.map(o=>O.resolve(r,o)).filter(o=>!Ze.existsSync(o))}function at(){let e=ot.safeParse(process.env);if(!e.success)return rt({issues:e.error.issues.map(t=>`${t.path.join(".")}: ${t.message}`),kind:"env-invalid",missingEnvFiles:it(process.cwd())});let n=e.data;return en({appUrl:n.RIPPLO_APP_URL,engineUrl:n.RIPPLO_ENGINE_URL,webhookSecret:n.RIPPLO_WEBHOOK_SECRET})}var N=class extends Error{failure;constructor(n){super(n.kind),this.name="CliError",this.failure=n}};function si(e){return e instanceof N?ne(e.failure):e instanceof Error?e.message:String(e)}function ne(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).",Ae("setup")].join(`
|
|
4
|
+
`);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(n=>` ${n}`),"Fix the file by hand or re-run `npx ripplo init`."].join(`
|
|
5
|
+
`);case"not-authenticated":return["Not signed in. Run `npx ripplo auth login`.","(Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)"].join(`
|
|
6
|
+
`);case"env-invalid":return st(e);case"playwright-install-failed":return["Playwright browser install failed \u2014 Chromium is still missing.","Run `npx playwright install chromium` and check its output for network, proxy, or disk-space errors."].join(`
|
|
7
|
+
`);case"gitdir-unrecognized":return`Unrecognized .git file at ${e.marker} \u2014 expected a directory or a "gitdir:" pointer (worktree). Is the repo corrupted?`;case"gitdir-empty":return`Empty gitdir pointer at ${e.marker} \u2014 the worktree's .git file points nowhere. Re-create the worktree.`;case"oauth-device-code-failed":return[`Could not start sign-in (device-code request failed): ${e.description}`,"Is the Ripplo server reachable? Check RIPPLO_SERVER_URL and retry."].join(`
|
|
8
|
+
`);case"oauth-authorization-failed":return[`Sign-in failed (${e.code}): ${e.description}`,e.code==="expired_token"?"The approval window expired \u2014 run `npx ripplo auth login` again.":"Run `npx ripplo auth login` to retry."].join(`
|
|
9
|
+
`);case"compilation-failed":return T(e.error)}}function st(e){let n=e.missingEnvFiles.length===0?[]:["Declared env files not found:",...e.missingEnvFiles.map(t=>` ${t}`),"In a git worktree? Env files aren't copied from the main checkout \u2014 recreate them, or symlink to a shared file outside the working tree."];return["Env config invalid:",...e.issues.map(t=>` ${t}`),"Add the missing values to the env files declared in .ripplo/project.json.",...n].join(`
|
|
10
|
+
`)}import{err as ct,ok as ut}from"neverthrow";import{z as te}from"zod";var lt="https://ripplo.ai";function tn(){return on().RIPPLO_SERVER_URL}function rn(){return on().RIPPLO_PROJECT_ID}var dt=te.object({RIPPLO_PROJECT_ID:te.string().min(1).optional(),RIPPLO_SERVER_URL:te.string().min(1).default(lt)}),nn;function on(){return nn??=dt.parse(process.env),nn}import an from"fs";import re from"path";function sn(e){let n=an.realpathSync(e),t=n,r=re.dirname(t);for(;r!==t;){if(an.existsSync(re.join(t,".git")))return t;t=r,r=re.dirname(t)}return n}function ln(e){return Z(e).andThen(n=>U().andThen(t=>{let r=tn(),o=ve(r);return o==null?ct({kind:"not-authenticated"}):ut({appUrl:t.appUrl,cwd:sn(e),engineUrl:t.engineUrl,projectId:rn()??n.projectId,ripploServerUrl:r,token:o,tunnelAuth:void 0,webhookSecret:t.webhookSecret})}))}import pt from"p-queue";var ft=4,yt={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},L=new pt({concurrency:ft}),h={headedActive:0,interactiveActive:0,interactiveQueued:0},dn={current:null};function vi({headed:e,task:n,workClass:t}){let r=yt[t];return t==="p3-explore"?L.add(n,{priority:r}):(h.interactiveQueued+=1,D(),L.add(()=>gt({headed:e,task:n}),{priority:r}))}function xi(e){!Number.isFinite(e)||e<1||(L.concurrency=Math.floor(e),D())}function oe(){return{active:h.interactiveActive,headedActive:h.headedActive,poolSize:L.concurrency,queued:h.interactiveQueued}}function bi(e){dn.current=e}async function gt({headed:e,task:n}){h.interactiveQueued-=1,h.interactiveActive+=1,h.headedActive+=e?1:0,D();try{return await n()}finally{h.interactiveActive-=1,h.headedActive-=e?1:0,D()}}function D(){dn.current?.()}import ie from"fs";import ae from"path";function cn(e){try{let n=mt(e);if(n==null)return;let t=ae.join(n,"HEAD"),r=ie.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 mt(e){let n=ae.join(e,".git");if(ie.statSync(n).isDirectory())return n;let r=ie.readFileSync(n,"utf8").trim(),o="gitdir:";if(!r.startsWith(o))return;let i=r.slice(o.length).trim();if(i.length!==0)return ae.resolve(e,i)}import un from"crypto";import{readFile as pn}from"fs/promises";import fn from"path";import{graphql as se}from"gql.tada";import{err as Rt,ok as ht}from"neverthrow";var St=se(`
|
|
11
|
+
mutation SyncDevSession(
|
|
12
|
+
$projectId: String!
|
|
13
|
+
$cwd: String!
|
|
14
|
+
$branch: String
|
|
15
|
+
$lockfileContent: String
|
|
16
|
+
$fixtures: [SyncDevFixtureInput!]
|
|
17
|
+
$preconditions: [SyncDevPreconditionInput!]!
|
|
18
|
+
$singletons: [SyncDevSingletonInput!]
|
|
19
|
+
$workflows: [SyncDevWorkflowInput!]!
|
|
20
|
+
) {
|
|
21
|
+
syncDevSession(
|
|
22
|
+
projectId: $projectId
|
|
23
|
+
cwd: $cwd
|
|
24
|
+
branch: $branch
|
|
25
|
+
lockfileContent: $lockfileContent
|
|
26
|
+
fixtures: $fixtures
|
|
27
|
+
preconditions: $preconditions
|
|
28
|
+
singletons: $singletons
|
|
29
|
+
workflows: $workflows
|
|
30
|
+
) {
|
|
31
|
+
id
|
|
32
|
+
hooksPaused
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`);async function Di(e,n){let t=await C(e);if(t.isErr())return Rt({error:t.error,kind:"compilation-failed"});let r=await q({config:n,cwd:e,lockfile:t.value});return ht({devSessionId:r.devSessionId,lockfile:t.value})}async function q(e){let n=Ee(e.lockfile);return xt({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:n})}var kt=se(`
|
|
36
|
+
query DevSessionSyncState($projectId: String!, $cwd: String!) {
|
|
37
|
+
project(id: $projectId) {
|
|
38
|
+
devSession(cwd: $cwd) {
|
|
39
|
+
id
|
|
40
|
+
hooksPaused
|
|
41
|
+
lockfileHash
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`),wt=se(`
|
|
46
|
+
mutation AnnounceDevSessionActive($projectId: String!, $cwd: String!) {
|
|
47
|
+
announceDevSessionActive(projectId: $projectId, cwd: $cwd)
|
|
48
|
+
}
|
|
49
|
+
`);async function qi(e){let n=await yn(e.cwd);if(n!=null){let t=un.createHash("sha256").update(n).digest("hex"),o=(await u({config:e.config,document:kt,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null))?.project?.devSession;if(o!=null&&o.lockfileHash===t)return await u({config:e.config,document:wt,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null),{devSessionId:o.id,hash:t,hooksPaused:o.hooksPaused}}return q(e)}function vt(e){return un.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function xt({config:e,cwd:n,fixtures:t,payload:r}){let o=vt(r),i=cn(n),s=await yn(n),a=await bt(n,t),c=await u({config:e,document:St,variables:{branch:i??null,cwd:n,fixtures:a,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(p=>({namespace:p.namespace,preconditionName:p.preconditionName})),slug:d.slug,sourcePath:d.sourcePath,spec:JSON.stringify(d.spec)}))}});if(c.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:c.syncDevSession.id,hash:o,hooksPaused:c.syncDevSession.hooksPaused}}async function bt(e,n){let t=Object.entries(n);return Promise.all(t.map(async([r,o])=>({contentBase64:(await pn(fn.join(e,P,r))).toString("base64"),sha256:o.sha256})))}async function yn(e){try{return await pn(fn.join(e,Pe),"utf8")}catch{return null}}import{randomUUID as Kt}from"crypto";import{createId as Jt}from"@paralleldrive/cuid2";import{CancellationTokenSource as zt,ResponseError as Qt}from"vscode-jsonrpc/node";import{graphql as Et}from"gql.tada";var It=Et(`
|
|
50
|
+
mutation DaemonCreateRun(
|
|
51
|
+
$id: String
|
|
52
|
+
$workflowId: String!
|
|
53
|
+
$testId: String
|
|
54
|
+
$clientVersion: String
|
|
55
|
+
$executor: RunExecutor
|
|
56
|
+
$target: RunTarget
|
|
57
|
+
$lockfileHash: String
|
|
58
|
+
) {
|
|
59
|
+
createRun(
|
|
60
|
+
id: $id
|
|
61
|
+
workflowId: $workflowId
|
|
62
|
+
testId: $testId
|
|
63
|
+
executor: $executor
|
|
64
|
+
target: $target
|
|
65
|
+
clientVersion: $clientVersion
|
|
66
|
+
lockfileHash: $lockfileHash
|
|
67
|
+
) {
|
|
68
|
+
__typename
|
|
69
|
+
... on MutationCreateRunSuccess {
|
|
70
|
+
data {
|
|
71
|
+
id
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
... on LimitExceededError {
|
|
75
|
+
code
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
`);async function gn(e){try{let t=(await u({config:e.config,document:It,variables:Pt(e)})).createRun;return t==null?_({detail:"create-run-null",type:"generic"}):t.__typename==="MutationCreateRunSuccess"?null:t.__typename==="LimitExceededError"?_({code:t.code,type:"limit"}):_({detail:t.__typename,type:"generic"})}catch(n){return Ct(n)}}function Pt({executor:e,lockfileHash:n,runId:t,target:r}){return{clientVersion:E(),executor:e,id:t,lockfileHash:n,target:e==="cloud"?"tunnel":void 0,testId:r.testId,workflowId:r.workflowId}}function _(e){return{kind:"dispatch-error",reason:e}}function Ct(e){return e instanceof ke?{detail:e.message,kind:"infra-error"}:_({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{graphql as Tt}from"gql.tada";async function mn(e,n){let r=(await u({config:e,document:At,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 At=Tt(`
|
|
80
|
+
query DaemonWorkflows($projectId: String!, $cwd: String!) {
|
|
81
|
+
project(id: $projectId) {
|
|
82
|
+
id
|
|
83
|
+
devSession(cwd: $cwd) {
|
|
84
|
+
id
|
|
85
|
+
workflows {
|
|
86
|
+
id
|
|
87
|
+
slug
|
|
88
|
+
tests {
|
|
89
|
+
id
|
|
90
|
+
slug
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
`);import{CancellationTokenSource as jt}from"vscode-jsonrpc/node";function le(e){return`${e.workflowSlug}/${e.testSlug}`}function Rn(e){let{headed:n,inflight:t,jobId:r,lockfileHashValue:o,onExpire:i,runId:s,selection:a,timeoutMs:c}=e,d=le(a),p=`${d}@${o}@${String(n)}`,l=t.get(p);if(l!=null)return l.jobIds.add(r),null;let y={cancellation:new jt,claimed:!1,claimKey:d,headed:n,inflightKey:p,jobIds:new Set([r]),runId:s,testName:a.testName,timer:null,workflowName:a.workflowName};return y.timer=setTimeout(()=>{H(t,y),i(y)},c),t.set(p,y),y}function H(e,n){n.timer!=null&&(clearTimeout(n.timer),n.timer=null),e.delete(n.inflightKey)}function de(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 hn(e,n){[...e.values()].filter(t=>t.jobIds.has(n)).forEach(t=>{t.jobIds.delete(n),t.jobIds.size===0&&(H(e,t),t.cancellation.cancel())})}import{err as ce,ok as Sn}from"neverthrow";function wn({all:e,ids:n,lockfile:t}){if(e&&n.length>0)return ce({kind:"conflicting-flags"});if(e)return Sn(t.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>m(s))));if(n.length===0)return ce({kind:"nothing-selected"});let r=n.map(i=>({id:i,refs:$t(t,i)})),o=r.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?ce({kind:"unknown-ids",known:Ft(t),unknown:o}):Sn([...new Set(r.flatMap(i=>i.refs))])}function vn(e,n){let t=new Map(x(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 Ft(e){return e.workflows.map(n=>g(n.name))}function $t(e,n){let t=e.workflows.find(r=>r.name===n||g(r.name)===g(n));return t!=null?t.tests.map(r=>m(r)):x(e).filter(r=>r.ref===n||kn(r.ref)===kn(n)).map(r=>r.ref)}function kn(e){let n=e.lastIndexOf("/");return n===-1?g(e):`${g(e.slice(0,n))}/${g(e.slice(n+1))}`}import{err as ue,ok as bn}from"neverthrow";import{graphql as En}from"gql.tada";import{execFileSync as Mt}from"child_process";var Ot=256*1024*1024;function W(e,n){return Mt("git",[...e],{cwd:n,encoding:"utf8",maxBuffer:Ot,stdio:["ignore","pipe","pipe"]})}async function In({config:e,cwd:n,lockfile:t}){await Nt({config:e,cwd:n,lockfile:t});let r=await Dt(e);if(r.isErr())return ue(r.error);let o=new Map(t.workflows.filter(s=>!s.stub).map(s=>[g(s.name),s])),i=[...new Set(r.value)].flatMap(s=>{let a=o.get(s);return a==null?[]:a.tests.map(c=>m(c))});return i.length===0?ue({kind:"scope-empty"}):bn(i)}var Ut=En(`
|
|
97
|
+
mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
98
|
+
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
99
|
+
__typename
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`);async function Nt({config:e,cwd:n,lockfile:t}){let r=new Set(qt(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:Ut,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{f.warn({err:i},"auto-scope of dirty tests failed")})}var Lt=En(`
|
|
103
|
+
query ScopeSelection($projectId: String!, $cwd: String!) {
|
|
104
|
+
project(id: $projectId) {
|
|
105
|
+
id
|
|
106
|
+
devSession(cwd: $cwd) {
|
|
107
|
+
id
|
|
108
|
+
scopeItems {
|
|
109
|
+
id
|
|
110
|
+
workflow {
|
|
111
|
+
id
|
|
112
|
+
slug
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
`);async function Dt(e){try{let t=(await u({config:e,document:Lt,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return bn(t.flatMap(r=>r.workflow==null?[]:[r.workflow.slug]))}catch(n){return ue({detail:n instanceof Error?n.message:String(n),kind:"scope-fetch-failed"})}}var xn=".ripplo/workflows/";function qt(e){try{return W(["status","--porcelain","--",".ripplo/workflows"],e).split(`
|
|
119
|
+
`).map(n=>n.slice(3).trim()).filter(n=>n.startsWith(xn)&&n.endsWith(".ts")).map(n=>n.slice(xn.length)).filter(n=>n!=="index.ts"&&!n.endsWith("/index.ts"))}catch{return[]}}import{graphql as _t}from"gql.tada";var Ht=2e3,Wt=_t(`
|
|
120
|
+
query DaemonCloudRunStatus($runId: String!) {
|
|
121
|
+
run(id: $runId) {
|
|
122
|
+
status
|
|
123
|
+
failureReason
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`);function Cn({config:e,onComplete:n,onStarted:t,runId:r,signal:o}){let i=!1,s,a=!1,c=async()=>{if(i||o.aborted)return;let d=await Bt(e,r).catch(()=>"unknown");if(!(i||o.aborted)){if(!a&&(d==="running"||Pn(d))&&(a=!0,t()),Pn(d)){i=!0,n(Vt(d));return}s=setTimeout(()=>{c()},Ht)}};return c(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function Bt(e,n){let r=(await u({config:e,document:Wt,variables:{runId:n}})).run?.status;return r??"unknown"}function Pn(e){return e==="passed"||e==="failed"||e==="warning"||e==="cancelled"||e==="unready"}function Vt(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 Gt=12e4,Yt=-32099,pe=new Set,Tn=new Map;function Ta(e){pe.add(e)}function Xt(e){let n=new AbortController;return e.isCancellationRequested?(n.abort(),n.signal):(e.onCancellationRequested(()=>{n.abort()}),n.signal)}function Aa(e){let n={...e,inflight:new Map,jobs:new Map};return{claim:t=>rr(n,t),handleConnection:t=>{Zt(n,t)},idle:()=>Fn(n)}}function Zt(e,n){let t=We(n);t.onRequest(Ke,(r,o)=>er({connection:t,ctx:e,params:r,token:o})),t.onRequest(Je,()=>{let r=oe();return{active:r.active,queued:r.queued,sseHealth:e.sseHealth(),version:E(),...e.explorationStatus()}}),t.onRequest(ze,()=>{let r=Fn(e);return r&&e.onShutdownRequest(),r}),t.onClose(()=>{nr(e,t)}),t.onError(r=>{f.warn({err:r},"ipc connection error")}),n.on("error",r=>{f.warn({err:r},"ipc socket error")}),t.listen()}function Fn(e){let n=oe();return e.jobs.size===0&&n.active===0&&n.queued===0}async function er({connection:e,ctx:n,params:t,token:r}){let o=Be.safeParse(t);if(!o.success)throw An({code:"bad-message"});await n.ready;let i=await ir({config:n.config,cwd:n.cwd,message:o.data});if(i.kind==="error")throw An(i.error);let s=Kt(),a=new zt;return r.onCancellationRequested(()=>{$n(n,s)}),n.jobs.set(s,{cancellation:a,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),yr({ctx:n,headed:o.data.headed,jobId:s,lockfileHashValue:i.lockfileHashValue,selections:i.selections,targetsByClaimKey:i.targetsByClaimKey,token:a.token}).catch(c=>{f.error({err:c},"ipc dispatch failed")}),{jobId:s,total:i.selections.length}}function An(e){return new Qt(Yt,e.code,e)}function $n(e,n){let t=e.jobs.get(n);t!=null&&(t.cancellation.cancel(),e.jobs.delete(n),hn(e.inflight,n))}function nr(e,n){[...e.jobs.entries()].filter(([,t])=>t.connection===n).forEach(([t])=>{$n(e,t)})}function Mn(e,n,t){let r=e.jobs.get(n);r!=null&&(jn(()=>r.connection.sendNotification(Qe,{event:t,jobId:n})),t.kind==="test-outcome"&&(tr(r,t.outcome.kind),r.passed+r.failed+r.notRun>=r.total&&(jn(()=>r.connection.sendNotification(Ge,{failed:r.failed,jobId:n,notRun:r.notRun,passed:r.passed})),e.jobs.delete(n))))}function jn(e){Promise.resolve().then(e).catch(n=>{f.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 v(e,n,t){n.jobIds.forEach(r=>{Mn(e,r,t)})}function rr(e,n){let t=de(e.inflight,n);return t==null?null:{headed:t.headed,token:t.cancellation.token,finished:(r,o)=>{e.inflight.delete(t.inflightKey),v(e,t,{kind:"test-outcome",outcome:o,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},started:()=>{v(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}}}function or(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 ir({config:e,cwd:n,message:t}){return(await Ce(n)).match(o=>ar({config:e,cwd:n,lockfile:o,message:t}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...or(o)]},kind:"error"}))}async function ar({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=be(t);if(!pe.has(i)){let a=await cr({config:e,cwd:n,lockfile:t});if(a!=null)return{error:{code:"sync-failed",detail:a},kind:"error"};pe.add(i)}return(await ur({config:e,cwd:n,lockfile:t,message:r})).match(async a=>({kind:"ready",lockfileHashValue:i,selections:vn(t,a),targetsByClaimKey:await sr({config:e,cwd:n,hash:i})}),a=>Promise.resolve({error:a,kind:"error"}))}async function sr({config:e,cwd:n,hash:t}){let r=Tn.get(t);if(r!=null)return r;let o=await mn(e,n);return Tn.set(t,o),o}var lr=2e3;async function dr(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(lr)}),null}catch(n){return n instanceof Error?n.message:String(n)}}async function cr(e){try{return await q(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 In({config:e,cwd:n,lockfile:t})).mapErr(pr):wn({all:r.all,ids:r.tests,lockfile:t}).mapErr(fr)}function pr(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function fr(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 yr(e){await e.selections.reduce((n,t)=>n.then(()=>gr(e,t)),Promise.resolve())}async function gr(e,n){let{ctx:t,headed:r,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:a}=e;if(a.isCancellationRequested)return;let c=le(n),d=s.get(c);if(d==null){Mn(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 p=Rn({headed:r,inflight:t.inflight,jobId:o,lockfileHashValue:i,runId:Jt(),selection:n,timeoutMs:Gt,onExpire:y=>{v(t,y,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:y.testName,workflowName:y.workflowName})}});if(p==null)return;let l=await mr(t,d,p.runId,i);if(l!=null){H(t.inflight,p),v(t,p,{kind:"test-outcome",outcome:l,runId:"",testName:n.testName,workflowName:n.workflowName});return}t.executor==="cloud"&&Rr(t,p)}function mr(e,n,t,r){return gn({config:e.config,executor:e.executor,lockfileHash:r,runId:t,target:n})}function Rr(e,n){let t=de(e.inflight,n.runId);t!=null&&Cn({config:e.config,runId:t.runId,signal:Xt(t.cancellation.token),onComplete:r=>{e.inflight.delete(t.inflightKey),v(e,t,{kind:"test-outcome",outcome:r,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},onStarted:()=>{v(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}})}import hr from"fs";import Sr from"path";async function La(e){let n=Sr.join(e,".ripplo","index.ts");if(!hr.existsSync(n))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let t=await C(e);return t.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:T(t.error),path:".ripplo/"}],valid:!1,warnings:[]}:U().match(r=>({appUrl:r.appUrl,engineUrl:r.engineUrl,errors:[],valid:!0,warnings:[]}),r=>({appUrl:void 0,engineUrl:void 0,errors:[{message:ne(r),path:""}],valid:!1,warnings:[]}))}async function Da(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 qa({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 xr from"fs";import kr from"fs";import fe from"path";var wr=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function On(e){let n=vr(e);return n==null?!1:wr.some(t=>kr.existsSync(fe.join(n,t)))}function vr(e){try{let n=W(["rev-parse","--git-dir"],e).trim();return n.length===0?null:fe.isAbsolute(n)?n:fe.resolve(e,n)}catch{return null}}function br(e){return we(e,"hooks-paused")}function Ga(e){return xr.existsSync(br(e))||On(e)?!1:je(e)}import{createMessageConnection as Un,IPCMessageReader as Nn,IPCMessageWriter as Ln,NotificationType as Er,NotificationType0 as Dn,RequestType as qn,RequestType0 as Ir}from"vscode-jsonrpc/node";import{z as R}from"zod";var ts=R.object({headed:R.boolean(),runId:R.string().min(1),testRef:R.string().min(1)}),rs=R.object({lockfileJson:R.string().optional(),unavailable:R.string().optional()}),os=R.object({runId:R.string().min(1),span:xe}),is=R.object({outcome:Ve,serverNotified:R.boolean()}),as=new Dn("worker/ready"),ss=new qn("worker/run"),ls=new Ir("worker/lockfile"),ds=new qn("worker/exploreTrail"),cs=new Er("worker/span"),us=new Dn("worker/shutdown");function ps(e){let n=Un(new Nn(e),new Ln(e));return n.listen(),n}function fs(){let e=Un(new Nn(process),new Ln(process));return e.listen(),e}import{graphql as k}from"gql.tada";import{gzip as Mr}from"zlib";import{promisify as Or}from"util";import{existsSync as Bn,readFileSync as Vn}from"fs";import Kn from"path";import{graphql as b}from"gql.tada";function _n(e){return[e.kind,e.target,e.value].filter(n=>n.length>0).join(" ")}var Pr={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},Cr={"data-rule":"dataRule",fact:"fact",step:"step"},Tr={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 Hn(e){return e.kind==="consistency"?{consistency:{mismatch:Fr(e.mismatch),pending:e.pending}}:e.kind==="pending-check"?{pendingCheck:{budget:e.budget,source:Cr[e.source.kind],...Ar(e.source)}}:e.kind==="unrunnable"?{unrunnable:{reason:Pr[e.reason]}}:e.kind==="lift-visibility"?{impossibleAction:{subject:`lift visible to step ${String(e.visibleIndex+1)} of ${String(e.declaredIndex+1)}`}}:e.kind==="driver-error"?{driverError:{errorKind:Tr[e.error.kind],message:$r(e.error)}}:{impossibleAction:{subject:jr(e.step.action)}}}function Ar(e){return"check"in e?Wn(e.check,!1):{checkKind:void 0,expected:void 0,negated:void 0,subject:void 0}}function Wn(e,n){return e.kind==="not"?Wn(e.inner,!n):e.kind==="browser"?{checkKind:"browser",expected:e.value??void 0,negated:n,subject:Fe(e.key)}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:n,subject:I(e.locator)}:{checkKind:e.kind,expected:void 0,negated:n,subject:I(e.locator)}}function jr(e){let n=e.locator==null?e.url??"":I(e.locator);return`${e.kind} ${n}`.trim()}function Fr(e){return e.kind==="wrong-value"?{wrongValue:{entity:e.entity,field:e.field,key:e.key,snapshot:B(e.snapshot),sut:B(e.sut)}}:e.kind==="expected-change"?{expectedChange:{entity:e.entity,field:e.field,key:e.key,value:B(e.value)}}:e.kind==="scalar-mismatch"?{scalarMismatch:{singleton:Ue(e.subject),snapshot:Ne(e.want),sut:B(e.sut)}}:e.kind==="unexpected-row"?{unexpectedRow:{entity:e.entity,key:e.key}}:{missingRow:{entity:e.entity,key:e.key}}}function B(e){return e==null?null:String(e)}function $r(e){return"message"in e?e.message:"detail"in e?e.detail:null}function V({config:e,fixturesDir:n,headed:t}){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:n,generate:A,headed:t,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth}}async function ge(e){let n=await K(e);await me(e.config,e.runId,n)}async function K({config:e,debugDir:n,events:t,recordingOptional:r,runId:o,stepSources:i}){let s=Re(t),a=Dr(n,o);if(a==null&&!r)throw new Error("recording-missing");return await Promise.all([Jr({aliases:[...Hr(t),...Wr(s)],config:e,generated:Br(t),generatedSingletons:Vr(t),origin:a==null?Lr(s):a.origin,records:s,rrwebEvents:a==null?[]:a.events,runId:o,stepSources:i}),a==null?Promise.resolve():eo(e,o,a)]),s}async function me(e,n,t){let r=t.filter(s=>s.findings.length>0).length,o=t.length-r,i=t.reduce((s,a)=>s+Math.max(0,a.endMs-a.startMs),0);await u({config:e,document:oo,variables:{items:[{duration:i,failCount:r,passCount:o,runId:n,status:r>0?"failed":"passed",summary:null,warnCount:0}]}})}function Re(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 Jn(e,n){await u({config:e,document:io,variables:{runIds:[n]}})}async function Ur({config:e,debugDir:n,runId:t}){let r=Kn.join(n,t,"behavior.jsonl");if(Bn(r))try{let o=await u({config:e,document:no,variables:{runId:t}}),i=await fetch(o.debugArtifactUploadUrl,{body:Vn(r),headers:{"content-type":Nr},method:"PUT"});if(!i.ok){f.warn({runId:t,status:i.status},"behavior upload PUT failed");return}await Jn(e,t)}catch(o){f.warn({error:o,runId:t},"behavior upload failed")}}var Nr="application/x-ndjson";function Lr(e){return e.reduce((n,t)=>Math.min(n,t.startMs),e[0]?.startMs??0)}function Dr(e,n){let t=Kn.join(e,n,"behavior.jsonl");if(!Bn(t))return null;let r=Vn(t,"utf8").split(`
|
|
127
|
+
`).filter(i=>i.length>0).map(i=>qr(i)).flatMap(i=>_r(i)?[i.event]:[]),o=r[0];return o==null?null:{events:r,origin:o.timestamp}}function qr(e){return JSON.parse(e)}function _r(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function Hr(e){return e.flatMap(n=>n.kind==="world"?n.aliases:[])}function Wr(e){return e.flatMap(n=>{let t=Kr(n.source);return t.flatMap(r=>{let i=t.filter(a=>a.entity===r.entity).indexOf(r),s=n.state.rows.filter(a=>a.status==="created"&&a.entity===r.entity).at(i);return s==null?[]:[{alias:r.as,entity:r.entity,key:s.key}]})})}function Br(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generated.map(t=>zn(t)):[]))}function zn({entity:e,field:n,key:t}){return`${e} ${t} ${n}`}function Vr(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generatedSingletons:[]))}function Kr(e){return e==null?[]:e.expect.flatMap(n=>ye(n))}function ye(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(n=>ye(n)):e.kind==="when"?e.branches.flatMap(n=>n.consequence.flatMap(t=>ye(t))):[]}async function Jr({aliases:e,config:n,generated:t,generatedSingletons:r,origin:o,records:i,rrwebEvents:s,runId:a,stepSources:c}){let d=i.map((p,l)=>Yr({aliases:e,generated:t,generatedSingletons:r,origin:o,record:p,rrwebEvents:s,sourceTest:c?.[l]??null}));await u({config:n,document:to,variables:{items:[{runId:a,steps:d}]}})}var zr=3,Qr=0;function Gr({endMs:e,rrwebEvents:n,startMs:t}){let r=n.find(o=>o.type===zr&&o.data?.source===Qr&&o.timestamp>=t&&o.timestamp<=e);return r==null?t:r.timestamp}function Yr({aliases:e,generated:n,generatedSingletons:t,origin:r,record:o,rrwebEvents:i,sourceTest:s}){let a=Ie(o.source,o.index),c=Gr({endMs:o.endMs,rrwebEvents:i,startMs:o.startMs}),d=o.annotations.map(l=>({kind:l.kind,label:l.label,outcome:l.outcome,recordingStartMs:Math.max(0,(l.kind==="action"?c:l.atMs)-r),rrwebIds:[...l.rrwebIds],url:l.url,value:l.value??null})),p=o.annotations.find(l=>l.kind==="action")?.rrwebIds??[];return{annotations:d,detail:null,duration:Math.max(0,o.endMs-o.startMs),findings:o.findings.map(l=>Hn(l)),nodeType:a.kind,recordingEndMs:Math.max(0,o.endMs-r),recordingStartMs:Math.max(0,c-r),rrwebIds:[...p],snapshotTimestamp:Math.max(0,o.endMs-r),sourceTest:s,stateRows:o.state.rows.map(l=>Xr({aliases:e,generated:n,row:l})),stateSingletons:o.state.singletons.map(l=>({changed:l.changed,generated:t.has(l.name),name:l.name,value:l.value==null?null:String(l.value)})),status:o.findings.length>0?"failed":"passed",stepIndex:o.index,title:_n(a),url:o.url}}function Xr({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(zn({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 Zr=Or(Mr);async function eo(e,n,t){let r=t.events.map(s=>JSON.stringify(s)).join(`
|
|
128
|
+
`),o=await Zr(Buffer.from(r,"utf8")),i=t.events.at(-1);await u({config:e,document:ro,variables:{input:{bodyBase64:o.toString("base64"),chunkIndex:0,endTimestamp:Math.max(0,(i?.timestamp??t.origin)-t.origin),eventCount:t.events.length,runId:n,startTimestamp:0}}})}var no=b(`
|
|
129
|
+
mutation DebugArtifactUploadUrl($runId: String!) {
|
|
130
|
+
debugArtifactUploadUrl(runId: $runId)
|
|
131
|
+
}
|
|
132
|
+
`),to=b(`
|
|
133
|
+
mutation SubmitRunStepsBatch($items: [SubmitRunStepsItem!]!) {
|
|
134
|
+
submitRunStepsBatch(items: $items)
|
|
135
|
+
}
|
|
136
|
+
`),ro=b(`
|
|
137
|
+
mutation SubmitRunRecordingChunk($input: SubmitRunRecordingChunkInput!) {
|
|
138
|
+
submitRunRecordingChunk(input: $input)
|
|
139
|
+
}
|
|
140
|
+
`),oo=b(`
|
|
141
|
+
mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
|
|
142
|
+
completeRunsBatch(items: $items) {
|
|
143
|
+
id
|
|
144
|
+
status
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
`),io=b(`
|
|
148
|
+
mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
|
|
149
|
+
markRunArtifactsUploadedBatch(runIds: $runIds)
|
|
150
|
+
}
|
|
151
|
+
`);function ao(e){let n=e.trail;if(!(n==null||!so(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 so(e){return e==="clean"||e==="flaky"||e==="finding"}async function he({baseState:e,branchName:n,category:t,commitSha:r,config:o,debugDir:i,devSessionId:s,events:a,lockfileHash:c,reproJson:d,runId:p,signature:l,spec:y,stepSources:S}){await u({config:o,document:go,variables:{branchName:n??null,commitSha:r??null,devSessionId:s??null,lockfileHash:c??null,projectId:o.projectId,reproJson:d,runId:p,spec:y??null}}),await ge({config:o,debugDir:i,events:a,recordingOptional:!0,runId:p,stepSources:S}),await u({config:o,document:mo,variables:{baseState:e,category:t,projectId:o.projectId,reproRunId:p,signature:l}})}async function J(e,n,t){return(await u({config:e,document:Ro,variables:{lockfileHash:t,projectId:e.projectId,signature:n}})).exploreFindingExists}async function lo({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 co(e,n,t){let r=await u({config:e,document:uo,variables:{devSessionId:n}}).catch(i=>(f.warn({error:i},"fetchScopedTestRefs failed"),null)),o=new Set(r?.exploreScope??[]);return o.size===0?new Set:new Set(t.workflows.filter(i=>o.has(g(i.name))).flatMap(i=>i.tests.map(s=>m(s))))}var uo=k(`
|
|
152
|
+
query ExploreScope($devSessionId: String!) {
|
|
153
|
+
exploreScope(devSessionId: $devSessionId)
|
|
154
|
+
}
|
|
155
|
+
`);async function po(e,n){return(await u({config:e,document:yo,variables:{devSessionId:n}}).catch(r=>(f.warn({error:r},"reportExploreUnhealthy failed"),null)))?.reportExploreUnhealthy??!1}var fo=k(`
|
|
156
|
+
mutation RecordExplorationProgress(
|
|
157
|
+
$devSessionId: String!
|
|
158
|
+
$attempts: Int!
|
|
159
|
+
$findings: Int!
|
|
160
|
+
$trail: ExploreTrailInput
|
|
161
|
+
) {
|
|
162
|
+
recordExplorationProgress(
|
|
163
|
+
devSessionId: $devSessionId
|
|
164
|
+
attempts: $attempts
|
|
165
|
+
findings: $findings
|
|
166
|
+
trail: $trail
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
`),yo=k(`
|
|
170
|
+
mutation ReportExploreUnhealthy($devSessionId: String!) {
|
|
171
|
+
reportExploreUnhealthy(devSessionId: $devSessionId)
|
|
172
|
+
}
|
|
173
|
+
`),go=k(`
|
|
174
|
+
mutation CreateExploreRun(
|
|
175
|
+
$projectId: String!
|
|
176
|
+
$runId: String!
|
|
177
|
+
$devSessionId: String
|
|
178
|
+
$branchName: String
|
|
179
|
+
$commitSha: String
|
|
180
|
+
$lockfileHash: String
|
|
181
|
+
$spec: String
|
|
182
|
+
$reproJson: String
|
|
183
|
+
) {
|
|
184
|
+
createExploreRun(
|
|
185
|
+
projectId: $projectId
|
|
186
|
+
runId: $runId
|
|
187
|
+
devSessionId: $devSessionId
|
|
188
|
+
branchName: $branchName
|
|
189
|
+
commitSha: $commitSha
|
|
190
|
+
lockfileHash: $lockfileHash
|
|
191
|
+
spec: $spec
|
|
192
|
+
reproJson: $reproJson
|
|
193
|
+
) {
|
|
194
|
+
id
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
`),mo=k(`
|
|
198
|
+
mutation SubmitExploreFinding(
|
|
199
|
+
$projectId: String!
|
|
200
|
+
$signature: String!
|
|
201
|
+
$baseState: String!
|
|
202
|
+
$category: ExploreFindingCategory!
|
|
203
|
+
$reproRunId: String!
|
|
204
|
+
) {
|
|
205
|
+
submitExploreFinding(
|
|
206
|
+
projectId: $projectId
|
|
207
|
+
signature: $signature
|
|
208
|
+
baseState: $baseState
|
|
209
|
+
category: $category
|
|
210
|
+
reproRunId: $reproRunId
|
|
211
|
+
) {
|
|
212
|
+
id
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
`),Os=k(`
|
|
216
|
+
mutation SetExploreFindingStatus(
|
|
217
|
+
$projectId: String!
|
|
218
|
+
$signature: String!
|
|
219
|
+
$status: ExploreFindingStatus!
|
|
220
|
+
) {
|
|
221
|
+
setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
|
|
222
|
+
}
|
|
223
|
+
`),Ro=k(`
|
|
224
|
+
query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
|
|
225
|
+
exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
|
|
226
|
+
}
|
|
227
|
+
`);import ho from"path";import{graphql as So}from"gql.tada";async function ko({config:e,cwd:n,fixturesDir:t,headed:r,lockfile:o,runId:i,session:s,signal:a,test:c}){if(!await vo(e,i))return{outcome:{kind:"dispatch-failed",reason:"already-claimed",runId:i},persisted:Promise.resolve()};let p=ho.join(n,".ripplo","debug"),l=[];return(await s.runOnce({capture:!0,lockfile:o,onPhase:void 0,options:V({config:e,fixturesDir:t,headed:r}),params:void 0,runId:i,sequence:void 0,test:c,onEvent:S=>{l.push(S)}},a)).match(async S=>{let w=Re(l),Q=w.flatMap(Yn=>Yn.findings),Se=wo(Q);if(Se!=null)return await K({config:e,debugDir:p,events:l,recordingOptional:!0,runId:i,stepSources:void 0}),{outcome:{error:Se,kind:"error",runId:i},persisted:Promise.resolve()};await me(e,i,w);let Gn=K({config:e,debugDir:p,events:l,recordingOptional:!0,runId:i,stepSources:void 0}).then(()=>{});return{outcome:Q.length>0?{findings:Q,kind:"findings",runId:i}:{kind:"pass",runId:i},persisted:Gn}},S=>Promise.resolve({outcome:{error:S,kind:"error",runId:i},persisted:Promise.resolve()}))}function wo(e){let n=e.find(t=>t.kind==="driver-error"&&$e(t.error));return n!=null&&n.kind==="driver-error"?n.error:void 0}async function vo(e,n){return((await u({config:e,document:xo,variables:{runIds:[n]}})).startRunsBatch??[]).some(r=>r.id===n)}var xo=So(`
|
|
228
|
+
mutation StartRunsBatch($runIds: [String!]!) {
|
|
229
|
+
startRunsBatch(runIds: $runIds) {
|
|
230
|
+
id
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
`);import{graphql as Qn}from"gql.tada";async function bo(e,n,t){await u({config:e,document:Eo,variables:{reason:t,runId:n}}).catch(r=>{f.error(r,"failRun submission failed")})}var Eo=Qn(`
|
|
234
|
+
mutation FailRun($runId: String!, $reason: String!) {
|
|
235
|
+
failRun(runId: $runId, reason: $reason)
|
|
236
|
+
}
|
|
237
|
+
`),Vs=Qn(`
|
|
238
|
+
mutation MarkRunUnready($runId: String!, $cause: RunUnreadyCause!) {
|
|
239
|
+
markRunUnready(runId: $runId, cause: $cause)
|
|
240
|
+
}
|
|
241
|
+
`);import{randomUUID as Io}from"crypto";async function Po({assign:e,config:n,debugDir:t,devSessionId:r,fixturesDir:o,headed:i,lockfile:s,report:a,session:c,signal:d}){let p=Oe(s);if(e.stepRuns.length===0)return{kind:"error",reason:"empty-trail"};let l=Uo(p,e.stepRuns),y=await _e({baseState:{name:m(e.baseStateTest),test:e.baseStateTest},corpus:p,lockfile:s,options:V({config:n,fixturesDir:o,headed:i}),seenSignature:a?w=>J(n,w,e.lockfileHash):void 0,session:c,stepRuns:e.stepRuns,runIdFor:w=>`explore-${Io()}-${String(w)}`},d),S=a?await $o({baseStateTest:e.baseStateTest,config:n,debugDir:t,devSessionId:r,lockfileHash:e.lockfileHash,outcome:y,reproJson:jo(p,e),stepSources:Fo(l)}):!1;return Ao(y,l.length),No(y,S,Co(l,e,y))}function Co(e,n,t){if(t.kind==="error"||t.kind==="aborted")return;let r=t.timing.confirm;return{baseLabel:n.baseStateTest.intent,baseState:m(n.baseStateTest),durationMs:Math.round(z(t.timing.detect)+(r==null?0:z(r))),signature:t.kind==="finding"?t.signature:void 0,steps:To(e)}}function To(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(r=>({test:t,text:r}))})}function z(e){return e.engineMs+e.worldMs+e.browserMs+e.driveMs+e.teardownMs}function Ao(e,n){if(e.kind==="error"){f.info({detail:Me(e.error),kind:e.kind,reason:e.error.kind,steps:n},"explore trail");return}if(e.kind==="aborted"){f.info({kind:e.kind,steps:n},"explore trail");return}let t=e.timing.detect,r=e.timing.confirm;f.info({browserMs:t.browserMs,confirmMs:r==null?void 0:z(r),detectMs:z(t),driveMs:t.driveMs,engineMs:t.engineMs,kind:e.kind,steps:n,teardownMs:t.teardownMs,worldMs:t.worldMs},"explore trail")}function jo(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:m(n.baseStateTest),steps:t};return JSON.stringify(r)}function Fo(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(()=>t)})}async function $o({baseStateTest:e,config:n,debugDir:t,devSessionId:r,lockfileHash:o,outcome:i,reproJson:s,stepSources:a}){return i.kind!=="finding"||i.captureEvents.length===0?!1:await J(n,i.signature,o)?(f.info({devSessionId:r,signature:i.signature},"explore finding already reported, skipping duplicate"),!1):(await he({baseState:i.baseState,branchName:void 0,category:Mo(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:Oo(e,i.captureEvents),stepSources:a}).catch(c=>{f.warn({error:c},"explore finding report failed")}),!0)}function Mo(e){return e==="data-rule"?"dataRule":e==="fact"?"fact":e}function Oo(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 Uo(e,n){return n.flatMap(t=>{let r=e[t.idx];return r==null?[]:[{actions:[...r.nav,...r.steps].map(o=>Le(o.action)),label:`${r.test}#${String(r.index)}`}]})}function No(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 Lo from"path";import{randomUUID as Do}from"crypto";async function yl({cwd:e,onReady:n,signal:t,step:r,target:o}){let i=ln(e).match(l=>({config:l}),l=>({failure:l}));if("failure"in i)return{failure:i.failure,kind:"config-failed"};let s=i.config,a=await Te(e);if(a.result.isErr())return{error:a.result.error,kind:"compile-failed"};let c=a.result.value,d=await qo(c,o);return d.kind!=="ok"?d:(await De({lockfile:c,onReady:n,options:_o(s),runId:`teleport-${Do()}`,sequence:d.sequence,stopAfterStep:r,test:d.test},t)).match(l=>({kind:"done",result:l}),l=>({error:l,kind:"run-failed"}))}async function qo(e,n){if(n.kind==="explore"){let r=await He(e,n.repro);return r.kind==="unplannable"?{kind:"unplannable"}:{kind:"ok",sequence:r.sequence,test:r.baseTest}}let t=x(e).find(r=>r.ref===n.ref);return t==null?{kind:"no-test",ref:n.ref}:{kind:"ok",sequence:qe(e,t.test,void 0),test:t.test}}function _o(e){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:Lo.join(e.cwd,P),generate:A,headed:!0,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth}}export{Jo as a,ni as b,U as c,it as d,si as e,ne as f,tn as g,on as h,ln as i,W as j,On as k,La as l,Da as m,qa as n,br as o,Ga as p,ts as q,os as r,is as s,as as t,ss as u,ls as v,ds as w,cs as x,us as y,ps as z,fs as A,vi as B,xi as C,oe as D,bi as E,cn as F,Di as G,q as H,qi as I,Ta as J,Xt as K,Aa as L,Ur as M,ko as N,bo as O,ao as P,lo as Q,co as R,po as S,Po as T,yl as U};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{g as w}from"./chunk-
|
|
2
|
+
import{g as w}from"./chunk-IRJGSXWE.js";import{h as k}from"./chunk-4K4VY5OR.js";import{readFileSync as M}from"fs";import{z as F}from"zod";var O=F.object({version:F.string()});function xe(){let t=M(new URL("../package.json",import.meta.url),"utf8");return O.parse(JSON.parse(t)).version}import j from"fs";import g from"path";import{createJiti as K}from"jiti";import{err as f,ok as I}from"neverthrow";import z from"fs";import p from"path";import l from"typescript";function P(t){let r=p.join(t,"index.ts"),n=U(t);z.mkdirSync(p.dirname(n.tsBuildInfoFile??""),{recursive:!0});let o=l.createIncrementalCompilerHost(n),i=l.createIncrementalProgram({host:o,options:n,rootNames:[r]}),s=[...i.getSyntacticDiagnostics(),...i.getSemanticDiagnostics()];i.emit();let a=s.filter(u=>N(u,t));if(a.length===0)return{diagnostics:[],ok:!0};let L={getCanonicalFileName:u=>u,getCurrentDirectory:()=>p.dirname(t),getNewLine:()=>`
|
|
3
3
|
`};return{diagnostics:l.formatDiagnosticsWithColorAndContext(a,L).split(`
|
|
4
4
|
`).filter(u=>u.length>0),ok:!1}}function N(t,r){let n=t.file?.fileName;return n==null?!0:n.startsWith(r)}var D=p.join(".local","tsbuildinfo");function U(t){return{allowImportingTsExtensions:!0,allowJs:!1,esModuleInterop:!0,incremental:!0,module:l.ModuleKind.Preserve,moduleResolution:l.ModuleResolutionKind.Bundler,noEmit:!0,resolveJsonModule:!0,skipLibCheck:!0,strict:!1,target:l.ScriptTarget.ES2022,tsBuildInfoFile:p.join(t,D)}}import{createHash as q}from"crypto";import T from"fs/promises";import b from"path";import{err as c,ok as E,Result as H}from"neverthrow";var X=".ripplo/fixtures",R=10*1024*1024,S=50*1024*1024;async function v(t,r){let n=B(r);if(n.length===0)return E({});let o=b.join(t,X),i=await Promise.all(n.map(s=>J({fixturesRoot:o,name:s})));return H.combine(i).andThen(W)}function B(t){let n=t.workflows.flatMap(o=>[...o.steps,...o.tests.flatMap(i=>i.steps)]).flatMap(o=>o.action.kind==="upload"?o.action.files:[]);return[...new Set(n)].toSorted((o,i)=>o.localeCompare(i))}async function J({fixturesRoot:t,name:r}){if(r.includes("..")||b.isAbsolute(r))return c({kind:"fixture-invalid-name",name:r});let n=b.join(t,r),o=await T.lstat(n).catch(()=>null);if(o==null)return c({kind:"fixture-missing",name:r,path:n});if(o.isSymbolicLink())return c({kind:"fixture-symlink",name:r});if(!o.isFile())return c({kind:"fixture-not-file",name:r});let i=await T.readFile(n);if(i.byteLength>R)return c({kind:"fixture-too-large",name:r,size:i.byteLength});let s=q("sha256").update(i).digest("hex");return E([r,{sha256:s,size:i.byteLength}])}function W(t){let r=t.reduce((n,[,o])=>n+o.size,0);return r>S?c({kind:"fixtures-total-too-large",total:r}):E(Object.fromEntries(t))}var y=".ripplo/ripplo.lock",d;async function Me(t){let{result:r}=await V(t);return r}async function V(t){let r=Q(g.join(t,".ripplo"));if(d!=null&&d.fingerprint===r&&d.result.isOk())return{fingerprint:r,result:d.result};let n=await G(t);return d={fingerprint:r,result:n},{fingerprint:r,result:n}}async function G(t){let r=g.join(t,".ripplo"),n=g.join(r,"index.ts"),o=P(r);return o.ok?(await Z(n)).andThen(a=>te({entryPath:n,exported:a})).match(async a=>(await v(t,a)).map(m=>({...a,fixtures:m})).mapErr(m=>({error:m,kind:"fixture-failed"})),a=>Promise.resolve(f(a))):f({diagnostics:o.diagnostics,kind:"typecheck-failed"})}var Y=new Set([".local","debug","node_modules"]);function Q(t){return A(t).toSorted((r,n)=>r.localeCompare(n)).join("|")}function A(t){return(j.existsSync(t)?j.readdirSync(t,{withFileTypes:!0}):[]).flatMap(n=>{if(Y.has(n.name))return[];let o=g.join(t,n.name);if(n.isDirectory())return A(o);let i=j.statSync(o);return[`${o}:${String(i.mtimeMs)}:${String(i.size)}`]})}async function Z(t){try{let n=await K(import.meta.url,{fsCache:!1,moduleCache:!1,sourceMaps:!0}).import(t),o=n!=null&&typeof n=="object"&&"default"in n?Reflect.get(n,"default"):n;return I(o)}catch(r){return f({kind:"load-threw",message:ee(r)})}}function ee(t){return t instanceof Error?t.message:String(t)}function te({entryPath:t,exported:r}){if(r==null||typeof r!="object"||!("lockfile"in r))return f({entryPath:t,kind:"not-ripplo"});let n=w.safeParse(Reflect.get(r,"lockfile"));return n.success?I(n.data):f({issues:n.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"invalid-lockfile"})}function h(t,r){return r==null?`Load \`/ripplo:${t}\` skill for instructions.`:`Load \`/ripplo:${t}\` skill for instructions on ${r}.`}function ze(t){return t.length===1?h(t[0]):`Before proceeding, load the ${t.map(n=>`\`/ripplo:${n}\``).join(" and ")} skills \u2014 every one, each carries rules the others don't.`}function He(t){return[`Compilation failed: ${re(t)}`,h("create","DSL authoring + lint rules")].join(`
|
|
5
5
|
`)}function Xe(){return`${y} is up to date`}function Be(t){return[`${y} is ${t==="missing"?"missing":"out of date"} \u2014 run \`npx ripplo compile\` and commit the result`,h("setup")].join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{B as R,C as E,D as Ie,E as M,F as We,H as Ae,I as Le,J as De,K as He,L as _e,O as T,P as Me,Q as Ue,R as qe,S as Oe,U as Fe,b as V,f as re,i as w,m as te,o as fe,s as he,t as be,u as xe,v as Pe,w as Re,x as Ee,y as Te,z as Ce}from"./chunk-
|
|
2
|
+
import{B as R,C as E,D as Ie,E as M,F as We,H as Ae,I as Le,J as De,K as He,L as _e,O as T,P as Me,Q as Ue,R as qe,S as Oe,U as Fe,b as V,f as re,i as w,m as te,o as fe,s as he,t as be,u as xe,v as Pe,w as Re,x as Ee,y as Te,z as Ce}from"./chunk-NZOCRYCO.js";import{e as oe,f as ne}from"./chunk-4J4T7534.js";import{a as K,d as P,e as ee,f as H,i as _,m as me}from"./chunk-ZMZVVC65.js";import{$ as ge,K as le,M as se,N as ce,O as de,P as ue,Q as pe,_ as ye,aa as Se,ba as ke,ca as ve,e as Y,ea as we,h as X,i as b,l as Z,o as ie,q as ae}from"./chunk-IRJGSXWE.js";import{b as Ne}from"./chunk-33L574IL.js";import{c as Q,d as S,e as s,f as D,g as G}from"./chunk-4K4VY5OR.js";import"./chunk-SB7H6IAS.js";import zo from"path";import{createClient as Jo}from"graphql-sse";import Qo,{AbortError as Go}from"p-retry";import{graphql as j}from"gql.tada";import{graphql as Dr}from"gql.tada";import{print as Hr}from"graphql";async function $e({config:e,cwd:r,headed:o,pool:n,runId:t,signal:i,testSlug:a,workClass:l,workflowSlug:c}){let u=await P(r);if(u.isErr())return await T(e,t,`lockfile:${u.error.kind}`),{kind:"dispatch-error",reason:{detail:`lockfile:${u.error.kind}`,type:"generic"}};let p=Lr(u.value,{testSlug:a,workflowSlug:c});if(p==null)return await T(e,t,`no-test:${c}/${a}`),{kind:"dispatch-error",reason:{detail:`no-test:${c}/${a}`,type:"generic"}};let d=await R({headed:o,workClass:l,task:()=>n.execute({headed:o,runId:t,testRef:p},i)});return!d.serverNotified&&d.outcome.kind==="error"&&await T(e,t,d.outcome.detail),d.outcome}function Lr(e,{testSlug:r,workflowSlug:o}){let t=e.workflows.find(i=>Z(i.name)===o)?.tests.find(i=>i.slug===r);return t==null?void 0:ae(t)}var _r=6e4,Mr=Dr(`
|
|
3
3
|
subscription RunRequestedWatch($devSessionId: String!) {
|
|
4
4
|
runRequested(devSessionId: $devSessionId) {
|
|
5
5
|
runId
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{$ as c,Z as a,_ as b,aa as d,ba as e,ca as f,da as g,ea as h,fa as i,ga as j,ha as k,ia as l}from"./chunk-IRJGSXWE.js";import"./chunk-SB7H6IAS.js";export{b as renderDaemonBindError,h as renderDaemonLockCompromised,f as renderDaemonLockHeld,e as renderDaemonReady,i as renderDaemonStatus,g as renderDaemonStopResult,k as renderDaemonVersionNote,j as renderExplorationProgress,d as renderNotSignedIn,c as renderProjectAccessDenied,a as renderTunnelProvisionFailed,l as wireOutcome};
|