ripplo 0.9.2 → 0.9.4
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-IL452KDO.js → chunk-2TBRW5WZ.js} +1 -1
- package/dist/chunk-3KD2FTEQ.js +229 -0
- package/dist/{chunk-4W6WIT7T.js → chunk-3M2E253R.js} +1 -1
- package/dist/{chunk-XWUIRXMS.js → chunk-3OI2UH3H.js} +1 -1
- package/dist/{chunk-I2M24U3N.js → chunk-3PF5QK56.js} +1 -1
- package/dist/chunk-52IE2PAQ.js +48 -0
- package/dist/{chunk-L7GWKDGD.js → chunk-6FU7HD6D.js} +1 -1
- package/dist/{chunk-ZUPS6XVH.js → chunk-6Z555TLR.js} +1 -1
- package/dist/{chunk-WZBLSDNV.js → chunk-B6OQ2JE2.js} +1 -1
- package/dist/{chunk-4H7EIC6W.js → chunk-CUXFU3MF.js} +1 -1
- package/dist/{chunk-UDQKJVLD.js → chunk-FH2BITRY.js} +1 -1
- package/dist/{chunk-Q6IYTHMP.js → chunk-G3UFH3WS.js} +1 -1
- package/dist/{chunk-I5BHCICM.js → chunk-GAOLASGV.js} +1 -1
- package/dist/{chunk-DBIXYJRB.js → chunk-INURHJF4.js} +1 -1
- package/dist/{chunk-LEFXRK53.js → chunk-KQWFJRIP.js} +1 -1
- package/dist/{chunk-IRTBARRY.js → chunk-MHXAGRCM.js} +1 -1
- package/dist/{chunk-EVVF662P.js → chunk-ML7WCYPY.js} +1 -1
- package/dist/{chunk-T5VLZ43M.js → chunk-N45RSC6N.js} +1 -1
- package/dist/{chunk-BMRZGLUF.js → chunk-O2VP65IR.js} +1 -1
- package/dist/{chunk-XZ2TPZLD.js → chunk-PLQGRHHV.js} +1 -1
- package/dist/chunk-PPMW4GUY.js +83 -0
- package/dist/{chunk-4F67XQYS.js → chunk-SBDRIIVW.js} +20 -20
- package/dist/{chunk-ZNUC2RLT.js → chunk-T46B2OPT.js} +1 -1
- package/dist/chunk-T4GHICK4.js +6 -0
- package/dist/{chunk-4KOWK5QE.js → chunk-T6NNV7ZO.js} +1 -1
- package/dist/{chunk-SI42TC5O.js → chunk-TBCRT6EC.js} +1 -1
- package/dist/{chunk-KYMYKILH.js → chunk-XDK6UCMD.js} +1 -1
- package/dist/{chunk-3FF33GCX.js → chunk-YR3N73PR.js} +2 -2
- package/dist/chunk-ZQHKESUR.js +4 -0
- package/dist/{cli-error-J33JDZET.js → cli-error-TM2YODR3.js} +1 -1
- package/dist/{compile-write-SRW6FWD2.js → compile-write-TTEHFTNY.js} +1 -1
- package/dist/{daemon-4W6BN73Z.js → daemon-5IFFVQEE.js} +14 -14
- package/dist/{daemon-42BG4EKR.js → daemon-6B4OSRBS.js} +1 -1
- package/dist/{daemon-lock-LTQMLU4Q.js → daemon-lock-67AFXXED.js} +1 -1
- package/dist/{dsl-loader-5Z2JRKY3.js → dsl-loader-Z54ZM7C6.js} +1 -1
- package/dist/{exit-plan-gate-BNAUL4FC.js → exit-plan-gate-WPHQII5J.js} +1 -1
- package/dist/hook.js +1 -1
- package/dist/index.js +184 -184
- package/dist/{plan-reminder-2GIRATWH.js → plan-reminder-H2ZU5WZF.js} +1 -1
- package/dist/post-edit-HOYXFYSH.js +4 -0
- package/dist/post-edit-analyze-5HS3ZV4G.js +4 -0
- package/dist/post-edit-flag-stubs-CDKPTQ2L.js +4 -0
- package/dist/{pre-bash-run-gate-PWLARIYK.js → pre-bash-run-gate-WOGQZARU.js} +1 -1
- package/dist/pre-edit-TRMRQGTZ.js +4 -0
- package/dist/{pre-edit-ripplo-skill-gate-JD4BDCA3.js → pre-edit-ripplo-skill-gate-FXNQWVME.js} +1 -1
- package/dist/{pre-edit-scope-gate-NZO4HVGT.js → pre-edit-scope-gate-ADO3NRVS.js} +1 -1
- package/dist/{pre-edit-watch-gate-DZHQCMEI.js → pre-edit-watch-gate-OTD6WRUN.js} +1 -1
- package/dist/{prompt-submit-3SSUX3S2.js → prompt-submit-T6GURGAW.js} +1 -1
- package/dist/scope-reminder-XTXZHPLU.js +4 -0
- package/dist/solve-worker.js +1 -1
- package/dist/status-EM4ASO7T.js +4 -0
- package/dist/{stop-enforce-TYUSBDHO.js → stop-enforce-32B7BSQK.js} +1 -1
- package/dist/{tasks-reminder-VKRJRDNC.js → tasks-reminder-PICFLMC2.js} +1 -1
- package/package.json +3 -3
- package/dist/chunk-3LYVTLBJ.js +0 -4
- package/dist/chunk-IGPHRN4A.js +0 -83
- package/dist/chunk-PE5WVWI5.js +0 -48
- package/dist/chunk-SWYJTSC3.js +0 -6
- package/dist/chunk-VE6PPIKX.js +0 -229
- package/dist/post-edit-T5C6I6ZI.js +0 -4
- package/dist/post-edit-analyze-326U7L26.js +0 -4
- package/dist/post-edit-flag-stubs-EBDTZMDS.js +0 -4
- package/dist/pre-edit-EJO3TUNQ.js +0 -4
- package/dist/scope-reminder-CBY4I5SG.js +0 -4
- package/dist/status-WZG6MDCY.js +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{b as m,c as p}from"./chunk-
|
|
4
|
+
import{b as m,c as p}from"./chunk-N45RSC6N.js";import{c as l}from"./chunk-5E62BCS7.js";import{c as d}from"./chunk-KQWFJRIP.js";import{a as i}from"./chunk-7WZ3VIUU.js";import{f as u}from"./chunk-3M2E253R.js";import{e as a}from"./chunk-52IE2PAQ.js";import{createHash as g}from"crypto";import{graphql as k}from"gql.tada";var c="tasks-reminder",y=k(`
|
|
5
5
|
query TasksReminder($projectId: String!, $cwd: String!) {
|
|
6
6
|
project(id: $projectId) {
|
|
7
7
|
id
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{C as i,f as t}from"./chunk-PPMW4GUY.js";function m(e){switch(e.kind){case"empty-response":return"ripplo daemon: cloud tunnel provisioning returned no result. Check server logs and retry.";case"server-error":return`ripplo daemon: cloud tunnel provisioning failed (${e.typename}). Run \`npx ripplo doctor\` to check your setup.`}}function g(e){switch(e.kind){case"already-running":return`ripplo daemon: daemon already running (socket ${e.socketPath}).`;case"bind-failed":return`ripplo daemon: failed to bind IPC socket: ${e.message}`}}function f({projectId:e,serverUrl:n}){return[`Project "${e}" (from .ripplo/project.json) was not found on ${n}, or this account does not have access to it.`,"Run `npx ripplo projects list` to see your projects, then update .ripplo/project.json (or re-run `npx ripplo init --project <id>`)."].join(`
|
|
5
|
+
`)}function h(){return"Not signed in. Run `npx ripplo auth login`, then start the daemon again."}function x({devSessionId:e,version:n}){return`ripplo daemon: v${n} ready as local executor for session ${e} (switch with \`npx ripplo executor cloud\` \u2014 Ctrl-C to stop)`}function k({cwd:e,pid:n}){return`ripplo daemon: another daemon is already running for this project${n==null?"":` (pid ${String(n)})`} (cwd ${e}) \u2014 this one is exiting. Run \`npx ripplo daemon status\` to inspect it, or \`npx ripplo daemon stop\` to stop it.`}function y(e){switch(e.kind){case"not-running":return"ripplo daemon: not running.";case"stopped":return`ripplo daemon: stopped (pid ${String(e.pid)}).`;case"timeout":return`ripplo daemon: pid ${String(e.pid)} did not exit within 10s \u2014 it may be finishing a run. Check again with \`npx ripplo daemon status\`.`}}function $(){return"ripplo daemon: lock compromised \u2014 another daemon likely took over this project. Shutting down."}function w(e){if(e.kind==="not-running")return"daemon: not running";if(e.kind==="unresponsive")return`daemon: running but no reply within ${String(e.timeoutMs/1e3)}s \u2014 likely busy executing runs, retry when the batch drains`;let{status:n}=e,r=n.version==null?"version unknown (pre-0.7.8)":`v${n.version}`,s=`${String(n.active)} active, ${String(n.queued)} queued`,p=l(n.explorer,n.exploring),o=`daemon: running (${r} | ${s} | ${p} | ${d(n.progress)})`;if(n.sseHealth!=null&&!n.sseHealth.ok){let a=n.sseHealth.detail==null?"":`: ${n.sseHealth.detail}`;return`${o}
|
|
6
|
+
daemon: cannot subscribe to run dispatch${a} \u2014 server-side, restarting the daemon will not help`}return o}function d(e){return e.attempts===0?"explore: idle":`explore: ${String(e.attempts)} attempts, ${String(e.findings)} findings`}function b(e){let n=e.daemonVersion==null?"an older build":`v${e.daemonVersion}`;return e.kind==="restarted"?`ripplo: daemon was on ${n} \u2014 restarted on the current build`:`ripplo: daemon is on a stale build (${n}) with runs in flight \u2014 rerun once it drains, or npx ripplo daemon restart`}function v(e){switch(e.kind){case"pass":return{kind:"pass"};case"findings":return{findingLines:e.contradictions.map(n=>i({contradiction:n,evidencePath:`.ripplo/debug/${e.runId}/behavior.jsonl`})),kind:"findings"};case"error":return{detail:t(e.error),kind:"error"};case"dispatch-failed":return{kind:"dispatch-error",reason:{detail:e.reason,type:"generic"}}}}function l(e,n){switch(e.kind){case"off":return"explorer: off";case"on":return`explorer: on, ${String(n)} exploring`;case"paused":return"explorer: paused for active runs or a short cooldown \u2014 resumes on its own";case"blocked":return`explorer: blocked \u2014 ${u(e.reason)}`}}function u(e){switch(e){case"no-lockfile":return"no lockfile found, run npx ripplo compile";case"unstamped":return"lockfile has no compiled checks, run npx ripplo compile";case"expander-newer":return"lockfile predates the current CLI build, run npx ripplo compile";case"dsl-drift":return"workflow sources changed since the last compile, run npx ripplo compile";case"load-failed":return"workflow definitions do not compile, run npx ripplo compile for details"}}export{m as a,g as b,f as c,h as d,x as e,k as f,y as g,$ as h,w as i,d as j,b as k,v as l};
|
|
@@ -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}from"./chunk-7WZ3VIUU.js";import{f as n}from"./chunk-
|
|
4
|
+
import{a as r}from"./chunk-7WZ3VIUU.js";import{f as n}from"./chunk-3M2E253R.js";var m=async o=>{if(o.permission_mode!=="plan"||!r(o.cwd)||!n(o.cwd))return;let{loadRipplo:s}=await import("./dsl-loader-Z54ZM7C6.js"),{stubbedWorkflows:a}=await import("./compile-write-TTEHFTNY.js"),t=await s(o.cwd);if(t.isErr())return;let e=a(t.value),i=['Plan must include "Tests to implement" with a .ripplo/workflows/ file per affected flow (ExitPlanMode blocks otherwise). Stub each with `workflow("Intent")` (no body).'];return e.length>0&&i.push(`Existing stubs: ${e.join(", ")}`),{hookSpecificOutput:{additionalContext:i.join(`
|
|
5
5
|
`),hookEventName:"UserPromptSubmit"}}};export{m as a};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{a as r}from"./chunk-OQ6KNYPG.js";import{a as s}from"./chunk-MHNGR6M7.js";import{a as k,b as C,c as F,d as b}from"./chunk-
|
|
4
|
+
import{a as r}from"./chunk-OQ6KNYPG.js";import{a as s}from"./chunk-MHNGR6M7.js";import{a as k,b as C,c as F,d as b}from"./chunk-ZQHKESUR.js";import{A as S,B as v,F as $,c as u,g as o,q as c,t as f,v as m,w as p,x as g,y,z as h}from"./chunk-PPMW4GUY.js";import{K as d,R as l}from"./chunk-SBDRIIVW.js";async function P({cwd:e,lockfile:n}){let i=c(n),a=b(d(l,n));if(C({context:i,cwd:e})===a)return[];k({context:i,cwd:e});let t=await x(n);return F({cleanLockfileHash:t.length===0?a:null,context:i,cwd:e}),t}async function x(e){let n=u(e),i=await f(e),a=await m({context:c(e),facts:i.facts});return[...g(e).map(t=>({kind:"missing-precondition",missing:t})),...p(n,i.dataRules).map(t=>({gap:t,kind:"cascade-gap"})),...a.map(t=>({conflict:t,kind:"fact-conflict"})),...y(e).map(t=>({kind:"unreachable-interaction",violation:t})),...h(e).map(t=>({kind:"redundant-assertion",redundancy:t})),...S(e).map(t=>({kind:"unmodeled-surface",surface:t})),...v(e).map(t=>({content:t,kind:"unpinned-surface-content"}))]}function U(e){return`${o.good("ok")} \u2014 no static model violations (${r(e,"test")})`}function O(e){let i=e.some(a=>a.kind==="unmodeled-surface")?[`Elements that hide together are one surface. ${s("create","surfaces")}`]:[];return[`${o.bad("fail")} \u2014 ${r(e.length,"static model violation")}:`,...e.map(a=>$(a)),...i].join(`
|
|
5
5
|
|
|
6
6
|
`)}function E(e){return[`${o.warn("warn")} \u2014 ${r(e.length,"model coverage gap")} (not blocking):`,...e.map(n=>` ${A(n)}`),`Stub the missing flows. ${s("discover")}`].join(`
|
|
7
7
|
`)}function A(e){switch(e.kind){case"entity-never-given":return`${e.entity} \u2014 declared but no test seeds it`;case"entity-never-mutated":return`${e.entity} \u2014 seeded but never asserted created/updated/deleted`;case"unmatchable-delete-key":return`test ${e.workflow}/${e.testSlug} asserts ${e.entity} deleted with literal ${e.field} but no seeded ${e.entity} sets ${e.field} \u2014 solver treats it as no-match`}}export{P as a,U as b,O as c,E as d};
|
|
@@ -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{b as u}from"./chunk-
|
|
4
|
+
import{b as u}from"./chunk-GAOLASGV.js";import{a as f}from"./chunk-JJ4QQPAV.js";import{a as m}from"./chunk-7WZ3VIUU.js";import{f as c}from"./chunk-3M2E253R.js";import{i as p}from"./chunk-ZQHKESUR.js";import{k as l}from"./chunk-ML7WCYPY.js";import v from"path";import h from"picomatch";import*as s from"zod/mini";var w=s.looseObject({file_path:s.string()}),R=async n=>{let i=w.safeParse(n.tool_input);if(!i.success)return;let d=i.data.file_path,{cwd:t}=n;if(!m(t)||!c(t))return;let r=v.relative(t,d);if(r.startsWith(".."))return;let{ignorePaths:b,watchPaths:k}=f(),P=h([...k]),g=h([...b]);if(!P(r)||g(r))return;let o=await l(t);if(u({cwd:t,tests:o.isOk()?o.value.workflows.map(e=>({intent:e.intent,name:e.name,sourcePath:e.sourcePath??null,stub:e.stub})):void 0}),o.isErr())return;let a=p(o.value);if(a.length!==0)return{hookSpecificOutput:{additionalContext:`Reminder: stub workflows still unimplemented \u2014 ${a.join(", ")}. Implement with \`workflow("Intent", () => ({ given, steps }))\`.`,hookEventName:"PostToolUse"}}};export{R as a};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
4
|
import{a as p,c as t}from"./chunk-KOKEEAEF.js";import{c as s}from"./chunk-CJUKILIO.js";function l(){let o=process.cwd(),e=s(o);e!=null&&e!==o&&(process.chdir(e),process.stderr.write(`ripplo: resolved .ripplo/ at ${e}
|
|
5
|
-
`))}var d={"exit-plan-gate":()=>import("./exit-plan-gate-
|
|
6
|
-
`),process.exit(1));let i=await m(),r=await p(await e(),i);if(r.kind==="crash"){let{renderHookCrash:a}=await import("./cli-error-
|
|
5
|
+
`))}var d={"exit-plan-gate":()=>import("./exit-plan-gate-WPHQII5J.js").then(o=>o.exitPlanGateHook),"plan-reminder":()=>import("./plan-reminder-H2ZU5WZF.js").then(o=>t("UserPromptSubmit",o.planReminder)),"post-edit":()=>import("./post-edit-HOYXFYSH.js").then(o=>o.postEditHook),"post-edit-analyze":()=>import("./post-edit-analyze-5HS3ZV4G.js").then(o=>t("PostToolUse",o.postEditAnalyze)),"post-edit-flag-stubs":()=>import("./post-edit-flag-stubs-CDKPTQ2L.js").then(o=>t("PostToolUse",o.postEditFlagStubs)),"pre-bash-run-gate":()=>import("./pre-bash-run-gate-WOGQZARU.js").then(o=>o.preBashRunGateHook),"pre-edit":()=>import("./pre-edit-TRMRQGTZ.js").then(o=>o.preEditHook),"pre-edit-ripplo-skill-gate":()=>import("./pre-edit-ripplo-skill-gate-FXNQWVME.js").then(o=>t("PreToolUse",o.preEditRipploSkillGate)),"pre-edit-scope-gate":()=>import("./pre-edit-scope-gate-ADO3NRVS.js").then(o=>t("PreToolUse",o.preEditScopeGate)),"pre-edit-watch-gate":()=>import("./pre-edit-watch-gate-OTD6WRUN.js").then(o=>t("PreToolUse",o.preEditWatchGate)),"prompt-submit":()=>import("./prompt-submit-T6GURGAW.js").then(o=>o.promptSubmitHook),"scope-reminder":()=>import("./scope-reminder-XTXZHPLU.js").then(o=>t("UserPromptSubmit",o.scopeReminder)),"session-preamble":()=>import("./session-preamble-ZYVRDSGA.js").then(o=>o.sessionPreambleHook),"stop-enforce":()=>import("./stop-enforce-32B7BSQK.js").then(o=>o.stopEnforceHook),"tasks-reminder":()=>import("./tasks-reminder-PICFLMC2.js").then(o=>t("UserPromptSubmit",o.tasksReminder)),"tasks-reminder-tool":()=>Promise.resolve(t("PostToolUse",()=>{})),"track-skill-load":()=>import("./track-skill-load-CJ74GD3Q.js").then(o=>o.trackSkillLoadHook),"track-skill-prompt":()=>import("./track-skill-prompt-YSB6OOQN.js").then(o=>t("UserPromptSubmit",o.trackSkillPrompt))},n=d;async function P(o){let e=n[o];e==null&&(process.stderr.write(`Unknown hook: ${o}
|
|
6
|
+
`),process.exit(1));let i=await m(),r=await p(await e(),i);if(r.kind==="crash"){let{renderHookCrash:a}=await import("./cli-error-TM2YODR3.js");process.stderr.write(`${a(o,r.error)}
|
|
7
7
|
`),process.exit(0)}r.stdout!=null&&process.stdout.write(r.stdout),process.exit(0)}function m(){return new Promise((o,e)=>{if(process.stdin.isTTY){o("");return}let i=[];process.stdin.on("data",r=>i.push(r)),process.stdin.on("end",()=>{o(Buffer.concat(i).toString("utf8"))}),process.stdin.on("error",e)})}export{l as a,n as b,P as c};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
|
+
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
+
import{a as c,b as v,c as d,d as C,h as s,k as P}from"./chunk-ML7WCYPY.js";import{q as w,t as x,u as b,v as F}from"./chunk-PPMW4GUY.js";import{K as k,L as i,R as n,S as h,da as y,ha as L,ia as g}from"./chunk-SBDRIIVW.js";import{readFile as D,writeFile as W}from"fs/promises";import R from"path";import{err as m,ok as K}from"neverthrow";import{createHash as H}from"crypto";import l from"fs";import S from"path";import V from"safe-stable-stringify";import{z as f}from"zod";function B({context:e,cwd:t}){y(e);let o=I(t,u(e));o!=null&&L(e,o)}function ne({context:e,cwd:t}){let o=z(t);if(!(o==null||o.model!==u(e)))return o.cleanLockfile??void 0}function ie({cleanLockfileHash:e,context:t,cwd:o}){let r=E(o);l.mkdirSync(S.dirname(r),{recursive:!0}),l.writeFileSync(r,JSON.stringify({bundle:c(),cleanLockfile:e,model:u(t)}))}function se(e){return H("sha256").update(e).digest("base64")}var J=f.object({bundle:f.string().nullable(),cleanLockfile:f.string().nullable(),model:f.string()});function I(e,t){let o=S.join(e,s),r=_(o);return r==null||!d(r)?null:u({entities:r.entities,singletonSchemas:r.singletons,valueSpaces:r.valueSpaces})===t?r.solved:null}function _(e){try{return i(n,l.readFileSync(e,"utf8"))}catch{return null}}function u(e){let t=V({entities:e.entities,singletons:e.singletonSchemas,valueSpaces:e.valueSpaces});if(t==null)throw new Error("solve-cache: context is not serializable");return H("sha256").update(t).digest("base64")}function z(e){let t=E(e);if(l.existsSync(t))try{let o=J.safeParse(JSON.parse(l.readFileSync(t,"utf8")));return!o.success||!C(o.data.bundle)?void 0:o.data}catch{return}}function E(e){return S.join(e,".ripplo",".local","solve-cache.json")}async function Se(e){let t=await P(e);return t.isOk()&&await N(e,t.value),t}async function N(e,t){let o=await q(e,t);return await W(R.join(e,s),k(n,o)),o}var O=new WeakMap;function q(e,t){let o=O.get(t);if(o!=null)return o;let r=T(e,t).then(a=>a.match(p=>Promise.resolve(p),()=>G(e,t)));return O.set(t,r),r}function ye(e,t){return T(e,t)}function Le(e){return e.workflows.filter(t=>t.stub).map(t=>t.name)}async function ge(e,t){let o=await A(e);return o==null?"missing":o.checks==null?"stale":v(o,t)?"match":"stale"}async function T(e,t){let o=await A(e);return o==null?m({kind:"no-lockfile"}):o.checks==null?m({kind:"unstamped"}):d(o)?v(o,t)?K(h(o)):m({kind:"dsl-drift"}):m({kind:"expander-newer"})}async function A(e){try{let t=await D(R.join(e,s),"utf8");return i(n,t)}catch{return null}}async function G(e,t){let o=w(t);B({context:o,cwd:e});let r=await b(t),a=await x(t);await F({context:o,facts:a.facts});let p=await g(o),j=c(),M={...t,checks:{...r,expanderHash:j??void 0},solved:p};return h(i(n,k(n,M)))}export{B as a,ne as b,ie as c,se as d,Se as e,N as f,q as g,ye as h,Le as i,ge as j};
|
|
@@ -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-G3UFH3WS.js";import"./chunk-PLQGRHHV.js";import"./chunk-MHNGR6M7.js";import"./chunk-ML7WCYPY.js";import"./chunk-SBDRIIVW.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{e as a,f as b,g as c,h as d,i as e,j as f}from"./chunk-
|
|
4
|
+
import{e as a,f as b,g as c,h as d,i as e,j as f}from"./chunk-ZQHKESUR.js";import"./chunk-ML7WCYPY.js";import"./chunk-PPMW4GUY.js";import"./chunk-SBDRIIVW.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};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{A as
|
|
4
|
+
import{A as U,C as Ve,D as Xe,E as Ye,G as Ze,H as K,I as Q,J as er,K as rr,L as z,M as nr,e as Ee,i as He,j as Ue,k as We,l as $e,m as _e,n as Me,o as Oe,p as Fe,r as q,s as H,t as je,u as B,v as Qe,w as ze,x as Je,z as Ge}from"./chunk-3KD2FTEQ.js";import{d as Ie}from"./chunk-B6OQ2JE2.js";import{a as Ne,c as Be,d as Ke,e as w}from"./chunk-6Z555TLR.js";import{c as k}from"./chunk-KQWFJRIP.js";import{e as Pe}from"./chunk-3M2E253R.js";import{a as ce}from"./chunk-R4ZTRVDQ.js";import{c as ae}from"./chunk-FEHVIHVA.js";import{b as fe}from"./chunk-G3UFH3WS.js";import{a as L}from"./chunk-PLQGRHHV.js";import"./chunk-MHNGR6M7.js";import{g as xe,h as D}from"./chunk-ZQHKESUR.js";import{a as ue,i as v,j as pe,k as T}from"./chunk-ML7WCYPY.js";import{e as Re,f as be}from"./chunk-INURHJF4.js";import{c as te,d as u,f as s,g as oe,h as N,i as ie}from"./chunk-52IE2PAQ.js";import"./chunk-CJUKILIO.js";import{b as Ce,c as Te,d as Le,e as Ae,f as De,h as qe}from"./chunk-T4GHICK4.js";import{G as ye,J as A,K as ge,L as Se,N as ke,O as he,P as ve,W as we,a as me}from"./chunk-PPMW4GUY.js";import{K as se,R as le,X as de}from"./chunk-SBDRIIVW.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import no from"path";import{createClient as to}from"graphql-sse";import{graphql as ne}from"gql.tada";import Ln,{AbortError as An}from"p-retry";import{graphql as pn}from"gql.tada";import{print as fn}from"graphql";async function tr({config:e,cwd:r,headed:n,pool:t,runId:o,signal:i,testSlug:a,workClass:l,workflowSlug:d}){let c=await v(r);if(c.isErr())return await U(e,o,`lockfile:${c.error.kind}`),{kind:"dispatch-error",reason:{detail:`lockfile:${c.error.kind}`,type:"generic"}};let p=un(c.value,{testSlug:a,workflowSlug:d});if(p==null)return await U(e,o,`no-test:${d}/${a}`),{kind:"dispatch-error",reason:{detail:`no-test:${d}/${a}`,type:"generic"}};let f=await q({headed:n,workClass:l,task:()=>t.execute({headed:n,runId:o,testRef:p},i)});return!f.serverNotified&&f.outcome.kind==="error"&&await U(e,o,f.outcome.detail),f.outcome}function un(e,{testSlug:r,workflowSlug:n}){let o=e.workflows.find(i=>de(i.name)===n)?.tests.find(i=>i.slug===r);return o==null?void 0:me(o)}var mn=6e4,yn=pn(`
|
|
5
5
|
subscription RunRequestedWatch($devSessionId: String!) {
|
|
6
6
|
runRequested(devSessionId: $devSessionId) {
|
|
7
7
|
runId
|
|
@@ -10,8 +10,8 @@ import{A as Ge,B as U,D as Ve,E as Xe,F as Ye,H as Ze,I as K,J as Q,K as er,L as
|
|
|
10
10
|
workflowSlug
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
`);async function or(e){let r=Math.min(1e3*2**e,mn)+hn();await new Promise(n=>setTimeout(n,r))}function ir({claim:e,cwd:r,devSessionId:n,onSubscriptionDead:t,pool:o,sseClient:i,sseHealth:a}){let l=new Set,d=gn(r);return i.subscribe({query:fn(yn),variables:{devSessionId:n}},{complete:()=>{},error:c=>{let p=c instanceof Error?c.message:String(c);s.warn("runRequested SSE failed: %s; re-registering session",p),t(p)},next:c=>{Sn({claim:e,dispatchConfig:d,event:c.data?.runRequested,inFlightRunIds:l,pool:o})}},{connected:()=>{a.onConnected()},connecting:c=>{a.onConnecting(c),c&&s.debug("runRequested SSE reconnecting")}})}function gn(e){return
|
|
14
|
-
`);let i=kn(e(n.runId),n);i.started(),tr({config:r.config,cwd:r.cwd,headed:i.headed,pool:o,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(()=>{t.delete(n.runId)})}function kn(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:
|
|
13
|
+
`);async function or(e){let r=Math.min(1e3*2**e,mn)+hn();await new Promise(n=>setTimeout(n,r))}function ir({claim:e,cwd:r,devSessionId:n,onSubscriptionDead:t,pool:o,sseClient:i,sseHealth:a}){let l=new Set,d=gn(r);return i.subscribe({query:fn(yn),variables:{devSessionId:n}},{complete:()=>{},error:c=>{let p=c instanceof Error?c.message:String(c);s.warn("runRequested SSE failed: %s; re-registering session",p),t(p)},next:c=>{Sn({claim:e,dispatchConfig:d,event:c.data?.runRequested,inFlightRunIds:l,pool:o})}},{connected:()=>{a.onConnected()},connecting:c=>{a.onConnecting(c),c&&s.debug("runRequested SSE reconnecting")}})}function gn(e){return ae(e),{config:k(e).match(r=>r,r=>{s.error({failure:r},"failed to load env for run dispatch")}),cwd:e}}function Sn({claim:e,dispatchConfig:r,event:n,inFlightRunIds:t,pool:o}){if(n==null)return;if(t.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}t.add(n.runId),process.stdout.write(`ripplo: run ${n.workflowSlug}
|
|
14
|
+
`);let i=kn(e(n.runId),n);i.started(),tr({config:r.config,cwd:r.cwd,headed:i.headed,pool:o,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(()=>{t.delete(n.runId)})}function kn(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:ze(e.token),workClass:"p1-cli",finished:n=>{e.finished(r.runId,n)},started:()=>{e.started(r.runId)}}}function hn(){return Math.floor(Math.random()*2700)+300}import{graphql as J}from"gql.tada";import{print as vn}from"graphql";var wn=J(`
|
|
15
15
|
subscription TeleportRequestedWatch($devSessionId: String!) {
|
|
16
16
|
teleportRequested(devSessionId: $devSessionId) {
|
|
17
17
|
runId
|
|
@@ -33,8 +33,8 @@ import{A as Ge,B as U,D as Ve,E as Xe,F as Ye,H as Ze,I as K,J as Q,K as er,L as
|
|
|
33
33
|
reportTeleportResult(devSessionId: $devSessionId, runId: $runId, status: $status)
|
|
34
34
|
}
|
|
35
35
|
`);function ar({cwd:e,devSessionId:r,onSubscriptionDead:n,sseClient:t}){let o=new Set,i=t.subscribe({query:vn(wn),variables:{devSessionId:r}},{complete:()=>{},error:a=>{let l=a instanceof Error?a.message:String(a);s.warn("teleportRequested SSE failed: %s; re-registering session",l),n(l)},next:a=>{bn({cwd:e,devSessionId:r,event:a.data?.teleportRequested,running:o})}});return()=>{o.forEach(a=>{a.abort()}),o.clear(),i()}}function bn({cwd:e,devSessionId:r,event:n,running:t}){if(n==null)return;let o=new AbortController;t.add(o),En({cwd:e,devSessionId:r,event:n,signal:o.signal}).catch(i=>{s.error({err:i},"teleport failed; daemon continuing")}).finally(()=>{t.delete(o)})}async function En({cwd:e,devSessionId:r,event:n,signal:t}){let o=d=>Pn({cwd:e,devSessionId:r,runId:n.runId,status:d}),i=await In(e,n);if(i==null){s.warn({runId:n.runId},"teleport could not resolve target"),await o("unplannable");return}process.stdout.write(`ripplo: teleport ${Tn(n)} step ${String(n.stepIndex+1)}
|
|
36
|
-
`);let l=await Ze({cwd:e,onReady:()=>{o("opened")},signal:t,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 o(l.kind==="unplannable"?"unplannable":"error"))}async function Pn({cwd:e,devSessionId:r,runId:n,status:t}){let o=k(e).match(i=>i,()=>null);o!=null&&await u({config:o,document:Rn,variables:{devSessionId:r,runId:n,status:t}}).catch(()=>null)}async function In(e,r){if(r.kind==="explore"){let n=await Cn(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 Cn(e,r){let n=k(e).match(o=>o,()=>null);if(n==null)return null;let t=await u({config:n,document:xn,variables:{id:r}}).catch(()=>null);return t?.run?.reproJson==null?null:A.parse(JSON.parse(t.run.reproJson))}function Tn(e){return e.kind==="explore"?"explore finding":`${String(e.workflowSlug)}/${String(e.testSlug)}`}var sr=6e4,Dn=3;function lr({claim:e,config:r,cwd:n,initialId:t,pool:o,sseClient:i,sseHealth:a}){let l=t,d=null,c=0,p=0,f=y=>{I(y)},E=()=>{let y=ir({claim:e,cwd:n,devSessionId:l,onSubscriptionDead:f,pool:o,sseClient:i,sseHealth:a}),g=ar({cwd:n,devSessionId:l,onSubscriptionDead:f,sseClient:i});return()=>{y(),g()}},m=E(),P=async y=>{let g=Date.now();c=g-p>sr*2?1:c+1,p=g,c>=Dn&&a.markUnhealthy(y),await Un(Math.min(1e3*2**(c-1),sr));let h=await T(n);if(h.isErr()){s.error("re-register: compile failed: %s",L(h.error));return}let S=await G(()=>
|
|
37
|
-
`),process.exit(1)),n==="FORBIDDEN"&&(process.stderr.write(`ripplo: ${
|
|
36
|
+
`);let l=await Ze({cwd:e,onReady:()=>{o("opened")},signal:t,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 o(l.kind==="unplannable"?"unplannable":"error"))}async function Pn({cwd:e,devSessionId:r,runId:n,status:t}){let o=k(e).match(i=>i,()=>null);o!=null&&await u({config:o,document:Rn,variables:{devSessionId:r,runId:n,status:t}}).catch(()=>null)}async function In(e,r){if(r.kind==="explore"){let n=await Cn(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 Cn(e,r){let n=k(e).match(o=>o,()=>null);if(n==null)return null;let t=await u({config:n,document:xn,variables:{id:r}}).catch(()=>null);return t?.run?.reproJson==null?null:A.parse(JSON.parse(t.run.reproJson))}function Tn(e){return e.kind==="explore"?"explore finding":`${String(e.workflowSlug)}/${String(e.testSlug)}`}var sr=6e4,Dn=3;function lr({claim:e,config:r,cwd:n,initialId:t,pool:o,sseClient:i,sseHealth:a}){let l=t,d=null,c=0,p=0,f=y=>{I(y)},E=()=>{let y=ir({claim:e,cwd:n,devSessionId:l,onSubscriptionDead:f,pool:o,sseClient:i,sseHealth:a}),g=ar({cwd:n,devSessionId:l,onSubscriptionDead:f,sseClient:i});return()=>{y(),g()}},m=E(),P=async y=>{let g=Date.now();c=g-p>sr*2?1:c+1,p=g,c>=Dn&&a.markUnhealthy(y),await Un(Math.min(1e3*2**(c-1),sr));let h=await T(n);if(h.isErr()){s.error("re-register: compile failed: %s",L(h.error));return}let S=await G(()=>Be({config:r,cwd:n,lockfile:h.value}),{config:r,label:"re-register sync"});m(),l=S.devSessionId,m=E(),s.info("re-registered dev session as %s",l)},I=y=>(d!=null||(d=P(y).finally(()=>{d=null})),d);return{getId:()=>l,reregister:()=>I("dev session ended server-side"),stop:()=>{m()}}}function G(e,{config:r,label:n}){let t=r.ripploServerUrl.includes("localhost")||r.ripploServerUrl.includes("127.0.0.1");return Ln(async()=>{try{return await e()}catch(o){qn({config:r,error:o});let i=o instanceof Error?o.message:String(o);throw Hn(i)?o:(s.error("%s failed: %s",n,i),new An(i))}},{factor:2,maxTimeout:t?2e3:1e4,minTimeout:t?100:1e3,retries:1/0,onFailedAttempt:({attemptNumber:o,error:i})=>{s.warn("%s attempt %d failed \u2014 retrying: %s",n,o,i.message)}})}function qn({config:e,error:r}){let n=te(r);n==="UNAUTHENTICATED"&&(process.stderr.write(`ripplo: ${Le()}
|
|
37
|
+
`),process.exit(1)),n==="FORBIDDEN"&&(process.stderr.write(`ripplo: ${Te({projectId:e.projectId,serverUrl:e.ripploServerUrl})}
|
|
38
38
|
`),process.exit(1))}function Hn(e){return e.includes("status 502")||e.includes("ECONNREFUSED")||e.includes("Failed to connect")||e.includes("fetch failed")}function Un(e){return new Promise(r=>setTimeout(r,e))}import{graphql as dr}from"gql.tada";var Wn=dr(`
|
|
39
39
|
query OpenFindingsForRetire($projectId: String!) {
|
|
40
40
|
exploreFindings(projectId: $projectId, status: open) {
|
|
@@ -48,7 +48,7 @@ import{A as Ge,B as U,D as Ve,E as Xe,F as Ye,H as Ze,I as K,J as Q,K as er,L as
|
|
|
48
48
|
mutation RetireStaleFinding($projectId: String!, $signature: String!) {
|
|
49
49
|
retireStaleFinding(projectId: $projectId, signature: $signature)
|
|
50
50
|
}
|
|
51
|
-
`);async function cr({config:e,cwd:r,lockfile:n}){let o=(await u({config:e,document:Wn,variables:{projectId:e.projectId}})).exploreFindings,i=await D(r,n);if(i.isErr())return s.info({block:i.error.kind},"skipping finding retire until next compile"),!1;let a=await _n(o,i.value);return a.length===0||(await Promise.all(a.map(l=>On(e,l))),s.info({count:a.length},"retired findings whose trail no longer replays")),!0}async function _n(e,r){return(await Promise.all(e.map(async t=>await Mn(t,r)?t.signature:null))).filter(t=>t!=null)}async function Mn(e,r){let n=e.reproRun?.reproJson;if(n==null)return!1;let t=A.safeParse(JSON.parse(n));return t.success?(await ve(r,t.data)).kind==="unplannable":!1}function On(e,r){return u({config:e,document:$n,variables:{projectId:e.projectId,signature:r}})}var Fn=6e4;function ur(e){let r={retiredKey:null,running:!1,stopped:!1},n=async()=>{if(!(r.running||r.stopped)){r.running=!0;try{r.retiredKey=await jn(e,r.retiredKey)}catch(o){s.warn({err:o},"retire stale findings failed \u2014 retrying on next tick")}finally{r.running=!1}}},t={timer:setTimeout(function o(){n(),r.stopped||(t.timer=setTimeout(o,Fn))},0)};return()=>{r.stopped=!0,clearTimeout(t.timer)}}async function jn({config:e,cwd:r},n){let t=await w(r),o=ce();if(t==null||o==null)return n;let i=`${t}@${o}`;if(i===n)return n;let a=await v(r);return a.isErr()?n:await cr({config:e,cwd:r,lockfile:a.value})?i:n}function pr(){let e=!0,r,n=null,t=()=>{n!=null&&(clearTimeout(n),n=null)};return{markUnhealthy:o=>{e=!1,r=o,t()},onConnected:()=>{t(),n=setTimeout(()=>{e=!0,r=void 0,n=null},1e4)},onConnecting:()=>{t()},snapshot:()=>({detail:r,ok:e})}}import Nn from"fs";import gr from"net";import{err as Sr,ok as Bn}from"neverthrow";async function kr({cwd:e,onConnection:r}){oe(e);let n=Pe(e),t=await fr({onConnection:r,socketPath:n});return t.isOk()||t.error.kind!=="stale-candidate"?t.map(mr(n)).mapErr(yr(n)):await Kn(n)?Sr({kind:"already-running",socketPath:n}):(hr(n),(await fr({onConnection:r,socketPath:n})).map(mr(n)).mapErr(yr(n)))}function Kn(e){return new Promise(r=>{let n=gr.connect(e);n.once("connect",()=>{n.destroy(),r(!0)}),n.once("error",()=>{r(!1)})})}async function fr(e){let r=await Qn(e);return r.kind==="listening"?Bn(r.server):Sr(r.error)}function Qn({onConnection:e,socketPath:r}){return new Promise(n=>{let t=gr.createServer(e);t.once("error",o=>{n({error:o.code==="EADDRINUSE"?{kind:"stale-candidate"}:{kind:"listen-failed",message:o.message},kind:"failed"})}),t.listen(r,()=>{n({kind:"listening",server:t})})})}function mr(e){return r=>({socketPath:e,close:()=>{r.close(),hr(e)}})}function hr(e){Nn.rmSync(e,{force:!0})}function yr(e){return r=>r.kind==="stale-candidate"?{kind:"already-running",socketPath:e}:{kind:"bind-failed",message:r.message}}import{randomInt as nt,randomUUID as tt}from"crypto";function vr(){return{attempts:0,backoffUntil:0,consecutiveErrors:0,desired:{active:!1,localWorkers:er,maxTrailLength:rr},executorLocal:!0,findings:0,lastUnhealthyReportAt:null,loading:!1,lockfile:{kind:"loading"},prevInteractiveActive:0,stopped:!1,trails:new Map}}function wr(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 Jn(e,r.outcome);case"trail-started":return{effects:[],state:{...e,trails:new Map([...e.trails,[r.id,{startedAt:r.now}]])}};case"trail-settled":return Gn(e,r);case"stopped":return{effects:[{ids:[...e.trails.keys()],kind:"abort"}],state:{...e,stopped:!0,trails:new Map}}}}function xr(e,r,n){return z(br(e),Er(e,r,n)).health}function V(e,r,n){let t=zn(e,r,n),o={...e,...t,prevInteractiveActive:n.active},i=z(br(o),Er(o,r,n)),a=o.lockfile.kind!=="ready"&&!o.loading;return{effects:[...a?[{kind:"load"}]:[],...i.abortIds.length>0?[{ids:i.abortIds,kind:"abort"}]:[],...i.launchCount>0?[{count:i.launchCount,kind:"launch",maxTrailLength:o.desired.maxTrailLength}]:[]],state:{...o,loading:o.loading||a}}}function zn(e,r,n){return n.active<e.prevInteractiveActive?{backoffUntil:Math.max(e.backoffUntil,r+Q)}:{backoffUntil:e.backoffUntil}}function Jn(e,r){return r.kind==="blocked"?{effects:[],state:{...e,loading:!1,lockfile:{kind:"blocked",reason:r.reason}}}:{effects:[],state:{...e,consecutiveErrors:0,lastUnhealthyReportAt:null,loading:!1,lockfile:{kind:"ready"}}}}function Gn(e,r){let n=new Map([...e.trails].filter(([i])=>i!==r.id)),t=Vn({...e,trails:n},r.settled,r.now),o=V(t.state,r.now,r.queue);return{effects:[...t.effects,...o.effects],state:o.state}}function Vn(e,r,n){switch(r.kind){case"aborted":case"crashed":return{effects:[],state:e};case"app-unreachable":return Rr({category:"driver",now:n,state:e,subject:"app-unreachable"});case"error":return Xn(e,r.error,n);case"done":return Zn(e,r.result)}}function Xn(e,r,n){if(r.source==="lockfile-stale")return{effects:[{kind:"reload"}],state:{...e,loading:!0,lockfile:{kind:"loading"}}};let t=ye(r);return t==="trail"?{effects:[],state:{...e,consecutiveErrors:0,lastUnhealthyReportAt:null}}:Rr({category:t,now:n,state:e,subject:Yn(r)})}function Yn(e){switch(e.source){case"transport":case"config":return`${e.source}: ${e.detail}`;case"runtime":return`runtime: ${e.kind}`;case"empty-trail":case"bad-assign":case"lockfile-stale":return e.source}}function Zn(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 et=6,rt=2e4;function Rr({category:e,now:r,state:n,subject:t}){let o=n.consecutiveErrors+1;if(o<et)return{effects:[],state:{...n,consecutiveErrors:o}};let i=e==="driver"?Math.max(n.backoffUntil,r+Q):n.backoffUntil,a=n.lastUnhealthyReportAt==null||r-n.lastUnhealthyReportAt>=rt;return{effects:a?[{kind:"report-unhealthy",subject:t}]:[],state:{...n,backoffUntil:i,consecutiveErrors:o,lastUnhealthyReportAt:a?r:n.lastUnhealthyReportAt}}}function br(e){return{enabled:e.desired.active,executorLocal:e.executorLocal,maxTrailLength:e.desired.maxTrailLength,workers:e.desired.localWorkers}}function Er(e,r,n){return{backoffActive:r<e.backoffUntil,headedActive:n.headedActive>0,interactiveActive:n.active,interactiveQueued:n.queued,lockfile:e.lockfile,poolSize:n.poolSize,trails:[...e.trails.entries()].map(([t,o])=>({ageMs:r-o.startedAt,id:t}))}}function Ir(e){let r=ot(e),n=st(()=>{r.dispatch(R())});return B(()=>{r.dispatch(R())}),r.dispatch(R()),{notifyQueueChange:()=>{r.dispatch({kind:"executor-changed",local:e.executorIsLocal()}),r.dispatch(R())},setDesired:t=>{r.dispatch({desired:t,kind:"desired-changed",now:Date.now(),queue:W()})},status:()=>at(r.current()),stop:()=>{n(),B(null),r.dispatch({kind:"stopped"})}}}function ot(e){let r={draining:!1,queue:[],runtime:it(e)},n=i=>{r.runtime=i(r.runtime)},t=i=>{r.queue.push(i),!r.draining&&(r.draining=!0,o(),r.draining=!1)},o=()=>{let i=r.queue.shift();if(i==null)return;let a=wr(r.runtime.state,i);n(l=>({...l,state:a.state})),a.effects.forEach(l=>{lt({commit:n,dispatch:t,effect:l,params:e,runtime:r.runtime})}),o()};return{dispatch:t,current:()=>r.runtime}}function it(e){return{controllers:new Map,prepared:null,state:{...vr(),executorLocal:e.executorIsLocal()}}}function at(e){return{explorer:xr(e.state,Date.now(),W()),exploring:e.state.trails.size,progress:{attempts:e.state.attempts,findings:e.state.findings}}}function W(){let e=Fe();return{active:e.active,headedActive:e.headedActive,poolSize:e.poolSize,queued:e.queued}}function R(){return{kind:"tick",now:Date.now(),queue:W()}}function st(e){let r={timer:setTimeout(function n(){e(),r.timer=setTimeout(n,K)},K)};return()=>{clearTimeout(r.timer)}}function lt({commit:e,dispatch:r,effect:n,params:t,runtime:o}){switch(n.kind){case"load":case"reload":{dt(t.cwd,o.prepared).then(({outcome:i,prepared:a})=>{e(l=>({...l,prepared:a})),r({kind:"load-settled",now:Date.now(),outcome:i}),r(R())});return}case"abort":{n.ids.forEach(i=>{o.controllers.get(i)?.abort()});return}case"launch":{Array.from({length:n.count}).forEach(()=>{ct({commit:e,dispatch:r,maxTrailLength:n.maxTrailLength,params:t,prepared:o.prepared})});return}case"report":{t.report({attempts:1,findings:n.finding?1:0,result:n.result}),n.finding&&s.info("exploration finding recorded");return}case"report-unhealthy":s.warn("exploration unhealthy after repeated infra errors (last: %s)",n.subject),t.reportUnhealthy()}}async function dt(e,r){let n=await w(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:t}=await ue(e);if(t.isErr())return{outcome:{kind:"blocked",reason:"load-failed"},prepared:null};let o=await D(e,t.value);if(o.isErr())return{outcome:{kind:"blocked",reason:o.error.kind},prepared:null};let i=await Se(o.value);return i==null?{outcome:{kind:"blocked",reason:"load-failed"},prepared:null}:{outcome:{kind:"ready",rawHash:n},prepared:{exploration:i,rawHash:n}}}function ct({commit:e,dispatch:r,maxTrailLength:n,params:t,prepared:o}){if(o==null)return;let i=ke({lockfileHash:o.rawHash,prepared:o.exploration,random:ut,strategy:{...me("even"),maxAttemptLength:n}});if(i==null)return;let a=`explore:${tt()}`,l=new AbortController;e(d=>({...d,controllers:new Map([...d.controllers,[a,l]])})),r({id:a,kind:"trail-started",now:Date.now()}),q({headed:!1,workClass:"p3-explore",task:()=>pt({assign:i,params:t,signal:l.signal})}).catch(d=>(s.debug({err:d},"exploration trail crashed"),{kind:"crashed"})).then(d=>{e(c=>({...c,controllers:new Map([...c.controllers].filter(([p])=>p!==a))})),r({id:a,kind:"trail-settled",now:Date.now(),queue:W(),settled:d})})}var Pr=2**31;function ut(){return nt(Pr)/Pr}async function pt({assign:e,params:r,signal:n}){let t=await r.executeTrail(e,n);return t.kind==="aborted"?{kind:"aborted"}:t.kind==="error"?ft(r,t.error):{kind:"done",result:t}}async function ft(e,r){let n=await be(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 Tt}from"gql.tada";import{connect as yt}from"net";import gt from"ssh2";import{WebSocket as Tr,createWebSocketStream as St}from"ws";var mt="ripplo-";function X(e){return Object.entries(e).map(([r,n])=>`${mt}${r}.${n}`)}var{Server:kt,utils:Cr}=gt;function Lr(){let e=Cr.generateKeyPairSync("ed25519"),r=Cr.parseKey(e.private);if(r instanceof Error)throw r;return{fingerprint:r.getPublicSSH().toString("base64"),privateKey:e.private}}function Ar(e){return new Promise((r,n)=>{let t={closers:new Set,stopped:!1},o=new Tr(e.relayUrl,X({grant:e.grant,role:"daemon-control"}));o.on("open",()=>{s.info("cloud-executor relay control up"),r({stop:ht(o,t)})}),o.on("message",i=>{vt(e,t,i)}),o.on("close",(i,a)=>{t.stopped||s.warn({code:i,reason:a.toString()},"relay control closed"),Ct(e,t)}),o.on("error",i=>{n(i instanceof Error?i:new Error(String(i)))})})}function ht(e,r){return()=>(r.stopped=!0,r.closers.forEach(n=>{n()}),e.close(),Promise.resolve())}function vt(e,r,n){let t=wt(n);t!=null&&Rt(e,r,t.pipeId)}function wt(e){try{let r=JSON.parse(xt(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 xt(e){return Buffer.isBuffer(e)?e.toString("utf8"):Array.isArray(e)?Buffer.concat(e).toString("utf8"):Buffer.from(e).toString("utf8")}function Rt(e,r,n){if(r.stopped)return;let t=new Tr(e.relayUrl,X({pipeId:n,role:"daemon-data"}));t.on("open",()=>{bt(e,r,t)}),t.on("error",o=>{s.warn({err:o},"cloud-executor relay data pipe error")})}function bt(e,r,n){let t=St(n);t.on("error",()=>{});let o=new kt({hostKeys:[e.hostKey.privateKey]},a=>{a.on("error",l=>{s.warn({err:l},"cloud-executor ssh connection error")}),a.on("authentication",l=>{Pt(l,e.secret)}),a.on("ready",()=>{a.on("tcpip",(l,d,c)=>{It({accept:l,allowedPorts:e.allowedPorts,deny:d,destPort:c.destPort})})})}),i=()=>{n.close()};r.closers.add(i),n.on("close",()=>r.closers.delete(i)),Et(o,t)}function Et(e,r){e.injectSocket(r)}function Pt(e,r){if(e.method==="password"&&e.password===r){e.accept();return}if(e.method==="none"){e.reject(["password"]);return}e.reject()}function It({accept:e,allowedPorts:r,deny:n,destPort:t}){if(!r.includes(t)){n();return}let o=!1,i=yt({autoSelectFamily:!0,host:"localhost",port:t},()=>{o=!0;let a=e();a.on("error",()=>{}),i.pipe(a).pipe(i)});i.on("error",()=>{o||n()})}function Ct(e,r){r.stopped||(r.stopped=!0,r.closers.forEach(n=>{n()}),e.onFatal())}var Lt=Tt(`
|
|
51
|
+
`);async function cr({config:e,cwd:r,lockfile:n}){let o=(await u({config:e,document:Wn,variables:{projectId:e.projectId}})).exploreFindings,i=await D(r,n);if(i.isErr())return s.info({block:i.error.kind},"skipping finding retire until next compile"),!1;let a=await _n(o,i.value);return a.length===0||(await Promise.all(a.map(l=>On(e,l))),s.info({count:a.length},"retired findings whose trail no longer replays")),!0}async function _n(e,r){return(await Promise.all(e.map(async t=>await Mn(t,r)?t.signature:null))).filter(t=>t!=null)}async function Mn(e,r){let n=e.reproRun?.reproJson;if(n==null)return!1;let t=A.safeParse(JSON.parse(n));return t.success?(await we(r,t.data)).kind==="unplannable":!1}function On(e,r){return u({config:e,document:$n,variables:{projectId:e.projectId,signature:r}})}var Fn=6e4;function ur(e){let r={retiredKey:null,running:!1,stopped:!1},n=async()=>{if(!(r.running||r.stopped)){r.running=!0;try{r.retiredKey=await jn(e,r.retiredKey)}catch(o){s.warn({err:o},"retire stale findings failed \u2014 retrying on next tick")}finally{r.running=!1}}},t={timer:setTimeout(function o(){n(),r.stopped||(t.timer=setTimeout(o,Fn))},0)};return()=>{r.stopped=!0,clearTimeout(t.timer)}}async function jn({config:e,cwd:r},n){let t=await w(r),o=ue();if(t==null||o==null)return n;let i=`${t}@${o}`;if(i===n)return n;let a=await v(r);return a.isErr()?n:await cr({config:e,cwd:r,lockfile:a.value})?i:n}function pr(){let e=!0,r,n=null,t=()=>{n!=null&&(clearTimeout(n),n=null)};return{markUnhealthy:o=>{e=!1,r=o,t()},onConnected:()=>{t(),n=setTimeout(()=>{e=!0,r=void 0,n=null},1e4)},onConnecting:()=>{t()},snapshot:()=>({detail:r,ok:e})}}import Nn from"fs";import gr from"net";import{err as Sr,ok as Bn}from"neverthrow";async function kr({cwd:e,onConnection:r}){ie(e);let n=Ie(e),t=await fr({onConnection:r,socketPath:n});return t.isOk()||t.error.kind!=="stale-candidate"?t.map(mr(n)).mapErr(yr(n)):await Kn(n)?Sr({kind:"already-running",socketPath:n}):(hr(n),(await fr({onConnection:r,socketPath:n})).map(mr(n)).mapErr(yr(n)))}function Kn(e){return new Promise(r=>{let n=gr.connect(e);n.once("connect",()=>{n.destroy(),r(!0)}),n.once("error",()=>{r(!1)})})}async function fr(e){let r=await Qn(e);return r.kind==="listening"?Bn(r.server):Sr(r.error)}function Qn({onConnection:e,socketPath:r}){return new Promise(n=>{let t=gr.createServer(e);t.once("error",o=>{n({error:o.code==="EADDRINUSE"?{kind:"stale-candidate"}:{kind:"listen-failed",message:o.message},kind:"failed"})}),t.listen(r,()=>{n({kind:"listening",server:t})})})}function mr(e){return r=>({socketPath:e,close:()=>{r.close(),hr(e)}})}function hr(e){Nn.rmSync(e,{force:!0})}function yr(e){return r=>r.kind==="stale-candidate"?{kind:"already-running",socketPath:e}:{kind:"bind-failed",message:r.message}}import{randomInt as nt,randomUUID as tt}from"crypto";function vr(){return{attempts:0,backoffUntil:0,consecutiveErrors:0,desired:{active:!1,localWorkers:er,maxTrailLength:rr},executorLocal:!0,findings:0,lastUnhealthyReportAt:null,loading:!1,lockfile:{kind:"loading"},prevInteractiveActive:0,stopped:!1,trails:new Map}}function wr(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 Jn(e,r.outcome);case"trail-started":return{effects:[],state:{...e,trails:new Map([...e.trails,[r.id,{startedAt:r.now}]])}};case"trail-settled":return Gn(e,r);case"stopped":return{effects:[{ids:[...e.trails.keys()],kind:"abort"}],state:{...e,stopped:!0,trails:new Map}}}}function xr(e,r,n){return z(br(e),Er(e,r,n)).health}function V(e,r,n){let t=zn(e,r,n),o={...e,...t,prevInteractiveActive:n.active},i=z(br(o),Er(o,r,n)),a=o.lockfile.kind!=="ready"&&!o.loading;return{effects:[...a?[{kind:"load"}]:[],...i.abortIds.length>0?[{ids:i.abortIds,kind:"abort"}]:[],...i.launchCount>0?[{count:i.launchCount,kind:"launch",maxTrailLength:o.desired.maxTrailLength}]:[]],state:{...o,loading:o.loading||a}}}function zn(e,r,n){return n.active<e.prevInteractiveActive?{backoffUntil:Math.max(e.backoffUntil,r+Q)}:{backoffUntil:e.backoffUntil}}function Jn(e,r){return r.kind==="blocked"?{effects:[],state:{...e,loading:!1,lockfile:{kind:"blocked",reason:r.reason}}}:{effects:[],state:{...e,consecutiveErrors:0,lastUnhealthyReportAt:null,loading:!1,lockfile:{kind:"ready"}}}}function Gn(e,r){let n=new Map([...e.trails].filter(([i])=>i!==r.id)),t=Vn({...e,trails:n},r.settled,r.now),o=V(t.state,r.now,r.queue);return{effects:[...t.effects,...o.effects],state:o.state}}function Vn(e,r,n){switch(r.kind){case"aborted":case"crashed":return{effects:[],state:e};case"app-unreachable":return Rr({category:"driver",now:n,state:e,subject:"app-unreachable"});case"error":return Xn(e,r.error,n);case"done":return Zn(e,r.result)}}function Xn(e,r,n){if(r.source==="lockfile-stale")return{effects:[{kind:"reload"}],state:{...e,loading:!0,lockfile:{kind:"loading"}}};let t=ge(r);return t==="trail"?{effects:[],state:{...e,consecutiveErrors:0,lastUnhealthyReportAt:null}}:Rr({category:t,now:n,state:e,subject:Yn(r)})}function Yn(e){switch(e.source){case"transport":case"config":return`${e.source}: ${e.detail}`;case"runtime":return`runtime: ${e.kind}`;case"empty-trail":case"bad-assign":case"lockfile-stale":return e.source}}function Zn(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 et=6,rt=2e4;function Rr({category:e,now:r,state:n,subject:t}){let o=n.consecutiveErrors+1;if(o<et)return{effects:[],state:{...n,consecutiveErrors:o}};let i=e==="driver"?Math.max(n.backoffUntil,r+Q):n.backoffUntil,a=n.lastUnhealthyReportAt==null||r-n.lastUnhealthyReportAt>=rt;return{effects:a?[{kind:"report-unhealthy",subject:t}]:[],state:{...n,backoffUntil:i,consecutiveErrors:o,lastUnhealthyReportAt:a?r:n.lastUnhealthyReportAt}}}function br(e){return{enabled:e.desired.active,executorLocal:e.executorLocal,maxTrailLength:e.desired.maxTrailLength,workers:e.desired.localWorkers}}function Er(e,r,n){return{backoffActive:r<e.backoffUntil,headedActive:n.headedActive>0,interactiveActive:n.active,interactiveQueued:n.queued,lockfile:e.lockfile,poolSize:n.poolSize,trails:[...e.trails.entries()].map(([t,o])=>({ageMs:r-o.startedAt,id:t}))}}function Ir(e){let r=ot(e),n=st(()=>{r.dispatch(R())});return B(()=>{r.dispatch(R())}),r.dispatch(R()),{notifyQueueChange:()=>{r.dispatch({kind:"executor-changed",local:e.executorIsLocal()}),r.dispatch(R())},setDesired:t=>{r.dispatch({desired:t,kind:"desired-changed",now:Date.now(),queue:W()})},status:()=>at(r.current()),stop:()=>{n(),B(null),r.dispatch({kind:"stopped"})}}}function ot(e){let r={draining:!1,queue:[],runtime:it(e)},n=i=>{r.runtime=i(r.runtime)},t=i=>{r.queue.push(i),!r.draining&&(r.draining=!0,o(),r.draining=!1)},o=()=>{let i=r.queue.shift();if(i==null)return;let a=wr(r.runtime.state,i);n(l=>({...l,state:a.state})),a.effects.forEach(l=>{lt({commit:n,dispatch:t,effect:l,params:e,runtime:r.runtime})}),o()};return{dispatch:t,current:()=>r.runtime}}function it(e){return{controllers:new Map,prepared:null,state:{...vr(),executorLocal:e.executorIsLocal()}}}function at(e){return{explorer:xr(e.state,Date.now(),W()),exploring:e.state.trails.size,progress:{attempts:e.state.attempts,findings:e.state.findings}}}function W(){let e=je();return{active:e.active,headedActive:e.headedActive,poolSize:e.poolSize,queued:e.queued}}function R(){return{kind:"tick",now:Date.now(),queue:W()}}function st(e){let r={timer:setTimeout(function n(){e(),r.timer=setTimeout(n,K)},K)};return()=>{clearTimeout(r.timer)}}function lt({commit:e,dispatch:r,effect:n,params:t,runtime:o}){switch(n.kind){case"load":case"reload":{dt(t.cwd,o.prepared).then(({outcome:i,prepared:a})=>{e(l=>({...l,prepared:a})),r({kind:"load-settled",now:Date.now(),outcome:i}),r(R())});return}case"abort":{n.ids.forEach(i=>{o.controllers.get(i)?.abort()});return}case"launch":{Array.from({length:n.count}).forEach(()=>{ct({commit:e,dispatch:r,maxTrailLength:n.maxTrailLength,params:t,prepared:o.prepared})});return}case"report":{t.report({attempts:1,findings:n.finding?1:0,result:n.result}),n.finding&&s.info("exploration finding recorded");return}case"report-unhealthy":s.warn("exploration unhealthy after repeated infra errors (last: %s)",n.subject),t.reportUnhealthy()}}async function dt(e,r){let n=await w(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:t}=await pe(e);if(t.isErr())return{outcome:{kind:"blocked",reason:"load-failed"},prepared:null};let o=await D(e,t.value);if(o.isErr())return{outcome:{kind:"blocked",reason:o.error.kind},prepared:null};let i=await ke(o.value);return i==null?{outcome:{kind:"blocked",reason:"load-failed"},prepared:null}:{outcome:{kind:"ready",rawHash:n},prepared:{exploration:i,rawHash:n}}}function ct({commit:e,dispatch:r,maxTrailLength:n,params:t,prepared:o}){if(o==null)return;let i=he({lockfileHash:o.rawHash,prepared:o.exploration,random:ut,strategy:{...ye("even"),maxAttemptLength:n}});if(i==null)return;let a=`explore:${tt()}`,l=new AbortController;e(d=>({...d,controllers:new Map([...d.controllers,[a,l]])})),r({id:a,kind:"trail-started",now:Date.now()}),q({headed:!1,workClass:"p3-explore",task:()=>pt({assign:i,params:t,signal:l.signal})}).catch(d=>(s.debug({err:d},"exploration trail crashed"),{kind:"crashed"})).then(d=>{e(c=>({...c,controllers:new Map([...c.controllers].filter(([p])=>p!==a))})),r({id:a,kind:"trail-settled",now:Date.now(),queue:W(),settled:d})})}var Pr=2**31;function ut(){return nt(Pr)/Pr}async function pt({assign:e,params:r,signal:n}){let t=await r.executeTrail(e,n);return t.kind==="aborted"?{kind:"aborted"}:t.kind==="error"?ft(r,t.error):{kind:"done",result:t}}async function ft(e,r){let n=await Ee(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 Tt}from"gql.tada";import{connect as yt}from"net";import gt from"ssh2";import{WebSocket as Tr,createWebSocketStream as St}from"ws";var mt="ripplo-";function X(e){return Object.entries(e).map(([r,n])=>`${mt}${r}.${n}`)}var{Server:kt,utils:Cr}=gt;function Lr(){let e=Cr.generateKeyPairSync("ed25519"),r=Cr.parseKey(e.private);if(r instanceof Error)throw r;return{fingerprint:r.getPublicSSH().toString("base64"),privateKey:e.private}}function Ar(e){return new Promise((r,n)=>{let t={closers:new Set,stopped:!1},o=new Tr(e.relayUrl,X({grant:e.grant,role:"daemon-control"}));o.on("open",()=>{s.info("cloud-executor relay control up"),r({stop:ht(o,t)})}),o.on("message",i=>{vt(e,t,i)}),o.on("close",(i,a)=>{t.stopped||s.warn({code:i,reason:a.toString()},"relay control closed"),Ct(e,t)}),o.on("error",i=>{n(i instanceof Error?i:new Error(String(i)))})})}function ht(e,r){return()=>(r.stopped=!0,r.closers.forEach(n=>{n()}),e.close(),Promise.resolve())}function vt(e,r,n){let t=wt(n);t!=null&&Rt(e,r,t.pipeId)}function wt(e){try{let r=JSON.parse(xt(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 xt(e){return Buffer.isBuffer(e)?e.toString("utf8"):Array.isArray(e)?Buffer.concat(e).toString("utf8"):Buffer.from(e).toString("utf8")}function Rt(e,r,n){if(r.stopped)return;let t=new Tr(e.relayUrl,X({pipeId:n,role:"daemon-data"}));t.on("open",()=>{bt(e,r,t)}),t.on("error",o=>{s.warn({err:o},"cloud-executor relay data pipe error")})}function bt(e,r,n){let t=St(n);t.on("error",()=>{});let o=new kt({hostKeys:[e.hostKey.privateKey]},a=>{a.on("error",l=>{s.warn({err:l},"cloud-executor ssh connection error")}),a.on("authentication",l=>{Pt(l,e.secret)}),a.on("ready",()=>{a.on("tcpip",(l,d,c)=>{It({accept:l,allowedPorts:e.allowedPorts,deny:d,destPort:c.destPort})})})}),i=()=>{n.close()};r.closers.add(i),n.on("close",()=>r.closers.delete(i)),Et(o,t)}function Et(e,r){e.injectSocket(r)}function Pt(e,r){if(e.method==="password"&&e.password===r){e.accept();return}if(e.method==="none"){e.reject(["password"]);return}e.reject()}function It({accept:e,allowedPorts:r,deny:n,destPort:t}){if(!r.includes(t)){n();return}let o=!1,i=yt({autoSelectFamily:!0,host:"localhost",port:t},()=>{o=!0;let a=e();a.on("error",()=>{}),i.pipe(a).pipe(i)});i.on("error",()=>{o||n()})}function Ct(e,r){r.stopped||(r.stopped=!0,r.closers.forEach(n=>{n()}),e.onFatal())}var Lt=Tt(`
|
|
52
52
|
mutation EnterCloudMode(
|
|
53
53
|
$devSessionId: String!
|
|
54
54
|
$localUrl: String!
|
|
@@ -77,7 +77,7 @@ import{A as Ge,B as U,D as Ve,E as Xe,F as Ye,H as Ze,I as K,J as Q,K as er,L as
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
`),$=class extends Error{failure;constructor(r){super(r.kind),this.failure=r}};async function qr({config:e,devSessionId:r,onFatal:n}){let t=Lr(),i=(await u({config:e,document:Lt,variables:{devSessionId:r,engineUrl:e.engineUrl,hostKeyFingerprint:t.fingerprint,localUrl:e.appUrl}})).enterCloudMode;if(i==null)throw new $({kind:"empty-response"});if(i.__typename!=="RelaySession")throw new $({kind:"server-error",typename:i.__typename});let a=await Ar({allowedPorts:[...new Set([Dr(e.appUrl),Dr(e.engineUrl)])],grant:i.grant,hostKey:t,onFatal:n,relayUrl:i.relayUrl,secret:i.secret});return s.info({session:i.session},"cloud-executor relay up"),{stop:a.stop}}function Dr(e){let r=new URL(e);return r.port.length>0?Number(r.port):r.protocol==="https:"?443:80}var Hr=[1e3,3e3,8e3,15e3];function Ur(){return{attempt:0,desired:"local",devSessionId:null,stopped:!1,tunnel:"down"}}function Wr(e,r){if(e.stopped)return{effects:[],state:e};switch(r.kind){case"requested":return Dt(e,r.mode);case"connected":return Y({...e,devSessionId:r.devSessionId},[]);case"tunnel-started":return qt(e);case"tunnel-failed":case"tunnel-fatal":return Ht(e);case"retry-due":return e.tunnel==="down"?Y(e,[]):{effects:[],state:e};case"stopped":return{effects:e.tunnel==="down"?[]:[{kind:"stop-tunnel"}],state:{...e,desired:"local",stopped:!0,tunnel:"down"}}}}function At(e){let r=Math.min(e,Hr.length-1),n=Hr[r];if(n==null)throw new Error("executor retry ladder is empty");return n}function Dt(e,r){return r===e.desired?{effects:[],state:e}:Y({...e,attempt:0,desired:r},[{kind:"notify-changed"}])}function Y(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 qt(e){return _(e)?{effects:[],state:{...e,attempt:0,tunnel:"up"}}:{effects:[{kind:"stop-tunnel"}],state:{...e,tunnel:"down"}}}function Ht(e){let r={...e,tunnel:"down"};return _(r)?{effects:[{delayMs:At(r.attempt),kind:"schedule-retry"}],state:{...r,attempt:r.attempt+1}}:{effects:[],state:r}}function Mr(e){let r={draining:!1,io:Promise.resolve(),queue:[],retryTimer:null,state:Ur(),tunnel:null},n=t=>{r.queue.push(t),!r.draining&&(r.draining=!0,Or(r,n,e),r.draining=!1)};return{connect:t=>{n({devSessionId:t,kind:"connected"})},current:()=>r.state.desired,request:t=>{n({kind:"requested",mode:t})},stop:async()=>{n({kind:"stopped"}),await r.io.catch(()=>{})}}}function Or(e,r,n){let t=e.queue.shift();if(t==null)return;let o=Wr(e.state,t);e.state=o.state,o.effects.forEach(i=>{Ut({cell:e,dispatch:r,effect:i,params:n})}),Or(e,r,n)}function Ut({cell:e,dispatch:r,effect:n,params:t}){switch(n.kind){case"start-tunnel":{$r(e,()=>Wt({cell:e,devSessionId:n.devSessionId,dispatch:r,params:t}));return}case"stop-tunnel":{let o=e.tunnel;e.tunnel=null,_r(e),o!=null&&$r(e,async()=>{await o.stop(),s.info("executor switched to local")});return}case"schedule-retry":{_r(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":t.onChanged()}}async function Wt({cell:e,devSessionId:r,dispatch:n,params:t}){try{let o=await qr({config:t.config,devSessionId:r,onFatal:()=>{e.tunnel=null,n({kind:"tunnel-fatal"})}});e.tunnel=o,s.info("executor switched to cloud"),n({kind:"tunnel-started"})}catch(o){s.warn({err:o},"cloud tunnel failed to start; retrying in background"),n({kind:"tunnel-failed"})}}function $r(e,r){e.io=e.io.then(r).catch(n=>{s.warn({err:n},"executor io failed")})}function _r(e){e.retryTimer!=null&&(clearTimeout(e.retryTimer),e.retryTimer=null)}import{readdir as $t}from"fs/promises";import{existsSync as Fr}from"fs";import Z from"path";async function jr({config:e,cwd:r}){let n=Z.join(r,".ripplo","debug");await(await $t(n,{withFileTypes:!0}).catch(()=>[])).filter(i=>i.isDirectory()).map(i=>i.name).filter(i=>!i.startsWith("replay-")&&!i.startsWith("explore-")&&!Fr(Z.join(n,i,
|
|
80
|
+
`),$=class extends Error{failure;constructor(r){super(r.kind),this.failure=r}};async function qr({config:e,devSessionId:r,onFatal:n}){let t=Lr(),i=(await u({config:e,document:Lt,variables:{devSessionId:r,engineUrl:e.engineUrl,hostKeyFingerprint:t.fingerprint,localUrl:e.appUrl}})).enterCloudMode;if(i==null)throw new $({kind:"empty-response"});if(i.__typename!=="RelaySession")throw new $({kind:"server-error",typename:i.__typename});let a=await Ar({allowedPorts:[...new Set([Dr(e.appUrl),Dr(e.engineUrl)])],grant:i.grant,hostKey:t,onFatal:n,relayUrl:i.relayUrl,secret:i.secret});return s.info({session:i.session},"cloud-executor relay up"),{stop:a.stop}}function Dr(e){let r=new URL(e);return r.port.length>0?Number(r.port):r.protocol==="https:"?443:80}var Hr=[1e3,3e3,8e3,15e3];function Ur(){return{attempt:0,desired:"local",devSessionId:null,stopped:!1,tunnel:"down"}}function Wr(e,r){if(e.stopped)return{effects:[],state:e};switch(r.kind){case"requested":return Dt(e,r.mode);case"connected":return Y({...e,devSessionId:r.devSessionId},[]);case"tunnel-started":return qt(e);case"tunnel-failed":case"tunnel-fatal":return Ht(e);case"retry-due":return e.tunnel==="down"?Y(e,[]):{effects:[],state:e};case"stopped":return{effects:e.tunnel==="down"?[]:[{kind:"stop-tunnel"}],state:{...e,desired:"local",stopped:!0,tunnel:"down"}}}}function At(e){let r=Math.min(e,Hr.length-1),n=Hr[r];if(n==null)throw new Error("executor retry ladder is empty");return n}function Dt(e,r){return r===e.desired?{effects:[],state:e}:Y({...e,attempt:0,desired:r},[{kind:"notify-changed"}])}function Y(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 qt(e){return _(e)?{effects:[],state:{...e,attempt:0,tunnel:"up"}}:{effects:[{kind:"stop-tunnel"}],state:{...e,tunnel:"down"}}}function Ht(e){let r={...e,tunnel:"down"};return _(r)?{effects:[{delayMs:At(r.attempt),kind:"schedule-retry"}],state:{...r,attempt:r.attempt+1}}:{effects:[],state:r}}function Mr(e){let r={draining:!1,io:Promise.resolve(),queue:[],retryTimer:null,state:Ur(),tunnel:null},n=t=>{r.queue.push(t),!r.draining&&(r.draining=!0,Or(r,n,e),r.draining=!1)};return{connect:t=>{n({devSessionId:t,kind:"connected"})},current:()=>r.state.desired,request:t=>{n({kind:"requested",mode:t})},stop:async()=>{n({kind:"stopped"}),await r.io.catch(()=>{})}}}function Or(e,r,n){let t=e.queue.shift();if(t==null)return;let o=Wr(e.state,t);e.state=o.state,o.effects.forEach(i=>{Ut({cell:e,dispatch:r,effect:i,params:n})}),Or(e,r,n)}function Ut({cell:e,dispatch:r,effect:n,params:t}){switch(n.kind){case"start-tunnel":{$r(e,()=>Wt({cell:e,devSessionId:n.devSessionId,dispatch:r,params:t}));return}case"stop-tunnel":{let o=e.tunnel;e.tunnel=null,_r(e),o!=null&&$r(e,async()=>{await o.stop(),s.info("executor switched to local")});return}case"schedule-retry":{_r(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":t.onChanged()}}async function Wt({cell:e,devSessionId:r,dispatch:n,params:t}){try{let o=await qr({config:t.config,devSessionId:r,onFatal:()=>{e.tunnel=null,n({kind:"tunnel-fatal"})}});e.tunnel=o,s.info("executor switched to cloud"),n({kind:"tunnel-started"})}catch(o){s.warn({err:o},"cloud tunnel failed to start; retrying in background"),n({kind:"tunnel-failed"})}}function $r(e,r){e.io=e.io.then(r).catch(n=>{s.warn({err:n},"executor io failed")})}function _r(e){e.retryTimer!=null&&(clearTimeout(e.retryTimer),e.retryTimer=null)}import{readdir as $t}from"fs/promises";import{existsSync as Fr}from"fs";import Z from"path";async function jr({config:e,cwd:r}){let n=Z.join(r,".ripplo","debug");await(await $t(n,{withFileTypes:!0}).catch(()=>[])).filter(i=>i.isDirectory()).map(i=>i.name).filter(i=>!i.startsWith("replay-")&&!i.startsWith("explore-")&&!Fr(Z.join(n,i,oe))&&Fr(Z.join(n,i,"behavior.jsonl"))).reduce((i,a)=>i.then(()=>Ge({config:e,debugDir:n,runId:a}).catch(()=>{})),Promise.resolve(void 0))}import{fork as _t}from"child_process";import Nr from"os";import{CancellationTokenSource as Br,ResponseError as Kr}from"vscode-jsonrpc/node";function Qr(e,r){return()=>{let n=_t(e,["run-worker"],{cwd:r,detached:!0,stdio:["ignore","inherit","inherit","ipc"]});return{connection:Fe(n),kill:()=>{Mt(n)},onExit:t=>{n.once("exit",t)}}}}function zr(e){let r={closed:!1,devSessionId:e.devSessionId,lockfileProvider:e.lockfileProvider,nextId:0,size:e.initialSize,spawn:e.spawn,waiters:[],workers:[]};return Xr(r),{close:async()=>{r.closed=!0,await Promise.all([...r.workers].map(n=>ee(n,r)))},execute:(n,t)=>jt(n,t,r),exploreTrail:(n,t)=>Bt(n,t,r),routeSpan:(n,t)=>{let o=r.workers.find(i=>i.runId===n);o?.worker.connection.sendNotification(Me,{runId:n,span:t})},setSize:n=>{Qt(n,r)}}}function Mt(e){let r=e.pid;if(r!=null)try{process.kill(-r,"SIGKILL")}catch{e.kill("SIGKILL")}}var Ot=1e4,Ft=1e4,Jr=-32800;async function jt(e,r,n){let t=await Gr(n);if(t.runId=e.runId,!t.alive)return M(t,n),{outcome:{detail:"worker-exit",kind:"error"},serverNotified:!1};let o=new Br,i=()=>{o.cancel()};r.aborted&&o.cancel(),r.addEventListener("abort",i,{once:!0});try{let a=await t.worker.connection.sendRequest(We,e,o.token),l=He.safeParse(a);return l.success?l.data:{outcome:{detail:"bad-outcome-frame",kind:"error"},serverNotified:!1}}catch(a){return Nt(a,t)}finally{r.removeEventListener("abort",i),o.dispose(),M(t,n)}}async function Gr(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=Vr(e);return n.runId="pending",await n.ready,n}return new Promise(n=>{e.waiters.push(t=>{t.runId="pending",n(t)})})}function Vr(e){let r=e.spawn(),n={resolve:()=>{}},t={alive:!0,id:e.nextId,ready:new Promise(o=>{n.resolve=o,r.connection.onNotification(Ue,o)}),runId:void 0,worker:r};return e.nextId+=1,r.connection.onRequest($e,()=>e.lockfileProvider()),r.onExit(()=>{t.alive=!1,e.workers=e.workers.filter(o=>o!==t),r.connection.dispose(),n.resolve()}),e.workers.push(t),t}function M(e,r){if(e.runId=void 0,!e.alive||r.closed)return;if(r.workers.length>r.size){ee(e,r);return}let n=r.waiters.shift();n?.(e)}async function ee(e,r){if(r.workers=r.workers.filter(o=>o!==e),!e.alive)return;let n=new Promise(o=>{e.worker.onExit(o)});await e.ready,await e.worker.connection.sendNotification(Oe).catch(()=>{});let t=setTimeout(()=>{e.worker.kill()},Ot);await n,clearTimeout(t)}function Nt(e,r){return e instanceof Kr&&e.code===Jr?{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 Bt(e,r,n){let t=await Gr(n);if(t.runId="explore",!t.alive)return M(t,n),{error:{detail:"worker-dead",source:"transport"},kind:"error"};let o=new Br,i={cancel:()=>{}},a=()=>{o.cancel();let l=setTimeout(()=>{t.worker.kill()},Ft);i.cancel=()=>{clearTimeout(l)}};r.aborted&&a(),r.addEventListener("abort",a,{once:!0});try{let l=await t.worker.connection.sendRequest(_e,{assign:e,devSessionId:n.devSessionId},o.token),d=Se.safeParse(l);return d.success?d.data:{error:{detail:"bad-result",source:"transport"},kind:"error"}}catch(l){return Kt(l)}finally{i.cancel(),r.removeEventListener("abort",a),o.dispose(),M(t,n)}}function Kt(e){return e instanceof Kr&&e.code===Jr?{kind:"aborted"}:{error:{detail:e instanceof Error?e.message.slice(0,120):"unknown",source:"transport"},kind:"error"}}function Qt(e,r){r.size=e,e>Nr.availableParallelism()&&s.warn({cores:Nr.availableParallelism(),size:e},"worker pool size exceeds available cores");let n=r.workers.filter(o=>o.alive&&o.runId===void 0),t=r.workers.length-e;n.slice(0,Math.max(0,t)).forEach(o=>{ee(o,r)}),Xr(r)}function Xr(e){e.closed||Array.from({length:Math.max(0,e.size-e.workers.length)}).forEach(()=>{Vr(e)})}import O from"fs";import zt from"p-retry";import{graphql as b}from"gql.tada";import{print as F}from"graphql";var Jt=b(`
|
|
81
81
|
query DaemonExploration($devSessionId: String!) {
|
|
82
82
|
exploration(devSessionId: $devSessionId) {
|
|
83
83
|
active
|
|
@@ -112,7 +112,7 @@ import{A as Ge,B as U,D as Ve,E as Xe,F as Ye,H as Ze,I as K,J as Q,K as er,L as
|
|
|
112
112
|
executor
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
`);function rn({config:e,devSessionId:r,sseClient:n,switcher:t}){return t.connect(r),eo({config:e,switcher:t}),ro({devSessionId:r,sseClient:n,switcher:t})}async function eo({config:e,switcher:r}){let n=await nr(e);if(n.isErr()){s.warn({error:n.error},"initial executor fetch failed, staying local");return}r.request(n.value)}function ro({devSessionId:e,sseClient:r,switcher:n}){return r.subscribe({query:F(Zt),variables:{devSessionId:e}},{complete:()=>{},error:t=>{s.error(t,"executor subscription error")},next:t=>{let o=t.data?.executorChangeRequested?.executor;o!=null&&n.request(o)}})}function nn({cwd:e,projectId:r,sseClient:n}){return n.subscribe({query:F(Xt),variables:{projectId:r}},{complete:()=>{},error:t=>{s.error(t,"hooksPaused subscription error")},next:t=>{let o=t.data?.hooksPausedRequested?.paused;o!=null&&re({cwd:e,paused:o})}})}function re({cwd:e,paused:r}){let n=
|
|
115
|
+
`);function rn({config:e,devSessionId:r,sseClient:n,switcher:t}){return t.connect(r),eo({config:e,switcher:t}),ro({devSessionId:r,sseClient:n,switcher:t})}async function eo({config:e,switcher:r}){let n=await nr(e);if(n.isErr()){s.warn({error:n.error},"initial executor fetch failed, staying local");return}r.request(n.value)}function ro({devSessionId:e,sseClient:r,switcher:n}){return r.subscribe({query:F(Zt),variables:{devSessionId:e}},{complete:()=>{},error:t=>{s.error(t,"executor subscription error")},next:t=>{let o=t.data?.executorChangeRequested?.executor;o!=null&&n.request(o)}})}function nn({cwd:e,projectId:r,sseClient:n}){return n.subscribe({query:F(Xt),variables:{projectId:r}},{complete:()=>{},error:t=>{s.error(t,"hooksPaused subscription error")},next:t=>{let o=t.data?.hooksPausedRequested?.paused;o!=null&&re({cwd:e,paused:o})}})}function re({cwd:e,paused:r}){let n=Pe(e);if(r&&!O.existsSync(n)){O.writeFileSync(n,"");return}!r&&O.existsSync(n)&&O.unlinkSync(n)}var oo=6e4,tn=500,io=15e3,ao=ne(`
|
|
116
116
|
mutation HeartbeatDevSessionWatch($id: String!) {
|
|
117
117
|
heartbeatDevSession(id: $id) {
|
|
118
118
|
__typename
|
|
@@ -143,10 +143,10 @@ import{A as Ge,B as U,D as Ve,E as Xe,F as Ye,H as Ze,I as K,J as Q,K as er,L as
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
`);async function Ja(){Ro();let e=wo(process.cwd()),r=e.cwd,n=So(r),t={current:null},o={handler:()=>{}},i=Mr({config:e,onChanged:()=>{o.handler()}}),a={handler:()=>{}},l=ho(),d=pr(),c=
|
|
147
|
-
`),process.exit(1));let E=f.value,m=await G(()=>
|
|
148
|
-
`)}function yo({config:e,session:r}){let n=async()=>{try{let o=await u({config:e,document:ao,variables:{id:r.getId()}});o.heartbeatDevSession?.__typename==="DevSessionEndedError"&&(s.warn("dev session ended server-side (%s); re-registering",o.heartbeatDevSession.message),await r.reregister())}catch(o){s.warn("heartbeat failed: %s",o instanceof Error?o.message:String(o))}},t=setInterval(()=>{n()},io);return()=>{clearInterval(t)}}function go({cwd:e,devSessionId:r,initialConcurrency:n}){return zr({devSessionId:r,initialSize:n,spawn:Qr(Po(),e),lockfileProvider:async()=>{let t=await v(e);if(t.isErr())return{unavailable:`daemon-load-failed:${t.error.kind}`};let o=await
|
|
149
|
-
`),process.exit(1)),r}}function ko(){s.error("daemon lock compromised; shutting down"),process.stderr.write(`${
|
|
150
|
-
`),process.exit(1)}function ho(){let e={handler:()=>{}};return{promise:new Promise(n=>{e.handler=n}),resolve:()=>{e.handler()}}}async function vo({cwd:e,ipc:r,releasePid:n}){return(await kr({cwd:e,onConnection:r.handleConnection})).match(o=>o,o=>{process.stderr.write(`${
|
|
151
|
-
`),n(),process.exit(1)})}function wo(e){return k(e).match(r=>r,r=>{process.stderr.write(`${
|
|
146
|
+
`);async function Ja(){Ro();let e=wo(process.cwd()),r=e.cwd,n=So(r),t={current:null},o={handler:()=>{}},i=Mr({config:e,onChanged:()=>{o.handler()}}),a={handler:()=>{}},l=ho(),d=pr(),c=Je({config:e,cwd:r,executor:i.current,ready:l.promise,explorationStatus:()=>t.current?.status()??co(),onShutdownRequest:()=>{a.handler()},sseHealth:()=>d.snapshot()}),p=await vo({cwd:r,ipc:c,releasePid:n}),f=await T(r);f.isErr()&&(process.stderr.write(`ripplo: ${L(f.error)}
|
|
147
|
+
`),process.exit(1));let E=f.value,m=await G(()=>Ke({config:e,cwd:r,lockfile:E}),{config:e,label:"initial sync"}),P=await w(r);P!=null&&Qe(P);let I=ur({config:e,cwd:r}),y=await Eo(e);re({cwd:r,paused:m.hooksPaused});let g=Ne(r);g!=null&&s.info("watching branch %s in %s",g,r);let h=to({headers:{Authorization:`Bearer ${e.token}`},retry:or,retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`});jr({config:e,cwd:r}).catch(()=>{});let S=go({cwd:r,devSessionId:m.devSessionId,initialConcurrency:y}),C=po({config:e,devSessionId:m.devSessionId,pool:S,executorIsLocal:()=>i.current()==="local"});t.current=C,o.handler=C.notifyQueueChange;let on=await fo({cwd:r,pool:S}),j=lr({claim:c.claim,config:e,cwd:r,initialId:m.devSessionId,pool:S,sseClient:h,sseHealth:d}),an=uo({config:e,devSessionId:m.devSessionId,executorSwitch:i,exploration:C,pool:S,sseClient:h}),sn=yo({config:e,session:j}),ln=xo();l.resolve(),mo(m.devSessionId);let dn=async()=>{sn(),ln(),I(),C.stop(),p.close(),j.stop(),an(),await S.close(),await i.stop(),await on.stop().catch(()=>{}),await Promise.race([u({config:e,document:lo,variables:{cwd:e.cwd,devSessionId:j.getId(),projectId:e.projectId}}).catch(()=>{}),new Promise(cn=>setTimeout(cn,3e3))]),n()},x=()=>{dn().finally(()=>process.exit(0))};a.handler=x,process.on("SIGINT",x),process.on("SIGTERM",x),process.on("SIGHUP",x),process.on("SIGBREAK",x),await new Promise(()=>{})}function co(){return{explorer:{kind:"off"},exploring:0,progress:{attempts:0,findings:0}}}function uo({config:e,devSessionId:r,executorSwitch:n,exploration:t,pool:o,sseClient:i}){let a=[rn({config:e,devSessionId:r,sseClient:i,switcher:n}),nn({cwd:e.cwd,projectId:e.projectId,sseClient:i}),en({pool:o,sseClient:i}),Yr({config:e,devSessionId:r,exploration:t,sseClient:i})];return()=>{a.forEach(l=>{l()})}}function po({config:e,devSessionId:r,executorIsLocal:n,pool:t}){return Ir({appUrl:e.appUrl,cwd:e.cwd,executorIsLocal:n,executeTrail:(o,i)=>t.exploreTrail(o,i),report:o=>{Xe({attempts:o.attempts,config:e,devSessionId:r,findings:o.findings,trail:Ve(o.result)}).catch(i=>{s.warn({error:i},"exploration progress report failed")})},reportUnhealthy:()=>{Ye(e,r).catch(o=>{s.warn({error:o},"exploration unhealthy report failed")})}})}function fo({cwd:e,pool:r}){return ve({localDir:no.join(e,".ripplo",".local"),writePortFile:!0,onRrwebBatch:()=>{},onSpan:n=>{let t=n.attributes["ripplo.run"];t!=null&&r.routeSpan(t,n)}})}function mo(e){process.stdout.write(`${Ae({devSessionId:e,version:ce()})}
|
|
148
|
+
`)}function yo({config:e,session:r}){let n=async()=>{try{let o=await u({config:e,document:ao,variables:{id:r.getId()}});o.heartbeatDevSession?.__typename==="DevSessionEndedError"&&(s.warn("dev session ended server-side (%s); re-registering",o.heartbeatDevSession.message),await r.reregister())}catch(o){s.warn("heartbeat failed: %s",o instanceof Error?o.message:String(o))}},t=setInterval(()=>{n()},io);return()=>{clearInterval(t)}}function go({cwd:e,devSessionId:r,initialConcurrency:n}){return zr({devSessionId:r,initialSize:n,spawn:Qr(Po(),e),lockfileProvider:async()=>{let t=await v(e);if(t.isErr())return{unavailable:`daemon-load-failed:${t.error.kind}`};let o=await xe(e,t.value);return{lockfileJson:se(le,o)}}})}function So(e){try{return be({cwd:e,onCompromised:ko})}catch(r){throw r instanceof Re&&(process.stderr.write(`${De({cwd:r.cwd,pid:r.pid})}
|
|
149
|
+
`),process.exit(1)),r}}function ko(){s.error("daemon lock compromised; shutting down"),process.stderr.write(`${qe()}
|
|
150
|
+
`),process.exit(1)}function ho(){let e={handler:()=>{}};return{promise:new Promise(n=>{e.handler=n}),resolve:()=>{e.handler()}}}async function vo({cwd:e,ipc:r,releasePid:n}){return(await kr({cwd:e,onConnection:r.handleConnection})).match(o=>o,o=>{process.stderr.write(`${Ce(o)}
|
|
151
|
+
`),n(),process.exit(1)})}function wo(e){return k(e).match(r=>r,r=>{process.stderr.write(`${fe(r)}
|
|
152
152
|
`),process.exit(1)})}function xo(){N({maxRuns:tn});let e=setInterval(()=>{N({maxRuns:tn})},oo);return()=>{clearInterval(e)}}function Ro(){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 bo=4;async function Eo(e){try{let n=(await u({config:e,document:so,variables:void 0})).currentUser?.maxLocalConcurrentRuns;if(n!=null)return H(n),n}catch(r){s.warn({err:r},"failed to fetch local concurrency setting; using default")}return bo}function Po(){let e=process.argv[1];if(e==null)throw new Error("cli entry unavailable");return e}export{Ja 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,l}from"./chunk-
|
|
4
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-T4GHICK4.js";import"./chunk-PPMW4GUY.js";import"./chunk-SBDRIIVW.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{b as renderDaemonBindError,h as renderDaemonLockCompromised,f as renderDaemonLockHeld,e as renderDaemonReady,i as renderDaemonStatus,g as renderDaemonStopResult,k as renderDaemonVersionNote,j as renderExplorationProgress,d as renderNotSignedIn,c as renderProjectAccessDenied,a as renderTunnelProvisionFailed,l 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{a,b,c,d,e,f}from"./chunk-
|
|
4
|
+
import{a,b,c,d,e,f}from"./chunk-INURHJF4.js";import"./chunk-52IE2PAQ.js";import"./chunk-CJUKILIO.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{e as DevLockHeldError,f as acquireDevLock,d as devPidPath,c as isDevSessionAlive,a as readDevPid,b as stopDevDaemon};
|
|
@@ -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}from"./chunk-
|
|
4
|
+
import{h as a,i as b,j as c,k as d}from"./chunk-ML7WCYPY.js";import"./chunk-SBDRIIVW.js";import"./chunk-KMZ3L5YA.js";export{a as LOCKFILE_RELATIVE_PATH,d as loadRipplo,b as loadRipploCached,c as loadRipploCachedWithFingerprint};
|
|
@@ -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{f as r}from"./chunk-
|
|
4
|
+
import{f as r}from"./chunk-3M2E253R.js";import{c as s}from"./chunk-KOKEEAEF.js";import{a as n}from"./chunk-MHNGR6M7.js";import"./chunk-INURHJF4.js";import"./chunk-52IE2PAQ.js";import"./chunk-CJUKILIO.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";import t from"fs";import a from"os";import l from"path";var w=s("PreToolUse",o=>{if(o.tool_name!=="ExitPlanMode"||!r(o.cwd))return;let i=p();if(i==null)return{hookSpecificOutput:{additionalContext:`Ripplo plan gate: no plan file found \u2014 the "Tests to implement" requirement was not checked. Before implementing, stub a .ripplo/workflows/ workflow per affected flow. ${n("discover")}`,hookEventName:"PreToolUse"}};let e=t.readFileSync(i,"utf8");if(!/\.ripplo\/tests|Tests to implement|No e2e coverage needed/.test(e))return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`Plan must cite ripplo test stubs. Add a "Tests to implement" section listing .ripplo/workflows/<id>.ts per affected flow, OR add "No e2e coverage needed: <reason>" if this plan touches no user-facing behavior. ${n("discover")}`}}});function p(){let o=l.join(a.homedir(),".claude","plans");return t.existsSync(o)?t.readdirSync(o).filter(e=>e.endsWith(".md")).map(e=>l.join(o,e)).map(e=>({full:e,mtime:t.statSync(e).mtimeMs})).sort((e,m)=>m.mtime-e.mtime)[0]?.full??null:null}export{w as exitPlanGateHook};
|
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 o,c as s}from"./chunk-
|
|
4
|
+
import{a as o,c as s}from"./chunk-YR3N73PR.js";import{a as i}from"./chunk-R4ZTRVDQ.js";import{c as e}from"./chunk-FEHVIHVA.js";import"./chunk-KOKEEAEF.js";import{a as r}from"./chunk-CJUKILIO.js";import"./chunk-KMZ3L5YA.js";o();e(process.cwd());r(i());s(process.argv[2]??"").catch(async t=>{let{renderTopLevelError:p}=await import("./cli-error-TM2YODR3.js");process.stderr.write(`${p(t)}
|
|
5
5
|
`),process.exit(1)});
|