ripplo 0.7.44 → 0.7.45
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-44FQQWRS.js +279 -0
- package/dist/{chunk-M4ESW6JP.js → chunk-ADSV6V6H.js} +47 -47
- package/dist/{chunk-3MDHW3LO.js → chunk-KMNYXOL5.js} +1 -1
- package/dist/{chunk-VW7PTYJ3.js → chunk-PYDAUHSS.js} +1 -1
- package/dist/daemon-GSRF2HY6.js +125 -0
- package/dist/{daemon-SUSSQ463.js → daemon-X545JHJO.js} +1 -1
- package/dist/index.js +204 -227
- package/dist/status-JG34NBZX.js +2 -0
- package/package.json +7 -6
- package/dist/chunk-LYZ6JY7L.js +0 -252
- package/dist/daemon-MHGTHG25.js +0 -129
- package/dist/status-52ZOYXAV.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ripplo",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.45",
|
|
4
4
|
"description": "CLI for Ripplo — AI-powered end-to-end testing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://ripplo.ai",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@inquirer/prompts": "^7.5.3",
|
|
23
23
|
"@paralleldrive/cuid2": "^3.3.0",
|
|
24
24
|
"better-auth": "^1.5.6",
|
|
25
|
+
"cloudflared": "^0.7.1",
|
|
25
26
|
"dotenv": "^17.3.1",
|
|
26
27
|
"fuse.js": "^7.4.2",
|
|
27
28
|
"gql.tada": "^1.9.0",
|
|
@@ -59,13 +60,13 @@
|
|
|
59
60
|
"eslint-plugin-neverthrow": "^1.1.4",
|
|
60
61
|
"tsup": "^8.5.1",
|
|
61
62
|
"vitest": "^4.1.4",
|
|
62
|
-
"@ripplo/core": "^0.0.0",
|
|
63
63
|
"@ripplo/eslint-config": "0.0.0",
|
|
64
|
-
"@ripplo/
|
|
65
|
-
"@ripplo/
|
|
66
|
-
"@ripplo/run-report": "0.0.0",
|
|
64
|
+
"@ripplo/core": "^0.0.0",
|
|
65
|
+
"@ripplo/spec": "^0.0.0",
|
|
67
66
|
"@ripplo/runtime": "^0.0.0",
|
|
68
|
-
"@ripplo/
|
|
67
|
+
"@ripplo/run-report": "0.0.0",
|
|
68
|
+
"@ripplo/graphql": "^0.0.0",
|
|
69
|
+
"@ripplo/rrweb-bundle": "0.0.0"
|
|
69
70
|
},
|
|
70
71
|
"scripts": {
|
|
71
72
|
"dev": "tsx watch src/index.ts",
|
package/dist/chunk-LYZ6JY7L.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{c as Fe}from"./chunk-4J4T7534.js";import{A as Xe,a as E,b as T,c as Ce,d as Ae,e as je,f as C,g as $e,i as A,o as Be,p as Ke,s as Je,w as Qe,x as ze,y as Ge,z as Ye}from"./chunk-VW7PTYJ3.js";import{b as ve,d as u,e as f,h as xe,i as be}from"./chunk-4K4VY5OR.js";import{A as Ne,B as Le,E as qe,S as _e,T as He,W as We,X as Ve,a as P,b as Ie,i as Ee,j as Pe,k as Te,l as g,m as Me,n as Oe,p as Ue,q as h,r as b,s as De,w as j}from"./chunk-M4ESW6JP.js";import nn from"fs";import U from"path";import{config as it}from"dotenv";import{z as M}from"zod";import{err as at,ok as tn}from"neverthrow";import F from"fs";import Z from"path";import{err as Y,ok as Ze}from"neverthrow";import{z as $}from"zod";var nt=Z.join(".ripplo","project.json"),X=[".env",".env.local"],tt=$.object({envFiles:$.array($.string().min(1)).optional(),projectId:$.string().min(1)});function en(e){return Z.join(e,nt)}function ee(e){let n=en(e);return F.existsSync(n)?rt(n).andThen(t=>{let r=tt.safeParse(t);return r.success?Ze({envFiles:r.data.envFiles??X,projectId:r.data.projectId}):Y({issues:r.error.issues.map(o=>`${o.path.join(".")}: ${o.message}`),kind:"project-file-invalid",path:n})}):Y({kind:"project-file-missing",path:n})}function ne(e){return ee(e).match(n=>n,()=>{})}function rt(e){try{return Ze(JSON.parse(F.readFileSync(e,"utf8")))}catch(n){return Y({issues:[n instanceof Error?n.message:String(n)],kind:"project-file-invalid",path:e})}}function Xo({cwd:e,envFiles:n,projectId:t}){let r=en(e);F.mkdirSync(Z.dirname(r),{recursive:!0});let o={projectId:t};n!=null&&!ot(n)&&(o.envFiles=[...n]),F.writeFileSync(r,JSON.stringify(o,null,2)+`
|
|
3
|
-
`)}function ot(e){return e.length!==X.length?!1:e.every((n,t)=>n===X[t])}function ai(e){let t=ne(e)?.envFiles??[".env",".env.local"],r=U.join(e,".ripplo");t.forEach(o=>{let i=U.resolve(r,o);nn.existsSync(i)&&it({override:!0,path:i,quiet:!0})}),O=void 0}var st=M.object({RIPPLO_APP_URL:M.url(),RIPPLO_ENGINE_URL:M.url(),RIPPLO_WEBHOOK_SECRET:M.string().min(1)}),O;function D(){return O!=null?tn(O):dt().map(e=>(O=e,e))}function lt(e){let t=ne(e)?.envFiles??[],r=U.join(e,".ripplo");return t.map(o=>U.resolve(r,o)).filter(o=>!nn.existsSync(o))}function dt(){let e=st.safeParse(process.env);if(!e.success)return at({issues:e.error.issues.map(t=>`${t.path.join(".")}: ${t.message}`),kind:"env-invalid",missingEnvFiles:lt(process.cwd())});let n=e.data;return tn({appUrl:n.RIPPLO_APP_URL,engineUrl:n.RIPPLO_ENGINE_URL,webhookSecret:n.RIPPLO_WEBHOOK_SECRET})}var N=class extends Error{failure;constructor(n){super(n.kind),this.name="CliError",this.failure=n}};function pi(e){return e instanceof N?te(e.failure):e instanceof Error?e.message:String(e)}function te(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).",$e("setup")].join(`
|
|
4
|
-
`);case"project-file-invalid":return[`${e.path} is invalid:`,...e.issues.map(n=>` ${n}`),"Fix the file by hand or re-run `npx ripplo init`."].join(`
|
|
5
|
-
`);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(`
|
|
6
|
-
`);case"env-invalid":return ct(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(`
|
|
7
|
-
`);case"gitdir-unrecognized":return`Unrecognized .git file at ${e.marker} \u2014 expected a directory or a "gitdir:" pointer (worktree). Is the repo corrupted?`;case"gitdir-empty":return`Empty gitdir pointer at ${e.marker} \u2014 the worktree's .git file points nowhere. Re-create the worktree.`;case"oauth-device-code-failed":return[`Could not start sign-in (device-code request failed): ${e.description}`,"Is the Ripplo server reachable? Check RIPPLO_SERVER_URL and retry."].join(`
|
|
8
|
-
`);case"oauth-authorization-failed":return[`Sign-in failed (${e.code}): ${e.description}`,e.code==="expired_token"?"The approval window expired \u2014 run `npx ripplo auth login` again.":"Run `npx ripplo auth login` to retry."].join(`
|
|
9
|
-
`);case"compilation-failed":return A(e.error)}}function ct(e){let n=e.missingEnvFiles.length===0?[]:["Declared env files not found:",...e.missingEnvFiles.map(t=>` ${t}`),"In a git worktree? Env files aren't copied from the main checkout \u2014 recreate them, or symlink to a shared file outside the working tree."];return["Env config invalid:",...e.issues.map(t=>` ${t}`),"Add the missing values to the env files declared in .ripplo/project.json.",...n].join(`
|
|
10
|
-
`)}import{err as ft,ok as yt}from"neverthrow";import{z as re}from"zod";var ut="https://ripplo.ai";function on(){return sn().RIPPLO_SERVER_URL}function an(){return sn().RIPPLO_PROJECT_ID}var pt=re.object({RIPPLO_PROJECT_ID:re.string().min(1).optional(),RIPPLO_SERVER_URL:re.string().min(1).default(ut)}),rn;function sn(){return rn??=pt.parse(process.env),rn}import ln from"fs";import oe from"path";function dn(e){let n=ln.realpathSync(e),t=n,r=oe.dirname(t);for(;r!==t;){if(ln.existsSync(oe.join(t,".git")))return t;t=r,r=oe.dirname(t)}return n}function L(e){return ee(e).andThen(n=>D().andThen(t=>{let r=on(),o=be(r);return o==null?ft({kind:"not-authenticated"}):yt({appUrl:t.appUrl,cwd:dn(e),engineUrl:t.engineUrl,projectId:an()??n.projectId,ripploServerUrl:r,token:o,tunnelAuth:void 0,webhookSecret:t.webhookSecret})}))}import gt from"p-queue";var mt=4,ht={"p0-ui":3,"p1-cli":2,"p2-cover":1,"p3-explore":0},q=new gt({concurrency:mt}),S={headedActive:0,interactiveActive:0,interactiveQueued:0},cn={current:null};function Pi({headed:e,task:n,workClass:t}){let r=ht[t];return t==="p3-explore"?q.add(n,{priority:r}):(S.interactiveQueued+=1,_(),q.add(()=>Rt({headed:e,task:n}),{priority:r}))}function Ti(e){!Number.isFinite(e)||e<1||(q.concurrency=Math.floor(e),_())}function ie(){return{active:S.interactiveActive,headedActive:S.headedActive,poolSize:q.concurrency,queued:S.interactiveQueued}}function Ci(e){cn.current=e}async function Rt({headed:e,task:n}){S.interactiveQueued-=1,S.interactiveActive+=1,S.headedActive+=e?1:0,_();try{return await n()}finally{S.interactiveActive-=1,S.headedActive-=e?1:0,_()}}function _(){cn.current?.()}import ae from"fs";import se from"path";function un(e){try{let n=St(e);if(n==null)return;let t=se.join(n,"HEAD"),r=ae.readFileSync(t,"utf8").trim(),o="ref: refs/heads/";return r.startsWith(o)?r.slice(o.length):r.length===0?void 0:r.slice(0,7)}catch{return}}function St(e){let n=se.join(e,".git");if(ae.statSync(n).isDirectory())return n;let r=ae.readFileSync(n,"utf8").trim(),o="gitdir:";if(!r.startsWith(o))return;let i=r.slice(o.length).trim();if(i.length!==0)return se.resolve(e,i)}import pn from"crypto";import{readFile as fn}from"fs/promises";import yn from"path";import{graphql as le}from"gql.tada";import{err as kt,ok as wt}from"neverthrow";var vt=le(`
|
|
11
|
-
mutation SyncDevSession(
|
|
12
|
-
$projectId: String!
|
|
13
|
-
$cwd: String!
|
|
14
|
-
$branch: String
|
|
15
|
-
$lockfileContent: String
|
|
16
|
-
$fixtures: [SyncDevFixtureInput!]
|
|
17
|
-
$preconditions: [SyncDevPreconditionInput!]!
|
|
18
|
-
$singletons: [SyncDevSingletonInput!]
|
|
19
|
-
$workflows: [SyncDevWorkflowInput!]!
|
|
20
|
-
) {
|
|
21
|
-
syncDevSession(
|
|
22
|
-
projectId: $projectId
|
|
23
|
-
cwd: $cwd
|
|
24
|
-
branch: $branch
|
|
25
|
-
lockfileContent: $lockfileContent
|
|
26
|
-
fixtures: $fixtures
|
|
27
|
-
preconditions: $preconditions
|
|
28
|
-
singletons: $singletons
|
|
29
|
-
workflows: $workflows
|
|
30
|
-
) {
|
|
31
|
-
id
|
|
32
|
-
hooksPaused
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
`);async function Vi(e,n){let t=await C(e);if(t.isErr())return kt({error:t.error,kind:"compilation-failed"});let r=await v({config:n,cwd:e,lockfile:t.value});return wt({devSessionId:r.devSessionId,lockfile:t.value})}async function v(e){let n=Pe(e.lockfile);return Et({config:e.config,cwd:e.cwd,fixtures:e.lockfile.fixtures,payload:n})}var xt=le(`
|
|
36
|
-
query DevSessionSyncState($projectId: String!, $cwd: String!) {
|
|
37
|
-
project(id: $projectId) {
|
|
38
|
-
devSession(cwd: $cwd) {
|
|
39
|
-
id
|
|
40
|
-
hooksPaused
|
|
41
|
-
lockfileHash
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
`),bt=le(`
|
|
46
|
-
mutation AnnounceDevSessionActive($projectId: String!, $cwd: String!) {
|
|
47
|
-
announceDevSessionActive(projectId: $projectId, cwd: $cwd)
|
|
48
|
-
}
|
|
49
|
-
`);async function Bi(e){let n=await gn(e.cwd);if(n!=null){let t=pn.createHash("sha256").update(n).digest("hex"),o=(await u({config:e.config,document:xt,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null))?.project?.devSession;if(o!=null&&o.lockfileHash===t)return await u({config:e.config,document:bt,variables:{cwd:e.cwd,projectId:e.config.projectId}}).catch(()=>null),{devSessionId:o.id,hash:t,hooksPaused:o.hooksPaused}}return v(e)}function It(e){return pn.createHash("sha256").update(JSON.stringify(e)).digest("hex")}async function Et({config:e,cwd:n,fixtures:t,payload:r}){let o=It(r),i=un(n),s=await gn(n),a=await Pt(n,t),c=await u({config:e,document:vt,variables:{branch:i??null,cwd:n,fixtures:a,lockfileContent:s,preconditions:r.preconditions.map(d=>({depends:[...d.depends],description:d.description,name:d.name,returns:[...d.returns]})),projectId:e.projectId,singletons:r.singletons.map(d=>({defaultValue:d.defaultValue,description:d.description,name:d.name,type:d.type})),workflows:r.workflows.map(d=>({expectedOutcome:d.expectedOutcome,name:d.name,preconditions:[...d.preconditions],requiresKeys:d.requiresKeys.map(p=>({namespace:p.namespace,preconditionName:p.preconditionName})),slug:d.slug,sourcePath:d.sourcePath,spec:JSON.stringify(d.spec)}))}});if(c.syncDevSession==null)throw new Error("syncDevSession returned null");return{devSessionId:c.syncDevSession.id,hash:o,hooksPaused:c.syncDevSession.hooksPaused}}async function Pt(e,n){let t=Object.entries(n);return Promise.all(t.map(async([r,o])=>({contentBase64:(await fn(yn.join(e,T,r))).toString("base64"),sha256:o.sha256})))}async function gn(e){try{return await fn(yn.join(e,Ce),"utf8")}catch{return null}}import{randomUUID as tr}from"crypto";import{createId as rr}from"@paralleldrive/cuid2";import{CancellationTokenSource as or,ResponseError as ir}from"vscode-jsonrpc/node";import{graphql as Tt}from"gql.tada";var Ct=Tt(`
|
|
50
|
-
mutation DaemonCreateRun(
|
|
51
|
-
$id: String
|
|
52
|
-
$workflowId: String!
|
|
53
|
-
$testId: String
|
|
54
|
-
$clientVersion: String
|
|
55
|
-
$executor: RunExecutor
|
|
56
|
-
$target: RunTarget
|
|
57
|
-
$lockfileHash: String
|
|
58
|
-
) {
|
|
59
|
-
createRun(
|
|
60
|
-
id: $id
|
|
61
|
-
workflowId: $workflowId
|
|
62
|
-
testId: $testId
|
|
63
|
-
executor: $executor
|
|
64
|
-
target: $target
|
|
65
|
-
clientVersion: $clientVersion
|
|
66
|
-
lockfileHash: $lockfileHash
|
|
67
|
-
) {
|
|
68
|
-
__typename
|
|
69
|
-
... on MutationCreateRunSuccess {
|
|
70
|
-
data {
|
|
71
|
-
id
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
... on LimitExceededError {
|
|
75
|
-
code
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
`);async function mn(e){try{let t=(await u({config:e.config,document:Ct,variables:At(e)})).createRun;return t==null?H({detail:"create-run-null",type:"generic"}):t.__typename==="MutationCreateRunSuccess"?null:t.__typename==="LimitExceededError"?H({code:t.code,type:"limit"}):H({detail:t.__typename,type:"generic"})}catch(n){return jt(n)}}function At({executor:e,lockfileHash:n,runId:t,target:r}){return{clientVersion:E(),executor:e,id:t,lockfileHash:n,target:e==="cloud"?"tunnel":void 0,testId:r.testId,workflowId:r.workflowId}}function H(e){return{kind:"dispatch-error",reason:e}}function jt(e){return e instanceof ve?{detail:e.message,kind:"infra-error"}:H({detail:e instanceof Error?e.message:String(e),type:"generic"})}import{graphql as $t}from"gql.tada";async function hn(e,n){let r=(await u({config:e,document:Ft,variables:{cwd:n,projectId:e.projectId}})).project?.devSession?.workflows??[];return new Map(r.flatMap(o=>o.tests.map(i=>[`${o.slug}/${i.slug}`,{testId:i.id,workflowId:o.id}])))}var Ft=$t(`
|
|
80
|
-
query DaemonWorkflows($projectId: String!, $cwd: String!) {
|
|
81
|
-
project(id: $projectId) {
|
|
82
|
-
id
|
|
83
|
-
devSession(cwd: $cwd) {
|
|
84
|
-
id
|
|
85
|
-
workflows {
|
|
86
|
-
id
|
|
87
|
-
slug
|
|
88
|
-
tests {
|
|
89
|
-
id
|
|
90
|
-
slug
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
`);import{CancellationTokenSource as Mt}from"vscode-jsonrpc/node";function de(e){return`${e.workflowSlug}/${e.testSlug}`}function Rn(e){let{headed:n,inflight:t,jobId:r,lockfileHashValue:o,onExpire:i,runId:s,selection:a,timeoutMs:c}=e,d=de(a),p=`${d}@${o}@${String(n)}`,l=t.get(p);if(l!=null)return l.jobIds.add(r),null;let y={cancellation:new Mt,claimed:!1,claimKey:d,headed:n,inflightKey:p,jobIds:new Set([r]),runId:s,testName:a.testName,timer:null,workflowName:a.workflowName};return y.timer=setTimeout(()=>{W(t,y),i(y)},c),t.set(p,y),y}function W(e,n){n.timer!=null&&(clearTimeout(n.timer),n.timer=null),e.delete(n.inflightKey)}function ce(e,n){let t=[...e.values()].find(r=>r.runId===n&&!r.claimed);return t==null?null:(t.claimed=!0,t.timer!=null&&(clearTimeout(t.timer),t.timer=null),t)}function Sn(e,n){[...e.values()].filter(t=>t.jobIds.has(n)).forEach(t=>{t.jobIds.delete(n),t.jobIds.size===0&&(W(e,t),t.cancellation.cancel())})}import{err as ue,ok as kn}from"neverthrow";function vn({all:e,ids:n,lockfile:t}){if(e&&n.length>0)return ue({kind:"conflicting-flags"});if(e)return kn(t.workflows.filter(i=>!i.stub).flatMap(i=>i.tests.map(s=>h(s))));if(n.length===0)return ue({kind:"nothing-selected"});let r=n.map(i=>({id:i,refs:Ut(t,i)})),o=r.filter(i=>i.refs.length===0).map(i=>i.id);return o.length>0?ue({kind:"unknown-ids",known:Ot(t),unknown:o}):kn([...new Set(r.flatMap(i=>i.refs))])}function xn(e,n){let t=new Map(b(e).map(r=>[r.ref,{testName:r.test.name,testSlug:r.test.slug,workflowName:r.workflow.name,workflowSlug:g(r.workflow.name)}]));return n.map(r=>{let o=t.get(r);if(o==null)throw new Error(`selectionsFor: ref not in lockfile: ${r}`);return o})}function Ot(e){return e.workflows.map(n=>g(n.name))}function Ut(e,n){let t=e.workflows.find(r=>r.name===n||g(r.name)===g(n));return t!=null?t.tests.map(r=>h(r)):b(e).filter(r=>r.ref===n||wn(r.ref)===wn(n)).map(r=>r.ref)}function wn(e){let n=e.lastIndexOf("/");return n===-1?g(e):`${g(e.slice(0,n))}/${g(e.slice(n+1))}`}import{err as ye,ok as Tn}from"neverthrow";import{graphql as Cn}from"gql.tada";import{graphql as Vt}from"gql.tada";import{execFileSync as Dt}from"child_process";var Nt=256*1024*1024;function V(e,n){return Dt("git",[...e],{cwd:n,encoding:"utf8",maxBuffer:Nt,stdio:["ignore","pipe","pipe"]})}import Ht from"fs";import Lt from"fs";import pe from"path";var qt=["MERGE_HEAD","rebase-merge","rebase-apply","CHERRY_PICK_HEAD","REVERT_HEAD"];function bn(e){let n=_t(e);return n==null?!1:qt.some(t=>Lt.existsSync(pe.join(n,t)))}function _t(e){try{let n=V(["rev-parse","--git-dir"],e).trim();return n.length===0?null:pe.isAbsolute(n)?n:pe.resolve(e,n)}catch{return null}}function Wt(e){return xe(e,"hooks-paused")}function In(e){return Ht.existsSync(Wt(e))||bn(e)?!1:Fe(e)}var Bt=Vt(`
|
|
97
|
-
mutation AutoScopeAddDirty($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
98
|
-
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
99
|
-
__typename
|
|
100
|
-
... on MutationAddDirtyTestsToScopeSuccess {
|
|
101
|
-
data {
|
|
102
|
-
id
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
`);async function ba({cwd:e,lockfile:n}){if(!In(e))return{addedSlugs:[]};let t=fe(e);if(t.length===0)return{addedSlugs:[]};let r=new Set(t),o=n.workflows.filter(c=>c.sourcePath!=null&&r.has(c.sourcePath)).map(c=>g(c.name));if(o.length===0)return{addedSlugs:[]};let i=L(e).unwrapOr(void 0);return i==null?{addedSlugs:[]}:await v({config:i,cwd:e,lockfile:n}).catch(c=>(f.warn("auto-sync failed: %s",c instanceof Error?c.message:String(c)),null))==null?{addedSlugs:[]}:{addedSlugs:await Kt({cfg:i,slugs:o})?o:[]}}async function Kt({cfg:e,slugs:n}){let r=(await u({config:e,document:Bt,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:[...n]}}).catch(o=>(f.warn("auto-scope failed: %s",o instanceof Error?o.message:String(o)),null)))?.addDirtyTestsToScope;return r?.__typename!=="MutationAddDirtyTestsToScopeSuccess"?!1:r.data.length>0}var En=".ripplo/workflows/",Pn=" -> ";function fe(e){let n;try{n=V(["status","--porcelain","-uall","--",".ripplo/workflows"],e)}catch{return[]}return n.split(`
|
|
108
|
-
`).map(t=>t.slice(3).trim()).map(t=>t.includes(Pn)?t.split(Pn)[1]:t).filter(t=>t!=null).filter(t=>t.startsWith(En)&&t.endsWith(".ts")).map(t=>t.slice(En.length)).filter(t=>t!=="index.ts"&&!t.endsWith("/index.ts"))}async function An({config:e,cwd:n,lockfile:t}){await Qt({config:e,cwd:n,lockfile:t});let r=await Gt(e);if(r.isErr())return ye(r.error);let o=new Map(t.workflows.filter(s=>!s.stub).map(s=>[g(s.name),s])),i=[...new Set(r.value)].flatMap(s=>{let a=o.get(s);return a==null?[]:a.tests.map(c=>h(c))});return i.length===0?ye({kind:"scope-empty"}):Tn(i)}var Jt=Cn(`
|
|
109
|
-
mutation AddDirtyTestsToScope($projectId: String!, $cwd: String!, $workflowSlugs: [String!]!) {
|
|
110
|
-
addDirtyTestsToScope(projectId: $projectId, cwd: $cwd, workflowSlugs: $workflowSlugs) {
|
|
111
|
-
__typename
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
`);async function Qt({config:e,cwd:n,lockfile:t}){let r=new Set(fe(n)),o=t.workflows.filter(i=>i.sourcePath!=null&&r.has(i.sourcePath)).map(i=>g(i.name));o.length!==0&&await u({config:e,document:Jt,variables:{cwd:e.cwd,projectId:e.projectId,workflowSlugs:o}}).catch(i=>{f.warn({err:i},"auto-scope of dirty tests failed")})}var zt=Cn(`
|
|
115
|
-
query ScopeSelection($projectId: String!, $cwd: String!) {
|
|
116
|
-
project(id: $projectId) {
|
|
117
|
-
id
|
|
118
|
-
devSession(cwd: $cwd) {
|
|
119
|
-
id
|
|
120
|
-
scopeItems {
|
|
121
|
-
id
|
|
122
|
-
workflow {
|
|
123
|
-
id
|
|
124
|
-
slug
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
`);async function Gt(e){try{let t=(await u({config:e,document:zt,variables:{cwd:e.cwd,projectId:e.projectId}})).project?.devSession?.scopeItems??[];return Tn(t.flatMap(r=>r.workflow==null?[]:[r.workflow.slug]))}catch(n){return ye({detail:n instanceof Error?n.message:String(n),kind:"scope-fetch-failed"})}}import{graphql as Yt}from"gql.tada";var Xt=2e3,Zt=Yt(`
|
|
131
|
-
query DaemonCloudRunStatus($runId: String!) {
|
|
132
|
-
run(id: $runId) {
|
|
133
|
-
status
|
|
134
|
-
failureReason
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
`);function $n({config:e,onComplete:n,onStarted:t,runId:r,signal:o}){let i=!1,s,a=!1,c=async()=>{if(i||o.aborted)return;let d=await er(e,r).catch(()=>"unknown");if(!(i||o.aborted)){if(!a&&(d==="running"||jn(d))&&(a=!0,t()),jn(d)){i=!0,n(nr(d));return}s=setTimeout(()=>{c()},Xt)}};return c(),{stop:()=>{i=!0,s!=null&&clearTimeout(s)}}}async function er(e,n){let r=(await u({config:e,document:Zt,variables:{runId:n}})).run?.status;return r??"unknown"}function jn(e){return e==="passed"||e==="failed"||e==="warning"||e==="cancelled"||e==="unready"}function nr(e){return e==="passed"?{kind:"pass"}:e==="failed"?{detail:"failed",kind:"error"}:e==="warning"?{findingLines:[],kind:"findings"}:e==="cancelled"?{detail:"cancelled",kind:"error"}:e==="unready"?{detail:"unready",kind:"error"}:{detail:"unknown",kind:"error"}}var ar=12e4,sr=-32099,ge=new Set,Fn=new Map;function Xa(e){ge.add(e)}function lr(e){let n=new AbortController;return e.isCancellationRequested?(n.abort(),n.signal):(e.onCancellationRequested(()=>{n.abort()}),n.signal)}function Za(e){let n={...e,inflight:new Map,jobs:new Map};return{claim:t=>fr(n,t),handleConnection:t=>{dr(n,t)},idle:()=>Un(n)}}function dr(e,n){let t=Be(n);t.onRequest(Qe,(r,o)=>cr({connection:t,ctx:e,params:r,token:o})),t.onRequest(ze,()=>{let r=ie();return{active:r.active,queued:r.queued,sseHealth:e.sseHealth(),version:E(),...e.explorationStatus()}}),t.onRequest(Ge,()=>{let r=Un(e);return r&&e.onShutdownRequest(),r}),t.onClose(()=>{ur(e,t)}),t.onError(r=>{f.warn({err:r},"ipc connection error")}),n.on("error",r=>{f.warn({err:r},"ipc socket error")}),t.listen()}function Un(e){let n=ie();return e.jobs.size===0&&n.active===0&&n.queued===0}async function cr({connection:e,ctx:n,params:t,token:r}){let o=Ke.safeParse(t);if(!o.success)throw Mn({code:"bad-message"});await n.ready;let i=await gr({config:n.config,cwd:n.cwd,message:o.data});if(i.kind==="error")throw Mn(i.error);let s=tr(),a=new or;return r.onCancellationRequested(()=>{Dn(n,s)}),n.jobs.set(s,{cancellation:a,connection:e,failed:0,notRun:0,passed:0,total:i.selections.length}),br({ctx:n,headed:o.data.headed,jobId:s,lockfileHashValue:i.lockfileHashValue,selections:i.selections,targetsByClaimKey:i.targetsByClaimKey,token:a.token}).catch(c=>{f.error({err:c},"ipc dispatch failed")}),{jobId:s,total:i.selections.length}}function Mn(e){return new ir(sr,e.code,e)}function Dn(e,n){let t=e.jobs.get(n);t!=null&&(t.cancellation.cancel(),e.jobs.delete(n),Sn(e.inflight,n))}function ur(e,n){[...e.jobs.entries()].filter(([,t])=>t.connection===n).forEach(([t])=>{Dn(e,t)})}function Nn(e,n,t){let r=e.jobs.get(n);r!=null&&(On(()=>r.connection.sendNotification(Ye,{event:t,jobId:n})),t.kind==="test-outcome"&&(pr(r,t.outcome.kind),r.passed+r.failed+r.notRun>=r.total&&(On(()=>r.connection.sendNotification(Xe,{failed:r.failed,jobId:n,notRun:r.notRun,passed:r.passed})),e.jobs.delete(n))))}function On(e){Promise.resolve().then(e).catch(n=>{f.warn({err:n},"ipc notification failed")})}function pr(e,n){if(n==="pass"){e.passed+=1;return}if(n==="dispatch-error"||n==="dispatch-timeout"||n==="infra-error"){e.notRun+=1;return}e.failed+=1}function x(e,n,t){n.jobIds.forEach(r=>{Nn(e,r,t)})}function fr(e,n){let t=ce(e.inflight,n);return t==null?null:{headed:t.headed,token:t.cancellation.token,finished:(r,o)=>{e.inflight.delete(t.inflightKey),x(e,t,{kind:"test-outcome",outcome:o,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},started:()=>{x(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}}}function yr(e){return e.kind==="typecheck-failed"?e.diagnostics.slice(0,5):e.kind==="invalid-lockfile"?e.issues.slice(0,5):e.kind==="load-threw"?[e.message]:[]}async function gr({config:e,cwd:n,message:t}){return(await Ae(n)).match(o=>mr({config:e,cwd:n,lockfile:o,message:t}),o=>Promise.resolve({error:{code:"compile-failed",detail:o.kind,diagnostics:[...yr(o)]},kind:"error"}))}async function mr({config:e,cwd:n,lockfile:t,message:r}){let o=await Sr(e.appUrl);if(o!=null)return{error:{code:"app-unreachable",detail:o,url:e.appUrl},kind:"error"};let i=Ee(t);if(!ge.has(i)){let a=await kr({config:e,cwd:n,lockfile:t});if(a!=null)return{error:{code:"sync-failed",detail:a},kind:"error"};ge.add(i)}return(await wr({config:e,cwd:n,lockfile:t,message:r})).match(async a=>({kind:"ready",lockfileHashValue:i,selections:xn(t,a),targetsByClaimKey:await hr({config:e,cwd:n,hash:i})}),a=>Promise.resolve({error:a,kind:"error"}))}async function hr({config:e,cwd:n,hash:t}){let r=Fn.get(t);if(r!=null)return r;let o=await hn(e,n);return Fn.set(t,o),o}var Rr=2e3;async function Sr(e){try{return await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(Rr)}),null}catch(n){return n instanceof Error?n.message:String(n)}}async function kr(e){try{return await v(e),null}catch(n){return n instanceof Error?n.message:String(n)}}async function wr({config:e,cwd:n,lockfile:t,message:r}){return!r.all&&r.tests.length===0?(await An({config:e,cwd:n,lockfile:t})).mapErr(vr):vn({all:r.all,ids:r.tests,lockfile:t}).mapErr(xr)}function vr(e){return e.kind==="scope-empty"?{code:"selection-nothing-selected"}:{code:"scope-failed",detail:e.detail}}function xr(e){switch(e.kind){case"conflicting-flags":return{code:"selection-conflicting-flags"};case"nothing-selected":return{code:"selection-nothing-selected"};case"unknown-ids":return{code:"selection-unknown-ids",known:[...e.known],unknown:[...e.unknown]}}}async function br(e){await e.selections.reduce((n,t)=>n.then(()=>Ir(e,t)),Promise.resolve())}async function Ir(e,n){let{ctx:t,headed:r,jobId:o,lockfileHashValue:i,targetsByClaimKey:s,token:a}=e;if(a.isCancellationRequested)return;let c=de(n),d=s.get(c);if(d==null){Nn(t,o,{kind:"test-outcome",outcome:{kind:"dispatch-error",reason:{detail:"test-not-found",type:"generic"}},runId:"",testName:n.testName,workflowName:n.workflowName});return}let p=Rn({headed:r,inflight:t.inflight,jobId:o,lockfileHashValue:i,runId:rr(),selection:n,timeoutMs:ar,onExpire:m=>{x(t,m,{kind:"test-outcome",outcome:{detail:"dispatch-timeout",kind:"dispatch-timeout"},runId:"",testName:m.testName,workflowName:m.workflowName})}});if(p==null)return;let l=t.executor(),y=await Er({ctx:t,executor:l,lockfileHashValue:i,run:p,target:d});if(y!=null){W(t.inflight,p),x(t,p,{kind:"test-outcome",outcome:y,runId:"",testName:n.testName,workflowName:n.workflowName});return}l==="cloud"&&Pr(t,p)}function Er({ctx:e,executor:n,lockfileHashValue:t,run:r,target:o}){return mn({config:e.config,executor:n,lockfileHash:t,runId:r.runId,target:o})}function Pr(e,n){let t=ce(e.inflight,n.runId);t!=null&&$n({config:e.config,runId:t.runId,signal:lr(t.cancellation.token),onComplete:r=>{e.inflight.delete(t.inflightKey),x(e,t,{kind:"test-outcome",outcome:r,runId:t.runId,testName:t.testName,workflowName:t.workflowName})},onStarted:()=>{x(e,t,{kind:"test-started",runId:t.runId,testName:t.testName,workflowName:t.workflowName})}})}import Tr from"fs";import Cr from"path";async function ss(e){let n=Cr.join(e,".ripplo","index.ts");if(!Tr.existsSync(n))return{appUrl:void 0,engineUrl:void 0,errors:[{message:".ripplo/index.ts not found",path:""}],valid:!1,warnings:[]};let t=await C(e);return t.isErr()?{appUrl:void 0,engineUrl:void 0,errors:[{message:A(t.error),path:".ripplo/"}],valid:!1,warnings:[]}:D().match(r=>({appUrl:r.appUrl,engineUrl:r.engineUrl,errors:[],valid:!0,warnings:[]}),r=>({appUrl:void 0,engineUrl:void 0,errors:[{message:te(r),path:""}],valid:!1,warnings:[]}))}async function ls(e){try{await fetch(e,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return}catch{return`appUrl (${e}) is not responding. Make sure your dev server is running on that port.`}}async function ds({appUrl:e,engineUrl:n}){let t=n.startsWith("http://")||n.startsWith("https://")?n:`${e}${n}`;try{return(await fetch(`${t}/setup`,{body:JSON.stringify({}),headers:{"Content-Type":"application/json"},method:"PUT",signal:AbortSignal.timeout(5e3)})).ok?"Engine endpoint accepted an unsigned request \u2014 webhook signature verification may be missing.":void 0}catch{return}}import{createMessageConnection as Ln,IPCMessageReader as qn,IPCMessageWriter as _n,NotificationType as Ar,NotificationType0 as Hn,RequestType as Wn,RequestType0 as jr}from"vscode-jsonrpc/node";import{z as R}from"zod";var gs=R.object({headed:R.boolean(),runId:R.string().min(1),testRef:R.string().min(1)}),ms=R.object({lockfileJson:R.string().optional(),unavailable:R.string().optional()}),hs=R.object({runId:R.string().min(1),span:Ie}),Rs=R.object({outcome:Je,serverNotified:R.boolean()}),Ss=new Hn("worker/ready"),ks=new Wn("worker/run"),ws=new jr("worker/lockfile"),vs=new Wn("worker/exploreTrail"),xs=new Ar("worker/span"),bs=new Hn("worker/shutdown");function Is(e){let n=Ln(new qn(e),new _n(e));return n.listen(),n}function Es(){let e=Ln(new qn(process),new _n(process));return e.listen(),e}import{graphql as k}from"gql.tada";import{gzip as Lr}from"zlib";import{promisify as qr}from"util";import{existsSync as Jn,readFileSync as Qn}from"fs";import zn from"path";import{graphql as I}from"gql.tada";function Vn(e){return[e.kind,e.target,e.value].filter(n=>n.length>0).join(" ")}var $r={"no-effect":"noEffect","required-state-unsatisfied":"requiredStateUnsatisfied",unresolvable:"unresolvable"},Fr={"data-rule":"dataRule",fact:"fact",step:"step"},Mr={aborted:"aborted","action-failed":"actionFailed","app-not-ready":"appNotReady","check-failed":"checkFailed","client-mount-missing":"clientMountMissing","conflicting-sessions":"conflictingSessions","driver-launch":"driverLaunch","engine-decode":"engineDecode","engine-http":"engineHttp","engine-network":"engineNetwork","engine-unreachable":"engineUnreachable","setup-missing-row":"setupMissingRow","state-identity":"stateIdentity"};function Bn(e){return e.kind==="consistency"?{consistency:{mismatch:Dr(e.mismatch),pending:e.pending}}:e.kind==="pending-check"?{pendingCheck:{budget:e.budget,source:Fr[e.source.kind],...Or(e.source)}}:e.kind==="unrunnable"?{unrunnable:{reason:$r[e.reason]}}:e.kind==="lift-visibility"?{impossibleAction:{subject:`lift visible to step ${String(e.visibleIndex+1)} of ${String(e.declaredIndex+1)}`}}:e.kind==="driver-error"?{driverError:{errorKind:Mr[e.error.kind],message:Nr(e.error)}}:{impossibleAction:{subject:Ur(e.step.action)}}}function Or(e){return"check"in e?Kn(e.check,!1):{checkKind:void 0,expected:void 0,negated:void 0,subject:void 0}}function Kn(e,n){return e.kind==="not"?Kn(e.inner,!n):e.kind==="browser"?{checkKind:"browser",expected:e.value??void 0,negated:n,subject:Me(e.key)}:e.kind==="value"||e.kind==="text"?{checkKind:e.kind,expected:e.value,negated:n,subject:P(e.locator)}:{checkKind:e.kind,expected:void 0,negated:n,subject:P(e.locator)}}function Ur(e){let n=e.locator==null?e.url??"":P(e.locator);return`${e.kind} ${n}`.trim()}function Dr(e){return e.kind==="wrong-value"?{wrongValue:{entity:e.entity,field:e.field,key:e.key,snapshot:B(e.snapshot),sut:B(e.sut)}}:e.kind==="expected-change"?{expectedChange:{entity:e.entity,field:e.field,key:e.key,value:B(e.value)}}:e.kind==="scalar-mismatch"?{scalarMismatch:{singleton:Ne(e.subject),snapshot:Le(e.want),sut:B(e.sut)}}:e.kind==="unexpected-row"?{unexpectedRow:{entity:e.entity,key:e.key}}:{missingRow:{entity:e.entity,key:e.key}}}function B(e){return e==null?null:String(e)}function Nr(e){return"message"in e?e.message:"detail"in e?e.detail:null}function K({config:e,fixturesDir:n,headed:t}){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:n,generate:j,headed:t,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth}}async function he(e){let n=await J(e);await Re(e.config,e.runId,n)}async function J({config:e,debugDir:n,events:t,recordingOptional:r,runId:o,stepSources:i}){let s=Se(t),a=Vr(n,o);if(a==null&&!r)throw new Error("recording-missing");return await Promise.all([Xr({aliases:[...Jr(t),...Qr(s)],config:e,generated:zr(t),generatedSingletons:Gr(t),origin:a==null?Wr(s):a.origin,records:s,rrwebEvents:a==null?[]:a.events,runId:o,stepSources:i}),a==null?Promise.resolve():io(e,o,a)]),s}async function Re(e,n,t){let r=t.filter(s=>s.findings.length>0).length,o=t.length-r,i=t.reduce((s,a)=>s+Math.max(0,a.endMs-a.startMs),0);await u({config:e,document:co,variables:{items:[{duration:i,failCount:r,passCount:o,runId:n,status:r>0?"failed":"passed",summary:null,warnCount:0}]}})}function Se(e){return e.flatMap(n=>n.kind==="step"?[{annotations:n.annotations,endMs:n.endMs,findings:n.findings,index:n.index,source:n.source,startMs:n.startMs,state:n.state,url:n.url}]:[])}async function Gn(e,n){await u({config:e,document:uo,variables:{runIds:[n]}})}async function _r({config:e,debugDir:n,runId:t}){let r=zn.join(n,t,"behavior.jsonl");if(Jn(r))try{let o=await u({config:e,document:ao,variables:{runId:t}}),i=await fetch(o.debugArtifactUploadUrl,{body:Qn(r),headers:{"content-type":Hr},method:"PUT"});if(!i.ok){f.warn({runId:t,status:i.status},"behavior upload PUT failed");return}await Gn(e,t)}catch(o){f.warn({error:o,runId:t},"behavior upload failed")}}var Hr="application/x-ndjson";function Wr(e){return e.reduce((n,t)=>Math.min(n,t.startMs),e[0]?.startMs??0)}function Vr(e,n){let t=zn.join(e,n,"behavior.jsonl");if(!Jn(t))return null;let r=Qn(t,"utf8").split(`
|
|
138
|
-
`).filter(i=>i.length>0).map(i=>Br(i)).flatMap(i=>Kr(i)?[i.event]:[]),o=r[0];return o==null?null:{events:r,origin:o.timestamp}}function Br(e){return JSON.parse(e)}function Kr(e){return typeof e=="object"&&e!=null&&Reflect.get(e,"kind")==="rrweb"}function Jr(e){return e.flatMap(n=>n.kind==="world"?n.aliases:[])}function Qr(e){return e.flatMap(n=>{let t=Yr(n.source);return t.flatMap(r=>{let i=t.filter(a=>a.entity===r.entity).indexOf(r),s=n.state.rows.filter(a=>a.status==="created"&&a.entity===r.entity).at(i);return s==null?[]:[{alias:r.as,entity:r.entity,key:s.key}]})})}function zr(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generated.map(t=>Yn(t)):[]))}function Yn({entity:e,field:n,key:t}){return`${e} ${t} ${n}`}function Gr(e){return new Set(e.flatMap(n=>n.kind==="world"?n.generatedSingletons:[]))}function Yr(e){return e==null?[]:e.expect.flatMap(n=>me(n))}function me(e){return e.kind==="state"&&e.assertion.kind==="created"?[{as:e.assertion.as,entity:e.entity}]:e.kind==="and"?e.predicates.flatMap(n=>me(n)):e.kind==="when"?e.branches.flatMap(n=>n.consequence.flatMap(t=>me(t))):[]}async function Xr({aliases:e,config:n,generated:t,generatedSingletons:r,origin:o,records:i,rrwebEvents:s,runId:a,stepSources:c}){let d=i.map((p,l)=>to({aliases:e,generated:t,generatedSingletons:r,origin:o,record:p,rrwebEvents:s,sourceTest:c?.[l]??null}));await u({config:n,document:so,variables:{items:[{runId:a,steps:d}]}})}var Zr=3,eo=0;function no({endMs:e,rrwebEvents:n,startMs:t}){let r=n.find(o=>o.type===Zr&&o.data?.source===eo&&o.timestamp>=t&&o.timestamp<=e);return r==null?t:r.timestamp}function to({aliases:e,generated:n,generatedSingletons:t,origin:r,record:o,rrwebEvents:i,sourceTest:s}){let a=Te(o.source,o.index),c=no({endMs:o.endMs,rrwebEvents:i,startMs:o.startMs}),d=o.annotations.map(l=>({kind:l.kind,label:l.label,outcome:l.outcome,recordingStartMs:Math.max(0,(l.kind==="action"?c:l.atMs)-r),rrwebIds:[...l.rrwebIds],url:l.url,value:l.value??null})),p=o.annotations.find(l=>l.kind==="action")?.rrwebIds??[];return{annotations:d,detail:null,duration:Math.max(0,o.endMs-o.startMs),findings:o.findings.map(l=>Bn(l)),nodeType:a.kind,recordingEndMs:Math.max(0,o.endMs-r),recordingStartMs:Math.max(0,c-r),rrwebIds:[...p],snapshotTimestamp:Math.max(0,o.endMs-r),sourceTest:s,stateRows:o.state.rows.map(l=>ro({aliases:e,generated:n,row:l})),stateSingletons:o.state.singletons.map(l=>({changed:l.changed,generated:t.has(l.name),name:l.name,value:l.value==null?null:String(l.value)})),status:o.findings.length>0?"failed":"passed",stepIndex:o.index,title:Vn(a),url:o.url}}function ro({aliases:e,generated:n,row:t}){let r=e.find(o=>o.entity===t.entity&&o.key===t.key);return{entity:t.entity,fields:t.fields.map(o=>({changed:o.changed,field:o.field,generated:n.has(Yn({entity:t.entity,field:o.field,key:t.key})),value:o.value==null?null:String(o.value)})),key:t.key,label:r?.alias??t.key,status:t.status}}var oo=qr(Lr);async function io(e,n,t){let r=t.events.map(s=>JSON.stringify(s)).join(`
|
|
139
|
-
`),o=await oo(Buffer.from(r,"utf8")),i=t.events.at(-1);await u({config:e,document:lo,variables:{input:{bodyBase64:o.toString("base64"),chunkIndex:0,endTimestamp:Math.max(0,(i?.timestamp??t.origin)-t.origin),eventCount:t.events.length,runId:n,startTimestamp:0}}})}var ao=I(`
|
|
140
|
-
mutation DebugArtifactUploadUrl($runId: String!) {
|
|
141
|
-
debugArtifactUploadUrl(runId: $runId)
|
|
142
|
-
}
|
|
143
|
-
`),so=I(`
|
|
144
|
-
mutation SubmitRunStepsBatch($items: [SubmitRunStepsItem!]!) {
|
|
145
|
-
submitRunStepsBatch(items: $items)
|
|
146
|
-
}
|
|
147
|
-
`),lo=I(`
|
|
148
|
-
mutation SubmitRunRecordingChunk($input: SubmitRunRecordingChunkInput!) {
|
|
149
|
-
submitRunRecordingChunk(input: $input)
|
|
150
|
-
}
|
|
151
|
-
`),co=I(`
|
|
152
|
-
mutation CompleteRunsBatch($items: [CompleteRunItem!]!) {
|
|
153
|
-
completeRunsBatch(items: $items) {
|
|
154
|
-
id
|
|
155
|
-
status
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
`),uo=I(`
|
|
159
|
-
mutation MarkRunArtifactsUploadedBatch($runIds: [String!]!) {
|
|
160
|
-
markRunArtifactsUploadedBatch(runIds: $runIds)
|
|
161
|
-
}
|
|
162
|
-
`);function po(e){let n=e.trail;if(!(n==null||!fo(e.kind)))return{baseLabel:n.baseLabel,baseState:n.baseState,durationMs:n.durationMs,outcome:e.kind,runId:e.runId,signature:n.signature,steps:n.steps}}function fo(e){return e==="clean"||e==="flaky"||e==="finding"}async function ke({baseState:e,branchName:n,category:t,commitSha:r,config:o,debugDir:i,devSessionId:s,events:a,lockfileHash:c,reproJson:d,runId:p,signature:l,spec:y,stepSources:m}){await u({config:o,document:ko,variables:{branchName:n??null,commitSha:r??null,devSessionId:s??null,lockfileHash:c??null,projectId:o.projectId,reproJson:d,runId:p,spec:y??null}}),await he({config:o,debugDir:i,events:a,recordingOptional:!0,runId:p,stepSources:m}),await u({config:o,document:wo,variables:{baseState:e,category:t,projectId:o.projectId,reproRunId:p,signature:l}})}async function Q(e,n,t){return(await u({config:e,document:vo,variables:{lockfileHash:t,projectId:e.projectId,signature:n}})).exploreFindingExists}async function yo({attempts:e,config:n,devSessionId:t,findings:r,trail:o}){await u({config:n,document:Ro,variables:{attempts:e,devSessionId:t,findings:r,trail:o==null?null:{baseLabel:o.baseLabel,baseState:o.baseState,durationMs:o.durationMs,findingRunId:o.runId??null,findingSignature:o.signature??null,outcome:o.outcome,steps:o.steps.map(i=>({test:i.test,text:i.text}))}}})}async function go(e,n,t){let r=await u({config:e,document:mo,variables:{devSessionId:n}}).catch(i=>(f.warn({error:i},"fetchScopedTestRefs failed"),null)),o=new Set(r?.exploreScope??[]);return o.size===0?new Set:new Set(t.workflows.filter(i=>o.has(g(i.name))).flatMap(i=>i.tests.map(s=>h(s))))}var mo=k(`
|
|
163
|
-
query ExploreScope($devSessionId: String!) {
|
|
164
|
-
exploreScope(devSessionId: $devSessionId)
|
|
165
|
-
}
|
|
166
|
-
`);async function ho(e,n){return(await u({config:e,document:So,variables:{devSessionId:n}}).catch(r=>(f.warn({error:r},"reportExploreUnhealthy failed"),null)))?.reportExploreUnhealthy??!1}var Ro=k(`
|
|
167
|
-
mutation RecordExplorationProgress(
|
|
168
|
-
$devSessionId: String!
|
|
169
|
-
$attempts: Int!
|
|
170
|
-
$findings: Int!
|
|
171
|
-
$trail: ExploreTrailInput
|
|
172
|
-
) {
|
|
173
|
-
recordExplorationProgress(
|
|
174
|
-
devSessionId: $devSessionId
|
|
175
|
-
attempts: $attempts
|
|
176
|
-
findings: $findings
|
|
177
|
-
trail: $trail
|
|
178
|
-
)
|
|
179
|
-
}
|
|
180
|
-
`),So=k(`
|
|
181
|
-
mutation ReportExploreUnhealthy($devSessionId: String!) {
|
|
182
|
-
reportExploreUnhealthy(devSessionId: $devSessionId)
|
|
183
|
-
}
|
|
184
|
-
`),ko=k(`
|
|
185
|
-
mutation CreateExploreRun(
|
|
186
|
-
$projectId: String!
|
|
187
|
-
$runId: String!
|
|
188
|
-
$devSessionId: String
|
|
189
|
-
$branchName: String
|
|
190
|
-
$commitSha: String
|
|
191
|
-
$lockfileHash: String
|
|
192
|
-
$spec: String
|
|
193
|
-
$reproJson: String
|
|
194
|
-
) {
|
|
195
|
-
createExploreRun(
|
|
196
|
-
projectId: $projectId
|
|
197
|
-
runId: $runId
|
|
198
|
-
devSessionId: $devSessionId
|
|
199
|
-
branchName: $branchName
|
|
200
|
-
commitSha: $commitSha
|
|
201
|
-
lockfileHash: $lockfileHash
|
|
202
|
-
spec: $spec
|
|
203
|
-
reproJson: $reproJson
|
|
204
|
-
) {
|
|
205
|
-
id
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
`),wo=k(`
|
|
209
|
-
mutation SubmitExploreFinding(
|
|
210
|
-
$projectId: String!
|
|
211
|
-
$signature: String!
|
|
212
|
-
$baseState: String!
|
|
213
|
-
$category: ExploreFindingCategory!
|
|
214
|
-
$reproRunId: String!
|
|
215
|
-
) {
|
|
216
|
-
submitExploreFinding(
|
|
217
|
-
projectId: $projectId
|
|
218
|
-
signature: $signature
|
|
219
|
-
baseState: $baseState
|
|
220
|
-
category: $category
|
|
221
|
-
reproRunId: $reproRunId
|
|
222
|
-
) {
|
|
223
|
-
id
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
`),Qs=k(`
|
|
227
|
-
mutation SetExploreFindingStatus(
|
|
228
|
-
$projectId: String!
|
|
229
|
-
$signature: String!
|
|
230
|
-
$status: ExploreFindingStatus!
|
|
231
|
-
) {
|
|
232
|
-
setExploreFindingStatus(projectId: $projectId, signature: $signature, status: $status)
|
|
233
|
-
}
|
|
234
|
-
`),vo=k(`
|
|
235
|
-
query ExploreFindingExists($projectId: String!, $signature: String!, $lockfileHash: String!) {
|
|
236
|
-
exploreFindingExists(projectId: $projectId, signature: $signature, lockfileHash: $lockfileHash)
|
|
237
|
-
}
|
|
238
|
-
`);import xo from"path";import{graphql as bo}from"gql.tada";async function Io({config:e,cwd:n,fixturesDir:t,headed:r,lockfile:o,runId:i,session:s,signal:a,test:c}){if(!await Po(e,i))return{outcome:{kind:"dispatch-failed",reason:"already-claimed",runId:i},persisted:Promise.resolve()};let p=xo.join(n,".ripplo","debug"),l=[];return(await s.runOnce({capture:!0,lockfile:o,onPhase:void 0,options:K({config:e,fixturesDir:t,headed:r}),params:void 0,runId:i,sequence:void 0,test:c,onEvent:m=>{l.push(m)}},a)).match(async m=>{let w=Se(l),G=w.flatMap(et=>et.findings),we=Eo(G);if(we!=null)return await J({config:e,debugDir:p,events:l,recordingOptional:!0,runId:i,stepSources:void 0}),{outcome:{error:we,kind:"error",runId:i},persisted:Promise.resolve()};await Re(e,i,w);let Zn=J({config:e,debugDir:p,events:l,recordingOptional:!0,runId:i,stepSources:void 0}).then(()=>{});return{outcome:G.length>0?{findings:G,kind:"findings",runId:i}:{kind:"pass",runId:i},persisted:Zn}},m=>Promise.resolve({outcome:{error:m,kind:"error",runId:i},persisted:Promise.resolve()}))}function Eo(e){let n=e.find(t=>t.kind==="driver-error"&&Oe(t.error));return n!=null&&n.kind==="driver-error"?n.error:void 0}async function Po(e,n){return((await u({config:e,document:To,variables:{runIds:[n]}})).startRunsBatch??[]).some(r=>r.id===n)}var To=bo(`
|
|
239
|
-
mutation StartRunsBatch($runIds: [String!]!) {
|
|
240
|
-
startRunsBatch(runIds: $runIds) {
|
|
241
|
-
id
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
`);import{graphql as Xn}from"gql.tada";async function Co(e,n,t){await u({config:e,document:Ao,variables:{reason:t,runId:n}}).catch(r=>{f.error(r,"failRun submission failed")})}var Ao=Xn(`
|
|
245
|
-
mutation FailRun($runId: String!, $reason: String!) {
|
|
246
|
-
failRun(runId: $runId, reason: $reason)
|
|
247
|
-
}
|
|
248
|
-
`),ol=Xn(`
|
|
249
|
-
mutation MarkRunUnready($runId: String!, $cause: RunUnreadyCause!) {
|
|
250
|
-
markRunUnready(runId: $runId, cause: $cause)
|
|
251
|
-
}
|
|
252
|
-
`);import{randomUUID as jo}from"crypto";async function $o({assign:e,config:n,debugDir:t,devSessionId:r,fixturesDir:o,headed:i,lockfile:s,report:a,session:c,signal:d}){let p=De(s);if(e.stepRuns.length===0)return{kind:"error",reason:"empty-trail"};let l=_o(p,e.stepRuns),y=await We({baseState:{name:h(e.baseStateTest),test:e.baseStateTest},corpus:p,lockfile:s,options:K({config:n,fixturesDir:o,headed:i}),seenSignature:a?w=>Q(n,w,e.lockfileHash):void 0,session:c,stepRuns:e.stepRuns,runIdFor:w=>`explore-${jo()}-${String(w)}`},d),m=a?await No({baseStateTest:e.baseStateTest,config:n,debugDir:t,devSessionId:r,lockfileHash:e.lockfileHash,outcome:y,reproJson:Uo(p,e),stepSources:Do(l)}):!1;return Oo(y,l.length),Ho(y,m,Fo(l,e,y))}function Fo(e,n,t){if(t.kind==="error"||t.kind==="aborted")return;let r=t.timing.confirm;return{baseLabel:n.baseStateTest.intent,baseState:h(n.baseStateTest),durationMs:Math.round(z(t.timing.detect)+(r==null?0:z(r))),signature:t.kind==="finding"?t.signature:void 0,steps:Mo(e)}}function Mo(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(r=>({test:t,text:r}))})}function z(e){return e.engineMs+e.worldMs+e.browserMs+e.driveMs+e.teardownMs}function Oo(e,n){if(e.kind==="error"){f.info({detail:Ue(e.error),kind:e.kind,reason:e.error.kind,steps:n},"explore trail");return}if(e.kind==="aborted"){f.info({kind:e.kind,steps:n},"explore trail");return}let t=e.timing.detect,r=e.timing.confirm;f.info({browserMs:t.browserMs,confirmMs:r==null?void 0:z(r),detectMs:z(t),driveMs:t.driveMs,engineMs:t.engineMs,kind:e.kind,steps:n,teardownMs:t.teardownMs,worldMs:t.worldMs},"explore trail")}function Uo(e,n){let t=n.stepRuns.flatMap(o=>{let i=e[o.idx];return i==null?[]:[{index:i.index,params:o.params,test:i.test}]}),r={baseStateRef:h(n.baseStateTest),steps:t};return JSON.stringify(r)}function Do(e){return e.flatMap(n=>{let t=n.label.split("#")[0]??n.label;return n.actions.map(()=>t)})}async function No({baseStateTest:e,config:n,debugDir:t,devSessionId:r,lockfileHash:o,outcome:i,reproJson:s,stepSources:a}){return i.kind!=="finding"||i.captureEvents.length===0?!1:await Q(n,i.signature,o)?(f.info({devSessionId:r,signature:i.signature},"explore finding already reported, skipping duplicate"),!1):(await ke({baseState:i.baseState,branchName:void 0,category:Lo(i.verifierLayer),commitSha:void 0,config:n,debugDir:t,devSessionId:r,events:i.captureEvents,lockfileHash:o,reproJson:s,runId:i.runId,signature:i.signature,spec:qo(e,i.captureEvents),stepSources:a}).catch(c=>{f.warn({error:c},"explore finding report failed")}),!0)}function Lo(e){return e==="data-rule"?"dataRule":e==="fact"?"fact":e}function qo(e,n){let t=n.flatMap(o=>o.kind==="step"?[o.source]:[]),r={absent:e.absent,exclusive:e.exclusive,intent:e.intent,maybe:[],name:e.name,params:e.params,singletons:e.singletons,steps:t,stub:!1,tests:[],world:e.world};return JSON.stringify(r)}function _o(e,n){return n.flatMap(t=>{let r=e[t.idx];return r==null?[]:[{actions:[...r.nav,...r.steps].map(o=>qe(o.action)),label:`${r.test}#${String(r.index)}`}]})}function Ho(e,n,t){return e.kind==="error"?{kind:e.kind,reason:`runtime:${e.error.kind}`}:e.kind==="finding"?{kind:e.kind,runId:n?e.runId:void 0,trail:t}:{kind:e.kind,trail:t}}import Wo from"path";import{randomUUID as Vo}from"crypto";async function Pl({cwd:e,onReady:n,signal:t,step:r,target:o}){let i=L(e).match(l=>({config:l}),l=>({failure:l}));if("failure"in i)return{failure:i.failure,kind:"config-failed"};let s=i.config,a=await je(e);if(a.result.isErr())return{error:a.result.error,kind:"compile-failed"};let c=a.result.value,d=await Bo(c,o);return d.kind!=="ok"?d:(await _e({lockfile:c,onReady:n,options:Ko(s),runId:`teleport-${Vo()}`,sequence:d.sequence,stopAfterStep:r,test:d.test},t)).match(l=>({kind:"done",result:l}),l=>({error:l,kind:"run-failed"}))}async function Bo(e,n){if(n.kind==="explore"){let r=await Ve(e,n.repro);return r.kind==="unplannable"?{kind:"unplannable"}:{kind:"ok",sequence:r.sequence,test:r.baseTest}}let t=b(e).find(r=>r.ref===n.ref);return t==null?{kind:"no-test",ref:n.ref}:{kind:"ok",sequence:He(e,t.test,void 0),test:t.test}}function Ko(e){return{baseUrl:e.appUrl,engineUrl:e.engineUrl,fixturesDir:Wo.join(e.cwd,T),generate:j,headed:!0,secret:e.webhookSecret,tunnelAuth:e.tunnelAuth}}export{Xo as a,ai as b,D as c,lt as d,pi as e,te as f,on as g,sn as h,L as i,V as j,bn as k,ss as l,ls as m,ds as n,Wt as o,In as p,gs as q,hs as r,Rs as s,Ss as t,ks as u,ws as v,vs as w,xs as x,bs as y,Is as z,Es as A,Pi as B,Ti as C,ie as D,Ci as E,un as F,Vi as G,v as H,Bi as I,ba as J,Xa as K,lr as L,Za as M,_r as N,Io as O,Co as P,po as Q,yo as R,go as S,ho as T,$o as U,Pl as V};
|
package/dist/daemon-MHGTHG25.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{B as E,C as T,D as Ae,E as O,F as We,H as Le,I as De,K as He,L as _e,M as qe,P as C,Q as Me,R as Ue,S as $e,T as Oe,V as Fe,b as V,f as oe,i as v,m as ie,o as me,s as xe,t as be,u as Pe,v as Re,w as Ee,x as Te,y as Ce,z as Ie}from"./chunk-LYZ6JY7L.js";import{e as ne,f as te}from"./chunk-4J4T7534.js";import{a as Y,d as R,e as re,f as U,i as $,m as ye}from"./chunk-VW7PTYJ3.js";import{c as Q,d as y,e as l,f as M,g as K}from"./chunk-4K4VY5OR.js";import{$ as ge,K as se,M as ce,N as de,O as ue,P as pe,Q as fe,_ as Se,aa as ve,ba as ke,ca as he,e as X,ea as we,h as Z,i as x,l as ee,o as ae,q as le}from"./chunk-M4ESW6JP.js";import"./chunk-SB7H6IAS.js";import cn from"path";import{createClient as dn}from"graphql-sse";import un,{AbortError as pn}from"p-retry";import{graphql as J}from"gql.tada";import{graphql as Fr}from"gql.tada";import{print as Nr}from"graphql";async function Ne({config:e,cwd:r,headed:o,pool:n,runId:t,signal:a,testSlug:s,workClass:i,workflowSlug:c}){let u=await R(r);if(u.isErr())return await C(e,t,`lockfile:${u.error.kind}`),{kind:"dispatch-error",reason:{detail:`lockfile:${u.error.kind}`,type:"generic"}};let p=Or(u.value,{testSlug:s,workflowSlug:c});if(p==null)return await C(e,t,`no-test:${c}/${s}`),{kind:"dispatch-error",reason:{detail:`no-test:${c}/${s}`,type:"generic"}};let d=await E({headed:o,workClass:i,task:()=>n.execute({headed:o,runId:t,testRef:p},a)});return!d.serverNotified&&d.outcome.kind==="error"&&await C(e,t,d.outcome.detail),d.outcome}function Or(e,{testSlug:r,workflowSlug:o}){let t=e.workflows.find(a=>ee(a.name)===o)?.tests.find(a=>a.slug===r);return t==null?void 0:le(t)}var Br=6e4,jr=Fr(`
|
|
3
|
-
subscription RunRequestedWatch($devSessionId: String!) {
|
|
4
|
-
runRequested(devSessionId: $devSessionId) {
|
|
5
|
-
runId
|
|
6
|
-
testSlug
|
|
7
|
-
workflowId
|
|
8
|
-
workflowSlug
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
`);async function Be(e){let r=Math.min(1e3*2**e,Br)+Jr();await new Promise(o=>setTimeout(o,r))}function je({claim:e,cwd:r,devSessionId:o,onSubscriptionDead:n,pool:t,sseClient:a,sseHealth:s}){let i=new Set;return a.subscribe({query:Nr(jr),variables:{devSessionId:o}},{complete:()=>{},error:c=>{let u=c instanceof Error?c.message:String(c);l.warn("runRequested SSE failed: %s; re-registering session",u),n(u)},next:c=>{zr({claim:e,cwd:r,event:c.data?.runRequested,inFlightRunIds:i,pool:t})}},{connected:()=>{s.onConnected()},connecting:c=>{s.onConnecting(c),c&&l.debug("runRequested SSE reconnecting")}})}function zr({claim:e,cwd:r,event:o,inFlightRunIds:n,pool:t}){if(o==null)return;if(n.has(o.runId)){l.warn({runId:o.runId,workflowSlug:o.workflowSlug},"duplicate runRequested event; skipping dispatch");return}n.add(o.runId),process.stdout.write(`ripplo: run ${o.workflowSlug}
|
|
12
|
-
`),V(r);let a=v(r).match(i=>i,i=>{l.error({failure:i,runId:o.runId},"failed to load env for run dispatch; skipping")});if(a==null){n.delete(o.runId);return}let s=Gr(e(o.runId),o);s.started(),Ne({config:a,cwd:r,headed:s.headed,pool:t,runId:o.runId,signal:s.signal,testSlug:o.testSlug,workClass:s.workClass,workflowSlug:o.workflowSlug}).then(i=>{s.finished(i)}).catch(i=>{l.error({err:i,runId:o.runId,workflowSlug:o.workflowSlug},"run execution failed; daemon continuing"),s.finished({detail:i instanceof Error?i.message:String(i),kind:"error"})}).finally(()=>{n.delete(o.runId)})}function Gr(e,r){return e==null?(l.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:_e(e.token),workClass:"p1-cli",finished:o=>{e.finished(r.runId,o)},started:()=>{e.started(r.runId)}}}function Jr(){return Math.floor(Math.random()*2700)+300}import{graphql as F}from"gql.tada";import{print as Qr}from"graphql";var Kr=F(`
|
|
13
|
-
subscription TeleportRequestedWatch($devSessionId: String!) {
|
|
14
|
-
teleportRequested(devSessionId: $devSessionId) {
|
|
15
|
-
runId
|
|
16
|
-
stepIndex
|
|
17
|
-
kind
|
|
18
|
-
testSlug
|
|
19
|
-
workflowSlug
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
`),Vr=F(`
|
|
23
|
-
query TeleportRunRepro($id: String!) {
|
|
24
|
-
run(id: $id) {
|
|
25
|
-
id
|
|
26
|
-
reproJson
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`),Yr=F(`
|
|
30
|
-
mutation ReportTeleportResult($devSessionId: String!, $runId: String!, $status: String!) {
|
|
31
|
-
reportTeleportResult(devSessionId: $devSessionId, runId: $runId, status: $status)
|
|
32
|
-
}
|
|
33
|
-
`);function ze({cwd:e,devSessionId:r,onSubscriptionDead:o,sseClient:n}){let t=new Set,a=n.subscribe({query:Qr(Kr),variables:{devSessionId:r}},{complete:()=>{},error:s=>{let i=s instanceof Error?s.message:String(s);l.warn("teleportRequested SSE failed: %s; re-registering session",i),o(i)},next:s=>{Xr({cwd:e,devSessionId:r,event:s.data?.teleportRequested,running:t})}});return()=>{t.forEach(s=>{s.abort()}),t.clear(),a()}}function Xr({cwd:e,devSessionId:r,event:o,running:n}){if(o==null)return;let t=new AbortController;n.add(t),Zr({cwd:e,devSessionId:r,event:o,signal:t.signal}).catch(a=>{l.error({err:a},"teleport failed; daemon continuing")}).finally(()=>{n.delete(t)})}async function Zr({cwd:e,devSessionId:r,event:o,signal:n}){let t=c=>eo({cwd:e,devSessionId:r,runId:o.runId,status:c}),a=await ro(e,o);if(a==null){l.warn({runId:o.runId},"teleport could not resolve target"),await t("unplannable");return}process.stdout.write(`ripplo: teleport ${no(o)} step ${String(o.stepIndex+1)}
|
|
34
|
-
`);let i=await Fe({cwd:e,onReady:()=>{t("opened")},signal:n,step:o.stepIndex+1,target:a});i.kind==="done"&&i.result.kind==="handed-over"||(l.warn({kind:i.kind,runId:o.runId},"teleport could not open"),await t(i.kind==="unplannable"?"unplannable":"error"))}async function eo({cwd:e,devSessionId:r,runId:o,status:n}){let t=v(e).match(a=>a,()=>null);t!=null&&await y({config:t,document:Yr,variables:{devSessionId:r,runId:o,status:n}}).catch(()=>null)}async function ro(e,r){if(r.kind==="explore"){let o=await oo(e,r.runId);return o==null?null:{kind:"explore",repro:o}}return r.testSlug==null||r.workflowSlug==null?null:{kind:"test",ref:`${r.workflowSlug}/${r.testSlug}`}}async function oo(e,r){let o=v(e).match(t=>t,()=>null);if(o==null)return null;let n=await y({config:o,document:Vr,variables:{id:r}}).catch(()=>null);return n?.run?.reproJson==null?null:ce.parse(JSON.parse(n.run.reproJson))}function no(e){return e.kind==="explore"?"explore finding":`${String(e.workflowSlug)}/${String(e.testSlug)}`}function Ge(){let e=!0,r,o=null,n=()=>{o!=null&&(clearTimeout(o),o=null)};return{markUnhealthy:t=>{e=!1,r=t,n()},onConnected:()=>{n(),o=setTimeout(()=>{e=!0,r=void 0,o=null},1e4)},onConnecting:()=>{n()},snapshot:()=>({detail:r,ok:e})}}import to from"fs";import Ve from"net";import{err as Ye,ok as io}from"neverthrow";async function Xe({cwd:e,onConnection:r}){K(e);let o=ye(e),n=await Je({onConnection:r,socketPath:o});return n.isOk()||n.error.kind!=="stale-candidate"?n.map(Qe(o)).mapErr(Ke(o)):await ao(o)?Ye({kind:"already-running",socketPath:o}):(Ze(o),(await Je({onConnection:r,socketPath:o})).map(Qe(o)).mapErr(Ke(o)))}function ao(e){return new Promise(r=>{let o=Ve.connect(e);o.once("connect",()=>{o.destroy(),r(!0)}),o.once("error",()=>{r(!1)})})}async function Je(e){let r=await lo(e);return r.kind==="listening"?io(r.server):Ye(r.error)}function lo({onConnection:e,socketPath:r}){return new Promise(o=>{let n=Ve.createServer(e);n.once("error",t=>{o({error:t.code==="EADDRINUSE"?{kind:"stale-candidate"}:{kind:"listen-failed",message:t.message},kind:"failed"})}),n.listen(r,()=>{o({kind:"listening",server:n})})})}function Qe(e){return r=>({socketPath:e,close:()=>{r.close(),Ze(e)}})}function Ze(e){to.rmSync(e,{force:!0})}function Ke(e){return r=>r.kind==="stale-candidate"?{kind:"already-running",socketPath:e}:{kind:"bind-failed",message:r.message}}import{randomInt as so,randomUUID as co}from"crypto";function rr(e){let r={attempts:0,consecutiveErrors:0,driverBackoffUntil:0,findings:0,lastUnhealthyReportMs:0,lockfile:null,prepared:null,preparing:!1,refreshing:!1,scopedAt:0,scopedTests:new Set,scoping:!1,windowAttempts:0,windowFindings:0,windowStartMs:Date.now()},o=N(e,r);return{priority:"p3",next:()=>ko(e,r),onResult:()=>{},ready:()=>o,status:()=>({attempts:r.attempts,findings:r.findings}),stop:()=>Promise.resolve()}}var uo=10;async function N(e,r){if(!r.preparing){r.preparing=!0;try{let o=await e.loadLockfile(),n=o==null?null:await po(o);if(n==null||o==null)return;r.lockfile=o.lockfile,r.scopedAt=0,r.prepared=n,B(r),e.notifyWork()}finally{r.preparing=!1}}}async function po({lockfile:e}){let r=await ue(e);return r==null?null:{exploration:r,lockfileHashValue:x(e),strategy:se("even")}}var fo=6,mo=3e4,yo=2e4;function B(e){e.consecutiveErrors=0,e.driverBackoffUntil=0,e.lastUnhealthyReportMs=0}async function So(e,r){if(!(r.refreshing||r.preparing||r.prepared==null)){r.refreshing=!0;try{let o=await e.loadLockfile();if(o==null||x(o.lockfile)===r.prepared.lockfileHashValue)return;l.info("workflow definitions changed, re-preparing exploration"),r.prepared=null,await N(e,r)}finally{r.refreshing=!1}}}var go=15e3;async function vo(e,r){if(!(r.scoping||r.lockfile==null||Date.now()-r.scopedAt<go)){r.scoping=!0;try{r.scopedTests=await e.scopedTestRefs(r.lockfile),r.scopedAt=Date.now()}finally{r.scoping=!1}}}function ko(e,r){So(e,r),vo(e,r);let o=r.prepared;if(o==null||Date.now()<r.driverBackoffUntil)return null;let n=pe({lockfileHash:o.lockfileHashValue,prepared:o.exploration,random:ho,scopedTests:r.scopedTests,strategy:{...o.strategy,maxAttemptLength:e.maxTrailLength()}});if(n==null)return null;let t=n.baseStateTest.name;return{id:`explore:${co()}`,label:t,run:a=>wo({assign:n,params:e,signal:a,state:r})}}var er=2**31;function ho(){return so(er)/er}async function wo({assign:e,params:r,signal:o,state:n}){if(!await r.probeApp()){or({params:r,reason:"app-unreachable",state:n});return}let t=await r.executeTrail(e,o);if(t.kind==="aborted")return;if(t.kind==="error"){bo({params:r,reason:t.reason,state:n});return}B(n),n.attempts+=1,n.windowAttempts+=1;let a=t.kind==="finding";a&&(n.findings+=1,n.windowFindings+=1,l.info("exploration finding recorded")),r.reportProgress({attempts:1,findings:a?1:0,result:t}),n.windowAttempts>=uo&&xo(n)}function xo(e){let r=Date.now()-e.windowStartMs;l.info({attempts:e.windowAttempts,avgTrailMs:Math.round(r/e.windowAttempts),findings:e.windowFindings,windowMs:r,yield:Number((e.windowFindings/e.windowAttempts).toFixed(3))},"explore window"),e.windowAttempts=0,e.windowFindings=0,e.windowStartMs=Date.now()}function bo({params:e,reason:r,state:o}){if(r?.startsWith("lockfile:daemon-load-failed")===!0){Po(e,o);return}or({params:e,reason:r,state:o})}function Po(e,r){r.preparing||(r.prepared=null,N(e,r))}function or({params:e,reason:r,state:o}){let n=Eo(r);if(n==="trail"){B(o);return}o.consecutiveErrors+=1,l.debug("exploration infra error: %s",r),!(o.consecutiveErrors<fo)&&(n==="driver"&&(o.driverBackoffUntil=Date.now()+mo),Ro({params:e,reason:r,state:o}))}function Ro({params:e,reason:r,state:o}){let n=Date.now();n-o.lastUnhealthyReportMs<yo||(o.lastUnhealthyReportMs=n,l.warn("exploration unhealthy after %d consecutive infra errors (last: %s)",o.consecutiveErrors,r),e.reportUnhealthy())}function Eo(e){if(e==null||e==="error"||e==="app-unreachable"||e.startsWith("transport:"))return"infra";if(e.startsWith("runtime:")){let r=e.slice(8);return r==="driver-launch"?"driver":ae(r)?"infra":"trail"}return"trail"}function To(e){let{backoffActive:r,exploreEnabled:o,headedActive:n,interactiveActive:t,interactiveQueued:a}=e,{explorationActive:s,exploreConcurrency:i,poolSize:c}=e;if(!o||n||a>0)return{abortCount:s,refillCount:0};if(r)return{abortCount:0,refillCount:0};let u=Math.min(i,c-1,c-t);return{abortCount:0,refillCount:Math.max(0,u-s)}}function ir(e){let r={active:new Map,backoffUntil:0,cancelBackoffTimer:null,cancelHeartbeat:null,prevInteractiveActive:e.probe().interactiveActive,stopped:!1};return ar(r,e),{explorationActive:()=>r.active.size,notifyQueueChange:()=>{Co(r,e)},stop:()=>{r.stopped=!0,r.cancelBackoffTimer?.(),r.cancelBackoffTimer=null,r.cancelHeartbeat?.(),r.cancelHeartbeat=null,lr(r,r.active.size)}}}function ar(e,r){e.stopped||(e.cancelHeartbeat=r.setTimer(()=>{I(e,r),ar(e,r)},15e3))}function I(e,r){if(e.stopped)return;let o=r.probe(),n=To({backoffActive:r.now()<e.backoffUntil,explorationActive:e.active.size,exploreConcurrency:r.exploreConcurrency(),exploreEnabled:r.exploreEnabled(),headedActive:o.headedActive>0,interactiveActive:o.interactiveActive,interactiveQueued:o.interactiveQueued,poolSize:o.poolSize});lr(e,n.abortCount),sr({count:n.refillCount,params:r,state:e})}function lr(e,r){[...e.active.values()].slice(0,r).forEach(({controller:o})=>{o.abort()})}function Co(e,r){let o=r.probe();o.interactiveActive<e.prevInteractiveActive&&Io(e,r),e.prevInteractiveActive=o.interactiveActive,I(e,r)}function Io(e,r){e.backoffUntil=r.now()+3e4,e.cancelBackoffTimer?.(),e.cancelBackoffTimer=r.setTimer(()=>{e.cancelBackoffTimer=null,I(e,r)},3e4)}function sr({count:e,params:r,state:o}){if(e<=0)return;let n=Ao(r.sources);n!=null&&(Wo({params:r,pulled:n,state:o}),sr({count:e-1,params:r,state:o}))}function Ao(e){return e.reduce((r,o)=>{if(r!=null)return r;let n=o.next();return n==null?null:{job:n,source:o}},null)}function Wo({params:e,pulled:r,state:o}){let{job:n,source:t}=r,a=new AbortController;o.active.set(n.id,{controller:a,job:n,source:t}),e.execute({job:n,priority:t.priority,signal:a.signal}).then(()=>{tr({job:n,outcome:nr(a.signal,null),params:e,source:t,state:o})}).catch(s=>{tr({job:n,outcome:nr(a.signal,{error:s}),params:e,source:t,state:o})})}function nr(e,r){return e.aborted?{kind:"aborted"}:r==null?{kind:"completed"}:{error:r.error,kind:"error"}}function tr({job:e,outcome:r,params:o,source:n,state:t}){t.active.delete(e.id),n.onResult(e,r),I(t,o)}function j(e){return{priority:e,next:()=>null,onResult:()=>{}}}var Do=12;function cr({config:e,executorIsLocal:r,pool:o}){return Ho({appUrl:e.appUrl,cwd:e.cwd,executorIsLocal:r,executeTrail:async(n,t)=>(await o).exploreTrail(n,t)})}function Ho({appUrl:e,cwd:r,executeTrail:o,executorIsLocal:n}){let t={concurrency:2,enabled:!1,maxTrailLength:Do},a={notify:()=>{}},s={report:d=>{}},i={report:()=>{}},c={fetch:d=>Promise.resolve(new Set)},u=_o({appUrl:e,cwd:r,executeTrail:o,maxTrailLength:()=>t.maxTrailLength,notifyWork:()=>{a.notify()},reportProgress:d=>{s.report(d)},reportUnhealthy:()=>{i.report()},scopedTestRefs:d=>c.fetch(d)}),p=ir({now:Date.now,probe:qo,setTimer:Mo,sources:[j("p0"),j("p1"),u],execute:({job:d,priority:g,signal:f})=>E({headed:!1,workClass:Uo(g),task:()=>d.run(f)}),exploreConcurrency:()=>t.concurrency,exploreEnabled:()=>t.enabled&&n()});return O(()=>{p.notifyQueueChange()}),a.notify=()=>{p.notifyQueueChange()},{notifyExecutorChanged:()=>{p.notifyQueueChange()},progress:()=>u.status(),setConcurrency:d=>{n()&&d!==t.concurrency&&l.info({workers:d},"explore local worker count changed"),t.concurrency=d,p.notifyQueueChange()},setEnabled:d=>{t.enabled=d,p.notifyQueueChange()},setMaxTrailLength:d=>{t.maxTrailLength=d},setReportProgress:d=>{s.report=d},setReportUnhealthy:d=>{i.report=d},setScopedTestRefs:d=>{c.fetch=d},status:()=>({explorer:t.enabled?"on":"off",exploring:p.explorationActive(),progress:u.status()}),stop:()=>{p.stop(),O(null),u.stop()}}}function _o({appUrl:e,cwd:r,executeTrail:o,maxTrailLength:n,notifyWork:t,reportProgress:a,reportUnhealthy:s,scopedTestRefs:i}){return rr({cwd:r,executeTrail:o,maxTrailLength:n,notifyWork:t,reportProgress:a,reportUnhealthy:s,scopedTestRefs:i,loadLockfile:async()=>{let{fingerprint:c,result:u}=await re(r);return u.match(p=>({fingerprint:c,lockfile:p}),()=>null)},probeApp:async()=>await ie(e)==null})}function qo(){let e=Ae();return{headedActive:e.headedActive,interactiveActive:e.active,interactiveQueued:e.queued,poolSize:e.poolSize}}function Mo(e,r){let o=setTimeout(e,r);return()=>{clearTimeout(o)}}function Uo(e){switch(e){case"p0":return"p0-ui";case"p1":return"p1-cli";case"p2":return"p2-cover";case"p3":return"p3-explore"}}import{graphql as pr}from"gql.tada";import{execFileSync as $o,spawn as Oo}from"child_process";import{existsSync as dr}from"fs";var Fo=2e3,No=["/opt/homebrew/bin/cloudflared","/usr/local/bin/cloudflared","/usr/bin/cloudflared"],A=class extends Error{};function ur({token:e}){let r=Bo(),o=!1,n,t,a=()=>{if(o)return;let i=Oo(r,["tunnel","--no-autoupdate","run"],{env:{...process.env,TUNNEL_TOKEN:e},stdio:"ignore"});n=i,i.on("error",c=>{l.warn({err:c},"cloudflared spawn failed"),s()}),i.on("exit",(c,u)=>{l.warn({code:c,signal:u},"cloudflared exited"),n=void 0,s()})},s=()=>{o||t!=null||(t=setTimeout(()=>{t=void 0,a()},Fo))};return a(),{stop:async()=>{o=!0,t!=null&&(clearTimeout(t),t=void 0);let i=n;i!=null&&(i.kill("SIGTERM"),await new Promise(c=>{let u=setTimeout(()=>{i.kill("SIGKILL"),c()},5e3);i.on("exit",()=>{clearTimeout(u),c()})}))}}}function Bo(){let e=No.find(r=>dr(r));if(e!=null)return e;try{let r=$o("/usr/bin/env",["which","cloudflared"],{encoding:"utf8"}).trim();if(r.length>0&&dr(r))return r}catch{throw new A}throw new A}var fr=pr(`
|
|
35
|
-
mutation ReleaseDevTunnel($devSessionId: String!) {
|
|
36
|
-
releaseDevTunnel(devSessionId: $devSessionId)
|
|
37
|
-
}
|
|
38
|
-
`),jo=pr(`
|
|
39
|
-
mutation ProvisionDevTunnel($devSessionId: String!, $localUrl: String!, $engineUrl: String) {
|
|
40
|
-
provisionDevTunnel(devSessionId: $devSessionId, localUrl: $localUrl, engineUrl: $engineUrl) {
|
|
41
|
-
__typename
|
|
42
|
-
... on DevTunnel {
|
|
43
|
-
hostname
|
|
44
|
-
tunnelId
|
|
45
|
-
tunnelToken
|
|
46
|
-
}
|
|
47
|
-
... on DevSessionEndedError {
|
|
48
|
-
message
|
|
49
|
-
}
|
|
50
|
-
... on TunnelNotConfiguredError {
|
|
51
|
-
message
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
`),W=class extends Error{failure;constructor(r){super(r.kind),this.failure=r}};async function mr({config:e,devSessionId:r}){let n=(await y({config:e,document:jo,variables:{devSessionId:r,engineUrl:e.engineUrl,localUrl:e.appUrl}})).provisionDevTunnel;if(n==null)throw new W({kind:"empty-response"});if(n.__typename!=="DevTunnel")throw new W({kind:"server-error",typename:n.__typename});let t=n.hostname,a=ur({token:n.tunnelToken});return l.info({hostname:t},"cloud-executor tunnel up"),{hostname:t,stop:()=>zo({config:e,devSessionId:r,sidecar:a})}}async function L({config:e,devSessionId:r}){await y({config:e,document:fr,variables:{devSessionId:r}})}async function zo({config:e,devSessionId:r,sidecar:o}){await o.stop(),await y({config:e,document:fr,variables:{devSessionId:r}}).catch(n=>{l.warn({err:n},"releaseDevTunnel on shutdown failed")})}function yr({config:e,onChanged:r}){let o={devSessionId:null,mode:"local",queue:Promise.resolve(),tunnel:void 0},n=async i=>{let c=await mr({config:e,devSessionId:i});o.tunnel=c,o.mode="cloud",l.info("executor switched to cloud"),r()},t=async()=>{let i=o.tunnel;o.tunnel=void 0,o.mode="local",i!=null&&await i.stop(),l.info("executor switched to local"),r()},a=async i=>{let c=o.devSessionId;if(!(c==null||i===o.mode)){if(i==="cloud"){await n(c);return}await t()}},s=async i=>{l.warn({err:i},"executor switch failed; staying local");let c=o.devSessionId;c!=null&&await L({config:e,devSessionId:c}).catch(()=>{})};return{connect:i=>{o.devSessionId=i},current:()=>o.mode,request:i=>{o.queue=o.queue.then(()=>a(i).catch(s))},stop:async()=>{await o.queue.catch(()=>{}),await a("local")}}}import{fork as Go}from"child_process";import Sr from"os";import{CancellationTokenSource as gr,ResponseError as vr}from"vscode-jsonrpc/node";function kr(e,r){return()=>{let o=Go(e,["run-worker"],{cwd:r,detached:!0,stdio:["ignore","inherit","inherit","ipc"]});return{connection:Ie(o),kill:()=>{Jo(o)},onExit:n=>{o.once("exit",n)}}}}function hr(e){let r={closed:!1,devSessionId:e.devSessionId,lockfileProvider:e.lockfileProvider,nextId:0,size:e.initialSize,spawn:e.spawn,waiters:[],workers:[]};return{close:async()=>{r.closed=!0,await Promise.all([...r.workers].map(o=>z(o,r)))},execute:(o,n)=>Ko(o,n,r),exploreTrail:(o,n)=>Xo(o,n,r),routeSpan:(o,n)=>{let t=r.workers.find(a=>a.runId===o);t?.worker.connection.sendNotification(Te,{runId:o,span:n})},setSize:o=>{en(o,r)}}}function Jo(e){let r=e.pid;if(r!=null)try{process.kill(-r,"SIGKILL")}catch{e.kill("SIGKILL")}}var Qo=1e4,wr=-32800;async function Ko(e,r,o){let n=await xr(o);if(n.runId=e.runId,!n.alive)return D(n,o),{outcome:{detail:"worker-exit",kind:"error"},serverNotified:!1};let t=new gr,a=()=>{t.cancel()};r.aborted&&t.cancel(),r.addEventListener("abort",a,{once:!0});try{let s=await n.worker.connection.sendRequest(Pe,e,t.token),i=xe.safeParse(s);return i.success?i.data:{outcome:{detail:"bad-outcome-frame",kind:"error"},serverNotified:!1}}catch(s){return Yo(s,n)}finally{r.removeEventListener("abort",a),t.dispose(),D(n,o)}}async function xr(e){let r=e.workers.find(o=>o.alive&&o.runId===void 0);if(r!=null)return r.runId="pending",r;if(e.workers.length<e.size){let o=Vo(e);return o.runId="pending",await o.ready,o}return new Promise(o=>{e.waiters.push(n=>{n.runId="pending",o(n)})})}function Vo(e){let r=e.spawn(),o={resolve:()=>{}},n={alive:!0,id:e.nextId,ready:new Promise(t=>{o.resolve=t,r.connection.onNotification(be,t)}),runId:void 0,worker:r};return e.nextId+=1,r.connection.onRequest(Re,()=>e.lockfileProvider()),r.onExit(()=>{n.alive=!1,e.workers=e.workers.filter(t=>t!==n),r.connection.dispose(),o.resolve()}),e.workers.push(n),n}function D(e,r){if(e.runId=void 0,!e.alive||r.closed)return;if(r.workers.length>r.size){z(e,r);return}let o=r.waiters.shift();o?.(e)}async function z(e,r){if(r.workers=r.workers.filter(t=>t!==e),!e.alive)return;let o=new Promise(t=>{e.worker.onExit(t)});await e.worker.connection.sendNotification(Ce).catch(()=>{});let n=setTimeout(()=>{e.worker.kill()},Qo);await o,clearTimeout(n)}function Yo(e,r){return e instanceof vr&&e.code===wr?{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 Xo(e,r,o){let n=await xr(o);if(n.runId="explore",!n.alive)return D(n,o),{kind:"error"};let t=new gr,a=()=>{t.cancel()};r.aborted&&t.cancel(),r.addEventListener("abort",a,{once:!0});try{let s=await n.worker.connection.sendRequest(Ee,{assign:e,devSessionId:o.devSessionId},t.token),i=de.safeParse(s);return i.success?i.data:{kind:"error"}}catch(s){return Zo(s)}finally{r.removeEventListener("abort",a),t.dispose(),D(n,o)}}function Zo(e){return e instanceof vr&&e.code===wr?{kind:"aborted"}:{kind:"error",reason:`transport:${e instanceof Error?e.message.slice(0,120):"unknown"}`}}function en(e,r){r.size=e,e>Sr.availableParallelism()&&l.warn({cores:Sr.availableParallelism(),size:e},"worker pool size exceeds available cores");let o=r.workers.filter(t=>t.alive&&t.runId===void 0),n=r.workers.length-e;o.slice(0,Math.max(0,n)).forEach(t=>{z(t,r)})}import H from"fs";import{graphql as b}from"gql.tada";import{print as _}from"graphql";var rn=b(`
|
|
56
|
-
query DaemonExploration($devSessionId: String!) {
|
|
57
|
-
exploration(devSessionId: $devSessionId) {
|
|
58
|
-
active
|
|
59
|
-
localWorkers
|
|
60
|
-
maxTrailLength
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
`),on=b(`
|
|
64
|
-
subscription WatchExplorationChanged($devSessionId: String!) {
|
|
65
|
-
explorationChanged(devSessionId: $devSessionId) {
|
|
66
|
-
exploration {
|
|
67
|
-
active
|
|
68
|
-
localWorkers
|
|
69
|
-
maxTrailLength
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
`);function br({config:e,devSessionId:r,machinery:o,sseClient:n}){return nn({config:e,devSessionId:r,machinery:o}),n.subscribe({query:_(on),variables:{devSessionId:r}},{complete:()=>{},error:t=>{l.error(t,"exploration subscription error")},next:t=>{Pr(o,t.data?.explorationChanged.exploration)}})}async function nn({config:e,devSessionId:r,machinery:o}){let n=await y({config:e,document:rn,variables:{devSessionId:r}});Pr(o,n.exploration)}function Pr(e,r){r!=null&&(e.setMaxTrailLength(r.maxTrailLength),e.setConcurrency(r.localWorkers),e.setEnabled(r.active))}function Rr({config:e,devSessionId:r,machinery:o}){o.setScopedTestRefs(n=>$e(e,r,n)),o.setReportProgress(n=>{Ue({attempts:n.attempts,config:e,devSessionId:r,findings:n.findings,trail:Me(n.result)}).catch(t=>{l.warn({error:t},"exploration progress report failed")})}),o.setReportUnhealthy(()=>{Oe(e,r).catch(n=>{l.warn({error:n},"exploration unhealthy report failed")})})}var tn=b(`
|
|
74
|
-
subscription HooksPausedWatch($projectId: String!) {
|
|
75
|
-
hooksPausedRequested(projectId: $projectId) {
|
|
76
|
-
paused
|
|
77
|
-
projectId
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
`),an=b(`
|
|
81
|
-
subscription WatchLocalConcurrencyChanged {
|
|
82
|
-
myMaxLocalConcurrentRunsChanged
|
|
83
|
-
}
|
|
84
|
-
`);function Er({pool:e,sseClient:r}){return r.subscribe({query:_(an)},{complete:()=>{},error:o=>{l.error(o,"localConcurrency subscription error")},next:o=>{let n=o.data?.myMaxLocalConcurrentRunsChanged;n!=null&&(T(n),e.setSize(n))}})}var ln=b(`
|
|
85
|
-
subscription WatchExecutorChangeRequested($devSessionId: String!) {
|
|
86
|
-
executorChangeRequested(devSessionId: $devSessionId) {
|
|
87
|
-
executor
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
`);async function Tr({config:e,devSessionId:r,sseClient:o,switcher:n}){return n.connect(r),await L({config:e,devSessionId:r}).catch(t=>{l.warn({err:t},"stale tunnel release at boot failed")}),sn({devSessionId:r,sseClient:o,switcher:n})}function sn({devSessionId:e,sseClient:r,switcher:o}){return r.subscribe({query:_(ln),variables:{devSessionId:e}},{complete:()=>{},error:n=>{l.error(n,"executor subscription error")},next:n=>{let t=n.data?.executorChangeRequested?.executor;t!=null&&o.request(t)}})}function Cr({cwd:e,projectId:r,sseClient:o}){return o.subscribe({query:_(tn),variables:{projectId:r}},{complete:()=>{},error:n=>{l.error(n,"hooksPaused subscription error")},next:n=>{let t=n.data?.hooksPausedRequested?.paused;t!=null&&G({cwd:e,paused:t})}})}function G({cwd:e,paused:r}){let o=me(e);if(r&&!H.existsSync(o)){H.writeFileSync(o,"");return}!r&&H.existsSync(o)&&H.unlinkSync(o)}var fn=6e4,Ir=500,mn=15e3,Ar=6e4,yn=3,Sn=J(`
|
|
91
|
-
mutation HeartbeatDevSessionWatch($id: String!) {
|
|
92
|
-
heartbeatDevSession(id: $id) {
|
|
93
|
-
__typename
|
|
94
|
-
... on DevSession {
|
|
95
|
-
id
|
|
96
|
-
}
|
|
97
|
-
... on DevSessionEndedError {
|
|
98
|
-
message
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
`),gn=J(`
|
|
103
|
-
query WatchLocalConcurrency {
|
|
104
|
-
currentUser {
|
|
105
|
-
id
|
|
106
|
-
maxLocalConcurrentRuns
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
`),vn=J(`
|
|
110
|
-
mutation EndDevSessionWatch($projectId: String!, $cwd: String!) {
|
|
111
|
-
endDevSession(projectId: $projectId, cwd: $cwd) {
|
|
112
|
-
__typename
|
|
113
|
-
... on DevSession {
|
|
114
|
-
id
|
|
115
|
-
}
|
|
116
|
-
... on NoActiveDevSessionError {
|
|
117
|
-
message
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
`);async function Ei(){_n();let e=Wn(process.cwd()),r=e.cwd,o=En(r),{executorSwitch:n,exploration:t,poolGate:a}=kn(e),s={handler:()=>{}},i=Cn(),c=Ge(),u=qe({config:e,cwd:r,executor:n.current,explorationStatus:t.status,ready:i.promise,onShutdownRequest:()=>{s.handler()},sseHealth:()=>c.snapshot()}),p=await In({cwd:r,ipc:u,releasePid:o}),d=await U(r);d.isErr()&&(process.stderr.write(`ripplo: ${$(d.error)}
|
|
122
|
-
`),process.exit(1));let g=d.value,f=await Wr(()=>De({config:e,cwd:r,lockfile:g}),{config:e,label:"initial sync"});He(x(g));let q=await Mn(e);G({cwd:r,paused:f.hooksPaused});let k=We(r);k!=null&&l.info("watching branch %s in %s",k,r);let m=dn({headers:{Authorization:`Bearer ${e.token}`},retry:Be,retryAttempts:1/0,url:`${e.ripploServerUrl}/graphql`}),S=Rn({cwd:r,devSessionId:f.devSessionId,initialConcurrency:q});a.provide(S);let h=await hn({cwd:r,pool:S}),P=bn({claim:u.claim,config:e,cwd:r,initialId:f.devSessionId,pool:S,sseClient:m,sseHealth:c}),Lr=await Tr({config:e,devSessionId:f.devSessionId,sseClient:m,switcher:n}),Dr=Cr({cwd:r,projectId:e.projectId,sseClient:m}),Hr=Er({pool:S,sseClient:m}),_r=br({config:e,devSessionId:f.devSessionId,machinery:t,sseClient:m});Rr({config:e,devSessionId:f.devSessionId,machinery:t});let qr=xn({config:e,session:P}),Mr=Hn();i.resolve(),wn(f.devSessionId);let Ur=async()=>{qr(),Mr(),t.stop(),p.close(),P.stop(),Lr(),Dr(),Hr(),_r(),await S.close(),await n.stop(),await h.stop().catch(()=>{}),await Promise.race([y({config:e,document:vn,variables:{cwd:e.cwd,projectId:e.projectId}}).catch(()=>{}),new Promise($r=>setTimeout($r,3e3))]),o()},w=()=>{Ur().finally(()=>process.exit(0))};s.handler=w,process.on("SIGINT",w),process.on("SIGTERM",w),process.on("SIGHUP",w),process.on("SIGBREAK",w),await new Promise(()=>{})}function kn(e){let r={handler:()=>{}},o=yr({config:e,onChanged:()=>{r.handler()}}),n=An(),t=cr({config:e,pool:n.pool,executorIsLocal:()=>o.current()==="local"});return r.handler=t.notifyExecutorChanged,{executorSwitch:o,exploration:t,poolGate:n}}function hn({cwd:e,pool:r}){return fe({localDir:cn.join(e,".ripplo",".local"),writePortFile:!0,onRrwebBatch:()=>{},onSpan:o=>{let n=o.attributes["ripplo.run"];n!=null&&r.routeSpan(n,o)}})}function wn(e){process.stdout.write(`${ke({devSessionId:e,version:Y()})}
|
|
123
|
-
`)}function xn({config:e,session:r}){let o=async()=>{try{let t=await y({config:e,document:Sn,variables:{id:r.getId()}});t.heartbeatDevSession?.__typename==="DevSessionEndedError"&&(l.warn("dev session ended server-side (%s); re-registering",t.heartbeatDevSession.message),await r.reregister())}catch(t){l.warn("heartbeat failed: %s",t instanceof Error?t.message:String(t))}},n=setInterval(()=>{o()},mn);return()=>{clearInterval(n)}}function bn({claim:e,config:r,cwd:o,initialId:n,pool:t,sseClient:a,sseHealth:s}){let i=n,c=null,u=0,p=0,d=m=>{k(m)},g=()=>{let m=je({claim:e,cwd:o,devSessionId:i,onSubscriptionDead:d,pool:t,sseClient:a,sseHealth:s}),S=ze({cwd:o,devSessionId:i,onSubscriptionDead:d,sseClient:a});return()=>{m(),S()}},f=g(),q=async m=>{let S=Date.now();u=S-p>Ar*2?1:u+1,p=S,u>=yn&&s.markUnhealthy(m),await Pn(Math.min(1e3*2**(u-1),Ar));let h=await U(o);if(h.isErr()){l.error("re-register: compile failed: %s",$(h.error));return}let P=await Wr(()=>Le({config:r,cwd:o,lockfile:h.value}),{config:r,label:"re-register sync"});f(),i=P.devSessionId,f=g(),l.info("re-registered dev session as %s",i)},k=m=>(c!=null||(c=q(m).finally(()=>{c=null})),c);return{getId:()=>i,reregister:()=>k("dev session ended server-side"),stop:()=>{f()}}}function Pn(e){return new Promise(r=>setTimeout(r,e))}function Rn({cwd:e,devSessionId:r,initialConcurrency:o}){return hr({devSessionId:r,initialSize:o,spawn:kr(Un(),e),lockfileProvider:async()=>{let n=await R(e);return n.isErr()?{unavailable:`daemon-load-failed:${n.error.kind}`}:{lockfileJson:X(Z,n.value)}}})}function En(e){try{return te({cwd:e,onCompromised:Tn})}catch(r){throw r instanceof ne&&(process.stderr.write(`${he({cwd:r.cwd,pid:r.pid})}
|
|
124
|
-
`),process.exit(1)),r}}function Tn(){l.error("daemon lock compromised; shutting down"),process.stderr.write(`${we()}
|
|
125
|
-
`),process.exit(1)}function Cn(){let e={handler:()=>{}};return{promise:new Promise(o=>{e.handler=o}),resolve:()=>{e.handler()}}}async function In({cwd:e,ipc:r,releasePid:o}){return(await Xe({cwd:e,onConnection:r.handleConnection})).match(t=>t,t=>{process.stderr.write(`${Se(t)}
|
|
126
|
-
`),o(),process.exit(1)})}function An(){let e={provide:()=>{}};return{pool:new Promise(o=>{e.provide=o}),provide:o=>{e.provide(o)}}}function Wn(e){return v(e).match(r=>r,r=>{process.stderr.write(`${oe(r)}
|
|
127
|
-
`),process.exit(1)})}function Wr(e,{config:r,label:o}){let n=r.ripploServerUrl.includes("localhost")||r.ripploServerUrl.includes("127.0.0.1");return un(async()=>{try{return await e()}catch(t){Ln({config:r,error:t});let a=t instanceof Error?t.message:String(t);throw Dn(a)?t:(l.error("%s failed: %s",o,a),new pn(a))}},{factor:2,maxTimeout:n?2e3:1e4,minTimeout:n?100:1e3,retries:1/0,onFailedAttempt:({attemptNumber:t,error:a})=>{l.warn("%s attempt %d failed \u2014 retrying: %s",o,t,a.message)}})}function Ln({config:e,error:r}){let o=Q(r);o==="UNAUTHENTICATED"&&(process.stderr.write(`ripplo: ${ve()}
|
|
128
|
-
`),process.exit(1)),o==="FORBIDDEN"&&(process.stderr.write(`ripplo: ${ge({projectId:e.projectId,serverUrl:e.ripploServerUrl})}
|
|
129
|
-
`),process.exit(1))}function Dn(e){return e.includes("status 502")||e.includes("ECONNREFUSED")||e.includes("Failed to connect")||e.includes("fetch failed")}function Hn(){M({maxRuns:Ir});let e=setInterval(()=>{M({maxRuns:Ir})},fn);return()=>{clearInterval(e)}}function _n(){process.on("unhandledRejection",e=>{l.error({err:e},"unhandledRejection in watch; continuing")}),process.on("uncaughtException",e=>{l.error({err:e},"uncaughtException in watch; continuing")})}var qn=4;async function Mn(e){try{let o=(await y({config:e,document:gn,variables:void 0})).currentUser?.maxLocalConcurrentRuns;if(o!=null)return T(o),o}catch(r){l.warn({err:r},"failed to fetch local concurrency setting; using default")}return qn}function Un(){let e=process.argv[1];if(e==null)throw new Error("cli entry unavailable");return e}export{Ei as runDaemon};
|
package/dist/status-52ZOYXAV.js
DELETED