ripplo 0.7.31 → 0.7.32
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-LXKWT62N.js +163 -0
- package/dist/chunk-PRVH6TRX.js +228 -0
- package/dist/daemon-GWAOG6CS.js +90 -0
- package/dist/daemon-MQGSYFH7.js +2 -0
- package/dist/index.js +180 -174
- package/package.json +4 -4
- package/dist/chunk-MJXQ6SVH.js +0 -164
- package/dist/chunk-WJ7CHQ7B.js +0 -228
- package/dist/daemon-EWT54KJZ.js +0 -90
- package/dist/daemon-PU4XNBMZ.js +0 -2
package/dist/chunk-WJ7CHQ7B.js
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{K as Ve,N as ze,a as O,d as Oe,f as De,g as _e,h as qe,i as h,j as He,l as R,m as T,n as We,q as v,v as Be}from"./chunk-MJXQ6SVH.js";import{b as Le,d as m,e as g,g as Ue,h as w,i as Ne}from"./chunk-5VRJXHWH.js";import Qe from"fs";import W from"path";import{config as mt}from"dotenv";import{z as q}from"zod";import{err as gt,ok as Ge}from"neverthrow";import _ from"fs";import ae from"path";import{err as oe,ok as Je}from"neverthrow";import{z as D}from"zod";var ct=ae.join(".ripplo","project.json"),ie=[".env",".env.local"],ut=D.object({envFiles:D.array(D.string().min(1)).optional(),projectId:D.string().min(1)});function Ke(e){return ae.join(e,ct)}function se(e){let n=Ke(e);return _.existsSync(n)?pt(n).andThen(t=>{let r=ut.safeParse(t);return r.success?Je({envFiles:r.data.envFiles??ie,projectId:r.data.projectId}):oe({issues:r.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:n})}):oe({kind:"project-file-missing",path:n})}function le(e){return se(e).match(n=>n,()=>{})}function pt(e){try{return Je(JSON.parse(_.readFileSync(e,"utf8")))}catch(n){return oe({issues:[n instanceof Error?n.message:String(n)],kind:"project-file-invalid",path:e})}}function Li({cwd:e,envFiles:n,projectId:t}){let r=Ke(e);_.mkdirSync(ae.dirname(r),{recursive:!0});let o={projectId:t};n!=null&&!ft(n)&&(o.envFiles=[...n]),_.writeFileSync(r,JSON.stringify(o,null,2)+`
|
|
3
|
-
`)}function ft(e){return e.length!==ie.length?!1:e.every((n,t)=>n===ie[t])}function Wi(e){let t=le(e)?.envFiles??[".env",".env.local"],r=W.join(e,".ripplo");t.forEach(o=>{let i=W.resolve(r,o);Qe.existsSync(i)&&mt({override:!0,path:i,quiet:!0})}),H=void 0}var yt=q.object({RIPPLO_APP_URL:q.url(),RIPPLO_ENGINE_URL:q.url(),RIPPLO_WEBHOOK_SECRET:q.string().min(1)}),H;function B(){return H!=null?Ge(H):Rt().map(e=>(H=e,e))}function ht(e){let t=le(e)?.envFiles??[],r=W.join(e,".ripplo");return t.map(o=>W.resolve(r,o)).filter(o=>!Qe.existsSync(o))}function Rt(){let e=yt.safeParse(process.env);if(!e.success)return gt({issues:e.error.issues.map(t=>`${t.path.join(".")}: ${t.message}`),kind:"env-invalid",missingEnvFiles:ht(process.cwd())});let n=e.data;return Ge({appUrl:n.RIPPLO_APP_URL,engineUrl:n.RIPPLO_ENGINE_URL,webhookSecret:n.RIPPLO_WEBHOOK_SECRET})}import{readFileSync as kt}from"fs";import{z as Xe}from"zod";var St=Xe.object({version:Xe.string()});function V(){let e=kt(new URL("../package.json",import.meta.url),"utf8");return St.parse(JSON.parse(e)).version}import fe from"fs";import z from"path";import{createJiti as At}from"jiti";import{err as L,ok as nn}from"neverthrow";import xt from"fs";import F from"path";import I from"typescript";function Ye(e){let n=F.join(e,"index.ts"),t=Et(e);xt.mkdirSync(F.dirname(t.tsBuildInfoFile??""),{recursive:!0});let r=I.createIncrementalCompilerHost(t),o=I.createIncrementalProgram({host:r,options:t,rootNames:[n]}),i=[...o.getSyntacticDiagnostics(),...o.getSemanticDiagnostics()];o.emit();let s=i.filter(d=>wt(d,e));if(s.length===0)return{diagnostics:[],ok:!0};let l={getCanonicalFileName:d=>d,getCurrentDirectory:()=>F.dirname(e),getNewLine:()=>`
|
|
4
|
-
`};return{diagnostics:I.formatDiagnosticsWithColorAndContext(s,l).split(`
|
|
5
|
-
`).filter(d=>d.length>0),ok:!1}}function wt(e,n){let t=e.file?.fileName;return t==null?!0:t.startsWith(n)}var bt=F.join(".local","tsbuildinfo");function Et(e){return{allowImportingTsExtensions:!0,allowJs:!1,esModuleInterop:!0,incremental:!0,module:I.ModuleKind.Preserve,moduleResolution:I.ModuleResolutionKind.Bundler,noEmit:!0,resolveJsonModule:!0,skipLibCheck:!0,strict:!1,target:I.ScriptTarget.ES2022,tsBuildInfoFile:F.join(e,bt)}}import{createHash as vt}from"crypto";import Ze from"fs/promises";import de from"path";import{err as P,ok as ce,Result as It}from"neverthrow";var $=".ripplo/fixtures",ue=10*1024*1024,pe=50*1024*1024;async function en(e,n){let t=Pt(n);if(t.length===0)return ce({});let r=de.join(e,$),o=await Promise.all(t.map(i=>Ct({fixturesRoot:r,name:i})));return It.combine(o).andThen(jt)}function Pt(e){let t=e.workflows.flatMap(r=>[...r.steps,...r.tests.flatMap(o=>o.steps)]).flatMap(r=>r.action.kind==="upload"?r.action.files:[]);return[...new Set(t)].toSorted((r,o)=>r.localeCompare(o))}async function Ct({fixturesRoot:e,name:n}){if(n.includes("..")||de.isAbsolute(n))return P({kind:"fixture-invalid-name",name:n});let t=de.join(e,n),r=await Ze.lstat(t).catch(()=>null);if(r==null)return P({kind:"fixture-missing",name:n,path:t});if(r.isSymbolicLink())return P({kind:"fixture-symlink",name:n});if(!r.isFile())return P({kind:"fixture-not-file",name:n});let o=await Ze.readFile(t);if(o.byteLength>ue)return P({kind:"fixture-too-large",name:n,size:o.byteLength});let i=vt("sha256").update(o).digest("hex");return ce([n,{sha256:i,size:o.byteLength}])}function jt(e){let n=e.reduce((t,[,r])=>t+r.size,0);return n>pe?P({kind:"fixtures-total-too-large",total:n}):ce(Object.fromEntries(e))}var C=".ripplo/ripplo.lock",M;async function tn(e){let{result:n}=await me(e);return n}async function me(e){let n=Ft(z.join(e,".ripplo"));if(M!=null&&M.fingerprint===n&&M.result.isOk())return{fingerprint:n,result:M.result};let t=await U(e);return M={fingerprint:n,result:t},{fingerprint:n,result:t}}async function U(e){let n=z.join(e,".ripplo"),t=z.join(n,"index.ts"),r=Ye(n);return r.ok?(await $t(t)).andThen(s=>Lt({entryPath:t,exported:s})).match(async s=>(await en(e,s)).map(p=>({...s,fixtures:p})).mapErr(p=>({error:p,kind:"fixture-failed"})),s=>Promise.resolve(L(s))):L({diagnostics:r.diagnostics,kind:"typecheck-failed"})}var Tt=new Set([".local","debug","node_modules"]);function Ft(e){return rn(e).toSorted((n,t)=>n.localeCompare(t)).join("|")}function rn(e){return(fe.existsSync(e)?fe.readdirSync(e,{withFileTypes:!0}):[]).flatMap(t=>{if(Tt.has(t.name))return[];let r=z.join(e,t.name);if(t.isDirectory())return rn(r);let o=fe.statSync(r);return[`${r}:${String(o.mtimeMs)}:${String(o.size)}`]})}async function $t(e){try{let t=await At(import.meta.url,{fsCache:!1,moduleCache:!1,sourceMaps:!0}).import(e),r=t!=null&&typeof t=="object"&&"default"in t?Reflect.get(t,"default"):t;return nn(r)}catch(n){return L({kind:"load-threw",message:Mt(n)})}}function Mt(e){return e instanceof Error?e.message:String(e)}function Lt({entryPath:e,exported:n}){if(n==null||typeof n!="object"||!("lockfile"in n))return L({entryPath:e,kind:"not-ripplo"});let t=Oe.safeParse(Reflect.get(n,"lockfile"));return t.success?nn(t.data):L({issues:t.error.issues.map(r=>`${r.path.join(".")}: ${r.message}`),kind:"invalid-lockfile"})}function j(e,n){return n==null?`Load \`/ripplo:${e}\` skill for instructions.`:`Load \`/ripplo:${e}\` skill for instructions on ${n}.`}function ua(e){return e.length===1?j(e[0]):`Before proceeding, load the ${e.map(t=>`\`/ripplo:${t}\``).join(" and ")} skills \u2014 every one, each carries rules the others don't.`}function K(e){return[`Compilation failed: ${Ut(e)}`,j("create","DSL authoring + lint rules")].join(`
|
|
6
|
-
`)}function ya(){return`${C} is up to date`}function ha(e){return[`${C} is ${e==="missing"?"missing":"out of date"} \u2014 run \`npx ripplo compile\` and commit the result`,j("setup")].join(`
|
|
7
|
-
`)}function Ra(){return`Wrote ${C}`}function Ut(e){switch(e.kind){case"typecheck-failed":return["TypeScript errors in .ripplo/:",...on(e.diagnostics)].join(`
|
|
8
|
-
`);case"not-ripplo":return`${e.entryPath} must default-export a Ripplo (createRipplo({ entities, singletons, workflows })). Check that the default export is the value returned by createRipplo, not a function or a re-export.`;case"invalid-lockfile":return["Lockfile failed schema validation (stale or hand-edited .ripplo/ripplo.lock?):",...on(e.issues),"Regenerate with `npx ripplo compile` \u2014 never hand-edit the lockfile."].join(`
|
|
9
|
-
`);case"load-threw":return[`.ripplo/index.ts threw while loading: ${e.message}`,"Usually a bad import or a top-level throw in .ripplo/ \u2014 run `npx ripplo compile` for the stack."].join(`
|
|
10
|
-
`);case"fixture-failed":return Nt(e.error)}}function on(e,n=8){return e.length<=n?e:[...e.slice(0,n),`\u2026 and ${String(e.length-n)} more`]}function Nt(e){switch(e.kind){case"fixture-missing":return`Fixture "${e.name}" not found at ${e.path} \u2014 add the file under .ripplo/fixtures/ or fix the upload() name.`;case"fixture-invalid-name":return`Invalid fixture name "${e.name}" \u2014 upload() takes a bare name under .ripplo/fixtures/, no .. or absolute paths.`;case"fixture-symlink":return`Fixture "${e.name}" is a symlink \u2014 only regular files are allowed.`;case"fixture-not-file":return`Fixture "${e.name}" is not a regular file.`;case"fixture-too-large":return`Fixture "${e.name}" is ${J(e.size)} \u2014 over the ${J(ue)} per-file limit.`;case"fixtures-total-too-large":return`Fixtures total ${J(e.total)} \u2014 over the ${J(pe)} limit.`}}function J(e){return`${String(Math.round(e/(1024*1024)*10)/10)} MB`}var Q=class extends Error{failure;constructor(n){super(n.kind),this.name="CliError",this.failure=n}};function Ea(e){return e instanceof Q?ge(e.failure):e instanceof Error?e.message:String(e)}function ge(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).",j("setup")].join(`
|
|
11
|
-
`);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(n=>` ${n}`),"Fix the file by hand or re-run `npx ripplo init`."].join(`
|
|
12
|
-
`);case"not-authenticated":return["Not signed in. Run `npx ripplo auth login`.","(Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)"].join(`
|
|
13
|
-
`);case"env-invalid":return Ot(e);case"playwright-install-failed":return["Playwright browser install failed \u2014 Chromium is still missing.","Run `npx playwright install chromium` and check its output for network, proxy, or disk-space errors."].join(`
|
|
14
|
-
`);case"gitdir-unrecognized":return`Unrecognized .git file at ${e.marker} \u2014 expected a directory or a "gitdir:" pointer (worktree). Is the repo corrupted?`;case"gitdir-empty":return`Empty gitdir pointer at ${e.marker} \u2014 the worktree's .git file points nowhere. Re-create the worktree.`;case"oauth-device-code-failed":return[`Could not start sign-in (device-code request failed): ${e.description}`,"Is the Ripplo server reachable? Check RIPPLO_SERVER_URL and retry."].join(`
|
|
15
|
-
`);case"oauth-authorization-failed":return[`Sign-in failed (${e.code}): ${e.description}`,e.code==="expired_token"?"The approval window expired \u2014 run `npx ripplo auth login` again.":"Run `npx ripplo auth login` to retry."].join(`
|
|
16
|
-
`);case"compilation-failed":return K(e.error)}}function Ot(e){let n=e.missingEnvFiles.length===0?[]:["Declared env files not found:",...e.missingEnvFiles.map(t=>` ${t}`),"In a git worktree? Env files aren't copied from the main checkout \u2014 recreate them, or symlink to a shared file outside the working tree."];return["Env config invalid:",...e.issues.map(t=>` ${t}`),"Add the missing values to the env files declared in .ripplo/project.json.",...n].join(`
|
|
17
|
-
`)}import{err as qt,ok as Ht}from"neverthrow";import{z as ye}from"zod";var Dt="https://ripplo.ai";function sn(){return dn().RIPPLO_SERVER_URL}function ln(){return dn().RIPPLO_PROJECT_ID}var _t=ye.object({RIPPLO_PROJECT_ID:ye.string().min(1).optional(),RIPPLO_SERVER_URL:ye.string().min(1).default(Dt)}),an;function dn(){return an??=_t.parse(process.env),an}import cn from"fs";import he from"path";function un(e){let n=cn.realpathSync(e),t=n,r=he.dirname(t);for(;r!==t;){if(cn.existsSync(he.join(t,".git")))return t;t=r,r=he.dirname(t)}return n}function pn(e){return se(e).andThen(n=>B().andThen(t=>{let r=sn(),o=Ne(r);return o==null?qt({kind:"not-authenticated"}):Ht({appUrl:t.appUrl,cwd:un(e),engineUrl:t.engineUrl,projectId:ln()??n.projectId,ripploServerUrl:r,token:o,tunnelAuth:void 0,webhookSecret:t.webhookSecret})}))}import fn from"fs";import{checkSync as Wt,lockSync as Bt}from"proper-lockfile";var Vt="dev.pid",mn=15e3;function gn(e){return w(e,Vt)}function yn(e){try{return Wt(gn(e),{realpath:!1,stale:mn})}catch{return!1}}var Re=class extends Error{pid;cwd;constructor({cwd:n,pid:t}){super("dev-lock-held"),this.name="DevLockHeldError",this.pid=t,this.cwd=n}};function qa({cwd:e,onCompromised:n}){Ue(e);let t=gn(e),r=zt({cwd:e,onCompromised:n,path:t});return fn.writeFileSync(t,String(process.pid)),()=>{try{r()}catch{}}}function zt({cwd:e,onCompromised:n,path:t}){try{return Bt(t,{realpath:!1,stale:mn,onCompromised:()=>{n()}})}catch(r){throw Jt(r)?new Re({cwd:e,pid:Kt(t)}):r}}function Jt(e){if(!(e instanceof Error)||!("code"in e))return!1;let{code:n}=e;return n==="ELOCKED"}function Kt(e){try{let n=fn.readFileSync(e,"utf8").trim(),t=Number.parseInt(n,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}}import Qt from"p-queue";var Gt=4,Xt={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},G=new Qt({concurrency:Gt}),k={headedActive:0,interactiveActive:0,interactiveQueued:0},hn={current:null};function Ba({headed:e,task:n,workClass:t}){let r=Xt[t];return t==="p3-explore"?G.add(n,{priority:r}):(k.interactiveQueued+=1,X(),G.add(()=>Yt({headed:e,task:n}),{priority:r}))}function Va(e){!Number.isFinite(e)||e<1||(G.concurrency=Math.floor(e),X())}function ke(){return{active:k.interactiveActive,headedActive:k.headedActive,poolSize:G.concurrency,queued:k.interactiveQueued}}function za(e){hn.current=e}async function Yt({headed:e,task:n}){k.interactiveQueued-=1,k.interactiveActive+=1,k.headedActive+=e?1:0,X();try{return await n()}finally{k.interactiveActive-=1,k.headedActive-=e?1:0,X()}}function X(){hn.current?.()}import Se from"fs";import xe from"path";function Rn(e){try{let n=Zt(e);if(n==null)return;let t=xe.join(n,"HEAD"),r=Se.readFileSync(t,"utf8").trim(),o="ref: refs/heads/";return r.startsWith(o)?r.slice(o.length):r.length===0?void 0:r.slice(0,7)}catch{return}}function Zt(e){let n=xe.join(e,".git");if(Se.statSync(n).isDirectory())return n;let r=Se.readFileSync(n,"utf8").trim(),o="gitdir:";if(!r.startsWith(o))return;let i=r.slice(o.length).trim();if(i.length!==0)return xe.resolve(e,i)}import er from"crypto";import{readFile as kn}from"fs/promises";import Sn from"path";import{graphql as nr}from"gql.tada";import{err as tr,ok as rr}from"neverthrow";var or=nr(`
|
|
18
|
-
mutation SyncDevSession(
|
|
19
|
-
$projectId: String!
|
|
20
|
-
$cwd: String!
|
|
21
|
-
$branch: String
|
|
22
|
-
$lockfileContent: String
|
|
23
|
-
$fixtures: [SyncDevFixtureInput!]
|
|
24
|
-
$preconditions: [SyncDevPreconditionInput!]!
|
|
25
|
-
$singletons: [SyncDevSingletonInput!]
|
|
26
|
-
$workflows: [SyncDevWorkflowInput!]!
|
|
27
|
-
) {
|
|
28
|
-
syncDevSession(
|
|
29
|
-
projectId: $projectId
|
|
30
|
-
cwd: $cwd
|
|
31
|
-
branch: $branch
|
|
32
|
-
lockfileContent: $lockfileContent
|
|
33
|
-
fixtures: $fixtures
|
|
34
|
-
preconditions: $preconditions
|
|
35
|
-
singletons: $singletons
|
|
36
|
-
workflows: $workflows
|
|
37
|
-
) {
|
|
38
|
-
id
|
|
39
|
-
hooksPaused
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
`);async function ss(e,n){let t=await U(e);if(t.isErr())return tr({error:t.error,kind:"compilation-failed"});let r=await we({config:n,cwd:e,lockfile:t.value});return rr({devSessionId:r.devSessionId,lockfile:t.value})}async function we(e){let n=_e(e.lockfile);return ar({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:n})}function ir(e){return er.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function ar({config:e,cwd:n,fixtures:t,payload:r}){let o=ir(r),i=Rn(n),s=await lr(n),l=await sr(n,t),p=await m({config:e,document:or,variables:{branch:i??null,cwd:n,fixtures:l,lockfileContent:s,preconditions:r.preconditions.map(d=>({depends:[...d.depends],description:d.description,name:d.name,returns:[...d.returns]})),projectId:e.projectId,singletons:r.singletons.map(d=>({defaultValue:d.defaultValue,description:d.description,name:d.name,type:d.type})),workflows:r.workflows.map(d=>({expectedOutcome:d.expectedOutcome,name:d.name,preconditions:[...d.preconditions],requiresKeys:d.requiresKeys.map(c=>({namespace:c.namespace,preconditionName:c.preconditionName})),slug:d.slug,sourcePath:d.sourcePath,spec:JSON.stringify(d.spec)}))}});if(p.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:p.syncDevSession.id,hash:o,hooksPaused:p.syncDevSession.hooksPaused}}async function sr(e,n){let t=Object.entries(n);return Promise.all(t.map(async([r,o])=>({contentBase64:(await kn(Sn.join(e,$,r))).toString("base64"),sha256:o.sha256})))}async function lr(e){try{return await kn(Sn.join(e,C),"utf8")}catch{return null}}import{randomUUID as qr}from"crypto";import{createId as Hr}from"@paralleldrive/cuid2";import{CancellationTokenSource as Wr,ResponseError as Br}from"vscode-jsonrpc/node";import{graphql as dr}from"gql.tada";var cr=dr(`
|
|
43
|
-
mutation DaemonCreateRun(
|
|
44
|
-
$id: String
|
|
45
|
-
$workflowId: String!
|
|
46
|
-
$testId: String
|
|
47
|
-
$clientVersion: String
|
|
48
|
-
$executor: RunExecutor
|
|
49
|
-
$target: RunTarget
|
|
50
|
-
$lockfileHash: String
|
|
51
|
-
) {
|
|
52
|
-
createRun(
|
|
53
|
-
id: $id
|
|
54
|
-
workflowId: $workflowId
|
|
55
|
-
testId: $testId
|
|
56
|
-
executor: $executor
|
|
57
|
-
target: $target
|
|
58
|
-
clientVersion: $clientVersion
|
|
59
|
-
lockfileHash: $lockfileHash
|
|
60
|
-
) {
|
|
61
|
-
__typename
|
|
62
|
-
... on MutationCreateRunSuccess {
|
|
63
|
-
data {
|
|
64
|
-
id
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
... on LimitExceededError {
|
|
68
|
-
code
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
`);async function xn(e){try{let t=(await m({config:e.config,document:cr,variables:ur(e)})).createRun;return t==null?Y({detail:"create-run-null",type:"generic"}):t.__typename==="MutationCreateRunSuccess"?null:t.__typename==="LimitExceededError"?Y({code:t.code,type:"limit"}):Y({detail:t.__typename,type:"generic"})}catch(n){return pr(n)}}function ur({executor:e,lockfileHash:n,runId:t,target:r}){return{clientVersion:V(),executor:e,id:t,lockfileHash:n,target:e==="cloud"?"tunnel":void 0,testId:r.testId,workflowId:r.workflowId}}function Y(e){return{kind:"dispatch-error",reason:e}}function pr(e){return e instanceof Le?{detail:e.message,kind:"infra-error"}:Y({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{createMessageConnection as fr,NotificationType as wn,RequestType as mr,RequestType0 as bn,SocketMessageReader as gr,SocketMessageWriter as yr}from"vscode-jsonrpc/node";import{z as a}from"zod";var hr="daemon.sock",Rr="daemon.log";function ys(e){return w(e,hr)}function hs(e){return w(e,Rr)}function En(e){return fr(new gr(e),new yr(e))}var vn=a.object({all:a.boolean(),headed:a.boolean(),tests:a.array(a.string())}),Rs=a.object({jobId:a.string(),total:a.number()}),kr=a.enum(["on","off"]),Sr=a.object({attempts:a.number(),findings:a.number()}),ks=a.object({active:a.number(),explorer:kr,exploring:a.number(),progress:Sr,queued:a.number(),sseHealth:a.object({detail:a.string().optional(),ok:a.boolean()}).optional(),version:a.string().optional()}),xr=a.enum(["MAX_RUNS","OVERAGE_CAP","MAX_AGENTS","MAX_CONCURRENT_RUNS","MAX_PROJECTS"]),wr=a.discriminatedUnion("type",[a.object({code:xr,type:a.literal("limit")}),a.object({detail:a.string(),type:a.literal("generic")})]),be=a.discriminatedUnion("kind",[a.object({kind:a.literal("pass")}),a.object({findingLines:a.array(a.string()),kind:a.literal("findings")}),a.object({detail:a.string(),kind:a.literal("error")}),a.object({kind:a.literal("dispatch-error"),reason:wr}),a.object({detail:a.string(),kind:a.literal("dispatch-timeout")}),a.object({detail:a.string(),kind:a.literal("infra-error")})]),br=a.discriminatedUnion("kind",[a.object({kind:a.literal("test-started"),runId:a.string(),testName:a.string(),workflowName:a.string()}),a.object({kind:a.literal("test-outcome"),outcome:be,runId:a.string(),testName:a.string(),workflowName:a.string()})]),Ss=a.object({event:br,jobId:a.string()}),xs=a.object({failed:a.number(),jobId:a.string(),notRun:a.number(),passed:a.number()}),ws=a.discriminatedUnion("code",[a.object({code:a.literal("compile-failed"),detail:a.string(),diagnostics:a.array(a.string()).default([])}),a.object({code:a.literal("selection-conflicting-flags")}),a.object({code:a.literal("selection-nothing-selected")}),a.object({code:a.literal("selection-unknown-ids"),known:a.array(a.string()),unknown:a.array(a.string())}),a.object({code:a.literal("scope-failed"),detail:a.string()}),a.object({code:a.literal("app-unreachable"),detail:a.string(),url:a.string()}),a.object({code:a.literal("sync-failed"),detail:a.string()}),a.object({code:a.literal("bad-message")})]),In=new mr("ripplo/enqueue"),Pn=new bn("ripplo/status"),Cn=new bn("ripplo/shutdownIfIdle"),jn=new wn("ripplo/jobEvent"),An=new wn("ripplo/jobDone");import{graphql as Er}from"gql.tada";async function Tn(e,n){let r=(await m({config:e,document:vr,variables:{cwd:n,projectId:e.projectId}})).project?.devSession?.workflows??[];return new Map(r.flatMap(o=>o.tests.map(i=>[`${o.slug}/${i.slug}`,{testId:i.id,workflowId:o.id}])))}var vr=Er(`
|
|
73
|
-
query DaemonWorkflows($projectId: String!, $cwd: String!) {
|
|
74
|
-
project(id: $projectId) {
|
|
75
|
-
id
|
|
76
|
-
devSession(cwd: $cwd) {
|
|
77
|
-
id
|
|
78
|
-
workflows {
|
|
79
|
-
id
|
|
80
|
-
slug
|
|
81
|
-
tests {
|
|
82
|
-
id
|
|
83
|
-
slug
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
`);import{CancellationTokenSource as Ir}from"vscode-jsonrpc/node";function Ee(e){return`${e.workflowSlug}/${e.testSlug}`}function Fn(e){let{headed:n,inflight:t,jobId:r,lockfileHashValue:o,onExpire:i,runId:s,selection:l,timeoutMs:p}=e,d=Ee(l),c=`${d}@${o}@${String(n)}`,u=t.get(c);if(u!=null)return u.jobIds.add(r),null;let y={cancellation:new Ir,claimed:!1,claimKey:d,headed:n,inflightKey:c,jobIds:new Set([r]),runId:s,testName:l.testName,timer:null,workflowName:l.workflowName};return y.timer=setTimeout(()=>{Z(t,y),i(y)},p),t.set(c,y),y}function Z(e,n){n.timer!=null&&(clearTimeout(n.timer),n.timer=null),e.delete(n.inflightKey)}function ve(e,n){let t=[...e.values()].find(r=>r.runId===n&&!r.claimed);return t==null?null:(t.claimed=!0,t.timer!=null&&(clearTimeout(t.timer),t.timer=null),t)}function $n(e,n){[...e.values()].filter(t=>t.jobIds.has(n)).forEach(t=>{t.jobIds.delete(n),t.jobIds.size===0&&(Z(e,t),t.cancellation.cancel())})}import{err as Ie,ok as Mn}from"neverthrow";function Un({all:e,ids:n,lockfile:t}){if(e&&n.length>0)return Ie({kind:"conflicting-flags"});if(e)return Mn(t.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>R(s))));if(n.length===0)return Ie({kind:"nothing-selected"});let r=n.map(i=>({id:i,refs:Cr(t,i)})),o=r.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?Ie({kind:"unknown-ids",known:Pr(t),unknown:o}):Mn([...new Set(r.flatMap(i=>i.refs))])}function Nn(e,n){let t=new Map(T(e).map(r=>[r.ref,{testName:r.test.name,testSlug:r.test.slug,workflowName:r.workflow.name,workflowSlug:h(r.workflow.name)}]));return n.map(r=>{let o=t.get(r);if(o==null)throw new Error(`selectionsFor: ref not in lockfile: ${r}`);return o})}function Pr(e){return e.workflows.map(n=>h(n.name))}function Cr(e,n){let t=e.workflows.find(r=>r.name===n||h(r.name)===h(n));return t!=null?t.tests.map(r=>R(r)):T(e).filter(r=>r.ref===n||Ln(r.ref)===Ln(n)).map(r=>r.ref)}function Ln(e){let n=e.lastIndexOf("/");return n===-1?h(e):`${h(e.slice(0,n))}/${h(e.slice(n+1))}`}import{err as Pe,ok as Dn}from"neverthrow";import{graphql as _n}from"gql.tada";import{execFileSync as jr}from"child_process";var Ar=256*1024*1024;function ee(e,n){return jr("git",[...e],{cwd:n,encoding:"utf8",maxBuffer:Ar,stdio:["ignore","pipe","pipe"]})}async function qn({config:e,cwd:n,lockfile:t}){await Fr({config:e,cwd:n,lockfile:t});let r=await Mr(e);if(r.isErr())return Pe(r.error);let o=new Map(t.workflows.filter(s=>!s.stub).map(s=>[h(s.name),s])),i=[...new Set(r.value)].flatMap(s=>{let l=o.get(s);return l==null?[]:l.tests.map(p=>R(p))});return i.length===0?Pe({kind:"scope-empty"}):Dn(i)}var Tr=_n(`
|
|
90
|
-
mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
91
|
-
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
92
|
-
__typename
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
`);async function Fr({config:e,cwd:n,lockfile:t}){let r=new Set(Lr(n)),o=t.workflows.filter(i=>i.sourcePath!=null&&r.has(i.sourcePath)).map(i=>h(i.name));o.length!==0&&await m({config:e,document:Tr,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{g.warn({err:i},"auto-scope of dirty tests failed")})}var $r=_n(`
|
|
96
|
-
query ScopeSelection($projectId: String!, $cwd: String!) {
|
|
97
|
-
project(id: $projectId) {
|
|
98
|
-
id
|
|
99
|
-
devSession(cwd: $cwd) {
|
|
100
|
-
id
|
|
101
|
-
scopeItems {
|
|
102
|
-
id
|
|
103
|
-
workflow {
|
|
104
|
-
id
|
|
105
|
-
slug
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
`);async function Mr(e){try{let t=(await m({config:e,document:$r,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return Dn(t.flatMap(r=>r.workflow==null?[]:[r.workflow.slug]))}catch(n){return Pe({detail:n instanceof Error?n.message:String(n),kind:"scope-fetch-failed"})}}var On=".ripplo/workflows/";function Lr(e){try{return ee(["status","--porcelain","--",".ripplo/workflows"],e).split(`
|
|
112
|
-
`).map(n=>n.slice(3).trim()).filter(n=>n.startsWith(On)&&n.endsWith(".ts")).map(n=>n.slice(On.length)).filter(n=>n!=="index.ts"&&!n.endsWith("/index.ts"))}catch{return[]}}import{graphql as Ur}from"gql.tada";var Nr=2e3,Or=Ur(`
|
|
113
|
-
query DaemonCloudRunStatus($runId: String!) {
|
|
114
|
-
run(id: $runId) {
|
|
115
|
-
status
|
|
116
|
-
failureReason
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
`);function Wn({config:e,onComplete:n,onStarted:t,runId:r,signal:o}){let i=!1,s,l=!1,p=async()=>{if(i||o.aborted)return;let d=await Dr(e,r).catch(()=>"unknown");if(!l&&(d==="running"||Hn(d))&&(l=!0,t()),Hn(d)){i=!0,n(_r(d));return}s=setTimeout(()=>{p()},Nr)};return p(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function Dr(e,n){let r=(await m({config:e,document:Or,variables:{runId:n}})).run?.status;return r??"unknown"}function Hn(e){return e==="passed"||e==="failed"||e==="warning"||e==="cancelled"||e==="unready"}function _r(e){return e==="passed"?{kind:"pass"}:e==="failed"?{detail:"failed",kind:"error"}:e==="warning"?{findingLines:[],kind:"findings"}:e==="cancelled"?{detail:"cancelled",kind:"error"}:e==="unready"?{detail:"unready",kind:"error"}:{detail:"unknown",kind:"error"}}var Vr=12e4,zr=-32099;function Jr(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:t=>Yr(n,t),handleConnection:t=>{Kr(n,t)},idle:()=>zn(n)}}function Kr(e,n){let t=En(n);t.onRequest(In,(r,o)=>Qr({connection:t,ctx:e,params:r,token:o})),t.onRequest(Pn,()=>{let r=ke();return{active:r.active,queued:r.queued,sseHealth:e.sseHealth(),version:V(),...e.explorationStatus()}}),t.onRequest(Cn,()=>{let r=zn(e);return r&&e.onShutdownRequest(),r}),t.onClose(()=>{Gr(e,t)}),t.onError(r=>{g.warn({err:r},"ipc connection error")}),n.on("error",r=>{g.warn({err:r},"ipc socket error")}),t.listen()}function zn(e){let n=ke();return e.jobs.size===0&&n.active===0&&n.queued===0}async function Qr({connection:e,ctx:n,params:t,token:r}){let o=vn.safeParse(t);if(!o.success)throw Bn({code:"bad-message"});await n.ready;let i=await eo({config:n.config,cwd:n.cwd,message:o.data});if(i.kind==="error")throw Bn(i.error);let s=qr(),l=new Wr;return r.onCancellationRequested(()=>{Jn(n,s)}),n.jobs.set(s,{cancellation:l,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:l.token}).catch(p=>{g.error({err:p},"ipc dispatch failed")}),{jobId:s,total:i.selections.length}}function Bn(e){return new Br(zr,e.code,e)}function Jn(e,n){let t=e.jobs.get(n);t!=null&&(t.cancellation.cancel(),e.jobs.delete(n),$n(e.inflight,n))}function Gr(e,n){[...e.jobs.entries()].filter(([,t])=>t.connection===n).forEach(([t])=>{Jn(e,t)})}function Kn(e,n,t){let r=e.jobs.get(n);r!=null&&(Vn(()=>r.connection.sendNotification(jn,{event:t,jobId:n})),t.kind==="test-outcome"&&(Xr(r,t.outcome.kind),r.passed+r.failed+r.notRun>=r.total&&(Vn(()=>r.connection.sendNotification(An,{failed:r.failed,jobId:n,notRun:r.notRun,passed:r.passed})),e.jobs.delete(n))))}function Vn(e){e().catch(n=>{g.warn({err:n},"ipc notification failed")})}function Xr(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 A(e,n,t){n.jobIds.forEach(r=>{Kn(e,r,t)})}function Yr(e,n){let t=ve(e.inflight,n);return t==null?null:{headed:t.headed,token:t.cancellation.token,finished:(r,o)=>{e.inflight.delete(t.inflightKey),A(e,t,{kind:"test-outcome",outcome:o,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},started:()=>{A(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}}}function Zr(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 eo({config:e,cwd:n,message:t}){return(await tn(n)).match(o=>no({config:e,cwd:n,lockfile:o,message:t}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...Zr(o)]},kind:"error"}))}async function no({config:e,cwd:n,lockfile:t,message:r}){let o=await ro(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=await oo({config:e,cwd:n,lockfile:t});return i!=null?{error:{code:"sync-failed",detail:i},kind:"error"}:(await io({config:e,cwd:n,lockfile:t,message:r})).match(async l=>({kind:"ready",lockfileHashValue:De(t),selections:Nn(t,l),targetsByClaimKey:await Tn(e,n)}),l=>Promise.resolve({error:l,kind:"error"}))}var to=2e3;async function ro(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(to)}),null}catch(n){return n instanceof Error?n.message:String(n)}}async function oo(e){try{return await we(e),null}catch(n){return n instanceof Error?n.message:String(n)}}async function io({config:e,cwd:n,lockfile:t,message:r}){return!r.all&&r.tests.length===0?(await qn({config:e,cwd:n,lockfile:t})).mapErr(ao):Un({all:r.all,ids:r.tests,lockfile:t}).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,t)=>n.then(()=>co(e,t)),Promise.resolve())}async function co(e,n){let{ctx:t,headed:r,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:l}=e;if(l.isCancellationRequested)return;let p=Ee(n),d=s.get(p);if(d==null){Kn(t,o,{kind:"test-outcome",outcome:{kind:"dispatch-error",reason:{detail:"test-not-found",type:"generic"}},runId:"",testName:n.testName,workflowName:n.workflowName});return}let c=Fn({headed:r,inflight:t.inflight,jobId:o,lockfileHashValue:i,runId:Hr(),selection:n,timeoutMs:Vr,onExpire:y=>{A(t,y,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:y.testName,workflowName:y.workflowName})}});if(c==null)return;let u=await uo(t,d,c.runId,i);if(u!=null){Z(t.inflight,c),A(t,c,{kind:"test-outcome",outcome:u,runId:"",testName:n.testName,workflowName:n.workflowName});return}t.executor==="cloud"&&po(t,c)}function uo(e,n,t,r){return xn({config:e.config,executor:e.executor,lockfileHash:r,runId:t,target:n})}function po(e,n){let t=ve(e.inflight,n.runId);t!=null&&Wn({config:e.config,runId:t.runId,signal:Jr(t.cancellation.token),onComplete:r=>{e.inflight.delete(t.inflightKey),A(e,t,{kind:"test-outcome",outcome:r,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},onStarted:()=>{A(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}})}import fo from"fs";import mo from"path";async function gl(e){let n=mo.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 t=await U(e);return t.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:K(t.error),path:".ripplo/"}],valid:!1,warnings:[]}:B().match(r=>({appUrl:r.appUrl,engineUrl:r.engineUrl,errors:[],valid:!0,warnings:[]}),r=>({appUrl:void 0,engineUrl:void 0,errors:[{message:ge(r),path:""}],valid:!1,warnings:[]}))}async function yl(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 t=n.startsWith("http://")||n.startsWith("https://")?n:`${e}${n}`;try{return(await fetch(`${t}/setup`,{body:JSON.stringify({}),headers:{"Content-Type":"application/json"},method:"PUT",signal:AbortSignal.timeout(5e3)})).ok?"Engine endpoint accepted an unsigned request \u2014 webhook signature verification may be missing.":void 0}catch{return}}import Ro from"fs";import go from"fs";import Ce from"path";var yo=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function Qn(e){let n=ho(e);return n==null?!1:yo.some(t=>go.existsSync(Ce.join(n,t)))}function ho(e){try{let n=ee(["rev-parse","--git-dir"],e).trim();return n.length===0?null:Ce.isAbsolute(n)?n:Ce.resolve(e,n)}catch{return null}}function ko(e){return w(e,"hooks-paused")}function Pl(e){return Ro.existsSync(ko(e))||Qn(e)?!1:yn(e)}import{createMessageConnection as Gn,IPCMessageReader as Xn,IPCMessageWriter as Yn,NotificationType as So,NotificationType0 as Zn,RequestType as je}from"vscode-jsonrpc/node";import{z as f}from"zod";var Fl=f.object({headed:f.boolean(),lockfileFingerprint:f.string(),runId:f.string().min(1),testRef:f.string().min(1)}),$l=f.object({fingerprint:f.string()}),Ml=f.object({lockfileJson:f.string().optional(),unavailable:f.string().optional()}),xo=f.enum(["unspecified","internal","server","client","producer","consumer"]),wo=f.enum(["unset","ok","error"]),bo=f.object({attributes:f.record(f.string(),f.string()),durationMs:f.number(),kind:f.literal("span"),name:f.string(),parentSpanId:f.union([f.string(),f.undefined()]),source:f.literal("server"),spanId:f.string(),spanKind:xo,status:f.object({code:wo,message:f.union([f.string(),f.undefined()])}),timeNanos:f.string(),traceId:f.string()}),Ll=f.object({runId:f.string().min(1),span:bo}),Ul=f.object({outcome:be,serverNotified:f.boolean()}),Nl=new Zn("worker/ready"),Ol=new je("worker/run"),Dl=new je("worker/lockfile"),_l=new je("worker/exploreTrail"),ql=new So("worker/span"),Hl=new Zn("worker/shutdown");function Wl(e){let n=Gn(new Xn(e),new Yn(e));return n.listen(),n}function Bl(){let e=Gn(new Xn(process),new Yn(process));return e.listen(),e}import{graphql as E}from"gql.tada";import{gzip as To}from"zlib";import{promisify as Fo}from"util";import{existsSync as Te,readFileSync as Fe}from"fs";import ne from"path";import{graphql as b}from"gql.tada";function et(e){return[e.kind,e.target,e.value].filter(n=>n.length>0).join(" ")}var Eo={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},vo={"data-rule":"dataRule","page-rule":"pageRule",step:"step"},Io={aborted:"aborted","action-failed":"actionFailed","check-failed":"checkFailed","client-mount-missing":"clientMountMissing","conflicting-sessions":"conflictingSessions","driver-launch":"driverLaunch","engine-decode":"engineDecode","engine-http":"engineHttp","engine-network":"engineNetwork","engine-unreachable":"engineUnreachable","setup-missing-row":"setupMissingRow","state-identity":"stateIdentity"};function nt(e){return e.kind==="consistency"?{consistency:{mismatch:jo(e.mismatch),pending:e.pending}}:e.kind==="pending-check"?{pendingCheck:{budget:e.budget,source:vo[e.source.kind],...Po(e.source)}}:e.kind==="unrunnable"?{unrunnable:{reason:Eo[e.reason]}}:e.kind==="driver-error"?{driverError:{errorKind:Io[e.error.kind],message:Ao(e.error)}}:{impossibleAction:{subject:Co(e.step.action)}}}function Po(e){return"check"in e?tt(e.check,!1):{checkKind:void 0,expected:void 0,negated:void 0,subject:void 0}}function tt(e,n){return e.kind==="not"?tt(e.inner,!n):e.kind==="browser"?{checkKind:"browser",expected:e.value,negated:n,subject:e.name}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:n,subject:O(e.locator)}:{checkKind:e.kind,expected:void 0,negated:n,subject:O(e.locator)}}function Co(e){let n=e.locator==null?e.url??"":O(e.locator);return`${e.kind} ${n}`.trim()}function jo(e){return e.kind==="wrong-value"?{wrongValue:{entity:e.entity,field:e.field,key:e.key,snapshot:N(e.snapshot),sut:N(e.sut)}}:e.kind==="expected-change"?{expectedChange:{entity:e.entity,field:e.field,key:e.key,value:N(e.value)}}:e.kind==="singleton-mismatch"?{singletonMismatch:{singleton:e.singleton,snapshot:N(e.snapshot),sut:N(e.sut)}}:e.kind==="unexpected-row"?{unexpectedRow:{entity:e.entity,key:e.key}}:{missingRow:{entity:e.entity,key:e.key}}}function N(e){return e==null?null:String(e)}function Ao(e){return"message"in e?e.message:"detail"in e?e.detail:null}async function $o({config:e,cwd:n,fixturesDir:t,headed:r,lockfile:o,runId:i,session:s,signal:l,test:p}){if(!await oi(e,i))return{kind:"dispatch-failed",reason:"already-claimed",runId:i};let c=ne.join(n,".ripplo","debug"),u=[];return(await s.runOnce({capture:!0,lockfile:o,onPhase:void 0,options:{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:t,generate:v,headed:r,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth},params:void 0,runId:i,sequence:void 0,test:p,onEvent:S=>{u.push(S)}},l)).match(async S=>{let x=ot(u).flatMap(dt=>dt.findings),Me=Mo(x);return Me!=null?(await rt({config:e,debugDir:c,events:u,recordingOptional:!0,runId:i,stepSources:void 0}),{error:Me,kind:"error",runId:i}):(await te({config:e,debugDir:c,events:u,recordingOptional:!1,runId:i,stepSources:void 0}),x.length>0?{findings:x,kind:"findings",runId:i}:{kind:"pass",runId:i})},S=>Promise.resolve({error:S,kind:"error",runId:i}))}function Mo(e){let n=e.find(t=>t.kind==="driver-error"&&He(t.error));return n!=null&&n.kind==="driver-error"?n.error:void 0}async function te(e){let n=await rt(e);await ri(e.config,e.runId,n),await Uo(e.config,e.debugDir,e.runId)}async function rt({config:e,debugDir:n,events:t,recordingOptional:r,runId:o,stepSources:i}){let s=ot(t),l=Oo(n,o);if(l==null&&!r)throw new Error("recording-missing");return await zo({aliases:[...qo(t),...Ho(s)],config:e,generated:Wo(t),generatedSingletons:Bo(t),origin:l==null?No(s):l.origin,records:s,rrwebEvents:l==null?[]:l.events,runId:o,stepSources:i}),l!=null&&await ti(e,o,l),s}var Lo=b(`
|
|
120
|
-
mutation ClipUploadUrl($runId: ID!) {
|
|
121
|
-
clipUploadUrl(runId: $runId)
|
|
122
|
-
}
|
|
123
|
-
`);async function Uo(e,n,t){let r=ne.join(n,t,"clip.gif");if(Te(r))try{let o=await m({config:e,document:Lo,variables:{runId:t}});if(o.clipUploadUrl==null)return;let i=await fetch(o.clipUploadUrl,{body:new Uint8Array(Fe(r)),headers:{"Content-Type":"image/gif"},method:"PUT"});i.ok||g.warn({runId:t,status:i.status},"Clip upload failed")}catch(o){g.warn({err:o,runId:t},"Clip upload skipped")}}function No(e){return e.reduce((n,t)=>Math.min(n,t.startMs),e[0]?.startMs??0)}function ot(e){return e.flatMap(n=>n.kind==="step"?[{annotations:n.annotations,endMs:n.endMs,findings:n.findings,index:n.index,source:n.source,startMs:n.startMs,state:n.state,url:n.url}]:[])}function Oo(e,n){let t=ne.join(e,n,"behavior.jsonl");if(!Te(t))return null;let r=Fe(t,"utf8").split(`
|
|
124
|
-
`).filter(i=>i.length>0).map(i=>Do(i)).flatMap(i=>_o(i)?[i.event]:[]),o=r[0];return o==null?null:{events:r,origin:o.timestamp}}function Do(e){return JSON.parse(e)}function _o(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function qo(e){return e.flatMap(n=>n.kind==="world"?n.aliases:[])}function Ho(e){return e.flatMap(n=>{let t=Vo(n.source);return t.flatMap(r=>{let i=t.filter(l=>l.entity===r.entity).indexOf(r),s=n.state.rows.filter(l=>l.status==="created"&&l.entity===r.entity).at(i);return s==null?[]:[{alias:r.as,entity:r.entity,key:s.key}]})})}function Wo(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generated.map(t=>it(t)):[]))}function it({entity:e,field:n,key:t}){return`${e}\0${t}\0${n}`}function Bo(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generatedSingletons:[]))}function Vo(e){return e==null?[]:e.expect.flatMap(n=>Ae(n))}function Ae(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(n=>Ae(n)):e.kind==="when"?e.branches.flatMap(n=>n.consequence.flatMap(t=>Ae(t))):[]}async function zo({aliases:e,config:n,generated:t,generatedSingletons:r,origin:o,records:i,rrwebEvents:s,runId:l,stepSources:p}){let d=i.map((c,u)=>Go({aliases:e,generated:t,generatedSingletons:r,origin:o,record:c,rrwebEvents:s,sourceTest:p?.[u]??null}));await m({config:n,document:ai,variables:{items:[{runId:l,steps:d}]}})}var Jo=3,Ko=0;function Qo({endMs:e,rrwebEvents:n,startMs:t}){let r=n.find(o=>o.type===Jo&&o.data?.source===Ko&&o.timestamp>=t&&o.timestamp<=e);return r==null?t:r.timestamp}function Go({aliases:e,generated:n,generatedSingletons:t,origin:r,record:o,rrwebEvents:i,sourceTest:s}){let l=qe(o.source,o.index),p=Qo({endMs:o.endMs,rrwebEvents:i,startMs:o.startMs}),d=o.annotations.map(u=>({kind:u.kind,label:u.label,outcome:u.outcome,recordingStartMs:Math.max(0,(u.kind==="action"?p:u.atMs)-r),rrwebIds:[...u.rrwebIds],url:u.url})),c=o.annotations.find(u=>u.kind==="action")?.rrwebIds??[];return{annotations:d,detail:null,duration:Math.max(0,o.endMs-o.startMs),findings:o.findings.map(u=>nt(u)),nodeType:l.kind,recordingEndMs:Math.max(0,o.endMs-r),recordingStartMs:Math.max(0,p-r),rrwebIds:[...c],snapshotTimestamp:Math.max(0,o.endMs-r),sourceTest:s,stateRows:o.state.rows.map(u=>Xo({aliases:e,generated:n,row:u})),stateSingletons:o.state.singletons.map(u=>({changed:u.changed,generated:t.has(u.name),name:u.name,value:u.value==null?null:String(u.value)})),status:o.findings.length>0?"failed":"passed",stepIndex:o.index,title:et(l),url:o.url}}function Xo({aliases:e,generated:n,row:t}){let r=e.find(o=>o.entity===t.entity&&o.key===t.key);return{entity:t.entity,fields:t.fields.map(o=>({changed:o.changed,field:o.field,generated:n.has(it({entity:t.entity,field:o.field,key:t.key})),value:o.value==null?null:String(o.value)})),key:t.key,label:r?.alias??t.key,status:t.status}}var Yo=Fo(To);async function at(e,n){await m({config:e,document:di,variables:{runIds:[n]}})}var Zo="application/x-ndjson";async function ei({config:e,debugDir:n,runId:t}){let r=ne.join(n,t,"behavior.jsonl");if(Te(r))try{let o=await m({config:e,document:ni,variables:{runId:t}}),i=await fetch(o.debugArtifactUploadUrl,{body:Fe(r),headers:{"content-type":Zo},method:"PUT"});if(!i.ok){g.warn({runId:t,status:i.status},"behavior upload PUT failed");return}await at(e,t)}catch(o){g.warn({error:o,runId:t},"behavior upload failed")}}var ni=b(`
|
|
125
|
-
mutation DebugArtifactUploadUrl($runId: String!) {
|
|
126
|
-
debugArtifactUploadUrl(runId: $runId)
|
|
127
|
-
}
|
|
128
|
-
`);async function ti(e,n,t){let r=t.events.map(s=>JSON.stringify(s)).join(`
|
|
129
|
-
`),o=await Yo(Buffer.from(r,"utf8")),i=t.events.at(-1);await m({config:e,document:si,variables:{input:{bodyBase64:o.toString("base64"),chunkIndex:0,endTimestamp:Math.max(0,(i?.timestamp??t.origin)-t.origin),eventCount:t.events.length,runId:n,startTimestamp:0}}})}async function ri(e,n,t){let r=t.filter(s=>s.findings.length>0).length,o=t.length-r,i=t.reduce((s,l)=>s+Math.max(0,l.endMs-l.startMs),0);await m({config:e,document:li,variables:{items:[{duration:i,failCount:r,passCount:o,runId:n,status:r>0?"failed":"passed",summary:null,warnCount:0}]}})}async function oi(e,n){return((await m({config:e,document:ii,variables:{runIds:[n]}})).startRunsBatch??[]).some(r=>r.id===n)}var ii=b(`
|
|
130
|
-
mutation StartRunsBatch($runIds: [String!]!) {
|
|
131
|
-
startRunsBatch(runIds: $runIds) {
|
|
132
|
-
id
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
`),ai=b(`
|
|
136
|
-
mutation SubmitRunStepsBatch($items: [SubmitRunStepsItem!]!) {
|
|
137
|
-
submitRunStepsBatch(items: $items)
|
|
138
|
-
}
|
|
139
|
-
`),si=b(`
|
|
140
|
-
mutation SubmitRunRecordingChunk($input: SubmitRunRecordingChunkInput!) {
|
|
141
|
-
submitRunRecordingChunk(input: $input)
|
|
142
|
-
}
|
|
143
|
-
`),li=b(`
|
|
144
|
-
mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
|
|
145
|
-
completeRunsBatch(items: $items) {
|
|
146
|
-
id
|
|
147
|
-
status
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
`),di=b(`
|
|
151
|
-
mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
|
|
152
|
-
markRunArtifactsUploadedBatch(runIds: $runIds)
|
|
153
|
-
}
|
|
154
|
-
`);async function $e({baseState:e,branchName:n,category:t,commitSha:r,config:o,debugDir:i,devSessionId:s,events:l,lockfileHash:p,reproJson:d,runId:c,signature:u,spec:y,stepSources:S}){await m({config:o,document:mi,variables:{branchName:n??null,commitSha:r??null,devSessionId:s??null,lockfileHash:p??null,projectId:o.projectId,reproJson:d,runId:c,spec:y??null}}),await te({config:o,debugDir:i,events:l,recordingOptional:!0,runId:c,stepSources:S}),await m({config:o,document:gi,variables:{baseState:e,category:t,projectId:o.projectId,reproRunId:c,signature:u}})}async function re(e,n,t){return(await m({config:e,document:yi,variables:{lockfileHash:t,projectId:e.projectId,signature:n}})).exploreFindingExists}async function ci({attempts:e,config:n,devSessionId:t,findings:r}){await m({config:n,document:fi,variables:{attempts:e,devSessionId:t,findings:r}})}async function ui(e,n,t){let r=await m({config:e,document:pi,variables:{devSessionId:n}}).catch(i=>(g.warn({error:i},"fetchScopedTestRefs failed"),null)),o=new Set(r?.exploreScope??[]);return o.size===0?new Set:new Set(t.workflows.filter(i=>o.has(h(i.name))).flatMap(i=>i.tests.map(s=>R(s))))}var pi=E(`
|
|
155
|
-
query ExploreScope($devSessionId: String!) {
|
|
156
|
-
exploreScope(devSessionId: $devSessionId)
|
|
157
|
-
}
|
|
158
|
-
`);var fi=E(`
|
|
159
|
-
mutation RecordExplorationProgress($devSessionId: String!, $attempts: Int!, $findings: Int!) {
|
|
160
|
-
recordExplorationProgress(devSessionId: $devSessionId, attempts: $attempts, findings: $findings)
|
|
161
|
-
}
|
|
162
|
-
`),ud=E(`
|
|
163
|
-
mutation ReportExploreUnhealthy($devSessionId: String!) {
|
|
164
|
-
reportExploreUnhealthy(devSessionId: $devSessionId)
|
|
165
|
-
}
|
|
166
|
-
`),mi=E(`
|
|
167
|
-
mutation CreateExploreRun(
|
|
168
|
-
$projectId: String!
|
|
169
|
-
$runId: String!
|
|
170
|
-
$devSessionId: String
|
|
171
|
-
$branchName: String
|
|
172
|
-
$commitSha: String
|
|
173
|
-
$lockfileHash: String
|
|
174
|
-
$spec: String
|
|
175
|
-
$reproJson: String
|
|
176
|
-
) {
|
|
177
|
-
createExploreRun(
|
|
178
|
-
projectId: $projectId
|
|
179
|
-
runId: $runId
|
|
180
|
-
devSessionId: $devSessionId
|
|
181
|
-
branchName: $branchName
|
|
182
|
-
commitSha: $commitSha
|
|
183
|
-
lockfileHash: $lockfileHash
|
|
184
|
-
spec: $spec
|
|
185
|
-
reproJson: $reproJson
|
|
186
|
-
) {
|
|
187
|
-
id
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
`),gi=E(`
|
|
191
|
-
mutation SubmitExploreFinding(
|
|
192
|
-
$projectId: String!
|
|
193
|
-
$signature: String!
|
|
194
|
-
$baseState: String!
|
|
195
|
-
$category: ExploreFindingCategory!
|
|
196
|
-
$reproRunId: String!
|
|
197
|
-
) {
|
|
198
|
-
submitExploreFinding(
|
|
199
|
-
projectId: $projectId
|
|
200
|
-
signature: $signature
|
|
201
|
-
baseState: $baseState
|
|
202
|
-
category: $category
|
|
203
|
-
reproRunId: $reproRunId
|
|
204
|
-
) {
|
|
205
|
-
id
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
`),pd=E(`
|
|
209
|
-
mutation SetExploreFindingStatus(
|
|
210
|
-
$projectId: String!
|
|
211
|
-
$signature: String!
|
|
212
|
-
$status: ExploreFindingStatus!
|
|
213
|
-
) {
|
|
214
|
-
setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
|
|
215
|
-
}
|
|
216
|
-
`),yi=E(`
|
|
217
|
-
query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
|
|
218
|
-
exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
|
|
219
|
-
}
|
|
220
|
-
`);import{graphql as st}from"gql.tada";async function hi(e,n,t){await m({config:e,document:Ri,variables:{reason:t,runId:n}}).catch(r=>{g.error(r,"failRun submission failed")})}var Ri=st(`
|
|
221
|
-
mutation FailRun($runId: String!, $reason: String!) {
|
|
222
|
-
failRun(runId: $runId, reason: $reason)
|
|
223
|
-
}
|
|
224
|
-
`),yd=st(`
|
|
225
|
-
mutation MarkRunUnready($runId: String!, $cause: RunUnreadyCause!) {
|
|
226
|
-
markRunUnready(runId: $runId, cause: $cause)
|
|
227
|
-
}
|
|
228
|
-
`);import{randomUUID as ki}from"crypto";async function Si({assign:e,config:n,debugDir:t,devSessionId:r,fixturesDir:o,headed:i,lockfile:s,report:l,session:p,signal:d}){let c=We(s);if(e.stepRuns.length===0)return{kind:"error",reason:"empty-trail"};let u=Pi(c,e.stepRuns),y=await ze({baseState:{name:R(e.baseStateTest),test:e.baseStateTest},corpus:c,lockfile:s,options:{baseUrl:n.appUrl,engineUrl:n.engineUrl,fixturesDir:o,generate:v,headed:i,secret:n.webhookSecret,tunnelAuth:n.tunnelAuth},seenSignature:l?x=>re(n,x,e.lockfileHash):void 0,session:p,stepRuns:e.stepRuns,runIdFor:x=>`explore-${ki()}-${String(x)}`},d),S=l?await Ei({baseStateTest:e.baseStateTest,config:n,debugDir:t,devSessionId:r,lockfileHash:e.lockfileHash,outcome:y,reproJson:wi(c,e),stepSources:bi(u)}):!1;return xi(y,u.length),Ci(y,S)}function lt(e){return e.engineMs+e.worldMs+e.browserMs+e.driveMs+e.teardownMs}function xi(e,n){if(e.kind==="error"){g.info({kind:e.kind,reason:e.error.kind,steps:n},"explore trail");return}if(e.kind==="aborted"){g.info({kind:e.kind,steps:n},"explore trail");return}let t=e.timing.detect,r=e.timing.confirm;g.info({browserMs:t.browserMs,confirmMs:r==null?void 0:lt(r),detectMs:lt(t),driveMs:t.driveMs,engineMs:t.engineMs,kind:e.kind,steps:n,teardownMs:t.teardownMs,worldMs:t.worldMs},"explore trail")}function wi(e,n){let t=n.stepRuns.flatMap(o=>{let i=e[o.idx];return i==null?[]:[{index:i.index,params:o.params,test:i.test}]}),r={baseStateRef:R(n.baseStateTest),steps:t};return JSON.stringify(r)}function bi(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(()=>t)})}async function Ei({baseStateTest:e,config:n,debugDir:t,devSessionId:r,lockfileHash:o,outcome:i,reproJson:s,stepSources:l}){return i.kind!=="finding"||i.captureEvents.length===0?!1:await re(n,i.signature,o)?(g.info({devSessionId:r,signature:i.signature},"explore finding already reported, skipping duplicate"),!1):(await $e({baseState:i.baseState,branchName:void 0,category:vi(i.verifierLayer),commitSha:void 0,config:n,debugDir:t,devSessionId:r,events:i.captureEvents,lockfileHash:o,reproJson:s,runId:i.runId,signature:i.signature,spec:Ii(e,i.captureEvents),stepSources:l}).catch(p=>{g.warn({error:p},"explore finding report failed")}),!0)}function vi(e){return e==="data-rule"?"dataRule":e==="page-rule"?"pageRule":e}function Ii(e,n){let t=n.flatMap(o=>o.kind==="step"?[o.source]:[]),r={absent:e.absent,exclusive:e.exclusive,intent:e.intent,maybe:[],name:e.name,params:e.params,singletons:e.singletons,steps:t,stub:!1,tests:[],world:e.world};return JSON.stringify(r)}function Pi(e,n){return n.flatMap(t=>{let r=e[t.idx];return r==null?[]:[{actions:[...r.nav,...r.steps].map(o=>Be(o.action)),label:`${r.test}#${String(r.index)}`}]})}function Ci(e,n){return e.kind==="error"?{kind:e.kind,reason:`runtime:${e.error.kind}`}:e.kind==="finding"?{kind:e.kind,runId:n?e.runId:void 0}:{kind:e.kind}}import ji from"path";import{randomUUID as Ai}from"crypto";async function Od({cwd:e,ref:n,signal:t,step:r}){let o=pn(e).match(c=>({config:c}),c=>({failure:c}));if("failure"in o)return{failure:o.failure,kind:"config-failed"};let i=o.config,s=await me(e);if(s.result.isErr())return{error:s.result.error,kind:"compile-failed"};let l=s.result.value,p=T(l).find(c=>c.ref===n);return p==null?{kind:"no-test",ref:n}:(await Ve({lockfile:l,options:{baseUrl:i.appUrl,engineUrl:i.engineUrl,fixturesDir:ji.join(i.cwd,$),generate:v,headed:!0,secret:i.webhookSecret,tunnelAuth:i.tunnelAuth},params:void 0,runId:`teleport-${Ai()}`,stopAfterStep:r,test:p.test},t)).match(c=>({kind:"done",result:c}),c=>({error:c,kind:"run-failed"}))}export{Li as a,Wi as b,B as c,ht as d,V as e,$ as f,C as g,me as h,U as i,j,ua as k,K as l,ya as m,ha as n,Ra as o,Ea as p,ge as q,sn as r,dn as s,pn as t,yn as u,Re as v,qa as w,ee as x,Qn as y,gl as z,yl as A,hl as B,ko as C,Pl as D,ys as E,hs as F,En as G,Rs as H,ks as I,Ss as J,xs as K,ws as L,In as M,Pn as N,Cn as O,jn as P,An as Q,Fl as R,$l as S,Ll as T,Ul as U,Nl as V,Ol as W,Dl as X,_l as Y,ql as Z,Hl as _,Wl as $,Bl as aa,Ba as ba,Va as ca,ke as da,za as ea,Rn as fa,ss as ga,we as ha,Jr as ia,sl as ja,$o as ka,ei as la,hi as ma,ci as na,ui as oa,Si as pa,Od as qa};
|
package/dist/daemon-EWT54KJZ.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{$ as Ee,A as oe,C as ce,E as de,S as Se,U as ke,V as ve,W as we,X as be,Y as xe,Z as he,_ as Pe,b as J,ba as P,ca as E,da as Re,e as V,ea as M,fa as Ce,h as v,ha as q,i as H,ia as Te,ja as Ie,l as _,ma as R,na as We,oa as Ae,q as Z,qa as Le,t as h,v as ee,w as re}from"./chunk-WJ7CHQ7B.js";import{A as ie,B as ae,C as se,L as le,Q as ue,R as pe,S as fe,T as me,U as ye,V as ge,b as K,e as X,f as D,i as Y,l as ne,x as te}from"./chunk-MJXQ6SVH.js";import{b as De}from"./chunk-RLXQYG7H.js";import{c as Q,d as k,e as l,f as L,g as G}from"./chunk-5VRJXHWH.js";import"./chunk-IHSHBPJY.js";import"./chunk-7UWDMECF.js";import To from"path";import{createClient as Io}from"graphql-sse";import Wo,{AbortError as Ao}from"p-retry";import{graphql as j}from"gql.tada";import{graphql as Cr}from"gql.tada";import{print as Tr}from"graphql";async function He({config:r,cwd:e,headed:o,pool:n,runId:t,signal:i,testSlug:a,workClass:s,workflowSlug:c}){let{fingerprint:u,result:d}=await v(e);if(d.isErr())return await R(r,t,`lockfile:${d.error.kind}`),{kind:"dispatch-error",reason:{detail:`lockfile:${d.error.kind}`,type:"generic"}};let m=Rr(d.value,{testSlug:a,workflowSlug:c});if(m==null)return await R(r,t,`no-test:${c}/${a}`),{kind:"dispatch-error",reason:{detail:`no-test:${c}/${a}`,type:"generic"}};let p=await P({headed:o,workClass:s,task:()=>n.execute({headed:o,lockfileFingerprint:u,runId:t,testRef:m},i)});return!p.serverNotified&&p.outcome.kind==="error"&&await R(r,t,p.outcome.detail),p.outcome}function Rr(r,{testSlug:e,workflowSlug:o}){let t=r.workflows.find(i=>Y(i.name)===o)?.tests.find(i=>i.slug===e);return t==null?void 0:ne(t)}var Ir=6e4,Wr=Cr(`
|
|
3
|
-
subscription RunRequestedWatch($devSessionId: String!) {
|
|
4
|
-
runRequested(devSessionId: $devSessionId) {
|
|
5
|
-
runId
|
|
6
|
-
testSlug
|
|
7
|
-
workflowId
|
|
8
|
-
workflowSlug
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
`);async function _e(r){let e=Math.min(1e3*2**r,Ir)+Dr();await new Promise(o=>setTimeout(o,e))}function Me({claim:r,cwd:e,devSessionId:o,onSubscriptionDead:n,pool:t,sseClient:i,sseHealth:a}){let s=new Set;return i.subscribe({query:Tr(Wr),variables:{devSessionId:o}},{complete:()=>{},error:c=>{let u=c instanceof Error?c.message:String(c);l.warn("runRequested SSE failed: %s; re-registering session",u),n(u)},next:c=>{Ar({claim:r,cwd:e,event:c.data?.runRequested,inFlightRunIds:s,pool:t})}},{connected:()=>{a.onConnected()},connecting:c=>{a.onConnecting(c),c&&l.debug("runRequested SSE reconnecting")}})}function Ar({claim:r,cwd:e,event:o,inFlightRunIds:n,pool:t}){if(o==null)return;if(n.has(o.runId)){l.warn({runId:o.runId,workflowSlug:o.workflowSlug},"duplicate runRequested event; skipping dispatch");return}n.add(o.runId),process.stdout.write(`ripplo: run ${o.workflowSlug}
|
|
12
|
-
`),J(e);let i=h(e).match(s=>s,s=>{l.error({failure:s,runId:o.runId},"failed to load env for run dispatch; skipping")});if(i==null){n.delete(o.runId);return}let a=Lr(r(o.runId),o);a.started(),He({config:i,cwd:e,headed:a.headed,pool:t,runId:o.runId,signal:a.signal,testSlug:o.testSlug,workClass:a.workClass,workflowSlug:o.workflowSlug}).then(s=>{a.finished(s)}).catch(s=>{l.error({err:s,runId:o.runId,workflowSlug:o.workflowSlug},"run execution failed; daemon continuing"),a.finished({detail:s instanceof Error?s.message:String(s),kind:"error"})}).finally(()=>{n.delete(o.runId)})}function Lr(r,e){return r==null?(l.debug({runId:e.runId,workflowSlug:e.workflowSlug},"dispatching unclaimed run (externally triggered or replayed)"),{headed:!1,signal:new AbortController().signal,workClass:"p0-ui",finished:()=>{},started:()=>{}}):{headed:r.headed,signal:Te(r.token),workClass:"p1-cli",finished:o=>{r.finished(e.runId,o)},started:()=>{r.started(e.runId)}}}function Dr(){return Math.floor(Math.random()*2700)+300}import{graphql as Hr}from"gql.tada";import{print as _r}from"graphql";var Mr=Hr(`
|
|
13
|
-
subscription TeleportRequestedWatch($devSessionId: String!) {
|
|
14
|
-
teleportRequested(devSessionId: $devSessionId) {
|
|
15
|
-
runId
|
|
16
|
-
stepIndex
|
|
17
|
-
testSlug
|
|
18
|
-
workflowSlug
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
`);function qe({cwd:r,devSessionId:e,onSubscriptionDead:o,sseClient:n}){let t=new Set,i=n.subscribe({query:_r(Mr),variables:{devSessionId:e}},{complete:()=>{},error:a=>{let s=a instanceof Error?a.message:String(a);l.warn("teleportRequested SSE failed: %s; re-registering session",s),o(s)},next:a=>{qr({cwd:r,event:a.data?.teleportRequested,running:t})}});return()=>{t.forEach(a=>{a.abort()}),t.clear(),i()}}function qr({cwd:r,event:e,running:o}){if(e==null)return;let n=`${e.workflowSlug}/${e.testSlug}`,t=new AbortController;o.add(t),process.stdout.write(`ripplo: teleport ${n} step ${String(e.stepIndex+1)}
|
|
22
|
-
`),Le({cwd:r,ref:n,signal:t.signal,step:e.stepIndex+1}).then(i=>{i.kind!=="done"&&l.warn({kind:i.kind,ref:n},"teleport could not open")}).catch(i=>{l.error({err:i,ref:n},"teleport failed; daemon continuing")}).finally(()=>{o.delete(t)})}function Oe(){let r=!0,e,o=null,n=()=>{o!=null&&(clearTimeout(o),o=null)};return{markUnhealthy:t=>{r=!1,e=t,n()},onConnected:()=>{n(),o=setTimeout(()=>{r=!0,e=void 0,o=null},1e4)},onConnecting:()=>{n()},snapshot:()=>({detail:e,ok:r})}}import Or from"fs";import $e from"net";import{err as je,ok as Fr}from"neverthrow";async function Be({cwd:r,onConnection:e}){G(r);let o=de(r),n=await Fe({onConnection:e,socketPath:o});return n.isOk()||n.error.kind!=="stale-candidate"?n.map(Ne(o)).mapErr(Ue(o)):await Nr(o)?je({kind:"already-running",socketPath:o}):(ze(o),(await Fe({onConnection:e,socketPath:o})).map(Ne(o)).mapErr(Ue(o)))}function Nr(r){return new Promise(e=>{let o=$e.connect(r);o.once("connect",()=>{o.destroy(),e(!0)}),o.once("error",()=>{e(!1)})})}async function Fe(r){let e=await Ur(r);return e.kind==="listening"?Fr(e.server):je(e.error)}function Ur({onConnection:r,socketPath:e}){return new Promise(o=>{let n=$e.createServer(r);n.once("error",t=>{o({error:t.code==="EADDRINUSE"?{kind:"stale-candidate"}:{kind:"listen-failed",message:t.message},kind:"failed"})}),n.listen(e,()=>{o({kind:"listening",server:n})})})}function Ne(r){return e=>({socketPath:r,close:()=>{e.close(),ze(r)}})}function ze(r){Or.rmSync(r,{force:!0})}function Ue(r){return e=>e.kind==="stale-candidate"?{kind:"already-running",socketPath:r}:{kind:"bind-failed",message:e.message}}import{randomInt as $r,randomUUID as jr}from"crypto";function Ve(r){let e={attempts:0,consecutiveErrors:0,findings:0,haltedUntil:0,lockfile:null,prepared:null,preparing:!1,refreshing:!1,scopedAt:0,scopedTests:new Set,scoping:!1,windowAttempts:0,windowFindings:0,windowStartMs:Date.now()},o=O(r,e);return{priority:"p3",next:()=>Vr(r,e),onResult:()=>{},ready:()=>o,status:()=>({attempts:e.attempts,findings:e.findings}),stop:()=>Promise.resolve()}}var Br=10;async function O(r,e){if(!e.preparing){e.preparing=!0;try{let o=await r.loadLockfile(),n=o==null?null:await zr(o);if(n==null||o==null)return;e.lockfile=o.lockfile,e.scopedAt=0,e.prepared=n,e.consecutiveErrors=0,e.haltedUntil=0,r.notifyWork()}finally{e.preparing=!1}}}async function zr({fingerprint:r,lockfile:e}){let o=await ae(e);return o==null?null:{exploration:o,fingerprint:r,lockfileHashValue:D(e),strategy:te("even")}}var Qe=20,Ge=3e5;async function Qr(r,e){if(!(e.refreshing||e.preparing||e.prepared==null)){e.refreshing=!0;try{let o=await r.loadLockfile();if(o==null||D(o.lockfile)===e.prepared.lockfileHashValue)return;l.info("workflow definitions changed, re-preparing exploration"),e.prepared=null,await O(r,e)}finally{e.refreshing=!1}}}var Gr=15e3;async function Jr(r,e){if(!(e.scoping||e.lockfile==null||Date.now()-e.scopedAt<Gr)){e.scoping=!0;try{e.scopedTests=await r.scopedTestRefs(e.lockfile),e.scopedAt=Date.now()}finally{e.scoping=!1}}}function Vr(r,e){Qr(r,e),Jr(r,e);let o=e.prepared;if(o==null||Date.now()<e.haltedUntil)return null;let n=se({lockfileFingerprint:o.fingerprint,lockfileHash:o.lockfileHashValue,prepared:o.exploration,random:Kr,scopedTests:e.scopedTests,strategy:{...o.strategy,maxAttemptLength:r.maxTrailLength()}});if(n==null)return null;let t=n.baseStateTest.name;return{id:`explore:${jr()}`,label:t,run:i=>Xr({assign:n,params:r,signal:i,state:e})}}var Je=2**31;function Kr(){return $r(Je)/Je}async function Xr({assign:r,params:e,signal:o,state:n}){if(!await e.probeApp()){Ke(n,"app-unreachable");return}let t=await e.executeTrail(r,o);if(t.kind==="aborted")return;if(t.kind==="error"){Zr({params:e,reason:t.reason,state:n});return}n.consecutiveErrors=0,n.attempts+=1,n.windowAttempts+=1;let i=t.kind==="finding";i&&(n.findings+=1,n.windowFindings+=1,l.info("exploration finding recorded")),e.reportProgress({attempts:1,findings:i?1:0}),n.windowAttempts>=Br&&Yr(n)}function Yr(r){let e=Date.now()-r.windowStartMs;l.info({attempts:r.windowAttempts,avgTrailMs:Math.round(e/r.windowAttempts),findings:r.windowFindings,windowMs:e,yield:Number((r.windowFindings/r.windowAttempts).toFixed(3))},"explore window"),r.windowAttempts=0,r.windowFindings=0,r.windowStartMs=Date.now()}function Zr({params:r,reason:e,state:o}){if(e==="lockfile:fingerprint-mismatch"){eo(r,o);return}Ke(o,e)}function eo(r,e){e.preparing||(e.prepared=null,O(r,e))}function Ke(r,e){r.consecutiveErrors+=1,l.debug("exploration trail error: %s",e),r.consecutiveErrors>=Qe&&(r.haltedUntil=Date.now()+Ge,r.consecutiveErrors=0,l.warn("exploration cooling down for %ds after %d consecutive trail errors (last: %s)",Ge/1e3,Qe,e))}function ro(r){let{backoffActive:e,exploreEnabled:o,headedActive:n,interactiveActive:t,interactiveQueued:i}=r,{explorationActive:a,exploreConcurrency:s,poolSize:c}=r;if(!o||n||i>0)return{abortCount:a,refillCount:0};if(e)return{abortCount:0,refillCount:0};let u=Math.min(s,c-1,c-t);return{abortCount:0,refillCount:Math.max(0,u-a)}}function Ze(r){let e={active:new Map,backoffUntil:0,cancelBackoffTimer:null,cancelHeartbeat:null,prevInteractiveActive:r.probe().interactiveActive,stopped:!1};return er(e,r),{explorationActive:()=>e.active.size,notifyQueueChange:()=>{oo(e,r)},stop:()=>{e.stopped=!0,e.cancelBackoffTimer?.(),e.cancelBackoffTimer=null,e.cancelHeartbeat?.(),e.cancelHeartbeat=null,rr(e,e.active.size)}}}function er(r,e){r.stopped||(r.cancelHeartbeat=e.setTimer(()=>{C(r,e),er(r,e)},15e3))}function C(r,e){if(r.stopped)return;let o=e.probe(),n=ro({backoffActive:e.now()<r.backoffUntil,explorationActive:r.active.size,exploreConcurrency:e.exploreConcurrency(),exploreEnabled:e.exploreEnabled(),headedActive:o.headedActive>0,interactiveActive:o.interactiveActive,interactiveQueued:o.interactiveQueued,poolSize:o.poolSize});rr(r,n.abortCount),or({count:n.refillCount,params:e,state:r})}function rr(r,e){[...r.active.values()].slice(0,e).forEach(({controller:o})=>{o.abort()})}function oo(r,e){let o=e.probe();o.interactiveActive<r.prevInteractiveActive&&no(r,e),r.prevInteractiveActive=o.interactiveActive,C(r,e)}function no(r,e){r.backoffUntil=e.now()+3e4,r.cancelBackoffTimer?.(),r.cancelBackoffTimer=e.setTimer(()=>{r.cancelBackoffTimer=null,C(r,e)},3e4)}function or({count:r,params:e,state:o}){if(r<=0)return;let n=to(e.sources);n!=null&&(io({params:e,pulled:n,state:o}),or({count:r-1,params:e,state:o}))}function to(r){return r.reduce((e,o)=>{if(e!=null)return e;let n=o.next();return n==null?null:{job:n,source:o}},null)}function io({params:r,pulled:e,state:o}){let{job:n,source:t}=e,i=new AbortController;o.active.set(n.id,{controller:i,job:n,source:t}),r.execute({job:n,priority:t.priority,signal:i.signal}).then(()=>{Ye({job:n,outcome:Xe(i.signal,null),params:r,source:t,state:o})}).catch(a=>{Ye({job:n,outcome:Xe(i.signal,{error:a}),params:r,source:t,state:o})})}function Xe(r,e){return r.aborted?{kind:"aborted"}:e==null?{kind:"completed"}:{error:e.error,kind:"error"}}function Ye({job:r,outcome:e,params:o,source:n,state:t}){t.active.delete(r.id),n.onResult(r,e),C(t,o)}function F(r){return{priority:r,next:()=>null,onResult:()=>{}}}var so=12;function nr({config:r,executor:e,pool:o}){return lo({appUrl:r.appUrl,cwd:r.cwd,localExecutor:e==="local",executeTrail:async(n,t)=>(await o).exploreTrail(n,t)})}function lo({appUrl:r,cwd:e,executeTrail:o,localExecutor:n}){let t={concurrency:2,enabled:!1,maxTrailLength:so},i={notify:()=>{}},a={report:d=>{}},s={fetch:d=>Promise.resolve(new Set)},c=co({appUrl:r,cwd:e,executeTrail:o,maxTrailLength:()=>t.maxTrailLength,notifyWork:()=>{i.notify()},reportProgress:d=>{a.report(d)},scopedTestRefs:d=>s.fetch(d)}),u=Ze({now:Date.now,probe:uo,setTimer:po,sources:[F("p0"),F("p1"),c],execute:({job:d,priority:m,signal:p})=>P({headed:!1,workClass:fo(m),task:()=>d.run(p)}),exploreConcurrency:()=>t.concurrency,exploreEnabled:()=>t.enabled});return M(()=>{u.notifyQueueChange()}),i.notify=()=>{u.notifyQueueChange()},{progress:()=>c.status(),setConcurrency:d=>{n&&d!==t.concurrency&&l.info({workers:d},"explore local worker count changed"),t.concurrency=d,u.notifyQueueChange()},setEnabled:d=>{t.enabled=d&&n,u.notifyQueueChange()},setMaxTrailLength:d=>{t.maxTrailLength=d},setReportProgress:d=>{a.report=d},setScopedTestRefs:d=>{s.fetch=d},status:()=>({explorer:t.enabled?"on":"off",exploring:u.explorationActive(),progress:c.status()}),stop:()=>{u.stop(),M(null),c.stop()}}}function co({appUrl:r,cwd:e,executeTrail:o,maxTrailLength:n,notifyWork:t,reportProgress:i,scopedTestRefs:a}){return Ve({cwd:e,executeTrail:o,maxTrailLength:n,notifyWork:t,reportProgress:i,scopedTestRefs:a,loadLockfile:async()=>{let{fingerprint:s,result:c}=await v(e);return c.match(u=>({fingerprint:s,lockfile:u}),()=>null)},probeApp:async()=>await oe(r)==null})}function uo(){let r=Re();return{headedActive:r.headedActive,interactiveActive:r.active,interactiveQueued:r.queued,poolSize:r.poolSize}}function po(r,e){let o=setTimeout(r,e);return()=>{clearTimeout(o)}}function fo(r){switch(r){case"p0":return"p0-ui";case"p1":return"p1-cli";case"p2":return"p2-cover";case"p3":return"p3-explore"}}import{fork as mo}from"child_process";import tr from"os";import{CancellationTokenSource as ir,ResponseError as ar}from"vscode-jsonrpc/node";function sr(r,e){return()=>{let o=mo(r,["run-worker"],{cwd:e,detached:!0,stdio:["ignore","inherit","inherit","ipc"]});return{connection:Ee(o),kill:()=>{yo(o)},onExit:n=>{o.once("exit",n)}}}}function lr(r){let e={closed:!1,lockfileProvider:r.lockfileProvider,nextId:0,size:r.initialSize,spawn:r.spawn,waiters:[],workers:[]};return{close:async()=>{e.closed=!0,await Promise.all([...e.workers].map(o=>N(o,e)))},execute:(o,n)=>So(o,n,e),exploreTrail:(o,n)=>wo(o,n,e),routeSpan:(o,n)=>{let t=e.workers.find(i=>i.runId===o);t?.worker.connection.sendNotification(he,{runId:o,span:n})},setSize:o=>{xo(o,e)}}}function yo(r){let e=r.pid;if(e!=null)try{process.kill(-e,"SIGKILL")}catch{r.kill("SIGKILL")}}var go=1e4,cr=-32800;async function So(r,e,o){let n=await dr(o);if(n.runId=r.runId,!n.alive)return T(n,o),{outcome:{detail:"worker-exit",kind:"error"},serverNotified:!1};let t=new ir,i=()=>{t.cancel()};e.aborted&&t.cancel(),e.addEventListener("abort",i,{once:!0});try{let a=await n.worker.connection.sendRequest(we,r,t.token),s=ke.safeParse(a);return s.success?s.data:{outcome:{detail:"bad-outcome-frame",kind:"error"},serverNotified:!1}}catch(a){return vo(a,n)}finally{e.removeEventListener("abort",i),t.dispose(),T(n,o)}}async function dr(r){let e=r.workers.find(o=>o.alive&&o.runId===void 0);if(e!=null)return e.runId="pending",e;if(r.workers.length<r.size){let o=ko(r);return o.runId="pending",await o.ready,o}return new Promise(o=>{r.waiters.push(n=>{n.runId="pending",o(n)})})}function ko(r){let e=r.spawn(),o={resolve:()=>{}},n={alive:!0,id:r.nextId,ready:new Promise(t=>{o.resolve=t,e.connection.onNotification(ve,t)}),runId:void 0,worker:e};return r.nextId+=1,e.connection.onRequest(be,async t=>{let i=Se.safeParse(t);return i.success?r.lockfileProvider(i.data.fingerprint):{unavailable:"bad-lockfile-request"}}),e.onExit(()=>{n.alive=!1,r.workers=r.workers.filter(t=>t!==n),e.connection.dispose(),o.resolve()}),r.workers.push(n),n}function T(r,e){if(r.runId=void 0,!r.alive||e.closed)return;if(e.workers.length>e.size){N(r,e);return}let o=e.waiters.shift();o?.(r)}async function N(r,e){if(e.workers=e.workers.filter(t=>t!==r),!r.alive)return;let o=new Promise(t=>{r.worker.onExit(t)});await r.worker.connection.sendNotification(Pe).catch(()=>{});let n=setTimeout(()=>{r.worker.kill()},go);await o,clearTimeout(n)}function vo(r,e){return r instanceof ar&&r.code===cr?{outcome:{detail:"aborted",kind:"error"},serverNotified:!1}:e.alive?{outcome:{detail:r instanceof Error?r.message:String(r),kind:"error"},serverNotified:!1}:{outcome:{detail:"worker-exit",kind:"error"},serverNotified:!1}}async function wo(r,e,o){let n=await dr(o);if(n.runId="explore",!n.alive)return T(n,o),{kind:"error"};let t=new ir,i=()=>{t.cancel()};e.aborted&&t.cancel(),e.addEventListener("abort",i,{once:!0});try{let a=await n.worker.connection.sendRequest(xe,r,t.token),s=ie.safeParse(a);return s.success?s.data:{kind:"error"}}catch(a){return bo(a)}finally{e.removeEventListener("abort",i),t.dispose(),T(n,o)}}function bo(r){return r instanceof ar&&r.code===cr?{kind:"aborted"}:{kind:"error",reason:`transport:${r instanceof Error?r.message.slice(0,120):"unknown"}`}}function xo(r,e){e.size=r,r>tr.availableParallelism()&&l.warn({cores:tr.availableParallelism(),size:r},"worker pool size exceeds available cores");let o=e.workers.filter(t=>t.alive&&t.runId===void 0),n=e.workers.length-r;o.slice(0,Math.max(0,n)).forEach(t=>{N(t,e)})}import I from"fs";import{graphql as W}from"gql.tada";import{print as U}from"graphql";var ho=W(`
|
|
23
|
-
query DaemonExploration($devSessionId: String!) {
|
|
24
|
-
exploration(devSessionId: $devSessionId) {
|
|
25
|
-
active
|
|
26
|
-
localWorkers
|
|
27
|
-
maxTrailLength
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
`),Po=W(`
|
|
31
|
-
subscription WatchExplorationChanged($devSessionId: String!) {
|
|
32
|
-
explorationChanged(devSessionId: $devSessionId) {
|
|
33
|
-
exploration {
|
|
34
|
-
active
|
|
35
|
-
localWorkers
|
|
36
|
-
maxTrailLength
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
`);function ur({config:r,devSessionId:e,machinery:o,sseClient:n}){return Eo({config:r,devSessionId:e,machinery:o}),n.subscribe({query:U(Po),variables:{devSessionId:e}},{complete:()=>{},error:t=>{l.error(t,"exploration subscription error")},next:t=>{pr(o,t.data?.explorationChanged.exploration)}})}async function Eo({config:r,devSessionId:e,machinery:o}){let n=await k({config:r,document:ho,variables:{devSessionId:e}});pr(o,n.exploration)}function pr(r,e){e!=null&&(r.setMaxTrailLength(e.maxTrailLength),r.setConcurrency(e.localWorkers),r.setEnabled(e.active))}function fr({config:r,devSessionId:e,machinery:o}){o.setScopedTestRefs(n=>Ae(r,e,n)),o.setReportProgress(n=>{We({attempts:n.attempts,config:r,devSessionId:e,findings:n.findings}).catch(t=>{l.warn({error:t},"exploration progress report failed")})})}var Ro=W(`
|
|
41
|
-
subscription HooksPausedWatch($projectId: String!) {
|
|
42
|
-
hooksPausedRequested(projectId: $projectId) {
|
|
43
|
-
paused
|
|
44
|
-
projectId
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
`),Co=W(`
|
|
48
|
-
subscription WatchLocalConcurrencyChanged {
|
|
49
|
-
myMaxLocalConcurrentRunsChanged
|
|
50
|
-
}
|
|
51
|
-
`);function mr({pool:r,sseClient:e}){return e.subscribe({query:U(Co)},{complete:()=>{},error:o=>{l.error(o,"localConcurrency subscription error")},next:o=>{let n=o.data?.myMaxLocalConcurrentRunsChanged;n!=null&&(E(n),r.setSize(n))}})}function yr({cwd:r,projectId:e,sseClient:o}){return o.subscribe({query:U(Ro),variables:{projectId:e}},{complete:()=>{},error:n=>{l.error(n,"hooksPaused subscription error")},next:n=>{let t=n.data?.hooksPausedRequested?.paused;t!=null&&$({cwd:r,paused:t})}})}function $({cwd:r,paused:e}){let o=ce(r);if(e&&!I.existsSync(o)){I.writeFileSync(o,"");return}!e&&I.existsSync(o)&&I.unlinkSync(o)}var Lo=6e4,gr=500,Do=15e3,Sr=6e4,Ho=3,_o=j(`
|
|
52
|
-
mutation HeartbeatDevSessionWatch($id: String!) {
|
|
53
|
-
heartbeatDevSession(id: $id) {
|
|
54
|
-
__typename
|
|
55
|
-
... on DevSession {
|
|
56
|
-
id
|
|
57
|
-
}
|
|
58
|
-
... on DevSessionEndedError {
|
|
59
|
-
message
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
`),Mo=j(`
|
|
64
|
-
query WatchLocalConcurrency {
|
|
65
|
-
currentUser {
|
|
66
|
-
id
|
|
67
|
-
maxLocalConcurrentRuns
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
`),qo=j(`
|
|
71
|
-
mutation EndDevSessionWatch($projectId: String!, $cwd: String!) {
|
|
72
|
-
endDevSession(projectId: $projectId, cwd: $cwd) {
|
|
73
|
-
__typename
|
|
74
|
-
... on DevSession {
|
|
75
|
-
id
|
|
76
|
-
}
|
|
77
|
-
... on NoActiveDevSessionError {
|
|
78
|
-
message
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
`);async function Dt(r){let{executor:e}=r;rn();let o=Xo(process.cwd()),n=o.cwd,t=Qo(n),i=Ko(),a=nr({config:o,executor:e,pool:i.pool}),s={handler:()=>{}},c=Jo(),u=Oe(),d=Ie({config:o,cwd:n,executor:e,explorationStatus:a.status,ready:c.promise,onShutdownRequest:()=>{s.handler()},sseHealth:()=>u.snapshot()}),m=await Vo({cwd:n,ipc:d,releasePid:t}),p=await H(n);p.isErr()&&(process.stderr.write(`ripplo: ${_(p.error)}
|
|
83
|
-
`),process.exit(1));let w=p.value,S=await kr(()=>q({config:o,cwd:n,lockfile:w}),{config:o,label:"initial sync"}),x=await nn(o);$({cwd:n,paused:S.hooksPaused});let f=Ce(n);f!=null&&l.info("watching branch %s in %s",f,n);let y=Io({headers:{Authorization:`Bearer ${o.token}`},retry:_e,retryAttempts:1/0,url:`${o.ripploServerUrl}/graphql`}),g=zo({cwd:n,initialConcurrency:x});i.provide(g);let A=await No({cwd:n,pool:g}),B=jo({claim:d.claim,config:o,cwd:n,initialId:S.devSessionId,pool:g,sseClient:y,sseHealth:u}),vr=yr({cwd:n,projectId:o.projectId,sseClient:y}),wr=mr({pool:g,sseClient:y}),br=ur({config:o,devSessionId:S.devSessionId,machinery:a,sseClient:y});fr({config:o,devSessionId:S.devSessionId,machinery:a});let xr=$o({config:o,session:B}),hr=en(),z=await Oo({config:o,devSessionId:S.devSessionId,executor:e});c.resolve(),Uo({devSessionId:S.devSessionId,executor:e,tunnel:z});let Pr=async()=>{xr(),hr(),a.stop(),m.close(),B.stop(),vr(),wr(),br(),await g.close(),await Fo(z),await A.stop().catch(()=>{}),await Promise.race([k({config:o,document:qo,variables:{cwd:o.cwd,projectId:o.projectId}}).catch(()=>{}),new Promise(Er=>setTimeout(Er,3e3))]),t()},b=()=>{Pr().finally(()=>process.exit(0))};s.handler=b,process.on("SIGINT",b),process.on("SIGTERM",b),process.on("SIGHUP",b),process.on("SIGBREAK",b),await new Promise(()=>{})}async function Oo({config:r,devSessionId:e,executor:o}){if(o==="cloud")return De({config:r,devSessionId:e})}async function Fo(r){r!=null&&await r.stop()}function No({cwd:r,pool:e}){return le({localDir:To.join(r,".ripplo",".local"),writePortFile:!0,onRrwebBatch:()=>{},onSpan:o=>{let n=o.attributes["ripplo.run"];n!=null&&e.routeSpan(n,o)}})}function Uo({devSessionId:r,executor:e,tunnel:o}){process.stdout.write(`${me({devSessionId:r,executor:e,tunnelHostname:o?.hostname,version:V()})}
|
|
84
|
-
`)}function $o({config:r,session:e}){let o=async()=>{try{let t=await k({config:r,document:_o,variables:{id:e.getId()}});t.heartbeatDevSession?.__typename==="DevSessionEndedError"&&(l.warn("dev session ended server-side (%s); re-registering",t.heartbeatDevSession.message),await e.reregister())}catch(t){l.warn("heartbeat failed: %s",t instanceof Error?t.message:String(t))}},n=setInterval(()=>{o()},Do);return()=>{clearInterval(n)}}function jo({claim:r,config:e,cwd:o,initialId:n,pool:t,sseClient:i,sseHealth:a}){let s=n,c=null,u=0,d=0,m=f=>{x(f)},p=()=>{let f=Me({claim:r,cwd:o,devSessionId:s,onSubscriptionDead:m,pool:t,sseClient:i,sseHealth:a}),y=qe({cwd:o,devSessionId:s,onSubscriptionDead:m,sseClient:i});return()=>{f(),y()}},w=p(),S=async f=>{let y=Date.now();u=y-d>Sr*2?1:u+1,d=y,u>=Ho&&a.markUnhealthy(f),await Bo(Math.min(1e3*2**(u-1),Sr));let g=await H(o);if(g.isErr()){l.error("re-register: compile failed: %s",_(g.error));return}let A=await kr(()=>q({config:e,cwd:o,lockfile:g.value}),{config:e,label:"re-register sync"});w(),s=A.devSessionId,w=p(),l.info("re-registered dev session as %s",s)},x=f=>(c!=null||(c=S(f).finally(()=>{c=null})),c);return{getId:()=>s,reregister:()=>x("dev session ended server-side"),stop:()=>{w()}}}function Bo(r){return new Promise(e=>setTimeout(e,r))}function zo({cwd:r,initialConcurrency:e}){return lr({initialSize:e,spawn:sr(tn(),r),lockfileProvider:async o=>{let n=await v(r);return n.result.isErr()?{unavailable:`daemon-load-failed:${n.result.error.kind}`}:n.fingerprint!==o?{unavailable:"fingerprint-mismatch"}:{lockfileJson:K(X,n.result.value)}}})}function Qo(r){try{return re({cwd:r,onCompromised:Go})}catch(e){throw e instanceof ee&&(process.stderr.write(`${ye({cwd:e.cwd,pid:e.pid})}
|
|
85
|
-
`),process.exit(1)),e}}function Go(){l.error("daemon lock compromised; shutting down"),process.stderr.write(`${ge()}
|
|
86
|
-
`),process.exit(1)}function Jo(){let r={handler:()=>{}};return{promise:new Promise(o=>{r.handler=o}),resolve:()=>{r.handler()}}}async function Vo({cwd:r,ipc:e,releasePid:o}){return(await Be({cwd:r,onConnection:e.handleConnection})).match(t=>t,t=>{process.stderr.write(`${ue(t)}
|
|
87
|
-
`),o(),process.exit(1)})}function Ko(){let r={provide:()=>{}};return{pool:new Promise(o=>{r.provide=o}),provide:o=>{r.provide(o)}}}function Xo(r){return h(r).match(e=>e,e=>{process.stderr.write(`${Z(e)}
|
|
88
|
-
`),process.exit(1)})}function kr(r,{config:e,label:o}){let n=e.ripploServerUrl.includes("localhost")||e.ripploServerUrl.includes("127.0.0.1");return Wo(async()=>{try{return await r()}catch(t){Yo({config:e,error:t});let i=t instanceof Error?t.message:String(t);throw Zo(i)?t:(l.error("%s failed: %s",o,i),new Ao(i))}},{factor:2,maxTimeout:n?2e3:1e4,minTimeout:n?100:1e3,retries:1/0,onFailedAttempt:({attemptNumber:t,error:i})=>{l.warn("%s attempt %d failed \u2014 retrying: %s",o,t,i.message)}})}function Yo({config:r,error:e}){let o=Q(e);o==="UNAUTHENTICATED"&&(process.stderr.write(`ripplo: ${fe()}
|
|
89
|
-
`),process.exit(1)),o==="FORBIDDEN"&&(process.stderr.write(`ripplo: ${pe({projectId:r.projectId,serverUrl:r.ripploServerUrl})}
|
|
90
|
-
`),process.exit(1))}function Zo(r){return r.includes("status 502")||r.includes("ECONNREFUSED")||r.includes("Failed to connect")||r.includes("fetch failed")}function en(){L({maxRuns:gr});let r=setInterval(()=>{L({maxRuns:gr})},Lo);return()=>{clearInterval(r)}}function rn(){process.on("unhandledRejection",r=>{l.error({err:r},"unhandledRejection in watch; continuing")}),process.on("uncaughtException",r=>{l.error({err:r},"uncaughtException in watch; continuing")})}var on=4;async function nn(r){try{let o=(await k({config:r,document:Mo,variables:void 0})).currentUser?.maxLocalConcurrentRuns;if(o!=null)return E(o),o}catch(e){l.warn({err:e},"failed to fetch local concurrency setting; using default")}return on}function tn(){let r=process.argv[1];if(r==null)throw new Error("cli entry unavailable");return r}export{Dt as runDaemon};
|
package/dist/daemon-PU4XNBMZ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{P as a,Q as b,R as c,S as d,T as e,U as f,V as g,W as h,X as i,Y as j,Z as k}from"./chunk-MJXQ6SVH.js";import"./chunk-IHSHBPJY.js";import"./chunk-7UWDMECF.js";export{b as renderDaemonBindError,g as renderDaemonLockCompromised,f as renderDaemonLockHeld,e as renderDaemonReady,h as renderDaemonStatus,j as renderDaemonVersionNote,i as renderExplorationProgress,d as renderNotSignedIn,c as renderProjectAccessDenied,a as renderTunnelProvisionFailed,k as wireOutcome};
|