ripplo 0.7.29 → 0.7.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-MJXQ6SVH.js +164 -0
- package/dist/chunk-WJ7CHQ7B.js +228 -0
- package/dist/daemon-EWT54KJZ.js +90 -0
- package/dist/{daemon-W57NHXDG.js → daemon-PU4XNBMZ.js} +1 -1
- package/dist/index.js +2 -2
- package/package.json +5 -5
- package/dist/chunk-RJNO37CR.js +0 -220
- package/dist/chunk-UODLSLH7.js +0 -164
- package/dist/daemon-SACK4YJZ.js +0 -94
package/dist/chunk-RJNO37CR.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{J as We,M as Be,a as O,d as Ne,f as Oe,g as Ue,h as _e,i as h,j as De,k as S,l as A,m as qe,p as E,u as He}from"./chunk-UODLSLH7.js";import{b as $e,d as m,e as g,g as Me,h as w,i as Le}from"./chunk-5VRJXHWH.js";import Je from"fs";import H from"path";import{config as ut}from"dotenv";import{z as D}from"zod";import{err as pt,ok as Ke}from"neverthrow";import _ from"fs";import oe from"path";import{err as te,ok as Ve}from"neverthrow";import{z as U}from"zod";var st=oe.join(".ripplo","project.json"),re=[".env",".env.local"],lt=U.object({envFiles:U.array(U.string().min(1)).optional(),projectId:U.string().min(1)});function ze(e){return oe.join(e,st)}function ie(e){let n=ze(e);return _.existsSync(n)?dt(n).andThen(t=>{let r=lt.safeParse(t);return r.success?Ve({envFiles:r.data.envFiles??re,projectId:r.data.projectId}):te({issues:r.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:n})}):te({kind:"project-file-missing",path:n})}function ae(e){return ie(e).match(n=>n,()=>{})}function dt(e){try{return Ve(JSON.parse(_.readFileSync(e,"utf8")))}catch(n){return te({issues:[n instanceof Error?n.message:String(n)],kind:"project-file-invalid",path:e})}}function vi({cwd:e,envFiles:n,projectId:t}){let r=ze(e);_.mkdirSync(oe.dirname(r),{recursive:!0});let o={projectId:t};n!=null&&!ct(n)&&(o.envFiles=[...n]),_.writeFileSync(r,JSON.stringify(o,null,2)+`
|
|
3
|
-
`)}function ct(e){return e.length!==re.length?!1:e.every((n,t)=>n===re[t])}function $i(e){let t=ae(e)?.envFiles??[".env",".env.local"],r=H.join(e,".ripplo");t.forEach(o=>{let i=H.resolve(r,o);Je.existsSync(i)&&ut({override:!0,path:i,quiet:!0})}),q=void 0}var ft=D.object({RIPPLO_APP_URL:D.url(),RIPPLO_ENGINE_URL:D.url(),RIPPLO_WEBHOOK_SECRET:D.string().min(1)}),q;function W(){return q!=null?Ke(q):gt().map(e=>(q=e,e))}function mt(e){let t=ae(e)?.envFiles??[],r=H.join(e,".ripplo");return t.map(o=>H.resolve(r,o)).filter(o=>!Je.existsSync(o))}function gt(){let e=ft.safeParse(process.env);if(!e.success)return pt({issues:e.error.issues.map(t=>`${t.path.join(".")}: ${t.message}`),kind:"env-invalid",missingEnvFiles:mt(process.cwd())});let n=e.data;return Ke({appUrl:n.RIPPLO_APP_URL,engineUrl:n.RIPPLO_ENGINE_URL,webhookSecret:n.RIPPLO_WEBHOOK_SECRET})}import{readFileSync as yt}from"fs";import{z as Ge}from"zod";var ht=Ge.object({version:Ge.string()});function B(){let e=yt(new URL("../package.json",import.meta.url),"utf8");return ht.parse(JSON.parse(e)).version}import ue from"fs";import V from"path";import{createJiti as Pt}from"jiti";import{err as M,ok as Ze}from"neverthrow";import Rt from"fs";import T from"path";import b from"typescript";function Qe(e){let n=T.join(e,"index.ts"),t=xt(e);Rt.mkdirSync(T.dirname(t.tsBuildInfoFile??""),{recursive:!0});let r=b.createIncrementalCompilerHost(t),o=b.createIncrementalProgram({host:r,options:t,rootNames:[n]}),i=[...o.getSyntacticDiagnostics(),...o.getSemanticDiagnostics()];o.emit();let s=i.filter(d=>kt(d,e));if(s.length===0)return{diagnostics:[],ok:!0};let l={getCanonicalFileName:d=>d,getCurrentDirectory:()=>T.dirname(e),getNewLine:()=>`
|
|
4
|
-
`};return{diagnostics:b.formatDiagnosticsWithColorAndContext(s,l).split(`
|
|
5
|
-
`).filter(d=>d.length>0),ok:!1}}function kt(e,n){let t=e.file?.fileName;return t==null?!0:t.startsWith(n)}var St=T.join(".local","tsbuildinfo");function xt(e){return{allowImportingTsExtensions:!0,allowJs:!1,esModuleInterop:!0,incremental:!0,module:b.ModuleKind.Preserve,moduleResolution:b.ModuleResolutionKind.Bundler,noEmit:!0,resolveJsonModule:!0,skipLibCheck:!0,strict:!1,target:b.ScriptTarget.ES2022,tsBuildInfoFile:T.join(e,St)}}import{createHash as wt}from"crypto";import Xe from"fs/promises";import se from"path";import{err as v,ok as le,Result as Et}from"neverthrow";var F=".ripplo/fixtures",de=10*1024*1024,ce=50*1024*1024;async function Ye(e,n){let t=bt(n);if(t.length===0)return le({});let r=se.join(e,F),o=await Promise.all(t.map(i=>vt({fixturesRoot:r,name:i})));return Et.combine(o).andThen(It)}function bt(e){let t=e.workflows.flatMap(r=>[...r.steps,...r.tests.flatMap(o=>o.steps)]).flatMap(r=>r.action.kind==="upload"?r.action.files:[]);return[...new Set(t)].toSorted((r,o)=>r.localeCompare(o))}async function vt({fixturesRoot:e,name:n}){if(n.includes("..")||se.isAbsolute(n))return v({kind:"fixture-invalid-name",name:n});let t=se.join(e,n),r=await Xe.lstat(t).catch(()=>null);if(r==null)return v({kind:"fixture-missing",name:n,path:t});if(r.isSymbolicLink())return v({kind:"fixture-symlink",name:n});if(!r.isFile())return v({kind:"fixture-not-file",name:n});let o=await Xe.readFile(t);if(o.byteLength>de)return v({kind:"fixture-too-large",name:n,size:o.byteLength});let i=wt("sha256").update(o).digest("hex");return le([n,{sha256:i,size:o.byteLength}])}function It(e){let n=e.reduce((t,[,r])=>t+r.size,0);return n>ce?v({kind:"fixtures-total-too-large",total:n}):le(Object.fromEntries(e))}var I=".ripplo/ripplo.lock",$;async function en(e){let{result:n}=await pe(e);return n}async function pe(e){let n=jt(V.join(e,".ripplo"));if($!=null&&$.fingerprint===n&&$.result.isOk())return{fingerprint:n,result:$.result};let t=await L(e);return $={fingerprint:n,result:t},{fingerprint:n,result:t}}async function L(e){let n=V.join(e,".ripplo"),t=V.join(n,"index.ts"),r=Qe(n);return r.ok?(await At(t)).andThen(s=>Ft({entryPath:t,exported:s})).match(async s=>(await Ye(e,s)).map(p=>({...s,fixtures:p})).mapErr(p=>({error:p,kind:"fixture-failed"})),s=>Promise.resolve(M(s))):M({diagnostics:r.diagnostics,kind:"typecheck-failed"})}var Ct=new Set([".local","debug","node_modules"]);function jt(e){return nn(e).toSorted((n,t)=>n.localeCompare(t)).join("|")}function nn(e){return(ue.existsSync(e)?ue.readdirSync(e,{withFileTypes:!0}):[]).flatMap(t=>{if(Ct.has(t.name))return[];let r=V.join(e,t.name);if(t.isDirectory())return nn(r);let o=ue.statSync(r);return[`${r}:${String(o.mtimeMs)}:${String(o.size)}`]})}async function At(e){try{let t=await Pt(import.meta.url,{fsCache:!1,moduleCache:!1,sourceMaps:!0}).import(e),r=t!=null&&typeof t=="object"&&"default"in t?Reflect.get(t,"default"):t;return Ze(r)}catch(n){return M({kind:"load-threw",message:Tt(n)})}}function Tt(e){return e instanceof Error?e.message:String(e)}function Ft({entryPath:e,exported:n}){if(n==null||typeof n!="object"||!("lockfile"in n))return M({entryPath:e,kind:"not-ripplo"});let t=Ne.safeParse(Reflect.get(n,"lockfile"));return t.success?Ze(t.data):M({issues:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`),kind:"invalid-lockfile"})}function P(e,n){return n==null?`Load \`/ripplo:${e}\` skill for instructions.`:`Load \`/ripplo:${e}\` skill for instructions on ${n}.`}function na(e){return e.length===1?P(e[0]):`Before proceeding, load the ${e.map(t=>`\`/ripplo:${t}\``).join(" and ")} skills \u2014 every one, each carries rules the others don't.`}function J(e){return[`Compilation failed: ${$t(e)}`,P("create","DSL authoring + lint rules")].join(`
|
|
6
|
-
`)}function aa(){return`${I} is up to date`}function sa(e){return[`${I} is ${e==="missing"?"missing":"out of date"} \u2014 run \`npx ripplo compile\` and commit the result`,P("setup")].join(`
|
|
7
|
-
`)}function la(){return`Wrote ${I}`}function $t(e){switch(e.kind){case"typecheck-failed":return["TypeScript errors in .ripplo/:",...tn(e.diagnostics)].join(`
|
|
8
|
-
`);case"not-ripplo":return`${e.entryPath} must default-export a Ripplo (createRipplo({ entities, singletons, workflows })). Check that the default export is the value returned by createRipplo, not a function or a re-export.`;case"invalid-lockfile":return["Lockfile failed schema validation (stale or hand-edited .ripplo/ripplo.lock?):",...tn(e.issues),"Regenerate with `npx ripplo compile` \u2014 never hand-edit the lockfile."].join(`
|
|
9
|
-
`);case"load-threw":return[`.ripplo/index.ts threw while loading: ${e.message}`,"Usually a bad import or a top-level throw in .ripplo/ \u2014 run `npx ripplo compile` for the stack."].join(`
|
|
10
|
-
`);case"fixture-failed":return Mt(e.error)}}function tn(e,n=8){return e.length<=n?e:[...e.slice(0,n),`\u2026 and ${String(e.length-n)} more`]}function Mt(e){switch(e.kind){case"fixture-missing":return`Fixture "${e.name}" not found at ${e.path} \u2014 add the file under .ripplo/fixtures/ or fix the upload() name.`;case"fixture-invalid-name":return`Invalid fixture name "${e.name}" \u2014 upload() takes a bare name under .ripplo/fixtures/, no .. or absolute paths.`;case"fixture-symlink":return`Fixture "${e.name}" is a symlink \u2014 only regular files are allowed.`;case"fixture-not-file":return`Fixture "${e.name}" is not a regular file.`;case"fixture-too-large":return`Fixture "${e.name}" is ${z(e.size)} \u2014 over the ${z(de)} per-file limit.`;case"fixtures-total-too-large":return`Fixtures total ${z(e.total)} \u2014 over the ${z(ce)} limit.`}}function z(e){return`${String(Math.round(e/(1024*1024)*10)/10)} MB`}var K=class extends Error{failure;constructor(n){super(n.kind),this.name="CliError",this.failure=n}};function ma(e){return e instanceof K?fe(e.failure):e instanceof Error?e.message:String(e)}function fe(e){switch(e.kind){case"project-file-missing":return[`Missing ${e.path} \u2014 this directory is not a Ripplo project.`,"Run `npx ripplo init` to create it (or cd into the project root).",P("setup")].join(`
|
|
11
|
-
`);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(n=>` ${n}`),"Fix the file by hand or re-run `npx ripplo init`."].join(`
|
|
12
|
-
`);case"not-authenticated":return["Not signed in. Run `npx ripplo auth login`.","(Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)"].join(`
|
|
13
|
-
`);case"env-invalid":return Lt(e);case"playwright-install-failed":return["Playwright browser install failed \u2014 Chromium is still missing.","Run `npx playwright install chromium` and check its output for network, proxy, or disk-space errors."].join(`
|
|
14
|
-
`);case"gitdir-unrecognized":return`Unrecognized .git file at ${e.marker} \u2014 expected a directory or a "gitdir:" pointer (worktree). Is the repo corrupted?`;case"gitdir-empty":return`Empty gitdir pointer at ${e.marker} \u2014 the worktree's .git file points nowhere. Re-create the worktree.`;case"oauth-device-code-failed":return[`Could not start sign-in (device-code request failed): ${e.description}`,"Is the Ripplo server reachable? Check RIPPLO_SERVER_URL and retry."].join(`
|
|
15
|
-
`);case"oauth-authorization-failed":return[`Sign-in failed (${e.code}): ${e.description}`,e.code==="expired_token"?"The approval window expired \u2014 run `npx ripplo auth login` again.":"Run `npx ripplo auth login` to retry."].join(`
|
|
16
|
-
`);case"compilation-failed":return J(e.error)}}function Lt(e){let n=e.missingEnvFiles.length===0?[]:["Declared env files not found:",...e.missingEnvFiles.map(t=>` ${t}`),"In a git worktree? Env files aren't copied from the main checkout \u2014 recreate them, or symlink to a shared file outside the working tree."];return["Env config invalid:",...e.issues.map(t=>` ${t}`),"Add the missing values to the env files declared in .ripplo/project.json.",...n].join(`
|
|
17
|
-
`)}import{err as Ut,ok as _t}from"neverthrow";import{z as me}from"zod";var Nt="https://ripplo.ai";function on(){return sn().RIPPLO_SERVER_URL}function an(){return sn().RIPPLO_PROJECT_ID}var Ot=me.object({RIPPLO_PROJECT_ID:me.string().min(1).optional(),RIPPLO_SERVER_URL:me.string().min(1).default(Nt)}),rn;function sn(){return rn??=Ot.parse(process.env),rn}import ln from"fs";import ge from"path";function dn(e){let n=ln.realpathSync(e),t=n,r=ge.dirname(t);for(;r!==t;){if(ln.existsSync(ge.join(t,".git")))return t;t=r,r=ge.dirname(t)}return n}function cn(e){return ie(e).andThen(n=>W().andThen(t=>{let r=on(),o=Le(r);return o==null?Ut({kind:"not-authenticated"}):_t({appUrl:t.appUrl,cwd:dn(e),engineUrl:t.engineUrl,projectId:an()??n.projectId,ripploServerUrl:r,token:o,tunnelAuth:void 0,webhookSecret:t.webhookSecret})}))}import un from"fs";import{checkSync as Dt,lockSync as qt}from"proper-lockfile";var Ht="dev.pid",pn=15e3;function fn(e){return w(e,Ht)}function mn(e){try{return Dt(fn(e),{realpath:!1,stale:pn})}catch{return!1}}var ye=class extends Error{pid;cwd;constructor({cwd:n,pid:t}){super("dev-lock-held"),this.name="DevLockHeldError",this.pid=t,this.cwd=n}};function Ta({cwd:e,onCompromised:n}){Me(e);let t=fn(e),r=Wt({cwd:e,onCompromised:n,path:t});return un.writeFileSync(t,String(process.pid)),()=>{try{r()}catch{}}}function Wt({cwd:e,onCompromised:n,path:t}){try{return qt(t,{realpath:!1,stale:pn,onCompromised:()=>{n()}})}catch(r){throw Bt(r)?new ye({cwd:e,pid:Vt(t)}):r}}function Bt(e){if(!(e instanceof Error)||!("code"in e))return!1;let{code:n}=e;return n==="ELOCKED"}function Vt(e){try{let n=un.readFileSync(e,"utf8").trim(),t=Number.parseInt(n,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}}import zt from"p-queue";var Jt=4,Kt={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},G=new zt({concurrency:Jt}),k={headedActive:0,interactiveActive:0,interactiveQueued:0},gn={current:null};function Ma({headed:e,task:n,workClass:t}){let r=Kt[t];return t==="p3-explore"?G.add(n,{priority:r}):(k.interactiveQueued+=1,Q(),G.add(()=>Gt({headed:e,task:n}),{priority:r}))}function La(e){!Number.isFinite(e)||e<1||(G.concurrency=Math.floor(e),Q())}function he(){return{active:k.interactiveActive,headedActive:k.headedActive,poolSize:G.concurrency,queued:k.interactiveQueued}}function Na(e){gn.current=e}async function Gt({headed:e,task:n}){k.interactiveQueued-=1,k.interactiveActive+=1,k.headedActive+=e?1:0,Q();try{return await n()}finally{k.interactiveActive-=1,k.headedActive-=e?1:0,Q()}}function Q(){gn.current?.()}import Re from"fs";import ke from"path";function yn(e){try{let n=Qt(e);if(n==null)return;let t=ke.join(n,"HEAD"),r=Re.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 Qt(e){let n=ke.join(e,".git");if(Re.statSync(n).isDirectory())return n;let r=Re.readFileSync(n,"utf8").trim(),o="gitdir:";if(!r.startsWith(o))return;let i=r.slice(o.length).trim();if(i.length!==0)return ke.resolve(e,i)}import Xt from"crypto";import{readFile as hn}from"fs/promises";import Rn from"path";import{graphql as Yt}from"gql.tada";import{err as Zt,ok as er}from"neverthrow";var nr=Yt(`
|
|
18
|
-
mutation SyncDevSession(
|
|
19
|
-
$projectId: String!
|
|
20
|
-
$cwd: String!
|
|
21
|
-
$branch: String
|
|
22
|
-
$lockfileContent: String
|
|
23
|
-
$fixtures: [SyncDevFixtureInput!]
|
|
24
|
-
$preconditions: [SyncDevPreconditionInput!]!
|
|
25
|
-
$singletons: [SyncDevSingletonInput!]
|
|
26
|
-
$workflows: [SyncDevWorkflowInput!]!
|
|
27
|
-
) {
|
|
28
|
-
syncDevSession(
|
|
29
|
-
projectId: $projectId
|
|
30
|
-
cwd: $cwd
|
|
31
|
-
branch: $branch
|
|
32
|
-
lockfileContent: $lockfileContent
|
|
33
|
-
fixtures: $fixtures
|
|
34
|
-
preconditions: $preconditions
|
|
35
|
-
singletons: $singletons
|
|
36
|
-
workflows: $workflows
|
|
37
|
-
) {
|
|
38
|
-
id
|
|
39
|
-
hooksPaused
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
`);async function Xa(e,n){let t=await L(e);if(t.isErr())return Zt({error:t.error,kind:"compilation-failed"});let r=await Se({config:n,cwd:e,lockfile:t.value});return er({devSessionId:r.devSessionId,lockfile:t.value})}async function Se(e){let n=Ue(e.lockfile);return rr({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:n})}function tr(e){return Xt.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function rr({config:e,cwd:n,fixtures:t,payload:r}){let o=tr(r),i=yn(n),s=await ir(n),l=await or(n,t),p=await m({config:e,document:nr,variables:{branch:i??null,cwd:n,fixtures:l,lockfileContent:s,preconditions:r.preconditions.map(d=>({depends:[...d.depends],description:d.description,name:d.name,returns:[...d.returns]})),projectId:e.projectId,singletons:r.singletons.map(d=>({defaultValue:d.defaultValue,description:d.description,name:d.name,type:d.type})),workflows:r.workflows.map(d=>({expectedOutcome:d.expectedOutcome,name:d.name,preconditions:[...d.preconditions],requiresKeys:d.requiresKeys.map(c=>({namespace:c.namespace,preconditionName:c.preconditionName})),slug:d.slug,sourcePath:d.sourcePath,spec:JSON.stringify(d.spec)}))}});if(p.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:p.syncDevSession.id,hash:o,hooksPaused:p.syncDevSession.hooksPaused}}async function or(e,n){let t=Object.entries(n);return Promise.all(t.map(async([r,o])=>({contentBase64:(await hn(Rn.join(e,F,r))).toString("base64"),sha256:o.sha256})))}async function ir(e){try{return await hn(Rn.join(e,I),"utf8")}catch{return null}}import{randomUUID as Ur}from"crypto";import{createId as _r}from"@paralleldrive/cuid2";import{CancellationTokenSource as Dr,ResponseError as qr}from"vscode-jsonrpc/node";import{graphql as ar}from"gql.tada";var sr=ar(`
|
|
43
|
-
mutation DaemonCreateRun(
|
|
44
|
-
$id: String
|
|
45
|
-
$workflowId: String!
|
|
46
|
-
$testId: String
|
|
47
|
-
$clientVersion: String
|
|
48
|
-
$executor: RunExecutor
|
|
49
|
-
$target: RunTarget
|
|
50
|
-
$lockfileHash: String
|
|
51
|
-
) {
|
|
52
|
-
createRun(
|
|
53
|
-
id: $id
|
|
54
|
-
workflowId: $workflowId
|
|
55
|
-
testId: $testId
|
|
56
|
-
executor: $executor
|
|
57
|
-
target: $target
|
|
58
|
-
clientVersion: $clientVersion
|
|
59
|
-
lockfileHash: $lockfileHash
|
|
60
|
-
) {
|
|
61
|
-
__typename
|
|
62
|
-
... on MutationCreateRunSuccess {
|
|
63
|
-
data {
|
|
64
|
-
id
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
... on LimitExceededError {
|
|
68
|
-
code
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
`);async function kn(e){try{let t=(await m({config:e.config,document:sr,variables:lr(e)})).createRun;return t==null?X({detail:"create-run-null",type:"generic"}):t.__typename==="MutationCreateRunSuccess"?null:t.__typename==="LimitExceededError"?X({code:t.code,type:"limit"}):X({detail:t.__typename,type:"generic"})}catch(n){return dr(n)}}function lr({executor:e,lockfileHash:n,runId:t,target:r}){return{clientVersion:B(),executor:e,id:t,lockfileHash:n,target:e==="cloud"?"tunnel":void 0,testId:r.testId,workflowId:r.workflowId}}function X(e){return{kind:"dispatch-error",reason:e}}function dr(e){return e instanceof $e?{detail:e.message,kind:"infra-error"}:X({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{createMessageConnection as cr,NotificationType as Sn,RequestType as ur,RequestType0 as xn,SocketMessageReader as pr,SocketMessageWriter as fr}from"vscode-jsonrpc/node";import{z as a}from"zod";var mr="daemon.sock",gr="daemon.log";function as(e){return w(e,mr)}function ss(e){return w(e,gr)}function wn(e){return cr(new pr(e),new fr(e))}var En=a.object({all:a.boolean(),headed:a.boolean(),tests:a.array(a.string())}),ls=a.object({jobId:a.string(),total:a.number()}),yr=a.enum(["on","off"]),hr=a.object({attempts:a.number(),findings:a.number()}),ds=a.object({active:a.number(),explorer:yr,exploring:a.number(),progress:hr,queued:a.number(),sseHealth:a.object({detail:a.string().optional(),ok:a.boolean()}).optional(),version:a.string().optional()}),Rr=a.enum(["MAX_RUNS","OVERAGE_CAP","MAX_AGENTS","MAX_CONCURRENT_RUNS","MAX_PROJECTS"]),kr=a.discriminatedUnion("type",[a.object({code:Rr,type:a.literal("limit")}),a.object({detail:a.string(),type:a.literal("generic")})]),xe=a.discriminatedUnion("kind",[a.object({kind:a.literal("pass")}),a.object({findingLines:a.array(a.string()),kind:a.literal("findings")}),a.object({detail:a.string(),kind:a.literal("error")}),a.object({kind:a.literal("dispatch-error"),reason:kr}),a.object({detail:a.string(),kind:a.literal("dispatch-timeout")}),a.object({detail:a.string(),kind:a.literal("infra-error")})]),Sr=a.discriminatedUnion("kind",[a.object({kind:a.literal("test-started"),runId:a.string(),testName:a.string(),workflowName:a.string()}),a.object({kind:a.literal("test-outcome"),outcome:xe,runId:a.string(),testName:a.string(),workflowName:a.string()})]),cs=a.object({event:Sr,jobId:a.string()}),us=a.object({failed:a.number(),jobId:a.string(),notRun:a.number(),passed:a.number()}),ps=a.discriminatedUnion("code",[a.object({code:a.literal("compile-failed"),detail:a.string(),diagnostics:a.array(a.string()).default([])}),a.object({code:a.literal("selection-conflicting-flags")}),a.object({code:a.literal("selection-nothing-selected")}),a.object({code:a.literal("selection-unknown-ids"),known:a.array(a.string()),unknown:a.array(a.string())}),a.object({code:a.literal("scope-failed"),detail:a.string()}),a.object({code:a.literal("app-unreachable"),detail:a.string(),url:a.string()}),a.object({code:a.literal("sync-failed"),detail:a.string()}),a.object({code:a.literal("bad-message")})]),bn=new ur("ripplo/enqueue"),vn=new xn("ripplo/status"),In=new xn("ripplo/shutdownIfIdle"),Pn=new Sn("ripplo/jobEvent"),Cn=new Sn("ripplo/jobDone");import{graphql as xr}from"gql.tada";async function jn(e,n){let r=(await m({config:e,document:wr,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 wr=xr(`
|
|
73
|
-
query DaemonWorkflows($projectId: String!, $cwd: String!) {
|
|
74
|
-
project(id: $projectId) {
|
|
75
|
-
id
|
|
76
|
-
devSession(cwd: $cwd) {
|
|
77
|
-
id
|
|
78
|
-
workflows {
|
|
79
|
-
id
|
|
80
|
-
slug
|
|
81
|
-
tests {
|
|
82
|
-
id
|
|
83
|
-
slug
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`);import{CancellationTokenSource as Er}from"vscode-jsonrpc/node";function we(e){return`${e.workflowSlug}/${e.testSlug}`}function An(e){let{headed:n,inflight:t,jobId:r,lockfileHashValue:o,onExpire:i,runId:s,selection:l,timeoutMs:p}=e,d=we(l),c=`${d}@${o}@${String(n)}`,u=t.get(c);if(u!=null)return u.jobIds.add(r),null;let y={cancellation:new Er,claimed:!1,claimKey:d,headed:n,inflightKey:c,jobIds:new Set([r]),runId:s,testName:l.testName,timer:null,workflowName:l.workflowName};return y.timer=setTimeout(()=>{Y(t,y),i(y)},p),t.set(c,y),y}function Y(e,n){n.timer!=null&&(clearTimeout(n.timer),n.timer=null),e.delete(n.inflightKey)}function Ee(e,n){let t=[...e.values()].find(r=>r.runId===n&&!r.claimed);return t==null?null:(t.claimed=!0,t.timer!=null&&(clearTimeout(t.timer),t.timer=null),t)}function Tn(e,n){[...e.values()].filter(t=>t.jobIds.has(n)).forEach(t=>{t.jobIds.delete(n),t.jobIds.size===0&&(Y(e,t),t.cancellation.cancel())})}import{err as be,ok as Fn}from"neverthrow";function Mn({all:e,ids:n,lockfile:t}){if(e&&n.length>0)return be({kind:"conflicting-flags"});if(e)return Fn(t.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>S(s))));if(n.length===0)return be({kind:"nothing-selected"});let r=n.map(i=>({id:i,refs:vr(t,i)})),o=r.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?be({kind:"unknown-ids",known:br(t),unknown:o}):Fn([...new Set(r.flatMap(i=>i.refs))])}function Ln(e,n){let t=new Map(A(e).map(r=>[r.ref,{testName:r.test.name,testSlug:r.test.slug,workflowName:r.workflow.name,workflowSlug:h(r.workflow.name)}]));return n.map(r=>{let o=t.get(r);if(o==null)throw new Error(`selectionsFor: ref not in lockfile: ${r}`);return o})}function br(e){return e.workflows.map(n=>h(n.name))}function vr(e,n){let t=e.workflows.find(r=>r.name===n||h(r.name)===h(n));return t!=null?t.tests.map(r=>S(r)):A(e).filter(r=>r.ref===n||$n(r.ref)===$n(n)).map(r=>r.ref)}function $n(e){let n=e.lastIndexOf("/");return n===-1?h(e):`${h(e.slice(0,n))}/${h(e.slice(n+1))}`}import{err as ve,ok as On}from"neverthrow";import{graphql as Un}from"gql.tada";import{execFileSync as Ir}from"child_process";var Pr=256*1024*1024;function Z(e,n){return Ir("git",[...e],{cwd:n,encoding:"utf8",maxBuffer:Pr,stdio:["ignore","pipe","pipe"]})}async function _n({config:e,cwd:n,lockfile:t}){await jr({config:e,cwd:n,lockfile:t});let r=await Tr(e);if(r.isErr())return ve(r.error);let o=new Map(t.workflows.filter(s=>!s.stub).map(s=>[h(s.name),s])),i=[...new Set(r.value)].flatMap(s=>{let l=o.get(s);return l==null?[]:l.tests.map(p=>S(p))});return i.length===0?ve({kind:"scope-empty"}):On(i)}var Cr=Un(`
|
|
90
|
-
mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
91
|
-
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
92
|
-
__typename
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
`);async function jr({config:e,cwd:n,lockfile:t}){let r=new Set(Fr(n)),o=t.workflows.filter(i=>i.sourcePath!=null&&r.has(i.sourcePath)).map(i=>h(i.name));o.length!==0&&await m({config:e,document:Cr,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{g.warn({err:i},"auto-scope of dirty tests failed")})}var Ar=Un(`
|
|
96
|
-
query ScopeSelection($projectId: String!, $cwd: String!) {
|
|
97
|
-
project(id: $projectId) {
|
|
98
|
-
id
|
|
99
|
-
devSession(cwd: $cwd) {
|
|
100
|
-
id
|
|
101
|
-
scopeItems {
|
|
102
|
-
id
|
|
103
|
-
workflow {
|
|
104
|
-
id
|
|
105
|
-
slug
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
`);async function Tr(e){try{let t=(await m({config:e,document:Ar,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return On(t.flatMap(r=>r.workflow==null?[]:[r.workflow.slug]))}catch(n){return ve({detail:n instanceof Error?n.message:String(n),kind:"scope-fetch-failed"})}}var Nn=".ripplo/workflows/";function Fr(e){try{return Z(["status","--porcelain","--",".ripplo/workflows"],e).split(`
|
|
112
|
-
`).map(n=>n.slice(3).trim()).filter(n=>n.startsWith(Nn)&&n.endsWith(".ts")).map(n=>n.slice(Nn.length)).filter(n=>n!=="index.ts"&&!n.endsWith("/index.ts"))}catch{return[]}}import{graphql as $r}from"gql.tada";var Mr=2e3,Lr=$r(`
|
|
113
|
-
query DaemonCloudRunStatus($runId: String!) {
|
|
114
|
-
run(id: $runId) {
|
|
115
|
-
status
|
|
116
|
-
failureReason
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
`);function qn({config:e,onComplete:n,onStarted:t,runId:r,signal:o}){let i=!1,s,l=!1,p=async()=>{if(i||o.aborted)return;let d=await Nr(e,r).catch(()=>"unknown");if(!l&&(d==="running"||Dn(d))&&(l=!0,t()),Dn(d)){i=!0,n(Or(d));return}s=setTimeout(()=>{p()},Mr)};return p(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function Nr(e,n){let r=(await m({config:e,document:Lr,variables:{runId:n}})).run?.status;return r??"unknown"}function Dn(e){return e==="passed"||e==="failed"||e==="warning"||e==="cancelled"}function Or(e){return e==="passed"?{kind:"pass"}:e==="failed"?{detail:"failed",kind:"error"}:e==="warning"?{findingLines:[],kind:"findings"}:e==="cancelled"?{detail:"cancelled",kind:"error"}:{detail:"unknown",kind:"error"}}var Hr=12e4,Wr=-32099;function Br(e){let n=new AbortController;return e.isCancellationRequested?(n.abort(),n.signal):(e.onCancellationRequested(()=>{n.abort()}),n.signal)}function Xs(e){let n={...e,inflight:new Map,jobs:new Map};return{claim:t=>Gr(n,t),handleConnection:t=>{Vr(n,t)},idle:()=>Bn(n)}}function Vr(e,n){let t=wn(n);t.onRequest(bn,(r,o)=>zr({connection:t,ctx:e,params:r,token:o})),t.onRequest(vn,()=>{let r=he();return{active:r.active,queued:r.queued,sseHealth:e.sseHealth(),version:B(),...e.explorationStatus()}}),t.onRequest(In,()=>{let r=Bn(e);return r&&e.onShutdownRequest(),r}),t.onClose(()=>{Jr(e,t)}),t.onError(r=>{g.warn({err:r},"ipc connection error")}),n.on("error",r=>{g.warn({err:r},"ipc socket error")}),t.listen()}function Bn(e){let n=he();return e.jobs.size===0&&n.active===0&&n.queued===0}async function zr({connection:e,ctx:n,params:t,token:r}){let o=En.safeParse(t);if(!o.success)throw Hn({code:"bad-message"});await n.ready;let i=await Xr({config:n.config,cwd:n.cwd,message:o.data});if(i.kind==="error")throw Hn(i.error);let s=Ur(),l=new Dr;return r.onCancellationRequested(()=>{Vn(n,s)}),n.jobs.set(s,{cancellation:l,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),io({ctx:n,headed:o.data.headed,jobId:s,lockfileHashValue:i.lockfileHashValue,selections:i.selections,targetsByClaimKey:i.targetsByClaimKey,token:l.token}).catch(p=>{g.error({err:p},"ipc dispatch failed")}),{jobId:s,total:i.selections.length}}function Hn(e){return new qr(Wr,e.code,e)}function Vn(e,n){let t=e.jobs.get(n);t!=null&&(t.cancellation.cancel(),e.jobs.delete(n),Tn(e.inflight,n))}function Jr(e,n){[...e.jobs.entries()].filter(([,t])=>t.connection===n).forEach(([t])=>{Vn(e,t)})}function zn(e,n,t){let r=e.jobs.get(n);r!=null&&(Wn(()=>r.connection.sendNotification(Pn,{event:t,jobId:n})),t.kind==="test-outcome"&&(Kr(r,t.outcome.kind),r.passed+r.failed+r.notRun>=r.total&&(Wn(()=>r.connection.sendNotification(Cn,{failed:r.failed,jobId:n,notRun:r.notRun,passed:r.passed})),e.jobs.delete(n))))}function Wn(e){e().catch(n=>{g.warn({err:n},"ipc notification failed")})}function Kr(e,n){if(n==="pass"){e.passed+=1;return}if(n==="dispatch-error"||n==="dispatch-timeout"||n==="infra-error"){e.notRun+=1;return}e.failed+=1}function C(e,n,t){n.jobIds.forEach(r=>{zn(e,r,t)})}function Gr(e,n){let t=Ee(e.inflight,n);return t==null?null:{headed:t.headed,token:t.cancellation.token,finished:(r,o)=>{e.inflight.delete(t.inflightKey),C(e,t,{kind:"test-outcome",outcome:o,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},started:()=>{C(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}}}function Qr(e){return e.kind==="typecheck-failed"?e.diagnostics.slice(0,5):e.kind==="invalid-lockfile"?e.issues.slice(0,5):e.kind==="load-threw"?[e.message]:[]}async function Xr({config:e,cwd:n,message:t}){return(await en(n)).match(o=>Yr({config:e,cwd:n,lockfile:o,message:t}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...Qr(o)]},kind:"error"}))}async function Yr({config:e,cwd:n,lockfile:t,message:r}){let o=await eo(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=await no({config:e,cwd:n,lockfile:t});return i!=null?{error:{code:"sync-failed",detail:i},kind:"error"}:(await to({config:e,cwd:n,lockfile:t,message:r})).match(async l=>({kind:"ready",lockfileHashValue:Oe(t),selections:Ln(t,l),targetsByClaimKey:await jn(e,n)}),l=>Promise.resolve({error:l,kind:"error"}))}var Zr=2e3;async function eo(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(Zr)}),null}catch(n){return n instanceof Error?n.message:String(n)}}async function no(e){try{return await Se(e),null}catch(n){return n instanceof Error?n.message:String(n)}}async function to({config:e,cwd:n,lockfile:t,message:r}){return!r.all&&r.tests.length===0?(await _n({config:e,cwd:n,lockfile:t})).mapErr(ro):Mn({all:r.all,ids:r.tests,lockfile:t}).mapErr(oo)}function ro(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function oo(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 io(e){await e.selections.reduce((n,t)=>n.then(()=>ao(e,t)),Promise.resolve())}async function ao(e,n){let{ctx:t,headed:r,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:l}=e;if(l.isCancellationRequested)return;let p=we(n),d=s.get(p);if(d==null){zn(t,o,{kind:"test-outcome",outcome:{kind:"dispatch-error",reason:{detail:"test-not-found",type:"generic"}},runId:"",testName:n.testName,workflowName:n.workflowName});return}let c=An({headed:r,inflight:t.inflight,jobId:o,lockfileHashValue:i,runId:_r(),selection:n,timeoutMs:Hr,onExpire:y=>{C(t,y,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:y.testName,workflowName:y.workflowName})}});if(c==null)return;let u=await so(t,d,c.runId,i);if(u!=null){Y(t.inflight,c),C(t,c,{kind:"test-outcome",outcome:u,runId:"",testName:n.testName,workflowName:n.workflowName});return}t.executor==="cloud"&&lo(t,c)}function so(e,n,t,r){return kn({config:e.config,executor:e.executor,lockfileHash:r,runId:t,target:n})}function lo(e,n){let t=Ee(e.inflight,n.runId);t!=null&&qn({config:e.config,runId:t.runId,signal:Br(t.cancellation.token),onComplete:r=>{e.inflight.delete(t.inflightKey),C(e,t,{kind:"test-outcome",outcome:r,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},onStarted:()=>{C(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}})}import co from"fs";import uo from"path";async function il(e){let n=uo.join(e,".ripplo","index.ts");if(!co.existsSync(n))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let t=await L(e);return t.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:J(t.error),path:".ripplo/"}],valid:!1,warnings:[]}:W().match(r=>({appUrl:r.appUrl,engineUrl:r.engineUrl,errors:[],valid:!0,warnings:[]}),r=>({appUrl:void 0,engineUrl:void 0,errors:[{message:fe(r),path:""}],valid:!1,warnings:[]}))}async function al(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 sl({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 go from"fs";import po from"fs";import Ie from"path";var fo=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function Jn(e){let n=mo(e);return n==null?!1:fo.some(t=>po.existsSync(Ie.join(n,t)))}function mo(e){try{let n=Z(["rev-parse","--git-dir"],e).trim();return n.length===0?null:Ie.isAbsolute(n)?n:Ie.resolve(e,n)}catch{return null}}function yo(e){return w(e,"hooks-paused")}function hl(e){return go.existsSync(yo(e))||Jn(e)?!1:mn(e)}import{createMessageConnection as Kn,IPCMessageReader as Gn,IPCMessageWriter as Qn,NotificationType as ho,NotificationType0 as Xn,RequestType as Pe}from"vscode-jsonrpc/node";import{z as f}from"zod";var wl=f.object({headed:f.boolean(),lockfileFingerprint:f.string(),runId:f.string().min(1),testRef:f.string().min(1)}),El=f.object({fingerprint:f.string()}),bl=f.object({lockfileJson:f.string().optional(),unavailable:f.string().optional()}),Ro=f.enum(["unspecified","internal","server","client","producer","consumer"]),ko=f.enum(["unset","ok","error"]),So=f.object({attributes:f.record(f.string(),f.string()),durationMs:f.number(),kind:f.literal("span"),name:f.string(),parentSpanId:f.union([f.string(),f.undefined()]),source:f.literal("server"),spanId:f.string(),spanKind:Ro,status:f.object({code:ko,message:f.union([f.string(),f.undefined()])}),timeNanos:f.string(),traceId:f.string()}),vl=f.object({runId:f.string().min(1),span:So}),Il=f.object({outcome:xe,serverNotified:f.boolean()}),Pl=new Xn("worker/ready"),Cl=new Pe("worker/run"),jl=new Pe("worker/lockfile"),Al=new Pe("worker/exploreTrail"),Tl=new ho("worker/span"),Fl=new Xn("worker/shutdown");function $l(e){let n=Kn(new Gn(e),new Qn(e));return n.listen(),n}function Ml(){let e=Kn(new Gn(process),new Qn(process));return e.listen(),e}import xo from"path";import{randomUUID as wo}from"crypto";async function Hl({cwd:e,ref:n,signal:t,step:r}){let o=cn(e).match(c=>({config:c}),c=>({failure:c}));if("failure"in o)return{failure:o.failure,kind:"config-failed"};let i=o.config,s=await pe(e);if(s.result.isErr())return{error:s.result.error,kind:"compile-failed"};let l=s.result.value,p=A(l).find(c=>c.ref===n);return p==null?{kind:"no-test",ref:n}:(await We({lockfile:l,options:{baseUrl:i.appUrl,engineUrl:i.engineUrl,fixturesDir:xo.join(i.cwd,F),generate:E,headed:!0,secret:i.webhookSecret,tunnelAuth:i.tunnelAuth},params:void 0,runId:`teleport-${wo()}`,stopAfterStep:r,test:p.test},t)).match(c=>({kind:"done",result:c}),c=>({error:c,kind:"run-failed"}))}import{gzip as Ao}from"zlib";import{promisify as To}from"util";import{existsSync as je,readFileSync as Ae}from"fs";import ee from"path";import{graphql as x}from"gql.tada";function Yn(e){return[e.kind,e.target,e.value].filter(n=>n.length>0).join(" ")}var Eo={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},bo={"data-rule":"dataRule","page-rule":"pageRule",step:"step"},vo={aborted:"aborted","action-failed":"actionFailed","check-failed":"checkFailed","client-mount-missing":"clientMountMissing","conflicting-sessions":"conflictingSessions","driver-launch":"driverLaunch","engine-decode":"engineDecode","engine-http":"engineHttp","engine-network":"engineNetwork","engine-unreachable":"engineUnreachable","setup-missing-row":"setupMissingRow","state-identity":"stateIdentity"};function Zn(e){return e.kind==="consistency"?{consistency:{mismatch:Co(e.mismatch),pending:e.pending}}:e.kind==="pending-check"?{pendingCheck:{budget:e.budget,source:bo[e.source.kind],...Io(e.source)}}:e.kind==="unrunnable"?{unrunnable:{reason:Eo[e.reason]}}:e.kind==="driver-error"?{driverError:{errorKind:vo[e.error.kind],message:jo(e.error)}}:{impossibleAction:{subject:Po(e.step.action)}}}function Io(e){return"check"in e?et(e.check,!1):{checkKind:void 0,expected:void 0,negated:void 0,subject:void 0}}function et(e,n){return e.kind==="not"?et(e.inner,!n):e.kind==="browser"?{checkKind:"browser",expected:e.value,negated:n,subject:e.name}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:n,subject:O(e.locator)}:{checkKind:e.kind,expected:void 0,negated:n,subject:O(e.locator)}}function Po(e){let n=e.locator==null?e.url??"":O(e.locator);return`${e.kind} ${n}`.trim()}function Co(e){return e.kind==="wrong-value"?{wrongValue:{entity:e.entity,field:e.field,key:e.key,snapshot:N(e.snapshot),sut:N(e.sut)}}:e.kind==="expected-change"?{expectedChange:{entity:e.entity,field:e.field,key:e.key,value:N(e.value)}}:e.kind==="singleton-mismatch"?{singletonMismatch:{singleton:e.singleton,snapshot:N(e.snapshot),sut:N(e.sut)}}:e.kind==="unexpected-row"?{unexpectedRow:{entity:e.entity,key:e.key}}:{missingRow:{entity:e.entity,key:e.key}}}function N(e){return e==null?null:String(e)}function jo(e){return"message"in e?e.message:"detail"in e?e.detail:null}async function Fo({config:e,cwd:n,fixturesDir:t,headed:r,lockfile:o,runId:i,session:s,signal:l,test:p}){if(!await ti(e,i))return{kind:"dispatch-failed",reason:"already-claimed",runId:i};let c=ee.join(n,".ripplo","debug"),u=[];return(await s.runOnce({capture:!0,lockfile:o,onPhase:void 0,options:{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:t,generate:E,headed:r,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth},params:void 0,runId:i,sequence:void 0,test:p,onEvent:R=>{u.push(R)}},l)).match(async R=>{await ne({config:e,debugDir:c,events:u,recordingOptional:!1,runId:i,stepSources:void 0});let Fe=nt(u).flatMap(at=>at.findings);return Fe.length>0?{findings:Fe,kind:"findings",runId:i}:{kind:"pass",runId:i}},async R=>(await rt(e,i,De(R)),{error:R,kind:"error",runId:i}))}async function ne({config:e,debugDir:n,events:t,recordingOptional:r,runId:o,stepSources:i}){let s=nt(t),l=No(n,o);if(l==null&&!r)throw new Error("recording-missing");await Bo({aliases:[..._o(t),...Do(s)],config:e,generated:qo(t),generatedSingletons:Ho(t),origin:l==null?Lo(s):l.origin,records:s,rrwebEvents:l==null?[]:l.events,runId:o,stepSources:i}),l!=null&&await ei(e,o,l),await ni(e,o,s),await Mo(e,n,o)}var $o=x(`
|
|
120
|
-
mutation ClipUploadUrl($runId: ID!) {
|
|
121
|
-
clipUploadUrl(runId: $runId)
|
|
122
|
-
}
|
|
123
|
-
`);async function Mo(e,n,t){let r=ee.join(n,t,"clip.gif");if(je(r))try{let o=await m({config:e,document:$o,variables:{runId:t}});if(o.clipUploadUrl==null)return;let i=await fetch(o.clipUploadUrl,{body:new Uint8Array(Ae(r)),headers:{"Content-Type":"image/gif"},method:"PUT"});i.ok||g.warn({runId:t,status:i.status},"Clip upload failed")}catch(o){g.warn({err:o,runId:t},"Clip upload skipped")}}function Lo(e){return e.reduce((n,t)=>Math.min(n,t.startMs),e[0]?.startMs??0)}function nt(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 No(e,n){let t=ee.join(e,n,"behavior.jsonl");if(!je(t))return null;let r=Ae(t,"utf8").split(`
|
|
124
|
-
`).filter(i=>i.length>0).map(i=>Oo(i)).flatMap(i=>Uo(i)?[i.event]:[]),o=r[0];return o==null?null:{events:r,origin:o.timestamp}}function Oo(e){return JSON.parse(e)}function Uo(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function _o(e){return e.flatMap(n=>n.kind==="world"?n.aliases:[])}function Do(e){return e.flatMap(n=>{let t=Wo(n.source);return t.flatMap(r=>{let i=t.filter(l=>l.entity===r.entity).indexOf(r),s=n.state.rows.filter(l=>l.status==="created"&&l.entity===r.entity).at(i);return s==null?[]:[{alias:r.as,entity:r.entity,key:s.key}]})})}function qo(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generated.map(t=>tt(t)):[]))}function tt({entity:e,field:n,key:t}){return`${e}\0${t}\0${n}`}function Ho(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generatedSingletons:[]))}function Wo(e){return e==null?[]:e.expect.flatMap(n=>Ce(n))}function Ce(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(n=>Ce(n)):e.kind==="when"?e.branches.flatMap(n=>n.consequence.flatMap(t=>Ce(t))):[]}async function Bo({aliases:e,config:n,generated:t,generatedSingletons:r,origin:o,records:i,rrwebEvents:s,runId:l,stepSources:p}){let d=i.map((c,u)=>Ko({aliases:e,generated:t,generatedSingletons:r,origin:o,record:c,rrwebEvents:s,sourceTest:p?.[u]??null}));await m({config:n,document:oi,variables:{items:[{runId:l,steps:d}]}})}var Vo=3,zo=0;function Jo({endMs:e,rrwebEvents:n,startMs:t}){let r=n.find(o=>o.type===Vo&&o.data?.source===zo&&o.timestamp>=t&&o.timestamp<=e);return r==null?t:r.timestamp}function Ko({aliases:e,generated:n,generatedSingletons:t,origin:r,record:o,rrwebEvents:i,sourceTest:s}){let l=_e(o.source,o.index),p=Jo({endMs:o.endMs,rrwebEvents:i,startMs:o.startMs}),d=o.annotations.map(u=>({kind:u.kind,label:u.label,outcome:u.outcome,recordingStartMs:Math.max(0,(u.kind==="action"?p:u.atMs)-r),rrwebIds:[...u.rrwebIds],url:u.url})),c=o.annotations.find(u=>u.kind==="action")?.rrwebIds??[];return{annotations:d,detail:null,duration:Math.max(0,o.endMs-o.startMs),findings:o.findings.map(u=>Zn(u)),nodeType:l.kind,recordingEndMs:Math.max(0,o.endMs-r),recordingStartMs:Math.max(0,p-r),rrwebIds:[...c],snapshotTimestamp:Math.max(0,o.endMs-r),sourceTest:s,stateRows:o.state.rows.map(u=>Go({aliases:e,generated:n,row:u})),stateSingletons:o.state.singletons.map(u=>({changed:u.changed,generated:t.has(u.name),name:u.name,value:u.value==null?null:String(u.value)})),status:o.findings.length>0?"failed":"passed",stepIndex:o.index,title:Yn(l),url:o.url}}function Go({aliases:e,generated:n,row:t}){let r=e.find(o=>o.entity===t.entity&&o.key===t.key);return{entity:t.entity,fields:t.fields.map(o=>({changed:o.changed,field:o.field,generated:n.has(tt({entity:t.entity,field:o.field,key:t.key})),value:o.value==null?null:String(o.value)})),key:t.key,label:r?.alias??t.key,status:t.status}}var Qo=To(Ao);async function rt(e,n,t){await m({config:e,document:si,variables:{reason:t,runId:n}}).catch(r=>{g.error(r,"failRun submission failed")})}async function ot(e,n){await m({config:e,document:li,variables:{runIds:[n]}})}var Xo="application/x-ndjson";async function Yo({config:e,debugDir:n,runId:t}){let r=ee.join(n,t,"behavior.jsonl");if(je(r))try{let o=await m({config:e,document:Zo,variables:{runId:t}}),i=await fetch(o.debugArtifactUploadUrl,{body:Ae(r),headers:{"content-type":Xo},method:"PUT"});if(!i.ok){g.warn({runId:t,status:i.status},"behavior upload PUT failed");return}await ot(e,t)}catch(o){g.warn({error:o,runId:t},"behavior upload failed")}}var Zo=x(`
|
|
125
|
-
mutation DebugArtifactUploadUrl($runId: String!) {
|
|
126
|
-
debugArtifactUploadUrl(runId: $runId)
|
|
127
|
-
}
|
|
128
|
-
`);async function ei(e,n,t){let r=t.events.map(s=>JSON.stringify(s)).join(`
|
|
129
|
-
`),o=await Qo(Buffer.from(r,"utf8")),i=t.events.at(-1);await m({config:e,document:ii,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 ni(e,n,t){let r=t.filter(s=>s.findings.length>0).length,o=t.length-r,i=t.reduce((s,l)=>s+Math.max(0,l.endMs-l.startMs),0);await m({config:e,document:ai,variables:{items:[{duration:i,failCount:r,passCount:o,runId:n,status:r>0?"failed":"passed",summary:null,warnCount:0}]}})}async function ti(e,n){return((await m({config:e,document:ri,variables:{runIds:[n]}})).startRunsBatch??[]).some(r=>r.id===n)}var ri=x(`
|
|
130
|
-
mutation StartRunsBatch($runIds: [String!]!) {
|
|
131
|
-
startRunsBatch(runIds: $runIds) {
|
|
132
|
-
id
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
`),oi=x(`
|
|
136
|
-
mutation SubmitRunStepsBatch($items: [SubmitRunStepsItem!]!) {
|
|
137
|
-
submitRunStepsBatch(items: $items)
|
|
138
|
-
}
|
|
139
|
-
`),ii=x(`
|
|
140
|
-
mutation SubmitRunRecordingChunk($input: SubmitRunRecordingChunkInput!) {
|
|
141
|
-
submitRunRecordingChunk(input: $input)
|
|
142
|
-
}
|
|
143
|
-
`),ai=x(`
|
|
144
|
-
mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
|
|
145
|
-
completeRunsBatch(items: $items) {
|
|
146
|
-
id
|
|
147
|
-
status
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
`),si=x(`
|
|
151
|
-
mutation FailRun($runId: String!, $reason: String!) {
|
|
152
|
-
failRun(runId: $runId, reason: $reason)
|
|
153
|
-
}
|
|
154
|
-
`),li=x(`
|
|
155
|
-
mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
|
|
156
|
-
markRunArtifactsUploadedBatch(runIds: $runIds)
|
|
157
|
-
}
|
|
158
|
-
`);import{randomUUID as ui}from"crypto";import{graphql as j}from"gql.tada";async function Te({baseState:e,branchName:n,category:t,commitSha:r,config:o,debugDir:i,devSessionId:s,events:l,lockfileHash:p,reproJson:d,runId:c,signature:u,spec:y,stepSources:R}){await m({config:o,document:di,variables:{branchName:n??null,commitSha:r??null,devSessionId:s??null,lockfileHash:p??null,projectId:o.projectId,reproJson:d,runId:c,spec:y??null}}),await ne({config:o,debugDir:i,events:l,recordingOptional:!0,runId:c,stepSources:R}),await m({config:o,document:ci,variables:{baseState:e,category:t,projectId:o.projectId,reproRunId:c,signature:u}})}var sd=j(`
|
|
159
|
-
mutation RecordExplorationProgress($devSessionId: String!, $attempts: Int!, $findings: Int!) {
|
|
160
|
-
recordExplorationProgress(devSessionId: $devSessionId, attempts: $attempts, findings: $findings)
|
|
161
|
-
}
|
|
162
|
-
`),ld=j(`
|
|
163
|
-
mutation ContinueExploreLoop($devSessionId: String!, $epoch: Int!) {
|
|
164
|
-
continueExploreLoop(devSessionId: $devSessionId, epoch: $epoch)
|
|
165
|
-
}
|
|
166
|
-
`),di=j(`
|
|
167
|
-
mutation CreateExploreRun(
|
|
168
|
-
$projectId: String!
|
|
169
|
-
$runId: String!
|
|
170
|
-
$devSessionId: String
|
|
171
|
-
$branchName: String
|
|
172
|
-
$commitSha: String
|
|
173
|
-
$lockfileHash: String
|
|
174
|
-
$spec: String
|
|
175
|
-
$reproJson: String
|
|
176
|
-
) {
|
|
177
|
-
createExploreRun(
|
|
178
|
-
projectId: $projectId
|
|
179
|
-
runId: $runId
|
|
180
|
-
devSessionId: $devSessionId
|
|
181
|
-
branchName: $branchName
|
|
182
|
-
commitSha: $commitSha
|
|
183
|
-
lockfileHash: $lockfileHash
|
|
184
|
-
spec: $spec
|
|
185
|
-
reproJson: $reproJson
|
|
186
|
-
) {
|
|
187
|
-
id
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
`),ci=j(`
|
|
191
|
-
mutation SubmitExploreFinding(
|
|
192
|
-
$projectId: String!
|
|
193
|
-
$signature: String!
|
|
194
|
-
$baseState: String!
|
|
195
|
-
$category: ExploreFindingCategory!
|
|
196
|
-
$reproRunId: String!
|
|
197
|
-
) {
|
|
198
|
-
submitExploreFinding(
|
|
199
|
-
projectId: $projectId
|
|
200
|
-
signature: $signature
|
|
201
|
-
baseState: $baseState
|
|
202
|
-
category: $category
|
|
203
|
-
reproRunId: $reproRunId
|
|
204
|
-
) {
|
|
205
|
-
id
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
`),dd=j(`
|
|
209
|
-
mutation SetExploreFindingStatus(
|
|
210
|
-
$projectId: String!
|
|
211
|
-
$signature: String!
|
|
212
|
-
$status: ExploreFindingStatus!
|
|
213
|
-
) {
|
|
214
|
-
setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
|
|
215
|
-
}
|
|
216
|
-
`),cd=j(`
|
|
217
|
-
query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
|
|
218
|
-
exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
|
|
219
|
-
}
|
|
220
|
-
`);async function pi({assign:e,config:n,debugDir:t,devSessionId:r,fixturesDir:o,headed:i,lockfile:s,report:l,session:p,signal:d}){let c=qe(s);if(e.stepRuns.length===0)return{kind:"error",reason:"empty-trail"};let u=ki(c,e.stepRuns),y=await Be({baseState:{name:S(e.baseStateTest),test:e.baseStateTest},corpus:c,lockfile:s,options:{baseUrl:n.appUrl,engineUrl:n.engineUrl,fixturesDir:o,generate:E,headed:i,secret:n.webhookSecret,tunnelAuth:n.tunnelAuth},session:p,stepRuns:e.stepRuns,runIdFor:R=>`explore-${ui()}-${String(R)}`},d);return l&&await yi({baseStateTest:e.baseStateTest,config:n,debugDir:t,devSessionId:r,lockfileHash:e.lockfileHash,outcome:y,reproJson:mi(c,e),stepSources:gi(u)}),fi(y,u.length),Si(y)}function it(e){return e.engineMs+e.worldMs+e.browserMs+e.driveMs+e.teardownMs}function fi(e,n){if(e.kind==="error"||e.kind==="aborted"){g.info({kind:e.kind,steps:n},"explore trail");return}let t=e.timing.detect,r=e.timing.confirm;g.info({browserMs:t.browserMs,confirmMs:r==null?void 0:it(r),detectMs:it(t),driveMs:t.driveMs,engineMs:t.engineMs,kind:e.kind,steps:n,teardownMs:t.teardownMs,worldMs:t.worldMs},"explore trail")}function mi(e,n){let t=n.stepRuns.flatMap(o=>{let i=e[o.idx];return i==null?[]:[{index:i.index,params:o.params,test:i.test}]}),r={baseStateRef:S(n.baseStateTest),steps:t};return JSON.stringify(r)}function gi(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(()=>t)})}async function yi({baseStateTest:e,config:n,debugDir:t,devSessionId:r,lockfileHash:o,outcome:i,reproJson:s,stepSources:l}){i.kind!=="finding"||i.captureEvents.length===0||await Te({baseState:i.baseState,branchName:void 0,category:hi(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:Ri(e,i.captureEvents),stepSources:l}).catch(p=>{g.warn({error:p},"explore finding report failed")})}function hi(e){return e==="data-rule"?"dataRule":e==="page-rule"?"pageRule":e}function Ri(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 ki(e,n){return n.flatMap(t=>{let r=e[t.idx];return r==null?[]:[{actions:[...r.nav,...r.steps].map(o=>He(o.action)),label:`${r.test}#${String(r.index)}`}]})}function Si(e){return e.kind==="error"?{kind:e.kind,reason:`runtime:${e.error.kind}`}:e.kind==="finding"?{kind:e.kind,runId:e.runId}:{kind:e.kind}}export{vi as a,$i as b,W as c,mt as d,B as e,F as f,I as g,pe as h,L as i,P as j,na as k,J as l,aa as m,sa as n,la as o,ma as p,fe as q,on as r,sn as s,cn as t,mn as u,ye as v,Ta as w,Z as x,Jn as y,il as z,al as A,sl as B,yo as C,hl as D,as as E,ss as F,wn as G,ls as H,ds as I,cs as J,us as K,ps as L,bn as M,vn as N,In as O,Pn as P,Cn as Q,wl as R,El as S,vl as T,Il as U,Pl as V,Cl as W,jl as X,Al as Y,Tl as Z,Fl as _,$l as $,Ml as aa,Ma as ba,La as ca,he as da,Na as ea,yn as fa,Xa as ga,Se as ha,Br as ia,Xs as ja,Fo as ka,rt as la,Yo as ma,pi as na,Hl as oa};
|