@lensmcp/core 1.25.54 → 1.25.56
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/lib/settings.js +2 -2
- package/package.json +2 -2
package/lib/settings.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var M=Object.defineProperty;var l=(t,e)=>M(t,"name",{value:e,configurable:!0});var N=Object.defineProperty,s=l((t,e)=>N(t,"name",{value:e,configurable:!0}),"n");import{readFileSync as k,renameSync as L,statSync as C,unlinkSync as O,writeFileSync as P,mkdirSync as A}from"node:fs";import{availableParallelism as T,homedir as x}from"node:os";import{dirname as R,join as g}from"node:path";const I=[{value:"on",label:"On"},{value:"off",label:"Off"}],m=s(t=>t==="0"?"off":"on","zeroIsOff"),S=s(t=>/^(0|off|false|no)$/i.test(t.trim())?"off":"on","wordIsOff"),a=s(t=>{if(t.trim()==="")return;const e=Number(t);return Number.isFinite(e)?e:void 0},"num"),f={kind:"toggle",options:I,write:{on:"1",off:"0"}};export const SETTINGS=[{env:"LENSMCP_HTTP_CAPTURE",page:"capture",section:"Requests",title:"What each request keeps",desc:"For every request a service serves or makes: its headers, the query and the first 64 KB of each body; its headers only; or nothing.",kept:"repository",applies:"service",kind:"choice",options:[{value:"bodies",label:"Headers and bodies"},{value:"headers",label:"Headers"},{value:"off",label:"Nothing"}],default:"bodies",parse:s(t=>/^(off|0|false|none)$/i.test(t.trim())?"off":t.trim().toLowerCase()==="headers"?"headers":"bodies","parse")},{env:"LENSMCP_HTTP_MAX_FILES",page:"capture",section:"Requests",title:"Exchanges kept in each place",desc:"How many exchanges are kept for third-party calls, for requests served, and for calls between services. The oldest go first; AI calls are kept.",kept:"machine",applies:"service",kind:"number",number:{unit:"exchanges",min:10},default:1e4,parse:s(t=>{const e=a(t);return e!==void 0&&e>=10?Math.floor(e):void 0},"parse")},{env:"LENSMCP_LOGS",page:"capture",section:"Logs",...f,title:"Mirror the services\u2019 logs",desc:"What each service prints, and what its handlers give the Nest Logger, goes on the lens as logs. Off: Logs shows nothing of the services.",kept:"repository",applies:"service",default:"on",parse:m},{env:"LENSMCP_EVENT_LOOP",page:"capture",section:"Event loops",...f,title:"Measure the services\u2019 event loops",desc:"Samples each service\u2019s event-loop delay, measures slow callbacks and watches for a loop that stops answering. Off: Cluster \u203A Event loops has nothing.",kept:"repository",applies:"service",default:"on",parse:m},{env:"LENSMCP_TRACE_FLOWLESS_MIN_MS",page:"capture",section:"Traces",title:"Shortest traced call outside a request",desc:"A traced method that runs outside any request, flow or job and returns faster than this leaves no span \u2014 a timer that runs every second would otherwise fill the history.",kept:"repository",applies:"service",kind:"number",number:{unit:"ms",min:0,zero:"keep every one"},default:10,parse:s(t=>{const e=a(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_EVENT_HISTORY_DAYS",page:"history",section:"Event history",title:"Keep the history for",desc:"Rows older than this go. Whichever comes first, this or the size below, decides.",kept:"machine",applies:"lens",kind:"number",number:{unit:"days",min:0,zero:"keep by size only"},default:30,parse:s(t=>{const e=a(t);return e===void 0?void 0:e>0?e:0},"parse")},{env:"LENSMCP_EVENT_HISTORY_MAX_GB",page:"history",section:"Event history",title:"Most history kept",desc:"Past this size the oldest rows go, whatever their age. A busy workspace reaches it in days.",kept:"machine",applies:"lens",kind:"number",number:{unit:"GB",min:0,zero:"no limit"},default:16,parse:s(t=>{const e=a(t);return e===void 0?void 0:e>0?e:0},"parse")},{env:"LENSMCP_EVENT_LOOP_DAYS",page:"history",section:"Event history",title:"Keep event-loop stalls for",desc:"How long a stall and its evidence stay in the history.",kept:"machine",applies:"lens",kind:"number",number:{unit:"days",min:1},default:30,parse:s(t=>{const e=a(t);return e!==void 0&&e>0?e:void 0},"parse")},{env:"LENSMCP_EVENT_MAX_BYTES",page:"history",section:"The event bus",title:"Size of one bus file",desc:"The events every process writes go to .lensmcp/events.jsonl; past this size it is rotated.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"MB",scale:1048576,min:1048576},default:52428800,parse:s(t=>{const e=a(t);return e!==void 0&&e>0?e:void 0},"parse")},{env:"LENSMCP_EVENT_MAX_FILES",page:"history",section:"The event bus",title:"Bus files kept",desc:"How many rotated bus files are kept beside the one being written.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"files",min:1,max:20},default:5,parse:s(t=>{const e=a(t);return e!==void 0&&e>=1&&e<=20?Math.floor(e):void 0},"parse")},{env:"LENSMCP_TYPECHECK",page:"typecheck",section:"The checker",title:"Type checker",desc:"tsgo checks a service after each build with the native compiler and keeps nothing in memory between saves. fork-ts-checker keeps a whole TypeScript program in memory for each service, 1\u20133 GB on a large one. Off: no type errors on the lens.",kept:"repository",applies:"service",kind:"choice",options:[{value:"tsgo",label:"tsgo"},{value:"tsc",label:"fork-ts-checker"},{value:"off",label:"Off"}],default:"tsgo",parse:s(t=>t==="off"?"off":t==="tsgo"||t===""?"tsgo":"tsc","parse")},{env:"LENSMCP_TYPECHECK_MIN_FREE_MB",page:"typecheck",section:"tsgo",title:"Wait for free memory",desc:"A check waits while the machine has less than this free, and the lens says it is held. Each check of a large service takes 1.5\u20133.5 GB while it runs.",kept:"machine",applies:"service",kind:"number",number:{unit:"MB",min:0,zero:"never wait"},default:2048,parse:s(t=>{const e=a(t);return e!==void 0&&e>=0?Math.round(e):void 0},"parse")},{env:"LENSMCP_TYPECHECK_CONCURRENCY",page:"typecheck",section:"tsgo",title:"Checks at once on this machine",desc:"How many services are checked at the same time, every workspace\u2019s together. The rest wait their turn.",kept:"machine",applies:"service",kind:"number",number:{unit:"checks",min:1,max:8},default:1,parse:s(t=>{const e=a(t);return e!==void 0&&Number.isInteger(e)&&e>=1?Math.min(e,8):void 0},"parse")},{env:"LENSMCP_TSGO_INCREMENTAL",page:"typecheck",section:"tsgo",...f,title:"Check only what a change affects",desc:"Each service keeps what its last check learnt on disk (tmp/lensmcp-tsgo) and checks again only the files a change can affect. Off: every check is a full one.",kept:"repository",applies:"service",default:"on",parse:S},{env:"LENSMCP_PERF_RULES",page:"performance",section:"Rules",...f,title:"Performance rules",desc:"The rules that flag a barrel import that compiles a whole library, and a pod over its memory budget. Off: Performance shows none of their findings.",kept:"repository",applies:"service",default:"on",parse:S},{env:"LENSMCP_POD_HEAP_BUDGET_MB",page:"performance",section:"Rules",title:"A pod\u2019s memory budget",desc:"The live heap after a full collection above which a pod is flagged as over its budget. A service\u2019s own perfRules in .lensmcp/config.json wins.",kept:"repository",applies:"lens",kind:"number",number:{unit:"MB",min:16,max:1e6},default:512,parse:s(t=>{const e=a(t);return e!==void 0&&e>=16&&e<=1e6?e:void 0},"parse")},{env:"LENSMCP_MAX_COLD_STARTS",page:"services",section:"Starting",title:"Services starting at once",desc:"How many services may cold start together, every workspace\u2019s and worktree\u2019s counted. The rest wait their turn. Fewer start slower but keep a loaded machine answering.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"services",min:0,zero:"no limit"},default:s(()=>Math.max(2,Math.floor(T()/2)),"default"),parse:s(t=>{const e=a(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_POD_RESPONSE_TIMEOUT_MS",page:"services",section:"Answering",title:"Wait for a first byte",desc:"How long the gateway waits for a pod\u2019s first byte before it checks the pod is alive. A service\u2019s own cluster.firstByteMs wins.",kept:"repository",applies:"gateway",kind:"number",number:{unit:"s",scale:1e3,min:1e3},default:3e4,parse:s(t=>{const e=a(t);return e!==void 0&&e>0?e:void 0},"parse")},{env:"LENSMCP_POD_RECYCLE",page:"services",section:"Recycling",...f,title:"Recycle a pod that missed a change",desc:"A pod whose watcher missed a file added or removed is replaced by a fresh one. Off: a pod keeps serving its old code until you restart it.",kept:"repository",applies:"gateway",default:"on",parse:m},{env:"LENSMCP_POD_MAX_AGE_MS",page:"services",section:"Recycling",title:"Recycle a pod older than",desc:"A pod this old is replaced even with no change seen \u2014 the one whose watcher went quiet.",kept:"repository",applies:"gateway",kind:"number",number:{unit:"h",scale:36e5,min:0,zero:"never"},default:144e5,parse:s(t=>{const e=a(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_SWAP_MODE",page:"services",section:"A new build",title:"How a pod takes a new build",desc:"A fresh pod takes each new build and the old one finishes its work. In the same pod: the app is swapped inside the running process \u2014 faster, but a module that holds state can leak.",kept:"repository",applies:"service",kind:"choice",options:[{value:"process",label:"A fresh pod"},{value:"in-process",label:"In the same pod"}],default:"process",parse:s(t=>/^(in-process|inprocess|hot)$/i.test(t.trim())?"in-process":"process","parse")},{env:"LENSMCP_SWAP_DRAIN_MS",page:"services",section:"A new build",title:"Let the old app finish for",desc:"How long the previous app may finish its requests and background jobs before it is closed anyway.",kept:"repository",applies:"service",kind:"number",number:{unit:"min",scale:6e4,min:0,zero:"close at once"},default:9e5,parse:s(t=>{const e=a(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_SHARED_COMPILER",page:"builds",section:"Compiling",...f,title:"One compilation for every service",desc:"The services of a checkout share one webpack compilation: a shared library is compiled once, not once per service. Off: each service has its own watcher again.",kept:"repository",applies:"service",default:"on",parse:s(t=>/^(0|off|false|no)$/i.test(t.trim())?"off":"on","parse")},{env:"LENSMCP_BUILD_HOST_IDLE_SEC",page:"builds",section:"Compiling",title:"Stop an idle build host after",desc:"How long a checkout\u2019s build host keeps running once none of its services runs.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"min",scale:60,min:0,zero:"never"},default:300,parse:s(t=>{const e=a(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_DEV_DEVTOOL",page:"builds",section:"Source maps",title:"Source maps in development",desc:"eval is the fastest to build. A full source map gives exact lines in stack traces and costs build time and memory. A serve target\u2019s own devtool wins.",kept:"repository",applies:"service",kind:"choice",options:[{value:"eval",label:"eval"},{value:"eval-cheap-module-source-map",label:"eval-cheap-module-source-map"},{value:"cheap-module-source-map",label:"cheap-module-source-map"},{value:"source-map",label:"source-map"},{value:"off",label:"None"}],default:"eval",parse:s(t=>{const e=t.trim();return e?/^(false|off|none|0)$/i.test(e)?"off":/^(?:eval|(?:inline-|hidden-|eval-)?(?:nosources-)?(?:cheap-(?:module-)?)?source-map(?:-debugids)?)$/.test(e)?e:"eval":"eval"},"parse")},{env:"LENSMCP_WARM_MIN_FREE_MB",page:"worktrees",section:"Starting",title:"Start a worktree\u2019s services only with free memory",desc:"When a worktree registers, its always-warm services start one at a time, each only while the machine has this much free. The rest start on their first request.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"MB",min:0,zero:"no floor"},default:4096,parse:s(t=>{const e=a(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_WORKTREE_IDLE_SEC",page:"worktrees",section:"Sleeping",title:"Stop an unused worktree service after",desc:"A worktree\u2019s service with no request for this long stops, and starts again on the next one.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"min",scale:60,min:0,zero:"never"},default:1800,parse:s(t=>{const e=a(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_DASHBOARD_IDLE_SEC",page:"worktrees",section:"Sleeping",title:"Stop an unused worktree dashboard after",desc:"A worktree\u2019s dashboard starts on its first request and stops after this long with none.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"min",scale:60,min:0,zero:"always up"},default:600,parse:s(t=>{const e=a(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_GUEST_REPLAY",page:"worktrees",section:"After a restart",...f,title:"Host the worktrees again after a restart",desc:"A restarted gateway hosts again every worktree and workspace registered with it before. Off: each registers again when its lens starts.",kept:"machine",applies:"gateway",default:"on",parse:m},{env:"LENSMCP_GUEST_MIDDLEWARE",page:"worktrees",section:"Requests",title:"Whose middleware runs on a worktree\u2019s routes",desc:"Its own \u2014 the middleware its gateway target declares; the main checkout\u2019s, on every route; or none.",kept:"machine",applies:"gateway",kind:"choice",options:[{value:"own",label:"Its own"},{value:"owner",label:"The main checkout\u2019s"},{value:"none",label:"None"}],default:"own",parse:s(t=>t==="owner"||t==="none"?t:"own","parse")},{env:"LENSMCP_GW_ACT",page:"gateway",section:"Acting as a user",...f,title:"Let agents act as a signed-in user",desc:"An agent may call the services as a user who signed in on this machine, through a ticket the gateway checks. Off: every ticket is refused.",kept:"machine",applies:"gateway",default:"on",parse:m},{env:"LENSMCP_MAX_CONNECTIONS",page:"gateway",section:"Limits",title:"Most connections at once",desc:"The front door\u2019s ceiling on open connections. Past it, new ones wait.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"connections",min:0,zero:"no limit"},default:512,parse:s(t=>{const e=a(t);return e!==void 0&&e>=0?Math.floor(e):void 0},"parse")},{env:"LENSMCP_ANSWER_BUDGET_BYTES",page:"answers",section:"Size",title:"Largest answer to an agent",desc:"Every answer, and every page result_query reads, fits this. A bigger one is folded, or cut when folding is off.",kept:"repository",applies:"lens",kind:"number",number:{unit:"KB",scale:1024,min:2048,zero:"no limit (folding off)"},default:24576,parse:s(t=>{const e=a(t);return e===void 0||e<0?void 0:e===0?0:Math.max(2048,Math.floor(e))},"parse")},{env:"LENSMCP_RESULT_HANDLES_THRESHOLD_BYTES",page:"answers",section:"Size",title:"Fold answers larger than",desc:"An answer at or under this goes to the agent as it is; a larger one goes as a preview and a handle.",kept:"repository",applies:"lens",kind:"number",number:{unit:"KB",scale:1024,min:1024},default:8192,parse:s(t=>{const e=a(t);return e!==void 0&&e>=1024?Math.floor(e):void 0},"parse")}];const y=new Map(SETTINGS.map(t=>[t.env,t]));export const settingOf=s(t=>y.get(t),"settingOf"),defaultOf=s(t=>typeof t.default=="function"?t.default():t.default,"defaultOf");export function valueOf(t,e){const r=t.parse?t.parse(e):e;return r===void 0?defaultOf(t):r}l(valueOf,"valueOf"),s(valueOf,"valueOf");export function textFor(t,e){if(t.kind==="toggle")return e!=="on"&&e!=="off"?{refused:`${t.env} is on or off`}:{text:e==="on"?t.write.on:t.write.off};if(t.kind==="choice"){const o=t.options?.find(i=>i.value===e);return o?{text:o.value}:{refused:`${t.env} is one of ${t.options.map(i=>i.value).join(", ")}`}}const r=typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):NaN,n=t.number;return Number.isFinite(r)?r===0&&n.zero?{text:"0"}:n.min!==void 0&&r<n.min?{refused:`${t.env} is at least ${n.min}${n.zero?`, or 0 (${n.zero})`:""}`}:n.max!==void 0&&r>n.max?{refused:`${t.env} is at most ${n.max}`}:{text:String(r)}:{refused:`${t.env} is a number`}}l(textFor,"textFor"),s(textFor,"textFor");export const PROJECT_FILE_NAME="lensmcp.json";export function machineSettingsFile(t=process.env){return g(t.LENSMCP_HOME||x(),".lensmcp","settings.json")}l(machineSettingsFile,"machineSettingsFile"),s(machineSettingsFile,"machineSettingsFile");const w=new Map;function b(t){let e;try{const o=C(t);e=`${o.size}:${o.mtimeMs}`}catch{return w.delete(t),{}}const r=w.get(t);if(r?.stamp===e)return r.settings;const n={};try{const o=JSON.parse(k(t,"utf8"));if(o.settings&&typeof o.settings=="object"&&!Array.isArray(o.settings))for(const[i,c]of Object.entries(o.settings))y.has(i)&&(typeof c=="string"||typeof c=="number")&&(n[i]=String(c))}catch{}return w.set(t,{stamp:e,settings:n}),n}l(b,"E"),s(b,"fileSettings");export function readKeptSettings(t,e=process.env){const r=b(g(t,PROJECT_FILE_NAME)),n=b(machineSettingsFile(e)),o=s((i,c)=>Object.fromEntries(Object.entries(i).filter(([d])=>y.get(d)?.kept===c)),"pick");return{repository:o(r,"repository"),machine:o(n,"machine")}}l(readKeptSettings,"readKeptSettings"),s(readKeptSettings,"readKeptSettings");export function keptEnv(t,e=process.env){const r=readKeptSettings(t,e);return{...r.machine,...r.repository}}l(keptEnv,"keptEnv"),s(keptEnv,"keptEnv");export const KEPT_MARK="LENSMCP_KEPT_SETTINGS";const E=s(t=>new Set((t[KEPT_MARK]??"").split(",").filter(Boolean)),"markedNames");export const fromSettings=s((t,e=process.env)=>e[t]!==void 0&&E(e).has(t),"fromSettings"),DOTENV_FILES=[".env.local",".local.env",".env"];export function dotenvKeys(t){const e=new Map;for(const r of DOTENV_FILES){let n;try{n=k(g(t,r),"utf8")}catch{continue}for(const o of n.matchAll(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/gm))e.has(o[1])||e.set(o[1],r)}return e}l(dotenvKeys,"dotenvKeys"),s(dotenvKeys,"dotenvKeys");export const dotenvDeclaring=s((t,e)=>dotenvKeys(t).get(e),"dotenvDeclaring");export function withKeptSettings(t,e,r=process.env){const n={...e},o=keptEnv(t,r),i=E(e),c=dotenvKeys(t),d=[];for(const h of SETTINGS){const u=h.env;if(n[u]!==void 0&&!i.has(u))continue;const v=o[u];v===void 0||c.has(u)?delete n[u]:(n[u]=v,d.push(u))}return d.length?n[KEPT_MARK]=d.join(","):delete n[KEPT_MARK],n}l(withKeptSettings,"withKeptSettings"),s(withKeptSettings,"withKeptSettings");export function applyKeptSettings(t,e=process.env){const r=withKeptSettings(t,e,e);for(const n of[...SETTINGS.map(o=>o.env),KEPT_MARK])r[n]===void 0?delete e[n]:e[n]=r[n];return[...E(e)]}l(applyKeptSettings,"applyKeptSettings"),s(applyKeptSettings,"applyKeptSettings");export function resolveSetting(t,e,r=process.env,n=readKeptSettings(e,r)){const o=n[t.kept][t.env],i=r[t.env];return i!==void 0&&!fromSettings(t.env,r)?{value:valueOf(t,i),source:"env",envFrom:dotenvDeclaring(e,t.env)??"shell",...o!==void 0?{kept:o}:{}}:o!==void 0?{value:valueOf(t,o),source:t.kept}:{value:defaultOf(t),source:"default"}}l(resolveSetting,"resolveSetting"),s(resolveSetting,"resolveSetting");export function writeKeptSetting(t,e,r,n=process.env){const o=y.get(e);if(!o)throw new Error(`${e} is not a setting`);const i=o.kept==="repository"?g(t,PROJECT_FILE_NAME):machineSettingsFile(n);let c={},d=!0;try{const p=JSON.parse(k(i,"utf8"));if(!p||typeof p!="object"||Array.isArray(p))throw new Error(`${i} is not a JSON object \u2014 fix it by hand first`);c=p}catch(p){if(p.code!=="ENOENT")throw p instanceof SyntaxError?new Error(`${i} is not valid JSON (${p.message}) \u2014 fix it by hand first`):p;d=!1}const h=c.settings&&typeof c.settings=="object"&&!Array.isArray(c.settings)?{...c.settings}:{},u=typeof h[e]=="string"||typeof h[e]=="number"?String(h[e]):null;if(r===null?delete h[e]:h[e]=r,Object.keys(h).length?c.settings=Object.fromEntries(Object.entries(h).sort(([p],[_])=>p.localeCompare(_))):delete c.settings,!d&&!c.settings)return u;d||(c={schemaVersion:1,...c}),A(R(i),{recursive:!0});const v=`${i}.${process.pid}.tmp`;try{P(v,`${JSON.stringify(c,null,2)}
|
|
2
|
-
`),L(v,i)}catch(p){try{
|
|
1
|
+
"use strict";var M=Object.defineProperty;var l=(t,e)=>M(t,"name",{value:e,configurable:!0});var N=Object.defineProperty,s=l((t,e)=>N(t,"name",{value:e,configurable:!0}),"n");import{readFileSync as y,renameSync as L,statSync as C,unlinkSync as A,writeFileSync as O,mkdirSync as P}from"node:fs";import{availableParallelism as T,homedir as R}from"node:os";import{dirname as x,join as g}from"node:path";const I=[{value:"on",label:"On"},{value:"off",label:"Off"}],m=s(t=>t==="0"?"off":"on","zeroIsOff"),b=s(t=>/^(0|off|false|no)$/i.test(t.trim())?"off":"on","wordIsOff"),o=s(t=>{if(t.trim()==="")return;const e=Number(t);return Number.isFinite(e)?e:void 0},"num"),f={kind:"toggle",options:I,write:{on:"1",off:"0"}};export const SETTINGS=[{env:"LENSMCP_HTTP_CAPTURE",page:"capture",section:"Requests",title:"What each request keeps",desc:"For every request a service serves or makes: its headers, the query and the first 64 KB of each body; its headers only; or nothing.",kept:"repository",applies:"service",kind:"choice",options:[{value:"bodies",label:"Headers and bodies"},{value:"headers",label:"Headers"},{value:"off",label:"Nothing"}],default:"bodies",parse:s(t=>/^(off|0|false|none)$/i.test(t.trim())?"off":t.trim().toLowerCase()==="headers"?"headers":"bodies","parse")},{env:"LENSMCP_HTTP_MAX_FILES",page:"capture",section:"Requests",title:"Exchanges kept in each place",desc:"How many exchanges are kept for third-party calls, for requests served, and for calls between services. The oldest go first; AI calls are kept.",kept:"machine",applies:"service",kind:"number",number:{unit:"exchanges",min:10},default:1e4,parse:s(t=>{const e=o(t);return e!==void 0&&e>=10?Math.floor(e):void 0},"parse")},{env:"LENSMCP_LOGS",page:"capture",section:"Logs",...f,title:"Mirror the services\u2019 logs",desc:"What each service prints, and what its handlers give the Nest Logger, goes on the lens as logs. Off: Logs shows nothing of the services.",kept:"repository",applies:"service",default:"on",parse:m},{env:"LENSMCP_EVENT_LOOP",page:"capture",section:"Event loops",...f,title:"Measure the services\u2019 event loops",desc:"Samples each service\u2019s event-loop delay, measures slow callbacks and watches for a loop that stops answering. Off: Cluster \u203A Event loops has nothing.",kept:"repository",applies:"service",default:"on",parse:m},{env:"LENSMCP_TRACE_FLOWLESS_MIN_MS",page:"capture",section:"Traces",title:"Shortest traced call outside a request",desc:"A traced method that runs outside any request, flow or job and returns faster than this leaves no span \u2014 a timer that runs every second would otherwise fill the history.",kept:"repository",applies:"service",kind:"number",number:{unit:"ms",min:0,zero:"keep every one"},default:10,parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_EVENT_HISTORY_DAYS",page:"history",section:"Event history",title:"Keep the history for",desc:"Rows older than this go. Whichever comes first, this or the size below, decides.",kept:"machine",applies:"lens",kind:"number",number:{unit:"days",min:0,zero:"keep by size only"},default:30,parse:s(t=>{const e=o(t);return e===void 0?void 0:e>0?e:0},"parse")},{env:"LENSMCP_EVENT_HISTORY_MAX_GB",page:"history",section:"Event history",title:"Most history kept",desc:"Past this size the oldest rows go, whatever their age. A busy workspace reaches it in days.",kept:"machine",applies:"lens",kind:"number",number:{unit:"GB",min:0,zero:"no limit"},default:16,parse:s(t=>{const e=o(t);return e===void 0?void 0:e>0?e:0},"parse")},{env:"LENSMCP_EVENT_LOOP_DAYS",page:"history",section:"Event history",title:"Keep event-loop stalls for",desc:"How long a stall and its evidence stay in the history.",kept:"machine",applies:"lens",kind:"number",number:{unit:"days",min:1},default:30,parse:s(t=>{const e=o(t);return e!==void 0&&e>0?e:void 0},"parse")},{env:"LENSMCP_EVENT_MAX_BYTES",page:"history",section:"The event bus",title:"Size of one bus file",desc:"The events every process writes go to .lensmcp/events.jsonl; past this size it is rotated.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"MB",scale:1048576,min:1048576},default:52428800,parse:s(t=>{const e=o(t);return e!==void 0&&e>0?e:void 0},"parse")},{env:"LENSMCP_EVENT_MAX_FILES",page:"history",section:"The event bus",title:"Bus files kept",desc:"How many rotated bus files are kept beside the one being written.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"files",min:1,max:20},default:5,parse:s(t=>{const e=o(t);return e!==void 0&&e>=1&&e<=20?Math.floor(e):void 0},"parse")},{env:"LENSMCP_TYPECHECK",page:"typecheck",section:"The checker",title:"Type checker",desc:"tsgo checks a service after each build with the native compiler and keeps nothing in memory between saves. fork-ts-checker keeps a whole TypeScript program in memory for each service, 1\u20133 GB on a large one. Off: no type errors on the lens.",kept:"repository",applies:"service",kind:"choice",options:[{value:"tsgo",label:"tsgo"},{value:"tsc",label:"fork-ts-checker"},{value:"off",label:"Off"}],default:"tsgo",parse:s(t=>t==="off"?"off":t==="tsgo"||t===""?"tsgo":"tsc","parse")},{env:"LENSMCP_TYPECHECK_MIN_FREE_MB",page:"typecheck",section:"tsgo",title:"Wait for free memory",desc:"A check waits while the machine has less than this free, and the lens says it is held. Each check of a large service takes 1.5\u20133.5 GB while it runs.",kept:"machine",applies:"service",kind:"number",number:{unit:"MB",min:0,zero:"never wait"},default:2048,parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?Math.round(e):void 0},"parse")},{env:"LENSMCP_TYPECHECK_CONCURRENCY",page:"typecheck",section:"tsgo",title:"Checks at once on this machine",desc:"How many services are checked at the same time, every workspace\u2019s together. The rest wait their turn.",kept:"machine",applies:"service",kind:"number",number:{unit:"checks",min:1,max:8},default:1,parse:s(t=>{const e=o(t);return e!==void 0&&Number.isInteger(e)&&e>=1?Math.min(e,8):void 0},"parse")},{env:"LENSMCP_TSGO_INCREMENTAL",page:"typecheck",section:"tsgo",...f,title:"Check only what a change affects",desc:"Each service keeps what its last check learnt on disk (tmp/lensmcp-tsgo) and checks again only the files a change can affect. Off: every check is a full one.",kept:"repository",applies:"service",default:"on",parse:b},{env:"LENSMCP_PERF_RULES",page:"performance",section:"Rules",...f,title:"Performance rules",desc:"The rules that flag a barrel import that compiles a whole library, and a pod over its memory budget. Off: Performance shows none of their findings.",kept:"repository",applies:"service",default:"on",parse:b},{env:"LENSMCP_POD_HEAP_BUDGET_MB",page:"performance",section:"Rules",title:"A pod\u2019s memory budget",desc:"The live heap after a full collection above which a pod is flagged as over its budget. A service\u2019s own perfRules in .lensmcp/config.json wins.",kept:"repository",applies:"lens",kind:"number",number:{unit:"MB",min:16,max:1e6},default:512,parse:s(t=>{const e=o(t);return e!==void 0&&e>=16&&e<=1e6?e:void 0},"parse")},{env:"LENSMCP_MAX_COLD_STARTS",page:"services",section:"Starting",title:"Services starting at once",desc:"How many services may cold start together, every workspace\u2019s and worktree\u2019s counted. The rest wait their turn. Fewer start slower but keep a loaded machine answering.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"services",min:0,zero:"no limit"},default:s(()=>Math.max(2,Math.floor(T()/2)),"default"),parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_POD_RESPONSE_TIMEOUT_MS",page:"services",section:"Answering",title:"Wait for a first byte",desc:"How long the gateway waits for a pod\u2019s first byte before it checks the pod is alive. A service\u2019s own cluster.firstByteMs wins.",kept:"repository",applies:"gateway",kind:"number",number:{unit:"s",scale:1e3,min:1e3},default:3e4,parse:s(t=>{const e=o(t);return e!==void 0&&e>0?e:void 0},"parse")},{env:"LENSMCP_POD_RECYCLE",page:"services",section:"Recycling",...f,title:"Recycle a pod that missed a change",desc:"A pod whose watcher missed a file added or removed is replaced by a fresh one. Off: a pod keeps serving its old code until you restart it.",kept:"repository",applies:"gateway",default:"on",parse:m},{env:"LENSMCP_POD_MAX_AGE_MS",page:"services",section:"Recycling",title:"Recycle a pod older than",desc:"A pod this old is replaced even with no change seen \u2014 the one whose watcher went quiet.",kept:"repository",applies:"gateway",kind:"number",number:{unit:"h",scale:36e5,min:0,zero:"never"},default:144e5,parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_SWAP_MODE",page:"services",section:"A new build",title:"How a pod takes a new build",desc:"A fresh pod takes each new build and the old one finishes its work. In the same pod: the app is swapped inside the running process \u2014 faster, but a module that holds state can leak.",kept:"repository",applies:"service",kind:"choice",options:[{value:"process",label:"A fresh pod"},{value:"in-process",label:"In the same pod"}],default:"process",parse:s(t=>/^(in-process|inprocess|hot)$/i.test(t.trim())?"in-process":"process","parse")},{env:"LENSMCP_SWAP_DRAIN_MS",page:"services",section:"A new build",title:"Let the old app finish for",desc:"How long the previous app may finish its requests and background jobs before it is closed anyway.",kept:"repository",applies:"service",kind:"number",number:{unit:"min",scale:6e4,min:0,zero:"close at once"},default:9e5,parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_SHARED_COMPILER",page:"builds",section:"Compiling",...f,title:"One compilation for every service",desc:"The services of a checkout share one webpack compilation: a shared library is compiled once, not once per service. Off: each service has its own watcher again.",kept:"repository",applies:"service",default:"on",parse:s(t=>/^(0|off|false|no)$/i.test(t.trim())?"off":"on","parse")},{env:"LENSMCP_BUILD_HOST_IDLE_SEC",page:"builds",section:"Compiling",title:"Stop an idle build host after",desc:"How long a checkout\u2019s build host keeps running once none of its services runs.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"min",scale:60,min:0,zero:"never"},default:300,parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_DEV_DEVTOOL",page:"builds",section:"Source maps",title:"Source maps in development",desc:"eval is the fastest to build. A full source map gives exact lines in stack traces and costs build time and memory. A serve target\u2019s own devtool wins.",kept:"repository",applies:"service",kind:"choice",options:[{value:"eval",label:"eval"},{value:"eval-cheap-module-source-map",label:"eval-cheap-module-source-map"},{value:"cheap-module-source-map",label:"cheap-module-source-map"},{value:"source-map",label:"source-map"},{value:"off",label:"None"}],default:"eval",parse:s(t=>{const e=t.trim();return e?/^(false|off|none|0)$/i.test(e)?"off":/^(?:eval|(?:inline-|hidden-|eval-)?(?:nosources-)?(?:cheap-(?:module-)?)?source-map(?:-debugids)?)$/.test(e)?e:"eval":"eval"},"parse")},{env:"LENSMCP_WARM_MIN_FREE_MB",page:"worktrees",section:"Starting",title:"Start a worktree\u2019s services only with free memory",desc:"When a worktree registers, its always-warm services start one at a time, each only while the machine has this much free. The rest start on their first request.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"MB",min:0,zero:"no floor"},default:4096,parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_WORKTREE_RUN_MAX",page:"worktrees",section:"Starting",title:"On-demand worktrees running at once",desc:"At most this many on-demand worktrees run at the same time. One more is refused, naming those that run and when each parks. The main checkout does not count.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"worktrees",min:0,zero:"no cap"},default:2,parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?Math.floor(e):void 0},"parse")},{env:"LENSMCP_WORKTREE_IDLE_SEC",page:"worktrees",section:"Sleeping",title:"Stop an unused worktree service after",desc:"A worktree\u2019s service with no request for this long stops, and starts again on the next one.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"min",scale:60,min:0,zero:"never"},default:1800,parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_WORKTREE_RUN_IDLE_SEC",page:"worktrees",section:"Sleeping",title:"Park an unused on-demand worktree after",desc:"An on-demand worktree that runs is parked after this long with no request and no hold: its services, frontends and dashboard stop, and its data is kept. It runs again when asked.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"min",scale:60,min:60},default:900,parse:s(t=>{const e=o(t);return e!==void 0&&e>=60?e:void 0},"parse")},{env:"LENSMCP_DASHBOARD_IDLE_SEC",page:"worktrees",section:"Sleeping",title:"Stop an unused worktree dashboard after",desc:"A worktree\u2019s dashboard starts on its first request and stops after this long with none.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"min",scale:60,min:0,zero:"always up"},default:600,parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?e:void 0},"parse")},{env:"LENSMCP_GUEST_REPLAY",page:"worktrees",section:"After a restart",...f,title:"Host the worktrees again after a restart",desc:"A restarted gateway hosts again every worktree and workspace registered with it before. Off: each registers again when its lens starts.",kept:"machine",applies:"gateway",default:"on",parse:m},{env:"LENSMCP_GUEST_MIDDLEWARE",page:"worktrees",section:"Requests",title:"Whose middleware runs on a worktree\u2019s routes",desc:"Its own \u2014 the middleware its gateway target declares; the main checkout\u2019s, on every route; or none.",kept:"machine",applies:"gateway",kind:"choice",options:[{value:"own",label:"Its own"},{value:"owner",label:"The main checkout\u2019s"},{value:"none",label:"None"}],default:"own",parse:s(t=>t==="owner"||t==="none"?t:"own","parse")},{env:"LENSMCP_MAIN_ALWAYS_UP",page:"worktrees",section:"Main checkout",...f,title:"Keep the main checkout always up",desc:"Every main service starts when the gateway does \u2014 the always-warm ones first, then the rest one at a time while memory holds \u2014 and none stops for idleness. Off: the rest start on their first request.",kept:"machine",applies:"gateway",default:"on",parse:b},{env:"LENSMCP_GW_ACT",page:"gateway",section:"Acting as a user",...f,title:"Let agents act as a signed-in user",desc:"An agent may call the services as a user who signed in on this machine, through a ticket the gateway checks. Off: every ticket is refused.",kept:"machine",applies:"gateway",default:"on",parse:m},{env:"LENSMCP_MAX_CONNECTIONS",page:"gateway",section:"Limits",title:"Most connections at once",desc:"The front door\u2019s ceiling on open connections. Past it, new ones wait.",kept:"machine",applies:"gateway",kind:"number",number:{unit:"connections",min:0,zero:"no limit"},default:512,parse:s(t=>{const e=o(t);return e!==void 0&&e>=0?Math.floor(e):void 0},"parse")},{env:"LENSMCP_ANSWER_BUDGET_BYTES",page:"answers",section:"Size",title:"Largest answer to an agent",desc:"Every answer, and every page result_query reads, fits this. A bigger one is folded, or cut when folding is off.",kept:"repository",applies:"lens",kind:"number",number:{unit:"KB",scale:1024,min:2048,zero:"no limit (folding off)"},default:24576,parse:s(t=>{const e=o(t);return e===void 0||e<0?void 0:e===0?0:Math.max(2048,Math.floor(e))},"parse")},{env:"LENSMCP_RESULT_HANDLES_THRESHOLD_BYTES",page:"answers",section:"Size",title:"Fold answers larger than",desc:"An answer at or under this goes to the agent as it is; a larger one goes as a preview and a handle.",kept:"repository",applies:"lens",kind:"number",number:{unit:"KB",scale:1024,min:1024},default:8192,parse:s(t=>{const e=o(t);return e!==void 0&&e>=1024?Math.floor(e):void 0},"parse")}];const w=new Map(SETTINGS.map(t=>[t.env,t]));export const settingOf=s(t=>w.get(t),"settingOf"),defaultOf=s(t=>typeof t.default=="function"?t.default():t.default,"defaultOf");export function valueOf(t,e){const r=t.parse?t.parse(e):e;return r===void 0?defaultOf(t):r}l(valueOf,"valueOf"),s(valueOf,"valueOf");export function textFor(t,e){if(t.kind==="toggle")return e!=="on"&&e!=="off"?{refused:`${t.env} is on or off`}:{text:e==="on"?t.write.on:t.write.off};if(t.kind==="choice"){const a=t.options?.find(i=>i.value===e);return a?{text:a.value}:{refused:`${t.env} is one of ${t.options.map(i=>i.value).join(", ")}`}}const r=typeof e=="number"?e:typeof e=="string"&&e.trim()!==""?Number(e):NaN,n=t.number;return Number.isFinite(r)?r===0&&n.zero?{text:"0"}:n.min!==void 0&&r<n.min?{refused:`${t.env} is at least ${n.min}${n.zero?`, or 0 (${n.zero})`:""}`}:n.max!==void 0&&r>n.max?{refused:`${t.env} is at most ${n.max}`}:{text:String(r)}:{refused:`${t.env} is a number`}}l(textFor,"textFor"),s(textFor,"textFor");export const PROJECT_FILE_NAME="lensmcp.json";export function machineSettingsFile(t=process.env){return g(t.LENSMCP_HOME||R(),".lensmcp","settings.json")}l(machineSettingsFile,"machineSettingsFile"),s(machineSettingsFile,"machineSettingsFile");const k=new Map;function E(t){let e;try{const a=C(t);e=`${a.size}:${a.mtimeMs}`}catch{return k.delete(t),{}}const r=k.get(t);if(r?.stamp===e)return r.settings;const n={};try{const a=JSON.parse(y(t,"utf8"));if(a.settings&&typeof a.settings=="object"&&!Array.isArray(a.settings))for(const[i,c]of Object.entries(a.settings))w.has(i)&&(typeof c=="string"||typeof c=="number")&&(n[i]=String(c))}catch{}return k.set(t,{stamp:e,settings:n}),n}l(E,"b"),s(E,"fileSettings");export function readKeptSettings(t,e=process.env){const r=E(g(t,PROJECT_FILE_NAME)),n=E(machineSettingsFile(e)),a=s((i,c)=>Object.fromEntries(Object.entries(i).filter(([d])=>w.get(d)?.kept===c)),"pick");return{repository:a(r,"repository"),machine:a(n,"machine")}}l(readKeptSettings,"readKeptSettings"),s(readKeptSettings,"readKeptSettings");export function keptEnv(t,e=process.env){const r=readKeptSettings(t,e);return{...r.machine,...r.repository}}l(keptEnv,"keptEnv"),s(keptEnv,"keptEnv");export const KEPT_MARK="LENSMCP_KEPT_SETTINGS";const S=s(t=>new Set((t[KEPT_MARK]??"").split(",").filter(Boolean)),"markedNames");export const fromSettings=s((t,e=process.env)=>e[t]!==void 0&&S(e).has(t),"fromSettings"),DOTENV_FILES=[".env.local",".local.env",".env"];export function dotenvKeys(t){const e=new Map;for(const r of DOTENV_FILES){let n;try{n=y(g(t,r),"utf8")}catch{continue}for(const a of n.matchAll(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/gm))e.has(a[1])||e.set(a[1],r)}return e}l(dotenvKeys,"dotenvKeys"),s(dotenvKeys,"dotenvKeys");export const dotenvDeclaring=s((t,e)=>dotenvKeys(t).get(e),"dotenvDeclaring");export function withKeptSettings(t,e,r=process.env){const n={...e},a=keptEnv(t,r),i=S(e),c=dotenvKeys(t),d=[];for(const h of SETTINGS){const u=h.env;if(n[u]!==void 0&&!i.has(u))continue;const v=a[u];v===void 0||c.has(u)?delete n[u]:(n[u]=v,d.push(u))}return d.length?n[KEPT_MARK]=d.join(","):delete n[KEPT_MARK],n}l(withKeptSettings,"withKeptSettings"),s(withKeptSettings,"withKeptSettings");export function applyKeptSettings(t,e=process.env){const r=withKeptSettings(t,e,e);for(const n of[...SETTINGS.map(a=>a.env),KEPT_MARK])r[n]===void 0?delete e[n]:e[n]=r[n];return[...S(e)]}l(applyKeptSettings,"applyKeptSettings"),s(applyKeptSettings,"applyKeptSettings");export function resolveSetting(t,e,r=process.env,n=readKeptSettings(e,r)){const a=n[t.kept][t.env],i=r[t.env];return i!==void 0&&!fromSettings(t.env,r)?{value:valueOf(t,i),source:"env",envFrom:dotenvDeclaring(e,t.env)??"shell",...a!==void 0?{kept:a}:{}}:a!==void 0?{value:valueOf(t,a),source:t.kept}:{value:defaultOf(t),source:"default"}}l(resolveSetting,"resolveSetting"),s(resolveSetting,"resolveSetting");export function writeKeptSetting(t,e,r,n=process.env){const a=w.get(e);if(!a)throw new Error(`${e} is not a setting`);const i=a.kept==="repository"?g(t,PROJECT_FILE_NAME):machineSettingsFile(n);let c={},d=!0;try{const p=JSON.parse(y(i,"utf8"));if(!p||typeof p!="object"||Array.isArray(p))throw new Error(`${i} is not a JSON object \u2014 fix it by hand first`);c=p}catch(p){if(p.code!=="ENOENT")throw p instanceof SyntaxError?new Error(`${i} is not valid JSON (${p.message}) \u2014 fix it by hand first`):p;d=!1}const h=c.settings&&typeof c.settings=="object"&&!Array.isArray(c.settings)?{...c.settings}:{},u=typeof h[e]=="string"||typeof h[e]=="number"?String(h[e]):null;if(r===null?delete h[e]:h[e]=r,Object.keys(h).length?c.settings=Object.fromEntries(Object.entries(h).sort(([p],[_])=>p.localeCompare(_))):delete c.settings,!d&&!c.settings)return u;d||(c={schemaVersion:1,...c}),P(x(i),{recursive:!0});const v=`${i}.${process.pid}.tmp`;try{O(v,`${JSON.stringify(c,null,2)}
|
|
2
|
+
`),L(v,i)}catch(p){try{A(v)}catch{}throw p}return k.delete(i),u}l(writeKeptSetting,"writeKeptSetting"),s(writeKeptSetting,"writeKeptSetting");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/core",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.56",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@lensmcp/protocol-types": "1.25.
|
|
97
|
+
"@lensmcp/protocol-types": "1.25.56",
|
|
98
98
|
"tslib": "^2.3.0"
|
|
99
99
|
},
|
|
100
100
|
"license": "Apache-2.0",
|