ripplo 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-UFXH75WD.js → chunk-22KCYZGP.js} +3 -3
- package/dist/chunk-2QZIICHO.js +4 -0
- package/dist/chunk-2V4XEAR4.js +360 -0
- package/dist/{chunk-EEOTA6M4.js → chunk-6HGQIP4L.js} +1 -1
- package/dist/chunk-6PEFUZNO.js +83 -0
- package/dist/{chunk-D6TS77JP.js → chunk-7BLJ6357.js} +1 -1
- package/dist/{chunk-LWMXGWS2.js → chunk-CEUZS5YN.js} +1 -1
- package/dist/{chunk-4LXIRKM7.js → chunk-GL66NIOQ.js} +1 -1
- package/dist/{chunk-ROO3KF74.js → chunk-ISLXOVJF.js} +1 -1
- package/dist/{chunk-F4P36OMG.js → chunk-LBSM7G4L.js} +1 -1
- package/dist/{chunk-6U2LNGSV.js → chunk-LFBAW3EA.js} +1 -1
- package/dist/chunk-T6WA2F3S.js +16 -0
- package/dist/{chunk-EQORLKHG.js → chunk-TDIT65FZ.js} +1 -1
- package/dist/{chunk-WAGXAEB4.js → chunk-TROVQD5M.js} +1 -1
- package/dist/{chunk-WCMWNWNM.js → chunk-UNYR7SAP.js} +1 -1
- package/dist/{chunk-ZHDR7LXB.js → chunk-WZBHHW7X.js} +18 -18
- package/dist/{chunk-ZM2UPFCR.js → chunk-XA4ZWH7N.js} +2 -2
- package/dist/chunk-XJRG46JA.js +4 -0
- package/dist/{chunk-UC54UNEX.js → chunk-XPPUVBTI.js} +1 -1
- package/dist/{chunk-6WFJZ5L6.js → chunk-XSO43S23.js} +1 -1
- package/dist/{cli-error-6PUIWNIT.js → cli-error-VML3CZTB.js} +1 -1
- package/dist/{compile-write-N3PWYUKE.js → compile-write-AWMMKBY4.js} +1 -1
- package/dist/{daemon-X77GWCFM.js → daemon-2LB22RRW.js} +13 -13
- package/dist/{daemon-SAV2CLXD.js → daemon-RDOVYYAZ.js} +1 -1
- package/dist/{dsl-loader-WPAKMON7.js → dsl-loader-GZILSBK5.js} +1 -1
- package/dist/hook.js +1 -1
- package/dist/index.js +195 -187
- package/dist/{plan-reminder-YX375SPX.js → plan-reminder-V7RZXP37.js} +1 -1
- package/dist/{post-edit-7W6AHXE6.js → post-edit-D6EBGSYK.js} +1 -1
- package/dist/post-edit-analyze-NSUCATEN.js +4 -0
- package/dist/{post-edit-flag-stubs-G3G2FO6Z.js → post-edit-flag-stubs-CGV4LWX2.js} +1 -1
- package/dist/{pre-edit-C4MGURNO.js → pre-edit-MPV73OUC.js} +1 -1
- package/dist/{pre-edit-scope-gate-M5IQSVGF.js → pre-edit-scope-gate-HNIQ7KOQ.js} +1 -1
- package/dist/{pre-edit-watch-gate-ORQP7MSW.js → pre-edit-watch-gate-BXICNZNF.js} +1 -1
- package/dist/{prompt-submit-YOKR2RQN.js → prompt-submit-DO3YGL4V.js} +1 -1
- package/dist/status-4LFECRO4.js +4 -0
- package/dist/{stop-enforce-JT3SWBU4.js → stop-enforce-CEUM4LIV.js} +1 -1
- package/package.json +2 -2
- package/dist/chunk-2TA4WDEE.js +0 -4
- package/dist/chunk-5HZ2LDFS.js +0 -83
- package/dist/chunk-5VXXRMJU.js +0 -354
- package/dist/chunk-7JKCHASU.js +0 -4
- package/dist/chunk-PXXURBGC.js +0 -16
- package/dist/post-edit-analyze-PO54GIZ3.js +0 -4
- package/dist/status-HOJW4C3O.js +0 -4
|
@@ -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{a as s}from"./chunk-HEOMRXZE.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-44YWEKYS.js").then(o=>o.exitPlanGateHook),"plan-reminder":()=>import("./plan-reminder-
|
|
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-44YWEKYS.js").then(o=>o.exitPlanGateHook),"plan-reminder":()=>import("./plan-reminder-V7RZXP37.js").then(o=>t("UserPromptSubmit",o.planReminder)),"post-edit":()=>import("./post-edit-D6EBGSYK.js").then(o=>o.postEditHook),"post-edit-analyze":()=>import("./post-edit-analyze-NSUCATEN.js").then(o=>t("PostToolUse",o.postEditAnalyze)),"post-edit-flag-stubs":()=>import("./post-edit-flag-stubs-CGV4LWX2.js").then(o=>t("PostToolUse",o.postEditFlagStubs)),"pre-bash-run-gate":()=>import("./pre-bash-run-gate-MIEM2DBB.js").then(o=>o.preBashRunGateHook),"pre-edit":()=>import("./pre-edit-MPV73OUC.js").then(o=>o.preEditHook),"pre-edit-ripplo-skill-gate":()=>import("./pre-edit-ripplo-skill-gate-A6ETC3QN.js").then(o=>t("PreToolUse",o.preEditRipploSkillGate)),"pre-edit-scope-gate":()=>import("./pre-edit-scope-gate-HNIQ7KOQ.js").then(o=>t("PreToolUse",o.preEditScopeGate)),"pre-edit-watch-gate":()=>import("./pre-edit-watch-gate-BXICNZNF.js").then(o=>t("PreToolUse",o.preEditWatchGate)),"prompt-submit":()=>import("./prompt-submit-DO3YGL4V.js").then(o=>o.promptSubmitHook),"scope-reminder":()=>import("./scope-reminder-A6GVTTVE.js").then(o=>t("UserPromptSubmit",o.scopeReminder)),"session-preamble":()=>import("./session-preamble-IZQPIWST.js").then(o=>o.sessionPreambleHook),"stop-enforce":()=>import("./stop-enforce-CEUM4LIV.js").then(o=>o.stopEnforceHook),"tasks-reminder":()=>import("./tasks-reminder-TDWPD3KV.js").then(o=>t("UserPromptSubmit",o.tasksReminder)),"tasks-reminder-tool":()=>Promise.resolve(t("PostToolUse",()=>{})),"track-skill-load":()=>import("./track-skill-load-SXSDMHFO.js").then(o=>o.trackSkillLoadHook),"track-skill-prompt":()=>import("./track-skill-prompt-7N4TQAD2.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-VML3CZTB.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{U as d}from"./chunk-WZBHHW7X.js";import{j as p}from"./chunk-C7SV6AR2.js";import{spawnSync as k}from"child_process";import{existsSync as c,readdirSync as m,readFileSync as j,realpathSync as f,statSync as g}from"fs";import i from"path";var S=2e3;function x(t){if(t!=null)try{return g(f(t)).mtimeMs}catch{return}}function B(t){return k("pnpm",["turbo","run","build","--filter=ripplo..."],{cwd:t,stdio:"inherit"}).status===0}function X(){let t=process.argv[1];return t==null?{kind:"fresh"}:R({cwd:process.cwd(),scriptPath:f(t)})}function R({cwd:t,scriptPath:n}){let o=l(i.dirname(n));if(o!=null&&u(o))return n.includes(`${i.sep}src${i.sep}`)?{kind:"fresh"}:E({bundlePath:n,root:o});let r=l(t);return r!=null&&u(r)?{kind:"foreign-binary",workspaceRoot:r}:{kind:"fresh"}}function l(t){let n=i.dirname(t);return c(i.join(t,"pnpm-workspace.yaml"))?t:n===t?void 0:l(n)}function u(t){let n=i.join(t,"packages","cli","package.json"),o=w(n);return typeof o=="object"&&o!=null&&"name"in o&&o.name==="ripplo"}function w(t){try{return JSON.parse(j(t,"utf8"))}catch{return}}function E({bundlePath:t,root:n}){let o=x(t),r=i.join(n,"packages");if(o==null||!c(r))return{kind:"fresh"};let a=m(r).map(s=>({name:s,src:i.join(r,s,"src")})).filter(s=>c(s.src)).filter(s=>b(s.src)>o+S).map(s=>s.name);return a.length===0?{kind:"fresh"}:{kind:"stale",packages:a,workspaceRoot:n}}function b(t){let n=g(t);if(!n.isDirectory())return n.mtimeMs;let o=m(t).map(r=>b(i.join(t,r)));return Math.max(n.mtimeMs,...o)}import{createHash as P}from"crypto";import M from"os";import I from"path";import{createMessageConnection as q,NotificationType as y,RequestType as v,RequestType0 as h,SocketMessageReader as A,SocketMessageWriter as N}from"vscode-jsonrpc/node";import{z as e}from"zod";var C="daemon.log";function ee(t){let n=P("sha256").update(t).digest("hex").slice(0,16);return I.join(M.tmpdir(),`ripplo-${n}.sock`)}function te(t){return p(t,C)}function ne(t){return q(new A(t),new N(t))}var oe=e.object({all:e.boolean(),headed:e.boolean(),tests:e.array(e.string())}),re=e.object({jobId:e.string(),total:e.number()}),z=e.enum(["no-lockfile","unstamped","dsl-drift","load-failed","model-empty"]),F=e.discriminatedUnion("kind",[e.object({kind:e.literal("off")}),e.object({kind:e.literal("on")}),e.object({kind:e.literal("paused"),reason:e.enum(["interactive-runs","cooldown","loading"]).optional()}),e.object({kind:e.literal("waiting")}),e.object({kind:e.literal("blocked"),reason:z})]),O=e.object({attempts:e.number(),findings:e.number()}),ie=e.object({active:e.number(),bundleMtimeMs:e.number().optional(),explorer:F,exploring:e.number(),progress:O,queued:e.number(),sseHealth:e.object({detail:e.string().optional(),ok:e.boolean()}).optional(),version:e.string().optional()}),L=e.enum(["MAX_RUNS","OVERAGE_CAP","MAX_AGENTS","MAX_CONCURRENT_RUNS","MAX_PROJECTS","CLOUD_EXECUTOR","REVIEW_QUOTA","MEMBER_CEILING"]),U=e.discriminatedUnion("type",[e.object({code:L,type:e.literal("limit")}),e.object({detail:e.string(),type:e.literal("generic")})]),_=e.discriminatedUnion("kind",[e.object({kind:e.literal("pass")}),e.object({findingLines:e.array(e.string()),kind:e.literal("findings")}),e.object({detail:e.string(),kind:e.literal("error")}),e.object({kind:e.literal("dispatch-error"),reason:U}),e.object({detail:e.string(),kind:e.literal("dispatch-timeout")}),e.object({detail:e.string(),kind:e.literal("infra-error")})]),W=e.discriminatedUnion("kind",[e.object({kind:e.literal("run-progress"),runId:e.string(),signal:d,testName:e.string(),workflowName:e.string()}),e.object({kind:e.literal("test-started"),runId:e.string(),testName:e.string(),workflowName:e.string()}),e.object({kind:e.literal("test-outcome"),outcome:_,runId:e.string(),testName:e.string(),workflowName:e.string()})]),se=e.object({event:W,jobId:e.string()}),ae=e.object({failed:e.number(),jobId:e.string(),notRun:e.number(),passed:e.number()}),ce=e.discriminatedUnion("code",[e.object({code:e.literal("compile-failed"),detail:e.string(),diagnostics:e.array(e.string()).default([])}),e.object({code:e.literal("selection-conflicting-flags")}),e.object({code:e.literal("selection-nothing-selected")}),e.object({code:e.literal("selection-unknown-ids"),known:e.array(e.string()),unknown:e.array(e.string())}),e.object({code:e.literal("scope-failed"),detail:e.string()}),e.object({code:e.literal("app-unreachable"),detail:e.string(),url:e.string()}),e.object({code:e.literal("engine-unreachable"),detail:e.string(),url:e.string()}),e.object({code:e.literal("sync-failed"),detail:e.string()}),e.object({code:e.literal("bad-message")})]),le=new v("ripplo/enqueue"),pe=new h("ripplo/status"),de=new h("ripplo/shutdownIfIdle"),ue=new y("ripplo/jobEvent"),me=new y("ripplo/jobDone");export{x as a,B as b,X as c,ee as d,te as e,ne as f,oe as g,re as h,ie as i,_ as j,se as k,ae as l,ce as m,le as n,pe as o,de as p,ue as q,me as r};
|
|
@@ -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 n}from"./chunk-7WZ3VIUU.js";import{f as r}from"./chunk-KH4QH23U.js";var m=async o=>{if(o.permission_mode!=="plan"||!n(o.cwd)||!r(o.cwd))return;let{loadRipplo:s}=await import("./dsl-loader-
|
|
4
|
+
import{a as n}from"./chunk-7WZ3VIUU.js";import{f as r}from"./chunk-KH4QH23U.js";var m=async o=>{if(o.permission_mode!=="plan"||!n(o.cwd)||!r(o.cwd))return;let{loadRipplo:s}=await import("./dsl-loader-GZILSBK5.js"),{stubbedWorkflows:a}=await import("./compile-write-AWMMKBY4.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 o}from"./chunk-
|
|
4
|
+
import{a as o}from"./chunk-TROVQD5M.js";import{a as t}from"./chunk-MHNGR6M7.js";var r=class extends Error{failure;constructor(i){super(i.kind),this.name="CliError",this.failure=i}};function u(e){return e instanceof r?a(e.failure):e instanceof Error?e.message:String(e)}function a(e){switch(e.kind){case"project-file-missing":return[`Missing ${e.path} \u2014 this directory is not a Ripplo project.`,"Run `npx ripplo init` to create it (or cd into the project root).",t("setup")].join(`
|
|
5
5
|
`);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(i=>` ${i}`),"Fix the file by hand or re-run `npx ripplo init`."].join(`
|
|
6
6
|
`);case"not-authenticated":return["Not signed in. Run `npx ripplo auth login`.","(Claude Code: run it yourself in the background \u2014 the user just approves in the browser.)"].join(`
|
|
7
7
|
`);case"env-invalid":return s(e);case"playwright-install-failed":return["Playwright browser install failed \u2014 Chromium is still missing.","Run `npx playwright install chromium` and check its output for network, proxy, or disk-space errors."].join(`
|
|
@@ -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-XSO43S23.js";import"./chunk-TROVQD5M.js";import"./chunk-MHNGR6M7.js";import"./chunk-2QZIICHO.js";import"./chunk-WZBHHW7X.js";import"./chunk-KMZ3L5YA.js";export{b as renderCliFailure,c as renderHookCrash,a as renderTopLevelError};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{h as a,i as b,j as c,k as d,l as e,m as f}from"./chunk-
|
|
4
|
+
import{h as a,i as b,j as c,k as d,l as e,m as f}from"./chunk-GL66NIOQ.js";import"./chunk-6PEFUZNO.js";import"./chunk-2QZIICHO.js";import"./chunk-WZBHHW7X.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 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-
|
|
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-2V4XEAR4.js";import{a as Me,b as Oe,c as Ue,d as $e,e as je,g as Fe}from"./chunk-22KCYZGP.js";import{d as qe}from"./chunk-XJRG46JA.js";import{b as He}from"./chunk-XSO43S23.js";import{a as Ae,c as De,d as Le,e as h}from"./chunk-LFBAW3EA.js";import{a as C}from"./chunk-TROVQD5M.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-GL66NIOQ.js";import{G as ve,I as we,J as xe,M as I,N as be,O as Re,R as Ee,S as Pe,X as Ie,aa as Te,m as ke}from"./chunk-6PEFUZNO.js";import{k as S,l as he,m as P}from"./chunk-2QZIICHO.js";import{Ba as Se,S as ye,oa as ge}from"./chunk-WZBHHW7X.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
5
|
subscription RunRequestedWatch($devSessionId: String!) {
|
|
6
6
|
runRequested(devSessionId: $devSessionId) {
|
|
7
7
|
runId
|
|
@@ -81,7 +81,7 @@ 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
|
|
|
81
81
|
mutation RetireStaleFinding($projectId: String!, $signature: String!) {
|
|
82
82
|
retireStaleFinding(projectId: $projectId, signature: $signature)
|
|
83
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(()=>$o({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){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 $o({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 jo({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:()=>Fo({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 jo({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 Fo({assign:e,params:r,signal:n}){let o=await r.executeTrail(e,n);return o.kind==="aborted"?{kind:"aborted"}:o.kind==="error"?_o(r,o.error):{kind:"done",result:o}}async function _o(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 tt}from"gql.tada";import{connect as No}from"net";import zo from"ssh2";import{WebSocket as Nr,createWebSocketStream as Bo}from"ws";var Go="ripplo-";function Y(e){return Object.entries(e).map(([r,n])=>`${Go}${r}.${n}`)}var{Server:Ko,utils:Gr}=zo;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:Qo(t,o)})}),t.on("message",i=>{Jo(e,o,i)}),t.on("close",(i,a)=>{o.stopped||s.warn({code:i,reason:a.toString()},"relay control closed"),ot(e,o)}),t.on("error",i=>{n(i instanceof Error?i:new Error(String(i)))})})}function Qo(e,r){return()=>(r.stopped=!0,r.closers.forEach(n=>{n()}),e.close(),Promise.resolve())}function Jo(e,r,n){let o=Vo(n);o!=null&&Yo(e,r,o.pipeId)}function Vo(e){try{let r=JSON.parse(Xo(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 Xo(e){return Buffer.isBuffer(e)?e.toString("utf8"):Array.isArray(e)?Buffer.concat(e).toString("utf8"):Buffer.from(e).toString("utf8")}function Yo(e,r,n){if(r.stopped)return;let o=new Nr(e.relayUrl,Y({pipeId:n,role:"daemon-data"}));o.on("open",()=>{Zo(e,r,o)}),o.on("error",t=>{s.warn({err:t},"cloud-executor relay data pipe error")})}function Zo(e,r,n){let o=Bo(n);o.on("error",()=>{});let t=new Ko({hostKeys:[e.hostKey.privateKey]},a=>{a.on("error",l=>{s.warn({err:l},"cloud-executor ssh connection error")}),a.on("authentication",l=>{rt(l,e.secret)}),a.on("ready",()=>{a.on("tcpip",(l,d,c)=>{nt({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(t,o)}function et(e,r){e.injectSocket(r)}function rt(e,r){if(e.method==="password"&&e.password===r){e.accept();return}if(e.method==="none"){e.reject(["password"]);return}e.reject()}function nt({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=No({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 ot(e,r){r.stopped||(r.stopped=!0,r.closers.forEach(n=>{n()}),e.onFatal())}var it=tt(`
|
|
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
85
|
mutation EnterCloudMode(
|
|
86
86
|
$devSessionId: String!
|
|
87
87
|
$localUrl: String!
|
|
@@ -110,7 +110,7 @@ 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
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
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:
|
|
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
114
|
mutation EndDevSessionWatch($projectId: String!, $cwd: String!, $devSessionId: String) {
|
|
115
115
|
endDevSession(projectId: $projectId, cwd: $cwd, devSessionId: $devSessionId) {
|
|
116
116
|
__typename
|
|
@@ -122,7 +122,7 @@ 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
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
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:
|
|
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
126
|
mutation HeartbeatDevSessionWatch($id: String!) {
|
|
127
127
|
heartbeatDevSession(id: $id) {
|
|
128
128
|
__typename
|
|
@@ -134,19 +134,19 @@ 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
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
`),
|
|
137
|
+
`),qt=Sn(`
|
|
138
138
|
query WatchLocalConcurrency {
|
|
139
139
|
currentUser {
|
|
140
140
|
id
|
|
141
141
|
maxLocalConcurrentRuns
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
`);async function
|
|
145
|
-
`),process.exit(1));let hn=G.value,v=await
|
|
146
|
-
`)}function
|
|
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
147
|
`),process.exit(1)),n==="FORBIDDEN"&&(process.stderr.write(`ripplo: ${Oe({projectId:e.projectId,serverUrl:e.ripploServerUrl})}
|
|
148
|
-
`),process.exit(1))}async function
|
|
149
|
-
`),process.exit(1)),r}}function
|
|
150
|
-
`),process.exit(1)}function
|
|
151
|
-
`),n(),process.exit(1)})}function
|
|
152
|
-
`),process.exit(1)})}function
|
|
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 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-
|
|
4
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-22KCYZGP.js";import"./chunk-6PEFUZNO.js";import"./chunk-WZBHHW7X.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as renderDaemonBindError,g as renderDaemonLockCompromised,e as renderDaemonLockHeld,d as renderDaemonReady,h as renderDaemonStatus,f as renderDaemonStopResult,j as renderDaemonVersionNote,i as renderExplorationProgress,c as renderNotSignedIn,b as renderProjectAccessDenied,k as wireOutcome};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{j as a,k as b,l as c,m as d,n as e}from"./chunk-
|
|
4
|
+
import{j as a,k as b,l as c,m as d,n as e}from"./chunk-2QZIICHO.js";import"./chunk-WZBHHW7X.js";import"./chunk-KMZ3L5YA.js";export{a as LOCKFILE_RELATIVE_PATH,d as loadRipplo,b as loadRipploCached,c as loadRipploCachedWithFingerprint,e as ripploFingerprint};
|
package/dist/hook.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __ripploCreateRequire } from "node:module";
|
|
3
3
|
const require = globalThis.require ?? __ripploCreateRequire(import.meta.url);
|
|
4
|
-
import{a as r,c as s}from"./chunk-
|
|
4
|
+
import{a as r,c as s}from"./chunk-XA4ZWH7N.js";import{a as i}from"./chunk-R4ZTRVDQ.js";import{c as o}from"./chunk-FEHVIHVA.js";import"./chunk-KOKEEAEF.js";import{b as e}from"./chunk-HEOMRXZE.js";import"./chunk-KMZ3L5YA.js";r();o(process.cwd());e(i());s(process.argv[2]??"").catch(async t=>{let{renderTopLevelError:p}=await import("./cli-error-VML3CZTB.js");process.stderr.write(`${p(t)}
|
|
5
5
|
`),process.exit(1)});
|