@lensmcp/protocol-types 1.26.6 → 1.26.7

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 +1 @@
1
- "use strict";var O=Object.defineProperty;var m=(e,o)=>O(e,"name",{value:o,configurable:!0});var B=Object.defineProperty,b=m((e,o)=>B(e,"name",{value:o,configurable:!0}),"m"),I=Object.defineProperty,c=b((e,o)=>I(e,"name",{value:o,configurable:!0}),"c");import{CONTAINER_OOM as k,DOCKER_ENGINE_LOST as g,DOCKER_RUN_FIELD as N}from"./docker-jobs.js";import{joinId as E}from"./error-cause.js";const _=200,f=50,$=c(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),h=c(e=>{if(typeof e!="string")return;const o=e.trim();return o?o.slice(0,_):void 0},"name"),p=c(e=>typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0,"someMb"),C=c(e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0,"anyMb"),w=c(e=>Object.fromEntries(Object.entries(e).filter(([,o])=>o!==void 0)),"defined"),D=c(e=>{if(!$(e))return;const o=h(e.peer);if(!o)return;const n=h(e.name);return n?{peer:o,name:n}:{peer:o}},"hostOf"),M=c(e=>e.name??e.peer,"hostWord");export function readDockerError(e){if($(e)){if(e.kind===k)return w({kind:k,run:h(e.run),job:h(e.job),service:h(e.service),container:h(e.container),seen:e.seen==="event"||e.seen==="inspect"?e.seen:void 0,limitMb:p(e.limitMb),peakMb:p(e.peakMb),budgetMb:p(e.budgetMb),context:h(e.context),host:D(e.host)});if(e.kind===g){const o=new Map;for(const r of Array.isArray(e.runs)?e.runs:[]){const i=$(r)?h(r.run):h(r),t=$(r)?h(r.job):void 0;i&&!o.has(i)&&o.size<f&&o.set(i,{run:i,...t?{job:t}:{}})}const n=Array.isArray(e.killed)?[...new Set(e.killed.map(h).filter(r=>!!r))].slice(0,f):[];return w({kind:g,context:h(e.context),runs:[...o.values()],why:h(e.why),vmTotalMb:p(e.vmTotalMb),vmAvailableMb:C(e.vmAvailableMb),killed:n.length?n:void 0,host:D(e.host)})}}}m(readDockerError,"readDockerError"),b(readDockerError,"readDockerError"),c(readDockerError,"readDockerError");export function dockerErrorRuns(e){return e.kind===k?e.run?[e.run]:[]:e.runs.map(o=>o.run)}m(dockerErrorRuns,"dockerErrorRuns"),b(dockerErrorRuns,"dockerErrorRuns"),c(dockerErrorRuns,"dockerErrorRuns");export function dockerRunOfEvent(e){return $(e)?h(e[N]):void 0}m(dockerRunOfEvent,"dockerRunOfEvent"),b(dockerRunOfEvent,"dockerRunOfEvent"),c(dockerRunOfEvent,"dockerRunOfEvent");export const CONTAINER_OOM_ERROR="ContainerOOMKilled",DOCKER_ENGINE_LOST_ERROR="DockerEngineLost";const L=256,a=c(e=>`${Math.round(e)} MiB`,"mib");function x(e){const o=`${e.service??"a container"} ran out of memory in ${e.job??"a Docker job"}`,n=`${e.service?`\xAB${e.service}\xBB`:"A container"} ran out of memory and was killed, in ${e.job?`the Docker job \xAB${e.job}\xBB`:"a Docker job"}${e.host?` on the worker \xAB${M(e.host)}\xBB`:""}`,r=e.job?`\`${e.budgetMb!==void 0&&e.service?`jobs.${e.job}.budget.services.${e.service}`:`jobs.${e.job}.budget`}\` in lensmcp.json`:"its job's budget in lensmcp.json \u2192 jobs",{limitMb:i,peakMb:t,budgetMb:s}=e;let l;if(i!==void 0&&s!==void 0){const d=Math.round(i)-Math.round(s);l=d>0?`It was killed at its ${a(i)} limit \u2014 ${a(d)} over the ${a(s)} it declares. Raise ${r} to what it takes (more than ${a(i)}), and the container's memory limit with it.`:d===0?`It was killed at its ${a(i)} limit, which is all it declares. Raise ${r} to what it takes, and the container's memory limit with it.`:`It was killed at its ${a(i)} limit, ${a(-d)} under the ${a(s)} it declares. Raise the container's memory limit to its budget (${r}) \u2014 and both, if it takes more.`}else if(i!==void 0)l=`It was killed at its ${a(i)} limit. Raise the limit, and ${r}, to what it takes.`;else if(t!==void 0&&s!==void 0){const d=Math.round(t)-Math.round(s);l=d>0?`It held ${a(t)} at its peak \u2014 ${a(d)} over the ${a(s)} it declares. Raise ${r} to what it takes, so the queue lets the job in only when Docker's VM has that much.`:`It held ${a(t)} at its peak, within the ${a(s)} it declares (${r}): it was killed at a lower limit of its own, or when Docker's VM ran out. Check its memory limit in the compose file, and what else the VM held.`}else t!==void 0?l=`It held ${a(t)} at its peak. Check ${r} against that, and the container's memory limit.`:s!==void 0?l=`Its peak was not sampled. It declares ${a(s)}: raise ${r} to what it takes, and the container's memory limit with it.`:l=`Raise ${r} to what the service takes, and the container's memory limit with it.`;const u=[i!==void 0?`killed at its ${a(i)} limit`:"killed for memory",t!==void 0?`peak ${a(t)}`:void 0,s!==void 0?`budget ${a(s)}`:void 0,e.run?`run ${e.run}`:void 0,e.seen==="inspect"?"found by the inspect at the run's end":void 0,e.host?`on the worker ${M(e.host)}`:void 0,e.context?`Docker context ${e.context}`:void 0];return{cause:{id:E("cause",[CONTAINER_OOM_ERROR,e.job,e.service]),errorName:CONTAINER_OOM_ERROR,message:o},title:`${CONTAINER_OOM_ERROR}: ${o}`,headline:n,hint:l,facts:u.filter(Boolean).join(" \xB7 "),where:e.job?`Docker job ${e.job}`:"Docker"}}m(x,"y"),b(x,"A"),c(x,"oomWords");function y(e){const o=e.host?` on the worker ${M(e.host)}`:"",n=`Docker stopped answering${e.context?` (context ${e.context})`:""}${o}`,r=[...new Set(e.runs.map(v=>v.job).filter(v=>!!v))],i=e.runs.length,t=e.host?`Docker on the worker \xAB${M(e.host)}\xBB`:"Docker",s=i===0?`${t} stopped answering while LensMCP ran work in it`:i===1?`${t} stopped answering while ${r[0]?`the job \xAB${r[0]}\xBB`:"a job"} ran: its containers went with it`:`${t} stopped answering while ${i} runs were in it${r.length?` (${r.map(v=>`\xAB${v}\xBB`).join(", ")})`:""}: their containers went with it`,{vmTotalMb:l,vmAvailableMb:u}=e,d=u===void 0?void 0:`${a(u)} free${l!==void 0?` of ${a(l)}`:""}`,j=u===void 0?"If nobody stopped it, its VM most likely ran out of memory: compare the jobs' budgets in lensmcp.json with what Docker's VM has.":u<=L?`Its VM had ${d} when it was last read: it most likely ran out of memory. Let less in at once (the jobs' budgets in lensmcp.json decide), or give Docker's VM more.`:`Its VM had ${d} when it was last read, so memory is not the likely reason: was Docker stopped or restarted?`,A=[i?`${i} run${i===1?"":"s"} lost: ${e.runs.map(v=>`${v.job??"a job"} (run ${v.run})`).join(", ")}`:void 0,e.why,d?`VM ${d}`:void 0,e.killed?.length?`killed for memory before it went: ${e.killed.join(", ")}`:void 0];return{cause:{id:E("cause",e.host?[DOCKER_ENGINE_LOST_ERROR,e.context,e.host.peer]:[DOCKER_ENGINE_LOST_ERROR,e.context]),errorName:DOCKER_ENGINE_LOST_ERROR,message:n},title:`${DOCKER_ENGINE_LOST_ERROR}: ${n}`,headline:s,hint:`Start Docker again${o} and run ${i>1?"the jobs":"the job"} again: a run lost with the engine has no result. ${j}`,facts:A.filter(Boolean).join(" \xB7 "),where:`${e.context?`Docker context ${e.context}`:"Docker"}${o}`}}m(y,"E"),b(y,"I"),c(y,"engineWords");export function dockerErrorWords(e){return e.kind===k?x(e):y(e)}m(dockerErrorWords,"dockerErrorWords"),b(dockerErrorWords,"dockerErrorWords"),c(dockerErrorWords,"dockerErrorWords");export function mergeDockerError(e,o){if(e.kind===k){if(o.kind!==k)return e;const t=Math.max(e.peakMb??0,o.peakMb??0);return w({...o,...e,seen:e.seen==="event"||o.seen==="event"?"event":e.seen??o.seen,peakMb:t>0?t:void 0})}const n=e;if(o.kind===k)return o.service&&!n.killed?.includes(o.service)?{...n,killed:[...n.killed??[],o.service].slice(0,f)}:e;const r=new Map(n.runs.map(t=>[t.run,t]));for(const t of o.runs)(!r.has(t.run)||!r.get(t.run).job&&t.job)&&r.set(t.run,t);const i=[...new Set([...n.killed??[],...o.killed??[]])];return w({...o,...n,runs:[...r.values()].slice(0,f),vmAvailableMb:n.vmAvailableMb!==void 0&&o.vmAvailableMb!==void 0?Math.min(n.vmAvailableMb,o.vmAvailableMb):n.vmAvailableMb??o.vmAvailableMb,killed:i.length?i:void 0})}m(mergeDockerError,"mergeDockerError"),b(mergeDockerError,"mergeDockerError"),c(mergeDockerError,"mergeDockerError");export const DOCKER_ENGINE_LOSS_SAME_MS=6e4;const R=2e3,S=200;export class DockerErrorLedger{static{m(this,"DockerErrorLedger")}static{b(this,"DockerErrorLedger")}static{c(this,"DockerErrorLedger")}constructor(){this.kills=new Map,this.losses=new Map,this.lostRuns=new Map}account(o,n,r){if(o.kind===g){const l=o.host?`${o.host.peer}\0${o.context??""}`:o.context??"",u=this.losses.get(l),d=u&&Math.abs(r-u.at)<=DOCKER_ENGINE_LOSS_SAME_MS?u.told:void 0;d||this.remember(this.losses,l,{told:n,at:r},S);for(const j of o.runs)this.remember(this.lostRuns,j.run,d??n,R);return d}const i=o.seen!=="inspect",t=o.run&&o.container?`${o.run}\0${o.container}`:o.run&&o.service?`${o.run}\0\0${o.service}`:void 0,s=t?this.kills.get(t):void 0;if(!s){const l=!i&&o.run?this.lostRuns.get(o.run):void 0;if(l)return l;t&&this.remember(this.kills,t,{told:n,live:i?1:0},R);return}if(!i)return s.told;if(s.live===0)return s.live=1,s.told;s.live+=1,s.told=n}remember(o,n,r,i){o.delete(n),o.set(n,r),o.size>i&&o.delete(o.keys().next().value)}}
1
+ "use strict";var I=Object.defineProperty;var m=(e,r)=>I(e,"name",{value:r,configurable:!0});var N=Object.defineProperty,k=m((e,r)=>N(e,"name",{value:r,configurable:!0}),"m"),_=Object.defineProperty,b=k((e,r)=>_(e,"name",{value:r,configurable:!0}),"m"),L=Object.defineProperty,v=b((e,r)=>L(e,"name",{value:r,configurable:!0}),"m"),C=Object.defineProperty,d=v((e,r)=>C(e,"name",{value:r,configurable:!0}),"c");import{CONTAINER_OOM as f,DOCKER_ENGINE_LOST as D,DOCKER_RUN_FIELD as S}from"./docker-jobs.js";import{joinId as R}from"./error-cause.js";const V=200,j=50,p=d(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),u=d(e=>{if(typeof e!="string")return;const r=e.trim();return r?r.slice(0,V):void 0},"name"),E=d(e=>typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0,"someMb"),T=d(e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0,"anyMb"),g=d(e=>Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0)),"defined"),O=d(e=>{if(!p(e))return;const r=u(e.peer);if(!r)return;const n=u(e.name);return n?{peer:r,name:n}:{peer:r}},"hostOf"),x=d(e=>e.name??e.peer,"hostWord");export function readDockerError(e){if(p(e)){if(e.kind===f)return g({kind:f,run:u(e.run),job:u(e.job),service:u(e.service),container:u(e.container),seen:e.seen==="event"||e.seen==="inspect"?e.seen:void 0,limitMb:E(e.limitMb),peakMb:E(e.peakMb),budgetMb:E(e.budgetMb),context:u(e.context),host:O(e.host)});if(e.kind===D){const r=new Map;for(const t of Array.isArray(e.runs)?e.runs:[]){const o=p(t)?u(t.run):u(t),i=p(t)?u(t.job):void 0;o&&!r.has(o)&&r.size<j&&r.set(o,{run:o,...i?{job:i}:{}})}const n=Array.isArray(e.killed)?[...new Set(e.killed.map(u).filter(t=>!!t))].slice(0,j):[];return g({kind:D,context:u(e.context),runs:[...r.values()],why:u(e.why),vmTotalMb:E(e.vmTotalMb),vmAvailableMb:T(e.vmAvailableMb),killed:n.length?n:void 0,host:O(e.host)})}}}m(readDockerError,"readDockerError"),k(readDockerError,"readDockerError"),b(readDockerError,"readDockerError"),v(readDockerError,"readDockerError"),d(readDockerError,"readDockerError");export function dockerErrorRuns(e){return e.kind===f?e.run?[e.run]:[]:e.runs.map(r=>r.run)}m(dockerErrorRuns,"dockerErrorRuns"),k(dockerErrorRuns,"dockerErrorRuns"),b(dockerErrorRuns,"dockerErrorRuns"),v(dockerErrorRuns,"dockerErrorRuns"),d(dockerErrorRuns,"dockerErrorRuns");export function dockerRunOfEvent(e){return p(e)?u(e[S]):void 0}m(dockerRunOfEvent,"dockerRunOfEvent"),k(dockerRunOfEvent,"dockerRunOfEvent"),b(dockerRunOfEvent,"dockerRunOfEvent"),v(dockerRunOfEvent,"dockerRunOfEvent"),d(dockerRunOfEvent,"dockerRunOfEvent");export const CONTAINER_OOM_ERROR="ContainerOOMKilled",DOCKER_ENGINE_LOST_ERROR="DockerEngineLost";const W=256,a=d(e=>`${Math.round(e)} MiB`,"mib");function w(e){const r=`${e.service??"a container"} ran out of memory in ${e.job??"a Docker job"}`,n=`${e.service?`\xAB${e.service}\xBB`:"A container"} ran out of memory and was killed, in ${e.job?`the Docker job \xAB${e.job}\xBB`:"a Docker job"}${e.host?` on the worker \xAB${x(e.host)}\xBB`:""}`,t=e.job?`\`${e.budgetMb!==void 0&&e.service?`jobs.${e.job}.budget.services.${e.service}`:`jobs.${e.job}.budget`}\` in lensmcp.json`:"its job's budget in lensmcp.json \u2192 jobs",{limitMb:o,peakMb:i,budgetMb:s}=e;let l;if(o!==void 0&&s!==void 0){const c=Math.round(o)-Math.round(s);l=c>0?`It was killed at its ${a(o)} limit \u2014 ${a(c)} over the ${a(s)} it declares. Raise ${t} to what it takes (more than ${a(o)}), and the container's memory limit with it.`:c===0?`It was killed at its ${a(o)} limit, which is all it declares. Raise ${t} to what it takes, and the container's memory limit with it.`:`It was killed at its ${a(o)} limit, ${a(-c)} under the ${a(s)} it declares. Raise the container's memory limit to its budget (${t}) \u2014 and both, if it takes more.`}else if(o!==void 0)l=`It was killed at its ${a(o)} limit. Raise the limit, and ${t}, to what it takes.`;else if(i!==void 0&&s!==void 0){const c=Math.round(i)-Math.round(s);l=c>0?`It held ${a(i)} at its peak \u2014 ${a(c)} over the ${a(s)} it declares. Raise ${t} to what it takes, so the queue lets the job in only when Docker's VM has that much.`:`It held ${a(i)} at its peak, within the ${a(s)} it declares (${t}): it was killed at a lower limit of its own, or when Docker's VM ran out. Check its memory limit in the compose file, and what else the VM held.`}else i!==void 0?l=`It held ${a(i)} at its peak. Check ${t} against that, and the container's memory limit.`:s!==void 0?l=`Its peak was not sampled. It declares ${a(s)}: raise ${t} to what it takes, and the container's memory limit with it.`:l=`Raise ${t} to what the service takes, and the container's memory limit with it.`;const h=[o!==void 0?`killed at its ${a(o)} limit`:"killed for memory",i!==void 0?`peak ${a(i)}`:void 0,s!==void 0?`budget ${a(s)}`:void 0,e.run?`run ${e.run}`:void 0,e.seen==="inspect"?"found by the inspect at the run's end":void 0,e.host?`on the worker ${x(e.host)}`:void 0,e.context?`Docker context ${e.context}`:void 0];return{cause:{id:R("cause",[CONTAINER_OOM_ERROR,e.job,e.service]),errorName:CONTAINER_OOM_ERROR,message:r},title:`${CONTAINER_OOM_ERROR}: ${r}`,headline:n,hint:l,facts:h.filter(Boolean).join(" \xB7 "),where:e.job?`Docker job ${e.job}`:"Docker"}}m(w,"g"),k(w,"x"),b(w,"y"),v(w,"A"),d(w,"oomWords");function M(e){const r=e.host?` on the worker ${x(e.host)}`:"",n=`Docker stopped answering${e.context?` (context ${e.context})`:""}${r}`,t=[...new Set(e.runs.map($=>$.job).filter($=>!!$))],o=e.runs.length,i=e.host?`Docker on the worker \xAB${x(e.host)}\xBB`:"Docker",s=o===0?`${i} stopped answering while LensMCP ran work in it`:o===1?`${i} stopped answering while ${t[0]?`the job \xAB${t[0]}\xBB`:"a job"} ran: its containers went with it`:`${i} stopped answering while ${o} runs were in it${t.length?` (${t.map($=>`\xAB${$}\xBB`).join(", ")})`:""}: their containers went with it`,{vmTotalMb:l,vmAvailableMb:h}=e,c=h===void 0?void 0:`${a(h)} free${l!==void 0?` of ${a(l)}`:""}`,y=h===void 0?"If nobody stopped it, its VM most likely ran out of memory: compare the jobs' budgets in lensmcp.json with what Docker's VM has.":h<=W?`Its VM had ${c} when it was last read: it most likely ran out of memory. Let less in at once (the jobs' budgets in lensmcp.json decide), or give Docker's VM more.`:`Its VM had ${c} when it was last read, so memory is not the likely reason: was Docker stopped or restarted?`,B=[o?`${o} run${o===1?"":"s"} lost: ${e.runs.map($=>`${$.job??"a job"} (run ${$.run})`).join(", ")}`:void 0,e.why,c?`VM ${c}`:void 0,e.killed?.length?`killed for memory before it went: ${e.killed.join(", ")}`:void 0];return{cause:{id:R("cause",e.host?[DOCKER_ENGINE_LOST_ERROR,e.context,e.host.peer]:[DOCKER_ENGINE_LOST_ERROR,e.context]),errorName:DOCKER_ENGINE_LOST_ERROR,message:n},title:`${DOCKER_ENGINE_LOST_ERROR}: ${n}`,headline:s,hint:`Start Docker again${r} and run ${o>1?"the jobs":"the job"} again: a run lost with the engine has no result. ${y}`,facts:B.filter(Boolean).join(" \xB7 "),where:`${e.context?`Docker context ${e.context}`:"Docker"}${r}`}}m(M,"E"),k(M,"y"),b(M,"E"),v(M,"I"),d(M,"engineWords");export function dockerErrorWords(e){return e.kind===f?w(e):M(e)}m(dockerErrorWords,"dockerErrorWords"),k(dockerErrorWords,"dockerErrorWords"),b(dockerErrorWords,"dockerErrorWords"),v(dockerErrorWords,"dockerErrorWords"),d(dockerErrorWords,"dockerErrorWords");export function mergeDockerError(e,r){if(e.kind===f){if(r.kind!==f)return e;const i=Math.max(e.peakMb??0,r.peakMb??0);return g({...r,...e,seen:e.seen==="event"||r.seen==="event"?"event":e.seen??r.seen,peakMb:i>0?i:void 0})}const n=e;if(r.kind===f)return r.service&&!n.killed?.includes(r.service)?{...n,killed:[...n.killed??[],r.service].slice(0,j)}:e;const t=new Map(n.runs.map(i=>[i.run,i]));for(const i of r.runs)(!t.has(i.run)||!t.get(i.run).job&&i.job)&&t.set(i.run,i);const o=[...new Set([...n.killed??[],...r.killed??[]])];return g({...r,...n,runs:[...t.values()].slice(0,j),vmAvailableMb:n.vmAvailableMb!==void 0&&r.vmAvailableMb!==void 0?Math.min(n.vmAvailableMb,r.vmAvailableMb):n.vmAvailableMb??r.vmAvailableMb,killed:o.length?o:void 0})}m(mergeDockerError,"mergeDockerError"),k(mergeDockerError,"mergeDockerError"),b(mergeDockerError,"mergeDockerError"),v(mergeDockerError,"mergeDockerError"),d(mergeDockerError,"mergeDockerError");export const DOCKER_ENGINE_LOSS_SAME_MS=6e4;const A=2e3,K=200;export class DockerErrorLedger{static{m(this,"DockerErrorLedger")}static{k(this,"DockerErrorLedger")}static{b(this,"DockerErrorLedger")}static{v(this,"DockerErrorLedger")}static{d(this,"DockerErrorLedger")}constructor(){this.kills=new Map,this.losses=new Map,this.lostRuns=new Map}account(r,n,t){if(r.kind===D){const l=r.host?`${r.host.peer}\0${r.context??""}`:r.context??"",h=this.losses.get(l),c=h&&Math.abs(t-h.at)<=DOCKER_ENGINE_LOSS_SAME_MS?h.told:void 0;c||this.remember(this.losses,l,{told:n,at:t},K);for(const y of r.runs)this.remember(this.lostRuns,y.run,c??n,A);return c}const o=r.seen!=="inspect",i=r.run&&r.container?`${r.run}\0${r.container}`:r.run&&r.service?`${r.run}\0\0${r.service}`:void 0,s=i?this.kills.get(i):void 0;if(!s){const l=!o&&r.run?this.lostRuns.get(r.run):void 0;if(l)return l;i&&this.remember(this.kills,i,{told:n,live:o?1:0},A);return}if(!o)return s.told;if(s.live===0)return s.live=1,s.told;s.live+=1,s.told=n}remember(r,n,t,o){r.delete(n),r.set(n,t),r.size>o&&r.delete(r.keys().next().value)}}
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var a=(e,s)=>w(e,"name",{value:s,configurable:!0});var O=Object.defineProperty,c=a((e,s)=>O(e,"name",{value:s,configurable:!0}),"a"),L=Object.defineProperty,n=c((e,s)=>L(e,"name",{value:s,configurable:!0}),"i");export const DOCKER_LABELS={run:"com.lensmcp.run",home:"com.lensmcp.home",job:"com.lensmcp.job",probe:"com.lensmcp.probe"},LENS_JOB_KINDS=["compose","testcontainers","playwright"];export function neverShipped(e){const s=(e.split("/").at(-1)??"").toLowerCase();return s===".env"||s===".env.local"||/^\.env\..+\.local$/.test(s)}a(neverShipped,"neverShipped"),c(neverShipped,"neverShipped"),n(neverShipped,"neverShipped");export const jobInputFiles=n(e=>[...new Set(e.inputs?.files??[])].sort(),"jobInputFiles"),jobMintedFiles=n(e=>[...new Set(e.inputs?.minted??[])].sort(),"jobMintedFiles"),jobProblemText=n(e=>e.job===void 0?e.problem:`jobs.${e.job}: ${e.problem}`,"jobProblemText");const y=["kind","lane","prepare","command","cleanup","report","artifacts","inputs","timeoutMinutes","retryable","nx","budget"],$={compose:[...y,"compose"],testcontainers:y,playwright:[...y,"stack"]},_={compose:["services","buildMb","hostMb"],testcontainers:["vmMb","hostMb"],playwright:["hostMb","vmMb"]},N=/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/,R=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,j=1024*1024,S=360,h=100,x=4e3,d=n(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),A=n(e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=j,"isMb"),C=n(e=>e.map(s=>`"${s}"`).join(", "),"quoted");function m(e){return typeof e!="string"||!e||e.length>500||/[\0\\]/.test(e)||e.startsWith("/")||e.startsWith("~")||/^[A-Za-z]:/.test(e)?!1:!e.split("/").includes("..")}a(m,"m"),c(m,"b"),n(m,"inTree");function f(e){return Array.isArray(e)&&e.length>=1&&e.length<=h&&e.every(s=>typeof s=="string"&&s.length<=x)&&e[0]!==""}a(f,"f"),c(f,"g"),n(f,"isArgv");function l(e,s,t,o){const r=Object.keys(e).filter(i=>!s.includes(i));r.length&&o.push(`${t?`${t} has`:"has"} ${r.length===1?"an unknown key":"unknown keys"} ${C(r)}`)}a(l,"h"),c(l,"f"),n(l,"unknownKeys");function M(e,s,t){e!==void 0&&(!Array.isArray(e)||e.length>h||!e.every(m))&&t.push(`${s} is a list of paths inside the checkout`)}a(M,"A"),c(M,"R"),n(M,"paths");function v(e,s,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>h||!e.every(m))return t.push(`${s} is a list of paths inside the checkout`),[];for(const o of e){const r=o.split("/");r.some(i=>i===""||i===".")?t.push(`${s} names ${JSON.stringify(o)}: a file is written as git names it \u2014 a/b.json, with no ./, no // and no trailing /`):r.some(i=>i.toLowerCase()===".git")&&t.push(`${s} names ${JSON.stringify(o)}, which is inside git's own folder`)}return e}a(v,"y"),c(v,"A"),n(v,"inputPaths");function k(e){if(!d(e))return["is not an object"];const s=e.kind;if(!LENS_JOB_KINDS.includes(s))return[`kind is ${LENS_JOB_KINDS.slice(0,-1).join(", ")} or ${LENS_JOB_KINDS.at(-1)}`];const t=[];l(e,$[s],"",t),e.lane!==void 0&&e.lane!=="light"&&e.lane!=="heavy"&&t.push("lane is light or heavy"),f(e.command)||t.push("command is a program and its arguments, as a list of strings \u2014 not a shell line"),e.cleanup!==void 0&&!f(e.cleanup)&&t.push("cleanup is a program and its arguments, as a list of strings"),e.prepare!==void 0&&!(Array.isArray(e.prepare)&&e.prepare.length<=h&&e.prepare.every(f))&&t.push("prepare is a list of steps, each a program and its arguments"),e.report!==void 0&&!["jest","vitest","playwright"].includes(e.report)&&t.push("report is jest, vitest or playwright"),M(e.artifacts,"artifacts",t),e.timeoutMinutes!==void 0&&!(typeof e.timeoutMinutes=="number"&&e.timeoutMinutes>0&&e.timeoutMinutes<=S)&&t.push(`timeoutMinutes is execution minutes, up to ${S}`),e.retryable!==void 0&&typeof e.retryable!="boolean"&&t.push("retryable is true or false"),e.nx!==void 0&&!(typeof e.nx=="string"&&/^\S+:[^\s:]+$/.test(e.nx))&&t.push("nx is <project>:<target>");const o=e.inputs;if(o!==void 0)if(!d(o))t.push("inputs is an object of files, minted and secrets");else{l(o,["files","minted","secrets"],"inputs",t);const i=v(o.files,"inputs.files",t),p=v(o.minted,"inputs.minted",t);for(const b of i)neverShipped(b)&&t.push(`inputs.files names ${b}, which is never shipped to another Mac \u2014 declare it in inputs.minted, and make it in a prepare step`);const u=[...new Set(i.filter(b=>p.includes(b)))];u.length&&t.push(`inputs names ${u.join(", ")} in files and in minted: a file is shipped by hash, or made per run on the host that runs it \u2014 not both`);const g=o.secrets;g!==void 0&&!(Array.isArray(g)&&g.length<=h&&g.every(b=>typeof b=="string"&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(b)))&&t.push("inputs.secrets is a list of variable names, never values")}const r=e.budget;if(!d(r))t.push("has no budget: the memory it declares is what it is admitted by");else{l(r,_[s],"budget",t);for(const i of["buildMb","hostMb","vmMb"])_[s].includes(i)&&r[i]!==void 0&&!A(r[i])&&t.push(`budget.${i} is MiB, a whole number from 1 to ${j}`);if(s==="testcontainers"&&(r.vmMb===void 0||r.hostMb===void 0)&&t.push("budget needs vmMb (its containers, in Docker's VM) and hostMb (the test runner, on the host)"),s==="playwright"&&r.vmMb===void 0&&r.hostMb===void 0&&t.push("budget needs hostMb or vmMb: where its browsers run"),s==="compose"){const i=r.services;if(!d(i)||!Object.keys(i).length)t.push("budget.services is each service's expected peak, MiB, by its name in the compose files");else for(const[p,u]of Object.entries(i))R.test(p)?A(u)||t.push(`budget.services.${p} is MiB, a whole number from 1 to ${j}`):t.push(`budget.services has "${p}", which is no service name`)}}if(s==="compose"){const i=e.compose;if(!d(i))t.push("compose is an object of files and edge");else{l(i,["files","edge"],"compose",t);const p=i.files;(!Array.isArray(p)||!p.length||p.length>h||!p.every(m))&&t.push("compose.files is the compose files, as paths inside the checkout");const u=i.edge;u!==void 0&&(!d(u)||typeof u.service!="string"||!R.test(u.service)||!Number.isInteger(u.port)||u.port<1||u.port>65535?t.push('compose.edge is the service and the container port its URL reaches: { "service": "edge", "port": 8443 }'):(l(u,["service","port"],"compose.edge",t),d(r)&&d(r.services)&&!Object.hasOwn(r.services,u.service)&&t.push(`${u.service} has no budget`)))}}return s==="playwright"&&e.stack!==void 0&&!(typeof e.stack=="string"&&N.test(e.stack))&&t.push("stack is the name of a compose job of this file"),t}a(k,"E"),c(k,"j"),n(k,"jobProblems");export function readLensJobs(e){const s={jobs:{},problems:[]};if(e===void 0)return s;if(!d(e))return s.problems.push({problem:"jobs is an object of jobs by name"}),s;for(const[t,o]of Object.entries(e)){if(!N.test(t)){s.problems.push({job:t,problem:"a job's name is letters, digits, dots, dashes and underscores \u2014 63 at most, the first a letter or a digit"});continue}const r=k(o);r.length?s.problems.push(...r.map(i=>({job:t,problem:i}))):s.jobs[t]=o}for(const[t,o]of Object.entries(s.jobs))o.kind!=="playwright"||o.stack===void 0||s.jobs[o.stack]?.kind!=="compose"&&(s.problems.push({job:t,problem:`stack names "${o.stack}", which is no compose job of this file that may run`}),delete s.jobs[t]);return s}a(readLensJobs,"readLensJobs"),c(readLensJobs,"readLensJobs"),n(readLensJobs,"readLensJobs");const E=n(e=>Object.values(e).reduce((s,t)=>s+t,0),"sum");export function jobVmNeedMb(e,s={}){if(e.kind==="compose")return Math.max(e.budget.buildMb??0,E(e.budget.services));if(e.kind==="testcontainers")return e.budget.vmMb;const t=e.budget.vmMb??0,o=e.stack===void 0?void 0:s[e.stack];return o?.kind==="compose"?Math.max(o.budget.buildMb??0,E(o.budget.services)+t):t}a(jobVmNeedMb,"jobVmNeedMb"),c(jobVmNeedMb,"jobVmNeedMb"),n(jobVmNeedMb,"jobVmNeedMb");export function jobHostNeedMb(e,s={}){const t=e.budget.hostMb??0,o=e.kind==="playwright"&&e.stack!==void 0?s[e.stack]:void 0;return t+(o?.kind==="compose"?o.budget.hostMb??0:0)}a(jobHostNeedMb,"jobHostNeedMb"),c(jobHostNeedMb,"jobHostNeedMb"),n(jobHostNeedMb,"jobHostNeedMb");export function jobLane(e){return e.lane?e.lane:e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"heavy":"light"}a(jobLane,"jobLane"),c(jobLane,"jobLane"),n(jobLane,"jobLane");export function unbudgetedServices(e,s){return[...new Set(s)].filter(t=>!Object.hasOwn(e.budget.services,t)).sort()}a(unbudgetedServices,"unbudgetedServices"),c(unbudgetedServices,"unbudgetedServices"),n(unbudgetedServices,"unbudgetedServices");export const RUN_ID_PATTERN=/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/;export function runShortId(e){const s=e.toLowerCase().replace(/^[a-z]+_/,"").replace(/[^a-z0-9]/g,"").slice(0,8);return s.length===8?s:void 0}a(runShortId,"runShortId"),c(runShortId,"runShortId"),n(runShortId,"runShortId");export const composeProjectOf=n(e=>`lensmcp-${e}`,"composeProjectOf"),DOCKER_RUN_ENV={id:"LENSMCP_RUN_ID",origin:"LENSMCP_RUN_ORIGIN",artifacts:"LENSMCP_RUN_ARTIFACTS",labels:"LENSMCP_RUN_LABELS",override:"LENSMCP_COMPOSE_OVERRIDE",project:"COMPOSE_PROJECT_NAME"};export function dockerRunLabels(e){return{[DOCKER_LABELS.run]:e.id,[DOCKER_LABELS.home]:e.home,[DOCKER_LABELS.job]:e.job}}a(dockerRunLabels,"dockerRunLabels"),c(dockerRunLabels,"dockerRunLabels"),n(dockerRunLabels,"dockerRunLabels");export const runLabelsEnv=n(e=>JSON.stringify(e),"runLabelsEnv");export function jobRunScope(e){return e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"stack":jobVmNeedMb(e)>0?"containers":"none"}a(jobRunScope,"jobRunScope"),c(jobRunScope,"jobRunScope"),n(jobRunScope,"jobRunScope");export const RYUK_DISABLED_ENV="TESTCONTAINERS_RYUK_DISABLED",RYUK_LABEL="org.testcontainers.ryuk";export function ryukWarning(e,s){const t=s[RYUK_DISABLED_ENV];if(!(e.kind!=="testcontainers"||t===void 0||t.trim().toLowerCase()!=="true"))return`${RYUK_DISABLED_ENV}=${t.trim()} is set in the job's environment: testcontainers' own reaper (Ryuk) is off, so a container the suite leaves is removed only where it carries the run's labels \u2014 hand ${DOCKER_RUN_ENV.labels} to every container it starts. One that does not carry them stays in Docker's VM: LensMCP never removes it, and nothing else does.`}a(ryukWarning,"ryukWarning"),c(ryukWarning,"ryukWarning"),n(ryukWarning,"ryukWarning");export const MAX_RUN_ROUTE_SEC=14400,DOCKER_RUN_ENDS=["passed","failed","cancelled","timeout","errored","lost"],dockerRunEnded=n(e=>DOCKER_RUN_ENDS.includes(e),"dockerRunEnded"),MAX_RUN_STRANGERS=20,MAX_RUN_KILLS=100,CONTAINER_OOM="container-oom",DOCKER_ENGINE_LOST="docker-engine-lost",DOCKER_RUN_FIELD="dockerRun";
1
+ "use strict";var w=Object.defineProperty;var a=(e,s)=>w(e,"name",{value:s,configurable:!0});var $=Object.defineProperty,c=a((e,s)=>$(e,"name",{value:s,configurable:!0}),"a"),x=Object.defineProperty,u=c((e,s)=>x(e,"name",{value:s,configurable:!0}),"a"),I=Object.defineProperty,p=u((e,s)=>I(e,"name",{value:s,configurable:!0}),"a"),C=Object.defineProperty,n=p((e,s)=>C(e,"name",{value:s,configurable:!0}),"i");export const DOCKER_LABELS={run:"com.lensmcp.run",home:"com.lensmcp.home",job:"com.lensmcp.job",probe:"com.lensmcp.probe"},LENS_JOB_KINDS=["compose","testcontainers","playwright"];export function neverShipped(e){const s=(e.split("/").at(-1)??"").toLowerCase();return s===".env"||s===".env.local"||/^\.env\..+\.local$/.test(s)}a(neverShipped,"neverShipped"),c(neverShipped,"neverShipped"),u(neverShipped,"neverShipped"),p(neverShipped,"neverShipped"),n(neverShipped,"neverShipped");export const jobInputFiles=n(e=>[...new Set(e.inputs?.files??[])].sort(),"jobInputFiles"),jobMintedFiles=n(e=>[...new Set(e.inputs?.minted??[])].sort(),"jobMintedFiles"),jobProblemText=n(e=>e.job===void 0?e.problem:`jobs.${e.job}: ${e.problem}`,"jobProblemText");const S=["kind","lane","prepare","command","cleanup","report","artifacts","inputs","timeoutMinutes","retryable","nx","budget"],P={compose:[...S,"compose"],testcontainers:S,playwright:[...S,"stack"]},R={compose:["services","buildMb","hostMb"],testcontainers:["vmMb","hostMb"],playwright:["hostMb","vmMb"]},_=/^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/,A=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,N=1024*1024,L=360,g=100,D=4e3,l=n(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObj"),E=n(e=>typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=N,"isMb"),U=n(e=>e.map(s=>`"${s}"`).join(", "),"quoted");function f(e){return typeof e!="string"||!e||e.length>500||/[\0\\]/.test(e)||e.startsWith("/")||e.startsWith("~")||/^[A-Za-z]:/.test(e)?!1:!e.split("/").includes("..")}a(f,"f"),c(f,"m"),u(f,"m"),p(f,"b"),n(f,"inTree");function v(e){return Array.isArray(e)&&e.length>=1&&e.length<=g&&e.every(s=>typeof s=="string"&&s.length<=D)&&e[0]!==""}a(v,"g"),c(v,"f"),u(v,"f"),p(v,"g"),n(v,"isArgv");function h(e,s,t,o){const i=Object.keys(e).filter(r=>!s.includes(r));i.length&&o.push(`${t?`${t} has`:"has"} ${i.length===1?"an unknown key":"unknown keys"} ${U(i)}`)}a(h,"l"),c(h,"l"),u(h,"h"),p(h,"f"),n(h,"unknownKeys");function j(e,s,t){e!==void 0&&(!Array.isArray(e)||e.length>g||!e.every(f))&&t.push(`${s} is a list of paths inside the checkout`)}a(j,"j"),c(j,"M"),u(j,"A"),p(j,"R"),n(j,"paths");function y(e,s,t){if(e===void 0)return[];if(!Array.isArray(e)||e.length>g||!e.every(f))return t.push(`${s} is a list of paths inside the checkout`),[];for(const o of e){const i=o.split("/");i.some(r=>r===""||r===".")?t.push(`${s} names ${JSON.stringify(o)}: a file is written as git names it \u2014 a/b.json, with no ./, no // and no trailing /`):i.some(r=>r.toLowerCase()===".git")&&t.push(`${s} names ${JSON.stringify(o)}, which is inside git's own folder`)}return e}a(y,"v"),c(y,"v"),u(y,"y"),p(y,"A"),n(y,"inputPaths");function M(e){if(!l(e))return["is not an object"];const s=e.kind;if(!LENS_JOB_KINDS.includes(s))return[`kind is ${LENS_JOB_KINDS.slice(0,-1).join(", ")} or ${LENS_JOB_KINDS.at(-1)}`];const t=[];h(e,P[s],"",t),e.lane!==void 0&&e.lane!=="light"&&e.lane!=="heavy"&&t.push("lane is light or heavy"),v(e.command)||t.push("command is a program and its arguments, as a list of strings \u2014 not a shell line"),e.cleanup!==void 0&&!v(e.cleanup)&&t.push("cleanup is a program and its arguments, as a list of strings"),e.prepare!==void 0&&!(Array.isArray(e.prepare)&&e.prepare.length<=g&&e.prepare.every(v))&&t.push("prepare is a list of steps, each a program and its arguments"),e.report!==void 0&&!["jest","vitest","playwright"].includes(e.report)&&t.push("report is jest, vitest or playwright"),j(e.artifacts,"artifacts",t),e.timeoutMinutes!==void 0&&!(typeof e.timeoutMinutes=="number"&&e.timeoutMinutes>0&&e.timeoutMinutes<=L)&&t.push(`timeoutMinutes is execution minutes, up to ${L}`),e.retryable!==void 0&&typeof e.retryable!="boolean"&&t.push("retryable is true or false"),e.nx!==void 0&&!(typeof e.nx=="string"&&/^\S+:[^\s:]+$/.test(e.nx))&&t.push("nx is <project>:<target>");const o=e.inputs;if(o!==void 0)if(!l(o))t.push("inputs is an object of files, minted and secrets");else{h(o,["files","minted","secrets"],"inputs",t);const r=y(o.files,"inputs.files",t),b=y(o.minted,"inputs.minted",t);for(const m of r)neverShipped(m)&&t.push(`inputs.files names ${m}, which is never shipped to another Mac \u2014 declare it in inputs.minted, and make it in a prepare step`);const d=[...new Set(r.filter(m=>b.includes(m)))];d.length&&t.push(`inputs names ${d.join(", ")} in files and in minted: a file is shipped by hash, or made per run on the host that runs it \u2014 not both`);const k=o.secrets;k!==void 0&&!(Array.isArray(k)&&k.length<=g&&k.every(m=>typeof m=="string"&&/^[A-Za-z_][A-Za-z0-9_]*$/.test(m)))&&t.push("inputs.secrets is a list of variable names, never values")}const i=e.budget;if(!l(i))t.push("has no budget: the memory it declares is what it is admitted by");else{h(i,R[s],"budget",t);for(const r of["buildMb","hostMb","vmMb"])R[s].includes(r)&&i[r]!==void 0&&!E(i[r])&&t.push(`budget.${r} is MiB, a whole number from 1 to ${N}`);if(s==="testcontainers"&&(i.vmMb===void 0||i.hostMb===void 0)&&t.push("budget needs vmMb (its containers, in Docker's VM) and hostMb (the test runner, on the host)"),s==="playwright"&&i.vmMb===void 0&&i.hostMb===void 0&&t.push("budget needs hostMb or vmMb: where its browsers run"),s==="compose"){const r=i.services;if(!l(r)||!Object.keys(r).length)t.push("budget.services is each service's expected peak, MiB, by its name in the compose files");else for(const[b,d]of Object.entries(r))A.test(b)?E(d)||t.push(`budget.services.${b} is MiB, a whole number from 1 to ${N}`):t.push(`budget.services has "${b}", which is no service name`)}}if(s==="compose"){const r=e.compose;if(!l(r))t.push("compose is an object of files and edge");else{h(r,["files","edge"],"compose",t);const b=r.files;(!Array.isArray(b)||!b.length||b.length>g||!b.every(f))&&t.push("compose.files is the compose files, as paths inside the checkout");const d=r.edge;d!==void 0&&(!l(d)||typeof d.service!="string"||!A.test(d.service)||!Number.isInteger(d.port)||d.port<1||d.port>65535?t.push('compose.edge is the service and the container port its URL reaches: { "service": "edge", "port": 8443 }'):(h(d,["service","port"],"compose.edge",t),l(i)&&l(i.services)&&!Object.hasOwn(i.services,d.service)&&t.push(`${d.service} has no budget`)))}}return s==="playwright"&&e.stack!==void 0&&!(typeof e.stack=="string"&&_.test(e.stack))&&t.push("stack is the name of a compose job of this file"),t}a(M,"M"),c(M,"k"),u(M,"E"),p(M,"j"),n(M,"jobProblems");export function readLensJobs(e){const s={jobs:{},problems:[]};if(e===void 0)return s;if(!l(e))return s.problems.push({problem:"jobs is an object of jobs by name"}),s;for(const[t,o]of Object.entries(e)){if(!_.test(t)){s.problems.push({job:t,problem:"a job's name is letters, digits, dots, dashes and underscores \u2014 63 at most, the first a letter or a digit"});continue}const i=M(o);i.length?s.problems.push(...i.map(r=>({job:t,problem:r}))):s.jobs[t]=o}for(const[t,o]of Object.entries(s.jobs))o.kind!=="playwright"||o.stack===void 0||s.jobs[o.stack]?.kind!=="compose"&&(s.problems.push({job:t,problem:`stack names "${o.stack}", which is no compose job of this file that may run`}),delete s.jobs[t]);return s}a(readLensJobs,"readLensJobs"),c(readLensJobs,"readLensJobs"),u(readLensJobs,"readLensJobs"),p(readLensJobs,"readLensJobs"),n(readLensJobs,"readLensJobs");const O=n(e=>Object.values(e).reduce((s,t)=>s+t,0),"sum");export function jobVmNeedMb(e,s={}){if(e.kind==="compose")return Math.max(e.budget.buildMb??0,O(e.budget.services));if(e.kind==="testcontainers")return e.budget.vmMb;const t=e.budget.vmMb??0,o=e.stack===void 0?void 0:s[e.stack];return o?.kind==="compose"?Math.max(o.budget.buildMb??0,O(o.budget.services)+t):t}a(jobVmNeedMb,"jobVmNeedMb"),c(jobVmNeedMb,"jobVmNeedMb"),u(jobVmNeedMb,"jobVmNeedMb"),p(jobVmNeedMb,"jobVmNeedMb"),n(jobVmNeedMb,"jobVmNeedMb");export function jobHostNeedMb(e,s={}){const t=e.budget.hostMb??0,o=e.kind==="playwright"&&e.stack!==void 0?s[e.stack]:void 0;return t+(o?.kind==="compose"?o.budget.hostMb??0:0)}a(jobHostNeedMb,"jobHostNeedMb"),c(jobHostNeedMb,"jobHostNeedMb"),u(jobHostNeedMb,"jobHostNeedMb"),p(jobHostNeedMb,"jobHostNeedMb"),n(jobHostNeedMb,"jobHostNeedMb");export function jobLane(e){return e.lane?e.lane:e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"heavy":"light"}a(jobLane,"jobLane"),c(jobLane,"jobLane"),u(jobLane,"jobLane"),p(jobLane,"jobLane"),n(jobLane,"jobLane");export function unbudgetedServices(e,s){return[...new Set(s)].filter(t=>!Object.hasOwn(e.budget.services,t)).sort()}a(unbudgetedServices,"unbudgetedServices"),c(unbudgetedServices,"unbudgetedServices"),u(unbudgetedServices,"unbudgetedServices"),p(unbudgetedServices,"unbudgetedServices"),n(unbudgetedServices,"unbudgetedServices");export const RUN_ID_PATTERN=/^[A-Za-z0-9][A-Za-z0-9_-]{7,79}$/;export function runShortId(e){const s=e.toLowerCase().replace(/^[a-z]+_/,"").replace(/[^a-z0-9]/g,"").slice(0,8);return s.length===8?s:void 0}a(runShortId,"runShortId"),c(runShortId,"runShortId"),u(runShortId,"runShortId"),p(runShortId,"runShortId"),n(runShortId,"runShortId");export const composeProjectOf=n(e=>`lensmcp-${e}`,"composeProjectOf"),DOCKER_RUN_ENV={id:"LENSMCP_RUN_ID",origin:"LENSMCP_RUN_ORIGIN",artifacts:"LENSMCP_RUN_ARTIFACTS",labels:"LENSMCP_RUN_LABELS",override:"LENSMCP_COMPOSE_OVERRIDE",project:"COMPOSE_PROJECT_NAME"};export function dockerRunLabels(e){return{[DOCKER_LABELS.run]:e.id,[DOCKER_LABELS.home]:e.home,[DOCKER_LABELS.job]:e.job}}a(dockerRunLabels,"dockerRunLabels"),c(dockerRunLabels,"dockerRunLabels"),u(dockerRunLabels,"dockerRunLabels"),p(dockerRunLabels,"dockerRunLabels"),n(dockerRunLabels,"dockerRunLabels");export const runLabelsEnv=n(e=>JSON.stringify(e),"runLabelsEnv");export function jobRunScope(e){return e.kind==="compose"||e.kind==="playwright"&&e.stack!==void 0?"stack":jobVmNeedMb(e)>0?"containers":"none"}a(jobRunScope,"jobRunScope"),c(jobRunScope,"jobRunScope"),u(jobRunScope,"jobRunScope"),p(jobRunScope,"jobRunScope"),n(jobRunScope,"jobRunScope");export const RYUK_DISABLED_ENV="TESTCONTAINERS_RYUK_DISABLED",RYUK_LABEL="org.testcontainers.ryuk";export function ryukWarning(e,s){const t=s[RYUK_DISABLED_ENV];if(!(e.kind!=="testcontainers"||t===void 0||t.trim().toLowerCase()!=="true"))return`${RYUK_DISABLED_ENV}=${t.trim()} is set in the job's environment: testcontainers' own reaper (Ryuk) is off, so a container the suite leaves is removed only where it carries the run's labels \u2014 hand ${DOCKER_RUN_ENV.labels} to every container it starts. One that does not carry them stays in Docker's VM: LensMCP never removes it, and nothing else does.`}a(ryukWarning,"ryukWarning"),c(ryukWarning,"ryukWarning"),u(ryukWarning,"ryukWarning"),p(ryukWarning,"ryukWarning"),n(ryukWarning,"ryukWarning");export const MAX_RUN_ROUTE_SEC=14400,DOCKER_RUN_ENDS=["passed","failed","cancelled","timeout","errored","lost"],dockerRunEnded=n(e=>DOCKER_RUN_ENDS.includes(e),"dockerRunEnded"),MAX_RUN_STRANGERS=20,MAX_RUN_KILLS=100,CONTAINER_OOM="container-oom",DOCKER_ENGINE_LOST="docker-engine-lost",DOCKER_RUN_FIELD="dockerRun";
@@ -1,2 +1,2 @@
1
- "use strict";var w=Object.defineProperty;var c=(e,t)=>w(e,"name",{value:t,configurable:!0});var k=Object.defineProperty,p=c((e,t)=>k(e,"name",{value:t,configurable:!0}),"h"),x=Object.defineProperty,u=p((e,t)=>x(e,"name",{value:t,configurable:!0}),"u");import{DOCKER_RUN_ENV as f,dockerRunEnded as j,RYUK_DISABLED_ENV as A}from"./docker-jobs.js";export function runUnlabeledWords(e){if(e.scope!=="containers")return[];const t=[],o=`hand ${f.labels} to each container it starts \u2014 a JSON object of labels: .withLabels(JSON.parse(process.env.${f.labels} ?? '{}'))`,i=e.startedAt!==void 0&&e.watch?.inspected!==void 0&&!e.engineLost&&!(e.services??[]).length;i&&t.push(`LensMCP saw no container with the run's labels while it ran: it watched none and removed none. If the job starts containers, ${o}.`);const a=e.strangers;if(a?.containers.length){const n=a.containers.length+(a.more??0),h=(e.warnings??[]).some(l=>l.startsWith(A));t.push(`${n} container${n===1?"":"s"} without the run's labels came up while it ran and ${n===1?"is":"are"} still there: ${a.containers.join(", ")}${a.more?` and ${a.more} more`:""}. LensMCP cannot tell whether this run started ${n===1?"it":"them"} \u2014 Docker does not say who starts a container \u2014 and ${n===1?"does not remove it":"removes none of them"}: only what carries the run's labels is the run's. `+(h?"testcontainers' own reaper is off, so nothing else removes what a suite left either.":"Where testcontainers' own reaper is on, it removes what a suite left.")+(i?"":` If the job started ${n===1?"it":"them"}, ${o}.`))}return t}c(runUnlabeledWords,"runUnlabeledWords"),p(runUnlabeledWords,"runUnlabeledWords"),u(runUnlabeledWords,"runUnlabeledWords");export function dockerRunReport(e,t=Date.now()){const o=j(e.state),i=(e.services??[]).map(l=>{const s=l.budgetMb===void 0?0:l.peakMb-l.budgetMb;return{...l,...s>0?{overMb:s}:{},...l.peakMb>0?{}:{unsampled:!0}}}).sort((l,s)=>(s.overMb??0)-(l.overMb??0)||s.peakMb-l.peakMb||l.name.localeCompare(s.name)),a=i.filter(l=>l.budgetMb!==void 0),n=e.startedAt===void 0?void 0:Math.max(0,(e.endedAt??t)-e.startedAt),h=runUnlabeledWords(e);return{run:{id:e.id,job:e.job,kind:e.kind,state:e.state,ended:o,scope:e.scope??"stack",project:e.project,root:e.root,...e.context?{context:e.context}:{},...e.stage?{stage:e.stage}:{},...e.note?{note:e.note}:{},...e.url?{url:e.url}:{},...e.origin?{origin:e.origin}:{},...e.urlNote?{urlNote:e.urlNote}:{},createdAt:e.createdAt,...e.startedAt!==void 0?{startedAt:e.startedAt}:{},...e.endedAt!==void 0?{endedAt:e.endedAt}:{},...n!==void 0?{ranMs:n}:{},...e.exit?{exit:e.exit}:{}},services:i,totals:{lastMb:i.reduce((l,s)=>l+s.lastMb,0),...a.length?{budgetMb:a.reduce((l,s)=>l+(s.budgetMb??0),0)}:{}},kills:e.kills??[],...e.killsMore?{killsMore:e.killsMore}:{},...e.engineLost?{engineLost:e.engineLost}:{},...e.vm?{vm:e.vm}:{},...e.cleanup?{cleanup:e.cleanup}:{},...e.warnings?.length?{warnings:e.warnings}:{},...h.length?{unlabeled:h}:{},...e.watch?{watch:e.watch}:{},files:{...e.files.samples?{samples:e.files.samples}:{},...e.files.events?{events:e.files.events}:{},log:e.files.log,artifacts:e.files.artifacts}}}c(dockerRunReport,"dockerRunReport"),p(dockerRunReport,"dockerRunReport"),u(dockerRunReport,"dockerRunReport");const d=u(e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"Z"),"when"),M=u(e=>{const t=Math.round(e/1e3);if(t<60)return`${t} s`;const o=Math.floor(t/60);return o<60?`${o} min${t%60?` ${t%60} s`:""}`:`${Math.floor(o/60)} h${o%60?` ${o%60} min`:""}`},"lasted"),$=u((e,t,o)=>`${e} ${e===1?t:o}`,"plural");export{d as dockerTime,M as dockerLasted};function g(e){const t=e.exit?e.exit.signal?`its command was ended by ${e.exit.signal}`:`its command exited ${e.exit.code}`:void 0,o=[e.ranMs!==void 0?`${e.ended?"ran":"running for"} ${M(e.ranMs)}`:void 0,e.startedAt!==void 0?`started ${d(e.startedAt)}`:`created ${d(e.createdAt)}`,e.endedAt!==void 0?`ended ${d(e.endedAt)}`:void 0].filter(Boolean).join(", ");return`${{starting:"starting: nothing of the job has run yet",preparing:"preparing: its prepare steps run",running:"running",cleaning:`cleaning up${t?`: ${t}`:""}`,passed:`passed${t?`: ${t}`:""}`,failed:`failed${t?`: ${t}`:""}`,cancelled:"cancelled",timeout:"timed out",errored:"errored",lost:`lost: its runner died, so nobody knows how it would have ended${t?` (${t})`:""}`}[e.state]} \xB7 ${o}`}c(g,"v"),p(g,"w"),u(g,"stateText");function v(e){const t=e[0].map((o,i)=>Math.max(...e.map(a=>(a[i]??"").length)));return e.map(o=>o.map((i,a)=>a===0?i.padEnd(t[a]):a===o.length-1?i:i.padStart(t[a])).join(" ").trimEnd())}c(v,"f"),p(v,"k"),u(v,"table");export function dockerRunReportText(e){const{run:t,vm:o,watch:i,cleanup:a}=e,n=[`Docker run ${t.id} \u2014 job \xAB${t.job}\xBB (${t.kind}), ${t.project?`Compose project ${t.project}`:t.scope==="none"?"nothing in Docker":"no Compose project: its containers by the run's labels"}`,` ${g(t)}`,` in ${t.root}${t.context?` \xB7 Docker context ${t.context}`:""}`];t.stage&&n.push(` stage: ${t.stage}`),t.note&&n.push(` ${t.note}`);for(const s of e.warnings??[])n.push(` ! ${s}`);t.url?n.push(` URL: ${t.url}`):t.urlNote&&n.push(` no URL: ${t.urlNote}`),n.push("");const h=i?.samples?`${$(i.samples,"sample","samples")}${i.sampledAt!==void 0?`, the last at ${d(i.sampledAt)}`:""}`:"no sample was taken";if(n.push(t.scope==="none"?"Memory: the job declares nothing in Docker's VM \u2014 its commands were given no labels, and Docker was not asked about it.":`Memory by service, MiB \u2014 ${h}`),e.services.length){const s=u(r=>r===void 0?"\u2013":String(r),"figure"),b=u(r=>[r.overMb!==void 0?`OVER its budget by ${r.overMb}`:void 0,r.oomKilled?"killed for memory":void 0,r.exitCode!==void 0?`exit ${r.exitCode}`:void 0,r.unsampled?"never sampled":void 0].filter(Boolean).join(" \xB7 "),"remark");n.push(...v([["service","now","peak","budget","limit",""],...e.services.map(r=>[r.name,r.unsampled?"\u2013":String(r.lastMb),r.unsampled?"\u2013":String(r.peakMb),s(r.budgetMb),s(r.limitMb),b(r)]),["all",String(e.totals.lastMb),"",s(e.totals.budgetMb),"",""]]).map(r=>` ${r}`));const m=e.services.filter(r=>r.overMb!==void 0);m.length&&n.push(` ${$(m.length,"service","services")} over what ${m.length===1?"it declares":"they declare"}: raise \`jobs.${t.job}.budget.services\` in lensmcp.json to what ${m.length===1?"it takes":"they take"} \u2014 the queue lets the job in by these figures.`)}else t.scope!=="none"&&n.push(" No container of the run was seen.");n.push("");const l=e.kills.length+(e.killsMore??0);n.push(l?`Killed for memory: ${l}`:"Killed for memory: none");for(const s of e.kills){const b=[s.limitMb!==void 0?`at its ${s.limitMb} MiB limit`:"no limit of its own: the VM ran out, or it was not read",s.peakMb!==void 0?`peak ${s.peakMb} MiB`:"never sampled",s.budgetMb!==void 0?`budget ${s.budgetMb} MiB`:void 0,s.seen==="event"?"seen live":"found by the inspect: the live stream did not tell it"].filter(Boolean).join(" \xB7 ");n.push(` ${d(s.at)} ${s.service}${s.name?` (${s.name})`:""} ${b}`)}if(e.killsMore&&n.push(` \u2026 and ${e.killsMore} more, not listed`),e.engineLost){const s=e.engineLost;n.push(""),n.push(`Docker stopped answering at ${d(s.at)} \u2014 ${s.why}`),s.backAt!==void 0&&n.push(` it answered again at ${d(s.backAt)}`),s.killed?.length&&n.push(` found killed for memory once it was gone: ${s.killed.join(", ")} \u2014 they went with the engine`)}o&&(n.push(""),n.push(`Docker's VM: ${o.totalMb} MiB \xB7 ${o.read==="estimate"?"about ":""}${o.availableAtAdmissionMb} MiB free when the run was let in (${o.read==="estimate"?"an estimate: its own figure could not be read":"the VM's own figure"})`+(o.minAvailableMb!==void 0?` \xB7 lowest ${o.minAvailableMb} MiB while it ran`:" \xB7 not read while it ran")+(o.lastAvailableMb!==void 0?` \xB7 ${o.lastAvailableMb} MiB at the last read${o.sampledAt!==void 0?` (${d(o.sampledAt)})`:""}`:""))),n.push(""),a?a.done?n.push(`Cleanup: by ${a.by==="project"?"the project's own end (LensMCP looked, and found nothing)":a.by} at ${d(a.at)} \u2014 nothing of the run is left`):n.push(`Cleanup: OWED (${a.by}, ${d(a.at)}) \u2014 ${a.why??"something that carries the run's labels is left"}${a.left?.length?` \u2014 left: ${a.left.join(", ")}`:""}`):n.push(t.ended?"Cleanup: not recorded \u2014 its guard, or the sweep, has it":"Cleanup: not yet \u2014 the run has not ended"),a?.unlabeled?.length&&n.push(` in its Compose project without the run's labels, never removed: ${a.unlabeled.join(", ")}`);for(const s of e.unlabeled??[])n.push(` ${s}`);if(i?.notes?.length||i?.streamRestarts){n.push(""),n.push("What the watcher could not do:"),i.streamRestarts&&n.push(` the live stream ended ${$(i.streamRestarts,"time","times")} while Docker answered, and was started again`);for(const s of i.notes??[])n.push(` ${s}`)}return n.push(""),n.push(`Files: ${[e.files.samples?`samples ${e.files.samples}`:void 0,e.files.events?`events ${e.files.events}`:void 0,`log ${e.files.log}`].filter(Boolean).join(" \xB7 ")}`),n.join(`
2
- `)}c(dockerRunReportText,"dockerRunReportText"),p(dockerRunReportText,"dockerRunReportText"),u(dockerRunReportText,"dockerRunReportText");
1
+ "use strict";var x=Object.defineProperty;var c=(e,t)=>x(e,"name",{value:t,configurable:!0});var j=Object.defineProperty,p=c((e,t)=>j(e,"name",{value:t,configurable:!0}),"c"),A=Object.defineProperty,b=p((e,t)=>A(e,"name",{value:t,configurable:!0}),"c"),y=Object.defineProperty,m=b((e,t)=>y(e,"name",{value:t,configurable:!0}),"h"),R=Object.defineProperty,u=m((e,t)=>R(e,"name",{value:t,configurable:!0}),"u");import{DOCKER_RUN_ENV as w,dockerRunEnded as B,RYUK_DISABLED_ENV as D}from"./docker-jobs.js";export function runUnlabeledWords(e){if(e.scope!=="containers")return[];const t=[],s=`hand ${w.labels} to each container it starts \u2014 a JSON object of labels: .withLabels(JSON.parse(process.env.${w.labels} ?? '{}'))`,i=e.startedAt!==void 0&&e.watch?.inspected!==void 0&&!e.engineLost&&!(e.services??[]).length;i&&t.push(`LensMCP saw no container with the run's labels while it ran: it watched none and removed none. If the job starts containers, ${s}.`);const a=e.strangers;if(a?.containers.length){const n=a.containers.length+(a.more??0),h=(e.warnings??[]).some(l=>l.startsWith(D));t.push(`${n} container${n===1?"":"s"} without the run's labels came up while it ran and ${n===1?"is":"are"} still there: ${a.containers.join(", ")}${a.more?` and ${a.more} more`:""}. LensMCP cannot tell whether this run started ${n===1?"it":"them"} \u2014 Docker does not say who starts a container \u2014 and ${n===1?"does not remove it":"removes none of them"}: only what carries the run's labels is the run's. `+(h?"testcontainers' own reaper is off, so nothing else removes what a suite left either.":"Where testcontainers' own reaper is on, it removes what a suite left.")+(i?"":` If the job started ${n===1?"it":"them"}, ${s}.`))}return t}c(runUnlabeledWords,"runUnlabeledWords"),p(runUnlabeledWords,"runUnlabeledWords"),b(runUnlabeledWords,"runUnlabeledWords"),m(runUnlabeledWords,"runUnlabeledWords"),u(runUnlabeledWords,"runUnlabeledWords");export function dockerRunReport(e,t=Date.now()){const s=B(e.state),i=(e.services??[]).map(l=>{const o=l.budgetMb===void 0?0:l.peakMb-l.budgetMb;return{...l,...o>0?{overMb:o}:{},...l.peakMb>0?{}:{unsampled:!0}}}).sort((l,o)=>(o.overMb??0)-(l.overMb??0)||o.peakMb-l.peakMb||l.name.localeCompare(o.name)),a=i.filter(l=>l.budgetMb!==void 0),n=e.startedAt===void 0?void 0:Math.max(0,(e.endedAt??t)-e.startedAt),h=runUnlabeledWords(e);return{run:{id:e.id,job:e.job,kind:e.kind,state:e.state,ended:s,scope:e.scope??"stack",project:e.project,root:e.root,...e.context?{context:e.context}:{},...e.stage?{stage:e.stage}:{},...e.note?{note:e.note}:{},...e.url?{url:e.url}:{},...e.origin?{origin:e.origin}:{},...e.urlNote?{urlNote:e.urlNote}:{},createdAt:e.createdAt,...e.startedAt!==void 0?{startedAt:e.startedAt}:{},...e.endedAt!==void 0?{endedAt:e.endedAt}:{},...n!==void 0?{ranMs:n}:{},...e.exit?{exit:e.exit}:{}},services:i,totals:{lastMb:i.reduce((l,o)=>l+o.lastMb,0),...a.length?{budgetMb:a.reduce((l,o)=>l+(o.budgetMb??0),0)}:{}},kills:e.kills??[],...e.killsMore?{killsMore:e.killsMore}:{},...e.engineLost?{engineLost:e.engineLost}:{},...e.vm?{vm:e.vm}:{},...e.cleanup?{cleanup:e.cleanup}:{},...e.warnings?.length?{warnings:e.warnings}:{},...h.length?{unlabeled:h}:{},...e.watch?{watch:e.watch}:{},files:{...e.files.samples?{samples:e.files.samples}:{},...e.files.events?{events:e.files.events}:{},log:e.files.log,artifacts:e.files.artifacts}}}c(dockerRunReport,"dockerRunReport"),p(dockerRunReport,"dockerRunReport"),b(dockerRunReport,"dockerRunReport"),m(dockerRunReport,"dockerRunReport"),u(dockerRunReport,"dockerRunReport");const d=u(e=>new Date(e).toISOString().replace(/\.\d{3}Z$/,"Z"),"when"),k=u(e=>{const t=Math.round(e/1e3);if(t<60)return`${t} s`;const s=Math.floor(t/60);return s<60?`${s} min${t%60?` ${t%60} s`:""}`:`${Math.floor(s/60)} h${s%60?` ${s%60} min`:""}`},"lasted"),M=u((e,t,s)=>`${e} ${e===1?t:s}`,"plural");export{d as dockerTime,k as dockerLasted};function $(e){const t=e.exit?e.exit.signal?`its command was ended by ${e.exit.signal}`:`its command exited ${e.exit.code}`:void 0,s=[e.ranMs!==void 0?`${e.ended?"ran":"running for"} ${k(e.ranMs)}`:void 0,e.startedAt!==void 0?`started ${d(e.startedAt)}`:`created ${d(e.createdAt)}`,e.endedAt!==void 0?`ended ${d(e.endedAt)}`:void 0].filter(Boolean).join(", ");return`${{starting:"starting: nothing of the job has run yet",preparing:"preparing: its prepare steps run",running:"running",cleaning:`cleaning up${t?`: ${t}`:""}`,passed:`passed${t?`: ${t}`:""}`,failed:`failed${t?`: ${t}`:""}`,cancelled:"cancelled",timeout:"timed out",errored:"errored",lost:`lost: its runner died, so nobody knows how it would have ended${t?` (${t})`:""}`}[e.state]} \xB7 ${s}`}c($,"$"),p($,"g"),b($,"v"),m($,"w"),u($,"stateText");function g(e){const t=e[0].map((s,i)=>Math.max(...e.map(a=>(a[i]??"").length)));return e.map(s=>s.map((i,a)=>a===0?i.padEnd(t[a]):a===s.length-1?i:i.padStart(t[a])).join(" ").trimEnd())}c(g,"g"),p(g,"v"),b(g,"f"),m(g,"k"),u(g,"table");export function dockerRunReportText(e){const{run:t,vm:s,watch:i,cleanup:a}=e,n=[`Docker run ${t.id} \u2014 job \xAB${t.job}\xBB (${t.kind}), ${t.project?`Compose project ${t.project}`:t.scope==="none"?"nothing in Docker":"no Compose project: its containers by the run's labels"}`,` ${$(t)}`,` in ${t.root}${t.context?` \xB7 Docker context ${t.context}`:""}`];t.stage&&n.push(` stage: ${t.stage}`),t.note&&n.push(` ${t.note}`);for(const o of e.warnings??[])n.push(` ! ${o}`);t.url?n.push(` URL: ${t.url}`):t.urlNote&&n.push(` no URL: ${t.urlNote}`),n.push("");const h=i?.samples?`${M(i.samples,"sample","samples")}${i.sampledAt!==void 0?`, the last at ${d(i.sampledAt)}`:""}`:"no sample was taken";if(n.push(t.scope==="none"?"Memory: the job declares nothing in Docker's VM \u2014 its commands were given no labels, and Docker was not asked about it.":`Memory by service, MiB \u2014 ${h}`),e.services.length){const o=u(r=>r===void 0?"\u2013":String(r),"figure"),f=u(r=>[r.overMb!==void 0?`OVER its budget by ${r.overMb}`:void 0,r.oomKilled?"killed for memory":void 0,r.exitCode!==void 0?`exit ${r.exitCode}`:void 0,r.unsampled?"never sampled":void 0].filter(Boolean).join(" \xB7 "),"remark");n.push(...g([["service","now","peak","budget","limit",""],...e.services.map(r=>[r.name,r.unsampled?"\u2013":String(r.lastMb),r.unsampled?"\u2013":String(r.peakMb),o(r.budgetMb),o(r.limitMb),f(r)]),["all",String(e.totals.lastMb),"",o(e.totals.budgetMb),"",""]]).map(r=>` ${r}`));const v=e.services.filter(r=>r.overMb!==void 0);v.length&&n.push(` ${M(v.length,"service","services")} over what ${v.length===1?"it declares":"they declare"}: raise \`jobs.${t.job}.budget.services\` in lensmcp.json to what ${v.length===1?"it takes":"they take"} \u2014 the queue lets the job in by these figures.`)}else t.scope!=="none"&&n.push(" No container of the run was seen.");n.push("");const l=e.kills.length+(e.killsMore??0);n.push(l?`Killed for memory: ${l}`:"Killed for memory: none");for(const o of e.kills){const f=[o.limitMb!==void 0?`at its ${o.limitMb} MiB limit`:"no limit of its own: the VM ran out, or it was not read",o.peakMb!==void 0?`peak ${o.peakMb} MiB`:"never sampled",o.budgetMb!==void 0?`budget ${o.budgetMb} MiB`:void 0,o.seen==="event"?"seen live":"found by the inspect: the live stream did not tell it"].filter(Boolean).join(" \xB7 ");n.push(` ${d(o.at)} ${o.service}${o.name?` (${o.name})`:""} ${f}`)}if(e.killsMore&&n.push(` \u2026 and ${e.killsMore} more, not listed`),e.engineLost){const o=e.engineLost;n.push(""),n.push(`Docker stopped answering at ${d(o.at)} \u2014 ${o.why}`),o.backAt!==void 0&&n.push(` it answered again at ${d(o.backAt)}`),o.killed?.length&&n.push(` found killed for memory once it was gone: ${o.killed.join(", ")} \u2014 they went with the engine`)}s&&(n.push(""),n.push(`Docker's VM: ${s.totalMb} MiB \xB7 ${s.read==="estimate"?"about ":""}${s.availableAtAdmissionMb} MiB free when the run was let in (${s.read==="estimate"?"an estimate: its own figure could not be read":"the VM's own figure"})`+(s.minAvailableMb!==void 0?` \xB7 lowest ${s.minAvailableMb} MiB while it ran`:" \xB7 not read while it ran")+(s.lastAvailableMb!==void 0?` \xB7 ${s.lastAvailableMb} MiB at the last read${s.sampledAt!==void 0?` (${d(s.sampledAt)})`:""}`:""))),n.push(""),a?a.done?n.push(`Cleanup: by ${a.by==="project"?"the project's own end (LensMCP looked, and found nothing)":a.by} at ${d(a.at)} \u2014 nothing of the run is left`):n.push(`Cleanup: OWED (${a.by}, ${d(a.at)}) \u2014 ${a.why??"something that carries the run's labels is left"}${a.left?.length?` \u2014 left: ${a.left.join(", ")}`:""}`):n.push(t.ended?"Cleanup: not recorded \u2014 its guard, or the sweep, has it":"Cleanup: not yet \u2014 the run has not ended"),a?.unlabeled?.length&&n.push(` in its Compose project without the run's labels, never removed: ${a.unlabeled.join(", ")}`);for(const o of e.unlabeled??[])n.push(` ${o}`);if(i?.notes?.length||i?.streamRestarts){n.push(""),n.push("What the watcher could not do:"),i.streamRestarts&&n.push(` the live stream ended ${M(i.streamRestarts,"time","times")} while Docker answered, and was started again`);for(const o of i.notes??[])n.push(` ${o}`)}return n.push(""),n.push(`Files: ${[e.files.samples?`samples ${e.files.samples}`:void 0,e.files.events?`events ${e.files.events}`:void 0,`log ${e.files.log}`].filter(Boolean).join(" \xB7 ")}`),n.join(`
2
+ `)}c(dockerRunReportText,"dockerRunReportText"),p(dockerRunReportText,"dockerRunReportText"),b(dockerRunReportText,"dockerRunReportText"),m(dockerRunReportText,"dockerRunReportText"),u(dockerRunReportText,"dockerRunReportText");
@@ -1,3 +1,3 @@
1
- "use strict";var w=Object.defineProperty;var u=(n,e)=>w(n,"name",{value:e,configurable:!0});var A=Object.defineProperty,a=u((n,e)=>A(n,"name",{value:e,configurable:!0}),"u"),M=Object.defineProperty,i=a((n,e)=>M(n,"name",{value:e,configurable:!0}),"l");import{dockerLasted as $,dockerRunReport as x,dockerTime as h}from"./docker-report.js";export function dockerRunStanding(n){return n.run.ended?n.cleanup?.done===!0?"ended":"owed":"up"}u(dockerRunStanding,"dockerRunStanding"),a(dockerRunStanding,"dockerRunStanding"),i(dockerRunStanding,"dockerRunStanding");export function dockerRunsList(n,e={}){const o=e.now??Date.now(),r=n.map(k=>{const c=x(k,o),g=dockerRunStanding(c);return{...c,standing:g,...g==="up"&&e.runnerGone?.(k)?{runnerGone:!0}:{}}}),d=i(k=>r.filter(c=>c.standing===k).sort((c,g)=>(g.run.endedAt??g.run.startedAt??g.run.createdAt)-(c.run.endedAt??c.run.startedAt??c.run.createdAt)||c.run.id.localeCompare(g.run.id)),"of"),t=d("up"),l=d("owed"),s=d("ended"),p=e.all?s.slice(0,e.endedMax??s.length):[];return{counts:{up:t.length,owed:l.length,ended:s.length},all:e.all===!0,...e.all&&p.length<s.length?{endedMore:s.length-p.length}:{},runs:[...t,...l,...p]}}u(dockerRunsList,"dockerRunsList"),a(dockerRunsList,"dockerRunsList"),i(dockerRunsList,"dockerRunsList");const L={starting:"starting",preparing:"preparing",running:"running",cleaning:"cleaning up",passed:"passed",failed:"failed",cancelled:"cancelled",timeout:"timed out",errored:"errored",lost:"lost"};export const dockerStateWord=i(n=>L[n],"dockerStateWord");export function dockerRunSince(n){const{run:e}=n;return e.ended?e.endedAt??e.startedAt??e.createdAt:e.startedAt??e.createdAt}u(dockerRunSince,"dockerRunSince"),a(dockerRunSince,"dockerRunSince"),i(dockerRunSince,"dockerRunSince");export function dockerRunHolds(n){if(n.services.some(e=>!e.unsampled))return n.totals.budgetMb===void 0?`${n.totals.lastMb} MiB`:`${n.totals.lastMb} of ${n.totals.budgetMb} MiB`}u(dockerRunHolds,"dockerRunHolds"),a(dockerRunHolds,"dockerRunHolds"),i(dockerRunHolds,"dockerRunHolds");export const RUNNER_GONE="its runner is gone: nothing runs it any more \u2014 its guard, or the sweep, writes its end and takes its stack down";export function dockerRunRemarks(n){const e=[];n.runnerGone&&!n.run.ended&&e.push(RUNNER_GONE);const o=n.services.filter(l=>l.overMb!==void 0);o.length&&e.push(`OVER its budget: ${o.map(l=>`${l.name} by ${l.overMb} MiB`).join(", ")}`);const r=n.kills.length+(n.killsMore??0),d=[...new Set(n.kills.map(l=>l.service))];r&&e.push(`killed for memory: ${r}${d.length?` (${d.join(", ")})`:""}`),n.engineLost&&e.push(`Docker stopped answering at ${h(n.engineLost.at)}${n.engineLost.backAt!==void 0?`, and answered again at ${h(n.engineLost.backAt)}`:""}`);const{cleanup:t}=n;return n.run.ended&&!t?e.push("cleanup OWED: none is recorded \u2014 its guard, or the sweep, has it"):t&&!t.done&&e.push(`cleanup OWED: ${t.why??"something that carries the run's labels is left"}${t.left?.length?` \u2014 left: ${t.left.join(", ")}`:""}`),t?.unlabeled?.length&&e.push(`in its Compose project without the run's labels, never removed: ${t.unlabeled.join(", ")}`),e}u(dockerRunRemarks,"dockerRunRemarks"),a(dockerRunRemarks,"dockerRunRemarks"),i(dockerRunRemarks,"dockerRunRemarks");function R(n){const{run:e}=n,o=dockerRunSince(n),r=e.ended?`ended ${h(o)}${e.ranMs!==void 0?` after ${$(e.ranMs)}`:""}`:e.startedAt!==void 0?`for ${$(e.ranMs??0)}, since ${h(o)}`:`since ${h(o)}`,d=n.standing==="up"?dockerRunHolds(n):void 0,t=[[e.job,`${dockerStateWord(e.state)}${n.standing==="owed"?", cleanup OWED":n.runnerGone?", its runner GONE":""}`,r,...d?[`holds ${d}`]:[],e.id].join(" ")];e.stage&&!e.ended&&t.push(` stage: ${e.stage}`),e.url?t.push(` URL: ${e.url}`):e.urlNote&&!e.ended&&t.push(` no URL: ${e.urlNote}`),e.note&&t.push(` ${e.note}`);for(const l of dockerRunRemarks(n))t.push(` ${l}`);return t}u(R,"$"),a(R,"R"),i(R,"runLines");const v=i((n,e,o)=>`${n} ${n===1?e:o}`,"plural");export function dockerRunsText(n){const{counts:e}=n;if(!(e.up+e.owed+e.ended))return["This home's registry holds no Docker run.","A job is declared in the checkout's lensmcp.json \u2192 jobs, and started with `lensmcp docker run <job>`."].join(`
2
- `);const o=e.ended?` \xB7 ${v(e.ended,"ended one is","ended ones are")} kept${n.all?"":" (--all lists them)"}`:"",r=[`Docker runs of this home \u2014 ${e.up} up, ${e.owed?`${v(e.owed,"owes","owe")} a cleanup`:"none owes a cleanup"}${o}`];n.runs.length||r.push(" Nothing of this home is in Docker now.");for(const d of n.runs)r.push(...R(d).map(t=>` ${t}`));return n.endedMore&&r.push(` \u2026 and ${n.endedMore} more ended, not listed`),e.owed&&r.push("","A cleanup that is owed is taken by the run's guard, then by the sweep: `lensmcp docker sweep --dry-run` says what one would take down."),r.join(`
3
- `)}u(dockerRunsText,"dockerRunsText"),a(dockerRunsText,"dockerRunsText"),i(dockerRunsText,"dockerRunsText");export const BLOCK_MAX_SERVICES=8,BLOCK_MAX_KILLS=5;const j=8,b=300,m=i(n=>n.length>b?`${n.slice(0,b-1)}\u2026`:n,"cut"),f=i(n=>n?.length?n.slice(0,j).map(e=>e.slice(0,120)):void 0,"names");export function dockerRunBlock(n){const{run:e,cleanup:o,engineLost:r}=n,d=n.services.slice(0,BLOCK_MAX_SERVICES),t=n.kills.slice(0,BLOCK_MAX_KILLS),l=n.kills.length-t.length+(n.killsMore??0),s=f(o?.left),p=f(o?.unlabeled),k=f(r?.killed);return{run:e.id,job:e.job,kind:e.kind,state:e.state,standing:dockerRunStanding(n),...n.runnerGone&&!e.ended?{runnerGone:!0}:{},project:e.project,...e.context?{context:e.context}:{},...e.stage?{stage:e.stage}:{},...e.url?{url:e.url}:{},...e.urlNote?{urlNote:m(e.urlNote)}:{},...e.note?{note:m(e.note)}:{},...e.startedAt!==void 0?{startedAt:e.startedAt}:{},...e.endedAt!==void 0?{endedAt:e.endedAt}:{},...e.ranMs!==void 0?{ranMs:e.ranMs}:{},...e.exit?{exit:e.exit}:{},...n.vm?{vm:n.vm}:{},services:d,...n.services.length>d.length?{servicesMore:n.services.length-d.length}:{},totals:n.totals,kills:t.map(c=>({...c,container:c.container.slice(0,12)})),...l?{killsMore:l}:{},...r?{engineLost:{at:r.at,why:m(r.why),...r.backAt!==void 0?{backAt:r.backAt}:{},...k?{killed:k}:{}}}:{},...o?{cleanup:{by:o.by,at:o.at,done:o.done,...s?{left:s}:{},...p?{unlabeled:p}:{},...o.why?{why:m(o.why)}:{}}}:{}}}u(dockerRunBlock,"dockerRunBlock"),a(dockerRunBlock,"dockerRunBlock"),i(dockerRunBlock,"dockerRunBlock");export function dockerRunBlockLess(n){if(n.services&&n.services.length>1)return{...n,services:n.services.slice(0,-1),servicesMore:(n.servicesMore??0)+1};if(n.kills&&n.kills.length>1)return{...n,kills:n.kills.slice(0,-1),killsMore:(n.killsMore??0)+1}}u(dockerRunBlockLess,"dockerRunBlockLess"),a(dockerRunBlockLess,"dockerRunBlockLess"),i(dockerRunBlockLess,"dockerRunBlockLess");export const PAGE_MAX_ROWS=50;const y=["queued","running"];export function dockerRemoteStanding(n){return n.state==="lost"?"lost":y.includes(n.state)?"up":"ended"}u(dockerRemoteStanding,"dockerRemoteStanding"),a(dockerRemoteStanding,"dockerRemoteStanding"),i(dockerRemoteStanding,"dockerRemoteStanding");export function dockerRemoteRunsList(n,e={}){const o=i(s=>s.completedAt??s.startedAt??s.queuedAt,"since"),r=[...n].sort((s,p)=>o(p)-o(s)||s.run.localeCompare(p.run)),d=r.filter(s=>dockerRemoteStanding(s)==="up"),t=r.filter(s=>dockerRemoteStanding(s)!=="up"),l=t.slice(0,e.endedMax??t.length);return{counts:{up:d.length,lost:t.filter(s=>s.state==="lost").length,ended:t.filter(s=>s.state!=="lost").length},runs:[...d,...l],...l.length<t.length?{endedMore:t.length-l.length}:{}}}u(dockerRemoteRunsList,"dockerRemoteRunsList"),a(dockerRemoteRunsList,"dockerRemoteRunsList"),i(dockerRemoteRunsList,"dockerRemoteRunsList");
1
+ "use strict";var M=Object.defineProperty;var i=(n,e)=>M(n,"name",{value:e,configurable:!0});var L=Object.defineProperty,a=i((n,e)=>L(n,"name",{value:e,configurable:!0}),"i"),x=Object.defineProperty,k=a((n,e)=>x(n,"name",{value:e,configurable:!0}),"u"),S=Object.defineProperty,p=k((n,e)=>S(n,"name",{value:e,configurable:!0}),"u"),j=Object.defineProperty,l=p((n,e)=>j(n,"name",{value:e,configurable:!0}),"l");import{dockerLasted as v,dockerRunReport as y,dockerTime as m}from"./docker-report.js";export function dockerRunStanding(n){return n.run.ended?n.cleanup?.done===!0?"ended":"owed":"up"}i(dockerRunStanding,"dockerRunStanding"),a(dockerRunStanding,"dockerRunStanding"),k(dockerRunStanding,"dockerRunStanding"),p(dockerRunStanding,"dockerRunStanding"),l(dockerRunStanding,"dockerRunStanding");export function dockerRunsList(n,e={}){const t=e.now??Date.now(),s=n.map(h=>{const c=y(h,t),R=dockerRunStanding(c);return{...c,standing:R,...R==="up"&&e.runnerGone?.(h)?{runnerGone:!0}:{}}}),d=l(h=>s.filter(c=>c.standing===h).sort((c,R)=>(R.run.endedAt??R.run.startedAt??R.run.createdAt)-(c.run.endedAt??c.run.startedAt??c.run.createdAt)||c.run.id.localeCompare(R.run.id)),"of"),o=d("up"),u=d("owed"),r=d("ended"),g=e.all?r.slice(0,e.endedMax??r.length):[];return{counts:{up:o.length,owed:u.length,ended:r.length},all:e.all===!0,...e.all&&g.length<r.length?{endedMore:r.length-g.length}:{},runs:[...o,...u,...g]}}i(dockerRunsList,"dockerRunsList"),a(dockerRunsList,"dockerRunsList"),k(dockerRunsList,"dockerRunsList"),p(dockerRunsList,"dockerRunsList"),l(dockerRunsList,"dockerRunsList");const B={starting:"starting",preparing:"preparing",running:"running",cleaning:"cleaning up",passed:"passed",failed:"failed",cancelled:"cancelled",timeout:"timed out",errored:"errored",lost:"lost"};export const dockerStateWord=l(n=>B[n],"dockerStateWord");export function dockerRunSince(n){const{run:e}=n;return e.ended?e.endedAt??e.startedAt??e.createdAt:e.startedAt??e.createdAt}i(dockerRunSince,"dockerRunSince"),a(dockerRunSince,"dockerRunSince"),k(dockerRunSince,"dockerRunSince"),p(dockerRunSince,"dockerRunSince"),l(dockerRunSince,"dockerRunSince");export function dockerRunHolds(n){if(n.services.some(e=>!e.unsampled))return n.totals.budgetMb===void 0?`${n.totals.lastMb} MiB`:`${n.totals.lastMb} of ${n.totals.budgetMb} MiB`}i(dockerRunHolds,"dockerRunHolds"),a(dockerRunHolds,"dockerRunHolds"),k(dockerRunHolds,"dockerRunHolds"),p(dockerRunHolds,"dockerRunHolds"),l(dockerRunHolds,"dockerRunHolds");export const RUNNER_GONE="its runner is gone: nothing runs it any more \u2014 its guard, or the sweep, writes its end and takes its stack down";export function dockerRunRemarks(n){const e=[];n.runnerGone&&!n.run.ended&&e.push(RUNNER_GONE);const t=n.services.filter(u=>u.overMb!==void 0);t.length&&e.push(`OVER its budget: ${t.map(u=>`${u.name} by ${u.overMb} MiB`).join(", ")}`);const s=n.kills.length+(n.killsMore??0),d=[...new Set(n.kills.map(u=>u.service))];s&&e.push(`killed for memory: ${s}${d.length?` (${d.join(", ")})`:""}`),n.engineLost&&e.push(`Docker stopped answering at ${m(n.engineLost.at)}${n.engineLost.backAt!==void 0?`, and answered again at ${m(n.engineLost.backAt)}`:""}`);const{cleanup:o}=n;return n.run.ended&&!o?e.push("cleanup OWED: none is recorded \u2014 its guard, or the sweep, has it"):o&&!o.done&&e.push(`cleanup OWED: ${o.why??"something that carries the run's labels is left"}${o.left?.length?` \u2014 left: ${o.left.join(", ")}`:""}`),o?.unlabeled?.length&&e.push(`in its Compose project without the run's labels, never removed: ${o.unlabeled.join(", ")}`),e}i(dockerRunRemarks,"dockerRunRemarks"),a(dockerRunRemarks,"dockerRunRemarks"),k(dockerRunRemarks,"dockerRunRemarks"),p(dockerRunRemarks,"dockerRunRemarks"),l(dockerRunRemarks,"dockerRunRemarks");function f(n){const{run:e}=n,t=dockerRunSince(n),s=e.ended?`ended ${m(t)}${e.ranMs!==void 0?` after ${v(e.ranMs)}`:""}`:e.startedAt!==void 0?`for ${v(e.ranMs??0)}, since ${m(t)}`:`since ${m(t)}`,d=n.standing==="up"?dockerRunHolds(n):void 0,o=[[e.job,`${dockerStateWord(e.state)}${n.standing==="owed"?", cleanup OWED":n.runnerGone?", its runner GONE":""}`,s,...d?[`holds ${d}`]:[],e.id].join(" ")];e.stage&&!e.ended&&o.push(` stage: ${e.stage}`),e.url?o.push(` URL: ${e.url}`):e.urlNote&&!e.ended&&o.push(` no URL: ${e.urlNote}`),e.note&&o.push(` ${e.note}`);for(const u of dockerRunRemarks(n))o.push(` ${u}`);return o}i(f,"m"),a(f,"R"),k(f,"$"),p(f,"R"),l(f,"runLines");const w=l((n,e,t)=>`${n} ${n===1?e:t}`,"plural");export function dockerRunsText(n){const{counts:e}=n;if(!(e.up+e.owed+e.ended))return["This home's registry holds no Docker run.","A job is declared in the checkout's lensmcp.json \u2192 jobs, and started with `lensmcp docker run <job>`."].join(`
2
+ `);const t=e.ended?` \xB7 ${w(e.ended,"ended one is","ended ones are")} kept${n.all?"":" (--all lists them)"}`:"",s=[`Docker runs of this home \u2014 ${e.up} up, ${e.owed?`${w(e.owed,"owes","owe")} a cleanup`:"none owes a cleanup"}${t}`];n.runs.length||s.push(" Nothing of this home is in Docker now.");for(const d of n.runs)s.push(...f(d).map(o=>` ${o}`));return n.endedMore&&s.push(` \u2026 and ${n.endedMore} more ended, not listed`),e.owed&&s.push("","A cleanup that is owed is taken by the run's guard, then by the sweep: `lensmcp docker sweep --dry-run` says what one would take down."),s.join(`
3
+ `)}i(dockerRunsText,"dockerRunsText"),a(dockerRunsText,"dockerRunsText"),k(dockerRunsText,"dockerRunsText"),p(dockerRunsText,"dockerRunsText"),l(dockerRunsText,"dockerRunsText");export const BLOCK_MAX_SERVICES=8,BLOCK_MAX_KILLS=5;const O=8,A=300,$=l(n=>n.length>A?`${n.slice(0,A-1)}\u2026`:n,"cut"),b=l(n=>n?.length?n.slice(0,O).map(e=>e.slice(0,120)):void 0,"names");export function dockerRunBlock(n){const{run:e,cleanup:t,engineLost:s}=n,d=n.services.slice(0,BLOCK_MAX_SERVICES),o=n.kills.slice(0,BLOCK_MAX_KILLS),u=n.kills.length-o.length+(n.killsMore??0),r=b(t?.left),g=b(t?.unlabeled),h=b(s?.killed);return{run:e.id,job:e.job,kind:e.kind,state:e.state,standing:dockerRunStanding(n),...n.runnerGone&&!e.ended?{runnerGone:!0}:{},project:e.project,...e.context?{context:e.context}:{},...e.stage?{stage:e.stage}:{},...e.url?{url:e.url}:{},...e.urlNote?{urlNote:$(e.urlNote)}:{},...e.note?{note:$(e.note)}:{},...e.startedAt!==void 0?{startedAt:e.startedAt}:{},...e.endedAt!==void 0?{endedAt:e.endedAt}:{},...e.ranMs!==void 0?{ranMs:e.ranMs}:{},...e.exit?{exit:e.exit}:{},...n.vm?{vm:n.vm}:{},services:d,...n.services.length>d.length?{servicesMore:n.services.length-d.length}:{},totals:n.totals,kills:o.map(c=>({...c,container:c.container.slice(0,12)})),...u?{killsMore:u}:{},...s?{engineLost:{at:s.at,why:$(s.why),...s.backAt!==void 0?{backAt:s.backAt}:{},...h?{killed:h}:{}}}:{},...t?{cleanup:{by:t.by,at:t.at,done:t.done,...r?{left:r}:{},...g?{unlabeled:g}:{},...t.why?{why:$(t.why)}:{}}}:{}}}i(dockerRunBlock,"dockerRunBlock"),a(dockerRunBlock,"dockerRunBlock"),k(dockerRunBlock,"dockerRunBlock"),p(dockerRunBlock,"dockerRunBlock"),l(dockerRunBlock,"dockerRunBlock");export function dockerRunBlockLess(n){if(n.services&&n.services.length>1)return{...n,services:n.services.slice(0,-1),servicesMore:(n.servicesMore??0)+1};if(n.kills&&n.kills.length>1)return{...n,kills:n.kills.slice(0,-1),killsMore:(n.killsMore??0)+1}}i(dockerRunBlockLess,"dockerRunBlockLess"),a(dockerRunBlockLess,"dockerRunBlockLess"),k(dockerRunBlockLess,"dockerRunBlockLess"),p(dockerRunBlockLess,"dockerRunBlockLess"),l(dockerRunBlockLess,"dockerRunBlockLess");export const PAGE_MAX_ROWS=50;const E=["queued","running"];export function dockerRemoteStanding(n){return n.state==="lost"?"lost":E.includes(n.state)?"up":"ended"}i(dockerRemoteStanding,"dockerRemoteStanding"),a(dockerRemoteStanding,"dockerRemoteStanding"),k(dockerRemoteStanding,"dockerRemoteStanding"),p(dockerRemoteStanding,"dockerRemoteStanding"),l(dockerRemoteStanding,"dockerRemoteStanding");export function dockerRemoteRunsList(n,e={}){const t=l(r=>r.completedAt??r.startedAt??r.queuedAt,"since"),s=[...n].sort((r,g)=>t(g)-t(r)||r.run.localeCompare(g.run)),d=s.filter(r=>dockerRemoteStanding(r)==="up"),o=s.filter(r=>dockerRemoteStanding(r)!=="up"),u=o.slice(0,e.endedMax??o.length);return{counts:{up:d.length,lost:o.filter(r=>r.state==="lost").length,ended:o.filter(r=>r.state!=="lost").length},runs:[...d,...u],...u.length<o.length?{endedMore:o.length-u.length}:{}}}i(dockerRemoteRunsList,"dockerRemoteRunsList"),a(dockerRemoteRunsList,"dockerRemoteRunsList"),k(dockerRemoteRunsList,"dockerRemoteRunsList"),p(dockerRemoteRunsList,"dockerRemoteRunsList"),l(dockerRemoteRunsList,"dockerRemoteRunsList");
@@ -1,6 +1,6 @@
1
- "use strict";var g=Object.defineProperty;var s=(e,t)=>g(e,"name",{value:t,configurable:!0});var y=Object.defineProperty,c=s((e,t)=>y(e,"name",{value:t,configurable:!0}),"s"),E=Object.defineProperty,a=c((e,t)=>E(e,"name",{value:t,configurable:!0}),"n");export function joinId(e,t){const i=a(n=>n.replace(/%/g,"%25").replace(/:/g,"%3A"),"esc");return[e,...t.map(n=>i(n===void 0?"":String(n)))].join(":")}s(joinId,"joinId"),c(joinId,"joinId"),a(joinId,"joinId");export function foldMessage(e){return e?e.split(`
2
- `)[0].replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,"<id>").replace(/\b[0-9A-HJKMNP-TV-Z]{26}\b/g,"<id>").replace(/0x[0-9a-f]+/gi,"<hex>").replace(/\b[0-9a-f]{12,}\b/gi,"<id>").replace(/\d+/g,"#").trim().slice(0,140):""}s(foldMessage,"foldMessage"),c(foldMessage,"foldMessage"),a(foldMessage,"foldMessage");const x=a(e=>!!e&&typeof e=="object"&&typeof e.message=="string","isValidationIssue"),v=a(e=>Array.isArray(e)&&e.length?e.map(String).join("."):"(root)","issuePath"),p=3;export function readableErrorMessage(e){const t=e?.trim()??"",i=t.indexOf("["),n=t.slice(0,Math.max(i,0));if(i<0||!/^(?:[A-Za-z_$][\w$]*:\s*)?$/.test(n))return e;let d;try{d=JSON.parse(t.slice(i))}catch{return e}if(!Array.isArray(d)||!d.length||!d.every(x))return e;const o=d.map(m=>`${v(m.path)}: ${m.message}`),r=o.length===1?"1 issue":`${o.length} issues`,h=o.length>p?` (+${o.length-p} more)`:"";return[`${n}Validation failed (${r}): ${o.slice(0,p).join("; ")}${h}`,...o.map(m=>` ${m}`)].join(`
3
- `)}s(readableErrorMessage,"readableErrorMessage"),c(readableErrorMessage,"readableErrorMessage"),a(readableErrorMessage,"readableErrorMessage");const w=/^(?:Uncaught\s+(?:\(in promise\)\s+)?)?((?:[A-Za-z_$][\w$]*)?(?:Error|Exception|Failure|Fault|Rejection))(?:\s*\[[^\]]*\])?:\s*(.+)$/;function l(e){const t=w.exec((e??"").split(`
4
- `)[0].trim());return t?{name:t[1],message:t[2].trim()}:void 0}s(l,"h"),c(l,"u"),a(l,"named");export function appFrameOf(e){for(const t of(e??"").split(`
5
- `)){const i=/^\s*at\s+(.+)$/.exec(t);if(!i||/node_modules|node:internal|node:async_hooks|\(native\)|<anonymous>|\(internal\//.test(i[1]))continue;const n=/\(?([^()\s]+?):(\d+)(?::\d+)?\)?$/.exec(i[1].trim());return n?`${n[1].replace(/^.*?\/(?=(?:src|apps|libs)\/)/,"")}:${n[2]}`:i[1].trim()}}s(appFrameOf,"appFrameOf"),c(appFrameOf,"appFrameOf"),a(appFrameOf,"appFrameOf");export function errorCause(e){const t=readableErrorMessage(e.message),i=l(e.stack),n=l(t),d=l(e.title),o=e.name?.trim()||i?.name||n?.name||d?.name;if(!o)return;let r=(t!==e.message?t:void 0)??(i&&i.name===o?i.message:void 0)??t??d?.message??e.title??"";const h=l(r);h&&h.name===o&&(r=h.message),r=r.split(`
6
- `)[0].trim();const m=appFrameOf(e.stack),f=b.has(errorHeadline({name:o,message:r})?.id??"");return{id:joinId("cause",[o,foldMessage(r),f?void 0:m]),errorName:o,message:r,...m?{frame:m}:{}}}s(errorCause,"errorCause"),c(errorCause,"errorCause"),a(errorCause,"errorCause");const b=new Set(["missing-column","missing-table","connection-refused","out-of-memory"]);export function causeIdWithoutFrame(e){return joinId("cause",[e.errorName,foldMessage(e.message),void 0])}s(causeIdWithoutFrame,"causeIdWithoutFrame"),c(causeIdWithoutFrame,"causeIdWithoutFrame"),a(causeIdWithoutFrame,"causeIdWithoutFrame");const u=a(e=>e?` (\xAB${e}\xBB)`:"","q");export const ERROR_HEADLINES=[{id:"missing-column",match:a(e=>/column "?([\w.]+)"?(?: of relation "?[\w.]+"?)? does not exist|Unknown column '([^']+)'|ER_BAD_FIELD_ERROR/i.exec(e),"match"),say:a(e=>({headline:`The code expects a database column${u(e===!0?void 0:e[1]??e[2])} the database doesn't have`,hint:"Run the migrations, or add the migration the entity change needs."}),"say")},{id:"missing-table",match:a(e=>/relation "?([\w.]+)"? does not exist|Table '([^']+)' doesn't exist|ER_NO_SUCH_TABLE/i.exec(e),"match"),say:a(e=>({headline:`The code expects a database table${u(e===!0?void 0:e[1]??e[2])} the database doesn't have`,hint:"Run the migrations against this database."}),"say")},{id:"unique-violation",match:a((e,t)=>/duplicate key value violates unique constraint "?([\w.]+)"?|Duplicate entry '[^']*' for key '([^']+)'|ER_DUP_ENTRY/i.exec(e)||t.code==="23505","match"),say:a(e=>({headline:`A row with the same unique value already exists${u(e===!0?void 0:e[1]??e[2])}`,hint:"The code inserts a duplicate: look up the existing row first, or upsert."}),"say")},{id:"foreign-key-violation",match:a((e,t)=>/violates foreign key constraint "?([\w.]+)"?|a foreign key constraint fails|ER_NO_REFERENCED_ROW|ER_ROW_IS_REFERENCED/i.exec(e)||t.code==="23503","match"),say:a(e=>({headline:`A row points at a row that doesn't exist, or a row still in use was deleted${u(e===!0?void 0:e[1])}`,hint:"Create the referenced row first, or delete the rows that point at it."}),"say")},{id:"connection-refused",match:a((e,t)=>/ECONNREFUSED|connection refused|connect ECONNREFUSED/i.exec(e)||t.code==="ECONNREFUSED","match"),say:a(()=>({headline:"A service the code connects to is not running, or not listening where the code looks",hint:"Start it (database, cache, broker or API), or fix its host and port."}),"say")},{id:"out-of-memory",match:a((e,t)=>/heap out of memory|JavaScript heap|out of memory|ENOMEM|Allocation failed/i.exec(e)||t.code==="ENOMEM","match"),say:a(()=>({headline:"The process ran out of memory",hint:"Something holds or loads too much at once \u2014 look for an unbounded list, cache or query."}),"say")},{id:"jwt-expired",match:a((e,t)=>/jwt expired|token expired/i.exec(e)||t.name==="TokenExpiredError","match"),say:a(()=>({headline:"A sign-in token expired",hint:"Sign in again; if it keeps happening, the client is not refreshing its token."}),"say")},{id:"jwt-invalid",match:a((e,t)=>/jwt malformed|invalid signature|invalid token|jwt must be provided|jwt audience invalid|jwt issuer invalid/i.exec(e)||t.name==="JsonWebTokenError","match"),say:a(()=>({headline:"A sign-in token is not valid here",hint:"Its signature, audience or issuer does not match what this service expects."}),"say")},{id:"timeout",match:a((e,t)=>/ETIMEDOUT|ESOCKETTIMEDOUT|timed? ?out|timeout exceeded|statement timeout|canceling statement due to|Query read timeout/i.exec(e)||t.name==="TimeoutError"||t.code==="ETIMEDOUT","match"),say:a(()=>({headline:"Something took too long and was cut off",hint:"A slow query, a busy dependency or a lock \u2014 open the failing step to see which."}),"say")},{id:"unauthorized",match:a((e,t)=>t.status===401||t.name==="UnauthorizedException"||/^Unauthorized$/i.test(e.trim()),"match"),say:a(()=>({headline:"The request was not signed in (401)",hint:"It came without a valid session or token."}),"say")},{id:"forbidden",match:a((e,t)=>t.status===403||t.name==="ForbiddenException"||/^Forbidden(?: resource)?$/i.test(e.trim()),"match"),say:a(()=>({headline:"The signed-in user is not allowed to do this (403)",hint:"A role or permission check refused it."}),"say")}];export function errorHeadline(e){const t=[e.code,e.message].filter(Boolean).join(" ");for(const i of ERROR_HEADLINES){const n=i.match(t,e);if(n)return{id:i.id,...i.say(n)}}}s(errorHeadline,"errorHeadline"),c(errorHeadline,"errorHeadline"),a(errorHeadline,"errorHeadline");
1
+ "use strict";var E=Object.defineProperty;var r=(e,t)=>E(e,"name",{value:t,configurable:!0});var x=Object.defineProperty,c=r((e,t)=>x(e,"name",{value:t,configurable:!0}),"s"),v=Object.defineProperty,d=c((e,t)=>v(e,"name",{value:t,configurable:!0}),"s"),b=Object.defineProperty,m=d((e,t)=>b(e,"name",{value:t,configurable:!0}),"s"),w=Object.defineProperty,a=m((e,t)=>w(e,"name",{value:t,configurable:!0}),"n");export function joinId(e,t){const i=a(o=>o.replace(/%/g,"%25").replace(/:/g,"%3A"),"esc");return[e,...t.map(o=>i(o===void 0?"":String(o)))].join(":")}r(joinId,"joinId"),c(joinId,"joinId"),d(joinId,"joinId"),m(joinId,"joinId"),a(joinId,"joinId");export function foldMessage(e){return e?e.split(`
2
+ `)[0].replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi,"<id>").replace(/\b[0-9A-HJKMNP-TV-Z]{26}\b/g,"<id>").replace(/0x[0-9a-f]+/gi,"<hex>").replace(/\b[0-9a-f]{12,}\b/gi,"<id>").replace(/\d+/g,"#").trim().slice(0,140):""}r(foldMessage,"foldMessage"),c(foldMessage,"foldMessage"),d(foldMessage,"foldMessage"),m(foldMessage,"foldMessage"),a(foldMessage,"foldMessage");const $=a(e=>!!e&&typeof e=="object"&&typeof e.message=="string","isValidationIssue"),k=a(e=>Array.isArray(e)&&e.length?e.map(String).join("."):"(root)","issuePath"),g=3;export function readableErrorMessage(e){const t=e?.trim()??"",i=t.indexOf("["),o=t.slice(0,Math.max(i,0));if(i<0||!/^(?:[A-Za-z_$][\w$]*:\s*)?$/.test(o))return e;let l;try{l=JSON.parse(t.slice(i))}catch{return e}if(!Array.isArray(l)||!l.length||!l.every($))return e;const n=l.map(u=>`${k(u.path)}: ${u.message}`),s=n.length===1?"1 issue":`${n.length} issues`,f=n.length>g?` (+${n.length-g} more)`:"";return[`${o}Validation failed (${s}): ${n.slice(0,g).join("; ")}${f}`,...n.map(u=>` ${u}`)].join(`
3
+ `)}r(readableErrorMessage,"readableErrorMessage"),c(readableErrorMessage,"readableErrorMessage"),d(readableErrorMessage,"readableErrorMessage"),m(readableErrorMessage,"readableErrorMessage"),a(readableErrorMessage,"readableErrorMessage");const O=/^(?:Uncaught\s+(?:\(in promise\)\s+)?)?((?:[A-Za-z_$][\w$]*)?(?:Error|Exception|Failure|Fault|Rejection))(?:\s*\[[^\]]*\])?:\s*(.+)$/;function h(e){const t=O.exec((e??"").split(`
4
+ `)[0].trim());return t?{name:t[1],message:t[2].trim()}:void 0}r(h,"u"),c(h,"l"),d(h,"h"),m(h,"u"),a(h,"named");export function appFrameOf(e){for(const t of(e??"").split(`
5
+ `)){const i=/^\s*at\s+(.+)$/.exec(t);if(!i||/node_modules|node:internal|node:async_hooks|\(native\)|<anonymous>|\(internal\//.test(i[1]))continue;const o=/\(?([^()\s]+?):(\d+)(?::\d+)?\)?$/.exec(i[1].trim());return o?`${o[1].replace(/^.*?\/(?=(?:src|apps|libs)\/)/,"")}:${o[2]}`:i[1].trim()}}r(appFrameOf,"appFrameOf"),c(appFrameOf,"appFrameOf"),d(appFrameOf,"appFrameOf"),m(appFrameOf,"appFrameOf"),a(appFrameOf,"appFrameOf");export function errorCause(e){const t=readableErrorMessage(e.message),i=h(e.stack),o=h(t),l=h(e.title),n=e.name?.trim()||i?.name||o?.name||l?.name;if(!n)return;let s=(t!==e.message?t:void 0)??(i&&i.name===n?i.message:void 0)??t??l?.message??e.title??"";const f=h(s);f&&f.name===n&&(s=f.message),s=s.split(`
6
+ `)[0].trim();const u=appFrameOf(e.stack),y=R.has(errorHeadline({name:n,message:s})?.id??"");return{id:joinId("cause",[n,foldMessage(s),y?void 0:u]),errorName:n,message:s,...u?{frame:u}:{}}}r(errorCause,"errorCause"),c(errorCause,"errorCause"),d(errorCause,"errorCause"),m(errorCause,"errorCause"),a(errorCause,"errorCause");const R=new Set(["missing-column","missing-table","connection-refused","out-of-memory"]);export function causeIdWithoutFrame(e){return joinId("cause",[e.errorName,foldMessage(e.message),void 0])}r(causeIdWithoutFrame,"causeIdWithoutFrame"),c(causeIdWithoutFrame,"causeIdWithoutFrame"),d(causeIdWithoutFrame,"causeIdWithoutFrame"),m(causeIdWithoutFrame,"causeIdWithoutFrame"),a(causeIdWithoutFrame,"causeIdWithoutFrame");const p=a(e=>e?` (\xAB${e}\xBB)`:"","q");export const ERROR_HEADLINES=[{id:"missing-column",match:a(e=>/column "?([\w.]+)"?(?: of relation "?[\w.]+"?)? does not exist|Unknown column '([^']+)'|ER_BAD_FIELD_ERROR/i.exec(e),"match"),say:a(e=>({headline:`The code expects a database column${p(e===!0?void 0:e[1]??e[2])} the database doesn't have`,hint:"Run the migrations, or add the migration the entity change needs."}),"say")},{id:"missing-table",match:a(e=>/relation "?([\w.]+)"? does not exist|Table '([^']+)' doesn't exist|ER_NO_SUCH_TABLE/i.exec(e),"match"),say:a(e=>({headline:`The code expects a database table${p(e===!0?void 0:e[1]??e[2])} the database doesn't have`,hint:"Run the migrations against this database."}),"say")},{id:"unique-violation",match:a((e,t)=>/duplicate key value violates unique constraint "?([\w.]+)"?|Duplicate entry '[^']*' for key '([^']+)'|ER_DUP_ENTRY/i.exec(e)||t.code==="23505","match"),say:a(e=>({headline:`A row with the same unique value already exists${p(e===!0?void 0:e[1]??e[2])}`,hint:"The code inserts a duplicate: look up the existing row first, or upsert."}),"say")},{id:"foreign-key-violation",match:a((e,t)=>/violates foreign key constraint "?([\w.]+)"?|a foreign key constraint fails|ER_NO_REFERENCED_ROW|ER_ROW_IS_REFERENCED/i.exec(e)||t.code==="23503","match"),say:a(e=>({headline:`A row points at a row that doesn't exist, or a row still in use was deleted${p(e===!0?void 0:e[1])}`,hint:"Create the referenced row first, or delete the rows that point at it."}),"say")},{id:"connection-refused",match:a((e,t)=>/ECONNREFUSED|connection refused|connect ECONNREFUSED/i.exec(e)||t.code==="ECONNREFUSED","match"),say:a(()=>({headline:"A service the code connects to is not running, or not listening where the code looks",hint:"Start it (database, cache, broker or API), or fix its host and port."}),"say")},{id:"out-of-memory",match:a((e,t)=>/heap out of memory|JavaScript heap|out of memory|ENOMEM|Allocation failed/i.exec(e)||t.code==="ENOMEM","match"),say:a(()=>({headline:"The process ran out of memory",hint:"Something holds or loads too much at once \u2014 look for an unbounded list, cache or query."}),"say")},{id:"jwt-expired",match:a((e,t)=>/jwt expired|token expired/i.exec(e)||t.name==="TokenExpiredError","match"),say:a(()=>({headline:"A sign-in token expired",hint:"Sign in again; if it keeps happening, the client is not refreshing its token."}),"say")},{id:"jwt-invalid",match:a((e,t)=>/jwt malformed|invalid signature|invalid token|jwt must be provided|jwt audience invalid|jwt issuer invalid/i.exec(e)||t.name==="JsonWebTokenError","match"),say:a(()=>({headline:"A sign-in token is not valid here",hint:"Its signature, audience or issuer does not match what this service expects."}),"say")},{id:"timeout",match:a((e,t)=>/ETIMEDOUT|ESOCKETTIMEDOUT|timed? ?out|timeout exceeded|statement timeout|canceling statement due to|Query read timeout/i.exec(e)||t.name==="TimeoutError"||t.code==="ETIMEDOUT","match"),say:a(()=>({headline:"Something took too long and was cut off",hint:"A slow query, a busy dependency or a lock \u2014 open the failing step to see which."}),"say")},{id:"unauthorized",match:a((e,t)=>t.status===401||t.name==="UnauthorizedException"||/^Unauthorized$/i.test(e.trim()),"match"),say:a(()=>({headline:"The request was not signed in (401)",hint:"It came without a valid session or token."}),"say")},{id:"forbidden",match:a((e,t)=>t.status===403||t.name==="ForbiddenException"||/^Forbidden(?: resource)?$/i.test(e.trim()),"match"),say:a(()=>({headline:"The signed-in user is not allowed to do this (403)",hint:"A role or permission check refused it."}),"say")}];export function errorHeadline(e){const t=[e.code,e.message].filter(Boolean).join(" ");for(const i of ERROR_HEADLINES){const o=i.match(t,e);if(o)return{id:i.id,...i.say(o)}}}r(errorHeadline,"errorHeadline"),c(errorHeadline,"errorHeadline"),d(errorHeadline,"errorHeadline"),m(errorHeadline,"errorHeadline"),a(errorHeadline,"errorHeadline");
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var s=(e,r)=>E(e,"name",{value:r,configurable:!0});var m=Object.defineProperty,c=s((e,r)=>m(e,"name",{value:r,configurable:!0}),"s"),p=Object.defineProperty,l=c((e,r)=>p(e,"name",{value:r,configurable:!0}),"s");export const ERROR_DISMISSED="error-dismissed",ERROR_RESTORED="error-restored",LENS_EVENT_SOURCE="lens",MAX_DISMISSAL_EVENT_IDS=200;const y=2048;export const MAX_DISMISSAL_REASON_CHARS=500;const b=300,I=new Set(["dashboard","cli","agent"]);export function readErrorDismissal(e){if(e.source!==LENS_EVENT_SOURCE||!e.raw||typeof e.raw!="object")return;const r=e.raw,i=r.groupId;if(typeof i!="string"||i.length===0||i.length>2048)return;if(r.kind===ERROR_RESTORED)return{kind:ERROR_RESTORED,groupId:i};if(r.kind!==ERROR_DISMISSED)return;const n=r.until;if(typeof n!="number"||!Number.isFinite(n))return;const f=Array.isArray(r.eventIds)?r.eventIds.filter(t=>typeof t=="string"&&t.length>0).slice(0,200):[],o=I.has(r.by)?r.by:void 0,a=l((t,S)=>typeof t=="string"&&t.trim()?t.trim().slice(0,S):void 0,"text"),d=a(r.reason,500),u=a(r.title,300);return{kind:ERROR_DISMISSED,groupId:i,until:Math.min(n,e.timestamp),eventIds:f,...o?{by:o}:{},...d?{reason:d}:{},...u?{title:u}:{}}}s(readErrorDismissal,"readErrorDismissal"),c(readErrorDismissal,"readErrorDismissal"),l(readErrorDismissal,"readErrorDismissal");
1
+ "use strict";var S=Object.defineProperty;var s=(e,r)=>S(e,"name",{value:r,configurable:!0});var b=Object.defineProperty,u=s((e,r)=>b(e,"name",{value:r,configurable:!0}),"s"),y=Object.defineProperty,c=u((e,r)=>y(e,"name",{value:r,configurable:!0}),"s"),g=Object.defineProperty,f=c((e,r)=>g(e,"name",{value:r,configurable:!0}),"s"),I=Object.defineProperty,E=f((e,r)=>I(e,"name",{value:r,configurable:!0}),"s");export const ERROR_DISMISSED="error-dismissed",ERROR_RESTORED="error-restored",LENS_EVENT_SOURCE="lens",MAX_DISMISSAL_EVENT_IDS=200;const D=2048;export const MAX_DISMISSAL_REASON_CHARS=500;const _=300,v=new Set(["dashboard","cli","agent"]);export function readErrorDismissal(e){if(e.source!==LENS_EVENT_SOURCE||!e.raw||typeof e.raw!="object")return;const r=e.raw,i=r.groupId;if(typeof i!="string"||i.length===0||i.length>2048)return;if(r.kind===ERROR_RESTORED)return{kind:ERROR_RESTORED,groupId:i};if(r.kind!==ERROR_DISMISSED)return;const n=r.until;if(typeof n!="number"||!Number.isFinite(n))return;const m=Array.isArray(r.eventIds)?r.eventIds.filter(t=>typeof t=="string"&&t.length>0).slice(0,200):[],o=v.has(r.by)?r.by:void 0,a=E((t,p)=>typeof t=="string"&&t.trim()?t.trim().slice(0,p):void 0,"text"),d=a(r.reason,500),l=a(r.title,300);return{kind:ERROR_DISMISSED,groupId:i,until:Math.min(n,e.timestamp),eventIds:m,...o?{by:o}:{},...d?{reason:d}:{},...l?{title:l}:{}}}s(readErrorDismissal,"readErrorDismissal"),u(readErrorDismissal,"readErrorDismissal"),c(readErrorDismissal,"readErrorDismissal"),f(readErrorDismissal,"readErrorDismissal"),E(readErrorDismissal,"readErrorDismissal");
package/lib/event-loop.js CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var s=(e,t)=>f(e,"name",{value:t,configurable:!0});var w=Object.defineProperty,a=s((e,t)=>w(e,"name",{value:t,configurable:!0}),"r"),h=Object.defineProperty,l=a((e,t)=>h(e,"name",{value:t,configurable:!0}),"r");export const LENS_CAUSES={"lensmcp-gc":"forced GC","lensmcp-cleanup":"cleanup","lensmcp-write":"writing events","lensmcp-capture":"capturing values"};export function lensOwnWork(e){const t=typeof e.cause=="string"&&e.cause.startsWith("lensmcp-");if(!t&&!(typeof e.lensMs=="number"&&e.durationMs>0&&e.lensMs>=e.durationMs/2))return;const o=t?LENS_CAUSES[e.cause]:void 0;return o?`LensMCP's own work \u2014 ${o}`:"LensMCP's own work"}s(lensOwnWork,"lensOwnWork"),a(lensOwnWork,"lensOwnWork"),l(lensOwnWork,"lensOwnWork");export function waitedBehind(e){const t=new Set,o=new Set;for(const n of e.evidence)n.relation==="executing"||(n.requestId?n.requestId===e.requestId:!n.flowId||n.flowId===e.flowId)||(t.add(n.requestId??n.flowId),n.flowId&&n.flowId!==e.flowId&&o.add(n.flowId));return{requests:t.size,flows:o.size,atLeast:e.evidenceTruncated}}s(waitedBehind,"waitedBehind"),a(waitedBehind,"waitedBehind"),l(waitedBehind,"waitedBehind");export function waitedLine(e){const t=waitedBehind(e);return t.requests?`${t.atLeast?"at least ":""}${t.requests} request${t.requests===1?"":"s"} waited behind it`:void 0}s(waitedLine,"waitedLine"),a(waitedLine,"waitedLine"),l(waitedLine,"waitedLine");export function flowStalls(e,t){const o={ran:[],overlapped:[]};for(const n of e){if(lensOwnWork(n))continue;if(n.flowId===t){o.ran.push(n);continue}const u=n.endAt??n.observedAt,d=n.evidence.filter(r=>r.flowId===t).map(r=>[Math.max(r.startAt,n.startAt),Math.min(r.endAt,u)]).filter(([r,i])=>i>=r).sort((r,i)=>r[0]-i[0]);if(!d.length)continue;let p=0,c=-1/0;for(const[r,i]of d)i>c&&(p+=i-Math.max(r,c)),c=Math.max(c,i);o.overlapped.push({incident:n,overlapMs:Math.round(p*100)/100})}return o}s(flowStalls,"flowStalls"),a(flowStalls,"flowStalls"),l(flowStalls,"flowStalls");export function overlapLine(e){if(!e.length)return;const t=[...new Set(e.map(u=>u.incident.loop.project))],o=t.length<=2?t.join(" and "):`${t.length} services`,n=e.length;return{count:n,services:t,longestMs:Math.max(...e.map(u=>u.overlapMs)),text:`${n} pause${n===1?"":"s"} in ${o} while this flow was open \u2014 not this flow\u2019s code`}}s(overlapLine,"overlapLine"),a(overlapLine,"overlapLine"),l(overlapLine,"overlapLine");export const LOOP_STARTUP_MS=6e4;export function loopStartedAt(e){if(!e.startsWith("node:"))return;const t=Number(e.slice(e.lastIndexOf(":")+1));return Number.isFinite(t)&&t>0?t:void 0}s(loopStartedAt,"loopStartedAt"),a(loopStartedAt,"loopStartedAt"),l(loopStartedAt,"loopStartedAt");export function loopPhaseAt(e,t){const o=loopStartedAt(e);if(o===void 0)return;const n=Math.max(0,Math.round(t-o));return{phase:n<LOOP_STARTUP_MS?"startup":"running",sinceStartMs:n}}s(loopPhaseAt,"loopPhaseAt"),a(loopPhaseAt,"loopPhaseAt"),l(loopPhaseAt,"loopPhaseAt");
1
+ "use strict";var h=Object.defineProperty;var s=(e,t)=>h(e,"name",{value:t,configurable:!0});var v=Object.defineProperty,a=s((e,t)=>v(e,"name",{value:t,configurable:!0}),"s"),m=Object.defineProperty,i=a((e,t)=>m(e,"name",{value:t,configurable:!0}),"s"),M=Object.defineProperty,l=i((e,t)=>M(e,"name",{value:t,configurable:!0}),"r"),S=Object.defineProperty,u=l((e,t)=>S(e,"name",{value:t,configurable:!0}),"r");export const LENS_CAUSES={"lensmcp-gc":"forced GC","lensmcp-cleanup":"cleanup","lensmcp-write":"writing events","lensmcp-capture":"capturing values"};export function lensOwnWork(e){const t=typeof e.cause=="string"&&e.cause.startsWith("lensmcp-");if(!t&&!(typeof e.lensMs=="number"&&e.durationMs>0&&e.lensMs>=e.durationMs/2))return;const o=t?LENS_CAUSES[e.cause]:void 0;return o?`LensMCP's own work \u2014 ${o}`:"LensMCP's own work"}s(lensOwnWork,"lensOwnWork"),a(lensOwnWork,"lensOwnWork"),i(lensOwnWork,"lensOwnWork"),l(lensOwnWork,"lensOwnWork"),u(lensOwnWork,"lensOwnWork");export function waitedBehind(e){const t=new Set,o=new Set;for(const n of e.evidence)n.relation==="executing"||(n.requestId?n.requestId===e.requestId:!n.flowId||n.flowId===e.flowId)||(t.add(n.requestId??n.flowId),n.flowId&&n.flowId!==e.flowId&&o.add(n.flowId));return{requests:t.size,flows:o.size,atLeast:e.evidenceTruncated}}s(waitedBehind,"waitedBehind"),a(waitedBehind,"waitedBehind"),i(waitedBehind,"waitedBehind"),l(waitedBehind,"waitedBehind"),u(waitedBehind,"waitedBehind");export function waitedLine(e){const t=waitedBehind(e);return t.requests?`${t.atLeast?"at least ":""}${t.requests} request${t.requests===1?"":"s"} waited behind it`:void 0}s(waitedLine,"waitedLine"),a(waitedLine,"waitedLine"),i(waitedLine,"waitedLine"),l(waitedLine,"waitedLine"),u(waitedLine,"waitedLine");export function flowStalls(e,t){const o={ran:[],overlapped:[]};for(const n of e){if(lensOwnWork(n))continue;if(n.flowId===t){o.ran.push(n);continue}const c=n.endAt??n.observedAt,f=n.evidence.filter(r=>r.flowId===t).map(r=>[Math.max(r.startAt,n.startAt),Math.min(r.endAt,c)]).filter(([r,d])=>d>=r).sort((r,d)=>r[0]-d[0]);if(!f.length)continue;let w=0,p=-1/0;for(const[r,d]of f)d>p&&(w+=d-Math.max(r,p)),p=Math.max(p,d);o.overlapped.push({incident:n,overlapMs:Math.round(w*100)/100})}return o}s(flowStalls,"flowStalls"),a(flowStalls,"flowStalls"),i(flowStalls,"flowStalls"),l(flowStalls,"flowStalls"),u(flowStalls,"flowStalls");export function overlapLine(e){if(!e.length)return;const t=[...new Set(e.map(c=>c.incident.loop.project))],o=t.length<=2?t.join(" and "):`${t.length} services`,n=e.length;return{count:n,services:t,longestMs:Math.max(...e.map(c=>c.overlapMs)),text:`${n} pause${n===1?"":"s"} in ${o} while this flow was open \u2014 not this flow\u2019s code`}}s(overlapLine,"overlapLine"),a(overlapLine,"overlapLine"),i(overlapLine,"overlapLine"),l(overlapLine,"overlapLine"),u(overlapLine,"overlapLine");export const LOOP_STARTUP_MS=6e4;export function loopStartedAt(e){if(!e.startsWith("node:"))return;const t=Number(e.slice(e.lastIndexOf(":")+1));return Number.isFinite(t)&&t>0?t:void 0}s(loopStartedAt,"loopStartedAt"),a(loopStartedAt,"loopStartedAt"),i(loopStartedAt,"loopStartedAt"),l(loopStartedAt,"loopStartedAt"),u(loopStartedAt,"loopStartedAt");export function loopPhaseAt(e,t){const o=loopStartedAt(e);if(o===void 0)return;const n=Math.max(0,Math.round(t-o));return{phase:n<LOOP_STARTUP_MS?"startup":"running",sinceStartMs:n}}s(loopPhaseAt,"loopPhaseAt"),a(loopPhaseAt,"loopPhaseAt"),i(loopPhaseAt,"loopPhaseAt"),l(loopPhaseAt,"loopPhaseAt"),u(loopPhaseAt,"loopPhaseAt");
@@ -1,2 +1,2 @@
1
- "use strict";var K=Object.defineProperty;var h=(t,e)=>K(t,"name",{value:e,configurable:!0});var W=Object.defineProperty,l=h((t,e)=>W(t,"name",{value:e,configurable:!0}),"h"),G=Object.defineProperty,c=l((t,e)=>G(t,"name",{value:e,configurable:!0}),"d");import{LENS_EVENT_SOURCE as J}from"./error-dismissal.js";export const EXPECTED_RULE_SET="expected-rule-set",EXPECTED_RULE_REMOVED="expected-rule-removed";const L=new Set(["dashboard","cli","agent"]),f=60*6e4;export const EXPECTED_RULE_DEFAULT_TTL_MS=168*f,EXPECTED_RULE_MAX_TTL_MS=720*f,EXPECTED_RULE_MIN_REASON_CHARS=8,MAX_EXPECTED_REASON_CHARS=500;const $=300,V=300,D=120,Z=200,U=20,p=c(t=>!!t&&typeof t=="object"&&!Array.isArray(t),"isObj"),x=c((t,e)=>typeof t=="string"&&t.trim()?t.trim().slice(0,e):void 0,"text"),_=c(t=>!!t&&t.replace(/[*?\s/:.#_-]/g,"").length>=2,"meaningful");export const EXPECTED_SCOPE_FIELDS=["route","span","flow"],EXPECTED_OUTCOME_FIELDS=["status","error","message"];export function checkExpectedMatch(t){if(!p(t))return{error:"a rule needs a match: a flow scope (route, span or flow) and an outcome (status, error or message)"};const e={};for(const r of["service","route","span","flow","error","message"]){const o=t[r];if(o==null||o==="")continue;if(typeof o!="string")return{error:`\`${r}\` must be text`};const i=o.trim();if(i.length>$)return{error:`\`${r}\` is longer than ${$} characters`};i&&(e[r]=i)}if(t.status!==void 0&&t.status!==null&&t.status!==""){const r=typeof t.status=="string"?Number(t.status):t.status;if(typeof r!="number"||!Number.isInteger(r)||r<100||r>599)return{error:"`status` must be an HTTP status (100\u2013599)"};e.status=r}const s=t.attribute;if(s!=null){const r=p(s)?x(s.name,100):void 0,o=p(s)?typeof s.value=="number"?String(s.value):x(s.value,$):void 0;if(!r||!o)return{error:"`attribute` needs a `name` and a `value` (one attribute of the flow, such as a tenant id)"};e.attribute={name:r,value:o}}return EXPECTED_SCOPE_FIELDS.some(r=>_(e[r]))?e.status===void 0&&!_(e.error)&&!_(e.message)?{error:"a rule needs an outcome \u2014 a `status`, an `error` key or a `message` pattern \u2014 saying WHICH failure is expected in that flow"}:{match:e}:{error:`a rule needs a flow scope \u2014 a \`route\`, a \`span\` or a \`flow\` \u2014 not only ${e.service?`the service \xAB${e.service}\xBB`:"an outcome"}: \xABeverything in a service\xBB is not expected, it is unwatched`}}h(checkExpectedMatch,"checkExpectedMatch"),l(checkExpectedMatch,"checkExpectedMatch"),c(checkExpectedMatch,"checkExpectedMatch");export function describeExpectedMatch(t){return[t.service,t.route,t.span,t.flow?`flow ${t.flow}`:void 0,t.status!==void 0?String(t.status):void 0,t.error,t.message?`\xAB${t.message}\xBB`:void 0,t.attribute?`${t.attribute.name}=${t.attribute.value}`:void 0].filter(Boolean).join(" \xB7 ")}h(describeExpectedMatch,"describeExpectedMatch"),l(describeExpectedMatch,"describeExpectedMatch"),c(describeExpectedMatch,"describeExpectedMatch");export function readExpectedRule(t){if(t.source!==J||!p(t.raw))return;const e=t.raw,s=x(e.id,D);if(!s)return;if(e.kind===EXPECTED_RULE_REMOVED)return{kind:EXPECTED_RULE_REMOVED,id:s,...L.has(e.by)?{by:e.by}:{}};if(e.kind!==EXPECTED_RULE_SET||!L.has(e.by))return;const r=x(e.reason,MAX_EXPECTED_REASON_CHARS);if(!r)return;const o=checkExpectedMatch(e.match);if("error"in o)return;const i=Math.min(typeof e.createdAt=="number"&&Number.isFinite(e.createdAt)?e.createdAt:t.timestamp,t.timestamp),u=typeof e.expiresAt=="number"&&Number.isFinite(e.expiresAt)?e.expiresAt:i+EXPECTED_RULE_DEFAULT_TTL_MS,a=x(e.title,V);return{kind:EXPECTED_RULE_SET,id:s,match:o.match,reason:r,by:e.by,createdAt:i,expiresAt:Math.min(u,i+EXPECTED_RULE_MAX_TTL_MS),...a?{title:a}:{}}}h(readExpectedRule,"readExpectedRule"),l(readExpectedRule,"readExpectedRule"),c(readExpectedRule,"readExpectedRule");export function expectedRuleTtlMs(t){return t===void 0||!Number.isFinite(t)||t<=0?EXPECTED_RULE_DEFAULT_TTL_MS:Math.min(Math.round(t*f),EXPECTED_RULE_MAX_TTL_MS)}h(expectedRuleTtlMs,"expectedRuleTtlMs"),l(expectedRuleTtlMs,"expectedRuleTtlMs"),c(expectedRuleTtlMs,"expectedRuleTtlMs");function j(t){let e=2166136261;for(let s=0;s<t.length;s++)e=Math.imul(e^t.charCodeAt(s),16777619);return(e>>>0).toString(36)}h(j,"F"),l(j,"z"),c(j,"hashOf");export function readRepositoryExpectedRules(t,e){const s=[],r=[];return t==null?{rules:s,problems:r}:Array.isArray(t)?(t.forEach((o,i)=>{if(!p(o))return void r.push(`expectedFailures[${i}] is not an object`);const u=checkExpectedMatch(p(o.match)?o.match:o);if("error"in u)return void r.push(`expectedFailures[${i}]: ${u.error}`);const a=x(o.reason,MAX_EXPECTED_REASON_CHARS);if(!a)return void r.push(`expectedFailures[${i}] has no reason \u2014 say why it is expected`);const d=`repository:${x(o.id,D)??j(JSON.stringify(u.match))}`;if(s.some(m=>m.id===d))return void r.push(`expectedFailures[${i}] repeats the id ${d}`);s.push({id:d,match:u.match,reason:a,by:"repository",createdAt:e})}),{rules:s,problems:r}):{rules:s,problems:["expectedFailures is not a list \u2014 no repository rule is read"]}}h(readRepositoryExpectedRules,"readRepositoryExpectedRules"),l(readRepositoryExpectedRules,"readRepositoryExpectedRules"),c(readRepositoryExpectedRules,"readRepositoryExpectedRules");const n=c(t=>typeof t=="string"&&t?t:void 0,"str"),I=c(t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,"num"),z=c(t=>{const e=t.split(/[?#]/)[0]??t,s=/^[a-z][a-z0-9+.-]*:\/\/[^/]+(\/.*)?$/i.exec(e);return s?s[1]??"/":e},"pathOf"),Q=new Set(["sessionId","flowId","requestId","parentRequestId","runId","traceparent","originNodeId","causedByNodeId","userActionId","browserContextId","frameId","tabId","url","route","projectName"]),S=24;export function eventAttributes(t){let e;const s=c((a,d)=>{if(e&&Object.keys(e).length>=S)return;const m=typeof d=="string"?d:typeof d=="number"||typeof d=="boolean"?String(d):void 0;m===void 0||m.length>$||((e??={})[a]=m)},"put"),r=t.context??{};for(const a of Object.keys(r))Q.has(a)||s(a,r[a]);const o=p(t.raw)?t.raw:void 0;if(!o)return e;const i=p(o.span)?o.span:void 0,u=p(o.request)?o.request:void 0;for(const a of[o.attributes,i?.attributes,u?.attributes,o.data,Array.isArray(i?.args)?i?.args[0]:i?.args])if(p(a))for(const d of Object.keys(a))s(d,a[d]);return e}h(eventAttributes,"eventAttributes"),l(eventAttributes,"eventAttributes"),c(eventAttributes,"eventAttributes");export function failureFacts(t){const e=p(t.raw)?t.raw:{},s=t.context??{},r=p(e.request)?e.request:{},o=p(e.span)?e.span:{},i=p(r.error)?r.error:{},u=p(o.error)?o.error:{},a=p(e.error)?e.error:{},d=n(e.kind),m=[],A=n(r.route)??(d==="egress"?n(e.path):void 0);A&&m.push(A);const y=n(e.url)??n(r.url);y&&m.push(z(y)),d!=="server-request"&&n(s.route)&&m.push(n(s.route));const v=[];if(d==="queue-failed"||d==="queue-enqueued"){const w=n(e.queue),M=e.jobId===void 0||e.jobId===null?void 0:String(e.jobId);w&&v.push(`job:${w}`),M&&v.push(`job:${M}`),w&&M&&v.push(`job:${w}#${M}`),n(e.name)&&v.push(`job:${n(e.name)}`)}const b=[i.errorKey,u.errorKey,a.errorKey,e.errorKey,i.reason,u.reason].map(n).filter(w=>!!w),k=n(i.message)??n(t.message)??n(u.message)??n(a.message)??n(e.failedReason)??n(e.error)??n(e.message)??n(t.title),P=I(r.status)??I(e.status),B=n(s.flowId)??n(o.flowId)??n(r.flowId),F=n(s.requestId)??n(r.requestId)??n(o.requestId),H=eventAttributes(t);return{...n(e.project)??n(s.projectName)?{service:n(e.project)??n(s.projectName)}:{},...n(r.method)??n(e.method)?{method:n(r.method)??n(e.method)}:{},...m.length?{routes:m}:{},...n(o.name)?{span:n(o.name)}:{},...B?{flowId:B}:{},...v.length?{flowNames:v}:{},...P!==void 0?{status:P}:{},...n(i.name)??n(u.name)??n(a.name)?{errorName:n(i.name)??n(u.name)??n(a.name)}:{},...b.length?{errorKeys:b}:{},...k?{message:k}:{},...H?{attributes:H}:{},...F?{requestId:F}:{}}}h(failureFacts,"failureFacts"),l(failureFacts,"failureFacts"),c(failureFacts,"failureFacts");export class FailureContextIndex{static{h(this,"FailureContextIndex")}static{l(this,"FailureContextIndex")}static{c(this,"FailureContextIndex")}constructor(e=5e3,s=2e3){this.maxRequests=e,this.maxFlows=s,this.requests=new Map,this.flows=new Map}observe(e){const s=p(e.raw)?e.raw:void 0,r=e.context??{},o=n(r.flowId);if(o&&(s?.attributes!==void 0||p(s?.span)||r.tenantIdHash!==void 0||r.userIdHash!==void 0||s?.data!==void 0)){const y=eventAttributes(e);if(y){const v=this.flows.get(o);this.flows.delete(o);const b={...v??{},...y};this.flows.set(o,Object.keys(b).length>S?Object.fromEntries(Object.entries(b).slice(-S)):b),this.flows.size>this.maxFlows&&this.flows.delete(this.flows.keys().next().value)}}const i=n(s?.kind);if(!s||i!=="server-request"&&i!=="gateway-request")return;const u=p(s.request)?s.request:s,a=n(r.requestId)??n(u.requestId);if(!a)return;const d=this.requests.get(a)??{},m=n(u.url),A={...d,...n(s.project)&&(i==="server-request"||!d.service)?{service:n(s.project)}:{},...n(u.method)?{method:n(u.method)}:{},...i==="server-request"&&n(u.route)?{route:n(u.route)}:{},...m?{path:z(m)}:{},...I(u.status)!==void 0&&(i==="server-request"||d.status===void 0)?{status:I(u.status)}:{}};return this.requests.delete(a),this.requests.set(a,A),this.requests.size>this.maxRequests&&this.requests.delete(this.requests.keys().next().value),i==="server-request"?a:void 0}request(e){return e?this.requests.get(e):void 0}enrich(e){const s=this.request(e.requestId),r=e.flowId?this.flows.get(e.flowId):void 0;if(!s&&!r)return e;const o=[...e.routes??[],...s?.route?[s.route]:[],...s?.path?[s.path]:[]];return{...e,...e.service??s?.service?{service:e.service??s?.service}:{},...e.method??s?.method?{method:e.method??s?.method}:{},...o.length?{routes:[...new Set(o)]}:{},...e.status??s?.status!==void 0?{status:e.status??s?.status}:{},...r||e.attributes?{attributes:{...r??{},...e.attributes??{}}}:{}}}}const R=new Map,C=c((t,e)=>t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,e).replace(/\?/g,"."),"globBody");function E(t,e="whole"){const s=`${e}\0${t}`;let r=R.get(s);return r||(r=e==="whole"?new RegExp(`^${C(t,"[\\s\\S]*")}$`,"i"):e==="anywhere"?new RegExp(C(t,"[\\s\\S]*"),"i"):new RegExp(`(?:^|[^\\w.])${C(t,"[\\w.]*")}(?:$|[^\\w.])`,"i"),R.size>1e3&&R.clear(),R.set(s,r)),r}h(E,"M"),l(E,"S"),c(E,"globRe");const g=c((t,e)=>e!==void 0&&E(t).test(e),"glob");function T(t,e){const s=e.routes??[],r=/^([A-Za-z]+)\s+(\S.*)$/.exec(t);return r&&/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|\*)$/i.test(r[1])?r[1]!=="*"&&(e.method??"").toUpperCase()!==r[1].toUpperCase()?!1:s.some(o=>g(r[2],o)):s.some(o=>g(t,o))}h(T,"D"),l(T,"B"),c(T,"routeMatches");function O(t,e){const s=[e.flowId,...e.flowNames??[]].filter(o=>!!o),r=t.endsWith(":")?`${t}*`:t;return s.some(o=>g(r,o))}h(O,"L"),l(O,"G"),c(O,"flowMatches");function N(t,e){return g(t,e.errorName)||(e.errorKeys??[]).some(s=>g(t,s))?!0:e.message!==void 0&&E(t,"word").test(e.message)}h(N,"U"),l(N,"W"),c(N,"errorMatches");export function expectedMatches(t,e){return!(t.service!==void 0&&!g(t.service,e.service)||t.route!==void 0&&!T(t.route,e)||t.span!==void 0&&!g(t.span,e.span)||t.flow!==void 0&&!O(t.flow,e)||t.status!==void 0&&e.status!==t.status||t.error!==void 0&&!N(t.error,e)||t.message!==void 0&&!(e.message!==void 0&&E(t.message,"anywhere").test(e.message))||t.attribute!==void 0&&!g(t.attribute.value,e.attributes?.[t.attribute.name]))}h(expectedMatches,"expectedMatches"),l(expectedMatches,"expectedMatches"),c(expectedMatches,"expectedMatches");export function expectedMatchIsPerOccurrence(t){return t.flow!==void 0||t.attribute!==void 0||t.message!==void 0&&/\d/.test(t.message)}h(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence"),l(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence"),c(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence");export function suggestExpectedMatch(t){const e=t.routes?.find(a=>a.startsWith("/")),s=t.flowNames?.find(a=>a.startsWith("job:")&&!a.includes("#"))??(t.flowId?`${t.flowId.split(":")[0]}:`:void 0),r=e?{route:t.method?`${t.method.toUpperCase()} ${e}`:e}:t.span?{span:t.span}:s?{flow:s}:{},o=t.message?.split(`
2
- `)[0]?.replace(/\d+/g,"*").replace(/\*+/g,"*").slice(0,120).trim(),i=t.status!==void 0?{status:t.status}:t.errorName&&t.errorName!=="Error"?{error:t.errorName}:o?{message:o}:{},u=checkExpectedMatch({...t.service?{service:t.service}:{},...r,...i});return"match"in u?u.match:void 0}h(suggestExpectedMatch,"suggestExpectedMatch"),l(suggestExpectedMatch,"suggestExpectedMatch"),c(suggestExpectedMatch,"suggestExpectedMatch");export const EXPECTED_SURGE_FACTOR=10,EXPECTED_SURGE_MIN_PER_HOUR=20;const Y=2*f,X=24*f,q=6e4;export class ExpectedRuleBook{static{h(this,"ExpectedRuleBook")}static{l(this,"ExpectedRuleBook")}static{c(this,"ExpectedRuleBook")}constructor(e=Date.now()){this.startedAt=e,this.runtime=new Map,this.repository=[],this.repositoryKey="",this.stats=new Map,this.ended=[],this.version=0}apply(e,s){const r=readExpectedRule(e);if(!r)return!1;const o=this.runtime.get(r.id);if(this.runtime.delete(r.id),r.kind===EXPECTED_RULE_REMOVED)o&&this.end(o,s,"removed",r.by);else{const{kind:i,...u}=r;if(this.runtime.set(u.id,u),this.stats.has(u.id)||this.stats.set(u.id,{hits:0,minutes:new Map,since:Math.max(u.createdAt,this.startedAt)}),this.runtime.size>Z){const a=this.runtime.keys().next().value,d=this.runtime.get(a);this.runtime.delete(a),this.end(d,s,"expired")}}return this.version++,!0}setRepository(e,s){const r=JSON.stringify(e.map(i=>[i.id,i.match,i.reason]));if(r===this.repositoryKey)return!1;const o=new Set(e.map(i=>i.id));for(const i of this.repository)o.has(i.id)||this.end(i,s,"dropped from lensmcp.json");this.repository=e.slice(),this.repositoryKey=r;for(const i of e)this.stats.has(i.id)||this.stats.set(i.id,{hits:0,minutes:new Map,since:Math.max(this.startedAt,Math.min(i.createdAt,s))});return this.version++,!0}expire(e){let s=!1;for(const[r,o]of this.runtime)o.expiresAt===void 0||o.expiresAt>e||(this.runtime.delete(r),this.end(o,o.expiresAt,"expired"),s=!0);return s&&this.version++,s}end(e,s,r,o){this.ended.unshift({...e,endedAt:s,why:r,...o?{removedBy:o}:{}}),this.ended.length>U&&(this.ended.length=U)}active(e){return[...this.repository,...[...this.runtime.values()].filter(s=>s.expiresAt===void 0||s.expiresAt>e)]}get(e){return this.runtime.get(e)??this.repository.find(s=>s.id===e)}isActive(e,s){const r=this.get(e);return!!r&&(r.expiresAt===void 0||r.expiresAt>s)}get size(){return this.runtime.size+this.repository.length}holderOf(e,s){if(this.size!==0)return this.active(s).find(r=>expectedMatches(r.match,e))}count(e,s,r=1){const o=this.stats.get(e);if(!o||r<=0||(o.hits+=r,s===void 0))return;o.lastHitAt=Math.max(o.lastHitAt??0,s);const i=Math.floor(s/q);if(o.minutes.set(i,(o.minutes.get(i)??0)+r),o.minutes.size>1600){const u=i-(X+f)/q;for(const a of o.minutes.keys())a<u&&o.minutes.delete(a)}}windowCount(e,s,r){let o=0;for(const[i,u]of e.minutes)i*q>=s&&i*q<r&&(o+=u);return o}judge(e,s){const r=this.windowCount(e,s-f,s+1),o=Math.max(e.since,s-f-X),i=s-f-o;if(i<Y)return e.surge=void 0;const u=this.windowCount(e,o,s-f)/(i/f),a=Math.max(EXPECTED_SURGE_MIN_PER_HOUR,EXPECTED_SURGE_FACTOR*u);return e.surge?r<a/3?e.surge=void 0:e.surge={...e.surge,lastHour:r}:r>=a&&(e.surge={since:s,lastHour:r,usualPerHour:Math.round(u*10)/10}),e.surge}list(e){return this.active(e).map(s=>{const r=this.stats.get(s.id),o=r?this.judge(r,e):void 0;return{...s,hits:r?.hits??0,...r?.lastHitAt!==void 0?{lastHitAt:r.lastHitAt}:{},lastHour:r?this.windowCount(r,e-f,e+1):0,...o?{surge:o}:{}}}).sort((s,r)=>+(s.by==="repository")-+(r.by==="repository")||r.createdAt-s.createdAt)}endedRules(){return this.ended.slice()}}export function heldBackLine(t,e,s=""){return`${t} rule${t===1?"":"s"} held back ${e} occurrence${e===1?"":"s"}${s?` ${s}`:""}`}h(heldBackLine,"heldBackLine"),l(heldBackLine,"heldBackLine"),c(heldBackLine,"heldBackLine");export function surgeLine(t){const e=t.surge;return`this expected failure is now happening much more often: ${describeExpectedMatch(t.match)} \u2014 ${e?`${e.lastHour} in the last hour, usually ${e.usualPerHour} an hour`:"its rate jumped"} (expected because: ${t.reason})`}h(surgeLine,"surgeLine"),l(surgeLine,"surgeLine"),c(surgeLine,"surgeLine");
1
+ "use strict";var G=Object.defineProperty;var h=(t,e)=>G(t,"name",{value:e,configurable:!0});var J=Object.defineProperty,l=h((t,e)=>J(t,"name",{value:e,configurable:!0}),"h"),V=Object.defineProperty,p=l((t,e)=>V(t,"name",{value:e,configurable:!0}),"h"),Z=Object.defineProperty,m=p((t,e)=>Z(t,"name",{value:e,configurable:!0}),"h"),Q=Object.defineProperty,c=m((t,e)=>Q(t,"name",{value:e,configurable:!0}),"d");import{LENS_EVENT_SOURCE as Y}from"./error-dismissal.js";export const EXPECTED_RULE_SET="expected-rule-set",EXPECTED_RULE_REMOVED="expected-rule-removed";const U=new Set(["dashboard","cli","agent"]),v=60*6e4;export const EXPECTED_RULE_DEFAULT_TTL_MS=168*v,EXPECTED_RULE_MAX_TTL_MS=720*v,EXPECTED_RULE_MIN_REASON_CHARS=8,MAX_EXPECTED_REASON_CHARS=500;const k=300,ee=300,z=120,te=200,X=20,f=c(t=>!!t&&typeof t=="object"&&!Array.isArray(t),"isObj"),b=c((t,e)=>typeof t=="string"&&t.trim()?t.trim().slice(0,e):void 0,"text"),S=c(t=>!!t&&t.replace(/[*?\s/:.#_-]/g,"").length>=2,"meaningful");export const EXPECTED_SCOPE_FIELDS=["route","span","flow"],EXPECTED_OUTCOME_FIELDS=["status","error","message"];export function checkExpectedMatch(t){if(!f(t))return{error:"a rule needs a match: a flow scope (route, span or flow) and an outcome (status, error or message)"};const e={};for(const r of["service","route","span","flow","error","message"]){const i=t[r];if(i==null||i==="")continue;if(typeof i!="string")return{error:`\`${r}\` must be text`};const o=i.trim();if(o.length>k)return{error:`\`${r}\` is longer than ${k} characters`};o&&(e[r]=o)}if(t.status!==void 0&&t.status!==null&&t.status!==""){const r=typeof t.status=="string"?Number(t.status):t.status;if(typeof r!="number"||!Number.isInteger(r)||r<100||r>599)return{error:"`status` must be an HTTP status (100\u2013599)"};e.status=r}const s=t.attribute;if(s!=null){const r=f(s)?b(s.name,100):void 0,i=f(s)?typeof s.value=="number"?String(s.value):b(s.value,k):void 0;if(!r||!i)return{error:"`attribute` needs a `name` and a `value` (one attribute of the flow, such as a tenant id)"};e.attribute={name:r,value:i}}return EXPECTED_SCOPE_FIELDS.some(r=>S(e[r]))?e.status===void 0&&!S(e.error)&&!S(e.message)?{error:"a rule needs an outcome \u2014 a `status`, an `error` key or a `message` pattern \u2014 saying WHICH failure is expected in that flow"}:{match:e}:{error:`a rule needs a flow scope \u2014 a \`route\`, a \`span\` or a \`flow\` \u2014 not only ${e.service?`the service \xAB${e.service}\xBB`:"an outcome"}: \xABeverything in a service\xBB is not expected, it is unwatched`}}h(checkExpectedMatch,"checkExpectedMatch"),l(checkExpectedMatch,"checkExpectedMatch"),p(checkExpectedMatch,"checkExpectedMatch"),m(checkExpectedMatch,"checkExpectedMatch"),c(checkExpectedMatch,"checkExpectedMatch");export function describeExpectedMatch(t){return[t.service,t.route,t.span,t.flow?`flow ${t.flow}`:void 0,t.status!==void 0?String(t.status):void 0,t.error,t.message?`\xAB${t.message}\xBB`:void 0,t.attribute?`${t.attribute.name}=${t.attribute.value}`:void 0].filter(Boolean).join(" \xB7 ")}h(describeExpectedMatch,"describeExpectedMatch"),l(describeExpectedMatch,"describeExpectedMatch"),p(describeExpectedMatch,"describeExpectedMatch"),m(describeExpectedMatch,"describeExpectedMatch"),c(describeExpectedMatch,"describeExpectedMatch");export function readExpectedRule(t){if(t.source!==Y||!f(t.raw))return;const e=t.raw,s=b(e.id,z);if(!s)return;if(e.kind===EXPECTED_RULE_REMOVED)return{kind:EXPECTED_RULE_REMOVED,id:s,...U.has(e.by)?{by:e.by}:{}};if(e.kind!==EXPECTED_RULE_SET||!U.has(e.by))return;const r=b(e.reason,MAX_EXPECTED_REASON_CHARS);if(!r)return;const i=checkExpectedMatch(e.match);if("error"in i)return;const o=Math.min(typeof e.createdAt=="number"&&Number.isFinite(e.createdAt)?e.createdAt:t.timestamp,t.timestamp),u=typeof e.expiresAt=="number"&&Number.isFinite(e.expiresAt)?e.expiresAt:o+EXPECTED_RULE_DEFAULT_TTL_MS,a=b(e.title,ee);return{kind:EXPECTED_RULE_SET,id:s,match:i.match,reason:r,by:e.by,createdAt:o,expiresAt:Math.min(u,o+EXPECTED_RULE_MAX_TTL_MS),...a?{title:a}:{}}}h(readExpectedRule,"readExpectedRule"),l(readExpectedRule,"readExpectedRule"),p(readExpectedRule,"readExpectedRule"),m(readExpectedRule,"readExpectedRule"),c(readExpectedRule,"readExpectedRule");export function expectedRuleTtlMs(t){return t===void 0||!Number.isFinite(t)||t<=0?EXPECTED_RULE_DEFAULT_TTL_MS:Math.min(Math.round(t*v),EXPECTED_RULE_MAX_TTL_MS)}h(expectedRuleTtlMs,"expectedRuleTtlMs"),l(expectedRuleTtlMs,"expectedRuleTtlMs"),p(expectedRuleTtlMs,"expectedRuleTtlMs"),m(expectedRuleTtlMs,"expectedRuleTtlMs"),c(expectedRuleTtlMs,"expectedRuleTtlMs");function R(t){let e=2166136261;for(let s=0;s<t.length;s++)e=Math.imul(e^t.charCodeAt(s),16777619);return(e>>>0).toString(36)}h(R,"R"),l(R,"j"),p(R,"F"),m(R,"z"),c(R,"hashOf");export function readRepositoryExpectedRules(t,e){const s=[],r=[];return t==null?{rules:s,problems:r}:Array.isArray(t)?(t.forEach((i,o)=>{if(!f(i))return void r.push(`expectedFailures[${o}] is not an object`);const u=checkExpectedMatch(f(i.match)?i.match:i);if("error"in u)return void r.push(`expectedFailures[${o}]: ${u.error}`);const a=b(i.reason,MAX_EXPECTED_REASON_CHARS);if(!a)return void r.push(`expectedFailures[${o}] has no reason \u2014 say why it is expected`);const d=`repository:${b(i.id,z)??R(JSON.stringify(u.match))}`;if(s.some(x=>x.id===d))return void r.push(`expectedFailures[${o}] repeats the id ${d}`);s.push({id:d,match:u.match,reason:a,by:"repository",createdAt:e})}),{rules:s,problems:r}):{rules:s,problems:["expectedFailures is not a list \u2014 no repository rule is read"]}}h(readRepositoryExpectedRules,"readRepositoryExpectedRules"),l(readRepositoryExpectedRules,"readRepositoryExpectedRules"),p(readRepositoryExpectedRules,"readRepositoryExpectedRules"),m(readRepositoryExpectedRules,"readRepositoryExpectedRules"),c(readRepositoryExpectedRules,"readRepositoryExpectedRules");const n=c(t=>typeof t=="string"&&t?t:void 0,"str"),T=c(t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,"num"),K=c(t=>{const e=t.split(/[?#]/)[0]??t,s=/^[a-z][a-z0-9+.-]*:\/\/[^/]+(\/.*)?$/i.exec(e);return s?s[1]??"/":e},"pathOf"),se=new Set(["sessionId","flowId","requestId","parentRequestId","runId","traceparent","originNodeId","causedByNodeId","userActionId","browserContextId","frameId","tabId","url","route","projectName"]),N=24;export function eventAttributes(t){let e;const s=c((a,d)=>{if(e&&Object.keys(e).length>=N)return;const x=typeof d=="string"?d:typeof d=="number"||typeof d=="boolean"?String(d):void 0;x===void 0||x.length>k||((e??={})[a]=x)},"put"),r=t.context??{};for(const a of Object.keys(r))se.has(a)||s(a,r[a]);const i=f(t.raw)?t.raw:void 0;if(!i)return e;const o=f(i.span)?i.span:void 0,u=f(i.request)?i.request:void 0;for(const a of[i.attributes,o?.attributes,u?.attributes,i.data,Array.isArray(o?.args)?o?.args[0]:o?.args])if(f(a))for(const d of Object.keys(a))s(d,a[d]);return e}h(eventAttributes,"eventAttributes"),l(eventAttributes,"eventAttributes"),p(eventAttributes,"eventAttributes"),m(eventAttributes,"eventAttributes"),c(eventAttributes,"eventAttributes");export function failureFacts(t){const e=f(t.raw)?t.raw:{},s=t.context??{},r=f(e.request)?e.request:{},i=f(e.span)?e.span:{},o=f(r.error)?r.error:{},u=f(i.error)?i.error:{},a=f(e.error)?e.error:{},d=n(e.kind),x=[],j=n(r.route)??(d==="egress"?n(e.path):void 0);j&&x.push(j);const A=n(e.url)??n(r.url);A&&x.push(K(A)),d!=="server-request"&&n(s.route)&&x.push(n(s.route));const g=[];if(d==="queue-failed"||d==="queue-enqueued"){const M=n(e.queue),O=e.jobId===void 0||e.jobId===null?void 0:String(e.jobId);M&&g.push(`job:${M}`),O&&g.push(`job:${O}`),M&&O&&g.push(`job:${M}#${O}`),n(e.name)&&g.push(`job:${n(e.name)}`)}const w=[o.errorKey,u.errorKey,a.errorKey,e.errorKey,o.reason,u.reason].map(n).filter(M=>!!M),F=n(o.message)??n(t.message)??n(u.message)??n(a.message)??n(e.failedReason)??n(e.error)??n(e.message)??n(t.title),B=T(r.status)??T(e.status),L=n(s.flowId)??n(i.flowId)??n(r.flowId),H=n(s.requestId)??n(r.requestId)??n(i.requestId),D=eventAttributes(t);return{...n(e.project)??n(s.projectName)?{service:n(e.project)??n(s.projectName)}:{},...n(r.method)??n(e.method)?{method:n(r.method)??n(e.method)}:{},...x.length?{routes:x}:{},...n(i.name)?{span:n(i.name)}:{},...L?{flowId:L}:{},...g.length?{flowNames:g}:{},...B!==void 0?{status:B}:{},...n(o.name)??n(u.name)??n(a.name)?{errorName:n(o.name)??n(u.name)??n(a.name)}:{},...w.length?{errorKeys:w}:{},...F?{message:F}:{},...D?{attributes:D}:{},...H?{requestId:H}:{}}}h(failureFacts,"failureFacts"),l(failureFacts,"failureFacts"),p(failureFacts,"failureFacts"),m(failureFacts,"failureFacts"),c(failureFacts,"failureFacts");export class FailureContextIndex{static{h(this,"FailureContextIndex")}static{l(this,"FailureContextIndex")}static{p(this,"FailureContextIndex")}static{m(this,"FailureContextIndex")}static{c(this,"FailureContextIndex")}constructor(e=5e3,s=2e3){this.maxRequests=e,this.maxFlows=s,this.requests=new Map,this.flows=new Map}observe(e){const s=f(e.raw)?e.raw:void 0,r=e.context??{},i=n(r.flowId);if(i&&(s?.attributes!==void 0||f(s?.span)||r.tenantIdHash!==void 0||r.userIdHash!==void 0||s?.data!==void 0)){const A=eventAttributes(e);if(A){const g=this.flows.get(i);this.flows.delete(i);const w={...g??{},...A};this.flows.set(i,Object.keys(w).length>N?Object.fromEntries(Object.entries(w).slice(-N)):w),this.flows.size>this.maxFlows&&this.flows.delete(this.flows.keys().next().value)}}const o=n(s?.kind);if(!s||o!=="server-request"&&o!=="gateway-request")return;const u=f(s.request)?s.request:s,a=n(r.requestId)??n(u.requestId);if(!a)return;const d=this.requests.get(a)??{},x=n(u.url),j={...d,...n(s.project)&&(o==="server-request"||!d.service)?{service:n(s.project)}:{},...n(u.method)?{method:n(u.method)}:{},...o==="server-request"&&n(u.route)?{route:n(u.route)}:{},...x?{path:K(x)}:{},...T(u.status)!==void 0&&(o==="server-request"||d.status===void 0)?{status:T(u.status)}:{}};return this.requests.delete(a),this.requests.set(a,j),this.requests.size>this.maxRequests&&this.requests.delete(this.requests.keys().next().value),o==="server-request"?a:void 0}request(e){return e?this.requests.get(e):void 0}enrich(e){const s=this.request(e.requestId),r=e.flowId?this.flows.get(e.flowId):void 0;if(!s&&!r)return e;const i=[...e.routes??[],...s?.route?[s.route]:[],...s?.path?[s.path]:[]];return{...e,...e.service??s?.service?{service:e.service??s?.service}:{},...e.method??s?.method?{method:e.method??s?.method}:{},...i.length?{routes:[...new Set(i)]}:{},...e.status??s?.status!==void 0?{status:e.status??s?.status}:{},...r||e.attributes?{attributes:{...r??{},...e.attributes??{}}}:{}}}}const C=new Map,P=c((t,e)=>t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,e).replace(/\?/g,"."),"globBody");function y(t,e="whole"){const s=`${e}\0${t}`;let r=C.get(s);return r||(r=e==="whole"?new RegExp(`^${P(t,"[\\s\\S]*")}$`,"i"):e==="anywhere"?new RegExp(P(t,"[\\s\\S]*"),"i"):new RegExp(`(?:^|[^\\w.])${P(t,"[\\w.]*")}(?:$|[^\\w.])`,"i"),C.size>1e3&&C.clear(),C.set(s,r)),r}h(y,"w"),l(y,"E"),p(y,"M"),m(y,"S"),c(y,"globRe");const E=c((t,e)=>e!==void 0&&y(t).test(e),"glob");function I(t,e){const s=e.routes??[],r=/^([A-Za-z]+)\s+(\S.*)$/.exec(t);return r&&/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|\*)$/i.test(r[1])?r[1]!=="*"&&(e.method??"").toUpperCase()!==r[1].toUpperCase()?!1:s.some(i=>E(r[2],i)):s.some(i=>E(t,i))}h(I,"_"),l(I,"T"),p(I,"D"),m(I,"B"),c(I,"routeMatches");function $(t,e){const s=[e.flowId,...e.flowNames??[]].filter(i=>!!i),r=t.endsWith(":")?`${t}*`:t;return s.some(i=>E(r,i))}h($,"C"),l($,"O"),p($,"L"),m($,"G"),c($,"flowMatches");function q(t,e){return E(t,e.errorName)||(e.errorKeys??[]).some(s=>E(t,s))?!0:e.message!==void 0&&y(t,"word").test(e.message)}h(q,"O"),l(q,"N"),p(q,"U"),m(q,"W"),c(q,"errorMatches");export function expectedMatches(t,e){return!(t.service!==void 0&&!E(t.service,e.service)||t.route!==void 0&&!I(t.route,e)||t.span!==void 0&&!E(t.span,e.span)||t.flow!==void 0&&!$(t.flow,e)||t.status!==void 0&&e.status!==t.status||t.error!==void 0&&!q(t.error,e)||t.message!==void 0&&!(e.message!==void 0&&y(t.message,"anywhere").test(e.message))||t.attribute!==void 0&&!E(t.attribute.value,e.attributes?.[t.attribute.name]))}h(expectedMatches,"expectedMatches"),l(expectedMatches,"expectedMatches"),p(expectedMatches,"expectedMatches"),m(expectedMatches,"expectedMatches"),c(expectedMatches,"expectedMatches");export function expectedMatchIsPerOccurrence(t){return t.flow!==void 0||t.attribute!==void 0||t.message!==void 0&&/\d/.test(t.message)}h(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence"),l(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence"),p(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence"),m(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence"),c(expectedMatchIsPerOccurrence,"expectedMatchIsPerOccurrence");export function suggestExpectedMatch(t){const e=t.routes?.find(a=>a.startsWith("/")),s=t.flowNames?.find(a=>a.startsWith("job:")&&!a.includes("#"))??(t.flowId?`${t.flowId.split(":")[0]}:`:void 0),r=e?{route:t.method?`${t.method.toUpperCase()} ${e}`:e}:t.span?{span:t.span}:s?{flow:s}:{},i=t.message?.split(`
2
+ `)[0]?.replace(/\d+/g,"*").replace(/\*+/g,"*").slice(0,120).trim(),o=t.status!==void 0?{status:t.status}:t.errorName&&t.errorName!=="Error"?{error:t.errorName}:i?{message:i}:{},u=checkExpectedMatch({...t.service?{service:t.service}:{},...r,...o});return"match"in u?u.match:void 0}h(suggestExpectedMatch,"suggestExpectedMatch"),l(suggestExpectedMatch,"suggestExpectedMatch"),p(suggestExpectedMatch,"suggestExpectedMatch"),m(suggestExpectedMatch,"suggestExpectedMatch"),c(suggestExpectedMatch,"suggestExpectedMatch");export const EXPECTED_SURGE_FACTOR=10,EXPECTED_SURGE_MIN_PER_HOUR=20;const re=2*v,W=24*v,_=6e4;export class ExpectedRuleBook{static{h(this,"ExpectedRuleBook")}static{l(this,"ExpectedRuleBook")}static{p(this,"ExpectedRuleBook")}static{m(this,"ExpectedRuleBook")}static{c(this,"ExpectedRuleBook")}constructor(e=Date.now()){this.startedAt=e,this.runtime=new Map,this.repository=[],this.repositoryKey="",this.stats=new Map,this.ended=[],this.version=0}apply(e,s){const r=readExpectedRule(e);if(!r)return!1;const i=this.runtime.get(r.id);if(this.runtime.delete(r.id),r.kind===EXPECTED_RULE_REMOVED)i&&this.end(i,s,"removed",r.by);else{const{kind:o,...u}=r;if(this.runtime.set(u.id,u),this.stats.has(u.id)||this.stats.set(u.id,{hits:0,minutes:new Map,since:Math.max(u.createdAt,this.startedAt)}),this.runtime.size>te){const a=this.runtime.keys().next().value,d=this.runtime.get(a);this.runtime.delete(a),this.end(d,s,"expired")}}return this.version++,!0}setRepository(e,s){const r=JSON.stringify(e.map(o=>[o.id,o.match,o.reason]));if(r===this.repositoryKey)return!1;const i=new Set(e.map(o=>o.id));for(const o of this.repository)i.has(o.id)||this.end(o,s,"dropped from lensmcp.json");this.repository=e.slice(),this.repositoryKey=r;for(const o of e)this.stats.has(o.id)||this.stats.set(o.id,{hits:0,minutes:new Map,since:Math.max(this.startedAt,Math.min(o.createdAt,s))});return this.version++,!0}expire(e){let s=!1;for(const[r,i]of this.runtime)i.expiresAt===void 0||i.expiresAt>e||(this.runtime.delete(r),this.end(i,i.expiresAt,"expired"),s=!0);return s&&this.version++,s}end(e,s,r,i){this.ended.unshift({...e,endedAt:s,why:r,...i?{removedBy:i}:{}}),this.ended.length>X&&(this.ended.length=X)}active(e){return[...this.repository,...[...this.runtime.values()].filter(s=>s.expiresAt===void 0||s.expiresAt>e)]}get(e){return this.runtime.get(e)??this.repository.find(s=>s.id===e)}isActive(e,s){const r=this.get(e);return!!r&&(r.expiresAt===void 0||r.expiresAt>s)}get size(){return this.runtime.size+this.repository.length}holderOf(e,s){if(this.size!==0)return this.active(s).find(r=>expectedMatches(r.match,e))}count(e,s,r=1){const i=this.stats.get(e);if(!i||r<=0||(i.hits+=r,s===void 0))return;i.lastHitAt=Math.max(i.lastHitAt??0,s);const o=Math.floor(s/_);if(i.minutes.set(o,(i.minutes.get(o)??0)+r),i.minutes.size>1600){const u=o-(W+v)/_;for(const a of i.minutes.keys())a<u&&i.minutes.delete(a)}}windowCount(e,s,r){let i=0;for(const[o,u]of e.minutes)o*_>=s&&o*_<r&&(i+=u);return i}judge(e,s){const r=this.windowCount(e,s-v,s+1),i=Math.max(e.since,s-v-W),o=s-v-i;if(o<re)return e.surge=void 0;const u=this.windowCount(e,i,s-v)/(o/v),a=Math.max(EXPECTED_SURGE_MIN_PER_HOUR,EXPECTED_SURGE_FACTOR*u);return e.surge?r<a/3?e.surge=void 0:e.surge={...e.surge,lastHour:r}:r>=a&&(e.surge={since:s,lastHour:r,usualPerHour:Math.round(u*10)/10}),e.surge}list(e){return this.active(e).map(s=>{const r=this.stats.get(s.id),i=r?this.judge(r,e):void 0;return{...s,hits:r?.hits??0,...r?.lastHitAt!==void 0?{lastHitAt:r.lastHitAt}:{},lastHour:r?this.windowCount(r,e-v,e+1):0,...i?{surge:i}:{}}}).sort((s,r)=>+(s.by==="repository")-+(r.by==="repository")||r.createdAt-s.createdAt)}endedRules(){return this.ended.slice()}}export function heldBackLine(t,e,s=""){return`${t} rule${t===1?"":"s"} held back ${e} occurrence${e===1?"":"s"}${s?` ${s}`:""}`}h(heldBackLine,"heldBackLine"),l(heldBackLine,"heldBackLine"),p(heldBackLine,"heldBackLine"),m(heldBackLine,"heldBackLine"),c(heldBackLine,"heldBackLine");export function surgeLine(t){const e=t.surge;return`this expected failure is now happening much more often: ${describeExpectedMatch(t.match)} \u2014 ${e?`${e.lastHour} in the last hour, usually ${e.usualPerHour} an hour`:"its rate jumped"} (expected because: ${t.reason})`}h(surgeLine,"surgeLine"),l(surgeLine,"surgeLine"),p(surgeLine,"surgeLine"),m(surgeLine,"surgeLine"),c(surgeLine,"surgeLine");
@@ -1 +1 @@
1
- "use strict";var S=Object.defineProperty;var i=(t,s)=>S(t,"name",{value:s,configurable:!0});var A=Object.defineProperty,f=i((t,s)=>A(t,"name",{value:s,configurable:!0}),"i"),k=Object.defineProperty,u=f((t,s)=>k(t,"name",{value:s,configurable:!0}),"o");function l(){const t=typeof process<"u"?process.env?.LENSMCP_EVENT_MAX_EPS:void 0;if(t===void 0||t==="")return;if(t==="off")return"off";const s=Number(t);if(Number.isFinite(s))return s<=0?"off":s}i(l,"d"),f(l,"S"),u(l,"envPerSec");export function createEventFloodGuard(t){const s=t?.envOverride===!1?void 0:l();if(s==="off")return{admit:u(()=>({ok:!0,suppressed:0}),"admit")};const c=s??t?.perSec??5,d=Math.max(1,t?.burst??Math.max(30,c*4)),p=t?.maxKeys??2048,n=new Map,v=u(o=>{for(const[r,e]of n)o-e.lastSeenAt>6e4&&n.delete(r);if(n.size>p){const r=[...n.entries()].sort((e,a)=>e[1].lastSeenAt-a[1].lastSeenAt);for(let e=0;e<r.length>>1;e++)n.delete(r[e][0])}},"evictStale");return{admit(o){const r=Date.now();let e=n.get(o);e||(n.size>=p&&v(r),e={tokens:d,lastRefillAt:r,suppressed:0,lastSeenAt:r},n.set(o,e)),e.lastSeenAt=r;const a=r-e.lastRefillAt;if(a>0&&(e.tokens=Math.min(d,e.tokens+a/1e3*c),e.lastRefillAt=r),e.tokens>=1){e.tokens-=1;const m=e.suppressed;return e.suppressed=0,{ok:!0,suppressed:m}}return e.suppressed+=1,{ok:!1,suppressed:0}}}}i(createEventFloodGuard,"createEventFloodGuard"),f(createEventFloodGuard,"createEventFloodGuard"),u(createEventFloodGuard,"createEventFloodGuard");
1
+ "use strict";var A=Object.defineProperty;var l=(t,r)=>A(t,"name",{value:r,configurable:!0});var E=Object.defineProperty,d=l((t,r)=>E(t,"name",{value:r,configurable:!0}),"i"),k=Object.defineProperty,f=d((t,r)=>k(t,"name",{value:r,configurable:!0}),"i"),P=Object.defineProperty,c=f((t,r)=>P(t,"name",{value:r,configurable:!0}),"i"),g=Object.defineProperty,u=c((t,r)=>g(t,"name",{value:r,configurable:!0}),"o");function o(){const t=typeof process<"u"?process.env?.LENSMCP_EVENT_MAX_EPS:void 0;if(t===void 0||t==="")return;if(t==="off")return"off";const r=Number(t);if(Number.isFinite(r))return r<=0?"off":r}l(o,"l"),d(o,"l"),f(o,"d"),c(o,"S"),u(o,"envPerSec");export function createEventFloodGuard(t){const r=t?.envOverride===!1?void 0:o();if(r==="off")return{admit:u(()=>({ok:!0,suppressed:0}),"admit")};const p=r??t?.perSec??5,v=Math.max(1,t?.burst??Math.max(30,p*4)),m=t?.maxKeys??2048,n=new Map,b=u(a=>{for(const[s,e]of n)a-e.lastSeenAt>6e4&&n.delete(s);if(n.size>m){const s=[...n.entries()].sort((e,i)=>e[1].lastSeenAt-i[1].lastSeenAt);for(let e=0;e<s.length>>1;e++)n.delete(s[e][0])}},"evictStale");return{admit(a){const s=Date.now();let e=n.get(a);e||(n.size>=m&&b(s),e={tokens:v,lastRefillAt:s,suppressed:0,lastSeenAt:s},n.set(a,e)),e.lastSeenAt=s;const i=s-e.lastRefillAt;if(i>0&&(e.tokens=Math.min(v,e.tokens+i/1e3*p),e.lastRefillAt=s),e.tokens>=1){e.tokens-=1;const S=e.suppressed;return e.suppressed=0,{ok:!0,suppressed:S}}return e.suppressed+=1,{ok:!1,suppressed:0}}}}l(createEventFloodGuard,"createEventFloodGuard"),d(createEventFloodGuard,"createEventFloodGuard"),f(createEventFloodGuard,"createEventFloodGuard"),c(createEventFloodGuard,"createEventFloodGuard"),u(createEventFloodGuard,"createEventFloodGuard");
@@ -1 +1 @@
1
- "use strict";var o=Object.defineProperty;var t=(n,e)=>o(n,"name",{value:e,configurable:!0});var s=Object.defineProperty,a=t((n,e)=>s(n,"name",{value:e,configurable:!0}),"a"),l=Object.defineProperty,i=a((n,e)=>l(n,"name",{value:e,configurable:!0}),"a");export const DESIGN_TYPES=["bug","investigation","performance","reliability","feature","architecture","maintenance"],DESIGN_CONCERNS=["security","data","api","ui","integration","operations"],DESIGN_TYPE_INFO={bug:{label:"Bug",when:"Something works wrong, and the cause is known or can be found by reading the code."},investigation:{label:"Investigation",when:"Symptoms without a known cause: research first, and the goal ends in a decision or a fix."},performance:{label:"Performance",when:"Something is measurably slow, heavy or costly: a baseline the lens measured and a target."},reliability:{label:"Reliability",when:"Crashes, stalls, flaky tests, lost work, CI or the machine: how it fails and how often."},feature:{label:"Feature",when:"Someone can do something they cannot do now."},architecture:{label:"Architecture",when:"Boundaries, contracts or structure change, in steps that each ship."},maintenance:{label:"Maintenance",when:"Upgrades, moves, tooling and cleanup: no new behaviour, and nothing breaks."}},DESIGN_CONCERN_INFO={security:{label:"Security",when:"Auth, permissions, secrets, input from outside, or anything an attacker would read."},data:{label:"Data",when:"Schema, migrations, backfills, or data already stored."},api:{label:"API",when:"A request or response other code or other people depend on."},ui:{label:"UI",when:"Screens, flows or what a person sees."},integration:{label:"Integration",when:"A service outside the repository: its API, keys, limits and failures."},operations:{label:"Operations",when:"How it deploys, runs, is watched and is rolled back."}},DESIGN_STAGES=["proposed","requested","drafting","waiting","changes","approved","declined"];export function designWriter(n){if(n.writer)return n.writer;if(n.by==="user")return{kind:"person"};if(n.by==="lensmcp")return{kind:"lensmcp",...n.byName?{name:n.byName}:{}}}t(designWriter,"designWriter"),a(designWriter,"designWriter"),i(designWriter,"designWriter");const c={claude:"Claude Code",codex:"Codex"};export function designWriterText(n){const e=designWriter(n);if(!e)return"who handed it in was not recorded";const r=e.client?c[e.client]:void 0;switch(e.kind){case"person":return"written by the person";case"lensmcp":return"written by LensMCP's own run";case"terminal":return"handed in from a terminal, as the overseer";case"session":return`handed in by ${r?`a ${r}`:"an agent's"} session${e.role?`, the team's ${e.role}`:" with no role on this team"}`;case"launch":return e.purpose==="design"?`written by a design launch${r?` on ${r}`:""}`:`handed in by the overseer's ${e.purpose==="inbox"?"inbox launch":e.purpose==="round"?"round":"launch"}${r?` on ${r}`:""}`}}t(designWriterText,"designWriterText"),a(designWriterText,"designWriterText"),i(designWriterText,"designWriterText");
1
+ "use strict";var l=Object.defineProperty;var t=(n,e)=>l(n,"name",{value:e,configurable:!0});var d=Object.defineProperty,a=t((n,e)=>d(n,"name",{value:e,configurable:!0}),"t"),c=Object.defineProperty,i=a((n,e)=>c(n,"name",{value:e,configurable:!0}),"t"),u=Object.defineProperty,o=i((n,e)=>u(n,"name",{value:e,configurable:!0}),"a"),h=Object.defineProperty,s=o((n,e)=>h(n,"name",{value:e,configurable:!0}),"a");export const DESIGN_TYPES=["bug","investigation","performance","reliability","feature","architecture","maintenance"],DESIGN_CONCERNS=["security","data","api","ui","integration","operations"],DESIGN_TYPE_INFO={bug:{label:"Bug",when:"Something works wrong, and the cause is known or can be found by reading the code."},investigation:{label:"Investigation",when:"Symptoms without a known cause: research first, and the goal ends in a decision or a fix."},performance:{label:"Performance",when:"Something is measurably slow, heavy or costly: a baseline the lens measured and a target."},reliability:{label:"Reliability",when:"Crashes, stalls, flaky tests, lost work, CI or the machine: how it fails and how often."},feature:{label:"Feature",when:"Someone can do something they cannot do now."},architecture:{label:"Architecture",when:"Boundaries, contracts or structure change, in steps that each ship."},maintenance:{label:"Maintenance",when:"Upgrades, moves, tooling and cleanup: no new behaviour, and nothing breaks."}},DESIGN_CONCERN_INFO={security:{label:"Security",when:"Auth, permissions, secrets, input from outside, or anything an attacker would read."},data:{label:"Data",when:"Schema, migrations, backfills, or data already stored."},api:{label:"API",when:"A request or response other code or other people depend on."},ui:{label:"UI",when:"Screens, flows or what a person sees."},integration:{label:"Integration",when:"A service outside the repository: its API, keys, limits and failures."},operations:{label:"Operations",when:"How it deploys, runs, is watched and is rolled back."}},DESIGN_STAGES=["proposed","requested","drafting","waiting","changes","approved","declined"];export function designWriter(n){if(n.writer)return n.writer;if(n.by==="user")return{kind:"person"};if(n.by==="lensmcp")return{kind:"lensmcp",...n.byName?{name:n.byName}:{}}}t(designWriter,"designWriter"),a(designWriter,"designWriter"),i(designWriter,"designWriter"),o(designWriter,"designWriter"),s(designWriter,"designWriter");const b={claude:"Claude Code",codex:"Codex"};export function designWriterText(n){const e=designWriter(n);if(!e)return"who handed it in was not recorded";const r=e.client?b[e.client]:void 0;switch(e.kind){case"person":return"written by the person";case"lensmcp":return"written by LensMCP's own run";case"terminal":return"handed in from a terminal, as the overseer";case"session":return`handed in by ${r?`a ${r}`:"an agent's"} session${e.role?`, the team's ${e.role}`:" with no role on this team"}`;case"launch":return e.purpose==="design"?`written by a design launch${r?` on ${r}`:""}`:`handed in by the overseer's ${e.purpose==="inbox"?"inbox launch":e.purpose==="round"?"round":"launch"}${r?` on ${r}`:""}`}}t(designWriterText,"designWriterText"),a(designWriterText,"designWriterText"),i(designWriterText,"designWriterText"),o(designWriterText,"designWriterText"),s(designWriterText,"designWriterText");
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var o=(t,e)=>c(t,"name",{value:e,configurable:!0});var u=Object.defineProperty,n=o((t,e)=>u(t,"name",{value:e,configurable:!0}),"s"),i=Object.defineProperty,s=n((t,e)=>i(t,"name",{value:e,configurable:!0}),"o");export const HOST_AGENT_CLIENTS=["claude","codex"],HOST_AGENTS_FILES={agents:"host-agents.json",ceilings:"host-ceilings.json"},HOST_AGENTS_LIMITS={accounts:32,windows:6,label:60,why:300,plan:40,name:40,agents:64},HOST_ACCOUNT_ID=/^ac-[a-z0-9]{1,12}-[a-f0-9]{6}$/;const r=[/\bsk-[A-Za-z0-9_-]{16,}/,/\b[rs]k_(?:live|test)_[A-Za-z0-9]{12,}/,/\bgh[pousr]_[A-Za-z0-9]{20,}|\bgithub_pat_[A-Za-z0-9_]{20,}/,/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/,/\bxox[abposr]-[A-Za-z0-9-]{10,}/,/\bAIza[0-9A-Za-z_-]{30,}/,/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{4,}/,/-----BEGIN [A-Z ]*(?:PRIVATE KEY|CERTIFICATE)-----/,/\bbearer\s+[A-Za-z0-9._~+/=-]{12,}/i],A=/[A-Za-z0-9+/_=-]{32,}/g;export function tokenShaped(t){if(r.some(e=>e.test(t)))return!0;for(const e of t.match(A)??[])if(/\d/.test(e)&&/[A-Za-z]/.test(e))return!0;return!1}o(tokenShaped,"tokenShaped"),n(tokenShaped,"tokenShaped"),s(tokenShaped,"tokenShaped");export function withoutTokens(t){let e=t;for(const a of r)e=e.replace(new RegExp(a.source,a.flags.includes("g")?a.flags:`${a.flags}g`),"\u2026");return e.replace(A,a=>/\d/.test(a)&&/[A-Za-z]/.test(a)?"\u2026":a)}o(withoutTokens,"withoutTokens"),n(withoutTokens,"withoutTokens"),s(withoutTokens,"withoutTokens");
1
+ "use strict";var A=Object.defineProperty;var o=(t,e)=>A(t,"name",{value:e,configurable:!0});var b=Object.defineProperty,n=o((t,e)=>b(t,"name",{value:e,configurable:!0}),"o"),l=Object.defineProperty,s=n((t,e)=>l(t,"name",{value:e,configurable:!0}),"o"),f=Object.defineProperty,r=s((t,e)=>f(t,"name",{value:e,configurable:!0}),"s"),_=Object.defineProperty,u=r((t,e)=>_(t,"name",{value:e,configurable:!0}),"o");export const HOST_AGENT_CLIENTS=["claude","codex"],HOST_AGENTS_FILES={agents:"host-agents.json",ceilings:"host-ceilings.json"},HOST_AGENTS_LIMITS={accounts:32,windows:6,label:60,why:300,plan:40,name:40,agents:64},HOST_ACCOUNT_ID=/^ac-[a-z0-9]{1,12}-[a-f0-9]{6}$/;const c=[/\bsk-[A-Za-z0-9_-]{16,}/,/\b[rs]k_(?:live|test)_[A-Za-z0-9]{12,}/,/\bgh[pousr]_[A-Za-z0-9]{20,}|\bgithub_pat_[A-Za-z0-9_]{20,}/,/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/,/\bxox[abposr]-[A-Za-z0-9-]{10,}/,/\bAIza[0-9A-Za-z_-]{30,}/,/\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{4,}/,/-----BEGIN [A-Z ]*(?:PRIVATE KEY|CERTIFICATE)-----/,/\bbearer\s+[A-Za-z0-9._~+/=-]{12,}/i],i=/[A-Za-z0-9+/_=-]{32,}/g;export function tokenShaped(t){if(c.some(e=>e.test(t)))return!0;for(const e of t.match(i)??[])if(/\d/.test(e)&&/[A-Za-z]/.test(e))return!0;return!1}o(tokenShaped,"tokenShaped"),n(tokenShaped,"tokenShaped"),s(tokenShaped,"tokenShaped"),r(tokenShaped,"tokenShaped"),u(tokenShaped,"tokenShaped");export function withoutTokens(t){let e=t;for(const a of c)e=e.replace(new RegExp(a.source,a.flags.includes("g")?a.flags:`${a.flags}g`),"\u2026");return e.replace(i,a=>/\d/.test(a)&&/[A-Za-z]/.test(a)?"\u2026":a)}o(withoutTokens,"withoutTokens"),n(withoutTokens,"withoutTokens"),s(withoutTokens,"withoutTokens"),r(withoutTokens,"withoutTokens"),u(withoutTokens,"withoutTokens");
@@ -1 +1 @@
1
- "use strict";var C=Object.defineProperty;var p=(e,r)=>C(e,"name",{value:r,configurable:!0});var k=Object.defineProperty,h=p((e,r)=>k(e,"name",{value:r,configurable:!0}),"g"),A=Object.defineProperty,d=h((e,r)=>A(e,"name",{value:r,configurable:!0}),"i");import{TRUNCATION_MARKER_KEY as j}from"./bounded-clone.js";export const LINT_COVER_KIND="lint-cover",MAX_LINT_UNCOMMITTED=500;const L=["tree","paths","changed","incremental"],m=d(e=>Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.length>0):[],"strings"),i=d(e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0,"count"),l=d(e=>typeof e=="string"&&e?e:void 0,"text");export function readLintCoverage(e){if(!e||typeof e!="object"||e[j])return;const r=e.coverage;if(!r||typeof r!="object")return;const t=r,n=t.kind,a=t.root;if(!L.includes(n)||typeof a!="string"||!a)return;const u=m(t.dirs),o=m(t.files),g=m(t.gone),$=i(t.notLinted),y=i(t.untracked),s=t.base&&typeof t.base=="object"?t.base:void 0,v=s&&l(s.sha)&&l(s.run)?{from:s.from==="main"?"main":"own",sha:s.sha,run:s.run}:void 0,b=Array.isArray(t.inputs)?t.inputs.flatMap(f=>Array.isArray(f)&&typeof f[0]=="string"&&typeof f[1]=="string"?[[f[0],f[1]]]:[]):void 0;return{kind:n,root:a,dirs:u,files:o,gone:g,fileCount:i(t.fileCount)??o.length,goneCount:i(t.goneCount)??g.length,linted:i(t.linted)??0,...i(t.dirCount)!==void 0?{dirCount:i(t.dirCount)}:{},...$?{notLinted:$}:{},...y?{untracked:y}:{},...l(t.since)?{since:t.since}:{},...l(t.head)?{head:t.head}:{},...typeof t.dirty=="boolean"?{dirty:t.dirty}:{},...Array.isArray(t.uncommitted)?{uncommitted:m(t.uncommitted)}:{},...t.uncommittedMore===!0?{uncommittedMore:!0}:{},...b?{inputs:b}:{},...l(t.folder)?{folder:t.folder}:{},...t.projects===!0?{projects:!0}:{},...v?{base:v}:{},...t.fromZero===!0?{fromZero:!0}:{},...t.narrowed===!0?{narrowed:!0}:{}}}p(readLintCoverage,"readLintCoverage"),h(readLintCoverage,"readLintCoverage"),d(readLintCoverage,"readLintCoverage");const c=d((e,r)=>`${e} ${r}${e===1?"":"s"}`,"some");export function lintCoverageLabel(e,r={}){const t=e.files??0,n=e.gone??0;if(e.kind==="changed"){const o=`since ${e.since??"HEAD"}`;if(!t)return`${c(n,"deleted file")} ${o}`;const g=r.untracked&&e.untracked?` (${e.untracked} untracked)`:"";return`${c(t,"changed file")} ${o}${g}${n?`, ${n} deleted`:""}`}if(e.kind==="incremental"){const o=e.since?` since ${e.since.slice(0,7)}`:"";return!t&&!n?`nothing changed${o}`:t?`${c(t,"file")} changed${o}${n?`, ${n} deleted`:""}`:`${c(n,"file")} deleted${o}`}if(e.kind==="tree"&&e.projects)return`the workspace\u2019s ${c(e.projects,"project")}`;if(e.kind==="tree"&&e.paths[0]===".")return"whole checkout";if(e.narrowed)return`${c(t,"file")} ESLint linted with the caller\u2019s arguments`;const a=e.paths.slice(0,3).join(", "),u=(e.more??0)+Math.max(0,e.paths.length-3);return u?`${a} +${u} more`:a}p(lintCoverageLabel,"lintCoverageLabel"),h(lintCoverageLabel,"lintCoverageLabel"),d(lintCoverageLabel,"lintCoverageLabel");
1
+ "use strict";var k=Object.defineProperty;var p=(e,r)=>k(e,"name",{value:r,configurable:!0});var j=Object.defineProperty,h=p((e,r)=>j(e,"name",{value:r,configurable:!0}),"p"),A=Object.defineProperty,v=h((e,r)=>A(e,"name",{value:r,configurable:!0}),"p"),M=Object.defineProperty,y=v((e,r)=>M(e,"name",{value:r,configurable:!0}),"g"),w=Object.defineProperty,c=y((e,r)=>w(e,"name",{value:r,configurable:!0}),"i");import{TRUNCATION_MARKER_KEY as N}from"./bounded-clone.js";export const LINT_COVER_KIND="lint-cover",MAX_LINT_UNCOMMITTED=500;const O=["tree","paths","changed","incremental"],m=c(e=>Array.isArray(e)?e.filter(r=>typeof r=="string"&&r.length>0):[],"strings"),i=c(e=>typeof e=="number"&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0,"count"),f=c(e=>typeof e=="string"&&e?e:void 0,"text");export function readLintCoverage(e){if(!e||typeof e!="object"||e[N])return;const r=e.coverage;if(!r||typeof r!="object")return;const t=r,n=t.kind,a=t.root;if(!O.includes(n)||typeof a!="string"||!a)return;const u=m(t.dirs),o=m(t.files),g=m(t.gone),$=i(t.notLinted),b=i(t.untracked),d=t.base&&typeof t.base=="object"?t.base:void 0,C=d&&f(d.sha)&&f(d.run)?{from:d.from==="main"?"main":"own",sha:d.sha,run:d.run}:void 0,L=Array.isArray(t.inputs)?t.inputs.flatMap(l=>Array.isArray(l)&&typeof l[0]=="string"&&typeof l[1]=="string"?[[l[0],l[1]]]:[]):void 0;return{kind:n,root:a,dirs:u,files:o,gone:g,fileCount:i(t.fileCount)??o.length,goneCount:i(t.goneCount)??g.length,linted:i(t.linted)??0,...i(t.dirCount)!==void 0?{dirCount:i(t.dirCount)}:{},...$?{notLinted:$}:{},...b?{untracked:b}:{},...f(t.since)?{since:t.since}:{},...f(t.head)?{head:t.head}:{},...typeof t.dirty=="boolean"?{dirty:t.dirty}:{},...Array.isArray(t.uncommitted)?{uncommitted:m(t.uncommitted)}:{},...t.uncommittedMore===!0?{uncommittedMore:!0}:{},...L?{inputs:L}:{},...f(t.folder)?{folder:t.folder}:{},...t.projects===!0?{projects:!0}:{},...C?{base:C}:{},...t.fromZero===!0?{fromZero:!0}:{},...t.narrowed===!0?{narrowed:!0}:{}}}p(readLintCoverage,"readLintCoverage"),h(readLintCoverage,"readLintCoverage"),v(readLintCoverage,"readLintCoverage"),y(readLintCoverage,"readLintCoverage"),c(readLintCoverage,"readLintCoverage");const s=c((e,r)=>`${e} ${r}${e===1?"":"s"}`,"some");export function lintCoverageLabel(e,r={}){const t=e.files??0,n=e.gone??0;if(e.kind==="changed"){const o=`since ${e.since??"HEAD"}`;if(!t)return`${s(n,"deleted file")} ${o}`;const g=r.untracked&&e.untracked?` (${e.untracked} untracked)`:"";return`${s(t,"changed file")} ${o}${g}${n?`, ${n} deleted`:""}`}if(e.kind==="incremental"){const o=e.since?` since ${e.since.slice(0,7)}`:"";return!t&&!n?`nothing changed${o}`:t?`${s(t,"file")} changed${o}${n?`, ${n} deleted`:""}`:`${s(n,"file")} deleted${o}`}if(e.kind==="tree"&&e.projects)return`the workspace\u2019s ${s(e.projects,"project")}`;if(e.kind==="tree"&&e.paths[0]===".")return"whole checkout";if(e.narrowed)return`${s(t,"file")} ESLint linted with the caller\u2019s arguments`;const a=e.paths.slice(0,3).join(", "),u=(e.more??0)+Math.max(0,e.paths.length-3);return u?`${a} +${u} more`:a}p(lintCoverageLabel,"lintCoverageLabel"),h(lintCoverageLabel,"lintCoverageLabel"),v(lintCoverageLabel,"lintCoverageLabel"),y(lintCoverageLabel,"lintCoverageLabel"),c(lintCoverageLabel,"lintCoverageLabel");
package/lib/log-query.js CHANGED
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var a=(e,t)=>L(e,"name",{value:t,configurable:!0});var d=Object.defineProperty,c=a((e,t)=>d(e,"name",{value:t,configurable:!0}),"a"),h=Object.defineProperty,u=c((e,t)=>h(e,"name",{value:t,configurable:!0}),"c");const p={level:"level",severity:"level",service:"service",svc:"service",src:"service",source:"service",flow:"flow",trace:"trace",request:"trace",category:"category",cat:"category",ms:"ms"},C={warn:"warning",err:"error"},k=/(-?)(?:([A-Za-z]+):)?(?:"([^"]*)"|(\S+))/g;export function parseLogQuery(e){const t=[],r=[];for(const s of e.matchAll(k)){const[o,n,g,y,w]=s,i=(y??w??"").trim(),l=g?p[g.toLowerCase()]:void 0;if(l&&i){const m=l==="level"?C[i.toLowerCase()]??i.toLowerCase():i;t.push({key:l,value:m,negate:n==="-"})}else o.trim()&&r.push(o.trim())}return{tokens:t,text:r.join(" ")}}a(parseLogQuery,"parseLogQuery"),c(parseLogQuery,"parseLogQuery"),u(parseLogQuery,"parseLogQuery");export function formatLogQuery(e){const t=u(r=>/\s/.test(r)?`"${r}"`:r,"quote");return[...e.tokens.map(r=>`${r.negate?"-":""}${r.key}:${t(r.value)}`),e.text].filter(Boolean).join(" ")}a(formatLogQuery,"formatLogQuery"),c(formatLogQuery,"formatLogQuery"),u(formatLogQuery,"formatLogQuery");function v(e,t){if(e===void 0)return!1;const r=/^(>=|<=|>|<|=)?\s*(\d+(?:\.\d+)?)$/.exec(t);if(!r)return!1;const s=Number(r[2]);switch(r[1]){case">":return e>s;case"<":return e<s;case"<=":return e<=s;case"=":return e===s;default:return e>=s}}a(v,"v"),c(v,"h"),u(v,"msMatches");function f(e,t){const r=t.value.toLowerCase();switch(t.key){case"level":return e.severity.toLowerCase()===r;case"service":return e.source.toLowerCase()===r;case"flow":return!!e.flowId&&e.flowId.toLowerCase().startsWith(r);case"trace":return!!e.requestId&&e.requestId.toLowerCase().startsWith(r);case"category":return e.category.toLowerCase()===r;case"ms":return v(e.durationMs,t.value)}}a(f,"l"),c(f,"i"),u(f,"tokenMatches");export function matchesLogQuery(e,t,r){const s=new Map;for(const o of t.tokens){if(o.negate){if(f(e,o))return!1;continue}const n=s.get(o.key);n?n.push(o):s.set(o.key,[o])}for(const o of s.values())if(!o.some(n=>f(e,n)))return!1;if(t.text){const o=`${e.title} ${e.message??""} ${e.source} ${e.flowId??""}`;return r?r(o):o.toLowerCase().includes(t.text.toLowerCase())}return!0}a(matchesLogQuery,"matchesLogQuery"),c(matchesLogQuery,"matchesLogQuery"),u(matchesLogQuery,"matchesLogQuery");
1
+ "use strict";var d=Object.defineProperty;var a=(e,r)=>d(e,"name",{value:r,configurable:!0});var h=Object.defineProperty,c=a((e,r)=>h(e,"name",{value:r,configurable:!0}),"a"),Q=Object.defineProperty,u=c((e,r)=>Q(e,"name",{value:r,configurable:!0}),"a"),C=Object.defineProperty,i=u((e,r)=>C(e,"name",{value:r,configurable:!0}),"a"),k=Object.defineProperty,f=i((e,r)=>k(e,"name",{value:r,configurable:!0}),"c");const $={level:"level",severity:"level",service:"service",svc:"service",src:"service",source:"service",flow:"flow",trace:"trace",request:"trace",category:"category",cat:"category",ms:"ms"},b={warn:"warning",err:"error"},x=/(-?)(?:([A-Za-z]+):)?(?:"([^"]*)"|(\S+))/g;export function parseLogQuery(e){const r=[],t=[];for(const s of e.matchAll(x)){const[o,n,m,L,w]=s,y=(L??w??"").trim(),v=m?$[m.toLowerCase()]:void 0;if(v&&y){const p=v==="level"?b[y.toLowerCase()]??y.toLowerCase():y;r.push({key:v,value:p,negate:n==="-"})}else o.trim()&&t.push(o.trim())}return{tokens:r,text:t.join(" ")}}a(parseLogQuery,"parseLogQuery"),c(parseLogQuery,"parseLogQuery"),u(parseLogQuery,"parseLogQuery"),i(parseLogQuery,"parseLogQuery"),f(parseLogQuery,"parseLogQuery");export function formatLogQuery(e){const r=f(t=>/\s/.test(t)?`"${t}"`:t,"quote");return[...e.tokens.map(t=>`${t.negate?"-":""}${t.key}:${r(t.value)}`),e.text].filter(Boolean).join(" ")}a(formatLogQuery,"formatLogQuery"),c(formatLogQuery,"formatLogQuery"),u(formatLogQuery,"formatLogQuery"),i(formatLogQuery,"formatLogQuery"),f(formatLogQuery,"formatLogQuery");function g(e,r){if(e===void 0)return!1;const t=/^(>=|<=|>|<|=)?\s*(\d+(?:\.\d+)?)$/.exec(r);if(!t)return!1;const s=Number(t[2]);switch(t[1]){case">":return e>s;case"<":return e<s;case"<=":return e<=s;case"=":return e===s;default:return e>=s}}a(g,"v"),c(g,"v"),u(g,"v"),i(g,"h"),f(g,"msMatches");function l(e,r){const t=r.value.toLowerCase();switch(r.key){case"level":return e.severity.toLowerCase()===t;case"service":return e.source.toLowerCase()===t;case"flow":return!!e.flowId&&e.flowId.toLowerCase().startsWith(t);case"trace":return!!e.requestId&&e.requestId.toLowerCase().startsWith(t);case"category":return e.category.toLowerCase()===t;case"ms":return g(e.durationMs,r.value)}}a(l,"f"),c(l,"f"),u(l,"l"),i(l,"i"),f(l,"tokenMatches");export function matchesLogQuery(e,r,t){const s=new Map;for(const o of r.tokens){if(o.negate){if(l(e,o))return!1;continue}const n=s.get(o.key);n?n.push(o):s.set(o.key,[o])}for(const o of s.values())if(!o.some(n=>l(e,n)))return!1;if(r.text){const o=`${e.title} ${e.message??""} ${e.source} ${e.flowId??""}`;return t?t(o):o.toLowerCase().includes(r.text.toLowerCase())}return!0}a(matchesLogQuery,"matchesLogQuery"),c(matchesLogQuery,"matchesLogQuery"),u(matchesLogQuery,"matchesLogQuery"),i(matchesLogQuery,"matchesLogQuery"),f(matchesLogQuery,"matchesLogQuery");
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var i=(e,t)=>l(e,"name",{value:t,configurable:!0});var f=Object.defineProperty,a=i((e,t)=>f(e,"name",{value:t,configurable:!0}),"i"),u=Object.defineProperty,c=a((e,t)=>u(e,"name",{value:t,configurable:!0}),"s");import{LENS_EVENT_SOURCE as S}from"./error-dismissal.js";export const METRICS_RESET="metrics-reset",METRICS_RESTORED="metrics-restored",METRICS_SCOPES=["sql","external"],MAX_METRICS_RESET_IDS=500,MAX_METRICS_RESET_ID_LENGTH=512,METRICS_RESET_IDS_PER_EVENT=64;const d=16*1024,p=c(e=>e==="sql"||e==="external","isScope"),E=c(e=>typeof e=="string"&&e.length>0&&e.length<=MAX_METRICS_RESET_ID_LENGTH,"isId");export function readMetricsReset(e){if(e.source!==S||!e.raw||typeof e.raw!="object")return;const t=e.raw,r=t.kind;if(r!==METRICS_RESET&&r!==METRICS_RESTORED)return;const n=t.scope;if(!p(n))return;let s;if(t.ids!==void 0&&(!Array.isArray(t.ids)||(s=[...new Set(t.ids.filter(E))].slice(0,METRICS_RESET_IDS_PER_EVENT),!s.length)))return;if(r===METRICS_RESTORED)return{kind:r,scope:n,...s?{ids:s}:{}};const o=t.at;if(!(typeof o!="number"||!Number.isFinite(o)))return{kind:r,scope:n,at:Math.min(o,e.timestamp),...s?{ids:s}:{}}}i(readMetricsReset,"readMetricsReset"),a(readMetricsReset,"readMetricsReset"),c(readMetricsReset,"readMetricsReset");export function metricsIdBatches(e){const t=[];let r=[],n=0;for(const s of new Set(e.filter(E)))r.length&&(r.length>=METRICS_RESET_IDS_PER_EVENT||n+s.length+3>d)&&(t.push(r),r=[],n=0),r.push(s),n+=s.length+3;return r.length&&t.push(r),t}i(metricsIdBatches,"metricsIdBatches"),a(metricsIdBatches,"metricsIdBatches"),c(metricsIdBatches,"metricsIdBatches");
1
+ "use strict";var f=Object.defineProperty;var n=(e,t)=>f(e,"name",{value:t,configurable:!0});var u=Object.defineProperty,o=n((e,t)=>u(e,"name",{value:t,configurable:!0}),"n"),S=Object.defineProperty,d=o((e,t)=>S(e,"name",{value:t,configurable:!0}),"i"),p=Object.defineProperty,l=d((e,t)=>p(e,"name",{value:t,configurable:!0}),"i"),R=Object.defineProperty,c=l((e,t)=>R(e,"name",{value:t,configurable:!0}),"s");import{LENS_EVENT_SOURCE as h}from"./error-dismissal.js";export const METRICS_RESET="metrics-reset",METRICS_RESTORED="metrics-restored",METRICS_SCOPES=["sql","external"],MAX_METRICS_RESET_IDS=500,MAX_METRICS_RESET_ID_LENGTH=512,METRICS_RESET_IDS_PER_EVENT=64;const m=16*1024,_=c(e=>e==="sql"||e==="external","isScope"),E=c(e=>typeof e=="string"&&e.length>0&&e.length<=MAX_METRICS_RESET_ID_LENGTH,"isId");export function readMetricsReset(e){if(e.source!==h||!e.raw||typeof e.raw!="object")return;const t=e.raw,r=t.kind;if(r!==METRICS_RESET&&r!==METRICS_RESTORED)return;const i=t.scope;if(!_(i))return;let s;if(t.ids!==void 0&&(!Array.isArray(t.ids)||(s=[...new Set(t.ids.filter(E))].slice(0,METRICS_RESET_IDS_PER_EVENT),!s.length)))return;if(r===METRICS_RESTORED)return{kind:r,scope:i,...s?{ids:s}:{}};const a=t.at;if(!(typeof a!="number"||!Number.isFinite(a)))return{kind:r,scope:i,at:Math.min(a,e.timestamp),...s?{ids:s}:{}}}n(readMetricsReset,"readMetricsReset"),o(readMetricsReset,"readMetricsReset"),d(readMetricsReset,"readMetricsReset"),l(readMetricsReset,"readMetricsReset"),c(readMetricsReset,"readMetricsReset");export function metricsIdBatches(e){const t=[];let r=[],i=0;for(const s of new Set(e.filter(E)))r.length&&(r.length>=METRICS_RESET_IDS_PER_EVENT||i+s.length+3>m)&&(t.push(r),r=[],i=0),r.push(s),i+=s.length+3;return r.length&&t.push(r),t}n(metricsIdBatches,"metricsIdBatches"),o(metricsIdBatches,"metricsIdBatches"),d(metricsIdBatches,"metricsIdBatches"),l(metricsIdBatches,"metricsIdBatches"),c(metricsIdBatches,"metricsIdBatches");
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var i=(e,n)=>u(e,"name",{value:n,configurable:!0});var f=Object.defineProperty,s=i((e,n)=>f(e,"name",{value:n,configurable:!0}),"i"),d=Object.defineProperty,r=s((e,n)=>d(e,"name",{value:n,configurable:!0}),"s");export const FINDING_RUN_KINDS=["operate","stop-launch","close-session","role","role-off","check","rule","flow","lesson"];export function findingLive(e){return e.state==="open"||e.state==="proposed"||e.state==="applied"}i(findingLive,"findingLive"),s(findingLive,"findingLive"),r(findingLive,"findingLive");export function findingRunsActions(e,n={}){return e.actions.some(o=>FINDING_RUN_KINDS.includes(o.kind)||o.kind==="issue"&&n.issuesFolder===!0)}i(findingRunsActions,"findingRunsActions"),s(findingRunsActions,"findingRunsActions"),r(findingRunsActions,"findingRunsActions");export function findingsForCheck(e,n,o){const c=`repo:${n}/team.${o}`;return e.filter(t=>findingLive(t)&&t.checks.includes(c))}i(findingsForCheck,"findingsForCheck"),s(findingsForCheck,"findingsForCheck"),r(findingsForCheck,"findingsForCheck");
1
+ "use strict";var u=Object.defineProperty;var i=(e,n)=>u(e,"name",{value:n,configurable:!0});var a=Object.defineProperty,r=i((e,n)=>a(e,"name",{value:n,configurable:!0}),"i"),l=Object.defineProperty,s=r((e,n)=>l(e,"name",{value:n,configurable:!0}),"i"),g=Object.defineProperty,t=s((e,n)=>g(e,"name",{value:n,configurable:!0}),"i"),p=Object.defineProperty,c=t((e,n)=>p(e,"name",{value:n,configurable:!0}),"s");export const FINDING_RUN_KINDS=["operate","stop-launch","close-session","role","role-off","check","rule","flow","lesson"];export function findingLive(e){return e.state==="open"||e.state==="proposed"||e.state==="applied"}i(findingLive,"findingLive"),r(findingLive,"findingLive"),s(findingLive,"findingLive"),t(findingLive,"findingLive"),c(findingLive,"findingLive");export function findingRunsActions(e,n={}){return e.actions.some(o=>FINDING_RUN_KINDS.includes(o.kind)||o.kind==="issue"&&n.issuesFolder===!0)}i(findingRunsActions,"findingRunsActions"),r(findingRunsActions,"findingRunsActions"),s(findingRunsActions,"findingRunsActions"),t(findingRunsActions,"findingRunsActions"),c(findingRunsActions,"findingRunsActions");export function findingsForCheck(e,n,o){const d=`repo:${n}/team.${o}`;return e.filter(f=>findingLive(f)&&f.checks.includes(d))}i(findingsForCheck,"findingsForCheck"),r(findingsForCheck,"findingsForCheck"),s(findingsForCheck,"findingsForCheck"),t(findingsForCheck,"findingsForCheck"),c(findingsForCheck,"findingsForCheck");