werkmeister 0.89.2 → 0.89.3
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/{budget-P5JBRTPG.js → budget-TVWUOULR.js} +2 -2
- package/dist/{cache-DUYHRESP.js → cache-BFQZZEI4.js} +2 -2
- package/dist/{chunk-FS6YA3CG.js → chunk-2VHOLJPD.js} +2 -2
- package/dist/{chunk-NO4HS4QL.js → chunk-3CWFM32E.js} +6 -6
- package/dist/{chunk-LFNRVTYS.js → chunk-3I35353B.js} +2 -2
- package/dist/{chunk-OJKXMZOD.js → chunk-3UNRQ3J6.js} +2 -2
- package/dist/{chunk-WH2N7OIO.js → chunk-44YMNG7G.js} +2 -2
- package/dist/{chunk-ELLCJ25G.js → chunk-4532BYHL.js} +2 -2
- package/dist/{chunk-DRI4OHNA.js → chunk-4EUL55H7.js} +3 -3
- package/dist/{chunk-CQY3GTFJ.js → chunk-4UJXSHDG.js} +2 -2
- package/dist/{chunk-6JER3JWG.js → chunk-5D5SOUZL.js} +2 -2
- package/dist/{chunk-OFNMJWQV.js → chunk-5UMRCX33.js} +2 -2
- package/dist/{chunk-PCV6NAAK.js → chunk-6POQA2GP.js} +2 -2
- package/dist/{chunk-I3NEQJZQ.js → chunk-72B433OL.js} +3 -3
- package/dist/{chunk-PM5GFZ7K.js → chunk-7QKUAX64.js} +2 -2
- package/dist/{chunk-ASWXLDJM.js → chunk-ACGR3QDJ.js} +2 -2
- package/dist/{chunk-L766XAX3.js → chunk-AOH4K6GP.js} +2 -2
- package/dist/{chunk-FG2XLGNM.js → chunk-AYN55JE7.js} +2 -2
- package/dist/{chunk-IGZMYHXD.js → chunk-B4XOYXRD.js} +2 -2
- package/dist/{chunk-7D73HLJW.js → chunk-BKCYHB6B.js} +2 -2
- package/dist/{chunk-65WN7UFH.js → chunk-CQZO7HXP.js} +2 -2
- package/dist/{chunk-4O5AVQ7C.js → chunk-CRT2753J.js} +2 -2
- package/dist/{chunk-ZH2U6Z6K.js → chunk-D7V374JV.js} +2 -2
- package/dist/{chunk-2DWIVGDO.js → chunk-DDBE5WOZ.js} +3 -3
- package/dist/{chunk-E5EYLHWE.js → chunk-DDUJVGYS.js} +2 -2
- package/dist/{chunk-FN2A7LG6.js → chunk-EVIEFMQX.js} +2 -2
- package/dist/{chunk-MNANLNCS.js → chunk-F4UT472P.js} +2 -2
- package/dist/{chunk-S36EPVSQ.js → chunk-GAZQNGJS.js} +3 -3
- package/dist/{chunk-OGQ4U6IV.js → chunk-I7VVNLCE.js} +2 -2
- package/dist/{chunk-3QSQOSVX.js → chunk-ILPSDL7H.js} +2 -2
- package/dist/{chunk-5LQO3VEP.js → chunk-IXHOYBP4.js} +2 -2
- package/dist/{chunk-MMI6XRQX.js → chunk-J7CF3XWN.js} +2 -2
- package/dist/{chunk-5VBOWGVH.js → chunk-JDIATMMP.js} +2 -2
- package/dist/{chunk-4TT37SCP.js → chunk-JIVZUJQP.js} +2 -2
- package/dist/{chunk-G3QEUH6Q.js → chunk-KFPZ5GPD.js} +2 -2
- package/dist/{chunk-S6CT7QYD.js → chunk-KQ634E6Q.js} +2 -2
- package/dist/{chunk-SWZ47KNM.js → chunk-L6R7TZTL.js} +2 -2
- package/dist/{chunk-SA7ZCS57.js → chunk-LEC6E7ZF.js} +2 -2
- package/dist/{chunk-5H6K4MI5.js → chunk-M4P6IKGJ.js} +2 -2
- package/dist/{chunk-4HOBUMZ4.js → chunk-OBKPCTPF.js} +2 -2
- package/dist/{chunk-F5YT2U6R.js → chunk-PWP7ETUE.js} +2 -2
- package/dist/{chunk-2M2FM27H.js → chunk-RN3RYZ5D.js} +2 -2
- package/dist/{chunk-C25JQ6TF.js → chunk-SGXZD6S5.js} +2 -2
- package/dist/{chunk-4YFK45ID.js → chunk-SRHOFDPA.js} +2 -2
- package/dist/{chunk-4D72V6SW.js → chunk-SVUSC267.js} +2 -2
- package/dist/{chunk-LBSVNANO.js → chunk-T6ZJOJVL.js} +2 -2
- package/dist/{chunk-XV4L6ZZW.js → chunk-TTEC5IKC.js} +2 -2
- package/dist/{chunk-VCXHU46R.js → chunk-UA3SKI5H.js} +2 -2
- package/dist/{chunk-YQWPQIAT.js → chunk-UJJVS5FL.js} +2 -2
- package/dist/{chunk-HF34U4ZF.js → chunk-UMORQN4O.js} +2 -2
- package/dist/{chunk-IHSZHN6O.js → chunk-UONVX5PW.js} +2 -2
- package/dist/chunk-UW2AJYBP.js +4 -0
- package/dist/{chunk-WSTEEZR2.js → chunk-V3PHDF4N.js} +2 -2
- package/dist/{chunk-TOO3IRV2.js → chunk-VBQC4FHW.js} +2 -2
- package/dist/{chunk-KAV6YZGV.js → chunk-VZDWLCF5.js} +2 -2
- package/dist/{chunk-PK7M5KJY.js → chunk-W7NSXOX4.js} +2 -2
- package/dist/{chunk-YKXP53WF.js → chunk-WG72IZ56.js} +2 -2
- package/dist/{chunk-PWCZJOYO.js → chunk-WKBD3SWM.js} +2 -2
- package/dist/{chunk-CONW5UWC.js → chunk-WRXTCIKP.js} +2 -2
- package/dist/{chunk-F37P66U5.js → chunk-WVEQ2NN3.js} +2 -2
- package/dist/{chunk-J7B5NNPO.js → chunk-X7NYDP5V.js} +2 -2
- package/dist/{chunk-LBOP4JKF.js → chunk-X7VWEYJA.js} +2 -2
- package/dist/{chunk-HEW6VJOC.js → chunk-XVK63SA3.js} +2 -2
- package/dist/{chunk-2VPTBX43.js → chunk-Y3IKLSB7.js} +2 -2
- package/dist/{chunk-6RPHJEST.js → chunk-Z3QV5VNL.js} +2 -2
- package/dist/chunk-Z6FWTYQO.js +110 -0
- package/dist/{chunk-N66DB4DW.js → chunk-ZFR7U6NA.js} +2 -2
- package/dist/{chunk-I6XF24V6.js → chunk-ZP3TD2WH.js} +2 -2
- package/dist/clean-HWPJXNBJ.js +8 -0
- package/dist/close_out-W5GW6WRP.js +8 -0
- package/dist/code-LXWWJ75V.js +4 -0
- package/dist/{config-6MNBCGS3.js → config-3WD3L4VQ.js} +2 -2
- package/dist/{connect-LQKEWBWV.js → connect-UGQ43FQI.js} +2 -2
- package/dist/{daemon-BZU6CK7N.js → daemon-UKVJBUY6.js} +2 -2
- package/dist/dashboard.js +1 -1
- package/dist/{detect-LSPWGEOM.js → detect-HERBE3KK.js} +2 -2
- package/dist/{down-LEOIK4OY.js → down-T26JZGJO.js} +3 -3
- package/dist/fixture-KD63REDT.js +14 -0
- package/dist/form-cli.js +1 -1
- package/dist/hooks-TMLWRDDT.js +4 -0
- package/dist/{hooks_gen-OVQAIWEX.js → hooks_gen-YZJNYT5T.js} +2 -2
- package/dist/infra-I66Y4JAU.js +4 -0
- package/dist/init_workspace-OEBVESNA.js +4 -0
- package/dist/{intercept-MNBDHQJ7.js → intercept-EGKOTY5V.js} +2 -2
- package/dist/{issue-GZXM2RR5.js → issue-ZIHGMYBD.js} +2 -2
- package/dist/lib/agent_state.js +1 -1
- package/dist/lib/gate.js +1 -1
- package/dist/lib/pr_guard.js +1 -1
- package/dist/list_workspaces-UZP57BMT.js +7 -0
- package/dist/logs-WQPQDDYL.js +6 -0
- package/dist/main.js +3 -3
- package/dist/mcp-proxy.js +1 -1
- package/dist/mcp.js +1 -1
- package/dist/{migrate-PQR3O2FX.js → migrate-HADI4VFM.js} +2 -2
- package/dist/notes-F7QSCDHC.js +4 -0
- package/dist/{open-MCQTSCWF.js → open-GD3Y3OKD.js} +2 -2
- package/dist/{optimize-BIQFV4YN.js → optimize-3K4OSU4R.js} +2 -2
- package/dist/pause-6JWCUIUL.js +4 -0
- package/dist/pr-E63HJVSU.js +5 -0
- package/dist/proxy_reload-MH3ND5OE.js +6 -0
- package/dist/{registry-UZ6VLJZP.js → registry-Y23LPM7E.js} +2 -2
- package/dist/remove-AR2FHAZW.js +7 -0
- package/dist/remove_workspace-ZD65PFNI.js +8 -0
- package/dist/restart-PHB3HHZV.js +8 -0
- package/dist/resume-VZHY74K6.js +8 -0
- package/dist/{safari-YX2O7P2R.js → safari-SK3NFJOX.js} +2 -2
- package/dist/{sandbox-Z7EKZKRV.js → sandbox-FZMTZBPJ.js} +2 -2
- package/dist/{services-XBD543ZZ.js → services-OEKEKIL7.js} +2 -2
- package/dist/{setup-HRAOD75R.js → setup-I5ZC3RCG.js} +2 -2
- package/dist/skills-GE3CPWRR.js +4 -0
- package/dist/{slots-WDBO6I6S.js → slots-VQUXT5AI.js} +2 -2
- package/dist/{standards-2FFBOKMD.js → standards-BJZOMUPG.js} +2 -2
- package/dist/start_args-WQDU4APM.js +4 -0
- package/dist/starting_prompt-K3O7XPOK.js +4 -0
- package/dist/stats-3B7NQEBU.js +4 -0
- package/dist/{status-MUZPU2VT.js → status-PZLYZGIU.js} +2 -2
- package/dist/{stop-QYB6W4GK.js → stop-YHH6JBE5.js} +2 -2
- package/dist/{telepresence-HDNCXLWZ.js → telepresence-XNZMY3BH.js} +2 -2
- package/dist/{test-S2VBYZLP.js → test-PPJP5AE6.js} +2 -2
- package/dist/{tokens-KJ5AERQN.js → tokens-L53QZBUS.js} +2 -2
- package/dist/{up-DRYRRB7Q.js → up-E6H4QYXL.js} +3 -3
- package/dist/{v4-423YAJGU.js → v4-EHEA67RQ.js} +2 -2
- package/dist/wait_load-2QM3P6YP.js +4 -0
- package/dist/werkmeister-workspaces.vsix +0 -0
- package/dist/{workspace-VASWJFFX.js → workspace-VK7OEICO.js} +2 -2
- package/package.json +3 -3
- package/dist/chunk-CQED4F7H.js +0 -110
- package/dist/chunk-CTJWIG5A.js +0 -4
- package/dist/clean-Q3TZOFUJ.js +0 -8
- package/dist/close_out-PTIPM3PK.js +0 -8
- package/dist/code-BUNUJ2W3.js +0 -4
- package/dist/fixture-O4H4JIDN.js +0 -14
- package/dist/hooks-CHQKWPBJ.js +0 -4
- package/dist/infra-WSY5I6LI.js +0 -4
- package/dist/init_workspace-XSBDBCPS.js +0 -4
- package/dist/list_workspaces-UEFLKGMV.js +0 -7
- package/dist/logs-F4HLXLKU.js +0 -6
- package/dist/notes-JSKGX7FI.js +0 -4
- package/dist/pause-AGHXL5N4.js +0 -4
- package/dist/pr-D4WAT3SU.js +0 -5
- package/dist/proxy_reload-EVVA6LYX.js +0 -6
- package/dist/remove-4GVSAUYM.js +0 -7
- package/dist/remove_workspace-3QKG4ABK.js +0 -8
- package/dist/restart-WIFG35JS.js +0 -8
- package/dist/resume-I5RZUXQH.js +0 -8
- package/dist/skills-XGBM3JUR.js +0 -4
- package/dist/start_args-2YSDLIRJ.js +0 -4
- package/dist/starting_prompt-XMTWFIBE.js +0 -4
- package/dist/stats-EGB4LTTY.js +0 -4
- package/dist/wait_load-4PH7CAO4.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
import{c as i,d as n,f as s}from"./chunk-
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
import{c as i,d as n,f as s}from"./chunk-XVK63SA3.js";import{a as o,f as t}from"./chunk-J7CF3XWN.js";t();import*as c from"node:fs";function a(){if(process.stdin.isTTY)return"";try{return c.readFileSync(0,"utf8")}catch{return""}}o(a,"readStdinTask");async function d(e){try{await s(e,void 0,{readStdinTask:a,build:e.build!==!1})}catch(r){throw r instanceof n&&(console.log(r.message),process.exit(1)),r instanceof i&&process.exit(1),r}}o(d,"run");export{a,d as b};
|
|
4
|
+
//# sourceMappingURL=chunk-3UNRQ3J6.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
import{U as x}from"./chunk-
|
|
3
|
+
import{U as x}from"./chunk-CRT2753J.js";import{f as y,g as b,h as w}from"./chunk-AOH4K6GP.js";import{b as S}from"./chunk-5D5SOUZL.js";import{a,f as h}from"./chunk-J7CF3XWN.js";h();import*as l from"node:fs";import*as m from"node:os";import*as d from"node:path";var M=10,j=2e3,A=5*6e4;function v(t){return d.join(S(t),"starts.json")}a(v,"startsFile");function D(t){try{let e=JSON.parse(l.readFileSync(v(t),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}a(D,"readStarts");function C(t,e,r,n=Date.now()){try{let s=v(t),o=[...D(t),{by:e,from:new Date(r).toISOString(),to:new Date(n).toISOString()}].slice(-M);l.mkdirSync(d.dirname(s),{recursive:!0}),l.writeFileSync(s,`${JSON.stringify(o,null,2)}
|
|
4
4
|
`)}catch{}}a(C,"recordStart");async function W(t,e,r){let n=Date.now();try{return await r()}finally{C(t,e,n)}}a(W,"withStartRecord");function O(t,e){for(let r=e.length-1;r>=0;r--){let n=e[r];if(t>=Date.parse(n.from)-j&&t<=Date.parse(n.to)+j)return n.by}return"person"}a(O,"startedBy");function L(t,e,r){return t.state==="restarting"?!0:!e||e.restartCount===0?!1:t.state!=="running"||r-e.startedAt<A}a(L,"isCrashLoop");function P(t){return t.state==="running"||t.state==="restarting"||t.state==="exited"&&t.exitCode!==0}a(P,"worthInspecting");function k(t,e,r,n){let s=new Map,o=new Map;for(let c of t){let i=c.labels["com.docker.compose.project"];if(!i)continue;let f=s.get(i)??{started:null,crashLoops:[]};s.set(i,f);let u=e.get(c.name);if(L(c,u,n)&&f.crashLoops.push({service:c.service,restarts:u?.restartCount??0,lastLog:null}),c.state!=="running"||!u||Number.isNaN(u.startedAt))continue;let g=o.get(i);(!g||u.startedAt<g.at)&&o.set(i,{at:u.startedAt,workingDir:c.labels["com.docker.compose.project.working_dir"]??""})}for(let[c,{at:i,workingDir:f}]of o){let u=s.get(c);u.started={at:new Date(i).toISOString(),by:f?O(i,r(f)):"person"}}for(let c of s.values())c.crashLoops.sort((i,f)=>i.service.localeCompare(f.service));return s}a(k,"healthOf");async function B(t,e=Date.now()){let r=t.filter(P),n=await b(r.map(o=>o.name)),s=k(r,n,D,e);return await Promise.all(r.filter(o=>L(o,n.get(o.name),e)).map(async o=>{let c=s.get(o.labels["com.docker.compose.project"])?.crashLoops.find(i=>i.service===o.service&&i.lastLog===null);c&&(c.lastLog=await w(o.name,n.get(o.name)?.tty??!1))})),s}a(B,"projectHealth");var p=a(t=>Math.round(t*10)/10,"round1");function _(t){let e={};for(let r of t){let n=r.labels["com.docker.compose.project"];if(!n)continue;let s=e[n]??={cpuPercent:0,memMib:0};s.cpuPercent+=r.cpuPercent,s.memMib+=r.memMib}for(let r of Object.values(e))r.cpuPercent=p(r.cpuPercent),r.memMib=Math.round(r.memMib);return e}a(_,"usageByProject");function N(t,e=m.loadavg(),r=m.availableParallelism()){let n=t.filter(s=>{let o=x(s.labels,"feature");return o&&o!=="infra"});return{load:[p(e[0]),p(e[1]),p(e[2])],cores:r,featureCpuPercent:p(n.reduce((s,o)=>s+o.cpuPercent,0))}}a(N,"hostSummary");function H(t,e){let[r,n,s]=t.map(o=>p(o).toFixed(1));return`host load ${r} / ${n} / ${s} (1, 5, 15 min) on ${e} cores`}a(H,"loadNote");async function J(t=2e4){let e=await y(AbortSignal.timeout(t));return{projects:_(e),host:N(e)}}a(J,"getWorkspaceResources");export{W as a,B as b,H as c,J as d};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-44YMNG7G.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
import{U as Y}from"./chunk-
|
|
3
|
+
import{U as Y}from"./chunk-CRT2753J.js";import{d as N,e as L}from"./chunk-AOH4K6GP.js";import{l as R,m as g}from"./chunk-IXHOYBP4.js";import{b as J}from"./chunk-OBKPCTPF.js";import{E as K,J as M,M as h,P as U,Y as B,Z as f,a as ne,j as l,k as y,l as A,m as p,t as W,x}from"./chunk-X7NYDP5V.js";import{a as n,e as oe,f as u}from"./chunk-J7CF3XWN.js";u();var q=oe(ne(),1);import*as $ from"node:fs";import*as S from"node:path";var se=/@sha256:[0-9a-f]{64}$/;function m(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}n(m,"isDict");function ie(e,r){let t=(e??x()).infra,o=m(t)?t.baseline:void 0;if(!m(o))return[];let i=r??h();return Object.entries(o).map(([s,a])=>{let d=`config.yaml infra.baseline.${s}`,H=i[s];if(!m(H))throw new Error(`${d}: no such service in services.yaml`);let b=m(a)?a.image:void 0;if(typeof b!="string"||!se.test(b))throw new Error(`${d}.image must be pinned as <image>@sha256:<digest>, got ${JSON.stringify(b)}. Resolve one with: docker pull <image>:<tag> && docker inspect --format='{{index .RepoDigests 0}}' <image>:<tag>`);let _=m(a)?a.environment??{}:{};if(!m(_)||Object.values(_).some(v=>m(v)||Array.isArray(v)))throw new Error(`${d}.environment must be a map of plain values`);return{service:s,image:b,port:Number(H.internal_port??3e3),environment:Object.fromEntries(Object.entries(_).map(([v,te])=>[v,String(te)]))}})}n(ie,"baselineSpecs");function I(){return S.join(f(),"compose","baseline.override.yml")}n(I,"baselineOverridePath");var ae=["# AUTO-GENERATED by `werkmeister infra connect` from ~/.werkmeister/config.yaml infra.baseline \u2014 do not edit.","# Merged over infra/compose/shared-infra.yml by every `docker compose` call the CLI makes."];function ce(e){let r=Object.fromEntries(e.map(t=>{let o=`baseline-${t.service}`;return[o,{image:t.image,container_name:`w9r-${o}`,restart:"unless-stopped",...Object.keys(t.environment).length>0?{environment:t.environment}:{},networks:{"werkmeister-shared":{aliases:[o]}}}]}));return[...ae,(0,q.stringify)({services:r},{aliasDuplicateObjects:!1})].join(`
|
|
4
4
|
`)}n(ce,"renderBaselineOverride");function Fe(e=!1){let r=ie(),t=I();$.mkdirSync(S.dirname(t),{recursive:!0}),$.writeFileSync(t,ce(r)),e||l(`Generated ${t}`)}n(Fe,"generateBaselineOverride");u();import*as w from"node:fs";import*as k from"node:path";function E(e,r){return K(e??h(),r??U())}n(E,"forwardSpecs");function fe(e,r){return E(e,r).map(t=>`${t.name}|${t.listen}|${t.remote}|${t.ns}|${t.prefix}|${t.health}`)}n(fe,"buildForwardRows");function z(){return k.join(f(),"k8s-port-forward","forwards")}n(z,"forwardsFilePath");function P(){return k.join(f(),"compose","k8s-forwards.override.yml")}n(P,"overrideFilePath");function ue(e){e=e??z(),w.mkdirSync(k.dirname(e),{recursive:!0});let r=["# AUTO-GENERATED by `werkmeister infra connect` from ~/.werkmeister/services.yaml \u2014 do not edit.","# Format: name|listen_port|remote_port|namespace|pod_prefix|health_path",...fe(),""].join(`
|
|
5
5
|
`);return w.writeFileSync(e,r),e}n(ue,"generateForwardsFile");var V=["# AUTO-GENERATED by `werkmeister infra connect` from ~/.werkmeister/services.yaml \u2014 do not edit.","# Merged over infra/compose/shared-infra.yml by every `docker compose` call the CLI makes."];function le(e){return e.length===0?[...V,"services:"," k8s-forwards: {}",""].join(`
|
|
6
6
|
`):[...V,"services:"," k8s-forwards:"," ports:",...e.map(r=>` - "${r.listen}:${r.listen}" # ${r.name}`)," networks:"," werkmeister-shared:"," aliases:",...e.map(r=>` - k8s-${r.name}`),""].join(`
|
|
7
7
|
`)}n(le,"renderK8sForwardsOverride");function X(e=!1){ue();let r=P();w.mkdirSync(k.dirname(r),{recursive:!0}),w.writeFileSync(r,le(E())),e||l(`Generated ${z()} and ${r}`)}n(X,"generateK8sForwards");u();import*as D from"node:fs";import*as F from"node:path";var j="w9r-infra",He="sandbox-infra",C="w9r-k8s-forwards";function me(){let r=x().infra?.profiles;return Array.isArray(r)?r.filter(t=>typeof t=="string"&&t!==""):[]}n(me,"infraProfiles");function Q(){let e=P();D.existsSync(e)||X(!0);let r=I();return{argv:["docker","compose","-f",F.join(B(),"compose","shared-infra.yml"),"-f",e,...D.existsSync(r)?["-f",r]:[],"-p",j,...me().flatMap(t=>["--profile",t])],env:{...process.env,WERKMEISTER_STATE_DIR:f()},cwd:F.dirname(f())}}n(Q,"composeInvocation");u();import*as c from"node:fs";import*as Z from"node:http";import*as G from"node:net";import*as O from"node:path";import{setTimeout as de}from"node:timers/promises";async function pe(){return{"k8s-forwards":(await N(j,"k8s-forwards",{all:!1})??[]).some(r=>r.health==="healthy"||r.state==="running"&&!r.health)}}n(pe,"checkPortForwardHealth");function he(e,r){if(!e)return!0;let t=new Map;for(let o of e){let i=Y(o.labels,"feature");if(!i)continue;let s=t.get(i)??{local:[],running:!1};s.local.push(o.service),s.running||=o.state==="running",t.set(i,s)}return[...t.values()].some(o=>o.running&&M(o.local,r))}n(he,"clusterNeeded");async function we(e){let r;try{r=h()}catch{return!0}return he(e===void 0?await N():e,r)}n(we,"forwarderNeeded");function ke(e){return c.existsSync(e)&&c.statSync(e).isDirectory()}n(ke,"isDir");function ye(e){return/server:\s*https:\/\/(127\.0\.0\.1|localhost)\b/.test(e)?e.replace(/(server:\s*https:\/\/)(127\.0\.0\.1|localhost)\b/g,"$1host.docker.internal").replace(/^(\s*)certificate-authority-data:.*$/gm,"$1insecure-skip-tls-verify: true"):e}n(ye,"shimLocalApiServer");function ge(){let e=O.join(f(),"k8s-port-forward","kubeconfig");ke(e)&&c.rmSync(e,{recursive:!0,force:!0}),c.mkdirSync(O.dirname(e),{recursive:!0}),l("Refreshing k8s-port-forward/kubeconfig from current context...");try{let r=g(["kubectl","config","view","--raw","--minify","--flatten"],{capture:!0,timeout:30});if(r.status===0){c.writeFileSync(e,ye(r.stdout));let t=g(["kubectl","--kubeconfig",e,"config","current-context"],{capture:!0,timeout:15}),o=t.status===0?t.stdout.trim():"?";y(`Kubeconfig pinned to context: ${o}`)}else p(`kubectl config view failed: ${r.stderr.trim()}`)}catch(r){if(r instanceof R&&(r.code==="ENOENT"||r.code==="ETIMEDOUT"))p(`Could not generate kubeconfig: ${r.message}`);else throw r}return c.existsSync(e)&&c.statSync(e).isFile()}n(ge,"refreshKubeconfig");function Ee(){try{return g(["kubectl","--request-timeout=3s","get","--raw","/readyz"],{capture:!0,timeout:20}).status===0}catch(e){if(e instanceof R)return!1;throw e}}n(Ee,"clusterReachable");async function er(){if(W())return l("k8s port-forwards skipped (WERKMEISTER_FIXTURE)"),"healthy";if((await pe())["k8s-forwards"]??!1)return y("k8s port-forwards container is healthy"),"healthy";if(A("k8s port-forwards container is unhealthy \u2014 restarting..."),!ge())return p("Not restarting k8s-forwards without a kubeconfig file to mount"),"failed";if(!Ee())return A("No reachable k8s cluster \u2014 skipping port-forwards; services not run locally are unavailable"),"failed";let{argv:r,env:t,cwd:o}=Q();try{let i=g([...r,"up","-d","--force-recreate","k8s-forwards"],{capture:!0,timeout:60,env:t,cwd:o});return i.status!==0?(p(`Failed to restart k8s-forwards: ${i.stderr.trim()}`),"failed"):(y("k8s port-forwards container restarted"),"restarted")}catch(i){if(i instanceof R)return p(`Failed to restart k8s-forwards: ${i.message}`),"failed";throw i}}n(er,"ensurePortForwardsHealthy");async function rr(e=3e4,r=500){let t=E();if(!t.length)return;l("Waiting for port-forwards to reconnect...");let o=Date.now()+e;for(;;){if(t=(await Promise.all(t.map(async s=>({spec:s,ok:(await re(s.listen,s.health)).ok})))).filter(s=>!s.ok).map(s=>s.spec),!t.length){y("k8s port-forwards are carrying traffic");return}if(Date.now()>=o)throw new J(`k8s port-forwards did not come back within ${Math.round(e/1e3)}s: ${t.map(s=>`${s.name}:${s.listen}`).join(", ")}
|
|
8
8
|
Check \`docker logs ${C}\` and your kubeconfig.`,"FORWARDS_NEVER_READY");await de(r)}}n(rr,"waitForForwards");function be(e,r,t=3500){return new Promise(o=>{let i=Z.get({host:"127.0.0.1",port:e,path:r,timeout:t},s=>{s.resume();let a=s.statusCode??0;o({ok:a<500,detail:`HTTP ${a}`})});i.on("timeout",()=>{i.destroy(),o({ok:!1,detail:"timeout"})}),i.on("error",s=>o({ok:!1,detail:s.code??s.message}))})}n(be,"checkHttpHealth");var ee={redis:{send:Buffer.from(`PING\r
|
|
9
9
|
`),ok:n(e=>e.toString("latin1").startsWith("+PONG"),"ok")},postgres:{send:Buffer.from([0,0,0,8,4,210,22,47]),ok:n(e=>e[0]===83||e[0]===78,"ok")}};function ve(e,r,t=3500){return new Promise(o=>{let i=ee[r],s=G.connect({host:"127.0.0.1",port:e,timeout:t});s.on("connect",()=>s.write(i.send)),s.once("data",a=>{s.destroy();let d=i.ok(a);o({ok:d,detail:d?`${r} ok`:`${r} bad reply`})}),s.on("timeout",()=>{s.destroy(),o({ok:!1,detail:"timeout (connected, no reply)"})}),s.on("error",a=>o({ok:!1,detail:a.code??a.message})),s.on("close",()=>o({ok:!1,detail:"closed without reply"}))})}n(ve,"checkWireHealth");function xe(e,r=2500){return new Promise(t=>{let o=G.connect({host:"127.0.0.1",port:e,timeout:r});o.on("connect",()=>{o.destroy(),t({ok:!0,detail:"tcp open"})}),o.on("timeout",()=>{o.destroy(),t({ok:!1,detail:"timeout"})}),o.on("error",i=>t({ok:!1,detail:i.code??i.message}))})}n(xe,"checkTcpHealth");function re(e,r){return r.startsWith("/")?be(e,r):ee[r]?ve(e,r):r?Promise.resolve({ok:!1,detail:`unknown probe "${r}"`}):xe(e)}n(re,"checkForwardHealth");async function Re(e,r){return(await re(e,r)).ok?"alive":"dead"}n(Re,"classifyForward");async function tr(){let e=await L(C),r;try{r=E()}catch{return[]}let t=e?null:await we()?"container_down":"stopped",o=[];for(let i of r)o.push({name:i.name,listen_port:i.listen,remote_port:i.remote,health_path:i.health,status:t??await Re(i.listen,i.health)});return o}n(tr,"getPerServiceStatus");export{ie as a,Fe as b,X as c,j as d,He as e,C as f,me as g,Q as h,pe as i,we as j,ge as k,er as l,rr as m,re as n,tr as o};
|
|
10
|
-
//# sourceMappingURL=chunk-
|
|
10
|
+
//# sourceMappingURL=chunk-4532BYHL.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
import{n as C,r as M}from"./chunk-
|
|
3
|
+
import{n as C,r as M}from"./chunk-Z3QV5VNL.js";import{a as j,h as B,j as b,m as x,n as S}from"./chunk-X7NYDP5V.js";import{b as I}from"./chunk-5D5SOUZL.js";import{a as i,e as L,f as F}from"./chunk-J7CF3XWN.js";F();var _=L(j(),1);import{spawn as W}from"node:child_process";import*as k from"node:crypto";import*as p from"node:fs";import*as v from"node:net";import*as R from"node:os";import*as P from"node:path";function N(){return`.${M().local_domain.replace(/^\.+/,"")}`}i(N,"cookieDomain");var y={chrome:{label:"Google Chrome",engine:"chromium",macPath:"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"},chromium:{label:"Chromium",engine:"chromium",macPath:"/Applications/Chromium.app/Contents/MacOS/Chromium"},brave:{label:"Brave Browser",engine:"chromium",macPath:"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"},edge:{label:"Microsoft Edge",engine:"chromium",macPath:"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"},firefox:{label:"Firefox",engine:"gecko",macPath:"/Applications/Firefox.app/Contents/MacOS/firefox"},safari:{label:"Safari",engine:"webkit",macPath:"/Applications/Safari.app/Contents/MacOS/Safari"},duckduckgo:{label:"DuckDuckGo",engine:"webkit",macPath:"/Applications/DuckDuckGo.app/Contents/MacOS/DuckDuckGo"}},A="chrome",oe={key:"browser",label:"Browser for `werkmeister feature open`",help:"Chromium browsers (chrome, chromium, brave, edge) work via CDP; safari works via Apple's bundled safaridriver. Firefox/DuckDuckGo are listed for visibility but aren't wired up yet.",acceptEmpty:!1,pattern:`(${Object.keys(y).join("|")})`,placeholder:A,choicesFn:i(()=>Object.keys(y),"choicesFn")};function H(){if(process.env.CHROME_BIN)return process.env.CHROME_BIN;let s=C().overrides??{};if(s.browser_path)return s.browser_path;let t=s.browser||A,e=y[t];if(!e)return x(`Unknown overrides.browser '${t}' -- choices: ${Object.keys(y).join(", ")}`),null;if(e.engine!=="chromium"){let o=e.engine==="webkit"?"WebKit":"Gecko",r=Object.keys(y).filter(n=>y[n].engine==="chromium");return x(`${e.label} uses ${o}, not Chromium -- \`werkmeister feature open\` only speaks the Chrome DevTools Protocol, which just Chromium-based browsers support. Run \`werkmeister machine setup\` and pick one of: ${r.join(", ")}.`),null}return e.macPath}i(H,"resolveBrowserBinary");function $(s){return new Promise(t=>setTimeout(t,s))}i($,"sleep");var O=class s{static{i(this,"WS")}host;port;sock;fatalError=null;rxbuf=Buffer.alloc(0);nextId=0;pending=[];handler=null;set onMessage(t){if(this.handler=t,t)for(;this.pending.length;)t(this.pending.shift())}constructor(t,e,o){this.sock=t,this.host=e,this.port=o}static connect(t){let e=new URL(t),o=e.hostname,r=e.port?parseInt(e.port,10):80,n=e.pathname||"/";return e.search&&(n+=e.search),new Promise((a,l)=>{let c=v.createConnection({host:o,port:r}),u=new s(c,o,r),d=!1,f=Buffer.alloc(0);c.setTimeout(1e4,()=>c.destroy(new Error("websocket handshake timed out"))),c.on("error",h=>{d?u.fatalError||(u.fatalError=h):l(h)}),c.on("close",()=>{d?u.fatalError||(u.fatalError=new Error("websocket closed by peer")):l(new Error("websocket handshake failed (closed)"))});let m=i(h=>{f=Buffer.concat([f,h]);let w=f.indexOf(`\r
|
|
4
4
|
\r
|
|
5
5
|
`);if(w===-1)return;if(!f.subarray(0,f.indexOf(`\r
|
|
6
6
|
`)).toString("latin1").includes(" 101 ")){c.destroy(),l(new Error(`websocket handshake failed: ${f.subarray(0,80).toString("latin1")}`));return}u.rxbuf=f.subarray(w+4),c.setTimeout(0),c.off("data",m),c.on("data",g=>{u.rxbuf=Buffer.concat([u.rxbuf,g]),u.pump()}),d=!0,a(u),u.pump()},"onHandshakeData");c.on("data",m),c.on("connect",()=>{let h=k.randomBytes(16).toString("base64"),w=`GET ${n} HTTP/1.1\r
|
|
@@ -37,9 +37,9 @@ Sec-WebSocket-Version: 13\r
|
|
|
37
37
|
tick();
|
|
38
38
|
setInterval(tick,1000); // self-heal across SPA route changes
|
|
39
39
|
})();
|
|
40
|
-
`}i(J,"badgeScript");function K(){return new Promise((s,t)=>{let e=v.createServer();e.once("error",t),e.listen(0,"127.0.0.1",()=>{let o=e.address().port;e.close(()=>s(o))})})}i(K,"findFreePort");async function q(s,t=15){let e=Date.now()+t*1e3,o=null;for(;Date.now()<e;)try{return(await(await fetch(`http://127.0.0.1:${s}/json/version`,{signal:AbortSignal.timeout(2e3)})).json()).webSocketDebuggerUrl}catch(r){o=r,await $(250)}throw new Error(`Chrome debug endpoint never came up on :${s} (${o})`)}i(q,"waitForBrowserWs");var T=class{static{i(this,"FeatureSession")}ws;feature;url;script;procExited;shouldStop;configured=new Set;cookieSet=!1;navigated=!1;constructor(t,e,o,r,n,a){this.ws=t,this.feature=e,this.url=r,this.script=J(e,o),this.procExited=n,this.shouldStop=a}configureTarget(t){this.cookieSet||(this.ws.send("Network.enable",null,t),this.ws.send("Network.setCookie",{name:"X-Feature",value:this.feature,domain:N(),path:"/",secure:!0,sameSite:"Lax"},t),this.cookieSet=!0),this.ws.send("Page.enable",null,t),this.ws.send("Page.addScriptToEvaluateOnNewDocument",{source:this.script},t),this.ws.send("Runtime.evaluate",{expression:this.script},t),this.navigated||(this.ws.send("Page.navigate",{url:this.url},t),this.navigated=!0)}onEvent(t){if(t?.method!=="Target.attachedToTarget")return;let e=t.params,o=e.sessionId;if(e.targetInfo?.type==="page"&&!this.configured.has(o)){this.configured.add(o);try{this.configureTarget(o)}catch(r){x(`could not configure tab: ${r instanceof Error?r.message:r}`)}}}async start(t=15e3){this.ws.send("Target.setAutoAttach",{autoAttach:!0,waitForDebuggerOnStart:!1,flatten:!0}),this.ws.onMessage=o=>this.onEvent(o);let e=Date.now()+t;for(;!this.navigated;){if(this.ws.fatalError)throw this.ws.fatalError;if(this.procExited()||Date.now()>e)return!1;await $(50)}return!0}async poll(){for(;!this.procExited()&&!this.shouldStop();){if(this.ws.fatalError)throw this.ws.fatalError;await $(1e3)}}};function X(){if(process.env.CHROME_BIN)return!1;let s=C().overrides??{};return s.browser_path?!1:(s.browser||A)==="safari"}i(X,"wantsSafari");async function ne(s,t,e={}){if(X()){let{launchSafariWindow:o}=await import("./safari-
|
|
40
|
+
`}i(J,"badgeScript");function K(){return new Promise((s,t)=>{let e=v.createServer();e.once("error",t),e.listen(0,"127.0.0.1",()=>{let o=e.address().port;e.close(()=>s(o))})})}i(K,"findFreePort");async function q(s,t=15){let e=Date.now()+t*1e3,o=null;for(;Date.now()<e;)try{return(await(await fetch(`http://127.0.0.1:${s}/json/version`,{signal:AbortSignal.timeout(2e3)})).json()).webSocketDebuggerUrl}catch(r){o=r,await $(250)}throw new Error(`Chrome debug endpoint never came up on :${s} (${o})`)}i(q,"waitForBrowserWs");var T=class{static{i(this,"FeatureSession")}ws;feature;url;script;procExited;shouldStop;configured=new Set;cookieSet=!1;navigated=!1;constructor(t,e,o,r,n,a){this.ws=t,this.feature=e,this.url=r,this.script=J(e,o),this.procExited=n,this.shouldStop=a}configureTarget(t){this.cookieSet||(this.ws.send("Network.enable",null,t),this.ws.send("Network.setCookie",{name:"X-Feature",value:this.feature,domain:N(),path:"/",secure:!0,sameSite:"Lax"},t),this.cookieSet=!0),this.ws.send("Page.enable",null,t),this.ws.send("Page.addScriptToEvaluateOnNewDocument",{source:this.script},t),this.ws.send("Runtime.evaluate",{expression:this.script},t),this.navigated||(this.ws.send("Page.navigate",{url:this.url},t),this.navigated=!0)}onEvent(t){if(t?.method!=="Target.attachedToTarget")return;let e=t.params,o=e.sessionId;if(e.targetInfo?.type==="page"&&!this.configured.has(o)){this.configured.add(o);try{this.configureTarget(o)}catch(r){x(`could not configure tab: ${r instanceof Error?r.message:r}`)}}}async start(t=15e3){this.ws.send("Target.setAutoAttach",{autoAttach:!0,waitForDebuggerOnStart:!1,flatten:!0}),this.ws.onMessage=o=>this.onEvent(o);let e=Date.now()+t;for(;!this.navigated;){if(this.ws.fatalError)throw this.ws.fatalError;if(this.procExited()||Date.now()>e)return!1;await $(50)}return!0}async poll(){for(;!this.procExited()&&!this.shouldStop();){if(this.ws.fatalError)throw this.ws.fatalError;await $(1e3)}}};function X(){if(process.env.CHROME_BIN)return!1;let s=C().overrides??{};return s.browser_path?!1:(s.browser||A)==="safari"}i(X,"wantsSafari");async function ne(s,t,e={}){if(X()){let{launchSafariWindow:o}=await import("./safari-SK3NFJOX.js");return o(s,t,e)}return V(s,t,e)}i(ne,"launchFeatureWindow");async function V(s,t,e={}){let o=e.size??"1440,900",r=e.position??null,n=H();if(!n)return null;if(!p.existsSync(n))return x(`Browser not found at ${n} (set CHROME_BIN, or overrides.browser_path in config.yaml, to override -- or run \`werkmeister machine setup\` to pick an installed browser)`),null;let a=z(s),l=await K(),c=p.mkdtempSync(P.join(R.tmpdir(),`chrome-${s}-`));if(!r){let g=Number(G(s)%8n)*40;r=`${60+g},${60+g}`}let u=[`--user-data-dir=${c}`,`--remote-debugging-port=${l}`,"--no-first-run","--no-default-browser-check","--new-window",`--window-size=${o}`,`--window-position=${r}`,"about:blank"],d=W(n,u,{stdio:"ignore",detached:!0});d.unref();let f=!1;d.on("exit",()=>{f=!0});let m=null;async function h(){m?.close();try{d.kill()}catch{}if(!f&&!await new Promise(D=>{let U=setTimeout(()=>D(!1),5e3);d.once("exit",()=>{clearTimeout(U),D(!0)})}))try{d.kill("SIGKILL")}catch{}p.rmSync(c,{recursive:!0,force:!0})}i(h,"cleanup");let w,E=!1;try{if(m=await O.connect(await q(l)),w=new T(m,s,a,t,()=>f,()=>E),!await w.start())return x("The browser window never came up \u2014 nothing was tagged."),await h(),null}catch(g){throw await h(),g}return S(`
|
|
41
41
|
`),b(`Feature : ${s}`),b(`Cookie : X-Feature=${s} (domain ${N()})`),b(`Badge : ${a}`),b(`URL : ${t}`),b(`Profile : ${c} (throwaway)`),S(`
|
|
42
42
|
Window is tagged ${B.BOLD}[${s}]${B.RESET} in the title bar + corner badge.
|
|
43
43
|
`),{stop:i(()=>{E=!0},"stop"),async supervise(){try{return await w.poll(),E?(S(`
|
|
44
44
|
`),b("Closing feature window\u2026"),130):0}finally{await h()}}}}i(V,"launchChromiumWindow");function se(s){for(let t of["workspace.yml","workspace.yaml"]){let e=P.join(I(s),t);if(!(p.existsSync(e)&&p.statSync(e).isFile()))continue;let o;try{o=(0,_.parse)(p.readFileSync(e,"utf8"))}catch{return{}}return o&&typeof o=="object"&&!Array.isArray(o)?o:{}}return{}}i(se,"readWorkspaceYaml");export{N as a,y as b,A as c,oe as d,$ as e,z as f,J as g,K as h,ne as i,se as j};
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-4EUL55H7.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
import{L as c}from"./chunk-
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
import{L as c}from"./chunk-DDBE5WOZ.js";import{a as l,f}from"./chunk-J7CF3XWN.js";f();import*as s from"node:fs";import*as e from"node:path";function p(o){let n=e.resolve(o);for(;;){let r=e.join(n,".env"),t=!1;try{t=s.statSync(r).isFile()}catch{t=!1}if(t)return r;let i=e.dirname(n);if(i===n)return null;n=i}}l(p,"findDotenv");function v(o){let n=p(o);if(!n)return{};let r={};for(let t of s.readFileSync(n,"utf8").split(/\r?\n/)){if(t=t.trim(),!t||t.startsWith("#")||!t.includes("="))continue;let i=t.indexOf("="),a=t.slice(0,i),u=t.slice(i+1);r[a.trim()]=c(u.trim())}return r}l(v,"loadDotenv");export{p as a,v as b};
|
|
4
|
+
//# sourceMappingURL=chunk-4UJXSHDG.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
import{a as t,f as r}from"./chunk-
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
import{a as t,f as r}from"./chunk-J7CF3XWN.js";r();import*as o from"node:path";var i=".werkmeister";function p(e){return o.join(e,i)}t(p,"dotDir");export{i as a,p as b};
|
|
4
|
+
//# sourceMappingURL=chunk-5D5SOUZL.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
import{a as p,b as a}from"./chunk-
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
import{a as p,b as a}from"./chunk-5D5SOUZL.js";import{a as o,f as c}from"./chunk-J7CF3XWN.js";c();import*as i from"node:fs";import*as s from"node:path";function u(t){let e=s.resolve(t);for(;;){if(i.existsSync(s.join(a(e),"workspace.yml")))return e;let r=s.dirname(e);if(r===e)return null;e=r}}o(u,"findRecordRoot");function d(t){try{let e=i.readdirSync(s.join(t,"stages")).filter(n=>/^\d+_/.test(n)).sort(),r=e.find(n=>/^\d+_propose$/.test(n))??e.find(n=>/^\d+_ship$/.test(n))??e.at(-1);return r?`stages/${r}/output/`:"the last stage's output/"}catch{return`${s.basename(a(t))}/notes/`}}o(d,"prFileDirName");var f=/(?<!<)<<(?!<)-?\s*(['"]?)(\w+)\1([^\n]*)(?:\n(?:[\s\S]*?\n)?\t*\2(?=\n|$)|[\s\S]*$)/g,m=/'[^']*(?:'|$)|"(?:[^"\\]|\\[\s\S])*(?:"|$)/g,h=/(?:^|[;&|({\n`])\s*(?:(?:\w+=\S*|command|exec|env|then|do|else)\s+)*gh\s+pr\s+create\b/,R=/create_pull_request$/;function y(t){return h.test(t.replace(f,"$3").replace(m,"_"))}o(y,"opensPr");function S(t){return["_shared/pr-rules.md",`${p}/pr-rules.md`].find(e=>i.existsSync(s.join(t,e)))??"docs/workspace-lifecycle.md in the werkmeister repo"}o(S,"prRulesPath");function _(t){let e=u(String(t.cwd||process.cwd()));if(!e)return null;let r=String(t.tool_name||""),n=String(t.tool_input?.command||"");if(!(r==="Bash"&&y(n)||R.test(r)))return null;let l=S(e);return`Inside workspace \`${s.basename(e)}\`, PRs open only through \`werkmeister pr open\`: it runs the pre-PR gate and records the URL. Write the PR file in \`${d(e)}\`, have the person set \`status: approved\`, then run \`werkmeister pr open\`. Rules: \`${l}\`.`}o(_,"decide");function w(){let t=null;try{let e=process.stdin.isTTY?"":i.readFileSync(0,"utf8"),r=e.trim()?JSON.parse(e):{};typeof r=="object"&&r!==null&&!Array.isArray(r)&&(t=_(r))}catch{t=null}t&&console.log(JSON.stringify({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:t}}))}o(w,"main");export{u as a,S as b,w as c};
|
|
4
|
+
//# sourceMappingURL=chunk-5UMRCX33.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __sandboxCreateRequire } from "node:module";
|
|
2
2
|
const require = __sandboxCreateRequire(import.meta.url);
|
|
3
|
-
import{a as N}from"./chunk-
|
|
3
|
+
import{a as N}from"./chunk-L6R7TZTL.js";import{$ as R,a as O,ca as C}from"./chunk-CRT2753J.js";import{l as h,m as b,n as T}from"./chunk-IXHOYBP4.js";import{b as u}from"./chunk-OBKPCTPF.js";import{M as x,N as S,j as m,l as y,t as E}from"./chunk-X7NYDP5V.js";import{a as s,f as k}from"./chunk-J7CF3XWN.js";k();import*as f from"node:fs";import*as L from"node:net";import*as w from"node:path";var A=[2,30,0],W="telepresenceio/telepresence/telepresence-oss",J="curl -fL https://github.com/telepresenceio/telepresence/releases/latest/download/telepresence-darwin-arm64 -o /opt/homebrew/bin/telepresence && chmod +x /opt/homebrew/bin/telepresence",g=`Install Telepresence OSS >= ${A.join(".")} with \`brew install ${W}\`, or by direct release download: ${J}`;function F(e){for(let t of(process.env.PATH??"").split(w.delimiter)){if(!t)continue;let n=w.join(t,e);try{if(f.accessSync(n,f.constants.X_OK),f.statSync(n).isFile())return n}catch{}}return null}s(F,"which");function D(e,t=120){let n;try{n=b(e,{capture:!0,timeout:t})}catch(r){if(r instanceof h&&r.code==="ENOENT")return[127,`${e[0]}: command not found`];if(r instanceof h&&r.code==="ETIMEDOUT")return[124,`${e.join(" ")}: timed out after ${t}s`];throw r}return[n.status,((n.stdout||"")+(n.stderr||"")).trim()]}s(D,"_run");async function d(e,t,n=120){let r;try{r=await T(e,{capture:!0,timeout:n,signal:t})}catch(o){if(o instanceof h&&o.code==="ENOENT")return[127,`${e[0]}: command not found`];if(o instanceof h&&o.code==="ETIMEDOUT")return[124,`${e.join(" ")}: timed out after ${n}s`];throw o}return[r.status,((r.stdout||"")+(r.stderr||"")).trim()]}s(d,"runAsyncRunner");function X(e,t=1e3){return new Promise(n=>{let r=new L.Socket,o=!1,i=s(c=>{o||(o=!0,r.destroy(),n(c))},"finish");r.setTimeout(t),r.once("connect",()=>i(!0)),r.once("timeout",()=>i(!1)),r.once("error",()=>i(!1)),r.connect(e,"localhost")})}s(X,"portOpen");function G(e){let t=/v(\d+)\.(\d+)\.(\d+)/.exec(e);return t?[Number.parseInt(t[1],10),Number.parseInt(t[2],10),Number.parseInt(t[3],10)]:null}s(G,"parseVersion");function z(e,t){for(let n=0;n<3;n++)if(e[n]!==t[n])return e[n]<t[n];return!1}s(z,"versionLt");async function Q(e=t=>d(t)){if(F("telepresence")===null)return`telepresence not found on PATH. ${g}`;let[t,n]=await e(["telepresence","version"]),r=G(n);if(t!==0||r===null)return`could not determine telepresence version (${n?n.split(`
|
|
4
4
|
`)[0]:"no output"}). ${g}`;if(z(r,A)){let o=r.join("."),i=A.join(".");return`telepresence ${o} is too old (need >= ${i}). ${g}`}return null}s(Q,"versionError");function Y(e,t,n=!1){let r=["telepresence","connect"];return n&&r.push("--docker"),r.push("--context",e,"--namespace",t),r}s(Y,"buildConnectArgs");var Z="host.docker.internal";function I(e,t){return`${e}-${t}-cn`}s(I,"dockerDaemonName");function ee(e,t,n,r,o=!1){return["telepresence","intercept",e,"--port",`${t}:${n}`,"--http-header",`x-feature=${r}`,"--mount","false",...o?["--address",Z]:[]]}s(ee,"buildInterceptArgs");function _(e){return["telepresence","detach",e]}s(_,"buildLeaveArgs");function te(e){return["telepresence","uninstall",...e]}s(te,"buildUninstallArgs");function ne(){return["telepresence","quit","-s"]}s(ne,"buildQuitArgs");var P="x-feature";function U(){return["telepresence","list","-i","--format","json"]}s(U,"buildListInterceptsArgs");function re(e){if(typeof e!="object"||e===null||Array.isArray(e))return"is not defined in ~/.werkmeister/services.yaml.";let t=e,n=M(t);return n.length?`has no ${n.join("/")} in services.yaml \u2014 not interceptable.`:t.k8s_port_name?null:"has no k8s_port_name in services.yaml. Interception under Istio ambient requires a NAMED Service targetPort; add the port name there once the service's manifests are fixed."}s(re,"interceptBlocker");var oe=["k8s_deployment","k8s_namespace","k8s_port"];function M(e){return oe.filter(t=>!e[t])}s(M,"missingClusterKeys");function ye(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&M(e).length===0}s(ye,"isRemoteService");function H(e){let t=new Map,n=String(e||"").trim();if(!n)return t;let r;try{r=JSON.parse(n)}catch{return t}if(!Array.isArray(r))return t;for(let o of r){if(typeof o!="object"||o===null)continue;let i=o,c=i.name,a=i.intercept_info;typeof c!="string"||!c||!Array.isArray(a)||!a.length||t.set(c,se(a[0]))}return t}s(H,"parseInterceptList");function se(e){if(typeof e!="object"||e===null)return null;let t=e.spec?.header_filters;if(typeof t!="object"||t===null)return null;for(let[n,r]of Object.entries(t))if(n.toLowerCase()===P&&typeof r=="string")return r;return null}s(se,"featureOf");async function Ee(e=t=>d(t)){let t=new Map;if(E())return{installed:!1,available:!1,namespace:null,intercepts:t};let[n,r]=await e($);if(n===127)return{installed:!1,available:!1,namespace:null,intercepts:t};let o=v(n,r),i=[];for(let l of o===null?ie(r):[])if(o=v(...await e([...$,"--use",l])),o!==null){i=["--use",l];break}if(o===null)return{installed:!0,available:!1,namespace:o,intercepts:t};let[c,a]=await e([...U(),...i]);return c!==0?{installed:!0,available:!1,namespace:o,intercepts:t}:{installed:!0,available:!0,namespace:o,intercepts:H(a)}}s(Ee,"listIntercepts");function xe(e=D){return v(...e($))}s(xe,"connectedNamespace");var $=["telepresence","status","--format","json"];function ie(e){let t=/please select (.+?) using the --use/.exec(e);return t?t[1].split(/, | or /):[]}s(ie,"daemonChoices");function v(e,t){if(e!==0)return null;let n;try{n=JSON.parse(t)}catch{return null}let r=n.daemon||n.user_daemon||{};return(r.status==="Connected"||r.running)&&r.namespace||null}s(v,"parseConnectedNamespace");async function ce(e,t,n=!1,r=o=>d(o)){if(E())return;let o=n?["--use",I(e,t)]:[];if(v(...await r([...$,...o]))===t)return;await r(["telepresence","quit","-s"]);let[c,a]=await r(Y(e,t,n));if(c!==0)throw new Error(`telepresence connect failed: ${a||"no output"}`)}s(ce,"ensureConnected");function ae(e){let t;try{if(!f.statSync(e).isFile())return[];t=f.readFileSync(e,"utf8")}catch{return[]}for(let n of t.split(`
|
|
5
5
|
`))if(n=n.trim(),n.startsWith("SERVICES="))return n.slice(n.indexOf("=")+1).split(",").map(o=>o.trim()).filter(Boolean);return[]}s(ae,"servicesFromEnv");function $e(e,t=D){if(F("telepresence")===null)return[];let n=O(e);if(n===null)return[];let r=ae(w.join(n,".env"));if(!r.length)return[];let o=x(),i=[];for(let c of r){let a=q(o[c]);if(!a)continue;let[l]=t(_(a));l===0&&i.push(a)}return i}s($e,"leaveFeatureIntercepts");async function j(e,t=n=>d(n)){let n={uninstalled:[],quit:!1};if(!e.length)return n;let[r,o]=await t(U()),i=[];try{i=o.trim()?JSON.parse(o):[]}catch{i=null}if(r!==0||!Array.isArray(i))return y("Could not read telepresence intercepts -- leaving traffic agents and daemons in place"),n;let c=H(o),a=e.filter(l=>!c.has(l));if(a.length){let[l,p]=await t(te(a));l===0?(n.uninstalled=a,m(`Uninstalled traffic agent(s): ${a.join(", ")}`)):y(`Could not uninstall traffic agent(s) ${a.join(", ")}: ${p||"no output"}`)}if(c.size===0){let[l,p]=await t(ne());l===0?(n.quit=!0,m("Stopped telepresence daemons")):y(`Could not stop telepresence daemons: ${p||"no output"}`)}return n}s(j,"releaseIdleTelepresence");function q(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e.k8s_deployment:void 0}s(q,"deploymentOf");function B(e,t){if(!t.includes(e))throw new u(`'${e}' is not a local service of this workspace (SERVICES=${t.join(",")||"(none)"}). Add it to workspace.yml services and rerun \`werkmeister workspace init\`.`,"NOT_LOCAL");let n=x()[e],r=re(n);if(r)throw new u(`'${e}' ${r}`,"NOT_INTERCEPTABLE");return n}s(B,"resolveServiceDef");async function ve(e){if(E())throw new u("Intercepts are off under WERKMEISTER_FIXTURE.","FIXTURE");let t=B(e.service,e.localServices),n=s(V=>d(V,e.signal),"runner"),r=await Q(n);if(r)throw new u(r,"TELEPRESENCE_VERSION");let o=await R(e.feature);if(o===null)throw new u(`Feature '${e.feature}' has no allocated slot \u2014 run \`werkmeister feature up ${e.feature}\` first.`,"NOT_RUNNING");let i=C(o,t.port_offset??0);if(!await X(i))throw new u(`${e.service} is not listening on localhost:${i} \u2014 run \`werkmeister feature up ${e.feature}\` first (the local container is the intercept target).`,"PORT_CLOSED");let c=S(),a=t.k8s_namespace,l=t.k8s_deployment;m(`Connecting to ${a} on ${c}...`),await ce(c,a,!!e.dockerDaemon,n),m(`Intercepting ${l} \u2192 localhost:${i} (x-feature=${e.feature})...`);let[p,K]=await n([...ee(l,i,t.k8s_port,e.feature,!!e.dockerDaemon),...e.dockerDaemon?["--use",I(c,a)]:[]]);if(p!==0)throw new u(`telepresence intercept failed: ${K||"no output"}`,"INTERCEPT_FAILED");return{service:e.service,context:c,namespace:a,deployment:l,localPort:i,header:P,remoteHost:N()[e.service]?.remoteHostname??null}}s(ve,"startIntercept");async function Se(e){let t=s(i=>c=>d(e.dockerDaemon?[...c,"--use",I(S(),i)]:c,e.signal),"runnerIn");if(e.service){let i=B(e.service,e.localServices),c=i.k8s_deployment,a=t(i.k8s_namespace),[l,p]=await a(_(c));if(l!==0)throw new u(`Could not leave intercept: ${p||"no output"}`,"INTERCEPT_FAILED");return await j([c],a),[c]}let n=x(),r=[],o=t("default");for(let i of e.localServices){let c=q(n[i]);if(!c)continue;o=t(n[i].k8s_namespace??"default");let[a]=await o(_(c));a===0&&r.push(c)}return await j(r,o),r}s(Se,"leaveIntercept");export{A as a,W as b,J as c,g as d,D as e,d as f,X as g,G as h,z as i,Q as j,Y as k,Z as l,I as m,ee as n,_ as o,te as p,ne as q,P as r,U as s,re as t,ye as u,H as v,Ee as w,xe as x,ce as y,$e as z,j as A,ve as B,Se as C};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-6POQA2GP.js.map
|