ripplo 0.8.3 → 0.9.1

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.
Files changed (49) hide show
  1. package/dist/{chunk-5SM4TCSW.js → chunk-4F67XQYS.js} +19 -19
  2. package/dist/{chunk-EGETJKAQ.js → chunk-4H7EIC6W.js} +1 -1
  3. package/dist/{chunk-XBD3OTIW.js → chunk-4XC5TAOG.js} +1 -1
  4. package/dist/chunk-6BQADUAX.js +229 -0
  5. package/dist/chunk-EVVF662P.js +6 -0
  6. package/dist/chunk-INO3L4WS.js +4 -0
  7. package/dist/{chunk-N2B5GZPU.js → chunk-IRTBARRY.js} +1 -1
  8. package/dist/chunk-MG43RZXH.js +83 -0
  9. package/dist/{chunk-4FKGHWCC.js → chunk-MMCOPC4L.js} +1 -1
  10. package/dist/{chunk-7TYUZIUO.js → chunk-NEPJCCQS.js} +1 -1
  11. package/dist/{chunk-2MT2MZJW.js → chunk-Q6IYTHMP.js} +1 -1
  12. package/dist/chunk-RWFS5SCW.js +6 -0
  13. package/dist/{chunk-SWOTFHBR.js → chunk-SFWAAS5H.js} +1 -1
  14. package/dist/{chunk-PXZV5X3C.js → chunk-TY5K3P4F.js} +1 -1
  15. package/dist/{chunk-7Z7RVHEL.js → chunk-UMSBDSRS.js} +2 -2
  16. package/dist/chunk-WZBLSDNV.js +4 -0
  17. package/dist/{chunk-AVBP7Q2M.js → chunk-XZ2TPZLD.js} +1 -1
  18. package/dist/{chunk-LKYTQXPR.js → chunk-YODZBLYM.js} +1 -1
  19. package/dist/{chunk-UVYCSHOJ.js → chunk-ZUPS6XVH.js} +1 -1
  20. package/dist/{cli-error-SLG6JHK2.js → cli-error-J33JDZET.js} +1 -1
  21. package/dist/{compile-write-7AV66JUA.js → compile-write-4ZAIPQMG.js} +1 -1
  22. package/dist/{daemon-LFFCR3TB.js → daemon-MZWLJO75.js} +1 -1
  23. package/dist/daemon-YPXZGJAB.js +152 -0
  24. package/dist/{dsl-loader-H25XGSHJ.js → dsl-loader-5Z2JRKY3.js} +1 -1
  25. package/dist/hook.js +1 -1
  26. package/dist/index.js +189 -182
  27. package/dist/{plan-reminder-VMBDQTAP.js → plan-reminder-45PSVOVW.js} +1 -1
  28. package/dist/post-edit-JHJT2QTK.js +4 -0
  29. package/dist/post-edit-analyze-PPFHKIYQ.js +4 -0
  30. package/dist/post-edit-flag-stubs-Q3UKDZ2W.js +4 -0
  31. package/dist/{pre-edit-Q4U5LSWG.js → pre-edit-EJO3TUNQ.js} +1 -1
  32. package/dist/{pre-edit-watch-gate-EUZGEH2J.js → pre-edit-watch-gate-DZHQCMEI.js} +1 -1
  33. package/dist/{prompt-submit-MPRVCWOI.js → prompt-submit-ZCDG6T4Y.js} +1 -1
  34. package/dist/{session-preamble-IHBGHKCW.js → session-preamble-ZYVRDSGA.js} +1 -1
  35. package/dist/solve-worker.js +1 -1
  36. package/dist/status-66XIDYSP.js +4 -0
  37. package/dist/{stop-enforce-UXBQRTFP.js → stop-enforce-Q4JNBYQU.js} +1 -1
  38. package/package.json +6 -5
  39. package/dist/chunk-AQ3DMGAY.js +0 -6
  40. package/dist/chunk-EK6TENV6.js +0 -4
  41. package/dist/chunk-ESOXRGIY.js +0 -83
  42. package/dist/chunk-GD63CZVP.js +0 -242
  43. package/dist/chunk-M7VQD4VO.js +0 -6
  44. package/dist/chunk-OY6HNCAZ.js +0 -4
  45. package/dist/daemon-EGU25OUV.js +0 -139
  46. package/dist/post-edit-2VFE6QND.js +0 -4
  47. package/dist/post-edit-analyze-VETPP5Z4.js +0 -4
  48. package/dist/post-edit-flag-stubs-J3MCGLXI.js +0 -4
  49. package/dist/status-UBUNHH5O.js +0 -4
@@ -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-4W6WIT7T.js";var m=async o=>{if(o.permission_mode!=="plan"||!r(o.cwd)||!n(o.cwd))return;let{loadRipplo:s}=await import("./dsl-loader-H25XGSHJ.js"),{stubbedWorkflows:a}=await import("./compile-write-7AV66JUA.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(`
4
+ import{a as r}from"./chunk-7WZ3VIUU.js";import{f as n}from"./chunk-4W6WIT7T.js";var m=async o=>{if(o.permission_mode!=="plan"||!r(o.cwd)||!n(o.cwd))return;let{loadRipplo:s}=await import("./dsl-loader-5Z2JRKY3.js"),{stubbedWorkflows:a}=await import("./compile-write-4ZAIPQMG.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{b as w,c as P}from"./chunk-T5VLZ43M.js";import{a as m}from"./chunk-MOI4L3EX.js";import{a as u,c as y,d as g}from"./chunk-PXZV5X3C.js";import{a as h}from"./chunk-OQ6KNYPG.js";import{f as S}from"./chunk-UVYCSHOJ.js";import{a as c}from"./chunk-7WZ3VIUU.js";import{f as k}from"./chunk-4W6WIT7T.js";import{a as l}from"./chunk-AVBP7Q2M.js";import{a as s}from"./chunk-MHNGR6M7.js";import{e as f,f as p}from"./chunk-EK6TENV6.js";import{e as d}from"./chunk-ESOXRGIY.js";import{createHash as b}from"crypto";import*as a from"zod/mini";var v=a.looseObject({file_path:a.string()}),M=async e=>{let o=v.safeParse(e.tool_input);if(!o.success||!/\/\.ripplo\/.*\.ts$/.test(o.data.file_path))return;let{cwd:t}=e;if(!c(t))return;if(!k(t))return{hookSpecificOutput:{additionalContext:"Ripplo hooks are paused \u2014 DSL compile and lockfile sync did not run for this edit. Resume with `npx ripplo hooks resume` when ready.",hookEventName:"PostToolUse"}};let r=await f(t);if(r.isErr())return{decision:"block",reason:`${l(r.error)}
4
+ import{b as w,c as P}from"./chunk-T5VLZ43M.js";import{a as m}from"./chunk-MOI4L3EX.js";import{a as u,c as y,d as g}from"./chunk-TY5K3P4F.js";import{a as h}from"./chunk-OQ6KNYPG.js";import{f as S}from"./chunk-ZUPS6XVH.js";import{a as c}from"./chunk-7WZ3VIUU.js";import{f as k}from"./chunk-4W6WIT7T.js";import{a as l}from"./chunk-XZ2TPZLD.js";import{a as s}from"./chunk-MHNGR6M7.js";import{e as f,f as p}from"./chunk-INO3L4WS.js";import{e as d}from"./chunk-MG43RZXH.js";import{createHash as b}from"crypto";import*as a from"zod/mini";var v=a.looseObject({file_path:a.string()}),M=async e=>{let o=v.safeParse(e.tool_input);if(!o.success||!/\/\.ripplo\/.*\.ts$/.test(o.data.file_path))return;let{cwd:t}=e;if(!c(t))return;if(!k(t))return{hookSpecificOutput:{additionalContext:"Ripplo hooks are paused \u2014 DSL compile and lockfile sync did not run for this edit. Resume with `npx ripplo hooks resume` when ready.",hookEventName:"PostToolUse"}};let r=await f(t);if(r.isErr())return{decision:"block",reason:`${l(r.error)}
5
5
  ${s("create","DSL authoring rules")}`};let n=await N({cwd:t,filePath:o.data.file_path,lockfile:r.value});if("block"in n)return{decision:"block",reason:n.block};let{addedSlugs:i}=await S({cwd:t,editedPath:o.data.file_path,lockfile:r.value});return L(z({addedSlugs:i,cwd:t,elsewhere:n.elsewhere,lockfile:r.value}))};function z({addedSlugs:e,cwd:o,elsewhere:t,lockfile:r}){return[...e.length>0?[`Auto-scoped ${e.join(", ")} (dirty tests).`]:[],...t>0?[A(t).trimStart()]:[],...T(o,r)]}async function N({cwd:e,filePath:o,lockfile:t}){let r=await u({cwd:e,lockfile:t});await p(e,t);let n=R(r,t,o),i=r.length-n.length;return n.length===0?{elsewhere:i}:{block:`${y(n)}${A(i)}
6
6
  ${s("create")}`}}function R(e,o,t){let r=new Set(d(o).filter(({workflow:n})=>n.sourcePath!=null&&t.endsWith(n.sourcePath)).map(({ref:n})=>n));return r.size===0?e:e.filter(n=>{let i=F(n);return i==null||r.has(i)})}function F(e){return e.kind==="unreachable-interaction"?e.violation.test:e.kind==="redundant-assertion"?e.redundancy.test:e.kind==="missing-precondition"?e.missing.test:null}function A(e){return e===0?"":`
7
7
  ${h(e,"finding")} in other files \u2014 \`npx ripplo compile\` for the full list.`}function L(e){if(e.length!==0)return{hookSpecificOutput:{additionalContext:e.join(`
@@ -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-AVBP7Q2M.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(`
4
+ import{a as o}from"./chunk-XZ2TPZLD.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(`
@@ -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{A as i,C as s,F as d,i as t}from"./chunk-MG43RZXH.js";function y(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 $(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 b({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 w(){return"Not signed in. Run `npx ripplo auth login`, then start the daemon again."}function v({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 S({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 j(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 R(){return"ripplo daemon: lock compromised \u2014 another daemon likely took over this project. Shutting down."}function P(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}`,p=`${String(n.active)} active, ${String(n.queued)} queued`,l=m(n.explorer,n.exploring),o=`daemon: running (${r} | ${p} | ${l} | ${u(n.progress)})`;if(n.sseHealth!=null&&!n.sseHealth.ok){let c=n.sseHealth.detail==null?"":`: ${n.sseHealth.detail}`;return`${o}
6
+ daemon: cannot subscribe to run dispatch${c} \u2014 server-side, restarting the daemon will not help`}return o}function u(e){return e.attempts===0?"explore: idle":`explore: ${String(e.attempts)} attempts, ${String(e.findings)} findings`}function D(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 F(e){switch(e.kind){case"pass":return{kind:"pass"};case"findings":return{findingLines:f(e.findings).map(n=>d({evidencePath:`.ripplo/debug/${e.runId}/behavior.jsonl`,finding:n})),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 m(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 ${g(e.reason)}`}}function g(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"}}function f(e){let n=new Set(e.flatMap(r=>h(r)?[a(r)]:[]));return e.filter(r=>!(k(r)&&n.has(a(r))))}function h(e){return e.kind==="pending-check"&&e.source.kind==="step"}function a(e){return e.kind!=="pending-check"||e.source.kind==="data-rule"?"":`${i(e.source.check)}|${s(e.step)}`}function k(e){return e.kind==="pending-check"&&e.source.kind==="fact"}export{y as a,$ as b,b as c,w as d,v as e,S as f,j as g,R as h,P as i,u as j,D as k,F as l};
@@ -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-I5BHCICM.js";import{a as f}from"./chunk-JJ4QQPAV.js";import{a as m}from"./chunk-7WZ3VIUU.js";import{f as c}from"./chunk-4W6WIT7T.js";import{i as p}from"./chunk-EK6TENV6.js";import{h as l}from"./chunk-AQ3DMGAY.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};
4
+ import{b as u}from"./chunk-I5BHCICM.js";import{a as f}from"./chunk-JJ4QQPAV.js";import{a as m}from"./chunk-7WZ3VIUU.js";import{f as c}from"./chunk-4W6WIT7T.js";import{i as p}from"./chunk-INO3L4WS.js";import{k as l}from"./chunk-EVVF662P.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};
@@ -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-EK6TENV6.js";import{L as $,f as u,k as c,n as f,p as m,q as p,r as g,s as y,t as h,u as S,v,w as o}from"./chunk-ESOXRGIY.js";import{A as d,H as l}from"./chunk-5SM4TCSW.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(`
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-INO3L4WS.js";import{L as $,f as u,k as c,n as f,p as m,q as p,r as g,s as y,t as h,u as S,v,w as o}from"./chunk-MG43RZXH.js";import{E as d,L as l}from"./chunk-4F67XQYS.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};
@@ -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-BNAUL4FC.js").then(o=>o.exitPlanGateHook),"plan-reminder":()=>import("./plan-reminder-VMBDQTAP.js").then(o=>t("UserPromptSubmit",o.planReminder)),"post-edit":()=>import("./post-edit-2VFE6QND.js").then(o=>o.postEditHook),"post-edit-analyze":()=>import("./post-edit-analyze-VETPP5Z4.js").then(o=>t("PostToolUse",o.postEditAnalyze)),"post-edit-flag-stubs":()=>import("./post-edit-flag-stubs-J3MCGLXI.js").then(o=>t("PostToolUse",o.postEditFlagStubs)),"pre-bash-run-gate":()=>import("./pre-bash-run-gate-PWLARIYK.js").then(o=>o.preBashRunGateHook),"pre-edit":()=>import("./pre-edit-Q4U5LSWG.js").then(o=>o.preEditHook),"pre-edit-ripplo-skill-gate":()=>import("./pre-edit-ripplo-skill-gate-JD4BDCA3.js").then(o=>t("PreToolUse",o.preEditRipploSkillGate)),"pre-edit-scope-gate":()=>import("./pre-edit-scope-gate-NZO4HVGT.js").then(o=>t("PreToolUse",o.preEditScopeGate)),"pre-edit-watch-gate":()=>import("./pre-edit-watch-gate-EUZGEH2J.js").then(o=>t("PreToolUse",o.preEditWatchGate)),"prompt-submit":()=>import("./prompt-submit-MPRVCWOI.js").then(o=>o.promptSubmitHook),"scope-reminder":()=>import("./scope-reminder-CBY4I5SG.js").then(o=>t("UserPromptSubmit",o.scopeReminder)),"session-preamble":()=>import("./session-preamble-IHBGHKCW.js").then(o=>o.sessionPreambleHook),"stop-enforce":()=>import("./stop-enforce-UXBQRTFP.js").then(o=>o.stopEnforceHook),"tasks-reminder":()=>import("./tasks-reminder-LKSUZUFD.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-SLG6JHK2.js");process.stderr.write(`${a(o,r.error)}
5
+ `))}var d={"exit-plan-gate":()=>import("./exit-plan-gate-BNAUL4FC.js").then(o=>o.exitPlanGateHook),"plan-reminder":()=>import("./plan-reminder-45PSVOVW.js").then(o=>t("UserPromptSubmit",o.planReminder)),"post-edit":()=>import("./post-edit-JHJT2QTK.js").then(o=>o.postEditHook),"post-edit-analyze":()=>import("./post-edit-analyze-PPFHKIYQ.js").then(o=>t("PostToolUse",o.postEditAnalyze)),"post-edit-flag-stubs":()=>import("./post-edit-flag-stubs-Q3UKDZ2W.js").then(o=>t("PostToolUse",o.postEditFlagStubs)),"pre-bash-run-gate":()=>import("./pre-bash-run-gate-PWLARIYK.js").then(o=>o.preBashRunGateHook),"pre-edit":()=>import("./pre-edit-EJO3TUNQ.js").then(o=>o.preEditHook),"pre-edit-ripplo-skill-gate":()=>import("./pre-edit-ripplo-skill-gate-JD4BDCA3.js").then(o=>t("PreToolUse",o.preEditRipploSkillGate)),"pre-edit-scope-gate":()=>import("./pre-edit-scope-gate-NZO4HVGT.js").then(o=>t("PreToolUse",o.preEditScopeGate)),"pre-edit-watch-gate":()=>import("./pre-edit-watch-gate-DZHQCMEI.js").then(o=>t("PreToolUse",o.preEditWatchGate)),"prompt-submit":()=>import("./prompt-submit-ZCDG6T4Y.js").then(o=>o.promptSubmitHook),"scope-reminder":()=>import("./scope-reminder-CBY4I5SG.js").then(o=>t("UserPromptSubmit",o.scopeReminder)),"session-preamble":()=>import("./session-preamble-ZYVRDSGA.js").then(o=>o.sessionPreambleHook),"stop-enforce":()=>import("./stop-enforce-Q4JNBYQU.js").then(o=>o.stopEnforceHook),"tasks-reminder":()=>import("./tasks-reminder-LKSUZUFD.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-J33JDZET.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{i as c}from"./chunk-PE5WVWI5.js";import{spawnSync as y}from"child_process";import{existsSync as s,readdirSync as d,readFileSync as g,realpathSync as u,statSync as m}from"fs";import i from"path";var k=2e3;function _(t){if(t!=null)try{return m(u(t)).mtimeMs}catch{return}}function D(t){return y("pnpm",["turbo","run","build","--filter=ripplo..."],{cwd:t,stdio:"inherit"}).status===0}function U(){let t=process.argv[1];if(t==null)return{kind:"fresh"};let n=u(t),r=n.includes(`${i.sep}src${i.sep}`),o=l(i.dirname(n));if(o!=null)return r?{kind:"fresh"}:h(o);let a=l(process.cwd());return a!=null&&j(a)?{kind:"foreign-binary",workspaceRoot:a}:{kind:"fresh"}}function l(t){let n=i.dirname(t);return s(i.join(t,"pnpm-workspace.yaml"))?t:n===t?void 0:l(n)}function h(t){let n=i.join(t,"packages");if(!s(n))return{kind:"fresh"};let r=d(n).map(o=>({dist:i.join(n,o,"dist"),name:o,src:i.join(n,o,"src")})).filter(o=>s(o.src)&&s(o.dist)).filter(o=>p(o.src)>p(o.dist)+k).map(o=>o.name);return r.length===0?{kind:"fresh"}:{kind:"stale",packages:r,workspaceRoot:t}}function p(t){let n=m(t);if(!n.isDirectory())return n.mtimeMs;let r=d(t).map(o=>p(i.join(t,o)));return Math.max(n.mtimeMs,...r)}function j(t){let n=i.join(t,"packages","cli","package.json");if(!s(n))return!1;let r=JSON.parse(g(n,"utf8"));return typeof r=="object"&&r!=null&&"name"in r&&r.name==="ripplo"}import{createMessageConnection as S,NotificationType as f,RequestType as x,RequestType0 as b,SocketMessageReader as R,SocketMessageWriter as w}from"vscode-jsonrpc/node";import{z as e}from"zod";var E="daemon.sock",P="daemon.log";function K(t){return c(t,E)}function B(t){return c(t,P)}function X(t){return S(new R(t),new w(t))}var G=e.object({all:e.boolean(),headed:e.boolean(),tests:e.array(e.string())}),$=e.object({jobId:e.string(),total:e.number()}),M=e.enum(["no-lockfile","unstamped","expander-newer","dsl-drift","load-failed"]),q=e.discriminatedUnion("kind",[e.object({kind:e.literal("off")}),e.object({kind:e.literal("on")}),e.object({kind:e.literal("paused")}),e.object({kind:e.literal("blocked"),reason:M})]),v=e.object({attempts:e.number(),findings:e.number()}),H=e.object({active:e.number(),bundleMtimeMs:e.number().optional(),explorer:q,exploring:e.number(),progress:v,queued:e.number(),sseHealth:e.object({detail:e.string().optional(),ok:e.boolean()}).optional(),version:e.string().optional()}),z=e.enum(["MAX_RUNS","OVERAGE_CAP","MAX_AGENTS","MAX_CONCURRENT_RUNS","MAX_PROJECTS"]),I=e.discriminatedUnion("type",[e.object({code:z,type:e.literal("limit")}),e.object({detail:e.string(),type:e.literal("generic")})]),A=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:I}),e.object({detail:e.string(),kind:e.literal("dispatch-timeout")}),e.object({detail:e.string(),kind:e.literal("infra-error")})]),C=e.discriminatedUnion("kind",[e.object({kind:e.literal("test-started"),runId:e.string(),testName:e.string(),workflowName:e.string()}),e.object({kind:e.literal("test-outcome"),outcome:A,runId:e.string(),testName:e.string(),workflowName:e.string()})]),V=e.object({event:C,jobId:e.string()}),Q=e.object({failed:e.number(),jobId:e.string(),notRun:e.number(),passed:e.number()}),Y=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")})]),Z=new x("ripplo/enqueue"),ee=new b("ripplo/status"),te=new b("ripplo/shutdownIfIdle"),ne=new f("ripplo/jobEvent"),oe=new f("ripplo/jobDone");export{_ as a,D as b,U as c,K as d,B as e,X as f,G as g,$ as h,H as i,A as j,V as k,Q as l,Y as m,Z as n,ee as o,te as p,ne as q,oe as r};
@@ -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 n}from"./chunk-MHNGR6M7.js";import{c as o,d as a,e as i}from"./chunk-AQ3DMGAY.js";function c(e){return[`Compilation failed: ${s(e)}`,n("create","DSL authoring rules")].join(`
4
+ import{a as n}from"./chunk-MHNGR6M7.js";import{f as o,g as a,h as i}from"./chunk-EVVF662P.js";function c(e){return[`Compilation failed: ${s(e)}`,n("create","DSL authoring rules")].join(`
5
5
  `)}function m(){return`${i} is up to date`}function g(e){return[`${i} is ${e==="missing"?"missing":"out of date"} \u2014 run \`npx ripplo compile\` and commit it`,n("setup")].join(`
6
6
  `)}function x(){return`Wrote ${i}`}function s(e){switch(e.kind){case"typecheck-failed":return["TypeScript errors in .ripplo/:",...l(e.diagnostics)].join(`
7
7
  `);case"not-ripplo":return`${e.entryPath} must default-export createRipplo({ entities, singletons, workflows }).`;case"invalid-lockfile":return["Lockfile failed schema validation (stale or hand-edited .ripplo/ripplo.lock):",...l(e.issues),"Regenerate with `npx ripplo compile`."].join(`
@@ -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 c}from"./chunk-OQ6KNYPG.js";import{c as p}from"./chunk-LEFXRK53.js";import{c as l}from"./chunk-FEHVIHVA.js";import{a}from"./chunk-MHNGR6M7.js";import{I as u,w as t}from"./chunk-ESOXRGIY.js";import{N as d}from"./chunk-5SM4TCSW.js";var f=3e3;async function S(e){l(e);let n=p(e).unwrapOr(void 0);if(n==null)return null;try{return await fetch(`${n.ripploServerUrl}/health`,{signal:AbortSignal.timeout(f)}),null}catch(r){return{detail:r instanceof Error?r.message:String(r),serverUrl:n.ripploServerUrl}}}function m(e){return e.includes("localhost")||e.includes("127.0.0.1")}import g from"fuse.js";function s(e){switch(e.kind){case"conflicting-flags":return"Pass either --all or test ids, not both.";case"nothing-selected":return`No tests selected \u2014 scope empty, no dirty .ripplo/workflows files. Pass test ids, add to scope (${a("run")}), or use --all.`;case"unknown-ids":{let n=e.known,r=e.unknown.flatMap(i=>y(i,n)),o=r.length>0?[`Did you mean: ${[...new Set(r)].join(", ")}`]:[];return[`Unknown ${e.unknown.length===1?"id":"ids"}: ${e.unknown.join(", ")}`,...o,"Pass a workflow slug for all its tests, or workflow/test for one. Known workflows:",...n.map(i=>` ${i}`)].join(`
4
+ import{a as c}from"./chunk-OQ6KNYPG.js";import{c as p}from"./chunk-LEFXRK53.js";import{c as l}from"./chunk-FEHVIHVA.js";import{a}from"./chunk-MHNGR6M7.js";import{I as u,w as t}from"./chunk-MG43RZXH.js";import{R as d}from"./chunk-4F67XQYS.js";var f=3e3;async function S(e){l(e);let n=p(e).unwrapOr(void 0);if(n==null)return null;try{return await fetch(`${n.ripploServerUrl}/health`,{signal:AbortSignal.timeout(f)}),null}catch(r){return{detail:r instanceof Error?r.message:String(r),serverUrl:n.ripploServerUrl}}}function m(e){return e.includes("localhost")||e.includes("127.0.0.1")}import g from"fuse.js";function s(e){switch(e.kind){case"conflicting-flags":return"Pass either --all or test ids, not both.";case"nothing-selected":return`No tests selected \u2014 scope empty, no dirty .ripplo/workflows files. Pass test ids, add to scope (${a("run")}), or use --all.`;case"unknown-ids":{let n=e.known,r=e.unknown.flatMap(i=>y(i,n)),o=r.length>0?[`Did you mean: ${[...new Set(r)].join(", ")}`]:[];return[`Unknown ${e.unknown.length===1?"id":"ids"}: ${e.unknown.join(", ")}`,...o,"Pass a workflow slug for all its tests, or workflow/test for one. Known workflows:",...n.map(i=>` ${i}`)].join(`
5
5
  `)}}}function L({failed:e,notRun:n,passed:r}){let o=n>0?`, ${String(n)} not run`:"";return`${String(r)} passed, ${String(e)} failed${o} (${String(r+e+n)} total)`}function A({debugDir:e,event:n}){let r=`${n.workflowName} \u2192 ${n.testName}`;if(n.kind==="test-started")return`${t.dim("run ")} ${r}`;switch(n.outcome.kind){case"pass":return`${t.good("pass")} ${r} ${t.dim(n.runId)}`;case"findings":return[`${t.bad("fail")} ${r} \u2014 ${c(n.outcome.findingLines.length,"finding")}`,...n.outcome.findingLines,u({debugDir:e,runId:n.runId}),`${t.dim("why")} npx ripplo explain ${n.runId}`].join(`
6
6
  `);case"error":return`${t.bad("error")} ${r} \u2014 ${n.outcome.detail} ${t.dim(n.runId)}`;case"dispatch-error":return`${t.bad("error")} ${r} \u2014 ${w(n.outcome.reason)}`;case"dispatch-timeout":return`${t.bad("error")} ${r} \u2014 not run: dispatch timed out (transient): ${n.outcome.detail}`;case"infra-error":return`${t.bad("error")} ${r} \u2014 not run: Ripplo server unreachable: ${n.outcome.detail}`}}var h={MAX_AGENTS:"agent limit reached for your plan \u2014 upgrade to add more",MAX_CONCURRENT_RUNS:"concurrent run limit reached for your plan \u2014 upgrade or wait for runs to finish",MAX_PROJECTS:"project limit reached for your plan \u2014 upgrade to add more",MAX_RUNS:"run limit reached for your plan \u2014 enable overage or upgrade",OVERAGE_CAP:"overage cap reached \u2014 raise the cap or upgrade"};function j({detail:e,serverUrl:n}){return m(n)?`Ripplo server at ${n} not running (${e}). Start the dev server with \`pnpm dev\`.`:`Ripplo server at ${n} unreachable (${e}) \u2014 server-side, not your local environment.`}function N(e){switch(e.code){case"compile-failed":{let n=e.diagnostics.length===0?[]:["",...e.diagnostics];return[`Compilation failed in the daemon (${e.detail}). Run \`npx ripplo compile\` for full output.`,...n].join(`
7
7
  `)}case"selection-conflicting-flags":return s({kind:"conflicting-flags"});case"selection-nothing-selected":return s({kind:"nothing-selected"});case"selection-unknown-ids":return s({kind:"unknown-ids",known:e.known,unknown:e.unknown});case"app-unreachable":return`Your dev server not responding at ${e.url} (${e.detail}) \u2014 your local environment, not the Ripplo server.`;case"engine-unreachable":return`Ripplo engine not responding at ${e.url} (${e.detail}) \u2014 adapter unmounted, behind a build error, or RIPPLO_ENGINE_URL points at the wrong path.`;case"scope-failed":return`Could not resolve the dev-session scope: ${e.detail}
@@ -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{c as k}from"./chunk-LEFXRK53.js";import{a as P,f as I}from"./chunk-4W6WIT7T.js";import{b as m,e as h,h as w}from"./chunk-AQ3DMGAY.js";import{d as c,f as d}from"./chunk-PE5WVWI5.js";import{L as g,N as S}from"./chunk-5SM4TCSW.js";import u from"fs";import f from"path";function v(e){try{let n=A(e);if(n==null)return;let t=f.join(n,"HEAD"),o=u.readFileSync(t,"utf8").trim(),i="ref: refs/heads/";return o.startsWith(i)?o.slice(i.length):o.length===0?void 0:o.slice(0,7)}catch{return}}function A(e){let n=f.join(e,".git");if(u.statSync(n).isDirectory())return n;let o=u.readFileSync(n,"utf8").trim(),i="gitdir:";if(!o.startsWith(i))return;let s=o.slice(i.length).trim();if(s.length!==0)return f.resolve(e,s)}import b from"crypto";import{readFile as D}from"fs/promises";import x from"path";import{graphql as y}from"gql.tada";import{err as E,ok as L}from"neverthrow";var T=y(`
4
+ import{c as k}from"./chunk-LEFXRK53.js";import{a as P,f as I}from"./chunk-4W6WIT7T.js";import{e as m,h,k as w}from"./chunk-EVVF662P.js";import{d as c,f as d}from"./chunk-PE5WVWI5.js";import{P as g,R as S}from"./chunk-4F67XQYS.js";import u from"fs";import f from"path";function v(e){try{let n=A(e);if(n==null)return;let t=f.join(n,"HEAD"),o=u.readFileSync(t,"utf8").trim(),i="ref: refs/heads/";return o.startsWith(i)?o.slice(i.length):o.length===0?void 0:o.slice(0,7)}catch{return}}function A(e){let n=f.join(e,".git");if(u.statSync(n).isDirectory())return n;let o=u.readFileSync(n,"utf8").trim(),i="gitdir:";if(!o.startsWith(i))return;let s=o.slice(i.length).trim();if(s.length!==0)return f.resolve(e,s)}import b from"crypto";import{readFile as D}from"fs/promises";import x from"path";import{graphql as y}from"gql.tada";import{err as E,ok as L}from"neverthrow";var T=y(`
5
5
  mutation SyncDevSession(
6
6
  $projectId: String!
7
7
  $cwd: String!
@@ -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-2MT2MZJW.js";import"./chunk-AVBP7Q2M.js";import"./chunk-MHNGR6M7.js";import"./chunk-AQ3DMGAY.js";import"./chunk-5SM4TCSW.js";import"./chunk-KMZ3L5YA.js";export{b as renderCliFailure,c as renderHookCrash,a as renderTopLevelError};
4
+ import{a,b,c}from"./chunk-Q6IYTHMP.js";import"./chunk-XZ2TPZLD.js";import"./chunk-MHNGR6M7.js";import"./chunk-EVVF662P.js";import"./chunk-4F67XQYS.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}from"./chunk-EK6TENV6.js";import"./chunk-AQ3DMGAY.js";import"./chunk-ESOXRGIY.js";import"./chunk-5SM4TCSW.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as compileAndWrite,c as stampedLockfile,d as stampedLockfileFromDisk,e as stubbedWorkflows,b as writeStampedLockfile};
4
+ import{e as a,f as b,g as c,h as d,i as e}from"./chunk-INO3L4WS.js";import"./chunk-EVVF662P.js";import"./chunk-MG43RZXH.js";import"./chunk-4F67XQYS.js";import"./chunk-NNH3YVVO.js";import"./chunk-KMZ3L5YA.js";export{a as compileAndWrite,c as stampedLockfile,d as stampedLockfileFromDisk,e as stubbedWorkflows,b as writeStampedLockfile};
@@ -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-M7VQD4VO.js";import"./chunk-ESOXRGIY.js";import"./chunk-5SM4TCSW.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};
4
+ import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-RWFS5SCW.js";import"./chunk-MG43RZXH.js";import"./chunk-4F67XQYS.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};
@@ -0,0 +1,152 @@
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 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 rr,M as z,N as nr,e as be,i as qe,j as He,k as Ue,l as We,m as $e,n as _e,o as Me,p as Oe,r as q,s as H,t as Fe,u as B,v as Ke,w as Qe,x as ze,z as Je}from"./chunk-6BQADUAX.js";import{d as Pe}from"./chunk-WZBLSDNV.js";import{a as je,c as Ne,d as Be,e as w}from"./chunk-ZUPS6XVH.js";import{c as k}from"./chunk-LEFXRK53.js";import{e as Ee}from"./chunk-4W6WIT7T.js";import{a as de}from"./chunk-R4ZTRVDQ.js";import{c as ie}from"./chunk-FEHVIHVA.js";import{b as pe}from"./chunk-Q6IYTHMP.js";import{a as L}from"./chunk-XZ2TPZLD.js";import"./chunk-MHNGR6M7.js";import{g as we,h as D}from"./chunk-INO3L4WS.js";import{a as ce,i as v,j as ue,k as T}from"./chunk-EVVF662P.js";import{e as xe,f as Re}from"./chunk-DBIXYJRB.js";import{c as te,d as u,f as s,g as N,h as oe}from"./chunk-PE5WVWI5.js";import"./chunk-CJUKILIO.js";import{b as Ie,c as Ce,d as Te,e as Le,f as Ae,h as De}from"./chunk-RWFS5SCW.js";import{$ as ve,M as me,P as A,Q as ye,R as ge,S as Se,T as ke,U as he,d as fe}from"./chunk-MG43RZXH.js";import{E as ae,L as se,R as le}from"./chunk-4F67XQYS.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=>le(i.name)===n)?.tests.find(i=>i.slug===r);return o==null?void 0:fe(o)}var mn=6e4,yn=pn(`
5
+ subscription RunRequestedWatch($devSessionId: String!) {
6
+ runRequested(devSessionId: $devSessionId) {
7
+ runId
8
+ testSlug
9
+ workflowId
10
+ workflowSlug
11
+ }
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 ie(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:Qe(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
+ subscription TeleportRequestedWatch($devSessionId: String!) {
16
+ teleportRequested(devSessionId: $devSessionId) {
17
+ runId
18
+ stepIndex
19
+ kind
20
+ testSlug
21
+ workflowSlug
22
+ }
23
+ }
24
+ `),xn=J(`
25
+ query TeleportRunRepro($id: String!) {
26
+ run(id: $id) {
27
+ id
28
+ reproJson
29
+ }
30
+ }
31
+ `),Rn=J(`
32
+ mutation ReportTeleportResult($devSessionId: String!, $runId: String!, $status: String!) {
33
+ reportTeleportResult(devSessionId: $devSessionId, runId: $runId, status: $status)
34
+ }
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(()=>Ne({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: ${Te()}
37
+ `),process.exit(1)),n==="FORBIDDEN"&&(process.stderr.write(`ripplo: ${Ce({projectId:e.projectId,serverUrl:e.ripploServerUrl})}
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
+ query OpenFindingsForRetire($projectId: String!) {
40
+ exploreFindings(projectId: $projectId, status: open) {
41
+ signature
42
+ reproRun {
43
+ reproJson
44
+ }
45
+ }
46
+ }
47
+ `),$n=dr(`
48
+ mutation RetireStaleFinding($projectId: String!, $signature: String!) {
49
+ retireStaleFinding(projectId: $projectId, signature: $signature)
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(`
52
+ mutation EnterCloudMode(
53
+ $devSessionId: String!
54
+ $localUrl: String!
55
+ $engineUrl: String!
56
+ $hostKeyFingerprint: String!
57
+ ) {
58
+ enterCloudMode(
59
+ devSessionId: $devSessionId
60
+ localUrl: $localUrl
61
+ engineUrl: $engineUrl
62
+ hostKeyFingerprint: $hostKeyFingerprint
63
+ ) {
64
+ __typename
65
+ ... on RelaySession {
66
+ generation
67
+ grant
68
+ relayUrl
69
+ secret
70
+ session
71
+ }
72
+ ... on DevSessionEndedError {
73
+ message
74
+ }
75
+ ... on TunnelNotConfiguredError {
76
+ message
77
+ }
78
+ }
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,Je))&&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:Oe(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(_e,{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(Ue,e,o.token),l=qe.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(He,o)}),runId:void 0,worker:r};return e.nextId+=1,r.connection.onRequest(We,()=>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(Me).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=ge.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
+ query DaemonExploration($devSessionId: String!) {
82
+ exploration(devSessionId: $devSessionId) {
83
+ active
84
+ localWorkers
85
+ maxTrailLength
86
+ }
87
+ }
88
+ `),Gt=b(`
89
+ subscription WatchExplorationChanged($devSessionId: String!) {
90
+ explorationChanged(devSessionId: $devSessionId) {
91
+ exploration {
92
+ active
93
+ localWorkers
94
+ maxTrailLength
95
+ }
96
+ }
97
+ }
98
+ `);function Yr({config:e,devSessionId:r,exploration:n,sseClient:t}){return zt(()=>Vt({config:e,devSessionId:r,exploration:n}),{factor:2,minTimeout:500,retries:6}).catch(o=>{s.warn({err:o},"initial exploration state read failed \u2014 explorer stays off")}),t.subscribe({query:F(Gt),variables:{devSessionId:r}},{complete:()=>{},error:o=>{s.error(o,"exploration subscription error")},next:o=>{Zr(n,o.data?.explorationChanged.exploration)}})}async function Vt({config:e,devSessionId:r,exploration:n}){let t=await u({config:e,document:Jt,variables:{devSessionId:r}});Zr(n,t.exploration)}function Zr(e,r){r!=null&&e.setDesired({active:r.active,localWorkers:r.localWorkers,maxTrailLength:r.maxTrailLength})}var Xt=b(`
99
+ subscription HooksPausedWatch($projectId: String!) {
100
+ hooksPausedRequested(projectId: $projectId) {
101
+ paused
102
+ projectId
103
+ }
104
+ }
105
+ `),Yt=b(`
106
+ subscription WatchLocalConcurrencyChanged {
107
+ myMaxLocalConcurrentRunsChanged
108
+ }
109
+ `);function en({pool:e,sseClient:r}){return r.subscribe({query:F(Yt)},{complete:()=>{},error:n=>{s.error(n,"localConcurrency subscription error")},next:n=>{let t=n.data?.myMaxLocalConcurrentRunsChanged;t!=null&&(H(t),e.setSize(t))}})}var Zt=b(`
110
+ subscription WatchExecutorChangeRequested($devSessionId: String!) {
111
+ executorChangeRequested(devSessionId: $devSessionId) {
112
+ executor
113
+ }
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=Ee(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
+ mutation HeartbeatDevSessionWatch($id: String!) {
117
+ heartbeatDevSession(id: $id) {
118
+ __typename
119
+ ... on DevSession {
120
+ id
121
+ }
122
+ ... on DevSessionEndedError {
123
+ message
124
+ }
125
+ }
126
+ }
127
+ `),so=ne(`
128
+ query WatchLocalConcurrency {
129
+ currentUser {
130
+ id
131
+ maxLocalConcurrentRuns
132
+ }
133
+ }
134
+ `),lo=ne(`
135
+ mutation EndDevSessionWatch($projectId: String!, $cwd: String!, $devSessionId: String) {
136
+ endDevSession(projectId: $projectId, cwd: $cwd, devSessionId: $devSessionId) {
137
+ __typename
138
+ ... on DevSession {
139
+ id
140
+ }
141
+ ... on NoActiveDevSessionError {
142
+ message
143
+ }
144
+ }
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=ze({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(()=>Be({config:e,cwd:r,lockfile:E}),{config:e,label:"initial sync"}),P=await w(r);P!=null&&Ke(P);let I=ur({config:e,cwd:r}),y=await Eo(e);re({cwd:r,paused:m.hooksPaused});let g=je(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 he({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(`${Le({devSessionId:e,version:de()})}
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 we(e,t.value);return{lockfileJson:ae(se,o)}}})}function So(e){try{return Re({cwd:e,onCompromised:ko})}catch(r){throw r instanceof xe&&(process.stderr.write(`${Ae({cwd:r.cwd,pid:r.pid})}
149
+ `),process.exit(1)),r}}function ko(){s.error("daemon lock compromised; shutting down"),process.stderr.write(`${De()}
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(`${Ie(o)}
151
+ `),n(),process.exit(1)})}function wo(e){return k(e).match(r=>r,r=>{process.stderr.write(`${pe(r)}
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{e as a,f as b,g as c,h as d}from"./chunk-AQ3DMGAY.js";import"./chunk-5SM4TCSW.js";import"./chunk-KMZ3L5YA.js";export{a as LOCKFILE_RELATIVE_PATH,d as loadRipplo,b as loadRipploCached,c as loadRipploCachedWithFingerprint};
4
+ import{h as a,i as b,j as c,k as d}from"./chunk-EVVF662P.js";import"./chunk-4F67XQYS.js";import"./chunk-KMZ3L5YA.js";export{a as LOCKFILE_RELATIVE_PATH,d as loadRipplo,b as loadRipploCached,c as loadRipploCachedWithFingerprint};
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-7Z7RVHEL.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-SLG6JHK2.js");process.stderr.write(`${p(t)}
4
+ import{a as o,c as s}from"./chunk-UMSBDSRS.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-J33JDZET.js");process.stderr.write(`${p(t)}
5
5
  `),process.exit(1)});