ripplo 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-6JXOIP2T.js → chunk-33X7JOIS.js} +1 -1
- package/dist/{chunk-PWDBRLJP.js → chunk-66ILXPAB.js} +1 -1
- package/dist/chunk-755GNXZM.js +61 -0
- package/dist/{chunk-U4LFIMDP.js → chunk-D3X4WMLM.js} +1 -1
- package/dist/{chunk-ULIHURY6.js → chunk-E52EBMZ6.js} +1 -1
- package/dist/{chunk-75T33SK5.js → chunk-EJGLDNQQ.js} +1 -1
- package/dist/{chunk-EOBWMMVC.js → chunk-EWF5XUHE.js} +1 -1
- package/dist/{chunk-56MARCN3.js → chunk-HOPUAKLV.js} +1 -1
- package/dist/{chunk-R3FZ2JEW.js → chunk-LGXGJCWO.js} +1 -1
- package/dist/{chunk-LEYSGMW2.js → chunk-LKSPG7VE.js} +1 -1
- package/dist/{chunk-GTB7NYDE.js → chunk-OJP65ZCN.js} +1 -1
- package/dist/{chunk-NXKOUVSC.js → chunk-PSLQ3HRP.js} +5 -5
- package/dist/{chunk-Q7FIZGKZ.js → chunk-RROQ7ULM.js} +1 -1
- package/dist/{chunk-BQ25IGJS.js → chunk-TM6CZ34R.js} +1 -1
- package/dist/{chunk-3ZQRLG7C.js → chunk-U3542BWK.js} +1 -1
- package/dist/{chunk-B5HDXHPI.js → chunk-UNNCONOS.js} +2 -2
- package/dist/{chunk-ZGWV564Y.js → chunk-X7ZHRVMR.js} +1 -1
- package/dist/{chunk-AVBTPZUU.js → chunk-ZEZ5O7PZ.js} +1 -1
- package/dist/chunk-ZPJ6MRKF.js +83 -0
- package/dist/{cli-error-N7X2CREI.js → cli-error-PMT64ZXX.js} +1 -1
- package/dist/{compile-write-XMVD5PX2.js → compile-write-63UB2DA5.js} +1 -1
- package/dist/daemon-K6OMN2RY.js +175 -0
- package/dist/{daemon-DARMT5AV.js → daemon-RKXMF66W.js} +1 -1
- package/dist/{dsl-loader-SSXMC5EE.js → dsl-loader-JKBFRYTG.js} +1 -1
- package/dist/hook.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{plan-reminder-K7HOFGJN.js → plan-reminder-25WKHV6G.js} +1 -1
- package/dist/{post-edit-OI6DDU25.js → post-edit-NNQDVLZX.js} +1 -1
- package/dist/post-edit-analyze-TG4BPWTP.js +4 -0
- package/dist/{post-edit-flag-stubs-IKIH5DAH.js → post-edit-flag-stubs-OCF5DCCS.js} +1 -1
- package/dist/{pre-edit-IOWNUOZY.js → pre-edit-4BCNZ6ZW.js} +1 -1
- package/dist/{pre-edit-watch-gate-N7FI5HBA.js → pre-edit-watch-gate-XGPB5GAF.js} +1 -1
- package/dist/{prompt-submit-ZU466ET5.js → prompt-submit-4ZWKXB6N.js} +1 -1
- package/dist/status-LFD3KLZV.js +4 -0
- package/dist/{stop-enforce-4UUK36YU.js → stop-enforce-J4VZOBMW.js} +1 -1
- package/package.json +4 -4
- package/dist/chunk-NIC2DOQW.js +0 -51
- package/dist/chunk-PVRM4YWS.js +0 -83
- package/dist/daemon-ZUDQ7ERI.js +0 -152
- package/dist/post-edit-analyze-6V5YI3CR.js +0 -4
- package/dist/status-OSHZ3JGU.js +0 -4
package/dist/daemon-ZUDQ7ERI.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
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 rr,C as nr,D as L,H as or,I as tr,J as ir,K as ar,M as sr,N as lr,P as B,Q as q,R as dr,S as cr,T as K,e as We,i as _e,j as Ge,k as Ne,l as ze,m as Be,o as Ke,p as Qe,q as Je,r as Ve,s as Xe,u as A,v as D,w as Ye,x as z,y as Ze,z as er}from"./chunk-AVBTPZUU.js";import{a as Me,b as Oe,c as Ue,d as $e,e as je,g as Fe}from"./chunk-6JXOIP2T.js";import{d as qe}from"./chunk-U4LFIMDP.js";import{b as He}from"./chunk-PWDBRLJP.js";import{a as Ae,c as De,d as Le,e as h}from"./chunk-NIC2DOQW.js";import{a as C}from"./chunk-EOBWMMVC.js";import{c as y}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 T}from"./chunk-GTB7NYDE.js";import{H as ve,J as we,K as xe,N as I,O as be,P as Re,S as Ee,T as Pe,Y as Ie,ba as Te,n as ke}from"./chunk-PVRM4YWS.js";import{k as S,l as he,m as P}from"./chunk-BQ25IGJS.js";import{Ma as Se,U as ye,sa as ge}from"./chunk-NXKOUVSC.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 f,f as s,g as ce,h as N,i as ue}from"./chunk-C7SV6AR2.js";import"./chunk-HEOMRXZE.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import{randomUUID as Et}from"crypto";import Pt from"path";import{createClient as It}from"graphql-sse";import Tt,{AbortError as Ct}from"p-retry";import{graphql as Sn}from"gql.tada";import{graphql as En}from"gql.tada";import{print as Pn}from"graphql";async function ur({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 L({config:e,ownerToken:null,reason:`lockfile:${c.error.kind}`,runId:t}),{kind:"dispatch-error",reason:{detail:`lockfile:${c.error.kind}`,type:"generic"}};let u=Rn(c.value,{testSlug:a,workflowSlug:d});if(u==null)return await L({config:e,ownerToken:null,reason:`no-test:${d}/${a}`,runId:t}),{kind:"dispatch-error",reason:{detail:`no-test:${d}/${a}`,type:"generic"}};let p=await A({headed:n,workClass:l,task:()=>o.execute({headed:n,runId:t,testRef:u},i)});return!p.serverNotified&&p.outcome.kind==="error"&&await L({config:e,ownerToken:null,reason:p.outcome.detail,runId:t}),p.outcome}function Rn(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 In=6e4,Tn=En(`
|
|
5
|
-
subscription RunRequestedWatch($devSessionId: String!) {
|
|
6
|
-
runRequested(devSessionId: $devSessionId) {
|
|
7
|
-
runId
|
|
8
|
-
testSlug
|
|
9
|
-
workflowId
|
|
10
|
-
workflowSlug
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
`);async function pr(e){let r=Math.min(1e3*2**e,In)+qn();await new Promise(n=>setTimeout(n,r))}function fr({claim:e,cwd:r,devSessionId:n,pool:o,sseClient:t,sseHealth:i}){let a=new Set,l=An(r);return t.subscribe({query:Pn(Tn),variables:{devSessionId:n}},{complete:Cn,error:d=>{let c=d instanceof Error?d.message:String(d);i.markUnhealthy(c),s.error({err:d},"runRequested subscription failed")},next:d=>{Dn({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 Cn(){}function An(e){return ae(e),{config:y(e).match(r=>r,r=>{s.error({failure:r},"failed to load env for run dispatch")}),cwd:e}}function Dn({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=Ln(e(n.runId),n);i.started(),ur({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 Ln(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:er(e.token),workClass:"p1-cli",finished:n=>{e.finished(r.runId,n)},started:()=>{e.started(r.runId)}}}function qn(){return Math.floor(Math.random()*2700)+300}import{graphql as Q}from"gql.tada";import{print as Hn}from"graphql";var Wn=Q(`
|
|
15
|
-
subscription TeleportRequestedWatch($devSessionId: String!) {
|
|
16
|
-
teleportRequested(devSessionId: $devSessionId) {
|
|
17
|
-
runId
|
|
18
|
-
stepIndex
|
|
19
|
-
kind
|
|
20
|
-
testSlug
|
|
21
|
-
workflowSlug
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
`),Mn=Q(`
|
|
25
|
-
query TeleportRunRepro($id: String!) {
|
|
26
|
-
run(id: $id) {
|
|
27
|
-
id
|
|
28
|
-
reproJson
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
`),On=Q(`
|
|
32
|
-
mutation ReportTeleportResult($devSessionId: String!, $runId: String!, $status: String!) {
|
|
33
|
-
reportTeleportResult(devSessionId: $devSessionId, runId: $runId, status: $status)
|
|
34
|
-
}
|
|
35
|
-
`);function mr({cwd:e,devSessionId:r,sseClient:n}){let o=new Set,t=n.subscribe({query:Hn(Wn),variables:{devSessionId:r}},{complete:Un,error:i=>{s.error({err:i},"teleportRequested subscription failed")},next:i=>{$n({cwd:e,devSessionId:r,event:i.data?.teleportRequested,running:o})}});return()=>{o.forEach(i=>{i.abort()}),o.clear(),t()}}function Un(){}function $n({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}){let t=d=>Fn({cwd:e,devSessionId:r,runId:n.runId,status:d}),i=await _n(e,n);if(i==null){s.warn({runId:n.runId},"teleport could not resolve target"),await t("unplannable");return}process.stdout.write(`ripplo: teleport ${Nn(n)} step ${String(n.stepIndex+1)}
|
|
36
|
-
`);let l=await sr({cwd:e,onReady:()=>{t("opened")},signal:o,step:n.stepIndex+1,target:i});l.kind==="done"&&l.result.kind==="handed-over"||(s.warn({kind:l.kind,runId:n.runId},"teleport could not open"),await t(l.kind==="unplannable"?"unplannable":"error"))}async function Fn({cwd:e,devSessionId:r,runId:n,status:o}){let t=y(e).match(i=>i,()=>null);t!=null&&await f({config:t,document:On,variables:{devSessionId:r,runId:n,status:o}}).catch(()=>null)}async function _n(e,r){if(r.kind==="explore"){let n=await Gn(e,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 Gn(e,r){let n=y(e).match(i=>i,()=>null);if(n==null)return null;let o=await f({config:n,document:Mn,variables:{id:r}}).catch(()=>null);if(o?.run?.reproJson==null)return null;let t=I(o.run.reproJson);return t.kind==="valid"?t.repro:null}function Nn(e){return e.kind==="explore"?"explore finding":`${String(e.workflowSlug)}/${String(e.testSlug)}`}import H from"fs";import zn from"p-retry";import{graphql as x}from"gql.tada";import{print as M}from"graphql";var Bn=x(`
|
|
37
|
-
query DaemonExploration($devSessionId: String!) {
|
|
38
|
-
exploration(devSessionId: $devSessionId) {
|
|
39
|
-
active
|
|
40
|
-
localWorkers
|
|
41
|
-
maxTrailLength
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
`),Kn=x(`
|
|
45
|
-
subscription WatchExplorationChanged($devSessionId: String!) {
|
|
46
|
-
explorationChanged(devSessionId: $devSessionId) {
|
|
47
|
-
exploration {
|
|
48
|
-
active
|
|
49
|
-
localWorkers
|
|
50
|
-
maxTrailLength
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`);function yr({config:e,devSessionId:r,exploration:n,lifetime:o,sseClient:t}){return zn(()=>Qn({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(Kn),variables:{devSessionId:r}},{complete:U,error:i=>{O({error:i,stream:"explorationChanged"})},next:i=>{gr(n,i.data?.explorationChanged.exploration)}})}async function Qn({config:e,devSessionId:r,exploration:n,lifetime:o}){if(W(o))return;let t=await f({config:e,document:Bn,variables:{devSessionId:r}});W(o)||gr(n,t.exploration)}function gr(e,r){r!=null&&e.setDesired({active:r.active,localWorkers:r.localWorkers,maxTrailLength:r.maxTrailLength})}var Jn=x(`
|
|
55
|
-
subscription HooksPausedWatch($projectId: String!) {
|
|
56
|
-
hooksPausedRequested(projectId: $projectId) {
|
|
57
|
-
paused
|
|
58
|
-
projectId
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
`),Vn=x(`
|
|
62
|
-
subscription WatchLocalConcurrencyChanged {
|
|
63
|
-
myMaxLocalConcurrentRunsChanged
|
|
64
|
-
}
|
|
65
|
-
`);function Sr({pool:e,sseClient:r}){return r.subscribe({query:M(Vn)},{complete:U,error:n=>{O({error:n,stream:"myMaxLocalConcurrentRunsChanged"})},next:n=>{let o=n.data?.myMaxLocalConcurrentRunsChanged;o!=null&&(D(o),e.setSize(o))}})}var Xn=x(`
|
|
66
|
-
subscription WatchExecutorChangeRequested($devSessionId: String!) {
|
|
67
|
-
executorChangeRequested(devSessionId: $devSessionId) {
|
|
68
|
-
executor
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
`);function hr({config:e,devSessionId:r,lifetime:n,sseClient:o,switcher:t}){return t.connect(r),Yn({config:e,lifetime:n,switcher:t}),Zn({devSessionId:r,sseClient:o,switcher:t})}async function Yn({config:e,lifetime:r,switcher:n}){if(W(r))return;let o=await lr(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 Zn({devSessionId:e,sseClient:r,switcher:n}){return r.subscribe({query:M(Xn),variables:{devSessionId:e}},{complete:U,error:o=>{O({error:o,stream:"executorChangeRequested"})},next:o=>{let t=o.data?.executorChangeRequested?.executor;t!=null&&n.request(t)}})}function kr({cwd:e,projectId:r,sseClient:n}){return n.subscribe({query:M(Jn),variables:{projectId:r}},{complete:U,error:o=>{O({error:o,stream:"hooksPausedRequested"})},next:o=>{let t=o.data?.hooksPausedRequested?.paused;t!=null&&b({cwd:e,paused:t})}})}function O({error:e,stream:r}){s.error({error:e},"%s subscription failed",r)}function U(){}function b({cwd:e,paused:r}){let n=me(e);if(r&&!H.existsSync(n)){H.writeFileSync(n,"");return}!r&&H.existsSync(n)&&H.unlinkSync(n)}function vr({initialId:e,onSynchronized:r,subscribe:n,synchronize:o}){let t=e,i=null,a=!1,l=d();function d(){let p=new AbortController,m=n({devSessionId:t,lifetime:p.signal});return()=>{p.abort(),m()}}async function c(p){let m=await o(p);m==null||a||(l(),t=m.devSessionId,r(m),l=d())}function u(p){return a?Promise.resolve():(i!=null||(i=c(p).finally(()=>{i=null})),i)}return{getId:()=>t,reregister:()=>u("dev session ended server-side"),stop:()=>{a||(a=!0,l())}}}function wr({claim:e,config:r,devSessionId:n,executorSwitch:o,exploration:t,onSynchronized:i,pool:a,sseClient:l,sseHealth:d}){return vr({initialId:n,onSynchronized:c=>{i(c),b({cwd:r.cwd,paused:c.hooksPaused})},subscribe:({devSessionId:c,lifetime:u})=>eo({claim:e,config:r,devSessionId:c,executorSwitch:o,exploration:t,lifetime:u,pool:a,sseClient:l,sseHealth:d}),synchronize:c=>ro({config:r,reason:c,sseHealth:d})})}function eo({claim:e,config:r,devSessionId:n,executorSwitch:o,exploration:t,lifetime:i,pool:a,sseClient:l,sseHealth:d}){let c=[hr({config:r,devSessionId:n,lifetime:i,sseClient:l,switcher:o}),kr({cwd:r.cwd,projectId:r.projectId,sseClient:l}),Sr({pool:a,sseClient:l}),yr({config:r,devSessionId:n,exploration:t,lifetime:i,sseClient:l}),fr({claim:e,cwd:r.cwd,devSessionId:n,pool:a,sseClient:l,sseHealth:d}),mr({cwd:r.cwd,devSessionId:n,sseClient:l})];return()=>{c.forEach(u=>{u()})}}async function ro({config:e,reason:r,sseHealth:n}){n.markUnhealthy(r);let o=await P(e.cwd);return o.isErr()?(s.error("re-register: compile failed: %s",C(o.error)),null):De({config:e,cwd:e.cwd,lockfile:o.value})}import{createHash as no}from"crypto";import xr from"fs";function br(){return J===void 0&&(J=oo()),J}var J;function oo(){let e=process.argv[1];if(e==null)return null;try{let r=xr.readFileSync(xr.realpathSync(e));return no("sha256").update(r).digest("hex")}catch{return null}}import{graphql as Rr}from"gql.tada";var to=Rr(`
|
|
72
|
-
query OpenFindingsForRetire($projectId: String!) {
|
|
73
|
-
exploreFindings(projectId: $projectId, status: open) {
|
|
74
|
-
signature
|
|
75
|
-
reproRun {
|
|
76
|
-
reproJson
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
`),io=Rr(`
|
|
81
|
-
mutation RetireStaleFinding($projectId: String!, $signature: String!) {
|
|
82
|
-
retireStaleFinding(projectId: $projectId, signature: $signature)
|
|
83
|
-
}
|
|
84
|
-
`);async function Er({config:e,cwd:r,lockfile:n}){let t=(await f({config:e,document:to,variables:{projectId:e.projectId}})).exploreFindings,i=await T(r,n);if(i.isErr())return s.info({block:i.error.kind},"skipping finding retire until next compile"),!1;let a=ao(t,i.value);return a.length===0||(await Promise.all(a.map(l=>lo(e,l))),s.info({count:a.length},"retired findings whose trail no longer replays")),!0}function ao(e,r){return e.map(n=>so(n,r)?n.signature:null).filter(n=>n!=null)}function so(e,r){let n=e.reproRun?.reproJson;if(n==null)return!0;let o=I(n);return o.kind==="rejected"?!0:Te(r,o.repro).kind==="unplannable"}function lo(e,r){return f({config:e,document:io,variables:{projectId:e.projectId,signature:r}})}var co=6e4;function Pr(e){let r={retiredKey:null,running:!1,stopped:!1},n=async()=>{if(!(r.running||r.stopped)){r.running=!0;try{r.retiredKey=await uo(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,co))},0)};return()=>{r.stopped=!0,clearTimeout(o.timer)}}async function uo({config:e,cwd:r},n){let o=await h(r),t=br();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 Er({config:e,cwd:r,lockfile:a.value})?i:n}import{Agent as po,fetch as fo}from"undici";var mo=3e4;function Ir(e=mo){let r=new po({bodyTimeout:e});return(n,o)=>fo(n,{...o,dispatcher:r})}function Tr(){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 yo from"fs";import Lr from"net";import{err as qr,ok as go}from"neverthrow";async function Hr({cwd:e,onConnection:r}){ue(e);let n=qe(e),o=await Cr({onConnection:r,socketPath:n});return o.isOk()||o.error.kind!=="stale-candidate"?o.map(Ar(n)).mapErr(Dr(n)):await So(n)?qr({kind:"already-running",socketPath:n}):(Wr(n),(await Cr({onConnection:r,socketPath:n})).map(Ar(n)).mapErr(Dr(n)))}function So(e){return new Promise(r=>{let n=Lr.connect(e);n.once("connect",()=>{n.destroy(),r(!0)}),n.once("error",()=>{r(!1)})})}async function Cr(e){let r=await ho(e);return r.kind==="listening"?go(r.server):qr(r.error)}function ho({onConnection:e,socketPath:r}){return new Promise(n=>{let o=Lr.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 Ar(e){return r=>({socketPath:e,close:()=>{r.close(),Wr(e)}})}function Wr(e){yo.rmSync(e,{force:!0})}function Dr(e){return r=>r.kind==="stale-candidate"?{kind:"already-running",socketPath:e}:{kind:"bind-failed",message:r.message}}import{randomUUID as Do}from"crypto";function Mr(){return{attempts:0,backoffUntil:0,consecutiveErrors:0,coverageWaiting:!1,desired:{active:!1,localWorkers:dr,maxTrailLength:cr},executorLocal:!0,findings:0,lastUnhealthyReportAt:null,loading:!1,lockfile:{kind:"loading"},prevInteractiveActive:0,stopped:!1,trails:new Map}}function Or(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 bo(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 Ro(e,r);case"stopped":return{effects:[{ids:[...e.trails.keys()],kind:"abort"}],state:{...e,stopped:!0,trails:new Map}}}}function Ur(e,r,n){return K($r(e),jr(e,r,n)).health}function V(e,r,n){let o=xo(e,r,n),t={...e,...o,prevInteractiveActive:n.active},i=K($r(t),jr(t,r,n)),a=t.lockfile.kind!=="ready"&&!t.loading;return{effects:[...ko(a),...vo(i.abortIds),...wo({count:i.launchCount,maxTrailLength:t.desired.maxTrailLength})],state:{...t,loading:t.loading||a}}}function ko(e){return e?[{kind:"load"}]:[]}function vo(e){return e.length>0?[{ids:e,kind:"abort"}]:[]}function wo({count:e,maxTrailLength:r}){return e>0?[{count:e,kind:"launch",maxTrailLength:r}]:[]}function xo(e,r,n){return n.active<e.prevInteractiveActive?{backoffUntil:Math.max(e.backoffUntil,r+q)}:{backoffUntil:e.backoffUntil}}function bo(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 Ro(e,r){let n=new Map([...e.trails].filter(([i])=>i!==r.id)),o=Eo({...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 Eo(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+q),consecutiveErrors:0,coverageWaiting:xe(r.reason)}};case"app-unreachable":return X({now:n,state:e,subject:"app-unreachable"});case"error":return Po(e,r.error,n);case"done":return To(e,r.result)}}function Po(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:Io(r)})}function Io(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 To(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 Co=6,Ao=2e4;function X({now:e,state:r,subject:n}){let o=r.consecutiveErrors+1,t=Math.max(r.backoffUntil,e+q);if(o<Co)return{effects:[],state:{...r,backoffUntil:t,consecutiveErrors:o}};let i=r.lastUnhealthyReportAt==null||e-r.lastUnhealthyReportAt>=Ao;return{effects:i?[{kind:"report-unhealthy",subject:n}]:[],state:{...r,backoffUntil:t,consecutiveErrors:o,lastUnhealthyReportAt:i?e:r.lastUnhealthyReportAt}}}function $r(e){return{enabled:e.desired.active,executorLocal:e.executorLocal,maxTrailLength:e.desired.maxTrailLength,workers:e.desired.localWorkers}}function jr(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 _r(e){let r=Lo(e),n=Wo(()=>{r.dispatch(R())});return z(()=>{r.dispatch(R())}),r.dispatch(R()),{notifyQueueChange:()=>{r.dispatch({kind:"executor-changed",local:e.executorIsLocal()}),r.dispatch(R())},setDesired:o=>{r.dispatch({desired:o,kind:"desired-changed",now:Date.now(),queue:$()})},status:()=>Ho(r.current()),stop:()=>{n(),z(null),r.dispatch({kind:"stopped"})}}}function Lo(e){let r={draining:!1,planning:Promise.resolve(),queue:[],runtime:qo(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=Or(r.runtime.state,a);n(d=>({...d,state:l.state})),l.effects.forEach(d=>{Mo({commit:n,dispatch:o,effect:d,params:e,queuePlanning:t,runtime:r.runtime,current:()=>r.runtime})}),i()};return{dispatch:o,current:()=>r.runtime}}function qo(e){return{controllers:new Map,prepared:null,reservations:new Map,state:{...Mr(),executorLocal:e.executorIsLocal()}}}function Ho(e){return{explorer:Ur(e.state,Date.now(),$()),exploring:e.state.trails.size,progress:{attempts:e.state.attempts,findings:e.state.findings}}}function $(){let e=Ye();return{active:e.active,headedActive:e.headedActive,poolSize:e.poolSize,queued:e.queued}}function R(){return{kind:"tick",now:Date.now(),queue:$()}}function Wo(e){let r={timer:setTimeout(function n(){e(),r.timer=setTimeout(n,B)},B)};return()=>{clearTimeout(r.timer)}}function Mo({commit:e,current:r,dispatch:n,effect:o,params:t,queuePlanning:i,runtime:a}){switch(o.kind){case"load":case"reload":{Uo(t.cwd,a.prepared).then(({outcome:l,prepared:d})=>{e(c=>({...c,prepared:d})),n({kind:"load-settled",now:Date.now(),outcome:l}),n(R())});return}case"abort":{o.ids.forEach(l=>{a.controllers.get(l)?.abort()});return}case"launch":{Array.from({length:o.count}).forEach(()=>{let l=Oo({commit:e,dispatch:n});i(()=>jo({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 Oo({commit:e,dispatch:r}){let n=`explore:${Do()}`,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 Uo(e,r){try{return await $o(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 $o(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 T(e,o.value);if(t.isErr())return{outcome:{kind:"blocked",reason:t.error.kind},prepared:null};let i=Ee(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 jo({commit:e,controller:r,dispatch:n,id:o,maxTrailLength:t,params:i,prepared:a,reservedSignatures:l}){if(Fr(r.signal)){k({commit:e,dispatch:n,id:o,settled:{kind:"aborted"}});return}if(a==null){k({commit:e,dispatch:n,id:o,settled:{kind:"crashed",stage:"planning"}});return}let d=await Fo({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){k({commit:e,dispatch:n,id:o,settled:{kind:"crashed",stage:"planning"}});return}if(Fr(r.signal)){k({commit:e,dispatch:n,id:o,settled:{kind:"aborted"}});return}if(i.onPlannerTrace?.(d),d.kind==="no-candidate"){k({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:()=>_o({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=>{k({commit:e,dispatch:n,id:o,settled:u})})}function Fr(e){return e.aborted}async function Fo({maxTrailLength:e,params:r,prepared:n,reservedSignatures:o}){let t=Date.now(),i=await r.leaseOrdinal(),a=await Pe({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 k({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:$(),settled:o})}async function _o({assign:e,params:r,signal:n}){let o=await r.executeTrail(e,n);return o.kind==="aborted"?{kind:"aborted"}:o.kind==="error"?Go(r,o.error):{kind:"done",result:o}}async function Go(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 it}from"gql.tada";import{connect as zo}from"net";import Bo from"ssh2";import{WebSocket as Nr,createWebSocketStream as Ko}from"ws";var No="ripplo-";function Y(e){return Object.entries(e).map(([r,n])=>`${No}${r}.${n}`)}var{Server:Qo,utils:Gr}=Bo;function zr(){let e=Gr.generateKeyPairSync("ed25519"),r=Gr.parseKey(e.private);if(r instanceof Error)throw r;return{fingerprint:r.getPublicSSH().toString("base64"),privateKey:e.private}}function Br(e){return new Promise((r,n)=>{let o={closers:new Set,stopped:!1},t=new Nr(e.relayUrl,Y({grant:e.grant,role:"daemon-control"}));t.on("open",()=>{s.info("cloud-executor relay control up"),r({stop:Jo(t,o)})}),t.on("message",i=>{Vo(e,o,i)}),t.on("close",(i,a)=>{o.stopped||s.warn({code:i,reason:a.toString()},"relay control closed"),tt(e,o)}),t.on("error",i=>{n(i instanceof Error?i:new Error(String(i)))})})}function Jo(e,r){return()=>(r.stopped=!0,r.closers.forEach(n=>{n()}),e.close(),Promise.resolve())}function Vo(e,r,n){let o=Xo(n);o!=null&&Zo(e,r,o.pipeId)}function Xo(e){try{let r=JSON.parse(Yo(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 Yo(e){return Buffer.isBuffer(e)?e.toString("utf8"):Array.isArray(e)?Buffer.concat(e).toString("utf8"):Buffer.from(e).toString("utf8")}function Zo(e,r,n){if(r.stopped)return;let o=new Nr(e.relayUrl,Y({pipeId:n,role:"daemon-data"}));o.on("open",()=>{et(e,r,o)}),o.on("error",t=>{s.warn({err:t},"cloud-executor relay data pipe error")})}function et(e,r,n){let o=Ko(n);o.on("error",()=>{});let t=new Qo({hostKeys:[e.hostKey.privateKey]},a=>{a.on("error",l=>{s.warn({err:l},"cloud-executor ssh connection error")}),a.on("authentication",l=>{nt(l,e.secret)}),a.on("ready",()=>{a.on("tcpip",(l,d,c)=>{ot({accept:l,allowedPorts:e.allowedPorts,deny:d,destPort:c.destPort})})})}),i=()=>{n.close()};r.closers.add(i),n.on("close",()=>r.closers.delete(i)),rt(t,o)}function rt(e,r){e.injectSocket(r)}function nt(e,r){if(e.method==="password"&&e.password===r){e.accept();return}if(e.method==="none"){e.reject(["password"]);return}e.reject()}function ot({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=zo({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 tt(e,r){r.stopped||(r.stopped=!0,r.closers.forEach(n=>{n()}),e.onFatal())}var at=it(`
|
|
85
|
-
mutation EnterCloudMode(
|
|
86
|
-
$devSessionId: String!
|
|
87
|
-
$localUrl: String!
|
|
88
|
-
$engineUrl: String!
|
|
89
|
-
$hostKeyFingerprint: String!
|
|
90
|
-
) {
|
|
91
|
-
enterCloudMode(
|
|
92
|
-
devSessionId: $devSessionId
|
|
93
|
-
localUrl: $localUrl
|
|
94
|
-
engineUrl: $engineUrl
|
|
95
|
-
hostKeyFingerprint: $hostKeyFingerprint
|
|
96
|
-
) {
|
|
97
|
-
__typename
|
|
98
|
-
... on RelaySession {
|
|
99
|
-
generation
|
|
100
|
-
grant
|
|
101
|
-
relayUrl
|
|
102
|
-
secret
|
|
103
|
-
session
|
|
104
|
-
}
|
|
105
|
-
... on DevSessionEndedError {
|
|
106
|
-
message
|
|
107
|
-
}
|
|
108
|
-
... on TunnelNotConfiguredError {
|
|
109
|
-
message
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
`),j=class extends Error{failure;constructor(r){super(r.kind),this.failure=r}};async function Qr({config:e,devSessionId:r,onFatal:n}){let o=zr(),i=(await f({config:e,document:at,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 Br({allowedPorts:[...new Set([Kr(e.appUrl),Kr(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 Kr(e){let r=new URL(e);return r.port.length>0?Number(r.port):r.protocol==="https:"?443:80}var Jr=[1e3,3e3,8e3,15e3];function Vr(){return{attempt:0,desired:"local",devSessionId:null,stopped:!1,tunnel:"down"}}function Xr(e,r){if(e.stopped)return{effects:[],state:e};switch(r.kind){case"requested":return lt(e,r.mode);case"connected":return Z({...e,devSessionId:r.devSessionId},[]);case"tunnel-started":return dt(e);case"tunnel-failed":case"tunnel-fatal":return ct(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 st(e){let r=Math.min(e,Jr.length-1),n=Jr[r];if(n==null)throw new Error("executor retry ladder is empty");return n}function lt(e,r){return r===e.desired?{effects:[],state:e}:Z({...e,attempt:0,desired:r},[{kind:"notify-changed"}])}function Z(e,r){return F(e)&&e.tunnel==="down"&&e.devSessionId!=null?{effects:[...r,{devSessionId:e.devSessionId,kind:"start-tunnel"}],state:{...e,tunnel:"starting"}}:!F(e)&&e.tunnel!=="down"?{effects:[...r,{kind:"stop-tunnel"}],state:{...e,tunnel:"down"}}:{effects:r,state:e}}function F(e){return e.desired==="cloud"&&e.devSessionId!=null&&!e.stopped}function dt(e){return F(e)?{effects:[],state:{...e,attempt:0,tunnel:"up"}}:{effects:[{kind:"stop-tunnel"}],state:{...e,tunnel:"down"}}}function ct(e){let r={...e,tunnel:"down"};return F(r)?{effects:[{delayMs:st(r.attempt),kind:"schedule-retry"}],state:{...r,attempt:r.attempt+1}}:{effects:[],state:r}}function en(e){let r={draining:!1,io:Promise.resolve(),queue:[],retryTimer:null,state:Vr(),tunnel:null},n=o=>{r.queue.push(o),!r.draining&&(r.draining=!0,rn(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 rn(e,r,n){let o=e.queue.shift();if(o==null)return;let t=Xr(e.state,o);e.state=t.state,t.effects.forEach(i=>{ut({cell:e,dispatch:r,effect:i,params:n})}),rn(e,r,n)}function ut({cell:e,dispatch:r,effect:n,params:o}){switch(n.kind){case"start-tunnel":{Yr(e,()=>pt({cell:e,devSessionId:n.devSessionId,dispatch:r,params:o}));return}case"stop-tunnel":{let t=e.tunnel;e.tunnel=null,Zr(e),t!=null&&Yr(e,async()=>{await t.stop(),s.info("executor switched to local")});return}case"schedule-retry":{Zr(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 pt({cell:e,devSessionId:r,dispatch:n,params:o}){try{let t=await Qr({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 Yr(e,r){e.io=e.io.then(r).catch(n=>{s.warn({err:n},"executor io failed")})}function Zr(e){e.retryTimer!=null&&(clearTimeout(e.retryTimer),e.retryTimer=null)}import{graphql as ft}from"gql.tada";var mt=ft(`
|
|
114
|
-
mutation EndDevSessionWatch($projectId: String!, $cwd: String!, $devSessionId: String) {
|
|
115
|
-
endDevSession(projectId: $projectId, cwd: $cwd, devSessionId: $devSessionId) {
|
|
116
|
-
__typename
|
|
117
|
-
... on DevSession {
|
|
118
|
-
id
|
|
119
|
-
}
|
|
120
|
-
... on NoActiveDevSessionError {
|
|
121
|
-
message
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
`);function nn(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([f({config:e.config,document:mt,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 yt}from"fs/promises";import{existsSync as on}from"fs";import ee from"path";async function tn({config:e,cwd:r}){let n=ee.join(r,".ripplo","debug");await(await yt(n,{withFileTypes:!0}).catch(()=>[])).filter(i=>i.isDirectory()).map(i=>i.name).filter(i=>!i.startsWith("replay-")&&!i.startsWith("explore-")&&!on(ee.join(n,i,ce))&&on(ee.join(n,i,"behavior.jsonl"))).reduce((i,a)=>i.then(()=>nr({config:e,debugDir:n,runId:a}).catch(()=>{})),Promise.resolve(void 0))}import{fork as gt}from"child_process";import an from"os";import{CancellationTokenSource as sn,ResponseError as ln}from"vscode-jsonrpc/node";function dn(e,r){return()=>{let n=gt(e,["run-worker"],{cwd:r,detached:!0,stdio:["ignore","inherit","inherit","ipc"]});return{connection:Xe(n),kill:()=>{St(n)},onExit:o=>{n.once("exit",o)}}}}function cn(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 mn(r),{close:async()=>{r.closed=!0,await Promise.all([...r.workers].map(n=>re(n,r)))},execute:(n,o)=>vt(n,o,r),exploreTrail:(n,o)=>xt(n,o,r),routeSpan:(n,o)=>{let t=r.workers.find(i=>i.runId===n);t?.worker.connection.sendNotification(Qe,{runId:n,span:o})},setSize:n=>{Rt(n,r)},updateSession:n=>{r.devSessionId=n.devSessionId,r.targetGeneration=n.targetGeneration}}}function St(e){let r=e.pid;if(r!=null)try{process.kill(-r,"SIGKILL")}catch{e.kill("SIGKILL")}}var ht=1e4,kt=1e4,un=-32800;async function vt(e,r,n){let o=await pn(n);if(o.runId=e.runId,!o.alive)return _(o,n),{outcome:{detail:"worker-exit",kind:"error"},serverNotified:!1};let t=new sn,i=()=>{t.cancel()};r.aborted&&t.cancel(),r.addEventListener("abort",i,{once:!0});try{let a=await o.worker.connection.sendRequest(ze,e,t.token),l=Ge.safeParse(a);return l.success?l.data:{outcome:{detail:"bad-outcome-frame",kind:"error"},serverNotified:!1}}catch(a){return wt(a,o)}finally{r.removeEventListener("abort",i),t.dispose(),_(o,n)}}async function pn(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=fn(e);return n.runId="pending",await n.ready,n}return new Promise(n=>{e.waiters.push(o=>{o.runId="pending",n(o)})})}function fn(e){let r=e.spawn(),n={resolve:()=>{}},o={alive:!0,id:e.nextId,ready:new Promise(t=>{n.resolve=t,r.connection.onNotification(Ne,t)}),runId:void 0,worker:r};return e.nextId+=1,r.connection.onRequest(Be,()=>e.lockfileProvider()),r.connection.onNotification(Je,t=>{let i=_e.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 _(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(Ve).catch(()=>{});let o=setTimeout(()=>{e.worker.kill()},ht);await n,clearTimeout(o)}function wt(e,r){return e instanceof ln&&e.code===un?{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 xt(e,r,n){let o=await pn(n);if(o.runId="explore",!o.alive)return _(o,n),{error:{detail:"worker-dead",source:"transport"},kind:"error"};let t=new sn,i={cancel:()=>{}},a=()=>{t.cancel();let l=setTimeout(()=>{o.worker.kill()},kt);i.cancel=()=>{clearTimeout(l)}};r.aborted&&a(),r.addEventListener("abort",a,{once:!0});try{let l=await o.worker.connection.sendRequest(Ke,{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 bt(l)}finally{i.cancel(),r.removeEventListener("abort",a),t.dispose(),_(o,n)}}function bt(e){return e instanceof ln&&e.code===un?{kind:"aborted",ranCount:0}:{error:{detail:e instanceof Error?e.message.slice(0,120):"unknown",source:"transport"},kind:"error"}}function Rt(e,r){r.size=e,e>an.availableParallelism()&&s.warn({cores:an.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)}),mn(r)}function mn(e){e.closed||Array.from({length:Math.max(0,e.size-e.workers.length)}).forEach(()=>{fn(e)})}var At=6e4,yn=500,Dt=15e3,Lt=Sn(`
|
|
126
|
-
mutation HeartbeatDevSessionWatch($id: String!) {
|
|
127
|
-
heartbeatDevSession(id: $id) {
|
|
128
|
-
__typename
|
|
129
|
-
... on DevSession {
|
|
130
|
-
id
|
|
131
|
-
}
|
|
132
|
-
... on DevSessionEndedError {
|
|
133
|
-
message
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
`),qt=Sn(`
|
|
138
|
-
query WatchLocalConcurrency {
|
|
139
|
-
currentUser {
|
|
140
|
-
id
|
|
141
|
-
maxLocalConcurrentRuns
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
`);async function Hs({exploreDebug:e}){Vt();let r=Qt(process.cwd()),n=r.cwd,o=Et(),t=Nt(n),i={current:null},a={handler:()=>{}},l=en({config:r,onChanged:()=>{a.handler()}}),d={handler:()=>{}},c=Bt(),u=Tr(),p=rr({config:r,cwd:n,executor:l.current,ready:c.promise,explorationStatus:()=>i.current?.status()??Ht(),onShutdownRequest:()=>{d.handler()},sseHealth:()=>u.snapshot()}),m=await Kt({cwd:n,ipc:p,releasePid:t}),G=await P(n);G.isErr()&&(process.stderr.write(`ripplo: ${C(G.error)}
|
|
145
|
-
`),process.exit(1));let hn=G.value,v=await jt({config:r,synchronize:()=>Le({config:r,cwd:n,lockfile:hn})}),ne=await h(n);ne!=null&&Ze(ne);let g={devSessionId:v.devSessionId,targetGeneration:gn({devSessionId:v.devSessionId,nonce:o})},kn=Pr({config:r,cwd:n});b({cwd:n,paused:v.hooksPaused});let oe=Ae(n);oe!=null&&s.info("watching branch %s in %s",oe,n);let vn=It({fetchFn:Ir(),headers:{Authorization:`Bearer ${r.token}`},retry:pr,retryAttempts:1/0,url:`${r.ripploServerUrl}/graphql`});tn({config:r,cwd:n}).catch(()=>{});let w=await _t({config:r,devSessionId:g.devSessionId,ipc:p,targetGeneration:g.targetGeneration}),E=Wt({config:r,exploreDebug:e,pool:w,currentSession:()=>g,executorIsLocal:()=>l.current()==="local"});i.current=E,a.handler=E.notifyQueueChange;let wn=await Ot({cwd:n,pool:w}),te=wr({claim:p.claim,config:r,devSessionId:v.devSessionId,executorSwitch:l,exploration:E,pool:w,sseClient:vn,sseHealth:u,onSynchronized:ie=>{g.devSessionId=ie.devSessionId,g.targetGeneration=gn({devSessionId:ie.devSessionId,nonce:o}),w.updateSession(g)}}),xn=$t({config:r,session:te}),bn=Jt();c.resolve(),Ut(v.devSessionId),nn({config:r,executorSwitch:l,exploration:E,pool:w,releasePid:t,session:te,shutdownRef:d,socketHandle:m,spanReceiver:wn,stops:[xn,bn,kn]}),await new Promise(()=>{})}function Ht(){return{explorer:{kind:"off"},exploring:0,progress:{attempts:0,findings:0}}}function Wt({config:e,currentSession:r,executorIsLocal:n,exploreDebug:o,pool:t}){return _r({appUrl:e.appUrl,cwd:e.cwd,executorIsLocal:n,onPlannerTrace:o?Mt:void 0,executeTrail:(i,a)=>t.exploreTrail(i,a),leaseOrdinal:()=>ir({config:e,count:1,devSessionId:r().devSessionId}),report:i=>{tr({attempts:i.attempts,config:e,devSessionId:r().devSessionId,findings:i.findings,trail:or(i.result)}).catch(a=>{s.warn({error:a},"exploration progress report failed")})},reportUnhealthy:()=>{ar(e,r().devSessionId).catch(i=>{s.warn({error:i},"exploration unhealthy report failed")})},targetGeneration:()=>r().targetGeneration})}function gn({devSessionId:e,nonce:r}){return{kind:"dev-session",value:`${e}:${r}`}}function Mt(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 Ot({cwd:e,pool:r}){return Ie({localDir:Pt.join(e,".ripplo",".local"),writePortFile:!0,onRrwebBatch:()=>{},onSpan:n=>{let o=n.attributes["ripplo.run"];o!=null&&r.routeSpan(o,n)}})}function Ut(e){process.stdout.write(`${$e({devSessionId:e,version:se()})}
|
|
146
|
-
`)}function $t({config:e,session:r}){let n=async()=>{try{let t=await f({config:e,document:Lt,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))}},o=setInterval(()=>{n()},Dt);return()=>{clearInterval(o)}}function jt({config:e,synchronize:r}){let n=e.ripploServerUrl.includes("localhost")||e.ripploServerUrl.includes("127.0.0.1");return Tt(async()=>{try{return await r()}catch(o){if(Ft({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 Ct(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 Ft({config:e,error:r}){let n=de(r);n==="UNAUTHENTICATED"&&(process.stderr.write(`ripplo: ${Ue()}
|
|
147
|
-
`),process.exit(1)),n==="FORBIDDEN"&&(process.stderr.write(`ripplo: ${Oe({projectId:e.projectId,serverUrl:e.ripploServerUrl})}
|
|
148
|
-
`),process.exit(1))}async function _t({config:e,devSessionId:r,ipc:n,targetGeneration:o}){let t=await Yt(e);return Gt({cwd:e.cwd,devSessionId:r,initialConcurrency:t,onProgress:n.progress,targetGeneration:o})}function Gt({cwd:e,devSessionId:r,initialConcurrency:n,onProgress:o,targetGeneration:t}){return cn({devSessionId:r,initialSize:n,onProgress:o,spawn:dn(Zt(),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 Nt(e){try{return fe({cwd:e,onCompromised:zt})}catch(r){throw r instanceof pe&&(process.stderr.write(`${je({cwd:r.cwd,pid:r.pid})}
|
|
149
|
-
`),process.exit(1)),r}}function zt(){s.error("daemon lock compromised; shutting down"),process.stderr.write(`${Fe()}
|
|
150
|
-
`),process.exit(1)}function Bt(){let e={handler:()=>{}};return{promise:new Promise(n=>{e.handler=n}),resolve:()=>{e.handler()}}}async function Kt({cwd:e,ipc:r,releasePid:n}){return(await Hr({cwd:e,onConnection:r.handleConnection})).match(t=>t,t=>{process.stderr.write(`${Me(t)}
|
|
151
|
-
`),n(),process.exit(1)})}function Qt(e){return y(e).match(r=>r,r=>{process.stderr.write(`${He(r)}
|
|
152
|
-
`),process.exit(1)})}function Jt(){N({maxRuns:yn});let e=setInterval(()=>{N({maxRuns:yn})},At);return()=>{clearInterval(e)}}function Vt(){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 Xt=4;async function Yt(e){try{let n=(await f({config:e,document:qt,variables:void 0})).currentUser?.maxLocalConcurrentRuns;if(n!=null)return D(n),n}catch(r){s.warn({err:r},"failed to fetch local concurrency setting; using default")}return Xt}function Zt(){let e=process.argv[1];if(e==null)throw new Error("cli entry unavailable");return e}export{Hs as runDaemon};
|
|
@@ -1,4 +0,0 @@
|
|
|
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}from"./chunk-56MARCN3.js";import"./chunk-NIC2DOQW.js";import"./chunk-75T33SK5.js";import"./chunk-OQ6KNYPG.js";import"./chunk-EOBWMMVC.js";import"./chunk-JS3DLVVI.js";import"./chunk-FEHVIHVA.js";import"./chunk-MHNGR6M7.js";import"./chunk-GTB7NYDE.js";import"./chunk-PVRM4YWS.js";import"./chunk-BQ25IGJS.js";import"./chunk-NXKOUVSC.js";import"./chunk-7WZ3VIUU.js";import"./chunk-KH4QH23U.js";import"./chunk-RIASQHPG.js";import"./chunk-C7SV6AR2.js";import"./chunk-HEOMRXZE.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as postEditAnalyze};
|
package/dist/status-OSHZ3JGU.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
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}from"./chunk-ULIHURY6.js";import"./chunk-6JXOIP2T.js";import"./chunk-ZGWV564Y.js";import"./chunk-U4LFIMDP.js";import"./chunk-EOBWMMVC.js";import"./chunk-R4ZTRVDQ.js";import"./chunk-MHNGR6M7.js";import"./chunk-GTB7NYDE.js";import"./chunk-PVRM4YWS.js";import"./chunk-BQ25IGJS.js";import"./chunk-NXKOUVSC.js";import"./chunk-C7SV6AR2.js";import"./chunk-HEOMRXZE.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as statusCommand};
|