ripplo 0.15.1 → 0.15.2
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-XPOOWIRL.js → chunk-3BPQWAUL.js} +1 -1
- package/dist/{chunk-BTIQ5H3K.js → chunk-5RKZ44OU.js} +1 -1
- package/dist/{chunk-IRT6UHD3.js → chunk-BFAWQ5U2.js} +1 -1
- package/dist/chunk-BIB4JJKD.js +84 -0
- package/dist/chunk-HN55QF5N.js +405 -0
- package/dist/{chunk-ANAQCK5G.js → chunk-JQ2CRYVX.js} +1 -1
- package/dist/{chunk-QQ6VKZ6A.js → chunk-LCCJPRT5.js} +1 -1
- package/dist/{chunk-O4A5UISQ.js → chunk-Q2TF5WLS.js} +1 -1
- package/dist/{chunk-NUBMOTH6.js → chunk-QEE4CNMY.js} +1 -1
- package/dist/{chunk-5JXP37ET.js → chunk-RLB66SU3.js} +1 -1
- package/dist/{chunk-KL6TIUNF.js → chunk-TZPYILZK.js} +1 -1
- package/dist/{chunk-RXLDAR2J.js → chunk-VHFITVRX.js} +1 -1
- package/dist/{chunk-JPXTGKSB.js → chunk-W3CXPVVB.js} +2 -2
- package/dist/{chunk-EYILCSW6.js → chunk-WB3HHOCG.js} +1 -1
- package/dist/{chunk-QSKOYBDO.js → chunk-XA6BMQTW.js} +1 -1
- package/dist/{chunk-AUXGLJ3J.js → chunk-Y52M43LO.js} +1 -1
- package/dist/{chunk-EVEITUJH.js → chunk-YD4VBOBY.js} +1 -1
- package/dist/{chunk-5PICILBD.js → chunk-YRU6BOIP.js} +1 -1
- package/dist/{chunk-KOZTQJBB.js → chunk-ZSD6QDYB.js} +18 -18
- package/dist/{cli-error-7LCAN3Z5.js → cli-error-UYWIDE4L.js} +1 -1
- package/dist/{compile-write-Y5III4OM.js → compile-write-QNV2EA5B.js} +1 -1
- package/dist/daemon-D4UCHMHS.js +175 -0
- package/dist/{daemon-EITBDEP7.js → daemon-LZTY7W4M.js} +1 -1
- package/dist/{dsl-loader-ASNZDV7E.js → dsl-loader-G2CRA252.js} +1 -1
- package/dist/hook.js +1 -1
- package/dist/index.js +213 -192
- package/dist/{plan-reminder-6VWOS6HD.js → plan-reminder-EDDIUY43.js} +1 -1
- package/dist/{post-edit-A5Y26UH5.js → post-edit-4CM5P2G2.js} +1 -1
- package/dist/post-edit-analyze-HKOTNA2H.js +4 -0
- package/dist/{post-edit-flag-stubs-I43B5QPO.js → post-edit-flag-stubs-2HZMK4NQ.js} +1 -1
- package/dist/{pre-edit-HJVNM7U5.js → pre-edit-JZX36QX6.js} +1 -1
- package/dist/{pre-edit-watch-gate-G6BVWIDL.js → pre-edit-watch-gate-T2TWL66C.js} +1 -1
- package/dist/{prompt-submit-OXYVNXHK.js → prompt-submit-GVZHK3CI.js} +1 -1
- package/dist/status-CNSPYNYP.js +4 -0
- package/dist/{stop-enforce-BP6IIW3D.js → stop-enforce-NKKP2X4U.js} +1 -1
- package/package.json +4 -3
- package/dist/chunk-F4UCCW7Q.js +0 -83
- package/dist/chunk-IVW5DUE4.js +0 -360
- package/dist/daemon-6UYMYGPI.js +0 -175
- package/dist/post-edit-analyze-2SBNWX6Y.js +0 -4
- package/dist/status-XUIBJXNP.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{a,b,c}from"./chunk-
|
|
4
|
+
import{a,b,c}from"./chunk-WB3HHOCG.js";import"./chunk-VHFITVRX.js";import"./chunk-MHNGR6M7.js";import"./chunk-RLB66SU3.js";import"./chunk-ZSD6QDYB.js";import"./chunk-KMZ3L5YA.js";export{b as renderCliFailure,c as renderHookCrash,a as renderTopLevelError};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{h as a,i as b,j as c,k as d,l as e,m as f}from"./chunk-
|
|
4
|
+
import{h as a,i as b,j as c,k as d,l as e,m as f}from"./chunk-5RKZ44OU.js";import"./chunk-BIB4JJKD.js";import"./chunk-RLB66SU3.js";import"./chunk-ZSD6QDYB.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as compileAndWrite,f as lockfileModelStatus,c as stampedLockfile,d as stampedLockfileFromDisk,e as stubbedWorkflows,b as writeStampedLockfile};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{A as er,B as rr,C as nr,E as or,F as q,J as tr,K as ir,L as ar,M as sr,O as lr,P as dr,R as K,S as H,T as cr,U as ur,V as Q,b as Oe,g as We,k as Ge,l as Ne,m as ze,n as Be,o as Ke,q as Qe,r as Je,s as Ve,t as Xe,u as Ye,w as A,x as L,y as Ze,z as B}from"./chunk-HN55QF5N.js";import{a as Me,b as $e,c as Ue,d as Fe,e as je,g as _e}from"./chunk-Q2TF5WLS.js";import{d as qe}from"./chunk-JQ2CRYVX.js";import{b as He}from"./chunk-WB3HHOCG.js";import{a as De,c as Ae,d as Le,e as h}from"./chunk-BFAWQ5U2.js";import{a as D}from"./chunk-VHFITVRX.js";import{c as m}from"./chunk-JS3DLVVI.js";import{a as se}from"./chunk-R4ZTRVDQ.js";import{c as ae}from"./chunk-FEHVIHVA.js";import"./chunk-MHNGR6M7.js";import{j as Ce,k as C}from"./chunk-5RKZ44OU.js";import{H as ve,J as we,K as xe,N as T,O as be,P as Re,S as Pe,T as Ee,Y as Ie,ba as Te,n as ke}from"./chunk-BIB4JJKD.js";import{k as S,l as he,m as I}from"./chunk-RLB66SU3.js";import{Ma as Se,U as ye,sa as ge}from"./chunk-ZSD6QDYB.js";import{e as me}from"./chunk-KH4QH23U.js";import{e as pe,f as fe}from"./chunk-RIASQHPG.js";import{a as le,c as de,d as p,f as s,g as ce,h as z,i as ue}from"./chunk-C7SV6AR2.js";import"./chunk-HEOMRXZE.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import{randomUUID as Ft}from"crypto";import jt from"path";import{createClient as _t}from"graphql-sse";import Gt,{AbortError as Nt}from"p-retry";import{graphql as wn}from"gql.tada";import{graphql as Cn}from"gql.tada";import{print as Dn}from"graphql";async function pr({config:e,cwd:r,headed:n,pool:o,runId:t,signal:i,testSlug:a,workClass:l,workflowSlug:d}){let c=await S(r);if(c.isErr())return await q({config:e,ownerToken:null,reason:`lockfile:${c.error.kind}`,runId:t}),{kind:"dispatch-error",reason:{detail:`lockfile:${c.error.kind}`,type:"generic"}};let u=Tn(c.value,{testSlug:a,workflowSlug:d});if(u==null)return await q({config:e,ownerToken:null,reason:`no-test:${d}/${a}`,runId:t}),{kind:"dispatch-error",reason:{detail:`no-test:${d}/${a}`,type:"generic"}};let f=await A({headed:n,workClass:l,task:()=>o.execute({headed:n,runId:t,testRef:u},i)});return!f.serverNotified&&f.outcome.kind==="error"&&await q({config:e,ownerToken:null,reason:f.outcome.detail,runId:t}),f.outcome}function Tn(e,{testSlug:r,workflowSlug:n}){let t=e.workflows.find(i=>Se(i.name)===n)?.tests.find(i=>i.slug===r);return t==null?void 0:ke(t)}var An=6e4,Ln=Cn(`
|
|
5
|
+
subscription RunRequestedWatch($devSessionId: String!) {
|
|
6
|
+
runRequested(devSessionId: $devSessionId) {
|
|
7
|
+
runId
|
|
8
|
+
testSlug
|
|
9
|
+
workflowId
|
|
10
|
+
workflowSlug
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`);async function fr(e){let r=Math.min(1e3*2**e,An)+Mn();await new Promise(n=>setTimeout(n,r))}function mr({claim:e,cwd:r,devSessionId:n,pool:o,sseClient:t,sseHealth:i}){let a=new Set,l=Hn(r);return t.subscribe({query:Dn(Ln),variables:{devSessionId:n}},{complete:qn,error:d=>{let c=d instanceof Error?d.message:String(d);i.markUnhealthy(c),s.error({err:d},"runRequested subscription failed")},next:d=>{On({claim:e,dispatchConfig:l,event:d.data?.runRequested,inFlightRunIds:a,pool:o})}},{connected:()=>{i.onConnected()},connecting:d=>{i.onConnecting(d),d&&s.debug("runRequested SSE reconnecting")}})}function qn(){}function Hn(e){return ae(e),{config:m(e).match(r=>r,r=>{s.error({failure:r},"failed to load env for run dispatch")}),cwd:e}}function On({claim:e,dispatchConfig:r,event:n,inFlightRunIds:o,pool:t}){if(n==null)return;if(o.has(n.runId)){s.warn({runId:n.runId,workflowSlug:n.workflowSlug},"duplicate runRequested event; skipping dispatch");return}if(r.config==null){s.error({runId:n.runId},"run dispatch skipped, env failed to load at startup");return}o.add(n.runId),process.stdout.write(`ripplo: run ${n.workflowSlug}
|
|
14
|
+
`);let i=Wn(e(n.runId),n);i.started(),pr({config:r.config,cwd:r.cwd,headed:i.headed,pool:t,runId:n.runId,signal:i.signal,testSlug:n.testSlug,workClass:i.workClass,workflowSlug:n.workflowSlug}).then(a=>{i.finished(a)}).catch(a=>{s.error({err:a,runId:n.runId,workflowSlug:n.workflowSlug},"run execution failed; daemon continuing"),i.finished({detail:a instanceof Error?a.message:String(a),kind:"error"})}).finally(()=>{o.delete(n.runId)})}function Wn(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:rr(e.token),workClass:"p1-cli",finished:n=>{e.finished(r.runId,n)},started:()=>{e.started(r.runId)}}}function Mn(){return Math.floor(Math.random()*2700)+300}import{graphql as k}from"gql.tada";import{print as yr}from"graphql";import{clearTimeout as Un,setTimeout as Fn}from"timers";var jn=k(`
|
|
15
|
+
subscription TeleportRequestedWatch($devSessionId: String!) {
|
|
16
|
+
teleportRequested(devSessionId: $devSessionId) {
|
|
17
|
+
runId
|
|
18
|
+
stepIndex
|
|
19
|
+
kind
|
|
20
|
+
testSlug
|
|
21
|
+
workflowSlug
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`),_n=k(`
|
|
25
|
+
subscription DurableTeleportRequestedWatch($devSessionId: String!) {
|
|
26
|
+
durableTeleportRequested(devSessionId: $devSessionId) {
|
|
27
|
+
requestId
|
|
28
|
+
runId
|
|
29
|
+
stepIndex
|
|
30
|
+
kind
|
|
31
|
+
testSlug
|
|
32
|
+
workflowSlug
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`),Gn=k(`
|
|
36
|
+
query TeleportRunRepro($id: String!) {
|
|
37
|
+
run(id: $id) {
|
|
38
|
+
id
|
|
39
|
+
reproJson
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`),Nn=k(`
|
|
43
|
+
mutation ReportTeleportResult($devSessionId: String!, $runId: String!, $status: String!) {
|
|
44
|
+
reportTeleportResult(devSessionId: $devSessionId, runId: $runId, status: $status)
|
|
45
|
+
}
|
|
46
|
+
`),zn=k(`
|
|
47
|
+
mutation ClaimTeleportRequest($devSessionId: String!, $requestId: String!) {
|
|
48
|
+
claimTeleportRequest(devSessionId: $devSessionId, requestId: $requestId)
|
|
49
|
+
}
|
|
50
|
+
`),Bn=k(`
|
|
51
|
+
mutation ReportDurableTeleportResult(
|
|
52
|
+
$devSessionId: String!
|
|
53
|
+
$requestId: String!
|
|
54
|
+
$status: TeleportOutcome!
|
|
55
|
+
) {
|
|
56
|
+
reportDurableTeleportResult(devSessionId: $devSessionId, requestId: $requestId, status: $status)
|
|
57
|
+
}
|
|
58
|
+
`);function gr({cwd:e,devSessionId:r,sseClient:n}){let o=new Set,t=Kn({cwd:e,devSessionId:r,running:o,sseClient:n}),i=Qn({cwd:e,devSessionId:r,running:o,sseClient:n});return()=>{o.forEach(a=>{a.abort()}),o.clear(),t(),i()}}function Kn({cwd:e,devSessionId:r,running:n,sseClient:o}){return o.subscribe({query:yr(jn),variables:{devSessionId:r}},{complete:Sr,error:t=>{s.error({err:t},"teleportRequested subscription failed")},next:t=>{let i=t.data?.teleportRequested;hr({cwd:e,devSessionId:r,event:i==null?i:{...i,requestId:void 0},running:n})}})}function Sr(){}function Qn({cwd:e,devSessionId:r,running:n,sseClient:o}){return o.subscribe({query:yr(_n),variables:{devSessionId:r}},{complete:Sr,error:t=>{s.error({err:t},"durableTeleportRequested subscription failed")},next:t=>{hr({cwd:e,devSessionId:r,event:t.data?.durableTeleportRequested,running:n})}})}function hr({cwd:e,devSessionId:r,event:n,running:o}){if(n==null)return;let t=new AbortController;o.add(t),Jn({cwd:e,devSessionId:r,event:n,signal:t.signal}).catch(i=>{s.error({err:i},"teleport failed; daemon continuing")}).finally(()=>{o.delete(t)})}async function Jn({cwd:e,devSessionId:r,event:n,signal:o}){n.requestId!=null&&!await Yn({cwd:e,devSessionId:r,requestId:n.requestId})||await Vn({cwd:e,devSessionId:r,event:n,signal:o})}async function Vn({cwd:e,devSessionId:r,event:n,signal:o}){let t=c=>Xn({cwd:e,devSessionId:r,requestId:n.requestId,runId:n.runId,status:c}),i=to(o),a=await ro({cwd:e,event:n});if(a==null){i.clear(),s.warn({runId:n.runId},"teleport could not resolve target"),await t("unplannable");return}process.stdout.write(`ripplo: teleport ${oo(n)} step ${String(n.stepIndex+1)}
|
|
59
|
+
`);let d=await lr({cwd:e,onReady:()=>{i.clear(),t("opened")},signal:i.signal,step:n.stepIndex+1,target:a});i.clear(),!(d.kind==="done"&&d.result.kind==="handed-over")&&(s.warn({kind:d.kind,runId:n.runId},"teleport could not open"),await t(d.kind==="unplannable"?"unplannable":"error"))}async function Xn({cwd:e,devSessionId:r,requestId:n,runId:o,status:t}){if(n!=null){await eo({cwd:e,devSessionId:r,requestId:n,status:t});return}await Zn({cwd:e,devSessionId:r,runId:o,status:t})}async function Yn({cwd:e,devSessionId:r,requestId:n}){let o=m(e).match(i=>i,()=>null);return o==null?!1:(await p({config:o,document:zn,variables:{devSessionId:r,requestId:n}}).catch(()=>null))?.claimTeleportRequest===!0}async function Zn({cwd:e,devSessionId:r,runId:n,status:o}){let t=m(e).match(i=>i,()=>null);t!=null&&await p({config:t,document:Nn,variables:{devSessionId:r,runId:n,status:o}}).catch(()=>null)}async function eo({cwd:e,devSessionId:r,requestId:n,status:o}){let t=m(e).match(i=>i,()=>null);t!=null&&await p({config:t,document:Bn,variables:{devSessionId:r,requestId:n,status:o}}).catch(()=>null)}async function ro({cwd:e,event:r}){if(r.kind==="explore"){let n=await no({cwd:e,runId:r.runId});return n==null?null:{kind:"explore",repro:n}}return r.testSlug==null||r.workflowSlug==null?null:{kind:"test",ref:`${r.workflowSlug}/${r.testSlug}`}}async function no({cwd:e,runId:r}){let n=m(e).match(i=>i,()=>null);if(n==null)return null;let o=await p({config:n,document:Gn,variables:{id:r}}).catch(()=>null);if(o?.run?.reproJson==null)return null;let t=T(o.run.reproJson);return t.kind==="valid"?t.repro:null}function oo(e){return e.kind==="explore"?"explore finding":`${String(e.workflowSlug)}/${String(e.testSlug)}`}function to(e){let r=new AbortController,n=Fn(()=>{r.abort()},3e4);return{signal:AbortSignal.any([e,r.signal]),clear:()=>{Un(n)}}}import O from"fs";import io from"p-retry";import{graphql as b}from"gql.tada";import{print as M}from"graphql";var ao=b(`
|
|
60
|
+
query DaemonExploration($devSessionId: String!) {
|
|
61
|
+
exploration(devSessionId: $devSessionId) {
|
|
62
|
+
active
|
|
63
|
+
localWorkers
|
|
64
|
+
maxTrailLength
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`),so=b(`
|
|
68
|
+
subscription WatchExplorationChanged($devSessionId: String!) {
|
|
69
|
+
explorationChanged(devSessionId: $devSessionId) {
|
|
70
|
+
exploration {
|
|
71
|
+
active
|
|
72
|
+
localWorkers
|
|
73
|
+
maxTrailLength
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`);function kr({config:e,devSessionId:r,exploration:n,lifetime:o,sseClient:t}){return io(()=>lo({config:e,devSessionId:r,exploration:n,lifetime:o}),{factor:2,minTimeout:500,retries:6}).catch(i=>{s.warn({err:i},"initial exploration state read failed \u2014 explorer stays off")}),t.subscribe({query:M(so),variables:{devSessionId:r}},{complete:U,error:i=>{$({error:i,stream:"explorationChanged"})},next:i=>{vr(n,i.data?.explorationChanged.exploration)}})}async function lo({config:e,devSessionId:r,exploration:n,lifetime:o}){if(W(o))return;let t=await p({config:e,document:ao,variables:{devSessionId:r}});W(o)||vr(n,t.exploration)}function vr(e,r){r!=null&&e.setDesired({active:r.active,localWorkers:r.localWorkers,maxTrailLength:r.maxTrailLength})}var co=b(`
|
|
78
|
+
subscription HooksPausedWatch($projectId: String!) {
|
|
79
|
+
hooksPausedRequested(projectId: $projectId) {
|
|
80
|
+
paused
|
|
81
|
+
projectId
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
`),uo=b(`
|
|
85
|
+
subscription WatchLocalConcurrencyChanged {
|
|
86
|
+
myMaxLocalConcurrentRunsChanged
|
|
87
|
+
}
|
|
88
|
+
`);function wr({pool:e,sseClient:r}){return r.subscribe({query:M(uo)},{complete:U,error:n=>{$({error:n,stream:"myMaxLocalConcurrentRunsChanged"})},next:n=>{let o=n.data?.myMaxLocalConcurrentRunsChanged;o!=null&&(L(o),e.setSize(o))}})}var po=b(`
|
|
89
|
+
subscription WatchExecutorChangeRequested($devSessionId: String!) {
|
|
90
|
+
executorChangeRequested(devSessionId: $devSessionId) {
|
|
91
|
+
executor
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`);function xr({config:e,devSessionId:r,lifetime:n,sseClient:o,switcher:t}){return t.connect(r),fo({config:e,lifetime:n,switcher:t}),mo({devSessionId:r,sseClient:o,switcher:t})}async function fo({config:e,lifetime:r,switcher:n}){if(W(r))return;let o=await dr(e);if(!W(r)){if(o.isErr()){s.warn({error:o.error},"initial executor fetch failed, staying local");return}n.request(o.value)}}function W(e){return e.aborted}function mo({devSessionId:e,sseClient:r,switcher:n}){return r.subscribe({query:M(po),variables:{devSessionId:e}},{complete:U,error:o=>{$({error:o,stream:"executorChangeRequested"})},next:o=>{let t=o.data?.executorChangeRequested?.executor;t!=null&&n.request(t)}})}function br({cwd:e,projectId:r,sseClient:n}){return n.subscribe({query:M(co),variables:{projectId:r}},{complete:U,error:o=>{$({error:o,stream:"hooksPausedRequested"})},next:o=>{let t=o.data?.hooksPausedRequested?.paused;t!=null&&R({cwd:e,paused:t})}})}function $({error:e,stream:r}){s.error({error:e},"%s subscription failed",r)}function U(){}function R({cwd:e,paused:r}){let n=me(e);if(r&&!O.existsSync(n)){O.writeFileSync(n,"");return}!r&&O.existsSync(n)&&O.unlinkSync(n)}function Rr({initialId:e,onSynchronized:r,subscribe:n,synchronize:o}){let t=e,i=null,a=!1,l=d();function d(){let f=new AbortController,y=n({devSessionId:t,lifetime:f.signal});return()=>{f.abort(),y()}}async function c(f){let y=await o(f);y==null||a||(l(),t=y.devSessionId,r(y),l=d())}function u(f){return a?Promise.resolve():(i!=null||(i=c(f).finally(()=>{i=null})),i)}return{getId:()=>t,reregister:()=>u("dev session ended server-side"),stop:()=>{a||(a=!0,l())}}}function Pr({claim:e,config:r,devSessionId:n,executorSwitch:o,exploration:t,onSynchronized:i,pool:a,sseClient:l,sseHealth:d}){return Rr({initialId:n,onSynchronized:c=>{i(c),R({cwd:r.cwd,paused:c.hooksPaused})},subscribe:({devSessionId:c,lifetime:u})=>yo({claim:e,config:r,devSessionId:c,executorSwitch:o,exploration:t,lifetime:u,pool:a,sseClient:l,sseHealth:d}),synchronize:c=>go({config:r,reason:c,sseHealth:d})})}function yo({claim:e,config:r,devSessionId:n,executorSwitch:o,exploration:t,lifetime:i,pool:a,sseClient:l,sseHealth:d}){let c=[xr({config:r,devSessionId:n,lifetime:i,sseClient:l,switcher:o}),br({cwd:r.cwd,projectId:r.projectId,sseClient:l}),wr({pool:a,sseClient:l}),kr({config:r,devSessionId:n,exploration:t,lifetime:i,sseClient:l}),mr({claim:e,cwd:r.cwd,devSessionId:n,pool:a,sseClient:l,sseHealth:d}),gr({cwd:r.cwd,devSessionId:n,sseClient:l})];return()=>{c.forEach(u=>{u()})}}async function go({config:e,reason:r,sseHealth:n}){n.markUnhealthy(r);let o=await I(e.cwd);return o.isErr()?(s.error("re-register: compile failed: %s",D(o.error)),null):Ae({config:e,cwd:e.cwd,lockfile:o.value})}import{createHash as So}from"crypto";import Er from"fs";function Ir(){return J===void 0&&(J=ho()),J}var J;function ho(){let e=process.argv[1];if(e==null)return null;try{let r=Er.readFileSync(Er.realpathSync(e));return So("sha256").update(r).digest("hex")}catch{return null}}import{graphql as Tr}from"gql.tada";var ko=Tr(`
|
|
95
|
+
query OpenFindingsForRetire($projectId: String!) {
|
|
96
|
+
exploreFindings(projectId: $projectId, status: open) {
|
|
97
|
+
signature
|
|
98
|
+
reproRun {
|
|
99
|
+
reproJson
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
`),vo=Tr(`
|
|
104
|
+
mutation RetireStaleFinding($projectId: String!, $signature: String!) {
|
|
105
|
+
retireStaleFinding(projectId: $projectId, signature: $signature)
|
|
106
|
+
}
|
|
107
|
+
`);async function Cr({config:e,cwd:r,lockfile:n}){let t=(await p({config:e,document:ko,variables:{projectId:e.projectId}})).exploreFindings,i=await C(r,n);if(i.isErr())return s.info({block:i.error.kind},"skipping finding retire until next compile"),!1;let a=wo(t,i.value);return a.length===0||(await Promise.all(a.map(l=>bo(e,l))),s.info({count:a.length},"retired findings whose trail no longer replays")),!0}function wo(e,r){return e.map(n=>xo(n,r)?n.signature:null).filter(n=>n!=null)}function xo(e,r){let n=e.reproRun?.reproJson;if(n==null)return!0;let o=T(n);return o.kind==="rejected"?!0:Te(r,o.repro).kind==="unplannable"}function bo(e,r){return p({config:e,document:vo,variables:{projectId:e.projectId,signature:r}})}var Ro=6e4;function Dr(e){let r={retiredKey:null,running:!1,stopped:!1},n=async()=>{if(!(r.running||r.stopped)){r.running=!0;try{r.retiredKey=await Po(e,r.retiredKey)}catch(t){s.warn({err:t},"retire stale findings failed \u2014 retrying on next tick")}finally{r.running=!1}}},o={timer:setTimeout(function t(){n(),r.stopped||(o.timer=setTimeout(t,Ro))},0)};return()=>{r.stopped=!0,clearTimeout(o.timer)}}async function Po({config:e,cwd:r},n){let o=await h(r),t=Ir();if(o==null||t==null)return n;let i=`${o}@${t}`;if(i===n)return n;let a=await S(r);return a.isErr()?n:await Cr({config:e,cwd:r,lockfile:a.value})?i:n}import{Agent as Eo,fetch as Io}from"undici";var To=3e4;function Ar(e=To){let r=new Eo({bodyTimeout:e});return(n,o)=>Io(n,{...o,dispatcher:r})}function Lr(){let e=!0,r,n=null,o=()=>{n!=null&&(clearTimeout(n),n=null)};return{markUnhealthy:t=>{e=!1,r=t,o()},onConnected:()=>{o(),n=setTimeout(()=>{e=!0,r=void 0,n=null},1e4)},onConnecting:()=>{o()},snapshot:()=>({detail:r,ok:e})}}import Co from"fs";import Wr from"net";import{err as Mr,ok as Do}from"neverthrow";async function $r({cwd:e,onConnection:r}){ue(e);let n=qe(e),o=await qr({onConnection:r,socketPath:n});return o.isOk()||o.error.kind!=="stale-candidate"?o.map(Hr(n)).mapErr(Or(n)):await Ao(n)?Mr({kind:"already-running",socketPath:n}):(Ur(n),(await qr({onConnection:r,socketPath:n})).map(Hr(n)).mapErr(Or(n)))}function Ao(e){return new Promise(r=>{let n=Wr.connect(e);n.once("connect",()=>{n.destroy(),r(!0)}),n.once("error",()=>{r(!1)})})}async function qr(e){let r=await Lo(e);return r.kind==="listening"?Do(r.server):Mr(r.error)}function Lo({onConnection:e,socketPath:r}){return new Promise(n=>{let o=Wr.createServer(e);o.once("error",t=>{n({error:t.code==="EADDRINUSE"?{kind:"stale-candidate"}:{kind:"listen-failed",message:t.message},kind:"failed"})}),o.listen(r,()=>{n({kind:"listening",server:o})})})}function Hr(e){return r=>({socketPath:e,close:()=>{r.close(),Ur(e)}})}function Ur(e){Co.rmSync(e,{force:!0})}function Or(e){return r=>r.kind==="stale-candidate"?{kind:"already-running",socketPath:e}:{kind:"bind-failed",message:r.message}}import{randomUUID as zo}from"crypto";function Fr(){return{attempts:0,backoffUntil:0,consecutiveErrors:0,coverageWaiting:!1,desired:{active:!1,localWorkers:cr,maxTrailLength:ur},executorLocal:!0,findings:0,lastUnhealthyReportAt:null,loading:!1,lockfile:{kind:"loading"},prevInteractiveActive:0,stopped:!1,trails:new Map}}function jr(e,r){if(e.stopped)return{effects:[],state:e};switch(r.kind){case"tick":return V(e,r.now,r.queue);case"desired-changed":return V({...e,desired:r.desired},r.now,r.queue);case"executor-changed":return{effects:[],state:{...e,executorLocal:r.local}};case"load-settled":return Mo(e,r.outcome);case"trail-started":return{effects:[],state:{...e,coverageWaiting:!1,trails:new Map([...e.trails,[r.id,{startedAt:r.now}]])}};case"trail-settled":return $o(e,r);case"stopped":return{effects:[{ids:[...e.trails.keys()],kind:"abort"}],state:{...e,stopped:!0,trails:new Map}}}}function _r(e,r,n){return Q(Gr(e),Nr(e,r,n)).health}function V(e,r,n){let o=Wo(e,r,n),t={...e,...o,prevInteractiveActive:n.active},i=Q(Gr(t),Nr(t,r,n)),a=t.lockfile.kind!=="ready"&&!t.loading;return{effects:[...qo(a),...Ho(i.abortIds),...Oo({count:i.launchCount,maxTrailLength:t.desired.maxTrailLength})],state:{...t,loading:t.loading||a}}}function qo(e){return e?[{kind:"load"}]:[]}function Ho(e){return e.length>0?[{ids:e,kind:"abort"}]:[]}function Oo({count:e,maxTrailLength:r}){return e>0?[{count:e,kind:"launch",maxTrailLength:r}]:[]}function Wo(e,r,n){return n.active<e.prevInteractiveActive?{backoffUntil:Math.max(e.backoffUntil,r+H)}:{backoffUntil:e.backoffUntil}}function Mo(e,r){return r.kind==="blocked"?{effects:[],state:{...e,loading:!1,lockfile:{kind:"blocked",reason:r.reason}}}:{effects:[],state:{...e,consecutiveErrors:0,coverageWaiting:!1,lastUnhealthyReportAt:null,loading:!1,lockfile:{kind:"ready"}}}}function $o(e,r){let n=new Map([...e.trails].filter(([i])=>i!==r.id)),o=Uo({...e,trails:n},r.settled,r.now),t=V(o.state,r.now,r.queue);return{effects:[...o.effects,...t.effects],state:t.state}}function Uo(e,r,n){switch(r.kind){case"aborted":return{effects:[],state:e};case"crashed":return X({now:n,state:e,subject:`exploration ${r.stage} crashed`});case"no-candidate":return{effects:[],state:{...e,backoffUntil:Math.max(e.backoffUntil,n+H),consecutiveErrors:0,coverageWaiting:xe(r.reason)}};case"app-unreachable":return X({now:n,state:e,subject:"app-unreachable"});case"error":return Fo(e,r.error,n);case"done":return _o(e,r.result)}}function Fo(e,r,n){return r.source==="lockfile-stale"?{effects:[{kind:"reload"}],state:{...e,loading:!0,lockfile:{kind:"loading"}}}:be(r)==="trail"?{effects:[],state:{...e,consecutiveErrors:0,lastUnhealthyReportAt:null}}:X({now:n,state:e,subject:jo(r)})}function jo(e){switch(e.source){case"transport":case"config":return`${e.source}: ${e.detail}`;case"runtime":return`runtime: ${e.detail}`;case"empty-trail":case"assignment-rejected":case"lockfile-stale":return e.source}}function _o(e,r){let n=r.kind==="finding";return{effects:[{finding:n,kind:"report",result:r}],state:{...e,attempts:e.attempts+1,consecutiveErrors:0,findings:e.findings+(n?1:0),lastUnhealthyReportAt:null}}}var Go=6,No=2e4;function X({now:e,state:r,subject:n}){let o=r.consecutiveErrors+1,t=Math.max(r.backoffUntil,e+H);if(o<Go)return{effects:[],state:{...r,backoffUntil:t,consecutiveErrors:o}};let i=r.lastUnhealthyReportAt==null||e-r.lastUnhealthyReportAt>=No;return{effects:i?[{kind:"report-unhealthy",subject:n}]:[],state:{...r,backoffUntil:t,consecutiveErrors:o,lastUnhealthyReportAt:i?e:r.lastUnhealthyReportAt}}}function Gr(e){return{enabled:e.desired.active,executorLocal:e.executorLocal,maxTrailLength:e.desired.maxTrailLength,workers:e.desired.localWorkers}}function Nr(e,r,n){return{backoffActive:r<e.backoffUntil,coverageWaiting:e.coverageWaiting,headedActive:n.headedActive>0,interactiveActive:n.active,interactiveQueued:n.queued,lockfile:e.lockfile,poolSize:n.poolSize,trails:[...e.trails.entries()].map(([o,t])=>({ageMs:r-t.startedAt,id:o}))}}function Br(e){let r=Bo(e),n=Jo(()=>{r.dispatch(P())});return B(()=>{r.dispatch(P())}),r.dispatch(P()),{notifyQueueChange:()=>{r.dispatch({kind:"executor-changed",local:e.executorIsLocal()}),r.dispatch(P())},setDesired:o=>{r.dispatch({desired:o,kind:"desired-changed",now:Date.now(),queue:F()})},status:()=>Qo(r.current()),stop:()=>{n(),B(null),r.dispatch({kind:"stopped"})}}}function Bo(e){let r={draining:!1,planning:Promise.resolve(),queue:[],runtime:Ko(e)},n=a=>{r.runtime=a(r.runtime)},o=a=>{r.queue.push(a),!r.draining&&(r.draining=!0,i(),r.draining=!1)},t=a=>{r.planning=r.planning.then(a,a)},i=()=>{let a=r.queue.shift();if(a==null)return;let l=jr(r.runtime.state,a);n(d=>({...d,state:l.state})),l.effects.forEach(d=>{Vo({commit:n,dispatch:o,effect:d,params:e,queuePlanning:t,runtime:r.runtime,current:()=>r.runtime})}),i()};return{dispatch:o,current:()=>r.runtime}}function Ko(e){return{controllers:new Map,prepared:null,reservations:new Map,state:{...Fr(),executorLocal:e.executorIsLocal()}}}function Qo(e){return{explorer:_r(e.state,Date.now(),F()),exploring:e.state.trails.size,progress:{attempts:e.state.attempts,findings:e.state.findings}}}function F(){let e=Ze();return{active:e.active,headedActive:e.headedActive,poolSize:e.poolSize,queued:e.queued}}function P(){return{kind:"tick",now:Date.now(),queue:F()}}function Jo(e){let r={timer:setTimeout(function n(){e(),r.timer=setTimeout(n,K)},K)};return()=>{clearTimeout(r.timer)}}function Vo({commit:e,current:r,dispatch:n,effect:o,params:t,queuePlanning:i,runtime:a}){switch(o.kind){case"load":case"reload":{Yo(t.cwd,a.prepared).then(({outcome:l,prepared:d})=>{e(c=>({...c,prepared:d})),n({kind:"load-settled",now:Date.now(),outcome:l}),n(P())});return}case"abort":{o.ids.forEach(l=>{a.controllers.get(l)?.abort()});return}case"launch":{Array.from({length:o.count}).forEach(()=>{let l=Xo({commit:e,dispatch:n});i(()=>et({commit:e,controller:l.controller,dispatch:n,id:l.id,maxTrailLength:o.maxTrailLength,params:t,prepared:r().prepared,reservedSignatures:new Set(r().reservations.values())}))});return}case"report":{t.report({attempts:1,findings:o.finding?1:0,result:o.result}),o.finding&&s.info("exploration finding recorded");return}case"report-unhealthy":s.warn("exploration unhealthy after repeated infra errors (last: %s)",o.subject),t.reportUnhealthy()}}function Xo({commit:e,dispatch:r}){let n=`explore:${zo()}`,o=new AbortController;return e(t=>({...t,controllers:new Map([...t.controllers,[n,o]])})),r({id:n,kind:"trail-started",now:Date.now()}),{controller:o,id:n}}async function Yo(e,r){try{return await Zo(e,r)}catch(n){return s.warn({err:n},"Explorer couldn't load the model \u2014 retrying on the next tick"),{outcome:{kind:"blocked",reason:"load-failed"},prepared:null}}}async function Zo(e,r){let n=await h(e);if(n==null)return{outcome:{kind:"blocked",reason:"no-lockfile"},prepared:null};if(r?.rawHash===n)return{outcome:{kind:"ready",rawHash:n},prepared:r};let{result:o}=await he(e);if(o.isErr())return{outcome:{kind:"blocked",reason:"load-failed"},prepared:null};let t=await C(e,o.value);if(t.isErr())return{outcome:{kind:"blocked",reason:t.error.kind},prepared:null};let i=Pe(t.value);return i.kind==="model-empty"?{outcome:{kind:"blocked",reason:"model-empty"},prepared:null}:{outcome:{kind:"ready",rawHash:n},prepared:{exploration:i.value,rawHash:n}}}async function et({commit:e,controller:r,dispatch:n,id:o,maxTrailLength:t,params:i,prepared:a,reservedSignatures:l}){if(zr(r.signal)){v({commit:e,dispatch:n,id:o,settled:{kind:"aborted"}});return}if(a==null){v({commit:e,dispatch:n,id:o,settled:{kind:"crashed",stage:"planning"}});return}let d=await rt({maxTrailLength:t,params:i,prepared:a,reservedSignatures:l}).catch(u=>(s.warn({err:u},"Explorer couldn't plan a trail \u2014 retrying shortly"),null));if(d==null){v({commit:e,dispatch:n,id:o,settled:{kind:"crashed",stage:"planning"}});return}if(zr(r.signal)){v({commit:e,dispatch:n,id:o,settled:{kind:"aborted"}});return}if(i.onPlannerTrace?.(d),d.kind==="no-candidate"){v({commit:e,dispatch:n,id:o,settled:{kind:"no-candidate",reason:d.reason}});return}let c=d.assignment;e(u=>({...u,reservations:new Map([...u.reservations,[o,c.coverageSignature]])})),A({headed:!1,workClass:"p3-explore",task:()=>nt({assign:c,params:i,signal:r.signal})}).catch(u=>(s.warn({err:u},"Explorer couldn't run a trail \u2014 retrying shortly"),{kind:"crashed",stage:"execution"})).then(u=>{v({commit:e,dispatch:n,id:o,settled:u})})}function zr(e){return e.aborted}async function rt({maxTrailLength:e,params:r,prepared:n,reservedSignatures:o}){let t=Date.now(),i=await r.leaseOrdinal(),a=await Ee({attemptOrdinal:i,modelHash:n.rawHash,prepared:n.exploration,reservedSignatures:o,strategy:{...ve("even"),maxAttemptLength:e},targetGeneration:r.targetGeneration()});return s.debug({attemptOrdinal:i,beamMs:a.timing.beamMs,candidateMs:a.timing.candidateMs,candidates:a.trace.candidates,envelopesMs:a.timing.envelopesMs,expanded:a.trace.expanded,expansionMs:a.timing.expansionMs,kind:a.kind,planningMs:Date.now()-t,rejectedCycles:a.trace.rejectedCycles,rejectedReplays:a.trace.rejectedReplays,searchMs:a.timing.searchMs,selectionMs:a.timing.selectionMs,selectionTier:a.trace.selectionTier},"explorer planning completed"),a}function v({commit:e,dispatch:r,id:n,settled:o}){e(t=>({...t,controllers:new Map([...t.controllers].filter(([i])=>i!==n)),reservations:new Map([...t.reservations].filter(([i])=>i!==n))})),r({id:n,kind:"trail-settled",now:Date.now(),queue:F(),settled:o})}async function nt({assign:e,params:r,signal:n}){let o=await r.executeTrail(e,n);return o.kind==="aborted"?{kind:"aborted"}:o.kind==="error"?ot(r,o.error):{kind:"done",result:o}}async function ot(e,r){let n=await We(e.appUrl);return n!=null?(s.debug("exploration app probe failed: %s",n),{kind:"app-unreachable"}):(s.debug({error:r},"exploration trail error"),{error:r,kind:"error"})}import{graphql as kt}from"gql.tada";import{connect as it}from"net";import at from"ssh2";import{WebSocket as Qr,createWebSocketStream as st}from"ws";var tt="ripplo-";function Y(e){return Object.entries(e).map(([r,n])=>`${tt}${r}.${n}`)}var{Server:lt,utils:Kr}=at;function Jr(){let e=Kr.generateKeyPairSync("ed25519"),r=Kr.parseKey(e.private);if(r instanceof Error)throw r;return{fingerprint:r.getPublicSSH().toString("base64"),privateKey:e.private}}function Vr(e){return new Promise((r,n)=>{let o={closers:new Set,stopped:!1},t=new Qr(e.relayUrl,Y({grant:e.grant,role:"daemon-control"}));t.on("open",()=>{s.info("cloud-executor relay control up"),r({stop:dt(t,o)})}),t.on("message",i=>{ct(e,o,i)}),t.on("close",(i,a)=>{o.stopped||s.warn({code:i,reason:a.toString()},"relay control closed"),ht(e,o)}),t.on("error",i=>{n(i instanceof Error?i:new Error(String(i)))})})}function dt(e,r){return()=>(r.stopped=!0,r.closers.forEach(n=>{n()}),e.close(),Promise.resolve())}function ct(e,r,n){let o=ut(n);o!=null&&ft(e,r,o.pipeId)}function ut(e){try{let r=JSON.parse(pt(e));return typeof r=="object"&&r!=null&&"signal"in r&&r.signal==="open-data"&&"pipeId"in r&&typeof r.pipeId=="string"?{pipeId:r.pipeId}:null}catch{return null}}function pt(e){return Buffer.isBuffer(e)?e.toString("utf8"):Array.isArray(e)?Buffer.concat(e).toString("utf8"):Buffer.from(e).toString("utf8")}function ft(e,r,n){if(r.stopped)return;let o=new Qr(e.relayUrl,Y({pipeId:n,role:"daemon-data"}));o.on("open",()=>{mt(e,r,o)}),o.on("error",t=>{s.warn({err:t},"cloud-executor relay data pipe error")})}function mt(e,r,n){let o=st(n);o.on("error",()=>{});let t=new lt({hostKeys:[e.hostKey.privateKey]},a=>{a.on("error",l=>{s.warn({err:l},"cloud-executor ssh connection error")}),a.on("authentication",l=>{gt(l,e.secret)}),a.on("ready",()=>{a.on("tcpip",(l,d,c)=>{St({accept:l,allowedPorts:e.allowedPorts,deny:d,destPort:c.destPort})})})}),i=()=>{n.close()};r.closers.add(i),n.on("close",()=>r.closers.delete(i)),yt(t,o)}function yt(e,r){e.injectSocket(r)}function gt(e,r){if(e.method==="password"&&e.password===r){e.accept();return}if(e.method==="none"){e.reject(["password"]);return}e.reject()}function St({accept:e,allowedPorts:r,deny:n,destPort:o}){if(!r.includes(o)){s.warn({allowedPorts:r,destPort:o},"cloud-executor relay refused an unexpected port"),n();return}let t=!1,i=it({autoSelectFamily:!0,host:"localhost",port:o},()=>{t=!0;let a=e();a.on("error",()=>{}),i.pipe(a).pipe(i)});i.on("error",a=>{t||(s.warn({destPort:o,err:a},"cloud-executor relay could not reach the local app"),n())})}function ht(e,r){r.stopped||(r.stopped=!0,r.closers.forEach(n=>{n()}),e.onFatal())}var vt=kt(`
|
|
108
|
+
mutation EnterCloudMode(
|
|
109
|
+
$devSessionId: String!
|
|
110
|
+
$localUrl: String!
|
|
111
|
+
$engineUrl: String!
|
|
112
|
+
$hostKeyFingerprint: String!
|
|
113
|
+
) {
|
|
114
|
+
enterCloudMode(
|
|
115
|
+
devSessionId: $devSessionId
|
|
116
|
+
localUrl: $localUrl
|
|
117
|
+
engineUrl: $engineUrl
|
|
118
|
+
hostKeyFingerprint: $hostKeyFingerprint
|
|
119
|
+
) {
|
|
120
|
+
__typename
|
|
121
|
+
... on RelaySession {
|
|
122
|
+
generation
|
|
123
|
+
grant
|
|
124
|
+
relayUrl
|
|
125
|
+
secret
|
|
126
|
+
session
|
|
127
|
+
}
|
|
128
|
+
... on DevSessionEndedError {
|
|
129
|
+
message
|
|
130
|
+
}
|
|
131
|
+
... on TunnelNotConfiguredError {
|
|
132
|
+
message
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
`),j=class extends Error{failure;constructor(r){super(r.kind),this.failure=r}};async function Yr({config:e,devSessionId:r,onFatal:n}){let o=Jr(),i=(await p({config:e,document:vt,variables:{devSessionId:r,engineUrl:e.engineUrl,hostKeyFingerprint:o.fingerprint,localUrl:e.appUrl}})).enterCloudMode;if(i==null)throw new j({kind:"empty-response"});if(i.__typename!=="RelaySession")throw new j({kind:"server-error",typename:i.__typename});let a=await Vr({allowedPorts:[...new Set([Xr(e.appUrl),Xr(e.engineUrl)])],grant:i.grant,hostKey:o,onFatal:n,relayUrl:i.relayUrl,secret:i.secret});return s.info({session:i.session},"cloud-executor relay up"),{stop:a.stop}}function Xr(e){let r=new URL(e);return r.port.length>0?Number(r.port):r.protocol==="https:"?443:80}var Zr=[1e3,3e3,8e3,15e3];function en(){return{attempt:0,desired:"local",devSessionId:null,stopped:!1,tunnel:"down"}}function rn(e,r){if(e.stopped)return{effects:[],state:e};switch(r.kind){case"requested":return xt(e,r.mode);case"connected":return Z({...e,devSessionId:r.devSessionId},[]);case"tunnel-started":return bt(e);case"tunnel-failed":case"tunnel-fatal":return Rt(e);case"retry-due":return e.tunnel==="down"?Z(e,[]):{effects:[],state:e};case"stopped":return{effects:e.tunnel==="down"?[]:[{kind:"stop-tunnel"}],state:{...e,desired:"local",stopped:!0,tunnel:"down"}}}}function wt(e){let r=Math.min(e,Zr.length-1),n=Zr[r];if(n==null)throw new Error("executor retry ladder is empty");return n}function xt(e,r){return r===e.desired?{effects:[],state:e}:Z({...e,attempt:0,desired:r},[{kind:"notify-changed"}])}function Z(e,r){return _(e)&&e.tunnel==="down"&&e.devSessionId!=null?{effects:[...r,{devSessionId:e.devSessionId,kind:"start-tunnel"}],state:{...e,tunnel:"starting"}}:!_(e)&&e.tunnel!=="down"?{effects:[...r,{kind:"stop-tunnel"}],state:{...e,tunnel:"down"}}:{effects:r,state:e}}function _(e){return e.desired==="cloud"&&e.devSessionId!=null&&!e.stopped}function bt(e){return _(e)?{effects:[],state:{...e,attempt:0,tunnel:"up"}}:{effects:[{kind:"stop-tunnel"}],state:{...e,tunnel:"down"}}}function Rt(e){let r={...e,tunnel:"down"};return _(r)?{effects:[{delayMs:wt(r.attempt),kind:"schedule-retry"}],state:{...r,attempt:r.attempt+1}}:{effects:[],state:r}}function tn(e){let r={draining:!1,io:Promise.resolve(),queue:[],retryTimer:null,state:en(),tunnel:null},n=o=>{r.queue.push(o),!r.draining&&(r.draining=!0,an(r,n,e),r.draining=!1)};return{connect:o=>{n({devSessionId:o,kind:"connected"})},current:()=>r.state.desired,request:o=>{n({kind:"requested",mode:o})},stop:async()=>{n({kind:"stopped"}),await r.io.catch(()=>{})}}}function an(e,r,n){let o=e.queue.shift();if(o==null)return;let t=rn(e.state,o);e.state=t.state,t.effects.forEach(i=>{Pt({cell:e,dispatch:r,effect:i,params:n})}),an(e,r,n)}function Pt({cell:e,dispatch:r,effect:n,params:o}){switch(n.kind){case"start-tunnel":{nn(e,()=>Et({cell:e,devSessionId:n.devSessionId,dispatch:r,params:o}));return}case"stop-tunnel":{let t=e.tunnel;e.tunnel=null,on(e),t!=null&&nn(e,async()=>{await t.stop(),s.info("executor switched to local")});return}case"schedule-retry":{on(e),s.warn({delayMs:n.delayMs},"cloud tunnel down; retrying \u2014 switch with npx ripplo executor local"),e.retryTimer=setTimeout(()=>{e.retryTimer=null,r({kind:"retry-due"})},n.delayMs);return}case"notify-changed":o.onChanged()}}async function Et({cell:e,devSessionId:r,dispatch:n,params:o}){try{let t=await Yr({config:o.config,devSessionId:r,onFatal:()=>{e.tunnel=null,n({kind:"tunnel-fatal"})}});e.tunnel=t,s.info("executor switched to cloud"),n({kind:"tunnel-started"})}catch(t){s.warn({err:t},"cloud tunnel failed to start; retrying in background"),n({kind:"tunnel-failed"})}}function nn(e,r){e.io=e.io.then(r).catch(n=>{s.warn({err:n},"executor io failed")})}function on(e){e.retryTimer!=null&&(clearTimeout(e.retryTimer),e.retryTimer=null)}import{graphql as It}from"gql.tada";var Tt=It(`
|
|
137
|
+
mutation EndDevSessionWatch($projectId: String!, $cwd: String!, $devSessionId: String) {
|
|
138
|
+
endDevSession(projectId: $projectId, cwd: $cwd, devSessionId: $devSessionId) {
|
|
139
|
+
__typename
|
|
140
|
+
... on DevSession {
|
|
141
|
+
id
|
|
142
|
+
}
|
|
143
|
+
... on NoActiveDevSessionError {
|
|
144
|
+
message
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
`);function sn(e){let r=async()=>{e.stops.forEach(o=>{o()}),e.exploration.stop(),e.socketHandle.close(),e.session.stop(),await e.pool.close(),await e.executorSwitch.stop(),await e.spanReceiver.stop().catch(()=>{}),await Promise.race([p({config:e.config,document:Tt,variables:{cwd:e.config.cwd,devSessionId:e.session.getId(),projectId:e.config.projectId}}).catch(()=>{}),new Promise(o=>setTimeout(o,3e3))]),e.releasePid()},n=()=>{r().finally(()=>process.exit(0))};e.shutdownRef.handler=n,process.on("SIGINT",n),process.on("SIGTERM",n),process.on("SIGHUP",n),process.on("SIGBREAK",n)}import{readdir as Ct}from"fs/promises";import{existsSync as ln}from"fs";import ee from"path";async function dn({config:e,cwd:r}){let n=ee.join(r,".ripplo","debug");await(await Ct(n,{withFileTypes:!0}).catch(()=>[])).filter(i=>i.isDirectory()).map(i=>i.name).filter(i=>!i.startsWith("replay-")&&!i.startsWith("explore-")&&!ln(ee.join(n,i,ce))&&ln(ee.join(n,i,"behavior.jsonl"))).reduce((i,a)=>i.then(()=>or({config:e,debugDir:n,runId:a}).catch(()=>{})),Promise.resolve(void 0))}import{fork as Dt}from"child_process";import cn from"os";import{CancellationTokenSource as un,ResponseError as pn}from"vscode-jsonrpc/node";function fn(e,r){return()=>{let n=Dt(e,["run-worker"],{cwd:r,detached:!0,stdio:["ignore","inherit","inherit","ipc"]});return{connection:Ye(n),kill:()=>{At(n)},onExit:o=>{n.once("exit",o)}}}}function mn(e){let r={closed:!1,devSessionId:e.devSessionId,lockfileProvider:e.lockfileProvider,nextId:0,onProgress:e.onProgress,size:e.initialSize,spawn:e.spawn,targetGeneration:e.targetGeneration,waiters:[],workers:[]};return hn(r),{close:async()=>{r.closed=!0,await Promise.all([...r.workers].map(n=>re(n,r)))},execute:(n,o)=>Ht(n,o,r),exploreTrail:(n,o)=>Wt(n,o,r),routeSpan:(n,o)=>{let t=r.workers.find(i=>i.runId===n);t?.worker.connection.sendNotification(Je,{runId:n,span:o})},setSize:n=>{$t(n,r)},updateSession:n=>{r.devSessionId=n.devSessionId,r.targetGeneration=n.targetGeneration}}}function At(e){let r=e.pid;if(r!=null)try{process.kill(-r,"SIGKILL")}catch{e.kill("SIGKILL")}}var Lt=1e4,qt=1e4,yn=-32800;async function Ht(e,r,n){let o=await gn(n);if(o.runId=e.runId,!o.alive)return G(o,n),{outcome:{detail:"worker-exit",kind:"error"},serverNotified:!1};let t=new un,i=()=>{t.cancel()};r.aborted&&t.cancel(),r.addEventListener("abort",i,{once:!0});try{let a=await o.worker.connection.sendRequest(Be,e,t.token),l=Ne.safeParse(a);return l.success?l.data:{outcome:{detail:"bad-outcome-frame",kind:"error"},serverNotified:!1}}catch(a){return Ot(a,o)}finally{r.removeEventListener("abort",i),t.dispose(),G(o,n)}}async function gn(e){let r=e.workers.find(n=>n.alive&&n.runId===void 0);if(r!=null)return r.runId="pending",await r.ready,r;if(e.workers.length<e.size){let n=Sn(e);return n.runId="pending",await n.ready,n}return new Promise(n=>{e.waiters.push(o=>{o.runId="pending",n(o)})})}function Sn(e){let r=e.spawn(),n={resolve:()=>{}},o={alive:!0,id:e.nextId,ready:new Promise(t=>{n.resolve=t,r.connection.onNotification(ze,t)}),runId:void 0,worker:r};return e.nextId+=1,r.connection.onRequest(Ke,()=>e.lockfileProvider()),r.connection.onNotification(Ve,t=>{let i=Ge.safeParse(t);i.success&&e.onProgress(i.data.runId,i.data.signal)}),r.onExit(()=>{o.alive=!1,e.workers=e.workers.filter(t=>t!==o),r.connection.dispose(),n.resolve()}),e.workers.push(o),o}function G(e,r){if(e.runId=void 0,!e.alive||r.closed)return;if(r.workers.length>r.size){re(e,r);return}let n=r.waiters.shift();n?.(e)}async function re(e,r){if(r.workers=r.workers.filter(t=>t!==e),!e.alive)return;let n=new Promise(t=>{e.worker.onExit(t)});await e.ready,await e.worker.connection.sendNotification(Xe).catch(()=>{});let o=setTimeout(()=>{e.worker.kill()},Lt);await n,clearTimeout(o)}function Ot(e,r){return e instanceof pn&&e.code===yn?{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 Wt(e,r,n){let o=await gn(n);if(o.runId="explore",!o.alive)return G(o,n),{error:{detail:"worker-dead",source:"transport"},kind:"error"};let t=new un,i={cancel:()=>{}},a=()=>{t.cancel();let l=setTimeout(()=>{o.worker.kill()},qt);i.cancel=()=>{clearTimeout(l)}};r.aborted&&a(),r.addEventListener("abort",a,{once:!0});try{let l=await o.worker.connection.sendRequest(Qe,{assign:e,currentTargetGeneration:n.targetGeneration,devSessionId:n.devSessionId},t.token),d=Re.safeParse(l);return d.success?d.data:{error:{detail:"bad-result",source:"transport"},kind:"error"}}catch(l){return Mt(l)}finally{i.cancel(),r.removeEventListener("abort",a),t.dispose(),G(o,n)}}function Mt(e){return e instanceof pn&&e.code===yn?{kind:"aborted",ranCount:0}:{error:{detail:e instanceof Error?e.message.slice(0,120):"unknown",source:"transport"},kind:"error"}}function $t(e,r){r.size=e,e>cn.availableParallelism()&&s.warn({cores:cn.availableParallelism(),size:e},"worker pool size exceeds available cores");let n=r.workers.filter(t=>t.alive&&t.runId===void 0),o=r.workers.length-e;n.slice(0,Math.max(0,o)).forEach(t=>{re(t,r)}),hn(r)}function hn(e){e.closed||Array.from({length:Math.max(0,e.size-e.workers.length)}).forEach(()=>{Sn(e)})}var zt=6e4,kn=500,Bt=15e3,Kt=wn(`
|
|
149
|
+
mutation HeartbeatDevSessionWatch($id: String!, $teleportProtocolVersion: Int!) {
|
|
150
|
+
heartbeatDevSession(id: $id, teleportProtocolVersion: $teleportProtocolVersion) {
|
|
151
|
+
__typename
|
|
152
|
+
... on DevSession {
|
|
153
|
+
id
|
|
154
|
+
}
|
|
155
|
+
... on DevSessionEndedError {
|
|
156
|
+
message
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
`),Qt=wn(`
|
|
161
|
+
query WatchLocalConcurrency {
|
|
162
|
+
currentUser {
|
|
163
|
+
id
|
|
164
|
+
maxLocalConcurrentRuns
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
`);async function Zs({exploreDebug:e}){ui();let r=di(process.cwd()),n=r.cwd,o=Ft(),t=ii(n),i={current:null},a={handler:()=>{}},l=tn({config:r,onChanged:()=>{a.handler()}}),d={handler:()=>{}},c=si(),u=Lr(),f=nr({config:r,cwd:n,executor:l.current,ready:c.promise,explorationStatus:()=>i.current?.status()??Jt(),onShutdownRequest:()=>{d.handler()},sseHealth:()=>u.snapshot()}),y=await li({cwd:n,ipc:f,releasePid:t}),N=await I(n);N.isErr()&&(process.stderr.write(`ripplo: ${D(N.error)}
|
|
168
|
+
`),process.exit(1));let xn=N.value,w=await ri({config:r,synchronize:()=>Le({config:r,cwd:n,lockfile:xn})}),ne=await h(n);ne!=null&&er(ne);let g={devSessionId:w.devSessionId,targetGeneration:vn({devSessionId:w.devSessionId,nonce:o})},bn=Dr({config:r,cwd:n});R({cwd:n,paused:w.hooksPaused});let oe=De(n);oe!=null&&s.info("watching branch %s in %s",oe,n);let Rn=_t({fetchFn:Ar(),headers:{Authorization:`Bearer ${r.token}`},retry:fr,retryAttempts:1/0,url:`${r.ripploServerUrl}/graphql`});dn({config:r,cwd:n}).catch(()=>{});let x=await oi({config:r,devSessionId:g.devSessionId,ipc:f,targetGeneration:g.targetGeneration}),E=Vt({config:r,exploreDebug:e,pool:x,currentSession:()=>g,executorIsLocal:()=>l.current()==="local"});i.current=E,a.handler=E.notifyQueueChange;let Pn=await Yt({cwd:n,pool:x}),te=Pr({claim:f.claim,config:r,devSessionId:w.devSessionId,executorSwitch:l,exploration:E,pool:x,sseClient:Rn,sseHealth:u,onSynchronized:ie=>{g.devSessionId=ie.devSessionId,g.targetGeneration=vn({devSessionId:ie.devSessionId,nonce:o}),x.updateSession(g)}}),En=ei({config:r,session:te}),In=ci();c.resolve(),await Oe("daemon_started"),Zt(w.devSessionId),sn({config:r,executorSwitch:l,exploration:E,pool:x,releasePid:t,session:te,shutdownRef:d,socketHandle:y,spanReceiver:Pn,stops:[En,In,bn]}),await new Promise(()=>{})}function Jt(){return{explorer:{kind:"off"},exploring:0,progress:{attempts:0,findings:0}}}function Vt({config:e,currentSession:r,executorIsLocal:n,exploreDebug:o,pool:t}){return Br({appUrl:e.appUrl,cwd:e.cwd,executorIsLocal:n,onPlannerTrace:o?Xt:void 0,executeTrail:(i,a)=>t.exploreTrail(i,a),leaseOrdinal:()=>ar({config:e,count:1,devSessionId:r().devSessionId}),report:i=>{ir({attempts:i.attempts,config:e,devSessionId:r().devSessionId,findings:i.findings,trail:tr(i.result)}).catch(a=>{s.warn({error:a},"exploration progress report failed")})},reportUnhealthy:()=>{sr(e,r().devSessionId).catch(i=>{s.warn({error:i},"exploration unhealthy report failed")})},targetGeneration:()=>r().targetGeneration})}function vn({devSessionId:e,nonce:r}){return{kind:"dev-session",value:`${e}:${r}`}}function Xt(e){we(e.trace).forEach(r=>{s.info({...r,explorerEvent:r.kind},"explorer planner")}),e.kind==="no-candidate"&&s.info({explorerEvent:"no-candidate",reason:e.reason},"explorer planner")}function Yt({cwd:e,pool:r}){return Ie({localDir:jt.join(e,".ripplo",".local"),writePortFile:!0,onRrwebBatch:()=>{},onSpan:n=>{let o=n.attributes["ripplo.run"];o!=null&&r.routeSpan(o,n)}})}function Zt(e){process.stdout.write(`${Fe({devSessionId:e,version:se()})}
|
|
169
|
+
`)}function ei({config:e,session:r}){let n=async()=>{try{let t=await p({config:e,document:Kt,variables:{id:r.getId(),teleportProtocolVersion:2}});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))}},o=setInterval(()=>{n()},Bt);return()=>{clearInterval(o)}}function ri({config:e,synchronize:r}){let n=e.ripploServerUrl.includes("localhost")||e.ripploServerUrl.includes("127.0.0.1");return Gt(async()=>{try{return await r()}catch(o){if(ni({config:e,error:o}),!(o instanceof le)){let t=o instanceof Error?o.message:String(o);throw s.error("initial sync failed: %s",t),new Nt(t)}throw o}},{factor:2,maxTimeout:n?2e3:1e4,minTimeout:n?100:1e3,retries:1/0,onFailedAttempt:({attemptNumber:o,error:t})=>{s.warn("initial sync attempt %d failed \u2014 retrying: %s",o,t.message)}})}function ni({config:e,error:r}){let n=de(r);n==="UNAUTHENTICATED"&&(process.stderr.write(`ripplo: ${Ue()}
|
|
170
|
+
`),process.exit(1)),n==="FORBIDDEN"&&(process.stderr.write(`ripplo: ${$e({projectId:e.projectId,serverUrl:e.ripploServerUrl})}
|
|
171
|
+
`),process.exit(1))}async function oi({config:e,devSessionId:r,ipc:n,targetGeneration:o}){let t=await fi(e);return ti({cwd:e.cwd,devSessionId:r,initialConcurrency:t,onProgress:n.progress,targetGeneration:o})}function ti({cwd:e,devSessionId:r,initialConcurrency:n,onProgress:o,targetGeneration:t}){return mn({devSessionId:r,initialSize:n,onProgress:o,spawn:fn(mi(),e),targetGeneration:t,lockfileProvider:async()=>{let i=await S(e);if(i.isErr())return{unavailable:`daemon-load-failed:${i.error.kind}`};let a=await Ce(e,i.value);return{lockfileJson:ye(ge,a)}}})}function ii(e){try{return fe({cwd:e,onCompromised:ai})}catch(r){throw r instanceof pe&&(process.stderr.write(`${je({cwd:r.cwd,pid:r.pid})}
|
|
172
|
+
`),process.exit(1)),r}}function ai(){s.error("daemon lock compromised; shutting down"),process.stderr.write(`${_e()}
|
|
173
|
+
`),process.exit(1)}function si(){let e={handler:()=>{}};return{promise:new Promise(n=>{e.handler=n}),resolve:()=>{e.handler()}}}async function li({cwd:e,ipc:r,releasePid:n}){return(await $r({cwd:e,onConnection:r.handleConnection})).match(t=>t,t=>{process.stderr.write(`${Me(t)}
|
|
174
|
+
`),n(),process.exit(1)})}function di(e){return m(e).match(r=>r,r=>{process.stderr.write(`${He(r)}
|
|
175
|
+
`),process.exit(1)})}function ci(){z({maxRuns:kn});let e=setInterval(()=>{z({maxRuns:kn})},zt);return()=>{clearInterval(e)}}function ui(){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 pi=4;async function fi(e){try{let n=(await p({config:e,document:Qt,variables:void 0})).currentUser?.maxLocalConcurrentRuns;if(n!=null)return L(n),n}catch(r){s.warn({err:r},"failed to fetch local concurrency setting; using default")}return pi}function mi(){let e=process.argv[1];if(e==null)throw new Error("cli entry unavailable");return e}export{Zs as runDaemon};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-
|
|
4
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-Q2TF5WLS.js";import"./chunk-BIB4JJKD.js";import"./chunk-ZSD6QDYB.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as renderDaemonBindError,g as renderDaemonLockCompromised,e as renderDaemonLockHeld,d as renderDaemonReady,h as renderDaemonStatus,f as renderDaemonStopResult,j as renderDaemonVersionNote,i as renderExplorationProgress,c as renderNotSignedIn,b as renderProjectAccessDenied,k as wireOutcome};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{j as a,k as b,l as c,m as d,n as e}from"./chunk-
|
|
4
|
+
import{j as a,k as b,l as c,m as d,n as e}from"./chunk-RLB66SU3.js";import"./chunk-ZSD6QDYB.js";import"./chunk-KMZ3L5YA.js";export{a as LOCKFILE_RELATIVE_PATH,d as loadRipplo,b as loadRipploCached,c as loadRipploCachedWithFingerprint,e as ripploFingerprint};
|
package/dist/hook.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{a as r,c as s}from"./chunk-
|
|
4
|
+
import{a as r,c as s}from"./chunk-W3CXPVVB.js";import{a as i}from"./chunk-R4ZTRVDQ.js";import{c as o}from"./chunk-FEHVIHVA.js";import"./chunk-KOKEEAEF.js";import{b as e}from"./chunk-HEOMRXZE.js";import"./chunk-KMZ3L5YA.js";r();o(process.cwd());e(i());s(process.argv[2]??"").catch(async t=>{let{renderTopLevelError:p}=await import("./cli-error-UYWIDE4L.js");process.stderr.write(`${p(t)}
|
|
5
5
|
`),process.exit(1)});
|