ripplo 0.7.61 → 0.8.0
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-ZPCVY23H.js → chunk-D6FZ55DP.js} +1 -1
- package/dist/chunk-E4AOUQQ7.js +10 -0
- package/dist/{chunk-5YQYVDNN.js → chunk-GOFUUPKD.js} +1 -1
- package/dist/chunk-KMZ3L5YA.js +4 -0
- package/dist/chunk-NIKFQP6W.js +301 -0
- package/dist/chunk-NNH3YVVO.js +4 -0
- package/dist/chunk-SAYJ5AQK.js +55 -0
- package/dist/chunk-THHZNLXN.js +48 -0
- package/dist/chunk-VGYX2VAS.js +85 -0
- package/dist/daemon-MBF7JVEN.js +139 -0
- package/dist/daemon-VIHSG5KP.js +4 -0
- package/dist/daemon-lock-HIZ6UWXO.js +4 -0
- package/dist/index.js +228 -237
- package/dist/solve-worker.js +4 -0
- package/dist/status-G5OG62JI.js +4 -0
- package/package.json +5 -5
- package/dist/chunk-63TU4VJ7.js +0 -4
- package/dist/chunk-6SKODQ54.js +0 -136
- package/dist/chunk-7C6PFZJF.js +0 -287
- package/dist/chunk-LHXEVZIV.js +0 -10
- package/dist/chunk-PXYDLKAG.js +0 -48
- package/dist/daemon-47WHU7QZ.js +0 -139
- package/dist/daemon-MTPTV22N.js +0 -4
- package/dist/daemon-lock-6NG7JHQO.js +0 -4
- package/dist/status-UG3NHVXY.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{
|
|
4
|
+
import{i as s,j as a}from"./chunk-THHZNLXN.js";import d from"fs";import{setTimeout as p}from"timers/promises";import{checkSync as m,lockSync as f}from"proper-lockfile";var y="dev.pid",l=15e3,h=1e4,k=250;function g(n){return u(i(n))}async function b(n){let r=g(n);if(r==null||!c(n))return{kind:"not-running"};try{process.kill(r,"SIGTERM")}catch{return{kind:"not-running"}}let e=Date.now()+h;for(;Date.now()<e;){if(!c(n))return{kind:"stopped",pid:r};await p(k)}return{kind:"timeout",pid:r}}function c(n){try{return m(i(n),{realpath:!1,stale:l})}catch{return!1}}function i(n){return a(n,y)}var o=class extends Error{pid;cwd;constructor({cwd:r,pid:e}){super("dev-lock-held"),this.name="DevLockHeldError",this.pid=e,this.cwd=r}};function E({cwd:n,onCompromised:r}){s(n);let e=i(n),t=w({cwd:n,onCompromised:r,path:e});return d.writeFileSync(e,String(process.pid)),()=>{try{t()}catch{}}}function w({cwd:n,onCompromised:r,path:e}){try{return f(e,{realpath:!1,stale:l,onCompromised:()=>{r()}})}catch(t){throw D(t)?new o({cwd:n,pid:u(e)}):t}}function D(n){if(!(n instanceof Error)||!("code"in n))return!1;let{code:r}=n;return r==="ELOCKED"}function u(n){try{let r=d.readFileSync(n,"utf8").trim(),e=Number.parseInt(r,10);return Number.isFinite(e)&&e>0?e:null}catch{return null}}export{g as a,b,c,i as d,o as e,E as f};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{j as F}from"./chunk-THHZNLXN.js";import{k as G,n as Y,o as Q,p as Z}from"./chunk-VGYX2VAS.js";import{A as L,B as u,G as q,H as a,I as T,U as X,V,Z as B,_ as K}from"./chunk-SAYJ5AQK.js";import{readFileSync as Ee}from"fs";import{z as ee}from"zod";var ve=ee.object({version:ee.string()});function Tt(){let e=Ee(new URL("../package.json",import.meta.url),"utf8");return ve.parse(JSON.parse(e)).version}import m from"fs";import p from"path";import{createHash as We}from"crypto";import{pathToFileURL as qe}from"url";import{build as Xe}from"esbuild";import{err as v,ok as z,ResultAsync as Ve}from"neverthrow";import Re from"fs";import b from"path";import y from"typescript";function te(e){let t=b.join(e,"index.ts"),r=Ce(e);Re.mkdirSync(b.dirname(r.tsBuildInfoFile??""),{recursive:!0});let o=y.createIncrementalCompilerHost(r),i=y.createIncrementalProgram({host:o,options:r,rootNames:[t]}),s=[...i.getSyntacticDiagnostics(),...i.getSemanticDiagnostics()];i.emit();let l=s.filter(d=>Pe(d,e));if(l.length===0)return{diagnostics:[],ok:!0};let W={getCanonicalFileName:d=>d,getCurrentDirectory:()=>b.dirname(e),getNewLine:()=>`
|
|
5
|
+
`};return{diagnostics:y.formatDiagnosticsWithColorAndContext(l,W).split(`
|
|
6
|
+
`).filter(d=>d.length>0),ok:!1}}function Pe(e,t){let r=e.file?.fileName;return r==null?!0:r.startsWith(t)}var je=b.join(".local","tsbuildinfo");function Ce(e){return{allowImportingTsExtensions:!0,allowJs:!1,esModuleInterop:!0,incremental:!0,module:y.ModuleKind.Preserve,moduleResolution:y.ModuleResolutionKind.Bundler,noEmit:!0,resolveJsonModule:!0,skipLibCheck:!0,strict:!1,target:y.ScriptTarget.ES2022,tsBuildInfoFile:b.join(e,je)}}import w from"fs";import A from"safe-stable-stringify";import{err as Fe,ok as re,Result as Te}from"neverthrow";async function oe(e,t){let r={entities:e.entities,singletonSchemas:e.singletons,valueSpaces:e.valueSpaces},o=f(t)?void 0:Oe(t),i=Ie(e,o),s=await Promise.all(e.workflows.map(l=>Ae({context:r,reusable:i,workflow:l})));return Te.combine(s).map(l=>({...e,workflows:[...l]}))}function f(e){let t=process.argv[1];if(t==null||!w.existsSync(e))return!1;try{return w.statSync(t).mtimeMs>w.statSync(e).mtimeMs}catch{return!1}}async function Ae({context:e,reusable:t,workflow:r}){let o=t.get(ie(r));if(o!=null)return re({...r,tests:o.tests});try{return re(await X({context:e,workflow:r}))}catch(i){let s=i instanceof Error?i.message:String(i);return Fe({kind:"expand-failed",message:s,workflow:r.name})}}function ie(e){let t=A({...e,tests:[]});if(t==null)throw new Error("solver: workflow is not serializable");return t}function Ie(e,t){return t==null||A(ne(t))!==A(ne(e))?new Map:new Map(t.workflows.map(r=>[ie(r),r]))}function ne(e){return{entities:e.entities,singletons:e.singletons,valueSpaces:e.valueSpaces}}function Oe(e){if(w.existsSync(e))try{return u(a,w.readFileSync(e,"utf8"))}catch{return}}import{createHash as Me}from"crypto";import se from"fs/promises";import I from"path";import{err as h,ok as O,Result as $e}from"neverthrow";var _e=".ripplo/fixtures",M=10*1024*1024,$=50*1024*1024;async function ae(e,t){let r=Ne(t);if(r.length===0)return O({});let o=I.join(e,_e),i=await Promise.all(r.map(s=>ze({fixturesRoot:o,name:s})));return $e.combine(i).andThen(He)}function Ne(e){let r=e.workflows.flatMap(o=>[...o.steps,...o.tests.flatMap(i=>i.steps)]).flatMap(o=>o.action.kind==="upload"?o.action.files:[]);return[...new Set(r)].toSorted((o,i)=>o.localeCompare(i))}async function ze({fixturesRoot:e,name:t}){if(t.includes("..")||I.isAbsolute(t))return h({kind:"fixture-invalid-name",name:t});let r=I.join(e,t),o=await se.lstat(r).catch(()=>null);if(o==null)return h({kind:"fixture-missing",name:t,path:r});if(o.isSymbolicLink())return h({kind:"fixture-symlink",name:t});if(!o.isFile())return h({kind:"fixture-not-file",name:t});let i=await se.readFile(r);if(i.byteLength>M)return h({kind:"fixture-too-large",name:t,size:i.byteLength});let s=Me("sha256").update(i).digest("hex");return O([t,{sha256:s,size:i.byteLength}])}function He(e){let t=e.reduce((r,[,o])=>r+o.size,0);return t>$?h({kind:"fixtures-total-too-large",total:t}):O(Object.fromEntries(e))}import{createHash as Ue}from"crypto";import k from"fs";import N from"path";import{z as _}from"zod";function le({cwd:e,fingerprint:t}){let r=De(e);if(r==null||r.fingerprint!==R(t))return;let o=N.join(e,".ripplo","ripplo.lock");if(!k.existsSync(o))return;let i=k.readFileSync(o,"utf8");if(R(i)===r.lockfileHash)try{return u(a,i)}catch{return}}function ce({cwd:e,fingerprint:t,lockfile:r}){let o={fingerprint:R(t),lockfileHash:R(L(a,r))},i=de(e);k.mkdirSync(N.dirname(i),{recursive:!0}),k.writeFileSync(i,JSON.stringify(o))}var Je=_.object({fingerprint:_.string(),lockfileHash:_.string()});function De(e){let t=de(e);if(!(!k.existsSync(t)||f(t)))try{let r=Je.safeParse(JSON.parse(k.readFileSync(t,"utf8")));return r.success?r.data:void 0}catch{return}}function de(e){return N.join(e,".ripplo",".local","load-cache.json")}function R(e){return Ue("sha256").update(e).digest("base64")}var c=".ripplo/ripplo.lock",E;async function pr(e){let{result:t}=await Be(e);return t}async function Be(e){let t=ue(p.join(e,".ripplo"));if(E!=null&&E.fingerprint===t&&E.result.isOk())return{fingerprint:t,result:E.result};let r=await H(e);return E={fingerprint:t,result:r},{fingerprint:t,result:r}}async function H(e){let t=p.join(e,".ripplo"),r=p.join(t,"index.ts"),o=ue(t),i=le({cwd:e,fingerprint:o});if(i!=null)return z(i);let s=Ye(r);s.catch(()=>{});let l=te(t);if(!l.ok)return v({diagnostics:l.diagnostics,kind:"typecheck-failed"});let d=await(await Qe(r,s)).andThen(g=>tt({entryPath:r,exported:g})).match(async g=>(await ae(e,g)).map(S=>({...g,fixtures:S})).mapErr(S=>({error:S,kind:"fixture-failed"})).asyncAndThen(S=>new Ve(oe(S,p.join(e,c))).mapErr(we=>we)),g=>Promise.resolve(v(g)));return d.isOk()&&ce({cwd:e,fingerprint:o,lockfile:d.value}),d}var Ke=new Set([".local","debug","node_modules","ripplo.lock"]);function ue(e){let t=p.join(e,"..","node_modules","@ripplo","testing","package.json");return[...pe(e),...Ge(t)].toSorted((r,o)=>r.localeCompare(o)).join("|")}function pe(e){return(m.existsSync(e)?m.readdirSync(e,{withFileTypes:!0}):[]).flatMap(r=>{if(Ke.has(r.name))return[];let o=p.join(e,r.name);if(r.isDirectory())return pe(o);let i=m.statSync(o);return[`${o}:${String(i.mtimeMs)}:${String(i.size)}`]})}function Ge(e){if(!m.existsSync(e))return[];let t=m.statSync(e);return[`${e}:${String(t.mtimeMs)}:${String(t.size)}`]}async function Ye(e){let r=(await Xe({bundle:!0,entryPoints:[e],format:"esm",logLevel:"silent",platform:"node",sourcemap:"inline",target:"node22",write:!1})).outputFiles[0];if(r==null)throw new Error("dsl bundle produced no output");return r.text}async function Qe(e,t){try{let r=await t;process.setSourceMapsEnabled(!0);let o=await import(Ze(e,r)),i=o!=null&&typeof o=="object"&&"default"in o?Reflect.get(o,"default"):o;return z(i)}catch(r){return v({kind:"load-threw",message:et(r)})}}function Ze(e,t){let r=p.join(p.dirname(e),".local");m.mkdirSync(r,{recursive:!0});let o=We("sha256").update(t).digest("hex").slice(0,16),i=p.join(r,`dsl-bundle-${o}.mjs`);return m.writeFileSync(i,t),qe(i).href}function et(e){return e instanceof Error?e.message:String(e)}function tt({entryPath:e,exported:t}){if(t==null||typeof t!="object"||!("lockfile"in t))return v({entryPath:e,kind:"not-ripplo"});let r=q.safeParse(Reflect.get(t,"lockfile"));return r.success?z(r.data):v({issues:r.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"invalid-lockfile"})}function P(e,t){return t==null?`Load \`/ripplo:${e}\` skill for instructions.`:`Load \`/ripplo:${e}\` skill for instructions on ${t}.`}function mr(e){return e.length===1?P(e[0]):`Before proceeding, load the ${e.map(r=>`\`/ripplo:${r}\``).join(" and ")} skills \u2014 every one, each carries rules the others don't.`}function xr(e){return[`Compilation failed: ${rt(e)}`,P("create","DSL authoring rules")].join(`
|
|
7
|
+
`)}function Sr(){return`${c} is up to date`}function Lr(e){return[`${c} is ${e==="missing"?"missing":"out of date"} \u2014 run \`npx ripplo compile\` and commit it`,P("setup")].join(`
|
|
8
|
+
`)}function br(){return`Wrote ${c}`}function rt(e){switch(e.kind){case"typecheck-failed":return["TypeScript errors in .ripplo/:",...fe(e.diagnostics)].join(`
|
|
9
|
+
`);case"not-ripplo":return`${e.entryPath} must default-export createRipplo({ entities, singletons, workflows }).`;case"invalid-lockfile":return["Lockfile failed schema validation (stale or hand-edited .ripplo/ripplo.lock):",...fe(e.issues),"Regenerate with `npx ripplo compile`."].join(`
|
|
10
|
+
`);case"load-threw":return`.ripplo/index.ts threw while loading: ${e.message}`;case"fixture-failed":return nt(e.error);case"expand-failed":return`Could not resolve tests for workflow "${e.workflow}": ${e.message}`}}function fe(e,t=8){return e.length<=t?e:[...e.slice(0,t),`\u2026 and ${String(e.length-t)} more`]}function nt(e){switch(e.kind){case"fixture-missing":return`Fixture "${e.name}" not found at ${e.path}.`;case"fixture-invalid-name":return`Invalid fixture name "${e.name}" \u2014 bare name under .ripplo/fixtures/, no .. or absolute paths.`;case"fixture-symlink":return`Fixture "${e.name}" is a symlink \u2014 only regular files allowed.`;case"fixture-not-file":return`Fixture "${e.name}" is not a regular file.`;case"fixture-too-large":return`Fixture "${e.name}" is ${j(e.size)} \u2014 over the ${j(M)} per-file limit.`;case"fixtures-total-too-large":return`Fixtures total ${j(e.total)} \u2014 over the ${j($)} limit.`}}function j(e){return`${String(Math.round(e/(1024*1024)*10)/10)} MB`}import{readFile as ct,writeFile as dt}from"fs/promises";import D from"path";import he from"safe-stable-stringify";import{createHash as me}from"crypto";import x from"fs";import J from"path";import ot from"safe-stable-stringify";import{z as U}from"zod";function ge({context:e,cwd:t}){V(e);let r=st(t,C(e));r!=null&&B(e,r)}function Ir({context:e,cwd:t}){let r=lt(t);if(!(r==null||r.model!==C(e)))return r.cleanLockfile??void 0}function Or({cleanLockfileHash:e,context:t,cwd:r}){let o=ye(r);x.mkdirSync(J.dirname(o),{recursive:!0}),x.writeFileSync(o,JSON.stringify({cleanLockfile:e,model:C(t)}))}function Mr(e){return me("sha256").update(e).digest("base64")}var it=U.object({cleanLockfile:U.string().nullable(),model:U.string()});function st(e,t){let r=J.join(e,c);if(!x.existsSync(r)||f(r))return null;let o=at(r);return o==null?null:C({entities:o.entities,singletonSchemas:o.singletons,valueSpaces:o.valueSpaces})===t?o.solved:null}function at(e){try{return u(a,x.readFileSync(e,"utf8"))}catch{return null}}function C(e){let t=ot({entities:e.entities,singletons:e.singletonSchemas,valueSpaces:e.valueSpaces});if(t==null)throw new Error("solve-cache: context is not serializable");return me("sha256").update(t).digest("base64")}function lt(e){let t=ye(e);if(!(!x.existsSync(t)||f(t)))try{let r=it.safeParse(JSON.parse(x.readFileSync(t,"utf8")));return r.success?r.data:void 0}catch{return}}function ye(e){return J.join(e,".ripplo",".local","solve-cache.json")}async function Xr(e){let t=await H(e);return t.isOk()&&await ut(e,t.value),t}async function ut(e,t){let r=await pt(e,t);return await dt(D.join(e,c),L(a,r)),r}var ke=new WeakMap;function pt(e,t){let r=ke.get(t);if(r!=null)return r;let o=ft(e,t).then(i=>i??gt(e,t));return ke.set(t,o),o}function Vr(e){return e.workflows.filter(t=>t.stub).map(t=>t.name)}async function ft(e,t){if(f(D.join(e,c)))return null;let r=await mt(e);return r?.checks==null?null:he(xe(r))===he(xe(t))?T(r):null}async function mt(e){try{let t=await ct(D.join(e,c),"utf8");return u(a,t)}catch{return null}}function xe(e){return{...e,checks:void 0,solved:{cosat:{},subsume:{}}}}async function gt(e,t){let r=G(t);ge({context:r,cwd:e});let o=await Q(t),i=await Y(t);await Z({context:r,facts:i.facts});let s=await K(r),l={...t,checks:o,solved:s};return T(u(a,L(a,l)))}import{createMessageConnection as yt,NotificationType as Se,RequestType as ht,RequestType0 as Le,SocketMessageReader as kt,SocketMessageWriter as xt}from"vscode-jsonrpc/node";import{z as n}from"zod";var St="daemon.sock",Lt="daemon.log";function Qr(e){return F(e,St)}function Zr(e){return F(e,Lt)}function en(e){return yt(new kt(e),new xt(e))}var tn=n.object({all:n.boolean(),headed:n.boolean(),tests:n.array(n.string())}),rn=n.object({jobId:n.string(),total:n.number()}),bt=n.enum(["on","off","stalled"]),wt=n.object({attempts:n.number(),findings:n.number()}),nn=n.object({active:n.number(),explorer:bt,exploring:n.number(),progress:wt,queued:n.number(),sseHealth:n.object({detail:n.string().optional(),ok:n.boolean()}).optional(),version:n.string().optional()}),Et=n.enum(["MAX_RUNS","OVERAGE_CAP","MAX_AGENTS","MAX_CONCURRENT_RUNS","MAX_PROJECTS"]),vt=n.discriminatedUnion("type",[n.object({code:Et,type:n.literal("limit")}),n.object({detail:n.string(),type:n.literal("generic")})]),Rt=n.discriminatedUnion("kind",[n.object({kind:n.literal("pass")}),n.object({findingLines:n.array(n.string()),kind:n.literal("findings")}),n.object({detail:n.string(),kind:n.literal("error")}),n.object({kind:n.literal("dispatch-error"),reason:vt}),n.object({detail:n.string(),kind:n.literal("dispatch-timeout")}),n.object({detail:n.string(),kind:n.literal("infra-error")})]),Pt=n.discriminatedUnion("kind",[n.object({kind:n.literal("test-started"),runId:n.string(),testName:n.string(),workflowName:n.string()}),n.object({kind:n.literal("test-outcome"),outcome:Rt,runId:n.string(),testName:n.string(),workflowName:n.string()})]),on=n.object({event:Pt,jobId:n.string()}),sn=n.object({failed:n.number(),jobId:n.string(),notRun:n.number(),passed:n.number()}),an=n.discriminatedUnion("code",[n.object({code:n.literal("compile-failed"),detail:n.string(),diagnostics:n.array(n.string()).default([])}),n.object({code:n.literal("selection-conflicting-flags")}),n.object({code:n.literal("selection-nothing-selected")}),n.object({code:n.literal("selection-unknown-ids"),known:n.array(n.string()),unknown:n.array(n.string())}),n.object({code:n.literal("scope-failed"),detail:n.string()}),n.object({code:n.literal("app-unreachable"),detail:n.string(),url:n.string()}),n.object({code:n.literal("engine-unreachable"),detail:n.string(),url:n.string()}),n.object({code:n.literal("sync-failed"),detail:n.string()}),n.object({code:n.literal("bad-message")})]),ln=new ht("ripplo/enqueue"),cn=new Le("ripplo/status"),dn=new Le("ripplo/shutdownIfIdle"),un=new Se("ripplo/jobEvent"),pn=new Se("ripplo/jobDone");export{Tt as a,_e as b,c,pr as d,Be as e,H as f,P as g,mr as h,xr as i,Sr as j,Lr as k,br as l,ge as m,Ir as n,Or as o,Mr as p,Xr as q,ut as r,pt as s,Vr as t,Qr as u,Zr as v,en as w,tn as x,rn as y,nn as z,Rt as A,on as B,sn as C,an as D,ln as E,cn as F,dn as G,un as H,pn as I};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{B as R,C as h,D as v,E as x,F as q,G as p,H as N,I as O,a as w,f as S,i as P,t as g,u,v as y,w as C,y as E,z as b}from"./chunk-
|
|
4
|
+
import{B as R,C as h,D as v,E as x,F as q,G as p,H as N,I as O,a as w,f as S,i as P,t as g,u,v as y,w as C,y as E,z as b}from"./chunk-E4AOUQQ7.js";import{i as D}from"./chunk-THHZNLXN.js";import{fa as I}from"./chunk-VGYX2VAS.js";import{spawn as J}from"child_process";import A from"fs";import F from"net";import{setTimeout as k}from"timers/promises";import{err as d,ok as f}from"neverthrow";import{ResponseError as G}from"vscode-jsonrpc/node";var T=12e4,_=300,M=5e3;async function sn({cliEntry:o,cwd:n}){let e=u(n),r=await i(e);return r!=null?j({cliEntry:o,connection:l(r,!1),cwd:n}):V({cliEntry:o,cwd:n,versionNote:void 0})}async function cn({cliEntry:o,cwd:n}){let e=await i(u(n));return e==null?d({kind:"not-running"}):j({cliEntry:o,connection:l(e,!1),cwd:n})}async function V({cliEntry:o,cwd:n,versionNote:e}){let r=H({cliEntry:o,cwd:n});if(r!=null)return d(r);let t=await Q(u(n));return t==null?d({deadlineMs:T,kind:"connect-timeout",logPath:y(n)}):f({...l(t,!0),versionNote:e})}async function j({cliEntry:o,connection:n,cwd:e}){let r=await $(n);if(r==null||r.version===w())return f(n);let t={daemonVersion:r.version};return await U(n)?(n.socket.destroy(),await W(u(e))?V({cliEntry:o,cwd:e,versionNote:{...t,kind:"restarted"}}):d({kind:"connection-lost"})):f({...n,versionNote:{...t,kind:"stale-busy"}})}async function U(o){try{return await o.rpc.sendRequest(p)}catch{return!1}}var K=1e4;async function W(o){let n=Date.now()+K,e=await i(o);for(;e!=null&&Date.now()<n;)e.destroy(),await k(_),e=await i(o);return e?.destroy(),e==null}async function un({connection:o,onEvent:n,request:e,token:r}){let t=await z({connection:o,onEvent:n,request:e,token:r});return t.kind==="transport"?d(t.error):f(t)}async function dn(o){let n=await i(u(o));if(n==null)return!1;let e=l(n,!1);try{return await e.rpc.sendRequest(p)}catch{return!1}finally{n.destroy()}}async function ln(o){try{await o.rpc.sendRequest(p)}catch{}}async function L(o){let n=await i(u(o));if(n==null)return{kind:"not-running"};let e=l(n,!1),r=await Promise.race([$(e),k(M).then(()=>null)]);return n.destroy(),r==null?{kind:"unresponsive",timeoutMs:M}:{kind:"running",status:r}}async function $(o){try{let n=await o.rpc.sendRequest(q),e=b.safeParse(n);return e.success?e.data:null}catch{return null}}function z({connection:o,onEvent:n,request:e,token:r}){let{rpc:t}=o;return new Promise(m=>{let a=s=>{m(s)};t.onNotification(N,s=>{let c=R.safeParse(s);if(!c.success){a({error:{kind:"bad-frame"},kind:"transport"});return}n(c.data.event)}),t.onNotification(O,s=>{let c=h.safeParse(s);if(!c.success){a({error:{kind:"bad-frame"},kind:"transport"});return}a({failed:c.data.failed,kind:"done",notRun:c.data.notRun,passed:c.data.passed})}),t.onClose(()=>{a({error:{kind:"connection-lost"},kind:"transport"})}),t.sendRequest(x,e,r).then(s=>{E.safeParse(s).success||a({error:{kind:"bad-frame"},kind:"transport"})}).catch(s=>{a(B(s))})})}function B(o){if(o instanceof G){let n=v.safeParse(o.data);return n.success?{error:n.data,kind:"daemon-error"}:{error:{kind:"bad-frame"},kind:"transport"}}return{error:{kind:"connection-lost"},kind:"transport"}}function l(o,n){let e=C(o);return e.listen(),{rpc:e,socket:o,spawned:n,versionNote:void 0}}function i(o){return new Promise(n=>{let e=F.connect(o);e.once("connect",()=>{n(e)}),e.once("error",()=>{n(null)})})}function H({cliEntry:o,cwd:n}){try{D(n);let e=A.openSync(y(n),"a");return J(process.execPath,[o,"daemon"],{cwd:n,detached:!0,stdio:["ignore",e,e]}).unref(),A.closeSync(e),null}catch(e){return{kind:"spawn-failed",message:e instanceof Error?e.message:String(e)}}}async function Q(o){let n=Date.now()+T,e=await i(o);for(;e==null&&Date.now()<n;)await k(_),e=await i(o);return e}async function wn(o){let n=process.cwd(),e=await S(n);e.isErr()&&(process.stderr.write(`${P(e.error)}
|
|
5
5
|
`),process.exit(1));let r=g(e.value),t=await L(n);if(o.format==="summary"){r.length>0&&process.stdout.write(`stub workflows: ${r.join(", ")}
|
|
6
6
|
`),process.stdout.write(`${I(t)}
|
|
7
7
|
`);return}let m={daemon:t.kind==="running"?{active:t.status.active,explorer:t.status.explorer,exploring:t.status.exploring,progress:t.status.progress,queued:t.status.queued,running:!0}:{running:t.kind==="unresponsive",state:t.kind},tests:r.map(a=>({id:a,implemented:!1}))};process.stdout.write(`${JSON.stringify(m,null,2)}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var l=(b,a,c,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&f(b,d,{get:()=>a[d],enumerable:!(e=h(a,d))||e.enumerable});return b};var n=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b};
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{c as w}from"./chunk-D6FZ55DP.js";import{A as yn,E as mn,F as gn,G as hn,H as Rn,I as Sn,a as $,b as D,c as Je,d as Qe,e as ze,f as O,g as Ge,i as U,s as N,w as pn,x as fn}from"./chunk-E4AOUQQ7.js";import{c as qe,f as c,g as p,j as He,k as Be}from"./chunk-THHZNLXN.js";import{A as rn,B as v,C as tn,E as on,F as an,H as sn,M as ln,S as dn,T as cn,W as un,X as _,a as Xe,b as Ye,c as ue,d as R,e as A,f as Ze,g as en,i as L,z as nn}from"./chunk-VGYX2VAS.js";import{L as Ke,M,N as m,i as F,l as C,m as Ve}from"./chunk-SAYJ5AQK.js";import wn from"fs";import V from"path";import{config as Lr}from"dotenv";import{z as H}from"zod";import{err as _r,ok as xn}from"neverthrow";import q from"fs";import ye from"path";import{err as pe,ok as kn}from"neverthrow";import{z as W}from"zod";var $r=ye.join(".ripplo","project.json"),fe=[".env",".env.local"],Dr=W.object({envFiles:W.array(W.string().min(1)).optional(),projectId:W.string().min(1)});function vn(e){return ye.join(e,$r)}function me(e){let n=vn(e);return q.existsSync(n)?Or(n).andThen(r=>{let t=Dr.safeParse(r);return t.success?kn({envFiles:t.data.envFiles??fe,projectId:t.data.projectId}):pe({issues:t.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:n})}):pe({kind:"project-file-missing",path:n})}function ge(e){return me(e).match(n=>n,()=>{})}function Or(e){try{return kn(JSON.parse(q.readFileSync(e,"utf8")))}catch(n){return pe({issues:[n instanceof Error?n.message:String(n)],kind:"project-file-invalid",path:e})}}function zi({cwd:e,envFiles:n,projectId:r}){let t=vn(e);q.mkdirSync(ye.dirname(t),{recursive:!0});let o={projectId:r};n!=null&&!Ur(n)&&(o.envFiles=[...n]),q.writeFileSync(t,JSON.stringify(o,null,2)+`
|
|
5
|
+
`)}function Ur(e){return e.length!==fe.length?!1:e.every((n,r)=>n===fe[r])}function ta(e){let r=ge(e)?.envFiles??[".env",".env.local"],t=V.join(e,".ripplo");r.forEach(o=>{let i=V.resolve(t,o);wn.existsSync(i)&&Lr({override:!0,path:i,quiet:!0})}),B=void 0}var Nr=H.object({RIPPLO_APP_URL:H.url(),RIPPLO_ENGINE_URL:H.url(),RIPPLO_WEBHOOK_SECRET:H.string().min(1)}),B;function K(){return B!=null?xn(B):qr().map(e=>(B=e,e))}function Wr(e){let r=ge(e)?.envFiles??[],t=V.join(e,".ripplo");return r.map(o=>V.resolve(t,o)).filter(o=>!wn.existsSync(o))}function qr(){let e=Nr.safeParse(process.env);if(!e.success)return _r({issues:e.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`),kind:"env-invalid",missingEnvFiles:Wr(process.cwd())});let n=e.data;return xn({appUrl:n.RIPPLO_APP_URL,engineUrl:n.RIPPLO_ENGINE_URL,webhookSecret:n.RIPPLO_WEBHOOK_SECRET})}var J=class extends Error{failure;constructor(n){super(n.kind),this.name="CliError",this.failure=n}};function da(e){return e instanceof J?he(e.failure):e instanceof Error?e.message:String(e)}function he(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).",Ge("setup")].join(`
|
|
6
|
+
`);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(n=>` ${n}`),"Fix the file by hand or re-run `npx ripplo init`."].join(`
|
|
7
|
+
`);case"not-authenticated":return["Not signed in. Run `npx ripplo auth login`.","(Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)"].join(`
|
|
8
|
+
`);case"env-invalid":return Hr(e);case"playwright-install-failed":return["Playwright browser install failed \u2014 Chromium is still missing.","Run `npx playwright install chromium` and check its output for network, proxy, or disk-space errors."].join(`
|
|
9
|
+
`);case"gitdir-unrecognized":return`Unrecognized .git file at ${e.marker} \u2014 expected a directory or a "gitdir:" pointer (worktree). Is the repo corrupted?`;case"gitdir-empty":return`Empty gitdir pointer at ${e.marker} \u2014 the worktree's .git file points nowhere. Re-create the worktree.`;case"oauth-device-code-failed":return[`Could not start sign-in (device-code request failed): ${e.description}`,"Is the Ripplo server reachable? Check RIPPLO_SERVER_URL and retry."].join(`
|
|
10
|
+
`);case"oauth-authorization-failed":return[`Sign-in failed (${e.code}): ${e.description}`,e.code==="expired_token"?"The approval window expired \u2014 run `npx ripplo auth login` again.":"Run `npx ripplo auth login` to retry."].join(`
|
|
11
|
+
`);case"compilation-failed":return U(e.error)}}function ca(e,n){let r=n instanceof Error?n.message:String(n);return`ripplo hook "${e}" crashed and was skipped \u2014 ${r}`}function Hr(e){let n=e.missingEnvFiles.length===0?[]:["Declared env files not found:",...e.missingEnvFiles.map(r=>` ${r}`),"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(r=>` ${r}`),"Add the missing values to the env files declared in .ripplo/project.json.",...n].join(`
|
|
12
|
+
`)}import{err as Kr,ok as Jr}from"neverthrow";import{z as Re}from"zod";var Br="https://ripplo.ai";function En(){return Pn().RIPPLO_SERVER_URL}function In(){return Pn().RIPPLO_PROJECT_ID}var Vr=Re.object({RIPPLO_PROJECT_ID:Re.string().min(1).optional(),RIPPLO_SERVER_URL:Re.string().min(1).default(Br)}),bn;function Pn(){return bn??=Vr.parse(process.env),bn}import Cn from"fs";import Se from"path";function An(e){let n=Cn.realpathSync(e),r=n,t=Se.dirname(r);for(;t!==r;){if(Cn.existsSync(Se.join(r,".git")))return r;r=t,t=Se.dirname(r)}return n}function x(e){return me(e).andThen(n=>K().andThen(r=>{let t=En(),o=Be(t);return o==null?Kr({kind:"not-authenticated"}):Jr({appUrl:r.appUrl,cwd:An(e),engineUrl:r.engineUrl,projectId:In()??n.projectId,ripploServerUrl:t,token:o,webhookSecret:r.webhookSecret})}))}import Qr from"p-retry";import{graphql as Tn}from"gql.tada";var zr=Tn(`
|
|
13
|
+
query OpenFindingsForRetire($projectId: String!) {
|
|
14
|
+
exploreFindings(projectId: $projectId, status: open) {
|
|
15
|
+
signature
|
|
16
|
+
reproRun {
|
|
17
|
+
reproJson
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`),Gr=Tn(`
|
|
22
|
+
mutation RetireStaleFinding($projectId: String!, $signature: String!) {
|
|
23
|
+
retireStaleFinding(projectId: $projectId, signature: $signature)
|
|
24
|
+
}
|
|
25
|
+
`);function jn(e){Qr(()=>Xr(e),{factor:2,minTimeout:200,retries:10}).catch(n=>{p.warn({err:n},"retire stale findings failed")})}async function Xr({config:e,cwd:n,lockfile:r}){let o=(await c({config:e,document:zr,variables:{projectId:e.projectId}})).exploreFindings,i=await Yr(o,await N(n,r));i.length!==0&&(await Promise.all(i.map(s=>et(e,s))),p.info({count:i.length},"retired findings whose trail no longer replays"))}async function Yr(e,n){return(await Promise.all(e.map(async t=>await Zr(t,n)?t.signature:null))).filter(t=>t!=null)}async function Zr(e,n){let r=e.reproRun?.reproJson;if(r==null)return!1;let t=ln.safeParse(JSON.parse(r));return t.success?(await _(n,t.data)).kind==="unplannable":!1}function et(e,n){return c({config:e,document:Gr,variables:{projectId:e.projectId,signature:n}})}import nt from"p-queue";var rt=4,tt={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},Q=new nt({concurrency:rt}),S={headedActive:0,interactiveActive:0,interactiveQueued:0},Fn={current:null};function ja({headed:e,task:n,workClass:r}){let t=tt[r];return r==="p3-explore"?Q.add(n,{priority:t}):(S.interactiveQueued+=1,z(),Q.add(()=>ot({headed:e,task:n}),{priority:t}))}function Fa(e){!Number.isFinite(e)||e<1||(Q.concurrency=Math.floor(e),z())}function ke(){return{active:S.interactiveActive,headedActive:S.headedActive,poolSize:Q.concurrency,queued:S.interactiveQueued}}function Ma(e){Fn.current=e}async function ot({headed:e,task:n}){S.interactiveQueued-=1,S.interactiveActive+=1,S.headedActive+=e?1:0,z();try{return await n()}finally{S.interactiveActive-=1,S.headedActive-=e?1:0,z()}}function z(){Fn.current?.()}import ve from"fs";import we from"path";function Mn(e){try{let n=it(e);if(n==null)return;let r=we.join(n,"HEAD"),t=ve.readFileSync(r,"utf8").trim(),o="ref: refs/heads/";return t.startsWith(o)?t.slice(o.length):t.length===0?void 0:t.slice(0,7)}catch{return}}function it(e){let n=we.join(e,".git");if(ve.statSync(n).isDirectory())return n;let t=ve.readFileSync(n,"utf8").trim(),o="gitdir:";if(!t.startsWith(o))return;let i=t.slice(o.length).trim();if(i.length!==0)return we.resolve(e,i)}import at from"crypto";import{readFile as $n}from"fs/promises";import Dn from"path";import{graphql as xe}from"gql.tada";import{err as st,ok as lt}from"neverthrow";var dt=xe(`
|
|
26
|
+
mutation SyncDevSession(
|
|
27
|
+
$projectId: String!
|
|
28
|
+
$cwd: String!
|
|
29
|
+
$branch: String
|
|
30
|
+
$lockfileContent: String
|
|
31
|
+
$fixtures: [SyncDevFixtureInput!]
|
|
32
|
+
$entities: [SyncDevEntityInput!]!
|
|
33
|
+
$singletons: [SyncDevSingletonInput!]
|
|
34
|
+
$workflows: [SyncDevWorkflowInput!]!
|
|
35
|
+
) {
|
|
36
|
+
syncDevSession(
|
|
37
|
+
projectId: $projectId
|
|
38
|
+
cwd: $cwd
|
|
39
|
+
branch: $branch
|
|
40
|
+
lockfileContent: $lockfileContent
|
|
41
|
+
fixtures: $fixtures
|
|
42
|
+
entities: $entities
|
|
43
|
+
singletons: $singletons
|
|
44
|
+
workflows: $workflows
|
|
45
|
+
) {
|
|
46
|
+
id
|
|
47
|
+
hooksPaused
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`);async function Qa(e,n){let r=await O(e);if(r.isErr())return st({error:r.error,kind:"compilation-failed"});let t=await b({config:n,cwd:e,lockfile:r.value});return lt({devSessionId:t.devSessionId,lockfile:r.value})}async function b(e){let n=Ke(e.lockfile);return pt({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:n})}var ct=xe(`
|
|
51
|
+
query DevSessionSyncState($projectId: String!, $cwd: String!) {
|
|
52
|
+
project(id: $projectId) {
|
|
53
|
+
devSession(cwd: $cwd) {
|
|
54
|
+
id
|
|
55
|
+
hooksPaused
|
|
56
|
+
lockfileHash
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`),ut=xe(`
|
|
61
|
+
mutation AnnounceDevSessionActive($projectId: String!, $cwd: String!) {
|
|
62
|
+
announceDevSessionActive(projectId: $projectId, cwd: $cwd)
|
|
63
|
+
}
|
|
64
|
+
`);async function za(e){let n=await be(e.cwd);if(n!=null){let t=(await c({config:e.config,document:ct,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null))?.project?.devSession;if(t!=null&&t.lockfileHash===n)return await c({config:e.config,document:ut,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null),{devSessionId:t.id,hooksPaused:t.hooksPaused}}return b(e)}async function be(e){let n=await On(e);return n==null?null:at.createHash("sha256").update(n).digest("hex")}async function pt({config:e,cwd:n,fixtures:r,payload:t}){let o=Mn(n),i=await On(n),s=await ft(n,r),a=await c({config:e,document:dt,variables:{branch:o??null,cwd:n,entities:t.entities.map(l=>({description:l.description,name:l.name})),fixtures:s,lockfileContent:i,projectId:e.projectId,singletons:t.singletons.map(l=>({defaultValue:l.defaultValue,description:l.description,name:l.name,type:l.type})),workflows:t.workflows.map(l=>({entities:[...l.entities],expectedOutcome:l.expectedOutcome,name:l.name,slug:l.slug,sourcePath:l.sourcePath,spec:JSON.stringify(l.spec)}))}});if(a.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:a.syncDevSession.id,hooksPaused:a.syncDevSession.hooksPaused}}async function ft(e,n){let r=Object.entries(n);return Promise.all(r.map(async([t,o])=>({contentBase64:(await $n(Dn.join(e,D,t))).toString("base64"),sha256:o.sha256})))}async function On(e){try{return await $n(Dn.join(e,Je),"utf8")}catch{return null}}import{randomUUID as qt}from"crypto";import{createId as Ht}from"@paralleldrive/cuid2";import{CancellationTokenSource as Bt,ResponseError as Vt}from"vscode-jsonrpc/node";async function Un(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(2e3)}),null}catch(n){return n instanceof Error?n.message:String(n)}}async function Ln(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(25e3)}),null}catch(n){return n instanceof Error?n.message:String(n)}}import{graphql as yt}from"gql.tada";var mt=yt(`
|
|
65
|
+
mutation DaemonCreateRun(
|
|
66
|
+
$id: String
|
|
67
|
+
$workflowId: String!
|
|
68
|
+
$testId: String
|
|
69
|
+
$clientVersion: String
|
|
70
|
+
$executor: RunExecutor
|
|
71
|
+
$target: RunTarget
|
|
72
|
+
$lockfileHash: String
|
|
73
|
+
) {
|
|
74
|
+
createRun(
|
|
75
|
+
id: $id
|
|
76
|
+
workflowId: $workflowId
|
|
77
|
+
testId: $testId
|
|
78
|
+
executor: $executor
|
|
79
|
+
target: $target
|
|
80
|
+
clientVersion: $clientVersion
|
|
81
|
+
lockfileHash: $lockfileHash
|
|
82
|
+
) {
|
|
83
|
+
__typename
|
|
84
|
+
... on MutationCreateRunSuccess {
|
|
85
|
+
data {
|
|
86
|
+
id
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
... on LimitExceededError {
|
|
90
|
+
code
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`);async function _n(e){try{let r=(await c({config:e.config,document:mt,variables:gt(e)})).createRun;return r==null?G({detail:"create-run-null",type:"generic"}):r.__typename==="MutationCreateRunSuccess"?null:r.__typename==="LimitExceededError"?G({code:r.code,type:"limit"}):G({detail:r.__typename,type:"generic"})}catch(n){return ht(n)}}function gt({executor:e,lockfileHash:n,runId:r,target:t}){return{clientVersion:$(),executor:e,id:r,lockfileHash:n,target:e==="cloud"?"tunnel":void 0,testId:t.testId,workflowId:t.workflowId}}function G(e){return{kind:"dispatch-error",reason:e}}function ht(e){return e instanceof qe?{detail:e.message,kind:"infra-error"}:G({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{graphql as Rt}from"gql.tada";async function Nn(e,n){let t=(await c({config:e,document:St,variables:{cwd:n,projectId:e.projectId}})).project?.devSession?.workflows??[];return new Map(t.flatMap(o=>o.tests.map(i=>[`${o.slug}/${i.slug}`,{testId:i.id,workflowId:o.id}])))}var St=Rt(`
|
|
95
|
+
query DaemonWorkflows($projectId: String!, $cwd: String!) {
|
|
96
|
+
project(id: $projectId) {
|
|
97
|
+
id
|
|
98
|
+
devSession(cwd: $cwd) {
|
|
99
|
+
id
|
|
100
|
+
workflows {
|
|
101
|
+
id
|
|
102
|
+
slug
|
|
103
|
+
tests {
|
|
104
|
+
id
|
|
105
|
+
slug
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`);import{CancellationTokenSource as kt}from"vscode-jsonrpc/node";function Ee(e){return`${e.workflowSlug}/${e.testSlug}`}function Wn(e){let{headed:n,inflight:r,jobId:t,lockfileHashValue:o,onExpire:i,runId:s,selection:a,timeoutMs:l}=e,u=Ee(a),d=`${u}@${o}@${String(n)}`,f=r.get(d);if(f!=null)return f.jobIds.add(t),null;let y={cancellation:new kt,claimed:!1,claimKey:u,headed:n,inflightKey:d,jobIds:new Set([t]),runId:s,testName:a.testName,timer:null,workflowName:a.workflowName};return y.timer=setTimeout(()=>{X(r,y),i(y)},l),r.set(d,y),y}function X(e,n){n.timer!=null&&(clearTimeout(n.timer),n.timer=null),e.delete(n.inflightKey)}function Ie(e,n){let r=[...e.values()].find(t=>t.runId===n&&!t.claimed);return r==null?null:(r.claimed=!0,r.timer!=null&&(clearTimeout(r.timer),r.timer=null),r)}function qn(e,n){[...e.values()].filter(r=>r.jobIds.has(n)).forEach(r=>{r.jobIds.delete(n),r.jobIds.size===0&&(X(e,r),r.cancellation.cancel())})}import{err as Pe,ok as Hn}from"neverthrow";function Vn({all:e,ids:n,lockfile:r}){if(e&&n.length>0)return Pe({kind:"conflicting-flags"});if(e)return Hn(r.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>R(s))));if(n.length===0)return Pe({kind:"nothing-selected"});let t=n.map(i=>({id:i,refs:wt(r,i)})),o=t.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?Pe({kind:"unknown-ids",known:vt(r),unknown:o}):Hn([...new Set(t.flatMap(i=>i.refs))])}function Kn(e,n){let r=new Map(A(e).map(t=>[t.ref,{testName:t.test.name,testSlug:t.test.slug,workflowName:t.workflow.name,workflowSlug:m(t.workflow.name)}]));return n.map(t=>{let o=r.get(t);if(o==null)throw new Error(`selectionsFor: ref not in lockfile: ${t}`);return o})}function vt(e){return e.workflows.map(n=>m(n.name))}function wt(e,n){let r=e.workflows.find(t=>t.name===n||m(t.name)===m(n));return r!=null?r.tests.map(t=>R(t)):A(e).filter(t=>t.ref===n||Bn(t.ref)===Bn(n)).map(t=>t.ref)}function Bn(e){let n=e.lastIndexOf("/");return n===-1?m(e):`${m(e.slice(0,n))}/${m(e.slice(n+1))}`}import{err as Te,ok as Xn}from"neverthrow";import{graphql as Yn}from"gql.tada";import{graphql as At}from"gql.tada";import{execFileSync as xt}from"child_process";var bt=256*1024*1024;function T(e,n){return xt("git",[...e],{cwd:n,encoding:"utf8",maxBuffer:bt,stdio:["ignore","pipe","pipe"]})}function ps(e,n){try{return T(e,n)}catch{return""}}import Pt from"fs";import Et from"fs";import Ce from"path";var It=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function hs(e){return Jn(e)!=null}function Y(e){let n=Jn(e);return n==null?!1:It.some(r=>Et.existsSync(Ce.join(n,r)))}function Jn(e){try{let n=T(["rev-parse","--git-dir"],e).trim();return n.length===0?null:Ce.isAbsolute(n)?n:Ce.resolve(e,n)}catch{return null}}function Ct(e){return He(e,"hooks-paused")}function Qn(e){return Pt.existsSync(Ct(e))||Y(e)?!1:w(e)}var Tt=At(`
|
|
112
|
+
mutation AutoScopeAddDirty($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
113
|
+
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
114
|
+
__typename
|
|
115
|
+
... on MutationAddDirtyTestsToScopeSuccess {
|
|
116
|
+
data {
|
|
117
|
+
id
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
`);async function js({cwd:e,editedPath:n,lockfile:r}){if(!Qn(e))return{addedSlugs:[]};let t=new Set(Ae(e)),o=r.workflows.filter(l=>l.sourcePath!=null&&Ft({dirtySet:t,editedPath:n,sourcePath:l.sourcePath})).map(l=>m(l.name));if(o.length===0)return{addedSlugs:[]};let i=x(e).unwrapOr(void 0);return i==null?{addedSlugs:[]}:await b({config:i,cwd:e,lockfile:r}).catch(l=>(p.warn("auto-sync failed: %s",l instanceof Error?l.message:String(l)),null))==null?{addedSlugs:[]}:{addedSlugs:await jt({cfg:i,slugs:o})?o:[]}}async function jt({cfg:e,slugs:n}){let t=(await c({config:e,document:Tt,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:[...n]}}).catch(o=>(p.warn("auto-scope failed: %s",o instanceof Error?o.message:String(o)),null)))?.addDirtyTestsToScope;return t?.__typename!=="MutationAddDirtyTestsToScopeSuccess"?!1:t.data.length>0}function Ft({dirtySet:e,editedPath:n,sourcePath:r}){return e.has(r)||n!=null&&n.endsWith(r)}var zn=".ripplo/workflows/",Gn=" -> ";function Ae(e){let n;try{n=T(["status","--porcelain","-uall","--",".ripplo/workflows"],e)}catch{return[]}return n.split(`
|
|
123
|
+
`).map(r=>r.slice(3).trim()).map(r=>r.includes(Gn)?r.split(Gn)[1]:r).filter(r=>r!=null).filter(r=>r.startsWith(zn)&&r.endsWith(".ts")).map(r=>r.slice(zn.length)).filter(r=>r!=="index.ts"&&!r.endsWith("/index.ts"))}async function Zn({config:e,cwd:n,lockfile:r}){await $t({config:e,cwd:n,lockfile:r});let t=await Ot(e);if(t.isErr())return Te(t.error);let o=new Map(r.workflows.filter(s=>!s.stub).map(s=>[m(s.name),s])),i=[...new Set(t.value)].flatMap(s=>{let a=o.get(s);return a==null?[]:a.tests.map(l=>R(l))});return i.length===0?Te({kind:"scope-empty"}):Xn(i)}var Mt=Yn(`
|
|
124
|
+
mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
125
|
+
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
126
|
+
__typename
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
`);async function $t({config:e,cwd:n,lockfile:r}){let t=new Set(Ae(n)),o=r.workflows.filter(i=>i.sourcePath!=null&&t.has(i.sourcePath)).map(i=>m(i.name));o.length!==0&&await c({config:e,document:Mt,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{p.warn({err:i},"auto-scope of dirty tests failed")})}var Dt=Yn(`
|
|
130
|
+
query ScopeSelection($projectId: String!, $cwd: String!) {
|
|
131
|
+
project(id: $projectId) {
|
|
132
|
+
id
|
|
133
|
+
devSession(cwd: $cwd) {
|
|
134
|
+
id
|
|
135
|
+
scopeItems {
|
|
136
|
+
id
|
|
137
|
+
workflow {
|
|
138
|
+
id
|
|
139
|
+
slug
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
`);async function Ot(e){try{let r=(await c({config:e,document:Dt,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return Xn(r.flatMap(t=>t.workflow==null?[]:[t.workflow.slug]))}catch(n){return Te({detail:n instanceof Error?n.message:String(n),kind:"scope-fetch-failed"})}}import{graphql as Ut}from"gql.tada";var Lt=2e3,_t=Ut(`
|
|
146
|
+
query DaemonCloudRunStatus($runId: String!) {
|
|
147
|
+
run(id: $runId) {
|
|
148
|
+
status
|
|
149
|
+
failureReason
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
`);function nr({config:e,onComplete:n,onStarted:r,runId:t,signal:o}){let i=!1,s,a=!1,l=async()=>{if(i||o.aborted)return;let u=await Nt(e,t).catch(()=>"unknown");if(!(i||o.aborted)){if(!a&&(u==="running"||er(u))&&(a=!0,r()),er(u)){i=!0,n(Wt(u));return}s=setTimeout(()=>{l()},Lt)}};return l(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function Nt(e,n){let t=(await c({config:e,document:_t,variables:{runId:n}})).run?.status;return t??"unknown"}function er(e){return e==="passed"||e==="failed"||e==="cancelled"||e==="unready"}function Wt(e){return e==="passed"?{kind:"pass"}:e==="failed"?{detail:"failed",kind:"error"}:e==="cancelled"?{detail:"cancelled",kind:"error"}:e==="unready"?{detail:"unready",kind:"error"}:{detail:"unknown",kind:"error"}}var Kt=12e4,Jt=-32099,je=new Set,rr=new Map;function al(e){je.add(e)}function Qt(e){let n=new AbortController;return e.isCancellationRequested?(n.abort(),n.signal):(e.onCancellationRequested(()=>{n.abort()}),n.signal)}function sl(e){let n={...e,inflight:new Map,jobs:new Map};return{claim:r=>Zt(n,r),handleConnection:r=>{zt(n,r)},idle:()=>ir(n)}}function zt(e,n){let r=pn(n);r.onRequest(mn,(t,o)=>Gt({connection:r,ctx:e,params:t,token:o})),r.onRequest(gn,()=>{let t=ke();return{active:t.active,queued:t.queued,sseHealth:e.sseHealth(),version:$(),...e.explorationStatus()}}),r.onRequest(hn,()=>{let t=ir(e);return t&&e.onShutdownRequest(),t}),r.onClose(()=>{Xt(e,r)}),r.onError(t=>{p.warn({err:t},"ipc connection error")}),n.on("error",t=>{p.warn({err:t},"ipc socket error")}),r.listen()}function ir(e){let n=ke();return e.jobs.size===0&&n.active===0&&n.queued===0}async function Gt({connection:e,ctx:n,params:r,token:t}){let o=fn.safeParse(r);if(!o.success)throw tr({code:"bad-message"});await n.ready;let i=await no({config:n.config,cwd:n.cwd,message:o.data});if(i.kind==="error")throw tr(i.error);let s=qt(),a=new Bt;return t.onCancellationRequested(()=>{ar(n,s)}),n.jobs.set(s,{cancellation:a,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),lo({ctx:n,headed:o.data.headed,jobId:s,lockfileHashValue:i.lockfileHashValue,selections:i.selections,targetsByClaimKey:i.targetsByClaimKey,token:a.token}).catch(l=>{p.error({err:l},"ipc dispatch failed")}),{jobId:s,total:i.selections.length}}function tr(e){return new Vt(Jt,e.code,e)}function ar(e,n){let r=e.jobs.get(n);r!=null&&(r.cancellation.cancel(),e.jobs.delete(n),qn(e.inflight,n))}function Xt(e,n){[...e.jobs.entries()].filter(([,r])=>r.connection===n).forEach(([r])=>{ar(e,r)})}function sr(e,n,r){let t=e.jobs.get(n);t!=null&&(or(()=>t.connection.sendNotification(Rn,{event:r,jobId:n})),r.kind==="test-outcome"&&(Yt(t,r.outcome.kind),t.passed+t.failed+t.notRun>=t.total&&(or(()=>t.connection.sendNotification(Sn,{failed:t.failed,jobId:n,notRun:t.notRun,passed:t.passed})),e.jobs.delete(n))))}function or(e){Promise.resolve().then(e).catch(n=>{p.warn({err:n},"ipc notification failed")})}function Yt(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 E(e,n,r){n.jobIds.forEach(t=>{sr(e,t,r)})}function Zt(e,n){let r=Ie(e.inflight,n);return r==null?null:{headed:r.headed,token:r.cancellation.token,finished:(t,o)=>{e.inflight.delete(r.inflightKey),E(e,r,{kind:"test-outcome",outcome:o,runId:r.runId,testName:r.testName,workflowName:r.workflowName})},started:()=>{E(e,r,{kind:"test-started",runId:r.runId,testName:r.testName,workflowName:r.workflowName})}}}function eo(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 no({config:e,cwd:n,message:r}){return(await Qe(n)).match(o=>ro({config:e,cwd:n,lockfile:o,message:r}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...eo(o)]},kind:"error"}))}async function ro({config:e,cwd:n,lockfile:r,message:t}){let o=await Un(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=await Ln(e.engineUrl);if(i!=null)return{error:{code:"engine-unreachable",detail:i,url:e.engineUrl},kind:"error"};let s=await be(n);if(s==null)return{error:{code:"sync-failed",detail:"lockfile-missing"},kind:"error"};if(!je.has(s)){let l=await oo({config:e,cwd:n,lockfile:r});if(l!=null)return{error:{code:"sync-failed",detail:l},kind:"error"};je.add(s),jn({config:e,cwd:n,lockfile:r})}return(await io({config:e,cwd:n,lockfile:r,message:t})).match(async l=>({kind:"ready",lockfileHashValue:s,selections:Kn(r,l),targetsByClaimKey:await to({config:e,cwd:n,hash:s})}),l=>Promise.resolve({error:l,kind:"error"}))}async function to({config:e,cwd:n,hash:r}){let t=rr.get(r);if(t!=null)return t;let o=await Nn(e,n);return rr.set(r,o),o}async function oo(e){try{return await b(e),null}catch(n){return n instanceof Error?n.message:String(n)}}async function io({config:e,cwd:n,lockfile:r,message:t}){return!t.all&&t.tests.length===0?(await Zn({config:e,cwd:n,lockfile:r})).mapErr(ao):Vn({all:t.all,ids:t.tests,lockfile:r}).mapErr(so)}function ao(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function so(e){switch(e.kind){case"conflicting-flags":return{code:"selection-conflicting-flags"};case"nothing-selected":return{code:"selection-nothing-selected"};case"unknown-ids":return{code:"selection-unknown-ids",known:[...e.known],unknown:[...e.unknown]}}}async function lo(e){await e.selections.reduce((n,r)=>n.then(()=>co(e,r)),Promise.resolve())}async function co(e,n){let{ctx:r,headed:t,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:a}=e;if(a.isCancellationRequested)return;let l=Ee(n),u=s.get(l);if(u==null){sr(r,o,{kind:"test-outcome",outcome:{kind:"dispatch-error",reason:{detail:"test-not-found",type:"generic"}},runId:"",testName:n.testName,workflowName:n.workflowName});return}let d=Wn({headed:t,inflight:r.inflight,jobId:o,lockfileHashValue:i,runId:Ht(),selection:n,timeoutMs:Kt,onExpire:g=>{E(r,g,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:g.testName,workflowName:g.workflowName})}});if(d==null)return;let f=r.executor(),y=await uo({ctx:r,executor:f,lockfileHashValue:i,run:d,target:u});if(y!=null){X(r.inflight,d),E(r,d,{kind:"test-outcome",outcome:y,runId:"",testName:n.testName,workflowName:n.workflowName});return}f==="cloud"&&po(r,d)}function uo({ctx:e,executor:n,lockfileHashValue:r,run:t,target:o}){return _n({config:e.config,executor:n,lockfileHash:r,runId:t.runId,target:o})}function po(e,n){let r=Ie(e.inflight,n.runId);r!=null&&nr({config:e.config,runId:r.runId,signal:Qt(r.cancellation.token),onComplete:t=>{e.inflight.delete(r.inflightKey),E(e,r,{kind:"test-outcome",outcome:t,runId:r.runId,testName:r.testName,workflowName:r.workflowName})},onStarted:()=>{E(e,r,{kind:"test-started",runId:r.runId,testName:r.testName,workflowName:r.workflowName})}})}import fo from"fs";import yo from"path";async function ml(e){let n=yo.join(e,".ripplo","index.ts");if(!fo.existsSync(n))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let r=await O(e);return r.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:U(r.error),path:".ripplo/"}],valid:!1,warnings:[]}:K().match(t=>({appUrl:t.appUrl,engineUrl:t.engineUrl,errors:[],valid:!0,warnings:[]}),t=>({appUrl:void 0,engineUrl:void 0,errors:[{message:he(t),path:""}],valid:!1,warnings:[]}))}async function gl(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 hl({appUrl:e,engineUrl:n}){let r=n.startsWith("http://")||n.startsWith("https://")?n:`${e}${n}`;try{return(await fetch(`${r}/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}}function mo(e){let{backoffActive:n,exploreEnabled:r,headedActive:t,interactiveActive:o,interactiveQueued:i}=e,{explorationActive:s,exploreConcurrency:a,poolSize:l}=e;if(!r||t||o>0||i>0)return{abortCount:s,refillCount:0};if(n)return{abortCount:0,refillCount:0};let u=Math.min(a,l-1);return{abortCount:0,refillCount:Math.max(0,u-s)}}function Sl(e){let n={active:new Map,backoffUntil:0,cancelBackoffTimer:null,cancelHeartbeat:null,prevInteractiveActive:e.probe().interactiveActive,stopped:!1};return cr(n,e),{explorationActive:()=>n.active.size,notifyQueueChange:()=>{ho(n,e)},stalled:()=>So(n,e),stop:()=>{n.stopped=!0,n.cancelBackoffTimer?.(),n.cancelBackoffTimer=null,n.cancelHeartbeat?.(),n.cancelHeartbeat=null,pr(n,n.active.size)}}}function cr(e,n){e.stopped||(e.cancelHeartbeat=n.setTimer(()=>{Z(e,n),cr(e,n)},15e3))}function Z(e,n){if(e.stopped)return;go(e,n);let r=n.probe(),t=mo({backoffActive:n.now()<e.backoffUntil,explorationActive:e.active.size,exploreConcurrency:n.exploreConcurrency(),exploreEnabled:n.exploreEnabled(),headedActive:r.headedActive>0,interactiveActive:r.interactiveActive,interactiveQueued:r.interactiveQueued,poolSize:r.poolSize});pr(e,t.abortCount),fr({count:t.refillCount,params:n,state:e})}function go(e,n){ur(e,n).forEach(({controller:r})=>{r.abort()})}function ur(e,n){let r=n.now()-9e4;return[...e.active.values()].filter(t=>t.startedAt<=r)}function pr(e,n){[...e.active.values()].slice(0,n).forEach(({controller:r})=>{r.abort()})}function ho(e,n){let r=n.probe();r.interactiveActive<e.prevInteractiveActive&&Ro(e,n),e.prevInteractiveActive=r.interactiveActive,Z(e,n)}function Ro(e,n){e.backoffUntil=n.now()+3e4,e.cancelBackoffTimer?.(),e.cancelBackoffTimer=n.setTimer(()=>{e.cancelBackoffTimer=null,Z(e,n)},3e4)}function So(e,n){return ur(e,n).length}function fr({count:e,params:n,state:r}){if(e<=0)return;let t=ko(n.sources);t!=null&&(vo({params:n,pulled:t,state:r}),fr({count:e-1,params:n,state:r}))}function ko(e){return e.reduce((n,r)=>{if(n!=null)return n;let t=r.next();return t==null?null:{job:t,source:r}},null)}function vo({params:e,pulled:n,state:r}){let{job:t,source:o}=n,i=new AbortController;r.active.set(t.id,{controller:i,job:t,source:o,startedAt:e.now()}),e.execute({job:t,priority:o.priority,signal:i.signal}).then(()=>{dr({job:t,outcome:lr(i.signal,null),params:e,source:o,state:r})}).catch(s=>{dr({job:t,outcome:lr(i.signal,{error:s}),params:e,source:o,state:r})})}function lr(e,n){return e.aborted?{kind:"aborted"}:n==null?{kind:"completed"}:{error:n.error,kind:"error"}}function dr({job:e,outcome:n,params:r,source:t,state:o}){o.active.delete(e.id),t.onResult(e,n),Z(o,r)}import{createMessageConnection as yr,IPCMessageReader as mr,IPCMessageWriter as gr,NotificationType as wo,NotificationType0 as hr,RequestType as Rr,RequestType0 as xo}from"vscode-jsonrpc/node";import{z as h}from"zod";var El=h.object({headed:h.boolean(),runId:h.string().min(1),testRef:h.string().min(1)}),Il=h.object({lockfileJson:h.string().optional(),unavailable:h.string().optional()}),Pl=h.object({runId:h.string().min(1),span:Ve}),Cl=h.object({outcome:yn,serverNotified:h.boolean()}),Al=new hr("worker/ready"),Tl=new Rr("worker/run"),jl=new xo("worker/lockfile"),Fl=new Rr("worker/exploreTrail"),Ml=new wo("worker/span"),$l=new hr("worker/shutdown");function Dl(e){let n=yr(new mr(e),new gr(e));return n.listen(),n}function Ol(){let e=yr(new mr(process),new gr(process));return e.listen(),e}import{gzipSync as Fo}from"zlib";import{appendFileSync as Mo,existsSync as ne,readFileSync as xr,writeFileSync as wr}from"fs";import k from"path";import{graphql as Me}from"gql.tada";function ee(e){return[e.kind,e.target,e.value].filter(n=>n.length>0).join(" ")}function Sr(e,n){return{kind:"finding",payload:Po(e),source:"verifier",step:n.step,stepIndex:n.stepIndex,timeNanos:n.timeNanos}}var bo={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},Eo={"data-rule":"dataRule",fact:"fact",step:"step"},Io={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 Po(e){return e.kind==="consistency"?{kind:"mismatch",mismatch:jo(e.mismatch),pending:e.pending,wait:e.budget,waitMs:ue[e.budget]}:e.kind==="pending-check"?{...Co(e.source),kind:"pendingCheck",source:Eo[e.source.kind],wait:e.budget,waitMs:ue[e.budget]}:e.kind==="unrunnable"?{kind:"unrunnable",reason:bo[e.reason],unmet:e.unmet==null?void 0:an(e.unmet)}:e.kind==="impossible-action"?{action:Ao(e.step.action),kind:"impossibleAction",subject:vr(e.step.action)}:e.kind==="lift-visibility"?{declaredIndex:e.declaredIndex,kind:"liftVisibility",subject:C(e.locator),visibleIndex:e.visibleIndex}:{errorKind:Io[e.error.kind],kind:"driverError",message:To(e.error)}}function Co(e){return"check"in e?kr(e.check,!1):{checkKind:null,expected:null,negated:!1,subject:rn(e.dataRule)}}function kr(e,n){return e.kind==="not"?kr(e.inner,!n):e.kind==="browser"?{checkKind:"browser",expected:e.value??null,negated:n,subject:Xe(e.key)}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:n,subject:C(e.locator)}:{checkKind:e.kind,expected:null,negated:n,subject:C(e.locator)}}function Ao(e){return`${e.kind} ${vr(e)}`.trim()}function vr(e){return e.locator==null?e.url??"":C(e.locator)}function To(e){return"message"in e?e.message:"detail"in e?e.detail:null}function jo(e){if(e.kind==="wrong-value")return{actual:v(e.sut),entity:e.entity,expected:v(e.snapshot),field:e.field,key:e.key,kind:"wrongValue"};if(e.kind==="expected-change"){let n=e.direction==null?"change":e.direction.replace(/d$/,"");return{actual:v(e.value),entity:e.entity,expected:`${n} from ${v(e.from)}`,field:e.field,key:e.key,kind:"expectedChange"}}return e.kind==="scalar-mismatch"?{actual:v(e.sut),expected:tn(e.want),kind:"scalarMismatch",subject:nn(e.subject),subjectKey:Ye(e.subject)}:e.kind==="missing-row"?{entity:e.entity,key:e.key,kind:"missingRow"}:{entity:e.entity,key:e.key,kind:"unexpectedRow"}}function te({config:e,fixturesDir:n,headed:r}){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:n,generate:F,headed:r,secret:e.webhookSecret}}async function $e(e){let n=oe(e);await De(e.config,e.runId,n)}function oe({debugDir:e,events:n,recordingOptional:r,runId:t,stepSources:o}){let i=Oe(n),s=Wo(e,t);if(s==null&&!r)throw new Error("recording-missing");let a=i.map((u,d)=>Yo({aliases:[...Bo(n),...Vo(i)],generated:Ko(n),generatedSingletons:Jo(n),origin:s==null?No(i):s.origin,record:u,rrwebEvents:s==null?[]:s.events,sourceTest:o?.[d]??null})),l=i.flatMap(u=>u.findings.map(d=>Sr(d,{step:ee(M(u.source,u.index)),stepIndex:u.index,timeNanos:br(u)})));return $o({debugDir:e,events:[...a,...l],runId:t}),i}function $o({debugDir:e,events:n,runId:r}){if(n.length===0)return;let t=k.join(e,r,"behavior.jsonl");if(!ne(t))return;let o=n.map(i=>JSON.stringify(i)).join(`
|
|
153
|
+
`);Mo(t,`${o}
|
|
154
|
+
`)}function br(e){return String(BigInt(Math.max(0,Math.round(e.endMs)))*1000000n)}async function De(e,n,r){let t=r.filter(s=>s.findings.length>0).length,o=r.length-t,i=r.reduce((s,a)=>s+Math.max(0,a.endMs-a.startMs),0);await c({config:e,document:ni,variables:{items:[{duration:i,failCount:t,firstFailedStepTitle:Do(r),passCount:o,runId:n,status:t>0?"failed":"passed"}]}})}function Do(e){let n=e.filter(r=>r.findings.length>0).toSorted((r,t)=>r.index-t.index).at(0);return n==null?null:ee(M(n.source,n.index))}function Oe(e){return e.flatMap(n=>n.kind==="step"?[{annotations:n.annotations,endMs:n.endMs,findings:n.findings,index:n.index,source:n.source,startMs:n.startMs,state:n.state,url:n.url}]:[])}async function Er(e,n){await c({config:e,document:ri,variables:{runIds:[n]}})}var re=".uploaded";async function Oo({config:e,debugDir:n,runId:r}){let t=k.join(n,r),o=k.join(t,"behavior.jsonl");if(ne(k.join(t,re)))return;if(!ne(o)){p.warn({runId:r},"behavior upload skipped: behavior.jsonl missing on disk");return}await[0,1e3,3e3].reduce((s,a)=>s.then(async l=>l?!0:(await new Promise(u=>setTimeout(u,a)),Uo({behaviorPath:o,config:e,runDir:t,runId:r}))),Promise.resolve(!1))}async function Uo({behaviorPath:e,config:n,runDir:r,runId:t}){try{let o=await c({config:n,document:ei,variables:{runId:t}}),i=await fetch(o.debugArtifactUploadUrl,{body:Fo(xr(e)),headers:{"content-type":_o},method:"PUT"});return i.ok?(await Er(n,t),wr(k.join(r,re),""),!0):(p.warn({runId:t,status:i.status},"behavior upload PUT failed"),!1)}catch(o){return Lo(o)?(p.warn({runId:t},"behavior upload refused by server; run unknown \u2014 not retrying"),wr(k.join(r,re),""),!0):(p.warn({error:o,runId:t},"behavior upload failed"),!1)}}function Lo(e){if(typeof e!="object"||e==null||!("errors"in e))return!1;let{errors:n}=e;return Array.isArray(n)&&n.some(r=>{if(typeof r!="object"||r==null||!("extensions"in r))return!1;let{extensions:t}=r;return typeof t=="object"&&t!=null&&"code"in t&&t.code==="FORBIDDEN"})}var _o="application/x-ndjson";function No(e){return e.reduce((n,r)=>Math.min(n,r.startMs),e[0]?.startMs??0)}function Wo(e,n){let r=k.join(e,n,"behavior.jsonl");if(!ne(r))return null;let t=xr(r,"utf8").split(`
|
|
155
|
+
`).filter(i=>i.length>0).map(i=>qo(i)).flatMap(i=>Ho(i)?[i.event]:[]),o=t[0];return o==null?null:{events:t,origin:o.timestamp}}function qo(e){return JSON.parse(e)}function Ho(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function Bo(e){return e.flatMap(n=>n.kind==="world"?n.aliases:[])}function Vo(e){return e.flatMap(n=>{let r=Qo(n.source);return r.flatMap(t=>{let i=r.filter(a=>a.entity===t.entity).indexOf(t),s=n.state.rows.filter(a=>a.status==="created"&&a.entity===t.entity).at(i);return s==null?[]:[{alias:t.as,entity:t.entity,key:s.key}]})})}function Ko(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generated.map(r=>Ir(r)):[]))}function Ir({entity:e,field:n,key:r}){return`${e} ${r} ${n}`}function Jo(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generatedSingletons:[]))}function Qo(e){return e==null?[]:e.expect.flatMap(n=>Fe(n))}function Fe(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(n=>Fe(n)):e.kind==="when"?e.branches.flatMap(n=>n.consequence.flatMap(r=>Fe(r))):[]}var zo=3,Go=0;function Xo({endMs:e,rrwebEvents:n,startMs:r}){let t=n.find(o=>o.type===zo&&o.data?.source===Go&&o.timestamp>=r&&o.timestamp<=e);return t==null?r:t.timestamp}function Yo({aliases:e,generated:n,generatedSingletons:r,origin:t,record:o,rrwebEvents:i,sourceTest:s}){let a=M(o.source,o.index),l=Xo({endMs:o.endMs,rrwebEvents:i,startMs:o.startMs});return{annotations:[...o.annotations.map(d=>({ephemeral:d.ephemeral,kind:d.kind,label:d.label,outcome:d.outcome,recordingStartMs:Math.max(0,(d.kind==="action"?l:d.atMs)-t),rrwebIds:[...d.rrwebIds],url:d.url,value:d.value??null}))],duration:Math.max(0,o.endMs-o.startMs),kind:"step",nodeType:a.kind,pageUrl:o.url,recordingEndMs:Math.max(0,o.endMs-t),recordingStartMs:Math.max(0,l-t),source:"verifier",sourceTest:s,stateRows:o.state.rows.map(d=>Zo({aliases:e,generated:n,row:d})),stateSingletons:o.state.singletons.map(d=>({changed:d.changed,generated:r.has(d.name),name:d.name,value:d.value==null?null:String(d.value)})),stepIndex:o.index,timeNanos:br(o),title:ee(a)}}function Zo({aliases:e,generated:n,row:r}){let t=e.find(o=>o.entity===r.entity&&o.key===r.key);return{entity:r.entity,fields:r.fields.map(o=>({changed:o.changed,field:o.field,generated:n.has(Ir({entity:r.entity,field:o.field,key:r.key})),value:o.value==null?null:String(o.value)})),key:r.key,label:t?.alias??r.key,status:r.status}}var ei=Me(`
|
|
156
|
+
mutation DebugArtifactUploadUrl($runId: String!) {
|
|
157
|
+
debugArtifactUploadUrl(runId: $runId)
|
|
158
|
+
}
|
|
159
|
+
`),ni=Me(`
|
|
160
|
+
mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
|
|
161
|
+
completeRunsBatch(items: $items) {
|
|
162
|
+
id
|
|
163
|
+
status
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
`),ri=Me(`
|
|
167
|
+
mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
|
|
168
|
+
markRunArtifactsUploadedBatch(runIds: $runIds)
|
|
169
|
+
}
|
|
170
|
+
`);import{graphql as I}from"gql.tada";function ti(e){let n=e.trail;if(!(n==null||!oi(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 oi(e){return e==="clean"||e==="flaky"||e==="finding"}async function Ue({baseState:e,category:n,config:r,debugDir:t,devSessionId:o,events:i,lockfileHash:s,reproJson:a,runId:l,signature:u,spec:d,stepSources:f,summary:y,workflowSlug:g}){await c({config:r,document:di,variables:{devSessionId:o??null,lockfileHash:s??null,projectId:r.projectId,reproJson:a,runId:l,spec:d??null,workflowSlug:g??null}}),await $e({config:r,debugDir:t,events:i,recordingOptional:!0,runId:l,stepSources:f}),await c({config:r,document:ci,variables:{baseState:e,category:n,projectId:r.projectId,reproRunId:l,signature:u,summary:y}})}async function ie(e,n,r){return(await c({config:e,document:ui,variables:{lockfileHash:r,projectId:e.projectId,signature:n}})).exploreFindingExists}async function ii({attempts:e,config:n,devSessionId:r,findings:t,trail:o}){await c({config:n,document:si,variables:{attempts:e,devSessionId:r,findings:t,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 ai(e,n){return(await c({config:e,document:li,variables:{devSessionId:n}}).catch(t=>(p.warn({error:t},"reportExploreUnhealthy failed"),null)))?.reportExploreUnhealthy??!1}var si=I(`
|
|
171
|
+
mutation RecordExplorationProgress(
|
|
172
|
+
$devSessionId: String!
|
|
173
|
+
$attempts: Int!
|
|
174
|
+
$findings: Int!
|
|
175
|
+
$trail: ExploreTrailInput
|
|
176
|
+
) {
|
|
177
|
+
recordExplorationProgress(
|
|
178
|
+
devSessionId: $devSessionId
|
|
179
|
+
attempts: $attempts
|
|
180
|
+
findings: $findings
|
|
181
|
+
trail: $trail
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
`),li=I(`
|
|
185
|
+
mutation ReportExploreUnhealthy($devSessionId: String!) {
|
|
186
|
+
reportExploreUnhealthy(devSessionId: $devSessionId)
|
|
187
|
+
}
|
|
188
|
+
`),di=I(`
|
|
189
|
+
mutation CreateExploreRun(
|
|
190
|
+
$projectId: String!
|
|
191
|
+
$runId: String!
|
|
192
|
+
$devSessionId: String
|
|
193
|
+
$lockfileHash: String
|
|
194
|
+
$spec: String
|
|
195
|
+
$reproJson: String
|
|
196
|
+
$workflowSlug: String
|
|
197
|
+
) {
|
|
198
|
+
createExploreRun(
|
|
199
|
+
projectId: $projectId
|
|
200
|
+
runId: $runId
|
|
201
|
+
devSessionId: $devSessionId
|
|
202
|
+
lockfileHash: $lockfileHash
|
|
203
|
+
spec: $spec
|
|
204
|
+
reproJson: $reproJson
|
|
205
|
+
workflowSlug: $workflowSlug
|
|
206
|
+
) {
|
|
207
|
+
id
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
`),ci=I(`
|
|
211
|
+
mutation SubmitExploreFinding(
|
|
212
|
+
$projectId: String!
|
|
213
|
+
$signature: String!
|
|
214
|
+
$summary: String!
|
|
215
|
+
$baseState: String!
|
|
216
|
+
$category: ExploreFindingCategory!
|
|
217
|
+
$reproRunId: String!
|
|
218
|
+
) {
|
|
219
|
+
submitExploreFinding(
|
|
220
|
+
projectId: $projectId
|
|
221
|
+
signature: $signature
|
|
222
|
+
summary: $summary
|
|
223
|
+
baseState: $baseState
|
|
224
|
+
category: $category
|
|
225
|
+
reproRunId: $reproRunId
|
|
226
|
+
) {
|
|
227
|
+
id
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
`),nd=I(`
|
|
231
|
+
mutation SetExploreFindingStatus(
|
|
232
|
+
$projectId: String!
|
|
233
|
+
$signature: String!
|
|
234
|
+
$status: ExploreFindingStatus!
|
|
235
|
+
) {
|
|
236
|
+
setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
|
|
237
|
+
}
|
|
238
|
+
`),ui=I(`
|
|
239
|
+
query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
|
|
240
|
+
exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
|
|
241
|
+
}
|
|
242
|
+
`);import yi from"path";import{graphql as mi}from"gql.tada";import{graphql as ae}from"gql.tada";function Le(e){switch(e.kind){case"app-not-ready":return"appNotReady";case"client-mount-missing":return"appNotReady";case"engine-network":case"engine-http":return"backendUnreachable";case"engine-unreachable":return"engineUnreachable";case"engine-decode":case"state-identity":case"setup-missing-row":case"conflicting-sessions":case"driver-launch":case"action-failed":case"check-failed":case"aborted":return null}}async function _e(e,n,r){await c({config:e,document:pi,variables:{reason:r,runId:n}}).catch(t=>{p.error(t,"failRun submission failed")})}async function Ne(e,n,r){await c({config:e,document:fi,variables:{cause:r,runId:n}}).catch(t=>{p.error(t,"markRunUnready submission failed")})}var id=ae(`
|
|
243
|
+
mutation ReleaseRun($runId: String!) {
|
|
244
|
+
releaseRun(runId: $runId)
|
|
245
|
+
}
|
|
246
|
+
`),ad=ae(`
|
|
247
|
+
mutation HeartbeatRun($runId: String!) {
|
|
248
|
+
heartbeatRun(runId: $runId)
|
|
249
|
+
}
|
|
250
|
+
`),pi=ae(`
|
|
251
|
+
mutation FailRun($runId: String!, $reason: String!) {
|
|
252
|
+
failRun(runId: $runId, reason: $reason)
|
|
253
|
+
}
|
|
254
|
+
`),fi=ae(`
|
|
255
|
+
mutation MarkRunUnready($runId: String!, $cause: RunUnreadyCause!) {
|
|
256
|
+
markRunUnready(runId: $runId, cause: $cause)
|
|
257
|
+
}
|
|
258
|
+
`);async function gi({config:e,cwd:n,errorSettle:r,fixturesDir:t,headed:o,lockfile:i,onPhase:s,runId:a,session:l,signal:u,test:d}){if(!await Ri(e,a))return{outcome:{kind:"dispatch-failed",reason:"already-claimed",runId:a},persisted:Promise.resolve()};let y=yi.join(n,".ripplo","debug"),g=[];return(await l.runOnce({capture:!0,lockfile:i,onPhase:s,options:te({config:e,fixturesDir:t,headed:o}),params:void 0,runId:a,sequence:void 0,test:d,onEvent:P=>{g.push(P)}},u)).match(async P=>{let We=Oe(g),de=We.flatMap(Mr=>Mr.findings),ce=hi(de);if(ce!=null)return oe({config:e,debugDir:y,events:g,recordingOptional:!0,runId:a,stepSources:void 0}),await Pr({config:e,error:ce,errorSettle:r,runId:a}),{outcome:{error:ce,kind:"error",runId:a},persisted:Promise.resolve()};await De(e,a,We),oe({config:e,debugDir:y,events:g,recordingOptional:!0,runId:a,stepSources:void 0});let Fr=Promise.resolve();return{outcome:de.length>0?{findings:de,kind:"findings",runId:a}:{kind:"pass",runId:a},persisted:Fr}},async P=>(await Pr({config:e,error:P,errorSettle:r,runId:a}),{outcome:{error:P,kind:"error",runId:a},persisted:Promise.resolve()}))}async function Pr({config:e,error:n,errorSettle:r,runId:t}){if(r==="defer")return;let o=Le(n);if(o!=null){await Ne(e,t,o);return}await _e(e,t,L(n))}function hi(e){let n=e.find(r=>r.kind==="driver-error"&&en(r.error));return n!=null&&n.kind==="driver-error"?n.error:void 0}async function Ri(e,n){return((await c({config:e,document:Si,variables:{runIds:[n]}})).startRunsBatch??[]).some(t=>t.id===n)}var Si=mi(`
|
|
259
|
+
mutation StartRunsBatch($runIds: [String!]!) {
|
|
260
|
+
startRunsBatch(runIds: $runIds) {
|
|
261
|
+
id
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
`);import{randomUUID as ki}from"crypto";async function vi({assign:e,config:n,debugDir:r,devSessionId:t,fixturesDir:o,headed:i,lockfile:s,report:a,session:l,signal:u}){let d=Ze(s);if(e.stepRuns.length===0)return{kind:"error",reason:"empty-trail"};let f=ji(d,e.stepRuns),y=await un({baseState:{name:R(e.baseStateTest),test:e.baseStateTest},corpus:d,lockfile:s,options:te({config:n,fixturesDir:o,headed:i}),seenSignature:a?j=>ie(n,j,e.lockfileHash):void 0,session:l,stepRuns:e.stepRuns,runIdFor:j=>`explore-${ki()}-${String(j)}`},u),g=a?await Pi({baseStateTest:e.baseStateTest,config:n,debugDir:r,devSessionId:t,lockfileHash:e.lockfileHash,outcome:y,reproJson:Ei(d,e),stepSources:Ii(f)}):!1;return bi(y,f.length),Fi(y,g,wi(f,e,y))}function wi(e,n,r){if(r.kind==="error"||r.kind==="aborted")return;let t=r.timing.confirm;return{baseLabel:n.baseStateTest.intent,baseState:R(n.baseStateTest),durationMs:Math.round(se(r.timing.detect)+(t==null?0:se(t))),signature:r.kind==="finding"||r.kind==="seen"?r.signature:void 0,steps:xi(e.slice(0,r.ranCount))}}function xi(e){return e.flatMap(n=>{let r=n.label.split("#")[0]??n.label;return n.actions.map(t=>({test:r,text:t}))})}function se(e){return e.engineMs+e.worldMs+e.browserMs+e.driveMs+e.teardownMs}function bi(e,n){if(e.kind==="error"){p.info({detail:L(e.error),kind:e.kind,reason:e.error.kind,steps:n},"explore trail");return}if(e.kind==="aborted"||e.kind==="seen"){p.info({kind:e.kind,steps:n},"explore trail");return}let r=e.timing.detect,t=e.timing.confirm;p.info({browserMs:r.browserMs,confirmMs:t==null?void 0:se(t),detectMs:se(r),driveMs:r.driveMs,engineMs:r.engineMs,kind:e.kind,steps:n,teardownMs:r.teardownMs,worldMs:r.worldMs},"explore trail")}function Ei(e,n){let r=n.stepRuns.flatMap(o=>{let i=e[o.idx];return i==null?[]:[{index:i.index,params:o.params,test:i.test}]}),t={baseStateRef:R(n.baseStateTest),steps:r};return JSON.stringify(t)}function Ii(e){return e.flatMap(n=>{let r=n.label.split("#")[0]??n.label;return n.actions.map(()=>r)})}async function Pi({baseStateTest:e,config:n,debugDir:r,devSessionId:t,lockfileHash:o,outcome:i,reproJson:s,stepSources:a}){return i.kind!=="finding"||i.captureEvents.length===0?!1:await ie(n,i.signature,o)?(p.info({devSessionId:t,signature:i.signature},"explore finding already reported, skipping duplicate"),!1):(await Ue({baseState:i.baseState,category:Ci(i.verifierLayer),config:n,debugDir:r,devSessionId:t,events:i.captureEvents,lockfileHash:o,reproJson:s,runId:i.runId,signature:i.signature,spec:Ti(e,i.captureEvents),stepSources:a,summary:Ai(i.captureEvents,i.title),workflowSlug:i.sourceTest?.split("/")[0]}).catch(l=>{p.warn({error:l},"explore finding report failed")}),!0)}function Ci(e){return e==="data-rule"?"dataRule":e==="model-drift"?"modelDrift":e}function Ai(e,n){let r=e.flatMap(t=>t.kind==="step"?[...t.findings]:[]).at(0);if(r!=null)return on(r);if(n!=null)return n;throw new Error("explore finding has no findings to summarize")}function Ti(e,n){let r=n.flatMap(o=>o.kind==="step"?[o.source]:[]),t={absent:e.absent,actor:e.actor,exclusive:e.exclusive,intent:e.intent,maybe:[],name:e.name,params:e.params,singletons:e.singletons,steps:r,stub:!1,tests:[],viewports:[e.viewport],world:e.world};return JSON.stringify(t)}function ji(e,n){return n.flatMap(r=>{let t=e[r.idx];return t==null?[]:[{actions:[...t.nav,...t.steps].map(o=>sn(o.action)),label:`${t.test}#${String(t.index)}`}]})}function Fi(e,n,r){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:r}:{kind:e.kind,trail:r}}import Mi from"path";import{randomUUID as $i}from"crypto";async function Ud({cwd:e,onReady:n,signal:r,step:t,target:o}){let i=x(e).match(f=>({config:f}),f=>({failure:f}));if("failure"in i)return{failure:i.failure,kind:"config-failed"};let s=i.config,a=await ze(e);if(a.result.isErr())return{error:a.result.error,kind:"compile-failed"};let l=await N(e,a.result.value),u=await Di(l,o);return u.kind!=="ok"?u:(await dn({lockfile:l,onReady:n,options:Oi(s),runId:`teleport-${$i()}`,sequence:u.sequence,stopAfterStep:t,test:u.test},r)).match(f=>({kind:"done",result:f}),f=>({error:f,kind:"run-failed"}))}async function Di(e,n){if(n.kind==="explore"){let t=await _(e,n.repro);return t.kind==="unplannable"?{kind:"unplannable"}:{kind:"ok",sequence:t.sequence,test:t.baseTest}}let r=A(e).find(t=>t.ref===n.ref);return r==null?{kind:"no-test",ref:n.ref}:{kind:"ok",sequence:cn(e,r.test,void 0),test:r.test}}function Oi(e){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:Mi.join(e.cwd,D),generate:F,headed:!0,secret:e.webhookSecret}}import{graphql as qi}from"gql.tada";import{err as le,ok as Tr}from"neverthrow";import Ui,{AbortError as Li}from"p-retry";import{graphql as Cr}from"gql.tada";var _i=Cr(`
|
|
265
|
+
query AwaitDevSession($projectId: String!, $cwd: String!) {
|
|
266
|
+
project(id: $projectId) {
|
|
267
|
+
devSession(cwd: $cwd) {
|
|
268
|
+
id
|
|
269
|
+
executor
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
`);async function Ar(e){return Ui(async()=>{let t=(await c({config:e,document:_i,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession;if(t!=null)return{executor:t.executor,id:t.id,kind:"active"};throw w(e.cwd)?new Error("starting"):new Li("missing")},{factor:1,maxTimeout:400,minTimeout:400,retries:25}).catch(()=>w(e.cwd)?{kind:"starting"}:{kind:"missing"})}var Ni=Cr(`
|
|
274
|
+
query DevSessionCheckHealth($projectId: String!, $cwd: String!) {
|
|
275
|
+
activeDevSessions(projectId: $projectId) {
|
|
276
|
+
id
|
|
277
|
+
cwd
|
|
278
|
+
branch
|
|
279
|
+
}
|
|
280
|
+
project(id: $projectId) {
|
|
281
|
+
id
|
|
282
|
+
devSession(cwd: $cwd) {
|
|
283
|
+
id
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
`);function Vd(e){switch(e.status){case"active":return e.gitMidOperation?"\u2713 Dev session: ripplo daemon is live (hooks auto-paused while git is mid-merge/rebase/cherry-pick \u2014 they resume when the operation ends)":"\u2713 Dev session: ripplo daemon is live for this directory";case"starting":return"! Dev session: the daemon is running locally but hasn't registered with the server yet. Wait a few seconds and re-run `npx ripplo doctor`. If it persists, check the daemon output for auth or network errors.";case"missing":{let n="\u2717 Dev session: no daemon running for this directory. Start `npx ripplo daemon` as a background process (separate from your app's dev server). Without it, `npx ripplo run` refuses to dispatch and scope/coverage hooks won't arm.";return e.elsewhere.length===0?n:[n," A daemon is running for a different directory:",...Wi(e.elsewhere)].join(`
|
|
288
|
+
`)}}}async function Kd(e){let n=w(e),r=Y(e),t=x(e).unwrapOr(void 0);if(t==null)return{elsewhere:[],gitMidOperation:r,status:n?"starting":"missing",type:"dev-session"};let o=await c({config:t,document:Ni,variables:{cwd:t.cwd,projectId:t.projectId}}).catch(()=>null);return o?.project?.devSession!=null?{elsewhere:[],gitMidOperation:r,status:"active",type:"dev-session"}:{elsewhere:(o?.activeDevSessions??[]).filter(a=>a.cwd!==t.cwd).map(a=>({branch:a.branch,cwd:a.cwd})),gitMidOperation:r,status:n?"starting":"missing",type:"dev-session"}}function Wi(e){return e.map(n=>{let r=n.branch==null?"":` (${n.branch})`;return` - ${n.cwd}${r}`})}var Hi=qi(`
|
|
289
|
+
mutation SetDevSessionExecutor($devSessionId: String!, $executor: RunExecutor!) {
|
|
290
|
+
setDevSessionExecutor(devSessionId: $devSessionId, executor: $executor) {
|
|
291
|
+
__typename
|
|
292
|
+
... on DevSession {
|
|
293
|
+
id
|
|
294
|
+
executor
|
|
295
|
+
}
|
|
296
|
+
... on DevSessionEndedError {
|
|
297
|
+
message
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
`);async function Yd(e){return(await jr(e)).map(r=>r.executor)}async function Zd(e,n){let r=await jr(e);if(r.isErr())return le(r.error);let o=(await c({config:e,document:Hi,variables:{devSessionId:r.value.id,executor:n}})).setDevSessionExecutor;return o==null?le({kind:"empty-response"}):o.__typename!=="DevSession"?le({kind:"session-ended"}):Tr(o.executor)}async function jr(e){let n=await Ar(e);return n.kind==="active"?Tr({executor:n.executor,id:n.id}):le({kind:n.kind==="starting"?"starting":"no-session"})}export{zi as a,ta as b,K as c,Wr as d,da as e,he as f,ca as g,En as h,Pn as i,x as j,ps as k,hs as l,Ar as m,Vd as n,Kd as o,ml as p,gl as q,hl as r,Ct as s,Qn as t,Sl as u,El as v,Pl as w,Cl as x,Al as y,Tl as z,jl as A,Fl as B,Ml as C,$l as D,Dl as E,Ol as F,jn as G,ja as H,Fa as I,ke as J,Ma as K,Mn as L,Qa as M,b as N,za as O,be as P,js as Q,al as R,Qt as S,sl as T,re as U,Oo as V,_e as W,gi as X,ti as Y,ii as Z,ai as _,vi as $,Ud as aa,Yd as ba,Zd as ca};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{a as P}from"./chunk-KMZ3L5YA.js";var T=P(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.timingSafeEqual=void 0;function N(n,e=""){if(!n)throw new Error(e)}function F(n,e){if(n.byteLength!==e.byteLength)return!1;n instanceof DataView||(n=new DataView(ArrayBuffer.isView(n)?n.buffer:n)),e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),N(n instanceof DataView),N(e instanceof DataView);let r=n.byteLength,i=0,a=-1;for(;++a<r;)i|=n.getUint8(a)^e.getUint8(a);return i===0}V.timingSafeEqual=F});var W=P(S=>{"use strict";var G=S&&S.__extends||(function(){var n=function(e,r){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,a){i.__proto__=a}||function(i,a){for(var g in a)a.hasOwnProperty(g)&&(i[g]=a[g])},n(e,r)};return function(e,r){n(e,r);function i(){this.constructor=e}e.prototype=r===null?Object.create(r):(i.prototype=r.prototype,new i)}})();Object.defineProperty(S,"__esModule",{value:!0});var l=256,z=(function(){function n(e){e===void 0&&(e="="),this._paddingCharacter=e}return n.prototype.encodedLength=function(e){return this._paddingCharacter?(e+2)/3*4|0:(e*8+5)/6|0},n.prototype.encode=function(e){for(var r="",i=0;i<e.length-2;i+=3){var a=e[i]<<16|e[i+1]<<8|e[i+2];r+=this._encodeByte(a>>>18&63),r+=this._encodeByte(a>>>12&63),r+=this._encodeByte(a>>>6&63),r+=this._encodeByte(a>>>0&63)}var g=e.length-i;if(g>0){var a=e[i]<<16|(g===2?e[i+1]<<8:0);r+=this._encodeByte(a>>>18&63),r+=this._encodeByte(a>>>12&63),g===2?r+=this._encodeByte(a>>>6&63):r+=this._paddingCharacter||"",r+=this._paddingCharacter||""}return r},n.prototype.maxDecodedLength=function(e){return this._paddingCharacter?e/4*3|0:(e*6+7)/8|0},n.prototype.decodedLength=function(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))},n.prototype.decode=function(e){if(e.length===0)return new Uint8Array(0);for(var r=this._getPaddingLength(e),i=e.length-r,a=new Uint8Array(this.maxDecodedLength(i)),g=0,p=0,m=0,E=0,C=0,A=0,s=0;p<i-4;p+=4)E=this._decodeChar(e.charCodeAt(p+0)),C=this._decodeChar(e.charCodeAt(p+1)),A=this._decodeChar(e.charCodeAt(p+2)),s=this._decodeChar(e.charCodeAt(p+3)),a[g++]=E<<2|C>>>4,a[g++]=C<<4|A>>>2,a[g++]=A<<6|s,m|=E&l,m|=C&l,m|=A&l,m|=s&l;if(p<i-1&&(E=this._decodeChar(e.charCodeAt(p)),C=this._decodeChar(e.charCodeAt(p+1)),a[g++]=E<<2|C>>>4,m|=E&l,m|=C&l),p<i-2&&(A=this._decodeChar(e.charCodeAt(p+2)),a[g++]=C<<4|A>>>2,m|=A&l),p<i-3&&(s=this._decodeChar(e.charCodeAt(p+3)),a[g++]=A<<6|s,m|=s&l),m!==0)throw new Error("Base64Coder: incorrect characters for decoding");return a},n.prototype._encodeByte=function(e){var r=e;return r+=65,r+=25-e>>>8&6,r+=51-e>>>8&-75,r+=61-e>>>8&-15,r+=62-e>>>8&3,String.fromCharCode(r)},n.prototype._decodeChar=function(e){var r=l;return r+=(42-e&e-44)>>>8&-l+e-43+62,r+=(46-e&e-48)>>>8&-l+e-47+63,r+=(47-e&e-58)>>>8&-l+e-48+52,r+=(64-e&e-91)>>>8&-l+e-65+0,r+=(96-e&e-123)>>>8&-l+e-97+26,r},n.prototype._getPaddingLength=function(e){var r=0;if(this._paddingCharacter){for(var i=e.length-1;i>=0&&e[i]===this._paddingCharacter;i--)r++;if(e.length<4||r>2)throw new Error("Base64Coder: incorrect padding")}return r},n})();S.Coder=z;var D=new z;function Q(n){return D.encode(n)}S.encode=Q;function X(n){return D.decode(n)}S.decode=X;var I=(function(n){G(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e.prototype._encodeByte=function(r){var i=r;return i+=65,i+=25-r>>>8&6,i+=51-r>>>8&-75,i+=61-r>>>8&-13,i+=62-r>>>8&49,String.fromCharCode(i)},e.prototype._decodeChar=function(r){var i=l;return i+=(44-r&r-46)>>>8&-l+r-45+62,i+=(94-r&r-96)>>>8&-l+r-95+63,i+=(47-r&r-58)>>>8&-l+r-48+52,i+=(64-r&r-91)>>>8&-l+r-65+0,i+=(96-r&r-123)>>>8&-l+r-97+26,i},e})(z);S.URLSafeCoder=I;var R=new I;function Z(n){return R.encode(n)}S.encodeURLSafe=Z;function ee(n){return R.decode(n)}S.decodeURLSafe=ee;S.encodedLength=function(n){return D.encodedLength(n)};S.maxDecodedLength=function(n){return D.maxDecodedLength(n)};S.decodedLength=function(n){return D.decodedLength(n)}});var K=P(($,j)=>{"use strict";(function(n,e){var r={};e(r);var i=r.default;for(var a in r)i[a]=r[a];typeof j=="object"&&typeof j.exports=="object"?j.exports=i:typeof define=="function"&&define.amd?define(function(){return i}):n.sha256=i})($,function(n){"use strict";n.__esModule=!0,n.digestLength=32,n.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function r(s,t,o,f,x){for(var c,u,h,_,v,d,U,b,w,y,B,O,M;x>=64;){for(c=t[0],u=t[1],h=t[2],_=t[3],v=t[4],d=t[5],U=t[6],b=t[7],y=0;y<16;y++)B=f+y*4,s[y]=(o[B]&255)<<24|(o[B+1]&255)<<16|(o[B+2]&255)<<8|o[B+3]&255;for(y=16;y<64;y++)w=s[y-2],O=(w>>>17|w<<15)^(w>>>19|w<<13)^w>>>10,w=s[y-15],M=(w>>>7|w<<25)^(w>>>18|w<<14)^w>>>3,s[y]=(O+s[y-7]|0)+(M+s[y-16]|0);for(y=0;y<64;y++)O=(((v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7))+(v&d^~v&U)|0)+(b+(e[y]+s[y]|0)|0)|0,M=((c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10))+(c&u^c&h^u&h)|0,b=U,U=d,d=v,v=_+O|0,_=h,h=u,u=c,c=O+M|0;t[0]+=c,t[1]+=u,t[2]+=h,t[3]+=_,t[4]+=v,t[5]+=d,t[6]+=U,t[7]+=b,f+=64,x-=64}return f}var i=(function(){function s(){this.digestLength=n.digestLength,this.blockSize=n.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return s.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},s.prototype.clean=function(){for(var t=0;t<this.buffer.length;t++)this.buffer[t]=0;for(var t=0;t<this.temp.length;t++)this.temp[t]=0;this.reset()},s.prototype.update=function(t,o){if(o===void 0&&(o=t.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var f=0;if(this.bytesHashed+=o,this.bufferLength>0){for(;this.bufferLength<64&&o>0;)this.buffer[this.bufferLength++]=t[f++],o--;this.bufferLength===64&&(r(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(o>=64&&(f=r(this.temp,this.state,t,f,o),o%=64);o>0;)this.buffer[this.bufferLength++]=t[f++],o--;return this},s.prototype.finish=function(t){if(!this.finished){var o=this.bytesHashed,f=this.bufferLength,x=o/536870912|0,c=o<<3,u=o%64<56?64:128;this.buffer[f]=128;for(var h=f+1;h<u-8;h++)this.buffer[h]=0;this.buffer[u-8]=x>>>24&255,this.buffer[u-7]=x>>>16&255,this.buffer[u-6]=x>>>8&255,this.buffer[u-5]=x>>>0&255,this.buffer[u-4]=c>>>24&255,this.buffer[u-3]=c>>>16&255,this.buffer[u-2]=c>>>8&255,this.buffer[u-1]=c>>>0&255,r(this.temp,this.state,this.buffer,0,u),this.finished=!0}for(var h=0;h<8;h++)t[h*4+0]=this.state[h]>>>24&255,t[h*4+1]=this.state[h]>>>16&255,t[h*4+2]=this.state[h]>>>8&255,t[h*4+3]=this.state[h]>>>0&255;return this},s.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},s.prototype._saveState=function(t){for(var o=0;o<this.state.length;o++)t[o]=this.state[o]},s.prototype._restoreState=function(t,o){for(var f=0;f<this.state.length;f++)this.state[f]=t[f];this.bytesHashed=o,this.finished=!1,this.bufferLength=0},s})();n.Hash=i;var a=(function(){function s(t){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var o=new Uint8Array(this.blockSize);if(t.length>this.blockSize)new i().update(t).finish(o).clean();else for(var f=0;f<t.length;f++)o[f]=t[f];for(var f=0;f<o.length;f++)o[f]^=54;this.inner.update(o);for(var f=0;f<o.length;f++)o[f]^=106;this.outer.update(o),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var f=0;f<o.length;f++)o[f]=0}return s.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},s.prototype.clean=function(){for(var t=0;t<this.istate.length;t++)this.ostate[t]=this.istate[t]=0;this.inner.clean(),this.outer.clean()},s.prototype.update=function(t){return this.inner.update(t),this},s.prototype.finish=function(t){return this.outer.finished?this.outer.finish(t):(this.inner.finish(t),this.outer.update(t,this.digestLength).finish(t)),this},s.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},s})();n.HMAC=a;function g(s){var t=new i().update(s),o=t.digest();return t.clean(),o}n.hash=g,n.default=g;function p(s,t){var o=new a(s).update(t),f=o.digest();return o.clean(),f}n.hmac=p;function m(s,t,o,f){var x=f[0];if(x===0)throw new Error("hkdf: cannot expand more");t.reset(),x>1&&t.update(s),o&&t.update(o),t.update(f),t.finish(s),f[0]++}var E=new Uint8Array(n.digestLength);function C(s,t,o,f){t===void 0&&(t=E),f===void 0&&(f=32);for(var x=new Uint8Array([1]),c=p(t,s),u=new a(c),h=new Uint8Array(u.digestLength),_=h.length,v=new Uint8Array(f),d=0;d<f;d++)_===h.length&&(m(h,u,o,x),_=0),v[d]=h[_++];return u.clean(),h.fill(0),x.fill(0),v}n.hkdf=C;function A(s,t,o,f){for(var x=new a(s),c=x.digestLength,u=new Uint8Array(4),h=new Uint8Array(c),_=new Uint8Array(c),v=new Uint8Array(f),d=0;d*c<f;d++){var U=d+1;u[0]=U>>>24&255,u[1]=U>>>16&255,u[2]=U>>>8&255,u[3]=U>>>0&255,x.reset(),x.update(t),x.update(u),x.finish(_);for(var b=0;b<c;b++)h[b]=_[b];for(var b=2;b<=o;b++){x.reset(),x.update(_).finish(_);for(var w=0;w<c;w++)h[w]^=_[w]}for(var b=0;b<c&&d*c+b<f;b++)v[d*c+b]=h[b]}for(var d=0;d<c;d++)h[d]=_[d]=0;for(var d=0;d<4;d++)u[d]=0;return x.clean(),v}n.pbkdf2=A})});var ie=P(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.Webhook=L.WebhookVerificationError=void 0;var te=T(),J=W(),re=K(),Y=300,H=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name="ExtendableError",this.stack=new Error(e).stack}},k=class n extends H{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name="WebhookVerificationError"}};L.WebhookVerificationError=k;var q=class n{constructor(e,r){if(!e)throw new Error("Secret can't be empty.");if(r?.format==="raw")e instanceof Uint8Array?this.key=e:this.key=Uint8Array.from(e,i=>i.charCodeAt(0));else{if(typeof e!="string")throw new Error("Expected secret to be of type string");e.startsWith(n.prefix)&&(e=e.substring(n.prefix.length)),this.key=J.decode(e)}}verify(e,r){let i={};for(let t of Object.keys(r))i[t.toLowerCase()]=r[t];let a=i["webhook-id"],g=i["webhook-signature"],p=i["webhook-timestamp"];if(!g||!a||!p)throw new k("Missing required headers");let m=this.verifyTimestamp(p),C=this.sign(a,m,e).split(",")[1],A=g.split(" "),s=new globalThis.TextEncoder;for(let t of A){let[o,f]=t.split(",");if(o==="v1"&&(0,te.timingSafeEqual)(s.encode(f),s.encode(C)))return JSON.parse(e.toString())}throw new k("No matching signature found")}sign(e,r,i){if(typeof i!="string")if(i.constructor.name==="Buffer")i=i.toString();else throw new Error("Expected payload to be of type string or Buffer.");let a=new TextEncoder,g=Math.floor(r.getTime()/1e3),p=a.encode(`${e}.${g}.${i}`);return`v1,${J.encode(re.hmac(this.key,p))}`}verifyTimestamp(e){let r=Math.floor(Date.now()/1e3),i=parseInt(e,10);if(isNaN(i))throw new k("Invalid Signature Headers");if(r-i>Y)throw new k("Message timestamp too old");if(i>r+Y)throw new k("Message timestamp too new");return new Date(i*1e3)}};L.Webhook=q;q.prefix="whsec_"});export{ie as a};
|