ripplo 0.7.42 → 0.7.44
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-3MDHW3LO.js} +1 -1
- package/dist/chunk-LYZ6JY7L.js +252 -0
- package/dist/chunk-M4ESW6JP.js +135 -0
- package/dist/{chunk-7DEW7RDD.js → chunk-VW7PTYJ3.js} +1 -1
- package/dist/daemon-MHGTHG25.js +129 -0
- package/dist/daemon-SUSSQ463.js +2 -0
- package/dist/index.js +319 -241
- package/dist/status-52ZOYXAV.js +2 -0
- package/package.json +4 -4
- package/dist/chunk-33L574IL.js +0 -23
- package/dist/chunk-H3XHPJTD.js +0 -241
- package/dist/chunk-PQOQLQTZ.js +0 -135
- package/dist/daemon-QBD2YM3B.js +0 -2
- package/dist/daemon-SX2HNQO4.js +0 -102
- package/dist/daemon-tunnel-K4FR22ON.js +0 -2
- package/dist/status-TWQR76HF.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ripplo",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.44",
|
|
4
4
|
"description": "CLI for Ripplo — AI-powered end-to-end testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://ripplo.ai",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
"tsup": "^8.5.1",
|
|
61
61
|
"vitest": "^4.1.4",
|
|
62
62
|
"@ripplo/core": "^0.0.0",
|
|
63
|
-
"@ripplo/graphql": "^0.0.0",
|
|
64
|
-
"@ripplo/spec": "^0.0.0",
|
|
65
63
|
"@ripplo/eslint-config": "0.0.0",
|
|
64
|
+
"@ripplo/graphql": "^0.0.0",
|
|
65
|
+
"@ripplo/rrweb-bundle": "0.0.0",
|
|
66
66
|
"@ripplo/run-report": "0.0.0",
|
|
67
67
|
"@ripplo/runtime": "^0.0.0",
|
|
68
|
-
"@ripplo/
|
|
68
|
+
"@ripplo/spec": "^0.0.0"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"dev": "tsx watch src/index.ts",
|
package/dist/chunk-33L574IL.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{d as p,e as a}from"./chunk-4K4VY5OR.js";import{graphql as y}from"gql.tada";import{execFileSync as S,spawn as T}from"child_process";import{existsSync as m}from"fs";var g=2e3,w=["/opt/homebrew/bin/cloudflared","/usr/local/bin/cloudflared","/usr/bin/cloudflared"],d=class extends Error{};function v({token:n}){let e=h(),i=!1,r,o,s=()=>{if(i)return;let t=T(e,["tunnel","--no-autoupdate","run"],{env:{...process.env,TUNNEL_TOKEN:n},stdio:"ignore"});r=t,t.on("error",l=>{a.warn({err:l},"cloudflared spawn failed"),f()}),t.on("exit",(l,c)=>{a.warn({code:l,signal:c},"cloudflared exited"),r=void 0,f()})},f=()=>{i||o!=null||(o=setTimeout(()=>{o=void 0,s()},g))};return s(),{stop:async()=>{i=!0,o!=null&&(clearTimeout(o),o=void 0);let t=r;t!=null&&(t.kill("SIGTERM"),await new Promise(l=>{let c=setTimeout(()=>{t.kill("SIGKILL"),l()},5e3);t.on("exit",()=>{clearTimeout(c),l()})}))}}}function h(){let n=w.find(e=>m(e));if(n!=null)return n;try{let e=S("/usr/bin/env",["which","cloudflared"],{encoding:"utf8"}).trim();if(e.length>0&&m(e))return e}catch{throw new d}throw new d}var P=y(`
|
|
3
|
-
mutation ReleaseDevTunnel($devSessionId: String!) {
|
|
4
|
-
releaseDevTunnel(devSessionId: $devSessionId)
|
|
5
|
-
}
|
|
6
|
-
`),x=y(`
|
|
7
|
-
mutation ProvisionDevTunnel($devSessionId: String!, $localUrl: String!, $engineUrl: String) {
|
|
8
|
-
provisionDevTunnel(devSessionId: $devSessionId, localUrl: $localUrl, engineUrl: $engineUrl) {
|
|
9
|
-
__typename
|
|
10
|
-
... on DevTunnel {
|
|
11
|
-
hostname
|
|
12
|
-
tunnelId
|
|
13
|
-
tunnelToken
|
|
14
|
-
}
|
|
15
|
-
... on DevSessionEndedError {
|
|
16
|
-
message
|
|
17
|
-
}
|
|
18
|
-
... on TunnelNotConfiguredError {
|
|
19
|
-
message
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`),u=class extends Error{failure;constructor(e){super(e.kind),this.failure=e}};async function $({config:n,devSessionId:e}){let r=(await p({config:n,document:x,variables:{devSessionId:e,engineUrl:n.engineUrl,localUrl:n.appUrl}})).provisionDevTunnel;if(r==null)throw new u({kind:"empty-response"});if(r.__typename!=="DevTunnel")throw new u({kind:"server-error",typename:r.__typename});let o=r.hostname,s=v({token:r.tunnelToken});return a.info({hostname:o},"cloud-executor tunnel up"),{hostname:o,stop:()=>D({config:n,devSessionId:e,sidecar:s})}}async function D({config:n,devSessionId:e,sidecar:i}){await i.stop(),await p({config:n,document:P,variables:{devSessionId:e}}).catch(r=>{a.warn({err:r},"releaseDevTunnel on shutdown failed")})}export{u as a,$ as b};
|
package/dist/chunk-H3XHPJTD.js
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{c as Ae}from"./chunk-4J4T7534.js";import{A as Ke,a as P,b as T,c as Ie,d as Pe,e as Ce,f as A,g as Te,i as j,o as De,p as qe,s as _e,w as He,x as We,y as Be,z as Ve}from"./chunk-7DEW7RDD.js";import{B as $e,O as Ue,P as Oe,S as Ne,T as Le,a as C,b as ve,i as xe,j as be,k as Ee,l as g,m as je,o as Fe,p as z,q as m,r as I,s as Me,w as x}from"./chunk-PQOQLQTZ.js";import{b as ke,d as u,e as f,h as Se,i as we}from"./chunk-4K4VY5OR.js";import Qe from"fs";import O from"path";import{config as Zn}from"dotenv";import{z as $}from"zod";import{err as et,ok as Ge}from"neverthrow";import M from"fs";import Y from"path";import{err as Q,ok as Je}from"neverthrow";import{z as F}from"zod";var Qn=Y.join(".ripplo","project.json"),G=[".env",".env.local"],Gn=F.object({envFiles:F.array(F.string().min(1)).optional(),projectId:F.string().min(1)});function ze(e){return Y.join(e,Qn)}function X(e){let n=ze(e);return M.existsSync(n)?Yn(n).andThen(t=>{let r=Gn.safeParse(t);return r.success?Je({envFiles:r.data.envFiles??G,projectId:r.data.projectId}):Q({issues:r.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:n})}):Q({kind:"project-file-missing",path:n})}function Z(e){return X(e).match(n=>n,()=>{})}function Yn(e){try{return Je(JSON.parse(M.readFileSync(e,"utf8")))}catch(n){return Q({issues:[n instanceof Error?n.message:String(n)],kind:"project-file-invalid",path:e})}}function Ho({cwd:e,envFiles:n,projectId:t}){let r=ze(e);M.mkdirSync(Y.dirname(r),{recursive:!0});let o={projectId:t};n!=null&&!Xn(n)&&(o.envFiles=[...n]),M.writeFileSync(r,JSON.stringify(o,null,2)+`
|
|
3
|
-
`)}function Xn(e){return e.length!==G.length?!1:e.every((n,t)=>n===G[t])}function Go(e){let t=Z(e)?.envFiles??[".env",".env.local"],r=O.join(e,".ripplo");t.forEach(o=>{let i=O.resolve(r,o);Qe.existsSync(i)&&Zn({override:!0,path:i,quiet:!0})}),U=void 0}var nt=$.object({RIPPLO_APP_URL:$.url(),RIPPLO_ENGINE_URL:$.url(),RIPPLO_WEBHOOK_SECRET:$.string().min(1)}),U;function N(){return U!=null?Ge(U):rt().map(e=>(U=e,e))}function tt(e){let t=Z(e)?.envFiles??[],r=O.join(e,".ripplo");return t.map(o=>O.resolve(r,o)).filter(o=>!Qe.existsSync(o))}function rt(){let e=nt.safeParse(process.env);if(!e.success)return et({issues:e.error.issues.map(t=>`${t.path.join(".")}: ${t.message}`),kind:"env-invalid",missingEnvFiles:tt(process.cwd())});let n=e.data;return Ge({appUrl:n.RIPPLO_APP_URL,engineUrl:n.RIPPLO_ENGINE_URL,webhookSecret:n.RIPPLO_WEBHOOK_SECRET})}var L=class extends Error{failure;constructor(n){super(n.kind),this.name="CliError",this.failure=n}};function ti(e){return e instanceof L?ee(e.failure):e instanceof Error?e.message:String(e)}function ee(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).",Te("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 ot(e);case"playwright-install-failed":return["Playwright browser install failed \u2014 Chromium is still missing.","Run `npx playwright install chromium` and check its output for network, proxy, or disk-space errors."].join(`
|
|
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 j(e.error)}}function ot(e){let n=e.missingEnvFiles.length===0?[]:["Declared env files not found:",...e.missingEnvFiles.map(t=>` ${t}`),"In a git worktree? Env files aren't copied from the main checkout \u2014 recreate them, or symlink to a shared file outside the working tree."];return["Env config invalid:",...e.issues.map(t=>` ${t}`),"Add the missing values to the env files declared in .ripplo/project.json.",...n].join(`
|
|
10
|
-
`)}import{err as st,ok as lt}from"neverthrow";import{z as ne}from"zod";var it="https://ripplo.ai";function Xe(){return en().RIPPLO_SERVER_URL}function Ze(){return en().RIPPLO_PROJECT_ID}var at=ne.object({RIPPLO_PROJECT_ID:ne.string().min(1).optional(),RIPPLO_SERVER_URL:ne.string().min(1).default(it)}),Ye;function en(){return Ye??=at.parse(process.env),Ye}import nn from"fs";import te from"path";function tn(e){let n=nn.realpathSync(e),t=n,r=te.dirname(t);for(;r!==t;){if(nn.existsSync(te.join(t,".git")))return t;t=r,r=te.dirname(t)}return n}function rn(e){return X(e).andThen(n=>N().andThen(t=>{let r=Xe(),o=we(r);return o==null?st({kind:"not-authenticated"}):lt({appUrl:t.appUrl,cwd:tn(e),engineUrl:t.engineUrl,projectId:Ze()??n.projectId,ripploServerUrl:r,token:o,tunnelAuth:void 0,webhookSecret:t.webhookSecret})}))}import dt from"p-queue";var ct=4,ut={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},D=new dt({concurrency:ct}),R={headedActive:0,interactiveActive:0,interactiveQueued:0},on={current:null};function hi({headed:e,task:n,workClass:t}){let r=ut[t];return t==="p3-explore"?D.add(n,{priority:r}):(R.interactiveQueued+=1,q(),D.add(()=>pt({headed:e,task:n}),{priority:r}))}function Ri(e){!Number.isFinite(e)||e<1||(D.concurrency=Math.floor(e),q())}function re(){return{active:R.interactiveActive,headedActive:R.headedActive,poolSize:D.concurrency,queued:R.interactiveQueued}}function ki(e){on.current=e}async function pt({headed:e,task:n}){R.interactiveQueued-=1,R.interactiveActive+=1,R.headedActive+=e?1:0,q();try{return await n()}finally{R.interactiveActive-=1,R.headedActive-=e?1:0,q()}}function q(){on.current?.()}import oe from"fs";import ie from"path";function an(e){try{let n=ft(e);if(n==null)return;let t=ie.join(n,"HEAD"),r=oe.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 ft(e){let n=ie.join(e,".git");if(oe.statSync(n).isDirectory())return n;let r=oe.readFileSync(n,"utf8").trim(),o="gitdir:";if(!r.startsWith(o))return;let i=r.slice(o.length).trim();if(i.length!==0)return ie.resolve(e,i)}import sn from"crypto";import{readFile as ln}from"fs/promises";import dn from"path";import{graphql as ae}from"gql.tada";import{err as yt,ok as gt}from"neverthrow";var mt=ae(`
|
|
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 $i(e,n){let t=await A(e);if(t.isErr())return yt({error:t.error,kind:"compilation-failed"});let r=await _({config:n,cwd:e,lockfile:t.value});return gt({devSessionId:r.devSessionId,lockfile:t.value})}async function _(e){let n=be(e.lockfile);return St({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:n})}var ht=ae(`
|
|
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
|
-
`),Rt=ae(`
|
|
46
|
-
mutation AnnounceDevSessionActive($projectId: String!, $cwd: String!) {
|
|
47
|
-
announceDevSessionActive(projectId: $projectId, cwd: $cwd)
|
|
48
|
-
}
|
|
49
|
-
`);async function Ui(e){let n=await cn(e.cwd);if(n!=null){let t=sn.createHash("sha256").update(n).digest("hex"),o=(await u({config:e.config,document:ht,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:Rt,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null),{devSessionId:o.id,hash:t,hooksPaused:o.hooksPaused}}return _(e)}function kt(e){return sn.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function St({config:e,cwd:n,fixtures:t,payload:r}){let o=kt(r),i=an(n),s=await cn(n),a=await wt(n,t),c=await u({config:e,document:mt,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 wt(e,n){let t=Object.entries(n);return Promise.all(t.map(async([r,o])=>({contentBase64:(await ln(dn.join(e,T,r))).toString("base64"),sha256:o.sha256})))}async function cn(e){try{return await ln(dn.join(e,Ie),"utf8")}catch{return null}}import{randomUUID as Wt}from"crypto";import{createId as Bt}from"@paralleldrive/cuid2";import{CancellationTokenSource as Vt,ResponseError as Kt}from"vscode-jsonrpc/node";import{graphql as vt}from"gql.tada";var xt=vt(`
|
|
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 un(e){try{let t=(await u({config:e.config,document:xt,variables:bt(e)})).createRun;return t==null?H({detail:"create-run-null",type:"generic"}):t.__typename==="MutationCreateRunSuccess"?null:t.__typename==="LimitExceededError"?H({code:t.code,type:"limit"}):H({detail:t.__typename,type:"generic"})}catch(n){return Et(n)}}function bt({executor:e,lockfileHash:n,runId:t,target:r}){return{clientVersion:P(),executor:e,id:t,lockfileHash:n,target:e==="cloud"?"tunnel":void 0,testId:r.testId,workflowId:r.workflowId}}function H(e){return{kind:"dispatch-error",reason:e}}function Et(e){return e instanceof ke?{detail:e.message,kind:"infra-error"}:H({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{graphql as It}from"gql.tada";async function pn(e,n){let r=(await u({config:e,document:Pt,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 Pt=It(`
|
|
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 Ct}from"vscode-jsonrpc/node";function se(e){return`${e.workflowSlug}/${e.testSlug}`}function fn(e){let{headed:n,inflight:t,jobId:r,lockfileHashValue:o,onExpire:i,runId:s,selection:a,timeoutMs:c}=e,d=se(a),p=`${d}@${o}@${String(n)}`,l=t.get(p);if(l!=null)return l.jobIds.add(r),null;let y={cancellation:new Ct,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(()=>{W(t,y),i(y)},c),t.set(p,y),y}function W(e,n){n.timer!=null&&(clearTimeout(n.timer),n.timer=null),e.delete(n.inflightKey)}function le(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 yn(e,n){[...e.values()].filter(t=>t.jobIds.has(n)).forEach(t=>{t.jobIds.delete(n),t.jobIds.size===0&&(W(e,t),t.cancellation.cancel())})}import{err as de,ok as gn}from"neverthrow";function hn({all:e,ids:n,lockfile:t}){if(e&&n.length>0)return de({kind:"conflicting-flags"});if(e)return gn(t.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>m(s))));if(n.length===0)return de({kind:"nothing-selected"});let r=n.map(i=>({id:i,refs:At(t,i)})),o=r.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?de({kind:"unknown-ids",known:Tt(t),unknown:o}):gn([...new Set(r.flatMap(i=>i.refs))])}function Rn(e,n){let t=new Map(I(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 Tt(e){return e.workflows.map(n=>g(n.name))}function At(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)):I(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 ce,ok as Sn}from"neverthrow";import{graphql as wn}from"gql.tada";import{execFileSync as jt}from"child_process";var Ft=256*1024*1024;function B(e,n){return jt("git",[...e],{cwd:n,encoding:"utf8",maxBuffer:Ft,stdio:["ignore","pipe","pipe"]})}async function vn({config:e,cwd:n,lockfile:t}){await $t({config:e,cwd:n,lockfile:t});let r=await Ot(e);if(r.isErr())return ce(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?ce({kind:"scope-empty"}):Sn(i)}var Mt=wn(`
|
|
97
|
-
mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
98
|
-
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
99
|
-
__typename
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
`);async function $t({config:e,cwd:n,lockfile:t}){let r=new Set(Nt(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:Mt,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{f.warn({err:i},"auto-scope of dirty tests failed")})}var Ut=wn(`
|
|
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 Ot(e){try{let t=(await u({config:e,document:Ut,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return Sn(t.flatMap(r=>r.workflow==null?[]:[r.workflow.slug]))}catch(n){return ce({detail:n instanceof Error?n.message:String(n),kind:"scope-fetch-failed"})}}var kn=".ripplo/workflows/";function Nt(e){try{return B(["status","--porcelain","--",".ripplo/workflows"],e).split(`
|
|
119
|
-
`).map(n=>n.slice(3).trim()).filter(n=>n.startsWith(kn)&&n.endsWith(".ts")).map(n=>n.slice(kn.length)).filter(n=>n!=="index.ts"&&!n.endsWith("/index.ts"))}catch{return[]}}import{graphql as Lt}from"gql.tada";var Dt=2e3,qt=Lt(`
|
|
120
|
-
query DaemonCloudRunStatus($runId: String!) {
|
|
121
|
-
run(id: $runId) {
|
|
122
|
-
status
|
|
123
|
-
failureReason
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
`);function bn({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 _t(e,r).catch(()=>"unknown");if(!(i||o.aborted)){if(!a&&(d==="running"||xn(d))&&(a=!0,t()),xn(d)){i=!0,n(Ht(d));return}s=setTimeout(()=>{c()},Dt)}};return c(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function _t(e,n){let r=(await u({config:e,document:qt,variables:{runId:n}})).run?.status;return r??"unknown"}function xn(e){return e==="passed"||e==="failed"||e==="warning"||e==="cancelled"||e==="unready"}function Ht(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 Jt=12e4,zt=-32099,ue=new Set,En=new Map;function ba(e){ue.add(e)}function Qt(e){let n=new AbortController;return e.isCancellationRequested?(n.abort(),n.signal):(e.onCancellationRequested(()=>{n.abort()}),n.signal)}function Ea(e){let n={...e,inflight:new Map,jobs:new Map};return{claim:t=>er(n,t),handleConnection:t=>{Gt(n,t)},idle:()=>Cn(n)}}function Gt(e,n){let t=De(n);t.onRequest(He,(r,o)=>Yt({connection:t,ctx:e,params:r,token:o})),t.onRequest(We,()=>{let r=re();return{active:r.active,queued:r.queued,sseHealth:e.sseHealth(),version:P(),...e.explorationStatus()}}),t.onRequest(Be,()=>{let r=Cn(e);return r&&e.onShutdownRequest(),r}),t.onClose(()=>{Xt(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 Cn(e){let n=re();return e.jobs.size===0&&n.active===0&&n.queued===0}async function Yt({connection:e,ctx:n,params:t,token:r}){let o=qe.safeParse(t);if(!o.success)throw In({code:"bad-message"});await n.ready;let i=await tr({config:n.config,cwd:n.cwd,message:o.data});if(i.kind==="error")throw In(i.error);let s=Wt(),a=new Vt;return r.onCancellationRequested(()=>{Tn(n,s)}),n.jobs.set(s,{cancellation:a,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),ur({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 In(e){return new Kt(zt,e.code,e)}function Tn(e,n){let t=e.jobs.get(n);t!=null&&(t.cancellation.cancel(),e.jobs.delete(n),yn(e.inflight,n))}function Xt(e,n){[...e.jobs.entries()].filter(([,t])=>t.connection===n).forEach(([t])=>{Tn(e,t)})}function An(e,n,t){let r=e.jobs.get(n);r!=null&&(Pn(()=>r.connection.sendNotification(Ve,{event:t,jobId:n})),t.kind==="test-outcome"&&(Zt(r,t.outcome.kind),r.passed+r.failed+r.notRun>=r.total&&(Pn(()=>r.connection.sendNotification(Ke,{failed:r.failed,jobId:n,notRun:r.notRun,passed:r.passed})),e.jobs.delete(n))))}function Pn(e){Promise.resolve().then(e).catch(n=>{f.warn({err:n},"ipc notification failed")})}function Zt(e,n){if(n==="pass"){e.passed+=1;return}if(n==="dispatch-error"||n==="dispatch-timeout"||n==="infra-error"){e.notRun+=1;return}e.failed+=1}function b(e,n,t){n.jobIds.forEach(r=>{An(e,r,t)})}function er(e,n){let t=le(e.inflight,n);return t==null?null:{headed:t.headed,token:t.cancellation.token,finished:(r,o)=>{e.inflight.delete(t.inflightKey),b(e,t,{kind:"test-outcome",outcome:o,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},started:()=>{b(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}}}function nr(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 tr({config:e,cwd:n,message:t}){return(await Pe(n)).match(o=>rr({config:e,cwd:n,lockfile:o,message:t}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...nr(o)]},kind:"error"}))}async function rr({config:e,cwd:n,lockfile:t,message:r}){let o=await ar(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=xe(t);if(!ue.has(i)){let a=await sr({config:e,cwd:n,lockfile:t});if(a!=null)return{error:{code:"sync-failed",detail:a},kind:"error"};ue.add(i)}return(await lr({config:e,cwd:n,lockfile:t,message:r})).match(async a=>({kind:"ready",lockfileHashValue:i,selections:Rn(t,a),targetsByClaimKey:await or({config:e,cwd:n,hash:i})}),a=>Promise.resolve({error:a,kind:"error"}))}async function or({config:e,cwd:n,hash:t}){let r=En.get(t);if(r!=null)return r;let o=await pn(e,n);return En.set(t,o),o}var ir=2e3;async function ar(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(ir)}),null}catch(n){return n instanceof Error?n.message:String(n)}}async function sr(e){try{return await _(e),null}catch(n){return n instanceof Error?n.message:String(n)}}async function lr({config:e,cwd:n,lockfile:t,message:r}){return!r.all&&r.tests.length===0?(await vn({config:e,cwd:n,lockfile:t})).mapErr(dr):hn({all:r.all,ids:r.tests,lockfile:t}).mapErr(cr)}function dr(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function cr(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 ur(e){await e.selections.reduce((n,t)=>n.then(()=>pr(e,t)),Promise.resolve())}async function pr(e,n){let{ctx:t,headed:r,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:a}=e;if(a.isCancellationRequested)return;let c=se(n),d=s.get(c);if(d==null){An(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=fn({headed:r,inflight:t.inflight,jobId:o,lockfileHashValue:i,runId:Bt(),selection:n,timeoutMs:Jt,onExpire:y=>{b(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 fr(t,d,p.runId,i);if(l!=null){W(t.inflight,p),b(t,p,{kind:"test-outcome",outcome:l,runId:"",testName:n.testName,workflowName:n.workflowName});return}t.executor==="cloud"&&yr(t,p)}function fr(e,n,t,r){return un({config:e.config,executor:e.executor,lockfileHash:r,runId:t,target:n})}function yr(e,n){let t=le(e.inflight,n.runId);t!=null&&bn({config:e.config,runId:t.runId,signal:Qt(t.cancellation.token),onComplete:r=>{e.inflight.delete(t.inflightKey),b(e,t,{kind:"test-outcome",outcome:r,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},onStarted:()=>{b(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}})}import gr from"fs";import mr from"path";async function Ma(e){let n=mr.join(e,".ripplo","index.ts");if(!gr.existsSync(n))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let t=await A(e);return t.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:j(t.error),path:".ripplo/"}],valid:!1,warnings:[]}:N().match(r=>({appUrl:r.appUrl,engineUrl:r.engineUrl,errors:[],valid:!0,warnings:[]}),r=>({appUrl:void 0,engineUrl:void 0,errors:[{message:ee(r),path:""}],valid:!1,warnings:[]}))}async function $a(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 Ua({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 Sr from"fs";import hr from"fs";import pe from"path";var Rr=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function jn(e){let n=kr(e);return n==null?!1:Rr.some(t=>hr.existsSync(pe.join(n,t)))}function kr(e){try{let n=B(["rev-parse","--git-dir"],e).trim();return n.length===0?null:pe.isAbsolute(n)?n:pe.resolve(e,n)}catch{return null}}function wr(e){return Se(e,"hooks-paused")}function Va(e){return Sr.existsSync(wr(e))||jn(e)?!1:Ae(e)}import{createMessageConnection as Fn,IPCMessageReader as Mn,IPCMessageWriter as $n,NotificationType as vr,NotificationType0 as Un,RequestType as On,RequestType0 as xr}from"vscode-jsonrpc/node";import{z as h}from"zod";var Ya=h.object({headed:h.boolean(),runId:h.string().min(1),testRef:h.string().min(1)}),Xa=h.object({lockfileJson:h.string().optional(),unavailable:h.string().optional()}),Za=h.object({runId:h.string().min(1),span:ve}),es=h.object({outcome:_e,serverNotified:h.boolean()}),ns=new Un("worker/ready"),ts=new On("worker/run"),rs=new xr("worker/lockfile"),os=new On("worker/exploreTrail"),is=new vr("worker/span"),as=new Un("worker/shutdown");function ss(e){let n=Fn(new Mn(e),new $n(e));return n.listen(),n}function ls(){let e=Fn(new Mn(process),new $n(process));return e.listen(),e}import{graphql as w}from"gql.tada";import{gzip as jr}from"zlib";import{promisify as Fr}from"util";import{existsSync as qn,readFileSync as _n}from"fs";import ge from"path";import{graphql as E}from"gql.tada";function Nn(e){return[e.kind,e.target,e.value].filter(n=>n.length>0).join(" ")}var br={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},Er={"data-rule":"dataRule","page-rule":"pageRule",step:"step"},Ir={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 Ln(e){return e.kind==="consistency"?{consistency:{mismatch:Tr(e.mismatch),pending:e.pending}}:e.kind==="pending-check"?{pendingCheck:{budget:e.budget,source:Er[e.source.kind],...Pr(e.source)}}:e.kind==="unrunnable"?{unrunnable:{reason:br[e.reason]}}:e.kind==="driver-error"?{driverError:{errorKind:Ir[e.error.kind],message:Ar(e.error)}}:{impossibleAction:{subject:Cr(e.step.action)}}}function Pr(e){return"check"in e?Dn(e.check,!1):{checkKind:void 0,expected:void 0,negated:void 0,subject:void 0}}function Dn(e,n){return e.kind==="not"?Dn(e.inner,!n):e.kind==="browser"?{checkKind:"browser",expected:e.value??void 0,negated:n,subject:z(e.key)}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:n,subject:C(e.locator)}:{checkKind:e.kind,expected:void 0,negated:n,subject:C(e.locator)}}function Cr(e){let n=e.locator==null?e.url??"":C(e.locator);return`${e.kind} ${n}`.trim()}function Tr(e){return e.kind==="wrong-value"?{wrongValue:{entity:e.entity,field:e.field,key:e.key,snapshot:S(e.snapshot),sut:S(e.sut)}}:e.kind==="expected-change"?{expectedChange:{entity:e.entity,field:e.field,key:e.key,value:S(e.value)}}:e.kind==="singleton-mismatch"?{singletonMismatch:{singleton:e.singleton,snapshot:S(e.snapshot),sut:S(e.sut)}}:e.kind==="unexpected-row"?{unexpectedRow:{entity:e.entity,key:e.key}}:e.kind==="browser-mismatch"?{singletonMismatch:{singleton:z(e.key),snapshot:S(e.snapshot),sut:S(e.sut)}}:{missingRow:{entity:e.entity,key:e.key}}}function S(e){return e==null?null:String(e)}function Ar(e){return"message"in e?e.message:"detail"in e?e.detail:null}async function Mr({config:e,cwd:n,fixturesDir:t,headed:r,lockfile:o,runId:i,session:s,signal:a,test:c}){if(!await no(e,i))return{outcome:{kind:"dispatch-failed",reason:"already-claimed",runId:i},persisted:Promise.resolve()};let p=ge.join(n,".ripplo","debug"),l=[];return(await s.runOnce({capture:!0,lockfile:o,onPhase:void 0,options:{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:t,generate:x,headed:r,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth},params:void 0,runId:i,sequence:void 0,test:c,onEvent:k=>{l.push(k)}},a)).match(async k=>{let v=Hn(l),J=v.flatMap(zn=>zn.findings),Re=$r(J);if(Re!=null)return await fe({config:e,debugDir:p,events:l,recordingOptional:!0,runId:i,stepSources:void 0}),{outcome:{error:Re,kind:"error",runId:i},persisted:Promise.resolve()};await Vn(e,i,v);let Jn=fe({config:e,debugDir:p,events:l,recordingOptional:!0,runId:i,stepSources:void 0}).then(()=>{});return{outcome:J.length>0?{findings:J,kind:"findings",runId:i}:{kind:"pass",runId:i},persisted:Jn}},k=>Promise.resolve({outcome:{error:k,kind:"error",runId:i},persisted:Promise.resolve()}))}function $r(e){let n=e.find(t=>t.kind==="driver-error"&&je(t.error));return n!=null&&n.kind==="driver-error"?n.error:void 0}async function me(e){let n=await fe(e);await Vn(e.config,e.runId,n)}async function fe({config:e,debugDir:n,events:t,recordingOptional:r,runId:o,stepSources:i}){let s=Hn(t),a=Or(n,o);if(a==null&&!r)throw new Error("recording-missing");return await Promise.all([Br({aliases:[...Dr(t),...qr(s)],config:e,generated:_r(t),generatedSingletons:Hr(t),origin:a==null?Ur(s):a.origin,records:s,rrwebEvents:a==null?[]:a.events,runId:o,stepSources:i}),a==null?Promise.resolve():eo(e,o,a)]),s}function Ur(e){return e.reduce((n,t)=>Math.min(n,t.startMs),e[0]?.startMs??0)}function Hn(e){return e.flatMap(n=>n.kind==="step"?[{annotations:n.annotations,endMs:n.endMs,findings:n.findings,index:n.index,source:n.source,startMs:n.startMs,state:n.state,url:n.url}]:[])}function Or(e,n){let t=ge.join(e,n,"behavior.jsonl");if(!qn(t))return null;let r=_n(t,"utf8").split(`
|
|
127
|
-
`).filter(i=>i.length>0).map(i=>Nr(i)).flatMap(i=>Lr(i)?[i.event]:[]),o=r[0];return o==null?null:{events:r,origin:o.timestamp}}function Nr(e){return JSON.parse(e)}function Lr(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function Dr(e){return e.flatMap(n=>n.kind==="world"?n.aliases:[])}function qr(e){return e.flatMap(n=>{let t=Wr(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 _r(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generated.map(t=>Wn(t)):[]))}function Wn({entity:e,field:n,key:t}){return`${e}\0${t}\0${n}`}function Hr(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generatedSingletons:[]))}function Wr(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 Br({aliases:e,config:n,generated:t,generatedSingletons:r,origin:o,records:i,rrwebEvents:s,runId:a,stepSources:c}){let d=i.map((p,l)=>zr({aliases:e,generated:t,generatedSingletons:r,origin:o,record:p,rrwebEvents:s,sourceTest:c?.[l]??null}));await u({config:n,document:ro,variables:{items:[{runId:a,steps:d}]}})}var Vr=3,Kr=0;function Jr({endMs:e,rrwebEvents:n,startMs:t}){let r=n.find(o=>o.type===Vr&&o.data?.source===Kr&&o.timestamp>=t&&o.timestamp<=e);return r==null?t:r.timestamp}function zr({aliases:e,generated:n,generatedSingletons:t,origin:r,record:o,rrwebEvents:i,sourceTest:s}){let a=Ee(o.source,o.index),c=Jr({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=>Ln(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=>Qr({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:Nn(a),url:o.url}}function Qr({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(Wn({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 Gr=Fr(jr);async function Bn(e,n){await u({config:e,document:ao,variables:{runIds:[n]}})}var Yr="application/x-ndjson";async function Xr({config:e,debugDir:n,runId:t}){let r=ge.join(n,t,"behavior.jsonl");if(qn(r))try{let o=await u({config:e,document:Zr,variables:{runId:t}}),i=await fetch(o.debugArtifactUploadUrl,{body:_n(r),headers:{"content-type":Yr},method:"PUT"});if(!i.ok){f.warn({runId:t,status:i.status},"behavior upload PUT failed");return}await Bn(e,t)}catch(o){f.warn({error:o,runId:t},"behavior upload failed")}}var Zr=E(`
|
|
128
|
-
mutation DebugArtifactUploadUrl($runId: String!) {
|
|
129
|
-
debugArtifactUploadUrl(runId: $runId)
|
|
130
|
-
}
|
|
131
|
-
`);async function eo(e,n,t){let r=t.events.map(s=>JSON.stringify(s)).join(`
|
|
132
|
-
`),o=await Gr(Buffer.from(r,"utf8")),i=t.events.at(-1);await u({config:e,document:oo,variables:{input:{bodyBase64:o.toString("base64"),chunkIndex:0,endTimestamp:Math.max(0,(i?.timestamp??t.origin)-t.origin),eventCount:t.events.length,runId:n,startTimestamp:0}}})}async function Vn(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:io,variables:{items:[{duration:i,failCount:r,passCount:o,runId:n,status:r>0?"failed":"passed",summary:null,warnCount:0}]}})}async function no(e,n){return((await u({config:e,document:to,variables:{runIds:[n]}})).startRunsBatch??[]).some(r=>r.id===n)}var to=E(`
|
|
133
|
-
mutation StartRunsBatch($runIds: [String!]!) {
|
|
134
|
-
startRunsBatch(runIds: $runIds) {
|
|
135
|
-
id
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
`),ro=E(`
|
|
139
|
-
mutation SubmitRunStepsBatch($items: [SubmitRunStepsItem!]!) {
|
|
140
|
-
submitRunStepsBatch(items: $items)
|
|
141
|
-
}
|
|
142
|
-
`),oo=E(`
|
|
143
|
-
mutation SubmitRunRecordingChunk($input: SubmitRunRecordingChunkInput!) {
|
|
144
|
-
submitRunRecordingChunk(input: $input)
|
|
145
|
-
}
|
|
146
|
-
`),io=E(`
|
|
147
|
-
mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
|
|
148
|
-
completeRunsBatch(items: $items) {
|
|
149
|
-
id
|
|
150
|
-
status
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
`),ao=E(`
|
|
154
|
-
mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
|
|
155
|
-
markRunArtifactsUploadedBatch(runIds: $runIds)
|
|
156
|
-
}
|
|
157
|
-
`);function so(e){let n=e.trail;if(!(n==null||!lo(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 lo(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:k}){await u({config:o,document:mo,variables:{branchName:n??null,commitSha:r??null,devSessionId:s??null,lockfileHash:c??null,projectId:o.projectId,reproJson:d,runId:p,spec:y??null}}),await me({config:o,debugDir:i,events:a,recordingOptional:!0,runId:p,stepSources:k}),await u({config:o,document:ho,variables:{baseState:e,category:t,projectId:o.projectId,reproRunId:p,signature:l}})}async function V(e,n,t){return(await u({config:e,document:Ro,variables:{lockfileHash:t,projectId:e.projectId,signature:n}})).exploreFindingExists}async function co({attempts:e,config:n,devSessionId:t,findings:r,trail:o}){await u({config:n,document:yo,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 uo(e,n,t){let r=await u({config:e,document:po,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 po=w(`
|
|
158
|
-
query ExploreScope($devSessionId: String!) {
|
|
159
|
-
exploreScope(devSessionId: $devSessionId)
|
|
160
|
-
}
|
|
161
|
-
`);async function fo(e,n){return(await u({config:e,document:go,variables:{devSessionId:n}}).catch(r=>(f.warn({error:r},"reportExploreUnhealthy failed"),null)))?.reportExploreUnhealthy??!1}var yo=w(`
|
|
162
|
-
mutation RecordExplorationProgress(
|
|
163
|
-
$devSessionId: String!
|
|
164
|
-
$attempts: Int!
|
|
165
|
-
$findings: Int!
|
|
166
|
-
$trail: ExploreTrailInput
|
|
167
|
-
) {
|
|
168
|
-
recordExplorationProgress(
|
|
169
|
-
devSessionId: $devSessionId
|
|
170
|
-
attempts: $attempts
|
|
171
|
-
findings: $findings
|
|
172
|
-
trail: $trail
|
|
173
|
-
)
|
|
174
|
-
}
|
|
175
|
-
`),go=w(`
|
|
176
|
-
mutation ReportExploreUnhealthy($devSessionId: String!) {
|
|
177
|
-
reportExploreUnhealthy(devSessionId: $devSessionId)
|
|
178
|
-
}
|
|
179
|
-
`),mo=w(`
|
|
180
|
-
mutation CreateExploreRun(
|
|
181
|
-
$projectId: String!
|
|
182
|
-
$runId: String!
|
|
183
|
-
$devSessionId: String
|
|
184
|
-
$branchName: String
|
|
185
|
-
$commitSha: String
|
|
186
|
-
$lockfileHash: String
|
|
187
|
-
$spec: String
|
|
188
|
-
$reproJson: String
|
|
189
|
-
) {
|
|
190
|
-
createExploreRun(
|
|
191
|
-
projectId: $projectId
|
|
192
|
-
runId: $runId
|
|
193
|
-
devSessionId: $devSessionId
|
|
194
|
-
branchName: $branchName
|
|
195
|
-
commitSha: $commitSha
|
|
196
|
-
lockfileHash: $lockfileHash
|
|
197
|
-
spec: $spec
|
|
198
|
-
reproJson: $reproJson
|
|
199
|
-
) {
|
|
200
|
-
id
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
`),ho=w(`
|
|
204
|
-
mutation SubmitExploreFinding(
|
|
205
|
-
$projectId: String!
|
|
206
|
-
$signature: String!
|
|
207
|
-
$baseState: String!
|
|
208
|
-
$category: ExploreFindingCategory!
|
|
209
|
-
$reproRunId: String!
|
|
210
|
-
) {
|
|
211
|
-
submitExploreFinding(
|
|
212
|
-
projectId: $projectId
|
|
213
|
-
signature: $signature
|
|
214
|
-
baseState: $baseState
|
|
215
|
-
category: $category
|
|
216
|
-
reproRunId: $reproRunId
|
|
217
|
-
) {
|
|
218
|
-
id
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
`),As=w(`
|
|
222
|
-
mutation SetExploreFindingStatus(
|
|
223
|
-
$projectId: String!
|
|
224
|
-
$signature: String!
|
|
225
|
-
$status: ExploreFindingStatus!
|
|
226
|
-
) {
|
|
227
|
-
setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
|
|
228
|
-
}
|
|
229
|
-
`),Ro=w(`
|
|
230
|
-
query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
|
|
231
|
-
exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
|
|
232
|
-
}
|
|
233
|
-
`);import{graphql as Kn}from"gql.tada";async function ko(e,n,t){await u({config:e,document:So,variables:{reason:t,runId:n}}).catch(r=>{f.error(r,"failRun submission failed")})}var So=Kn(`
|
|
234
|
-
mutation FailRun($runId: String!, $reason: String!) {
|
|
235
|
-
failRun(runId: $runId, reason: $reason)
|
|
236
|
-
}
|
|
237
|
-
`),$s=Kn(`
|
|
238
|
-
mutation MarkRunUnready($runId: String!, $cause: RunUnreadyCause!) {
|
|
239
|
-
markRunUnready(runId: $runId, cause: $cause)
|
|
240
|
-
}
|
|
241
|
-
`);import{randomUUID as wo}from"crypto";async function vo({assign:e,config:n,debugDir:t,devSessionId:r,fixturesDir:o,headed:i,lockfile:s,report:a,session:c,signal:d}){let p=Me(s);if(e.stepRuns.length===0)return{kind:"error",reason:"empty-trail"};let l=jo(p,e.stepRuns),y=await Ne({baseState:{name:m(e.baseStateTest),test:e.baseStateTest},corpus:p,lockfile:s,options:{baseUrl:n.appUrl,engineUrl:n.engineUrl,fixturesDir:o,generate:x,headed:i,secret:n.webhookSecret,tunnelAuth:n.tunnelAuth},seenSignature:a?v=>V(n,v,e.lockfileHash):void 0,session:c,stepRuns:e.stepRuns,runIdFor:v=>`explore-${wo()}-${String(v)}`},d),k=a?await Co({baseStateTest:e.baseStateTest,config:n,debugDir:t,devSessionId:r,lockfileHash:e.lockfileHash,outcome:y,reproJson:Io(p,e),stepSources:Po(l)}):!1;return Eo(y,l.length),Fo(y,k,xo(l,e,y))}function xo(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(K(t.timing.detect)+(r==null?0:K(r))),signature:t.kind==="finding"?t.signature:void 0,steps:bo(e)}}function bo(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(r=>({test:t,text:r}))})}function K(e){return e.engineMs+e.worldMs+e.browserMs+e.driveMs+e.teardownMs}function Eo(e,n){if(e.kind==="error"){f.info({detail:Fe(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:K(r),detectMs:K(t),driveMs:t.driveMs,engineMs:t.engineMs,kind:e.kind,steps:n,teardownMs:t.teardownMs,worldMs:t.worldMs},"explore trail")}function Io(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 Po(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(()=>t)})}async function Co({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 V(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:To(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:Ao(e,i.captureEvents),stepSources:a}).catch(c=>{f.warn({error:c},"explore finding report failed")}),!0)}function To(e){return e==="data-rule"?"dataRule":e==="page-rule"?"pageRule":e}function Ao(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 jo(e,n){return n.flatMap(t=>{let r=e[t.idx];return r==null?[]:[{actions:[...r.nav,...r.steps].map(o=>$e(o.action)),label:`${r.test}#${String(r.index)}`}]})}function Fo(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 Mo from"path";import{randomUUID as $o}from"crypto";async function nl({cwd:e,onReady:n,signal:t,step:r,target:o}){let i=rn(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 Ce(e);if(a.result.isErr())return{error:a.result.error,kind:"compile-failed"};let c=a.result.value,d=await Uo(c,o);return d.kind!=="ok"?d:(await Ue({lockfile:c,onReady:n,options:Oo(s),runId:`teleport-${$o()}`,sequence:d.sequence,stopAfterStep:r,test:d.test},t)).match(l=>({kind:"done",result:l}),l=>({error:l,kind:"run-failed"}))}async function Uo(e,n){if(n.kind==="explore"){let r=await Le(e,n.repro);return r.kind==="unplannable"?{kind:"unplannable"}:{kind:"ok",sequence:r.sequence,test:r.baseTest}}let t=I(e).find(r=>r.ref===n.ref);return t==null?{kind:"no-test",ref:n.ref}:{kind:"ok",sequence:Oe(e,t.test,void 0),test:t.test}}function Oo(e){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:Mo.join(e.cwd,T),generate:x,headed:!0,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth}}export{Ho as a,Go as b,N as c,tt as d,ti as e,ee as f,Xe as g,en as h,rn as i,B as j,jn as k,Ma as l,$a as m,Ua as n,wr as o,Va as p,Ya as q,Za as r,es as s,ns as t,ts as u,rs as v,os as w,is as x,as as y,ss as z,ls as A,hi as B,Ri as C,re as D,ki as E,an as F,$i as G,_ as H,Ui as I,ba as J,Qt as K,Ea as L,Mr as M,Xr as N,ko as O,so as P,co as Q,uo as R,fo as S,vo as T,nl as U};
|