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