@lensmcp/cluster 1.25.61 → 1.25.63
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var i=(t,e)=>m(t,"name",{value:e,configurable:!0});var f=Object.defineProperty,a=i((t,e)=>f(t,"name",{value:e,configurable:!0}),"a");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_WORKTREE_RUN_MAX=exports.WORKTREE_RUN_MAX_ENV=exports.MIN_WORKTREE_RUN_IDLE_SEC=exports.DEFAULT_WORKTREE_RUN_IDLE_SEC=exports.WORKTREE_RUN_IDLE_ENV=void 0,exports.worktreeRunIdleSec=worktreeRunIdleSec,exports.worktreeRunMax=worktreeRunMax,exports.isOnDemand=isOnDemand,exports.holdEnd=holdEnd,exports.parkAt=parkAt,exports.runSummary=runSummary,exports.runUnderWay=runUnderWay,exports.parkVerdict=parkVerdict,exports.runCapRefusal=runCapRefusal,exports.runOf=runOf,exports.touchRun=touchRun,exports.touchStart=touchStart,exports.instancesFile=instancesFile,exports.onDemandRecords=onDemandRecords,exports.createOnDemandRecordsReader=createOnDemandRecordsReader,exports.parkedApexOf=parkedApexOf,exports.createParkedHostLookup=createParkedHostLookup,exports.runHint=runHint,exports.parkedAnswer=parkedAnswer;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),os=tslib_1.__importStar(require("node:os")),path=tslib_1.__importStar(require("node:path")),instance_1=require("./instance"),observability_1=require("./observability");exports.WORKTREE_RUN_IDLE_ENV="LENSMCP_WORKTREE_RUN_IDLE_SEC",exports.DEFAULT_WORKTREE_RUN_IDLE_SEC=900,exports.MIN_WORKTREE_RUN_IDLE_SEC=60,exports.WORKTREE_RUN_MAX_ENV="LENSMCP_WORKTREE_RUN_MAX",exports.DEFAULT_WORKTREE_RUN_MAX=2;function worktreeRunIdleSec(t=process.env){const e=Number(t[exports.WORKTREE_RUN_IDLE_ENV]?.trim()||NaN);return Number.isFinite(e)&&e>=exports.MIN_WORKTREE_RUN_IDLE_SEC?e:exports.DEFAULT_WORKTREE_RUN_IDLE_SEC}i(worktreeRunIdleSec,"worktreeRunIdleSec"),a(worktreeRunIdleSec,"worktreeRunIdleSec");function worktreeRunMax(t=process.env){const e=Number(t[exports.WORKTREE_RUN_MAX_ENV]?.trim()||NaN);if(!Number.isFinite(e)||e<0)return exports.DEFAULT_WORKTREE_RUN_MAX;const r=Math.floor(e);return r===0?void 0:r}i(worktreeRunMax,"worktreeRunMax"),a(worktreeRunMax,"worktreeRunMax");function isOnDemand(t){return!!t?.instance?.onDemand}i(isOnDemand,"isOnDemand"),a(isOnDemand,"isOnDemand");function holdEnd(t){let e=0;for(const r of t.services)e=Math.max(e,r.awakeUntil??0);return e}i(holdEnd,"holdEnd"),a(holdEnd,"holdEnd");function parkAt(t,e=process.env){if(isOnDemand(t))return Math.max((t.lastUseAt??0)+worktreeRunIdleSec(e)*1e3,holdEnd(t))}i(parkAt,"parkAt"),a(parkAt,"parkAt");function runSummary(t,e=process.env){return!t||!isOnDemand(t)?{}:{onDemand:!0,parkAt:parkAt(t,e),...t.lastUseAt!==void 0?{lastUseAt:t.lastUseAt}:{}}}i(runSummary,"runSummary"),a(runSummary,"runSummary");function runUnderWay(t){for(const e of t.services){if(e.inflight>0)return`${e.project} has ${e.inflight} request(s) in flight`;if(e.state==="starting"||e.actionStarting)return`${e.project} is starting`;if(e.rolling||e.restart&&!e.restart.done)return`${e.project} is restarting`;if(e.wake&&(e.wake.outcome==="queued"||e.wake.outcome==="starting"))return`${e.project} is waiting its turn to start`}}i(runUnderWay,"runUnderWay"),a(runUnderWay,"runUnderWay");function parkVerdict(t,e,r=process.env){const n=parkAt(t,r);if(n===void 0||e<n)return{ok:!1,...n!==void 0?{parkAt:n}:{}};const c=runUnderWay(t);return c?{ok:!1,parkAt:n,busy:c}:{ok:!0,parkAt:n}}i(parkVerdict,"parkVerdict"),a(parkVerdict,"parkVerdict");function runCapRefusal(t,e,r=process.env){if(!isOnDemand(e))return;const n=worktreeRunMax(r);if(n===void 0)return;const c=t.keys().filter(s=>s!==e.wsKey).map(s=>t.get(s)).filter(s=>!!s&&isOnDemand(s));if(c.length<n)return;const u=c.map(s=>({wsKey:s.wsKey,name:s.instance?.name??s.wsKey,parkAt:parkAt(s,r)})),o=u.map(s=>`${s.name}${s.parkAt?` (parks ${new Date(s.parkAt).toISOString()} unless used)`:""}`).join(", ");return{error:`${c.length} on-demand worktree(s) already run on this machine, the most ${exports.WORKTREE_RUN_MAX_ENV} allows (${n}): ${o}. Park one (worktree_park, \`lensmcp instance park <name>\`) or run again once one has parked.`,code:"run-cap",max:n,running:u}}i(runCapRefusal,"runCapRefusal"),a(runCapRefusal,"runCapRefusal");function runOf(t,e){if(!t||!e||e.internal||e.project===observability_1.LENS_DASHBOARD_PROJECT)return;const r=e.wsKey?t.get(e.wsKey):void 0;return r&&isOnDemand(r)?r:void 0}i(runOf,"runOf"),a(runOf,"runOf");function touchRun(t,e,r){const n=runOf(t,e);n&&(n.lastUseAt=Date.now(),r?.once("close",()=>{n.lastUseAt=Date.now()}))}i(touchRun,"touchRun"),a(touchRun,"touchRun");function touchStart(t,e){const r=t?.get(e.wsKey);r&&isOnDemand(r)&&(r.lastUseAt=Date.now())}i(touchStart,"touchStart"),a(touchStart,"touchStart");function instancesFile(t=process.env){return path.join(t.LENSMCP_HOME||os.homedir(),".lensmcp","instances.json")}i(instancesFile,"instancesFile"),a(instancesFile,"instancesFile");function onDemandRecords(t,e){let r;try{r=JSON.parse(t)}catch{return[]}const n=r?.instances;if(!n||typeof n!="object")return[];const c=[];for(const u of Object.values(n)){const o=u;if(!o||o.services!=="on-demand"||typeof o.key!="string"||typeof o.name!="string"||typeof o.baseKey!="string"||!o.name)continue;let s;if(e&&typeof o.root=="string")try{const p=JSON.parse(e(o.root)??"null");typeof p?.instance?.apex=="string"&&p.instance.apex&&(s=p.instance.apex.toLowerCase())}catch{}c.push({key:o.key,name:o.name.toLowerCase(),baseKey:o.baseKey,...s?{apex:s}:{},...typeof o.root=="string"&&o.root?{root:o.root}:{},...o.checkoutOnly===!0?{checkoutOnly:!0}:{}})}return c}i(onDemandRecords,"onDemandRecords"),a(onDemandRecords,"onDemandRecords");function createOnDemandRecordsReader(t={}){const e=t.ttlMs??2e3,r=t.now??Date.now,n=t.file??(()=>instancesFile());let c=-1/0,u="",o=[];return()=>{const s=r();if(s-c<e)return o;c=s;const p=n();let l
|
|
1
|
+
"use strict";var m=Object.defineProperty;var i=(t,e)=>m(t,"name",{value:e,configurable:!0});var f=Object.defineProperty,a=i((t,e)=>f(t,"name",{value:e,configurable:!0}),"a");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_WORKTREE_RUN_MAX=exports.WORKTREE_RUN_MAX_ENV=exports.MIN_WORKTREE_RUN_IDLE_SEC=exports.DEFAULT_WORKTREE_RUN_IDLE_SEC=exports.WORKTREE_RUN_IDLE_ENV=void 0,exports.worktreeRunIdleSec=worktreeRunIdleSec,exports.worktreeRunMax=worktreeRunMax,exports.isOnDemand=isOnDemand,exports.holdEnd=holdEnd,exports.parkAt=parkAt,exports.runSummary=runSummary,exports.runUnderWay=runUnderWay,exports.parkVerdict=parkVerdict,exports.runCapRefusal=runCapRefusal,exports.runOf=runOf,exports.touchRun=touchRun,exports.touchStart=touchStart,exports.instancesFile=instancesFile,exports.onDemandRecords=onDemandRecords,exports.createOnDemandRecordsReader=createOnDemandRecordsReader,exports.parkedApexOf=parkedApexOf,exports.createParkedHostLookup=createParkedHostLookup,exports.runHint=runHint,exports.parkedAnswer=parkedAnswer;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),os=tslib_1.__importStar(require("node:os")),path=tslib_1.__importStar(require("node:path")),instance_1=require("./instance"),observability_1=require("./observability");exports.WORKTREE_RUN_IDLE_ENV="LENSMCP_WORKTREE_RUN_IDLE_SEC",exports.DEFAULT_WORKTREE_RUN_IDLE_SEC=900,exports.MIN_WORKTREE_RUN_IDLE_SEC=60,exports.WORKTREE_RUN_MAX_ENV="LENSMCP_WORKTREE_RUN_MAX",exports.DEFAULT_WORKTREE_RUN_MAX=2;function worktreeRunIdleSec(t=process.env){const e=Number(t[exports.WORKTREE_RUN_IDLE_ENV]?.trim()||NaN);return Number.isFinite(e)&&e>=exports.MIN_WORKTREE_RUN_IDLE_SEC?e:exports.DEFAULT_WORKTREE_RUN_IDLE_SEC}i(worktreeRunIdleSec,"worktreeRunIdleSec"),a(worktreeRunIdleSec,"worktreeRunIdleSec");function worktreeRunMax(t=process.env){const e=Number(t[exports.WORKTREE_RUN_MAX_ENV]?.trim()||NaN);if(!Number.isFinite(e)||e<0)return exports.DEFAULT_WORKTREE_RUN_MAX;const r=Math.floor(e);return r===0?void 0:r}i(worktreeRunMax,"worktreeRunMax"),a(worktreeRunMax,"worktreeRunMax");function isOnDemand(t){return!!t?.instance?.onDemand}i(isOnDemand,"isOnDemand"),a(isOnDemand,"isOnDemand");function holdEnd(t){let e=0;for(const r of t.services)e=Math.max(e,r.awakeUntil??0);return e}i(holdEnd,"holdEnd"),a(holdEnd,"holdEnd");function parkAt(t,e=process.env){if(isOnDemand(t))return Math.max((t.lastUseAt??0)+worktreeRunIdleSec(e)*1e3,holdEnd(t))}i(parkAt,"parkAt"),a(parkAt,"parkAt");function runSummary(t,e=process.env){return!t||!isOnDemand(t)?{}:{onDemand:!0,parkAt:parkAt(t,e),...t.lastUseAt!==void 0?{lastUseAt:t.lastUseAt}:{}}}i(runSummary,"runSummary"),a(runSummary,"runSummary");function runUnderWay(t){for(const e of t.services){if(e.inflight>0)return`${e.project} has ${e.inflight} request(s) in flight`;if(e.state==="starting"||e.actionStarting)return`${e.project} is starting`;if(e.rolling||e.restart&&!e.restart.done)return`${e.project} is restarting`;if(e.wake&&(e.wake.outcome==="queued"||e.wake.outcome==="starting"))return`${e.project} is waiting its turn to start`}}i(runUnderWay,"runUnderWay"),a(runUnderWay,"runUnderWay");function parkVerdict(t,e,r=process.env){const n=parkAt(t,r);if(n===void 0||e<n)return{ok:!1,...n!==void 0?{parkAt:n}:{}};const c=runUnderWay(t);return c?{ok:!1,parkAt:n,busy:c}:{ok:!0,parkAt:n}}i(parkVerdict,"parkVerdict"),a(parkVerdict,"parkVerdict");function runCapRefusal(t,e,r=process.env){if(!isOnDemand(e))return;const n=worktreeRunMax(r);if(n===void 0)return;const c=t.keys().filter(s=>s!==e.wsKey).map(s=>t.get(s)).filter(s=>!!s&&isOnDemand(s));if(c.length<n)return;const u=c.map(s=>({wsKey:s.wsKey,name:s.instance?.name??s.wsKey,parkAt:parkAt(s,r)})),o=u.map(s=>`${s.name}${s.parkAt?` (parks ${new Date(s.parkAt).toISOString()} unless used)`:""}`).join(", ");return{error:`${c.length} on-demand worktree(s) already run on this machine, the most ${exports.WORKTREE_RUN_MAX_ENV} allows (${n}): ${o}. Park one (worktree_park, \`lensmcp instance park <name>\`) or run again once one has parked.`,code:"run-cap",max:n,running:u}}i(runCapRefusal,"runCapRefusal"),a(runCapRefusal,"runCapRefusal");function runOf(t,e){if(!t||!e||e.internal||e.project===observability_1.LENS_DASHBOARD_PROJECT)return;const r=e.wsKey?t.get(e.wsKey):void 0;return r&&isOnDemand(r)?r:void 0}i(runOf,"runOf"),a(runOf,"runOf");function touchRun(t,e,r){const n=runOf(t,e);n&&(n.lastUseAt=Date.now(),r?.once("close",()=>{n.lastUseAt=Date.now()}))}i(touchRun,"touchRun"),a(touchRun,"touchRun");function touchStart(t,e){const r=t?.get(e.wsKey);r&&isOnDemand(r)&&(r.lastUseAt=Date.now())}i(touchStart,"touchStart"),a(touchStart,"touchStart");function instancesFile(t=process.env){return path.join(t.LENSMCP_HOME||os.homedir(),".lensmcp","instances.json")}i(instancesFile,"instancesFile"),a(instancesFile,"instancesFile");function onDemandRecords(t,e){let r;try{r=JSON.parse(t)}catch{return[]}const n=r?.instances;if(!n||typeof n!="object")return[];const c=[];for(const u of Object.values(n)){const o=u;if(!o||o.services!=="on-demand"||typeof o.key!="string"||typeof o.name!="string"||typeof o.baseKey!="string"||!o.name)continue;let s;if(e&&typeof o.root=="string")try{const p=JSON.parse(e(o.root)??"null");typeof p?.instance?.apex=="string"&&p.instance.apex&&(s=p.instance.apex.toLowerCase())}catch{}c.push({key:o.key,name:o.name.toLowerCase(),baseKey:o.baseKey,...s?{apex:s}:{},...typeof o.root=="string"&&o.root?{root:o.root}:{},...o.checkoutOnly===!0?{checkoutOnly:!0}:{}})}return c}i(onDemandRecords,"onDemandRecords"),a(onDemandRecords,"onDemandRecords");function createOnDemandRecordsReader(t={}){const e=t.ttlMs??2e3,r=t.now??Date.now,n=t.file??(()=>instancesFile());let c=-1/0,u="",o=[];return()=>{const s=r();if(s-c<e)return o;c=s;const p=n();let l;try{const d=fs.statSync(p);l=`${p}:${d.mtimeMs}:${d.size}`}catch{return u="",o=[],o}if(l===u)return o;u=l;try{o=onDemandRecords(fs.readFileSync(p,"utf8"),d=>{try{return fs.readFileSync(path.join(d,".lensmcp","config.json"),"utf8")}catch{return}})}catch{o=[]}return o}}i(createOnDemandRecordsReader,"createOnDemandRecordsReader"),a(createOnDemandRecordsReader,"createOnDemandRecordsReader");function baseApexOf(t){return(0,instance_1.commonApex)(t.routes.filter(e=>!!e.host&&e.project!==observability_1.LENS_DASHBOARD_PROJECT).map(e=>e.host))}i(baseApexOf,"baseApexOf"),a(baseApexOf,"baseApexOf");function parkedApexOf(t,e,r){if(t.apex)return t.apex;let n=r?.get(e);return n===void 0&&(n=baseApexOf(e)??null,r?.set(e,n)),n??void 0}i(parkedApexOf,"parkedApexOf"),a(parkedApexOf,"parkedApexOf");function createParkedHostLookup(t){const e=t.records??createOnDemandRecordsReader(t),r=new WeakMap;return{match(n){const c=t.registry();if(!c||!n)return;const u=e();if(u.length===0)return;const o=n.toLowerCase();for(const s of u){if(c.has(s.key))continue;const p=c.get(s.baseKey);if(!p||p.instance)continue;const l=parkedApexOf(s,p,r);if(!l)continue;const d=`${s.name}.${l}`;if(o===d||o.endsWith(`.${d}`))return s}}}}i(createParkedHostLookup,"createParkedHostLookup"),a(createParkedHostLookup,"createParkedHostLookup");const escapeHtml=a(t=>t.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]),"escapeHtml");function runHint(t){return`worktree_run { name: "${t}" } \xB7 lensmcp instance run ${t}`}i(runHint,"runHint"),a(runHint,"runHint");function parkedAnswer(t,e,r){const n={"cache-control":"no-store","x-lensmcp-worktree":"parked"};if(/\btext\/html\b/i.test(e??"")){const c=escapeHtml(t.name),u=r?`<p>What its last run recorded \u2014 flows, errors, logs, reviews \u2014 is on <a href="${escapeHtml(r)}">its dashboard</a>, which opens without running it.</p>
|
|
2
2
|
`:"",o=`<!doctype html>
|
|
3
3
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
|
|
4
4
|
<title>${c} is parked</title>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/cluster",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.63",
|
|
4
4
|
"description": "Run your Nx workspace as a local production cluster: pods on unix sockets with true HMR, one https gateway with per-project domains, scale-from-zero, autoscale, idle-kill, local-CA TLS — observed by the LensMCP lens.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@lensmcp/core": "1.25.
|
|
62
|
-
"@lensmcp/node-instrumentation": "1.25.
|
|
63
|
-
"@lensmcp/nx-plugin": "1.25.
|
|
61
|
+
"@lensmcp/core": "1.25.63",
|
|
62
|
+
"@lensmcp/node-instrumentation": "1.25.63",
|
|
63
|
+
"@lensmcp/nx-plugin": "1.25.63",
|
|
64
64
|
"fastify": "^5.8.5",
|
|
65
65
|
"@fastify/reply-from": "^12.6.2",
|
|
66
66
|
"@typescript/native-preview": "^7.0.0-dev.20260707.2",
|